export type ThreeDeeEssInput = {enabled?: boolean | undefined}; export type CustomerAddressDetails = {addressDetailsFields?: Record | undefined, city?: string | undefined, country?: string | undefined, firstName?: string | undefined, lastName?: string | undefined, lineOne?: string | undefined, lineTwo?: string | undefined, postalCode?: string | undefined, region?: string | undefined}; export type CustomerAddressInput = {addressDetails?: CustomerAddressDetails | undefined, type?: ('BILLING' | 'SHIPPING' | 'RESIDENCE') | undefined}; export type CustomerName = {firstName?: string | undefined, lastName?: string | undefined}; export type JSONB = unknown; export type CustomerInput = {addresses?: Array | undefined, billingAddress?: CustomerAddressInput | undefined, billingAddressDetails?: CustomerAddressDetails | undefined, email?: string | undefined, externalId?: string | undefined, id?: string | undefined, name?: CustomerName | undefined, nameEmpty?: boolean | undefined, nameJSONB?: JSONB | undefined, nameOrEmptyString?: string | undefined, nameOrNull?: string | undefined, phone?: string | undefined, residenceAddress?: CustomerAddressInput | undefined, residenceAddressDetails?: CustomerAddressDetails | undefined, shippingAddress?: CustomerAddressInput | undefined, shippingAddressDetails?: CustomerAddressDetails | undefined}; export type CardExpiration = {month?: number | undefined, year?: number | undefined}; export type Name = {firstName: string, lastName: string}; export type PaymentMethodDetails = {cvc: string, expiration?: CardExpiration | undefined, name?: string | undefined, number: string} | {accountNumber: string, accountType: 'BUSINESS_CHECKING' | 'CHECKING' | 'SAVINGS', name?: Name | undefined, routingNumber: string} | {meldPaymentToken: string}; export type PaymentMethodInput = {details: PaymentMethodDetails, type: 'ACH' | 'CARD' | 'MELD_PAYMENT_TOKEN' | 'PLAID_TRANSFER_AUTHORIZATION'}; export type PaymentTransactionRequest = {'3ds'?: ThreeDeeEssInput | undefined, capture?: boolean | undefined, customer?: CustomerInput | undefined, customerId?: string | undefined, description?: string | undefined, externalCustomerId?: string | undefined, nonce?: string | undefined, paymentMethod?: PaymentMethodInput | undefined, serviceProvider?: ('AUTHORIZENET' | 'BRAINTREE' | 'CHECKOUT' | 'CIRCLE' | 'NMI' | 'STRIPE') | undefined, serviceProviderDetails?: {[key: string]: unknown} | undefined, sourceAmount: string, sourceCurrencyCode: string}; export type CreateApiPaymentsTransactionsArgs = {'X-Idempotency-Key'?: string | undefined, 'Meld-Passthrough-Reference'?: string | undefined, 'Meld-Passthrough-Key-Id'?: string | undefined, 'Meld-Passthrough-Key-Public'?: string | undefined, 'Meld-Passthrough-Key-Private'?: string | undefined, 'Meld-Passthrough-Oauth'?: string | undefined, body: PaymentTransactionRequest}; export type CreateApiPaymentsTransactionsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a payment transaction * * POST /payments/transactions */ export const createApiPaymentsTransactions = async (args: CreateApiPaymentsTransactionsArgs, options?: CreateApiPaymentsTransactionsOptions) => { const {baseUrl = "https://api-sb.meld.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args['X-Idempotency-Key'] != null) headers.set("X-Idempotency-Key", String(args['X-Idempotency-Key'])) if (args['Meld-Passthrough-Reference'] != null) headers.set("Meld-Passthrough-Reference", String(args['Meld-Passthrough-Reference'])) if (args['Meld-Passthrough-Key-Id'] != null) headers.set("Meld-Passthrough-Key-Id", String(args['Meld-Passthrough-Key-Id'])) if (args['Meld-Passthrough-Key-Public'] != null) headers.set("Meld-Passthrough-Key-Public", String(args['Meld-Passthrough-Key-Public'])) if (args['Meld-Passthrough-Key-Private'] != null) headers.set("Meld-Passthrough-Key-Private", String(args['Meld-Passthrough-Key-Private'])) if (args['Meld-Passthrough-Oauth'] != null) headers.set("Meld-Passthrough-Oauth", String(args['Meld-Passthrough-Oauth'])) if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/payments/transactions${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };