import {z} from 'zod' export type GetApiAccountAccountIdConnectorsArgs = {account_id: string}; export type GetApiAccountAccountIdConnectorsOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const connectorType = z.enum(["payment_processor", "payment_vas", "fin_operations", "fiz_operations", "networks", "banking_entities", "non_banking_finance", "payout_processor", "payment_method_auth", "authentication_processor", "tax_processor", "surcharge_processor", "billing_processor", "vault_processor"]); export const connector = z.enum(["absa_sanlam", "authipay", "adyenplatform", "stripe_billing_test", "phonypay", "fauxpay", "pretendpay", "stripe_test", "adyen_test", "checkout_test", "paypal_test", "aci", "adyen", "affirm", "airwallex", "amazonpay", "archipel", "authorizedotnet", "bambora", "bamboraapac", "bankofamerica", "barclaycard", "billwerk", "bitpay", "bluesnap", "blackhawknetwork", "calida", "boku", "braintree", "breadpay", "cardinal", "cashtocode", "celero", "chargebee", "checkbook", "checkout", "coinbase", "coingate", "custombilling", "cryptopay", "ctp_mastercard", "ctp_visa", "cybersource", "cybersourcedecisionmanager", "datatrans", "deutschebank", "digitalvirgo", "dlocal", "dwolla", "ebanx", "envoy", "elavon", "facilitapay", "finix", "fiserv", "fiservemea", "fiservcommercehub", "fiuu", "flexiti", "forte", "getnet", "gigadat", "givepayments", "globalpay", "globepay", "gocardless", "gpayments", "hipay", "helcim", "hyperpg", "hyperswitch_vault", "interpayments", "inespay", "iatapay", "imerchantsolutions", "itaubank", "jpmorgan", "juspaythreedsserver", "klarna", "loonio", "mifinity", "mollie", "moneris", "multisafepay", "netcetera", "nexinets", "nexixpay", "nmi", "nomupay", "noon", "nordea", "novalnet", "nuvei", "opennode", "paybox", "payload", "payme", "payone", "paypal", "paysafe", "paystack", "paytm", "payconex", "payu", "peachpayments", "payjustnow", "payjustnowinstore", "phonepe", "placetopay", "powertranz", "prophetpay", "rapyd", "razorpay", "recurly", "redsys", "revolv3", "santander", "shift4", "silverflow", "square", "stax", "stripe", "stripebilling", "taxjar", "threedsecureio", "tesouro", "tokenex", "tokenio", "trustly", "truelayer", "trustpay", "trustpayments", "tsys", "tsys_transit", "vgs", "volt", "wellsfargo", "wise", "worldline", "worldpay", "worldpayvantiv", "worldpayxml", "worldpaymodular", "signifyd", "plaid", "riskified", "xendit", "zen", "zift", "zsl"]); 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 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 paymentExperience = z.enum(["redirect_to_url", "invoke_sdk_client", "display_qr_code", "one_click", "link_wallet", "invoke_payment_app", "display_wait_screen", "collect_otp"]); 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 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 acceptedCurrencies = z.discriminatedUnion("type", [z.object({type: z.literal("enable_only"), list: z.array(currency)}), z.object({type: z.literal("disable_only"), list: z.array(currency)}), z.object({type: z.literal("all_accepted")})]); 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 acceptedCountries = z.discriminatedUnion("type", [z.object({type: z.literal("enable_only"), list: z.array(countryAlpha2)}), z.object({type: z.literal("disable_only"), list: z.array(countryAlpha2)}), z.object({type: z.literal("all_accepted")})]); export const minorUnit = z.number().int(); export const requestPaymentMethodTypes = z.object({payment_method_type: paymentMethodType, payment_experience: paymentExperience.nullable().optional(), card_networks: z.array(cardNetwork).nullable().optional(), accepted_currencies: acceptedCurrencies.nullable().optional(), accepted_countries: acceptedCountries.nullable().optional(), minimum_amount: minorUnit.nullable().optional(), maximum_amount: minorUnit.nullable().optional(), recurring_enabled: z.boolean().nullable().optional(), installment_payment_enabled: z.boolean().nullable().optional()}); export const paymentMethodsEnabled = z.object({payment_method: paymentMethod, payment_method_types: z.array(requestPaymentMethodTypes).nullable().optional()}); export const frmPreferredFlowTypes = z.enum(["pre", "post"]); export const frmAction = z.enum(["cancel_txn", "auto_refund", "manual_review"]); export const frmPaymentMethodType = z.object({payment_method_type: paymentMethodType, card_networks: cardNetwork, flow: frmPreferredFlowTypes, action: frmAction}); export const frmPaymentMethod = z.object({payment_method: paymentMethod, payment_method_types: z.array(frmPaymentMethodType).nullable().optional(), flow: frmPreferredFlowTypes.nullable().optional()}); export const frmConfigs = z.object({gateway: connectorType, payment_methods: z.array(frmPaymentMethod)}); export const connectorStatus = z.enum(["inactive", "active"]); export const merchantConnectorListResponse = z.object({connector_type: connectorType, connector_name: connector, connector_label: z.string().nullable().optional(), merchant_connector_id: z.string(), profile_id: z.string().max(64), payment_methods_enabled: z.array(paymentMethodsEnabled).nullable().optional(), test_mode: z.boolean().nullable().optional(), disabled: z.boolean().nullable().optional(), frm_configs: z.array(frmConfigs).nullable().optional(), business_country: countryAlpha2.nullable().optional(), business_label: z.string().nullable().optional(), business_sub_label: z.string().nullable().optional(), applepay_verified_domains: z.array(z.string()).nullable().optional(), pm_auth_config: z.object({}).nullable().optional(), status: connectorStatus}); export const getApiAccountAccountIdConnectorsResponse = z.array(merchantConnectorListResponse); 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 }; /** * Merchant Connector - List * * GET /account/{account_id}/connectors */ export const getApiAccountAccountIdConnectors = async (args: GetApiAccountAccountIdConnectorsArgs, options: GetApiAccountAccountIdConnectorsOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/account/${encodeURIComponent(String(args.account_id))}/connectors${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(getApiAccountAccountIdConnectorsResponse, await res.json()) };