import {z} from 'zod' export type CountryAlpha2 = 'AF' | 'AX' | 'AL' | 'DZ' | 'AS' | 'AD' | 'AO' | 'AI' | 'AQ' | 'AG' | 'AR' | 'AM' | 'AW' | 'AU' | 'AT' | 'AZ' | 'BS' | 'BH' | 'BD' | 'BB' | 'BY' | 'BE' | 'BZ' | 'BJ' | 'BM' | 'BT' | 'BO' | 'BQ' | 'BA' | 'BW' | 'BV' | 'BR' | 'IO' | 'BN' | 'BG' | 'BF' | 'BI' | 'KH' | 'CM' | 'CA' | 'CV' | 'KY' | 'CF' | 'TD' | 'CL' | 'CN' | 'CX' | 'CC' | 'CO' | 'KM' | 'CG' | 'CD' | 'CK' | 'CR' | 'CI' | 'HR' | 'CU' | 'CW' | 'CY' | 'CZ' | 'DK' | 'DJ' | 'DM' | 'DO' | 'EC' | 'EG' | 'SV' | 'GQ' | 'ER' | 'EE' | 'ET' | 'FK' | 'FO' | 'FJ' | 'FI' | 'FR' | 'GF' | 'PF' | 'TF' | 'GA' | 'GM' | 'GE' | 'DE' | 'GH' | 'GI' | 'GR' | 'GL' | 'GD' | 'GP' | 'GU' | 'GT' | 'GG' | 'GN' | 'GW' | 'GY' | 'HT' | 'HM' | 'VA' | 'HN' | 'HK' | 'HU' | 'IS' | 'IN' | 'ID' | 'IR' | 'IQ' | 'IE' | 'IM' | 'IL' | 'IT' | 'JM' | 'JP' | 'JE' | 'JO' | 'KZ' | 'KE' | 'KI' | 'KP' | 'KR' | 'KW' | 'KG' | 'LA' | 'LV' | 'LB' | 'LS' | 'LR' | 'LY' | 'LI' | 'LT' | 'LU' | 'MO' | 'MK' | 'MG' | 'MW' | 'MY' | 'MV' | 'ML' | 'MT' | 'MH' | 'MQ' | 'MR' | 'MU' | 'YT' | 'MX' | 'FM' | 'MD' | 'MC' | 'MN' | 'ME' | 'MS' | 'MA' | 'MZ' | 'MM' | 'NA' | 'NR' | 'NP' | 'NL' | 'NC' | 'NZ' | 'NI' | 'NE' | 'NG' | 'NU' | 'NF' | 'MP' | 'NO' | 'OM' | 'PK' | 'PW' | 'PS' | 'PA' | 'PG' | 'PY' | 'PE' | 'PH' | 'PN' | 'PL' | 'PT' | 'PR' | 'QA' | 'RE' | 'RO' | 'RU' | 'RW' | 'BL' | 'SH' | 'KN' | 'LC' | 'MF' | 'PM' | 'VC' | 'WS' | 'SM' | 'ST' | 'SA' | 'SN' | 'RS' | 'SC' | 'SL' | 'SG' | 'SX' | 'SK' | 'SI' | 'SB' | 'SO' | 'ZA' | 'GS' | 'SS' | 'ES' | 'LK' | 'SD' | 'SR' | 'SJ' | 'SZ' | 'SE' | 'CH' | 'SY' | 'TW' | 'TJ' | 'TZ' | 'TH' | 'TL' | 'TG' | 'TK' | 'TO' | 'TT' | 'TN' | 'TR' | 'TM' | 'TC' | 'TV' | 'UG' | 'UA' | 'AE' | 'GB' | 'UM' | 'UY' | 'UZ' | 'VU' | 'VE' | 'VN' | 'VG' | 'VI' | 'WF' | 'EH' | 'YE' | 'ZM' | 'ZW' | 'US'; export type Currency = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STD' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'UYU' | 'UZS' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XCD' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL'; export type CardNetwork = 'Visa' | 'Mastercard' | 'AmericanExpress' | 'JCB' | 'DinersClub' | 'Discover' | 'CartesBancaires' | 'UnionPay' | 'Interac' | 'RuPay' | 'Maestro' | 'Star' | 'Pulse' | 'Accel' | 'Nyce' | 'Prop' | 'PrivateLabel' | 'Dinacard'; export type GetApiAccountPaymentMethodsArgs = {client_secret?: (string | null) | undefined, accepted_countries?: (Array | null) | undefined, accepted_currencies?: (Array | null) | undefined, amount?: (number | null) | undefined, recurring_enabled?: (boolean | null) | undefined, installment_payment_enabled?: (boolean | null) | undefined, limit?: (number | null) | undefined, card_networks?: (Array | null) | undefined}; export type GetApiAccountPaymentMethodsOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const currency = z.enum(["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLE", "SLL", "SOS", "SRD", "SSP", "STD", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VES", "VND", "VUV", "WST", "XAF", "XCD", "XOF", "XPF", "YER", "ZAR", "ZMW", "ZWL"]); export const paymentMethod = z.enum(["card", "card_redirect", "pay_later", "wallet", "bank_redirect", "bank_transfer", "crypto", "bank_debit", "reward", "real_time_payment", "upi", "voucher", "gift_card", "open_banking", "mobile_payment", "network_token"]); export const cardNetwork = z.enum(["Visa", "Mastercard", "AmericanExpress", "JCB", "DinersClub", "Discover", "CartesBancaires", "UnionPay", "Interac", "RuPay", "Maestro", "Star", "Pulse", "Accel", "Nyce", "Prop", "PrivateLabel", "Dinacard"]); export const minorUnit = z.number().int(); export const surchargePercentage = z.object({percentage: z.number()}); export const surchargeResponse = z.discriminatedUnion("type", [z.object({type: z.literal("fixed"), value: minorUnit}), z.object({type: z.literal("rate"), value: surchargePercentage})]); export const surchargeDetailsResponse = z.object({surcharge: surchargeResponse, tax_on_surcharge: surchargePercentage.nullable().optional(), display_surcharge_amount: z.number(), display_tax_on_surcharge_amount: z.number(), display_total_surcharge_amount: z.number()}); export const cardNetworkTypes = z.object({card_network: cardNetwork.nullable().optional(), surcharge_details: surchargeDetailsResponse.nullable().optional(), eligible_connectors: z.array(z.string())}); export const paymentMethodType = z.enum(["ach", "affirm", "afterpay_clearpay", "alfamart", "ali_pay", "ali_pay_hk", "alma", "amazon_pay", "paysera", "apple_pay", "atome", "bacs", "bancontact_card", "becs", "benefit", "bizum", "blik", "bluecode", "boleto", "bca_bank_transfer", "bni_va", "breadpay", "bri_va", "bhn_card_network", "card_redirect", "cimb_va", "classic", "credit", "crypto_currency", "cashapp", "dana", "danamon_va", "debit", "duit_now", "efecty", "eft", "eft_debit_order", "eps", "flexiti", "fps", "evoucher", "giropay", "givex", "google_pay", "go_pay", "gcash", "ideal", "interac", "indomaret", "klarna", "kakao_pay", "local_bank_redirect", "mandiri_va", "knet", "mb_way", "mobile_pay", "momo", "momo_atm", "multibanco", "online_banking_thailand", "online_banking_czech_republic", "online_banking_finland", "online_banking_fpx", "online_banking_poland", "online_banking_slovakia", "oxxo", "pago_efectivo", "permata_bank_transfer", "open_banking_uk", "pay_bright", "payjustnow", "paypal", "paze", "pix", "pix_key", "pix_emv", "pix_qr", "pix_automatico_qr", "pix_automatico_push", "pay_safe_card", "przelewy24", "prompt_pay", "pse", "qris", "red_compra", "red_pagos", "samsung_pay", "sepa", "sepa_bank_transfer", "sepa_guarenteed_debit", "skrill", "sofort", "swish", "touch_n_go", "trustly", "twint", "upi_collect", "upi_intent", "upi_qr", "vipps", "viet_qr", "venmo", "walley", "we_chat_pay", "seven_eleven", "lawson", "mini_stop", "family_mart", "seicomart", "pay_easy", "local_bank_transfer", "mifinity", "open_banking_pis", "direct_carrier_billing", "instant_bank_transfer", "instant_bank_transfer_finland", "instant_bank_transfer_poland", "revolut_pay", "indonesian_bank_transfer", "open_banking", "network_token"]); export const fieldType = z.union([z.literal("user_card_number"), z.literal("user_gift_card_number"), z.literal("user_card_expiry_month"), z.literal("user_card_expiry_year"), z.literal("user_card_cvc"), z.literal("user_gift_card_pin"), z.literal("user_card_network"), z.literal("user_full_name"), z.literal("user_email_address"), z.literal("user_phone_number"), z.literal("user_phone_number_country_code"), z.object({user_country: z.object({options: z.array(z.string())})}), z.object({user_currency: z.object({options: z.array(z.string())})}), z.literal("user_crypto_currency_network"), z.literal("user_billing_name"), z.literal("user_address_line1"), z.literal("user_address_line2"), z.literal("user_address_city"), z.literal("user_address_pincode"), z.literal("user_address_state"), z.object({user_address_country: z.object({options: z.array(z.string())})}), z.literal("user_shipping_name"), z.literal("user_shipping_address_line1"), z.literal("user_shipping_address_line2"), z.literal("user_shipping_address_city"), z.literal("user_shipping_address_pincode"), z.literal("user_shipping_address_state"), z.object({user_shipping_address_country: z.object({options: z.array(z.string())})}), z.object({user_document_type: z.object({options: z.array(z.string())})}), z.literal("user_social_security_number"), z.literal("user_blik_code"), z.literal("user_bank"), z.object({user_bank_options: z.object({options: z.array(z.string())})}), z.literal("user_bank_account_number"), z.literal("user_source_bank_account_id"), z.literal("user_destination_bank_account_id"), z.literal("text"), z.object({drop_down: z.object({options: z.array(z.string())})}), z.literal("user_date_of_birth"), z.literal("user_vpa_id"), z.object({language_preference: z.object({options: z.array(z.string())})}), z.literal("user_pix_key"), z.literal("user_cpf"), z.literal("user_cnpj"), z.literal("user_iban"), z.literal("user_bsb_number"), z.literal("user_bank_sort_code"), z.literal("user_bank_routing_number"), z.object({user_bank_type: z.object({options: z.array(z.string())})}), z.literal("user_bank_account_holder_name"), z.literal("user_msisdn"), z.literal("user_client_identifier"), z.literal("order_details_product_name"), z.literal("user_branch_code"), z.literal("user_bank_identifier"), z.literal("user_pix_account_number")]); export const requiredFieldInfo = z.object({required_field: z.string(), display_name: z.string(), field_type: fieldType, value: z.string().nullable().optional()}); export const bankNames = z.enum(["absa", "american_express", "affin_bank", "agro_bank", "alliance_bank", "am_bank", "bank_of_america", "bank_of_china", "bank_islam", "bank_muamalat", "bank_rakyat", "bank_simpanan_nasional", "barclays", "blik_p_s_p", "capital_one", "chase", "citi", "cimb_bank", "discover", "navy_federal_credit_union", "pentagon_federal_credit_union", "synchrony_bank", "wells_fargo", "abn_amro", "asn_bank", "bunq", "handelsbanken", "hong_leong_bank", "hsbc_bank", "ing", "knab", "kuwait_finance_house", "moneyou", "rabobank", "regiobank", "revolut", "sns_bank", "triodos_bank", "van_lanschot", "arzte_und_apotheker_bank", "austrian_anadi_bank_ag", "bank_austria", "bank99_ag", "bankhaus_carl_spangler", "bankhaus_schelhammer_und_schattera_ag", "bank_millennium", "bank_p_e_k_a_o_s_a", "bawag_psk_ag", "bks_bank_ag", "brull_kallmus_bank_ag", "btv_vier_lander_bank", "capital_bank_grawe_gruppe_ag", "ceska_sporitelna", "dolomitenbank", "easybank_ag", "e_platby_v_u_b", "erste_bank_und_sparkassen", "friesland_bank", "hypo_alpeadriabank_international_ag", "hypo_noe_lb_fur_niederosterreich_u_wien", "hypo_oberosterreich_salzburg_steiermark", "hypo_tirol_bank_ag", "hypo_vorarlberg_bank_ag", "hypo_bank_burgenland_aktiengesellschaft", "komercni_banka", "m_bank", "marchfelder_bank", "maybank", "oberbank_ag", "osterreichische_arzte_und_apothekerbank", "ocbc_bank", "pay_with_i_n_g", "place_z_i_p_k_o", "platnosc_online_karta_platnicza", "posojilnica_bank_e_gen", "postova_banka", "public_bank", "raiffeisen_bankengruppe_osterreich", "rhb_bank", "schelhammer_capital_bank_ag", "standard_chartered_bank", "schoellerbank_ag", "sparda_bank_wien", "sporo_pay", "santander_przelew24", "tatra_pay", "viamo", "volksbank_gruppe", "volkskreditbank_ag", "vr_bank_braunau", "uob_bank", "pay_with_alior_bank", "banki_spoldzielcze", "pay_with_inteligo", "b_n_p_paribas_poland", "bank_nowy_s_a", "credit_agricole", "pay_with_b_o_s", "pay_with_citi_handlowy", "pay_with_plus_bank", "toyota_bank", "velo_bank", "e_transfer_pocztowy24", "plus_bank", "etransfer_pocztowy24", "banki_spbdzielcze", "bank_nowy_bfg_sa", "getin_bank", "blik", "noble_pay", "idea_bank", "envelo_bank", "nest_przelew", "mbank_mtransfer", "inteligo", "pbac_z_ipko", "bnp_paribas", "bank_pekao_sa", "volkswagen_bank", "alior_bank", "boz", "bangkok_bank", "krungsri_bank", "krung_thai_bank", "the_siam_commercial_bank", "kasikorn_bank", "open_bank_success", "open_bank_failure", "open_bank_cancelled", "aib", "bank_of_scotland", "danske_bank", "first_direct", "first_trust", "halifax", "lloyds", "monzo", "nat_west", "nationwide_bank", "royal_bank_of_scotland", "starling", "tsb_bank", "tesco_bank", "ulster_bank", "yoursafe", "n26", "nationale_nederlanden"]); export const responsePaymentMethodTypes = z.union([z.object({card_networks: z.array(cardNetworkTypes), payment_method_type: paymentMethod, payment_method_subtype: paymentMethodType, required_fields: z.array(requiredFieldInfo)}).nullable(), z.object({bank_names: bankNames, payment_method_type: paymentMethod, payment_method_subtype: paymentMethodType, required_fields: z.array(requiredFieldInfo)}).nullable()]); export const responsePaymentMethodsEnabled = z.object({payment_method: paymentMethod, payment_method_types: z.array(responsePaymentMethodTypes)}); export const mandateAmountData = z.object({amount: z.number().int(), currency: currency, start_date: z.string().nullable().optional(), end_date: z.string().nullable().optional(), metadata: z.object({}).nullable().optional()}); export const mandateType = z.union([z.object({single_use: mandateAmountData}), z.object({multi_use: mandateAmountData.nullable()})]); export const paymentType = z.enum(["normal", "new_mandate", "setup_mandate", "recurring_mandate", "installment"]); export const nextActionCall = z.union([z.literal("post_session_tokens"), z.literal("confirm"), z.literal("sync"), z.literal("complete_authorize"), z.literal("await_merchant_callback"), z.object({deny: z.object({message: z.string()})}), z.literal("eligibility_check")]); export const sdkNextAction = z.object({next_action: nextActionCall, should_block_confirm: z.boolean().nullable().optional()}); export const intentStatus = z.enum(["succeeded", "failed", "cancelled", "cancelled_post_capture", "processing", "requires_customer_action", "requires_merchant_action", "requires_payment_method", "requires_confirmation", "requires_capture", "partially_captured", "partially_captured_and_capturable", "partially_authorized_and_requires_capture", "partially_captured_and_processing", "conflicted", "expired", "review"]); export const futureUsage = z.enum(["off_session", "on_session"]); export const countryAlpha2 = z.enum(["AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW", "US"]); export const addressDetails = z.object({city: z.string().max(50).nullable().optional(), country: countryAlpha2.nullable().optional(), line1: z.string().max(200).nullable().optional(), line2: z.string().max(50).nullable().optional(), line3: z.string().max(50).nullable().optional(), zip: z.string().max(50).nullable().optional(), state: z.string().nullable().optional(), first_name: z.string().max(255).nullable().optional(), last_name: z.string().max(255).nullable().optional(), origin_zip: z.string().max(50).nullable().optional()}); export const phoneDetails = z.object({number: z.string().nullable().optional(), country_code: z.string().nullable().optional()}); export const address = z.object({address: addressDetails.nullable().optional(), phone: phoneDetails.nullable().optional(), email: z.string().nullable().optional()}); export const billingFrequency = z.literal("month"); export const paymentMethodListInstallmentAmountDetails = z.object({amount_per_installment: z.number(), total_amount: z.number()}); export const paymentMethodListInstallmentPlan = z.object({number_of_installments: z.number().int().gte(0), billing_frequency: billingFrequency, interest_rate: z.number(), amount_details: paymentMethodListInstallmentAmountDetails}); export const paymentMethodListInstallmentOption = z.object({payment_method: paymentMethod, available_plans: z.array(paymentMethodListInstallmentPlan)}); export const captureMethod = z.enum(["automatic", "manual", "manual_multiple", "scheduled", "sequential_automatic"]); export const acceptanceType = z.enum(["online", "offline"]); export const onlineMandate = z.object({ip_address: z.string(), user_agent: z.string()}); export const customerAcceptance = z.object({acceptance_type: acceptanceType, accepted_at: z.string().nullable().optional(), online: onlineMandate.nullable().optional()}); export const mandateData = z.object({update_mandate_id: z.string().nullable().optional(), customer_acceptance: customerAcceptance.nullable().optional(), mandate_type: mandateType.nullable().optional()}); export const paymentMethodListIntentData = z.object({payment_id: z.string(), status: intentStatus, amount: minorUnit, currency: currency.nullable().optional(), client_secret: z.string().nullable().optional(), description: z.string().nullable().optional(), customer_id: z.string().nullable().optional(), return_url: z.string().nullable().optional(), setup_future_usage: futureUsage.nullable().optional(), billing: address.nullable().optional(), shipping: address.nullable().optional(), email: z.string().nullable().optional(), metadata: z.object({}).nullable().optional(), order_details: z.array(z.object({})).nullable().optional(), created: z.string().nullable().optional(), expires_on: z.string().nullable().optional(), profile_id: z.string().nullable().optional(), merchant_order_reference_id: z.string().nullable().optional(), attempt_count: z.number().int(), installment_options: z.array(paymentMethodListInstallmentOption).nullable().optional(), capture_method: captureMethod.nullable().optional(), merchant_name: z.string().nullable().optional(), mandate_payment: mandateData.nullable().optional(), payment_type: paymentType.nullable().optional(), request_external_three_ds_authentication: z.boolean().nullable().optional(), is_tax_calculation_enabled: z.boolean().nullable().optional(), is_guest_customer: z.boolean().nullable().optional()}); export const paymentMethodListResponse = z.object({redirect_url: z.string().nullable().optional(), currency: currency, payment_methods: z.array(responsePaymentMethodsEnabled), mandate_payment: mandateType, merchant_name: z.string().nullable().optional(), show_surcharge_breakup_screen: z.boolean(), payment_type: paymentType.nullable().optional(), request_external_three_ds_authentication: z.boolean(), collect_shipping_details_from_wallets: z.boolean().nullable().optional(), collect_billing_details_from_wallets: z.boolean().nullable().optional(), is_tax_calculation_enabled: z.boolean(), sdk_next_action: sdkNextAction, is_guest_customer: z.boolean(), intent_data: paymentMethodListIntentData.nullable().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 }; /** * List payment methods for a Merchant * * GET /account/payment_methods * * Also accepts auth: publishable_key */ export const getApiAccountPaymentMethods = async (args: GetApiAccountPaymentMethodsArgs, options: GetApiAccountPaymentMethodsOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.client_secret != null) query.append("client_secret", String(args.client_secret)) for (const item of args.accepted_countries ?? []) query.append("accepted_countries", String(item)) for (const item of args.accepted_currencies ?? []) query.append("accepted_currencies", String(item)) if (args.amount != null) query.append("amount", String(args.amount)) if (args.recurring_enabled != null) query.append("recurring_enabled", String(args.recurring_enabled)) if (args.installment_payment_enabled != null) query.append("installment_payment_enabled", String(args.installment_payment_enabled)) if (args.limit != null) query.append("limit", String(args.limit)) for (const item of args.card_networks ?? []) query.append("card_networks", String(item)) if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/account/payment_methods${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(paymentMethodListResponse, await res.json()) };