import {z} from 'zod' export type Amount = number; export type Currency = 'CAD' | 'USD'; export type Source = string; export type CreateTransferMinimalFields = {amount: Amount, currency: Currency, merchant: string, source: Source}; export type Type3dSecureAuthentication = {cardholder_authentication: string, electronic_commerce_indicator: string, transaction_id: string} | null; export type AdditionalBuyerCharges = {convenience_amount?: (number | null) | undefined, rent_surcharge_amount?: (number | null) | undefined, surcharge_amount?: (number | null) | undefined} | null; export type CustomerReferenceNumber = string; export type AdditionalPurchaseData = {customer_reference_number?: CustomerReferenceNumber | undefined, customs_duty_amount?: (number | null) | undefined, destination_country_code?: (string | null) | undefined, destination_postal_code?: (string | null) | undefined, discount_amount?: (number | null) | undefined, invoice_reference_number?: (string | null) | undefined, order_date?: ({day?: number | undefined, month?: number | undefined, year?: number | undefined} | null) | undefined, sales_tax?: (number | null) | undefined, sales_tax_finix_generated?: (number | null) | undefined, ship_from_postal_code?: (string | null) | undefined, shipping_amount?: (number | null) | undefined, tax_exempt?: boolean | undefined, item_data?: (Array<{amount_excluding_sales_tax?: number | undefined, amount_including_sales_tax?: number | undefined, commodity_code?: string | undefined, cost_per_unit?: number | undefined, item_description?: string | undefined, item_discount_amount?: number | undefined, merchant_product_code?: string | undefined, quantity?: number | undefined, unit_of_measure?: string | undefined, sales_tax_amount?: number | undefined, sales_tax_rate?: number | undefined}>) | undefined} | null; export type IdempotencyId = string | null; export type IpAddressV4 = string | null; export type AmountBreakdown = {subtotal_amount?: number | undefined, shipping_amount?: number | undefined, estimated_tax_amount?: number | undefined, additional_buyer_charges?: AdditionalBuyerCharges | undefined, discount_amount?: number | undefined, tip_amount?: number | undefined}; export type Items = Array<{description?: string | undefined, image_details?: ({primary_image_url?: string | undefined, alternative_image_urls?: Array | undefined} | null) | undefined, item_details?: ({commodity_code?: (string | null) | undefined, cost_per_unit?: (number | null) | undefined, merchant_product_code?: (string | null) | undefined, unit_of_measure?: (string | null) | undefined} | null) | undefined, name?: string | undefined, price_details?: ({sale_amount?: number | undefined, currency?: Currency | undefined, price_type?: ('PROMOTIONAL' | 'REGULAR') | undefined, regular_amount?: number | undefined, amount_excluding_sales_tax?: number | undefined, item_discount_amount?: number | undefined}) | undefined, quantity?: number | undefined}>; export type RequestedDeliveryMethods = Array<{type: 'EMAIL' | 'SMS' | 'PRINT', destinations: Array}>; export type SecurityCode = string | null; export type Tags = {[key: string]: unknown} | null; export type SplitTransfers = Array<{merchant?: string | undefined, amount?: number | undefined, fee?: (number | null) | undefined, tags?: (Tags | null) | undefined} | null> | null; export type CreateTransferAllFields = {'3d_secure_authentication'?: Type3dSecureAuthentication | undefined, additional_buyer_charges?: AdditionalBuyerCharges | undefined, additional_purchase_data?: AdditionalPurchaseData | undefined, amount: Amount, credential_on_file?: ({type?: ('RECURRING' | 'UNSCHEDULED') | undefined} | null) | undefined, currency: Currency, destination?: (string | null) | undefined, device?: (string | null) | undefined, fee_profile?: (string | null) | undefined, idempotency_id?: IdempotencyId | undefined, identity?: string | undefined, ip_address_v4?: IpAddressV4 | undefined, merchant: string | null, operation_key?: ('CARD_NOT_PRESENT_SALE' | 'CARD_NOT_PRESENT_UNREFERENCED_REFUND' | 'CARD_PRESENT_DEBIT' | 'CARD_PRESENT_SALE' | 'CARD_PRESENT_UNREFERENCED_REFUND' | 'MERCHANT_CREDIT_ADJUSTMENT' | 'MERCHANT_DEBIT_ADJUSTMENT' | 'PULL_FROM_CARD' | 'PUSH_TO_ACH' | 'PUSH_TO_CARD' | 'PUSH_TO_SAME_DAY_ACH' | 'SALE' | 'UNREFERENCED_REFUND' | null) | undefined, partial_authorization?: boolean | undefined, receipt_options?: ({additional_details?: (Array<{name: string, value: string}> | null) | undefined, amount_breakdown?: AmountBreakdown | undefined, items?: Items | undefined, requested_delivery_methods?: RequestedDeliveryMethods | undefined} | null) | undefined, security_code?: SecurityCode | undefined, source: string, split_transfers?: SplitTransfers | undefined, statement_descriptor?: (string | null) | undefined, supplemental_fee?: (number | null) | undefined, tags?: Tags | undefined}; export type CreateTransferCanadaEFT = {amount: Amount, currency: Currency, merchant: string, source: Source}; export type CreateTransfer3DSecure = {'3d_secure_authentication'?: Type3dSecureAuthentication | undefined, amount: Amount, currency: Currency, merchant: string, source: Source}; export type CreateTransfer3DSecureSession = {'3d_secure_session': string, amount: Amount, currency: Currency, merchant: string, source: Source}; export type FundsFlowType = 'GENERAL_PAYOUT' | 'ME_TO_ME' | 'GOVERNMENT' | null; export type CreateTransferBankPayout = {amount: Amount, currency: Currency, destination: string, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PUSH_TO_ACH'}; export type CreateTransferBankPayoutSameDay = {amount: Amount, currency: Currency, destination: string, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PUSH_TO_SAME_DAY_ACH'}; export type CreateTransferCardPayout = {amount: Amount, currency: Currency, destination: string, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PUSH_TO_CARD', pull_transfer_id?: (string | null) | undefined}; export type CreateTransferCardPresent = {amount: Amount, currency: Currency, device: string, identity?: string | undefined, operation_key: 'CARD_PRESENT_SALE', receipt_options?: ({additional_details?: (Array<{name: string, value: string}> | null) | undefined, amount_breakdown?: AmountBreakdown | undefined, items?: Items | undefined, requested_delivery_methods?: RequestedDeliveryMethods | undefined}) | undefined}; export type CreateTransferUnreferencedRefund = {amount: Amount, currency: Currency, device: string, operation_key: 'CARD_PRESENT_UNREFERENCED_REFUND' | null}; export type CreateTransferCardVerificationCheck = {amount: Amount, currency: Currency, merchant: string, security_code?: (string | null) | undefined, source: Source}; export type CreateTransferConvenienceFee = {additional_buyer_charges?: AdditionalBuyerCharges | undefined, amount: Amount, currency: Currency, merchant: string, source: Source}; export type CreateTransferDebitBankAccount = {amount: Amount, currency: Currency, merchant: string, source: Source}; export type CreateTransferFeeProfile = {amount: Amount, currency: Currency, fee_profile?: string | undefined, merchant: string, source: Source}; export type Country = 'ABW' | 'AFG' | 'AGO' | 'AIA' | 'ALA' | 'ALB' | 'AND' | 'ARE' | 'ARG' | 'ARM' | 'ASM' | 'ATA' | 'ATF' | 'ATG' | 'AUS' | 'AUT' | 'AZE' | 'BDI' | 'BEL' | 'BEN' | 'BES' | 'BFA' | 'BGD' | 'BGR' | 'BHR' | 'BHS' | 'BIH' | 'BLM' | 'BLR' | 'BLZ' | 'BMU' | 'BOL' | 'BRA' | 'BRB' | 'BRN' | 'BTN' | 'BVT' | 'BWA' | 'CAF' | 'CAN' | 'CCK' | 'CHE' | 'CHL' | 'CHN' | 'CIV' | 'CMR' | 'COD' | 'COG' | 'COK' | 'COL' | 'COM' | 'CPV' | 'CRI' | 'CUB' | 'CUW' | 'CXR' | 'CYM' | 'CYP' | 'CZE' | 'DEU' | 'DJI' | 'DMA' | 'DNK' | 'DOM' | 'DZA' | 'ECU' | 'EGY' | 'ERI' | 'ESH' | 'ESP' | 'EST' | 'ETH' | 'FIN' | 'FJI' | 'FLK' | 'FRA' | 'FRO' | 'FSM' | 'GAB' | 'GBR' | 'GEO' | 'GGY' | 'GHA' | 'GIB' | 'GIN' | 'GLP' | 'GMB' | 'GNB' | 'GNQ' | 'GRC' | 'GRD' | 'GRL' | 'GTM' | 'GUF' | 'GUM' | 'GUY' | 'HKG' | 'HMD' | 'HND' | 'HRV' | 'HTI' | 'HUN' | 'IDN' | 'IMN' | 'IND' | 'IOT' | 'IRL' | 'IRN' | 'IRQ' | 'ISL' | 'ISR' | 'ITA' | 'JAM' | 'JEY' | 'JOR' | 'JPN' | 'KAZ' | 'KEN' | 'KGZ' | 'KHM' | 'KIR' | 'KNA' | 'KOR' | 'KWT' | 'LAO' | 'LBN' | 'LBR' | 'LBY' | 'LCA' | 'LIE' | 'LKA' | 'LSO' | 'LTU' | 'LUX' | 'LVA' | 'MAC' | 'MAF' | 'MAR' | 'MCO' | 'MDA' | 'MDG' | 'MDV' | 'MEX' | 'MHL' | 'MKD' | 'MLI' | 'MLT' | 'MMR' | 'MNE' | 'MNG' | 'MNP' | 'MRT' | 'MSR' | 'MTQ' | 'MUS' | 'MWI' | 'MYS' | 'MYT' | 'NAM' | 'NCL' | 'NER' | 'NFK' | 'NGA' | 'NIC' | 'NIU' | 'NLD' | 'NOR' | 'NPL' | 'NRU' | 'NZL' | 'OMN' | 'PAK' | 'PAN' | 'PCN' | 'PER' | 'PHL' | 'PLW' | 'PNG' | 'POL' | 'PRI' | 'PRK' | 'PRT' | 'PRY' | 'PSE' | 'PYF' | 'QAT' | 'REU' | 'ROU' | 'RUS' | 'RWA' | 'SAU' | 'SDN' | 'SEN' | 'SGP' | 'SGS' | 'SHN' | 'SJM' | 'SLB' | 'SLE' | 'SLV' | 'SMR' | 'SOM' | 'SPM' | 'SRB' | 'SSD' | 'STP' | 'SUR' | 'SVK' | 'SVN' | 'SWE' | 'SWZ' | 'SXM' | 'SYC' | 'SYR' | 'TCA' | 'TCD' | 'TGO' | 'THA' | 'TJK' | 'TKL' | 'TKM' | 'TLS' | 'TON' | 'TTO' | 'TUN' | 'TUR' | 'TUV' | 'TWN' | 'TZA' | 'UGA' | 'UKR' | 'UMI' | 'URY' | 'USA' | 'UZB' | 'VAT' | 'VCT' | 'VEN' | 'VGB' | 'VIR' | 'VNM' | 'VUT' | 'WLF' | 'WSM' | 'XKX' | 'YEM' | 'ZAF' | 'ZMB' | 'ZWE' | null; export type Address = {line1: string | null, line2?: (string | null) | undefined, city: string | null, region: string | null, postal_code: string | null, country: Country}; export type AdditionalMotorVehicleRentalData = {motor_vehicle_rental_agreement_number?: (string | null) | undefined, customer_service_number?: (string | null) | undefined, extra_charge_details?: ({extra_mileage_amount?: (number | null) | undefined, fuel_amount?: (number | null) | undefined, insurance_amount?: (number | null) | undefined, late_return_amount?: (number | null) | undefined, one_way_service_fee_amount?: (number | null) | undefined, parking_violation_amount?: (number | null) | undefined} | null) | undefined, is_no_show?: (boolean | null) | undefined, number_of_days?: (number | null) | undefined, rental_rate?: (string | null) | undefined, renter_name?: (string | null) | undefined, pickup_address?: (Address | null) | undefined, pickup_date?: ({month?: number | undefined, day?: number | undefined, year?: number | undefined} | null) | undefined, return_address?: (Address | null) | undefined, return_date?: ({month?: number | undefined, day?: number | undefined, year?: number | undefined} | null) | undefined} | null; export type CreateTransferAutoRental = {additional_motor_vehicle_rental_data?: AdditionalMotorVehicleRentalData | undefined, amount: Amount, currency: Currency, idempotency_id?: IdempotencyId | undefined, merchant: string, source: Source, tags?: Tags | undefined}; export type AdditionalLodgingData = {check_in_date?: ({month?: number | undefined, day?: number | undefined, year?: number | undefined} | null) | undefined, check_out_date?: ({month?: number | undefined, day?: number | undefined, year?: number | undefined} | null) | undefined, customer_service_phone?: (string | null) | undefined, extra_charge_details?: ({restaurant_amount?: (number | null) | undefined, mini_bar_amount?: (number | null) | undefined, laundry_amount?: (number | null) | undefined, other_amount?: (number | null) | undefined, phone_amount?: (number | null) | undefined, gift_shop_amount?: (number | null) | undefined} | null) | undefined, hotel_agreement_number?: (string | null) | undefined, is_advance_deposit?: (boolean | null) | undefined, is_no_show?: (boolean | null) | undefined, number_of_nights?: (number | null) | undefined, property_phone?: (string | null) | undefined, room_rate?: (string | null) | undefined, room_tax?: (string | null) | undefined} | null; export type CreateTransferLodging = {additional_lodging_data?: AdditionalLodgingData | undefined, amount: Amount, currency: Currency, idempotency_id?: IdempotencyId | undefined, merchant: string, source: Source, tags?: Tags | undefined}; export type CreateTransferGaming = {amount: Amount, currency: Currency, ip_address_v4?: IpAddressV4 | undefined, merchant: string, source: Source}; export type StatementDescriptor = string | null; export type CreateTransferLvl2Processing = {additional_purchase_data?: AdditionalPurchaseData | undefined, amount: Amount, currency: Currency, merchant: string, source: Source, statement_descriptor?: StatementDescriptor | undefined, tags?: Tags | undefined}; export type CreateTransferLvl3Processing = {additional_purchase_data?: AdditionalPurchaseData | undefined, amount: Amount, currency: Currency, merchant: string, source: Source, statement_descriptor?: StatementDescriptor | undefined, tags?: Tags | undefined}; export type CreateTransferPartialAuthorization = {amount: Amount, currency: Currency, merchant: string, partial_authorization?: boolean | undefined, source: Source}; export type CreateTransferRecurringUnscheduled = {amount: Amount, credential_on_file?: ({type?: ('RECURRING' | 'UNSCHEDULED') | undefined}) | undefined, currency: Currency, merchant: string, source: Source, tags?: Tags | undefined}; export type CreateTransferRentSurcharge = {additional_buyer_charges?: AdditionalBuyerCharges | undefined, amount: Amount, currency: Currency, merchant: string, source: Source}; export type CreateTransferSplitTransaction = {amount: Amount, currency: Currency, merchant: string, source: Source, split_transfers?: SplitTransfers | undefined}; export type CreateTransferSurcharge = {additional_buyer_charges?: AdditionalBuyerCharges | undefined, amount: Amount, currency: Currency, merchant: string, source: Source}; export type CreateTransferMeToMePullCard = {amount: Amount, currency: Currency, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PULL_FROM_CARD', source: string}; export type CreateTransferMeToMePullBank = {amount: Amount, currency: Currency, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PULL_FROM_ACH', source: string}; export type CreateTransferMeToMePullBankSameDay = {amount: Amount, currency: Currency, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PULL_FROM_SAME_DAY_ACH', source: string}; export type CreateTransferMeToMePayoutCard = {amount: Amount, currency: Currency, destination: string, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PUSH_TO_CARD', pull_transfer_id: string | null}; export type CreateTransferMeToMePayoutBank = {amount: Amount, currency: Currency, destination: string, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PUSH_TO_ACH', pull_transfer_id: string | null}; export type CreateTransferMeToMePayoutBankSameDay = {amount: Amount, currency: Currency, destination: string, funds_flow_type?: FundsFlowType | undefined, operation_key: 'PUSH_TO_SAME_DAY_ACH', pull_transfer_id: string | null}; export type CreateApiTransfersArgs = {'Finix-Version'?: string | undefined, 'Content-Type'?: string | undefined, body: CreateTransferMinimalFields | CreateTransferAllFields | CreateTransferCanadaEFT | CreateTransfer3DSecure | CreateTransfer3DSecureSession | CreateTransferBankPayout | CreateTransferBankPayoutSameDay | CreateTransferCardPayout | CreateTransferCardPresent | CreateTransferUnreferencedRefund | CreateTransferCardVerificationCheck | CreateTransferConvenienceFee | CreateTransferDebitBankAccount | CreateTransferFeeProfile | CreateTransferAutoRental | CreateTransferLodging | CreateTransferGaming | CreateTransferLvl2Processing | CreateTransferLvl3Processing | CreateTransferPartialAuthorization | CreateTransferRecurringUnscheduled | CreateTransferRentSurcharge | CreateTransferSplitTransaction | CreateTransferSurcharge | CreateTransferMeToMePullCard | CreateTransferMeToMePullBank | CreateTransferMeToMePullBankSameDay | CreateTransferMeToMePayoutCard | CreateTransferMeToMePayoutBank | CreateTransferMeToMePayoutBankSameDay}; export type CreateApiTransfersOptions = {baseUrl?: string | undefined, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const id = z.string().min(1); export const createdAt = z.string(); export const updatedAt = z.string(); export const additionalBuyerCharges = z.object({convenience_amount: z.number().int().nullable().optional(), rent_surcharge_amount: z.number().int().nullable().optional(), surcharge_amount: z.number().int().nullable().optional()}).nullable(); export const additionalHealthcareData = z.object({clinic_amount: z.number().int().nullable().optional(), dental_amount: z.number().int().nullable().optional(), prescription_amount: z.number().int().nullable().optional(), vision_amount: z.number().int().nullable().optional()}).nullable(); export const additionalLodgingData = z.object({check_in_date: z.object({month: z.number().int().optional(), day: z.number().int().optional(), year: z.number().int().optional()}).nullable().optional(), check_out_date: z.object({month: z.number().int().optional(), day: z.number().int().optional(), year: z.number().int().optional()}).nullable().optional(), customer_service_phone: z.string().nullable().optional(), extra_charge_details: z.object({restaurant_amount: z.number().int().nullable().optional(), mini_bar_amount: z.number().int().nullable().optional(), laundry_amount: z.number().int().nullable().optional(), other_amount: z.number().int().nullable().optional(), phone_amount: z.number().int().nullable().optional(), gift_shop_amount: z.number().int().nullable().optional()}).nullable().optional(), hotel_agreement_number: z.string().nullable().optional(), is_advance_deposit: z.boolean().nullable().optional(), is_no_show: z.boolean().nullable().optional(), number_of_nights: z.number().int().nullable().optional(), property_phone: z.string().nullable().optional(), room_rate: z.string().nullable().optional(), room_tax: z.string().nullable().optional()}).nullable(); export const country = z.enum(["ABW", "AFG", "AGO", "AIA", "ALA", "ALB", "AND", "ARE", "ARG", "ARM", "ASM", "ATA", "ATF", "ATG", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BES", "BFA", "BGD", "BGR", "BHR", "BHS", "BIH", "BLM", "BLR", "BLZ", "BMU", "BOL", "BRA", "BRB", "BRN", "BTN", "BVT", "BWA", "CAF", "CAN", "CCK", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COK", "COL", "COM", "CPV", "CRI", "CUB", "CUW", "CXR", "CYM", "CYP", "CZE", "DEU", "DJI", "DMA", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI", "ESH", "ESP", "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "FRO", "FSM", "GAB", "GBR", "GEO", "GGY", "GHA", "GIB", "GIN", "GLP", "GMB", "GNB", "GNQ", "GRC", "GRD", "GRL", "GTM", "GUF", "GUM", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN", "IDN", "IMN", "IND", "IOT", "IRL", "IRN", "IRQ", "ISL", "ISR", "ITA", "JAM", "JEY", "JOR", "JPN", "KAZ", "KEN", "KGZ", "KHM", "KIR", "KNA", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", "LCA", "LIE", "LKA", "LSO", "LTU", "LUX", "LVA", "MAC", "MAF", "MAR", "MCO", "MDA", "MDG", "MDV", "MEX", "MHL", "MKD", "MLI", "MLT", "MMR", "MNE", "MNG", "MNP", "MRT", "MSR", "MTQ", "MUS", "MWI", "MYS", "MYT", "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NIU", "NLD", "NOR", "NPL", "NRU", "NZL", "OMN", "PAK", "PAN", "PCN", "PER", "PHL", "PLW", "PNG", "POL", "PRI", "PRK", "PRT", "PRY", "PSE", "PYF", "QAT", "REU", "ROU", "RUS", "RWA", "SAU", "SDN", "SEN", "SGP", "SGS", "SHN", "SJM", "SLB", "SLE", "SLV", "SMR", "SOM", "SPM", "SRB", "SSD", "STP", "SUR", "SVK", "SVN", "SWE", "SWZ", "SXM", "SYC", "SYR", "TCA", "TCD", "TGO", "THA", "TJK", "TKL", "TKM", "TLS", "TON", "TTO", "TUN", "TUR", "TUV", "TWN", "TZA", "UGA", "UKR", "UMI", "URY", "USA", "UZB", "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "XKX", "YEM", "ZAF", "ZMB", "ZWE"]).nullable(); export const address = z.object({line1: z.string().min(1).nullable(), line2: z.string().min(1).nullable().optional(), city: z.string().min(1).nullable(), region: z.string().min(1).nullable(), postal_code: z.string().min(1).nullable(), country: country}); export const additionalMotorVehicleRentalData = z.object({motor_vehicle_rental_agreement_number: z.string().nullable().optional(), customer_service_number: z.string().nullable().optional(), extra_charge_details: z.object({extra_mileage_amount: z.number().int().nullable().optional(), fuel_amount: z.number().int().nullable().optional(), insurance_amount: z.number().int().nullable().optional(), late_return_amount: z.number().int().nullable().optional(), one_way_service_fee_amount: z.number().int().nullable().optional(), parking_violation_amount: z.number().int().nullable().optional()}).nullable().optional(), is_no_show: z.boolean().nullable().optional(), number_of_days: z.number().int().nullable().optional(), rental_rate: z.string().nullable().optional(), renter_name: z.string().nullable().optional(), pickup_address: address.nullable().optional(), pickup_date: z.object({month: z.number().int().optional(), day: z.number().int().optional(), year: z.number().int().optional()}).nullable().optional(), return_address: address.nullable().optional(), return_date: z.object({month: z.number().int().optional(), day: z.number().int().optional(), year: z.number().int().optional()}).nullable().optional()}).nullable(); export const customerReferenceNumber = z.string().max(17); export const additionalPurchaseData = z.object({customer_reference_number: customerReferenceNumber.optional(), customs_duty_amount: z.number().int().nullable().optional(), destination_country_code: z.string().nullable().optional(), destination_postal_code: z.string().max(10).nullable().optional(), discount_amount: z.number().int().nullable().optional(), invoice_reference_number: z.string().max(15).nullable().optional(), order_date: z.object({day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().gte(1990).optional()}).nullable().optional(), sales_tax: z.number().int().nullable().optional(), sales_tax_finix_generated: z.number().int().nullable().optional(), ship_from_postal_code: z.string().max(10).nullable().optional(), shipping_amount: z.number().int().nullable().optional(), tax_exempt: z.boolean().optional(), item_data: z.array(z.object({amount_excluding_sales_tax: z.number().int().optional(), amount_including_sales_tax: z.number().int().optional(), commodity_code: z.string().max(12).optional(), cost_per_unit: z.number().int().optional(), item_description: z.string().max(25).optional(), item_discount_amount: z.number().int().optional(), merchant_product_code: z.string().max(12).optional(), quantity: z.number().gte(1).lte(99).optional(), unit_of_measure: z.string().max(3).optional(), sales_tax_amount: z.number().int().optional(), sales_tax_rate: z.number().optional()})).optional()}).nullable(); export const amount = z.number().int(); export const tags = z.record(z.string(), z.unknown()).nullable(); export const currency = z.enum(["CAD", "USD"]); export const transfersAuthorizationsCreatedVia = z.enum(["API", "CARD_PRESENT_ANDROID_APP", "CARD_PRESENT_ANDROID_APP_MANUAL_ENTRY", "CARD_PRESENT_ANDROID_D135_SDK", "CARD_PRESENT_DEVICE_READER_SDK", "CARD_PRESENT_IOS_APP", "CARD_PRESENT_IOS_APP_MANUAL_ENTRY", "CARD_PRESENT_IOS_D135_SDK", "CARD_PRESENT_IOS_TAP_TO_PAY", "CARD_PRESENT_IOS_TAP_TO_PAY_SDK", "CARD_PRESENT_SEMI_INTEGRATED_API", "CARD_PRESENT_STANDALONE", "CARD_PRESENT_STANDALONE_MANUAL_ENTRY", "CHECKOUT_FORM", "CYBERSOURCE", "DEVICE_ORDER", "PAYMENT_LINK", "PAYOUT_LINK", "PLUGIN_ADMOJI", "PLUGIN_CHECKOUT_CHAMP", "PLUGIN_FYNTEK", "PLUGIN_GAMBLE_ID", "PLUGIN_GAMMA_SWEEP", "PLUGIN_GR4VY", "PLUGIN_HYPERSWITCH", "PLUGIN_LACORE", "PLUGIN_PAYSIGHT", "PLUGIN_PRYZR", "PLUGIN_SERVMAN", "PLUGIN_SOAP_PAY", "PLUGIN_STICKYIO", "PLUGIN_TAGADA", "PLUGIN_WOO_COMMERCE", "PLUGIN_VRIO", "SUBSCRIPTION", "UNKNOWN", "VIRTUAL_TERMINAL"]); export const failureCode = z.string().nullable(); export const failureMessage = z.string().nullable(); export const feeTransfer = z.number().int(); export const fundsFlowType = z.enum(["GENERAL_PAYOUT", "ME_TO_ME", "GOVERNMENT"]).nullable(); export const idempotencyId = z.string().nullable(); export const statementDescriptor = z.string().max(20).nullable(); export const applicationLink = z.object({href: z.string().min(1).optional()}); export const self = z.object({href: z.string().min(1).optional()}); export const transfer = z.object({id: id.optional(), created_at: createdAt.optional(), updated_at: updatedAt.optional(), "3d_secure_session": z.string().nullable().optional(), additional_buyer_charges: additionalBuyerCharges.optional(), additional_healthcare_data: additionalHealthcareData.optional(), additional_lodging_data: additionalLodgingData.optional(), additional_motor_vehicle_rental_data: additionalMotorVehicleRentalData.optional(), additional_purchase_data: additionalPurchaseData.optional(), address_verification: z.enum(["POSTAL_CODE_AND_STREET_MATCH", "STREET_MATCH", "POSTAL_CODE_MATCH", "NO_ADDRESS", "NO_MATCH", "NOT_SUPPORTED", "UNKNOWN"]).nullable().optional(), amount: amount.optional(), amount_requested: z.number().int().optional(), application: z.string().min(1).optional(), bank_return_details: z.object({reason_code: z.string().optional(), reason_message: z.string().optional(), reason_title: z.string().optional()}).nullable().optional(), card_present_details: z.object({approval_code: z.string().nullable().optional(), brand: z.string().nullable().optional(), emv_data: z.object({application_identifier: z.string().nullable().optional(), application_label: z.string().nullable().optional(), application_preferred_name: z.string().nullable().optional(), application_transaction_counter: z.string().nullable().optional(), cryptogram: z.string().nullable().optional(), issuer_code_table_index: z.string().nullable().optional(), network_emv_response: z.string().nullable().optional(), pin_verified: z.boolean().optional(), tags: tags.optional()}).nullable().optional(), entry_mode: z.enum(["UNKNOWN", "SWIPED", "CONTACTLESS", "CHIP_ENTRY"]).nullable().optional(), masked_account_number: z.string().nullable().optional(), name: z.string().nullable().optional(), digital_signature_file_id: z.string().nullable().optional(), payment_type: z.string().nullable().optional()}).nullable().optional(), currency: currency.optional(), created_via: transfersAuthorizationsCreatedVia.optional(), destination: z.string().nullable().optional(), device: z.string().optional(), externally_funded: z.string().optional(), expires_at: z.string().nullable().optional(), failure_code: failureCode.optional(), failure_message: failureMessage.optional(), fee: feeTransfer.optional(), fee_profile: z.string().optional(), funds_flow_type: fundsFlowType.optional(), idempotency_id: idempotencyId.optional(), ip_address_details: z.object({}).nullable().optional(), merchant: z.string().optional(), merchant_identity: z.string().optional(), messages: z.array(z.string()).nullable().optional(), network_details: z.object({brand: z.string().optional(), authorization_code: z.string().optional(), acquirer_reference_number: z.string().nullable().optional()}).nullable().optional(), operation_key: z.enum(["CARD_NOT_PRESENT_CAPTURE", "CARD_NOT_PRESENT_REFUND", "CARD_NOT_PRESENT_SALE", "CARD_NOT_PRESENT_UNREFERENCED_REFUND", "CARD_PRESENT_AUTHORIZATION", "CARD_PRESENT_DEBIT", "CARD_PRESENT_SALE", "CARD_PRESENT_UNREFERENCED_REFUND", "INSTANT_APPLICATION_FUNDING_PULL_FROM_ACH", "INSTANT_APPLICATION_FUNDING_PULL_FROM_CARD", "INSTANT_APPLICATION_FUNDING_PULL_FROM_FED_NOW", "INSTANT_APPLICATION_FUNDING_PULL_FROM_SAME_DAY_ACH", "INSTANT_APPLICATION_FUNDING_PUSH_TO_ACH", "INSTANT_APPLICATION_FUNDING_PUSH_TO_CARD", "INSTANT_APPLICATION_FUNDING_PUSH_TO_FED_NOW", "INSTANT_APPLICATION_FUNDING_PUSH_TO_SAME_DAY_ACH", "INSTANT_MERCHANT_FUNDING_PULL_FROM_ACH", "INSTANT_MERCHANT_FUNDING_PULL_FROM_FED_NOW", "INSTANT_MERCHANT_FUNDING_PULL_FROM_SAME_DAY_ACH", "INSTANT_MERCHANT_FUNDING_PUSH_TO_ACH", "INSTANT_MERCHANT_FUNDING_PUSH_TO_CARD", "INSTANT_MERCHANT_FUNDING_PUSH_TO_FED_NOW", "INSTANT_MERCHANT_FUNDING_PUSH_TO_SAME_DAY_ACH", "MERCHANT_CREDIT_ADJUSTMENT", "MERCHANT_DEBIT_ADJUSTMENT", "PULL_FROM_ACH", "PULL_FROM_CARD", "PULL_FROM_SAME_DAY_ACH", "PUSH_TO_ACH", "PUSH_TO_CARD", "PUSH_TO_SAME_DAY_ACH", "REFUND_MERCHANT_CREDIT_ADJUSTMENT", "REFUND_MERCHANT_DEBIT_ADJUSTMENT", "SALE", "STANDARD_APPLICATION_FUNDING_PULL_FROM_ACH", "STANDARD_APPLICATION_FUNDING_PULL_FROM_CARD", "STANDARD_APPLICATION_FUNDING_PULL_FROM_SAME_DAY_ACH", "STANDARD_APPLICATION_FUNDING_PUSH_TO_ACH", "STANDARD_APPLICATION_FUNDING_PUSH_TO_CARD", "STANDARD_APPLICATION_FUNDING_PUSH_TO_SAME_DAY_ACH", "STANDARD_MERCHANT_FUNDING_PULL_FROM_ACH", "STANDARD_MERCHANT_FUNDING_PULL_FROM_CARD", "STANDARD_MERCHANT_FUNDING_PULL_FROM_SAME_DAY_ACH", "STANDARD_MERCHANT_FUNDING_PUSH_TO_ACH", "STANDARD_MERCHANT_FUNDING_PUSH_TO_CARD", "STANDARD_MERCHANT_FUNDING_PUSH_TO_SAME_DAY_ACH", "UNREFERENCED_REFUND"]).nullable().optional(), parent_transfer: z.string().nullable().optional(), parent_transfer_trace_id: z.string().nullable().optional(), processed_at: z.string().nullable().optional(), pull_transfer_id: z.string().nullable().optional(), raw: z.union([z.object({}).nullable(), z.string().nullable()]).optional(), ready_to_settle_at: z.string().nullable().optional(), receipt_last_printed_at: z.string().nullable().optional(), security_code_verification: z.enum(["MATCHED", "UNKNOWN", "UNMATCHED"]).nullable().optional(), source: z.string().nullable().optional(), split_transfers: z.array(z.string()).optional(), state: z.enum(["CANCELED", "PENDING", "FAILED", "SUCCEEDED", "UNKNOWN", "RETURNED"]).optional(), statement_descriptor: statementDescriptor.optional(), subtype: z.enum(["API", "DISPUTE", "MERCHANT_CREDIT", "MERCHANT_CREDIT_ADJUSTMENT", "MERCHANT_DEBIT", "MERCHANT_DEBIT_ADJUSTMENT", "PLATFORM_CREDIT", "PLATFORM_CREDIT_ADJUSTMENT", "PLATFORM_DEBIT", "PLATFORM_DEBIT_ADJUSTMENT", "REFUND_MERCHANT_CREDIT_ADJUSTMENT", "REFUND_MERCHANT_DEBIT_ADJUSTMENT", "SETTLEMENT_MERCHANT", "SETTLEMENT_NOOP", "SETTLEMENT_PARTNER", "SETTLEMENT_PLATFORM", "SPLIT_PAYOUT", "SPLIT_PAYOUT_ADJUSTMENT", "SYSTEM"]).optional(), supplemental_fee: z.string().nullable().optional(), tags: tags.optional(), tip_amount: z.number().int().nullable().optional(), trace_id: z.string().nullable().optional(), type: z.enum(["DEBIT", "CREDIT", "REVERSAL", "ADJUSTMENT", "DISPUTE", "RESERVE", "SETTLEMENT", "UNKNOWN"]).optional(), third_party_details: z.object({external_trace_id: z.string().nullable().optional(), type: z.literal("CYBERSOURCE").nullable().optional()}).nullable().optional(), _links: z.object({application: applicationLink.optional(), destination: z.object({href: z.string().optional()}).optional(), device: z.object({href: z.string().optional()}).optional(), disputes: z.object({href: z.string().optional()}).optional(), fee_profile: z.object({href: z.string().optional()}).optional(), fees: z.object({href: z.string().optional()}).optional(), merchant_identity: z.object({href: z.string().optional()}).optional(), payment_instruments: z.object({href: z.string().optional()}).optional(), disputed_transfer: z.object({href: z.string().optional()}).optional(), parent: z.object({href: z.string().optional()}).optional(), reversals: z.object({href: z.string().optional()}).optional(), self: self.optional(), source: z.object({href: z.string().optional()}).optional()}).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create a Transfer * * POST /transfers */ export const createApiTransfers = async (args: CreateApiTransfersArgs, options?: CreateApiTransfersOptions) => { const {baseUrl = "https://finix.sandbox-payments-api.com", fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Finix-Version'] != null) headers.set("Finix-Version", String(args['Finix-Version'])) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/transfers${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 validateResponse(transfer, await res.json()) };