@payment-kit-js/vanilla 0.5.12 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{airwallex-apple-pay-adapter-BCYt7Jzc.d.mts → airwallex-apple-pay-adapter-Bb0CreWN.d.mts} +1 -1
- package/dist/{airwallex-apple-pay-adapter-BCYt7Jzc.d.mts.map → airwallex-apple-pay-adapter-Bb0CreWN.d.mts.map} +1 -1
- package/dist/{airwallex-apple-pay-adapter-BFsoDoSf.mjs → airwallex-apple-pay-adapter-CHAnLP_x.mjs} +1 -1
- package/dist/{airwallex-apple-pay-adapter-BFsoDoSf.mjs.map → airwallex-apple-pay-adapter-CHAnLP_x.mjs.map} +1 -1
- package/dist/{airwallex-google-pay-adapter-B5xmg7b8.mjs → airwallex-google-pay-adapter-C8JTp01q.mjs} +1 -1
- package/dist/{airwallex-google-pay-adapter-B5xmg7b8.mjs.map → airwallex-google-pay-adapter-C8JTp01q.mjs.map} +1 -1
- package/dist/{airwallex-google-pay-adapter-DvEB6t5i.d.mts → airwallex-google-pay-adapter-adaDktQM.d.mts} +1 -1
- package/dist/{airwallex-google-pay-adapter-DvEB6t5i.d.mts.map → airwallex-google-pay-adapter-adaDktQM.d.mts.map} +1 -1
- package/dist/bnpl-shared-B-en2sPr.d.mts +64 -0
- package/dist/bnpl-shared-B-en2sPr.d.mts.map +1 -0
- package/dist/bnpl-shared-CEAXTL3Q.mjs +107 -0
- package/dist/bnpl-shared-CEAXTL3Q.mjs.map +1 -0
- package/dist/cdn/paymentkit.js +355 -15
- package/dist/cdn/paymentkit.js.map +4 -4
- package/dist/cdn/paymentkit.min.js +9 -9
- package/dist/cdn/paymentkit.min.js.map +4 -4
- package/dist/{connect-card-Cxy51W6t.d.mts → connect-card-Cra_F1cC.d.mts} +1 -1
- package/dist/{connect-card-Cxy51W6t.d.mts.map → connect-card-Cra_F1cC.d.mts.map} +1 -1
- package/dist/{connect-card-CMZkeppE.mjs → connect-card-D3Je4V7p.mjs} +1 -1
- package/dist/{connect-card-CMZkeppE.mjs.map → connect-card-D3Je4V7p.mjs.map} +1 -1
- package/dist/{connect-tunnel-x-lv6Wtdme.d.mts → connect-tunnel-x-Wh-JG1O5.d.mts} +1 -1
- package/dist/{connect-tunnel-x-lv6Wtdme.d.mts.map → connect-tunnel-x-Wh-JG1O5.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{next-action-handlers-CTx8tRt0.mjs → next-action-handlers-BZs04hYb.mjs} +1 -1
- package/dist/{next-action-handlers-CTx8tRt0.mjs.map → next-action-handlers-BZs04hYb.mjs.map} +1 -1
- package/dist/payment-methods/affirm.d.mts +13 -0
- package/dist/payment-methods/affirm.d.mts.map +1 -0
- package/dist/payment-methods/affirm.mjs +14 -0
- package/dist/payment-methods/affirm.mjs.map +1 -0
- package/dist/payment-methods/afterpay.d.mts +13 -0
- package/dist/payment-methods/afterpay.d.mts.map +1 -0
- package/dist/payment-methods/afterpay.mjs +14 -0
- package/dist/payment-methods/afterpay.mjs.map +1 -0
- package/dist/payment-methods/airwallex-apple-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/airwallex-apple-pay-adapter.mjs +1 -1
- package/dist/payment-methods/airwallex-google-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/airwallex-google-pay-adapter.mjs +1 -1
- package/dist/payment-methods/apple-pay.d.mts +36 -7
- package/dist/payment-methods/apple-pay.d.mts.map +1 -1
- package/dist/payment-methods/apple-pay.mjs +162 -11
- package/dist/payment-methods/apple-pay.mjs.map +1 -1
- package/dist/payment-methods/bnpl-shared.d.mts +5 -0
- package/dist/payment-methods/bnpl-shared.mjs +4 -0
- package/dist/payment-methods/card.d.mts +3 -3
- package/dist/payment-methods/card.mjs +3 -3
- package/dist/payment-methods/google-pay.d.mts +5 -5
- package/dist/payment-methods/google-pay.mjs +3 -3
- package/dist/payment-methods/klarna.d.mts +13 -0
- package/dist/payment-methods/klarna.d.mts.map +1 -0
- package/dist/payment-methods/klarna.mjs +14 -0
- package/dist/payment-methods/klarna.mjs.map +1 -0
- package/dist/payment-methods/next-action-handlers.mjs +1 -1
- package/dist/payment-methods/paypal.d.mts +9 -3
- package/dist/payment-methods/paypal.d.mts.map +1 -1
- package/dist/payment-methods/paypal.mjs.map +1 -1
- package/dist/payment-methods/stripe-apple-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/stripe-apple-pay-adapter.mjs +1 -1
- package/dist/payment-methods/stripe-google-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/stripe-google-pay-adapter.mjs +1 -1
- package/dist/payment-methods/vgs-collect-loader.mjs +1 -1
- package/dist/penpal/connect-card.d.mts +1 -1
- package/dist/penpal/connect-card.mjs +1 -1
- package/dist/penpal/connect-tunnel-x.d.mts +1 -1
- package/dist/{stripe-apple-pay-adapter-Cd9LVNnp.mjs → stripe-apple-pay-adapter-BLRjqgDf.mjs} +1 -1
- package/dist/{stripe-apple-pay-adapter-Cd9LVNnp.mjs.map → stripe-apple-pay-adapter-BLRjqgDf.mjs.map} +1 -1
- package/dist/{stripe-apple-pay-adapter-DhpGclW9.d.mts → stripe-apple-pay-adapter-DcuGlQqQ.d.mts} +1 -1
- package/dist/{stripe-apple-pay-adapter-DhpGclW9.d.mts.map → stripe-apple-pay-adapter-DcuGlQqQ.d.mts.map} +1 -1
- package/dist/{stripe-google-pay-adapter-Bdox4xBq.d.mts → stripe-google-pay-adapter-BlQ2jVpE.d.mts} +1 -1
- package/dist/{stripe-google-pay-adapter-Bdox4xBq.d.mts.map → stripe-google-pay-adapter-BlQ2jVpE.d.mts.map} +1 -1
- package/dist/{stripe-google-pay-adapter-3cx0KNjK.mjs → stripe-google-pay-adapter-CIkgjhw8.mjs} +1 -1
- package/dist/{stripe-google-pay-adapter-3cx0KNjK.mjs.map → stripe-google-pay-adapter-CIkgjhw8.mjs.map} +1 -1
- package/dist/{types-D88-nhWu.d.mts → types-CQ8xbgoh.d.mts} +3 -3
- package/dist/{types-D88-nhWu.d.mts.map → types-CQ8xbgoh.d.mts.map} +1 -1
- package/dist/{vgs-collect-loader-BZj36d8r.mjs → vgs-collect-loader-l5_Pnmhz.mjs} +1 -1
- package/dist/{vgs-collect-loader-BZj36d8r.mjs.map → vgs-collect-loader-l5_Pnmhz.mjs.map} +1 -1
- package/package.json +6 -2
|
@@ -96,4 +96,4 @@ declare class AirwallexApplePayAdapter {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
export { ApplePayEncryptedToken as a, AirwallexApplePayShowResult as i, AirwallexApplePayConfig as n, MerchantValidationCallback as o, AirwallexApplePayMockScenario as r, AirwallexApplePayAdapter as t };
|
|
99
|
-
//# sourceMappingURL=airwallex-apple-pay-adapter-
|
|
99
|
+
//# sourceMappingURL=airwallex-apple-pay-adapter-Bb0CreWN.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"airwallex-apple-pay-adapter-
|
|
1
|
+
{"version":3,"file":"airwallex-apple-pay-adapter-Bb0CreWN.d.mts","names":[],"sources":["../src/payment-methods/airwallex-apple-pay-adapter.ts"],"sourcesContent":[],"mappings":";;AAoBA;AAOA;AAmBA;AAOA;AAWA;AAIA;;;;;;;;;;;aAhDY,6BAAA;;;;;UAOK,sBAAA;;;;;;;;;;;;;;;;;;UAmBA,uBAAA;;;;;;KAOL,2BAAA;;SAGC;;;;;;;;;;KAQD,0BAAA,8BAEP;;;;cAEQ,wBAAA;;;6BAIgB;;;;;qBAQR;;;;;oBAsBK;;;;;;;;;;;;;;;;;;yCAkEqB,6BAA6B,QAAQ"}
|
package/dist/{airwallex-apple-pay-adapter-BFsoDoSf.mjs → airwallex-apple-pay-adapter-CHAnLP_x.mjs}
RENAMED
|
@@ -238,4 +238,4 @@ var AirwallexApplePayAdapter = class {
|
|
|
238
238
|
|
|
239
239
|
//#endregion
|
|
240
240
|
export { AirwallexApplePayMockScenario as n, AirwallexApplePayAdapter as t };
|
|
241
|
-
//# sourceMappingURL=airwallex-apple-pay-adapter-
|
|
241
|
+
//# sourceMappingURL=airwallex-apple-pay-adapter-CHAnLP_x.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"airwallex-apple-pay-adapter-BFsoDoSf.mjs","names":["paymentRequest: ApplePayJS.ApplePayPaymentRequest","token: ApplePayEncryptedToken"],"sources":["../src/payment-methods/airwallex-apple-pay-adapter.ts"],"sourcesContent":["/**\n * Airwallex Apple Pay Adapter\n *\n * Uses native ApplePaySession API directly (not Stripe.js) to show the payment sheet\n * and extract the encrypted payment token for Airwallex processing.\n *\n * Flow:\n * 1. initialize() - Checks if ApplePaySession is available\n * 2. canMakePayment() - Checks if user can pay with Apple Pay\n * 3. showPaymentSheet() - Shows Apple Pay sheet with merchant validation callback\n *\n * The key difference from Stripe's approach is that we use the native\n * ApplePaySession API and handle merchant validation via Airwallex's\n * payment_session/start API which validates with Apple.\n *\n * Mock scenarios are supported for E2E testing without real Apple Pay.\n */\n\n/// <reference types=\"@types/applepayjs\" />\n\nexport enum AirwallexApplePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n// Apple Pay token structure from payment.token\nexport interface ApplePayEncryptedToken {\n paymentData: {\n version?: string;\n data: string;\n signature: string;\n header: {\n ephemeralPublicKey: string;\n publicKeyHash: string;\n transactionId: string;\n };\n };\n paymentMethod: {\n displayName: string;\n network: string;\n type: string;\n };\n transactionIdentifier: string;\n}\n\nexport interface AirwallexApplePayConfig {\n amount: number; // Amount in atomic units (cents)\n currency: string; // e.g., \"USD\"\n country: string; // e.g., \"US\"\n merchantName?: string; // Display name on Apple Pay sheet\n}\n\nexport type AirwallexApplePayShowResult =\n | {\n success: true;\n token: ApplePayEncryptedToken;\n payerEmail?: string;\n complete: (status: \"success\" | \"fail\") => void;\n }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\n// Merchant validation callback type - called during onvalidatemerchant\nexport type MerchantValidationCallback = (\n validationUrl: string,\n) => Promise<{ merchantSession?: object; error?: string }>;\n\nexport class AirwallexApplePayAdapter {\n private config: AirwallexApplePayConfig | null = null;\n private mockScenario: AirwallexApplePayMockScenario;\n\n constructor(mockScenario?: AirwallexApplePayMockScenario) {\n this.mockScenario = mockScenario ?? AirwallexApplePayMockScenario.None;\n }\n\n /**\n * Initialize the adapter with payment configuration.\n * Returns true if Apple Pay is available on this device.\n */\n initialize(config: AirwallexApplePayConfig): boolean {\n // Mock scenarios bypass real Apple Pay initialization\n if (this.mockScenario !== AirwallexApplePayMockScenario.None) {\n console.log(\"[MockApplePay:Airwallex] initialize called (mock mode)\");\n this.config = config;\n return true;\n }\n\n // Check if ApplePaySession is available (Safari on iOS/macOS only)\n if (typeof window === \"undefined\" || !window.ApplePaySession) {\n console.error(\"[ApplePay:Airwallex] ApplePaySession not available (not Safari or unsupported device)\");\n return false;\n }\n\n this.config = config;\n return true;\n }\n\n /**\n * Check if the user can make a payment with Apple Pay.\n * Returns true if Apple Pay is set up on this device.\n */\n async canMakePayment(): Promise<boolean> {\n // Mock scenarios always return true\n if (this.mockScenario !== AirwallexApplePayMockScenario.None) {\n console.log(\"[MockApplePay:Airwallex] canMakePayment: true (mock mode)\");\n return true;\n }\n\n if (!window.ApplePaySession) {\n return false;\n }\n\n try {\n const canMake = window.ApplePaySession.canMakePayments();\n console.log(\"[ApplePay:Airwallex] canMakePayments:\", canMake);\n return canMake;\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] canMakePayment error:\", error);\n return false;\n }\n }\n\n /**\n * Convert atomic units (cents) to display format for Apple Pay.\n * Apple Pay expects a string like \"10.00\" for $10.00.\n */\n private formatAmount(amountAtom: number, currency: string): string {\n // Most currencies use 2 decimal places, some like JPY use 0\n const zeroDecimalCurrencies = [\n \"BIF\",\n \"CLP\",\n \"DJF\",\n \"GNF\",\n \"ISK\",\n \"JPY\",\n \"KMF\",\n \"KRW\",\n \"PYG\",\n \"RWF\",\n \"UGX\",\n \"VND\",\n \"VUV\",\n \"XAF\",\n \"XOF\",\n \"XPF\",\n ];\n const isZeroDecimal = zeroDecimalCurrencies.includes(currency.toUpperCase());\n\n if (isZeroDecimal) {\n return amountAtom.toString();\n }\n\n return (amountAtom / 100).toFixed(2);\n }\n\n /**\n * Show the Apple Pay payment sheet and return the encrypted token.\n *\n * This uses the native ApplePaySession API with a two-step flow:\n * 1. onvalidatemerchant - Called by Apple to validate the merchant\n * The callback should call our backend which calls Airwallex's payment_session/start\n * 2. onpaymentauthorized - Called when user authorizes with Face ID/Touch ID\n * Returns the encrypted token for processing\n *\n * @param onMerchantValidation - Callback to validate merchant with backend\n * @returns Promise with token or error\n */\n async showPaymentSheet(onMerchantValidation: MerchantValidationCallback): Promise<AirwallexApplePayShowResult> {\n // Handle mock scenarios\n if (this.mockScenario === AirwallexApplePayMockScenario.Success) {\n console.log(\"[MockApplePay:Airwallex] showPaymentSheet: returning mock success token\");\n const mockToken: ApplePayEncryptedToken = {\n paymentData: {\n version: \"EC_v1\",\n data: \"MOCK_ENCRYPTED_DATA\",\n signature: \"MOCK_SIGNATURE\",\n header: {\n ephemeralPublicKey: \"MOCK_PUBLIC_KEY\",\n publicKeyHash: \"MOCK_HASH\",\n transactionId: \"mock_txn_123\",\n },\n },\n paymentMethod: {\n displayName: \"Visa 4242\",\n network: \"Visa\",\n type: \"debit\",\n },\n transactionIdentifier: \"MOCK_TXN_ID\",\n };\n return {\n success: true,\n token: mockToken,\n payerEmail: \"mock@example.com\",\n complete: (status) => console.log(`[MockApplePay:Airwallex] complete: ${status}`),\n };\n }\n\n if (this.mockScenario === AirwallexApplePayMockScenario.Cancelled) {\n console.log(\"[MockApplePay:Airwallex] showPaymentSheet: returning mock cancelled\");\n return { success: false, cancelled: true };\n }\n\n // Real Apple Pay flow\n if (!this.config) {\n return { success: false, error: \"Apple Pay not initialized\" };\n }\n\n if (!window.ApplePaySession) {\n return { success: false, error: \"ApplePaySession not available\" };\n }\n\n const config = this.config;\n const amount = this.formatAmount(config.amount, config.currency);\n\n // Create the Apple Pay payment request\n const paymentRequest: ApplePayJS.ApplePayPaymentRequest = {\n countryCode: config.country.toUpperCase(),\n currencyCode: config.currency.toUpperCase(),\n supportedNetworks: [\"visa\", \"masterCard\", \"amex\", \"discover\"],\n merchantCapabilities: [\"supports3DS\"],\n total: {\n label: config.merchantName || \"Total\",\n amount: amount,\n type: \"final\",\n },\n // Surface the payer's email so the backend can fill missing customer email.\n requiredBillingContactFields: [\"email\"],\n };\n\n return new Promise((resolve) => {\n try {\n // Create ApplePaySession (version 3 is widely supported)\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession is guaranteed to exist (checked in canMakePayments)\n const session = new window.ApplePaySession!(3, paymentRequest);\n\n // Capture status constants at creation time (before optional chaining could yield undefined)\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession existence verified above\n const STATUS_SUCCESS = window.ApplePaySession!.STATUS_SUCCESS;\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession existence verified above\n const STATUS_FAILURE = window.ApplePaySession!.STATUS_FAILURE;\n\n // Handle merchant validation\n session.onvalidatemerchant = async (event: ApplePayJS.ApplePayValidateMerchantEvent) => {\n console.log(\"[ApplePay:Airwallex] onvalidatemerchant called\", event.validationURL);\n\n try {\n const validationResult = await onMerchantValidation(event.validationURL);\n\n if (validationResult.error || !validationResult.merchantSession) {\n console.error(\"[ApplePay:Airwallex] Merchant validation failed:\", validationResult.error);\n session.abort();\n resolve({\n success: false,\n error: validationResult.error || \"Merchant validation failed\",\n });\n return;\n }\n\n // Complete merchant validation with the session from Apple\n session.completeMerchantValidation(validationResult.merchantSession);\n console.log(\"[ApplePay:Airwallex] Merchant validation completed\");\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] Merchant validation error:\", error);\n session.abort();\n resolve({\n success: false,\n error: `Merchant validation error: ${error}`,\n });\n }\n };\n\n // Handle payment authorization (user approved with Face ID/Touch ID)\n session.onpaymentauthorized = (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => {\n console.log(\"[ApplePay:Airwallex] onpaymentauthorized called\");\n\n // Extract the encrypted token\n const payment = event.payment;\n const token: ApplePayEncryptedToken = {\n paymentData: payment.token.paymentData as ApplePayEncryptedToken[\"paymentData\"],\n paymentMethod: {\n displayName: payment.token.paymentMethod.displayName,\n network: payment.token.paymentMethod.network,\n type: payment.token.paymentMethod.type,\n },\n transactionIdentifier: payment.token.transactionIdentifier,\n };\n\n const payerEmail = payment.billingContact?.emailAddress ?? payment.shippingContact?.emailAddress ?? undefined;\n\n // Create the complete callback that the caller will use after confirming\n const complete = (status: \"success\" | \"fail\") => {\n console.log(\"[ApplePay:Airwallex] completing session with status:\", status);\n const appleStatus = status === \"success\" ? STATUS_SUCCESS : STATUS_FAILURE;\n session.completePayment({ status: appleStatus });\n };\n\n resolve({\n success: true,\n token,\n payerEmail,\n complete,\n });\n };\n\n // Handle cancellation\n session.oncancel = () => {\n console.log(\"[ApplePay:Airwallex] oncancel - user cancelled\");\n resolve({ success: false, cancelled: true });\n };\n\n // Start the session - this shows the Apple Pay sheet\n console.log(\"[ApplePay:Airwallex] Starting Apple Pay session\");\n session.begin();\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] Session creation error:\", error);\n resolve({\n success: false,\n error: `Failed to create Apple Pay session: ${error}`,\n });\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,IAAY,0FAAL;AACL;AACA;AACA;;;AA6CF,IAAa,2BAAb,MAAsC;CACpC,AAAQ,SAAyC;CACjD,AAAQ;CAER,YAAY,cAA8C;AACxD,OAAK,eAAe,gBAAgB,8BAA8B;;;;;;CAOpE,WAAW,QAA0C;AAEnD,MAAI,KAAK,iBAAiB,8BAA8B,MAAM;AAC5D,WAAQ,IAAI,yDAAyD;AACrE,QAAK,SAAS;AACd,UAAO;;AAIT,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,iBAAiB;AAC5D,WAAQ,MAAM,wFAAwF;AACtG,UAA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MAAM;MACtC;KAED,MAAM,aAAa,QAAQ,gBAAgB,gBAAgB,QAAQ,iBAAiB,gBAAgB;KAGpG,MAAM,YAAY,WAA+B;AAC/C,cAAQ,IAAI,wDAAwD,OAAO;MAC3E,MAAM,cAAc,WAAW,YAAY,iBAAiB;AAC5D,cAAQ,gBAAgB,EAAE,QAAQ,aAAa,CAAC;;AAGlD,aAAQ;MACN,SAAS;MACT;MACA;MACA;MACD,CAAC;;AAIJ,YAAQ,iBAAiB;AACvB,aAAQ,IAAI,iDAAiD;AAC7D,aAAQ;MAAE,SAAS;MAAO,WAAW;MAAM,CAAC;;AAI9C,YAAQ,IAAI,kDAAkD;AAC9D,YAAQ,OAAO;YACR,OAAO;AACd,YAAQ,MAAM,gDAAgD,MAAM;AACpE,YAAQ;KACN,SAAS;KACT,OAAO,uCAAuC;KAC/C,CAAC;;IAEJ"}
|
|
1
|
+
{"version":3,"file":"airwallex-apple-pay-adapter-CHAnLP_x.mjs","names":["paymentRequest: ApplePayJS.ApplePayPaymentRequest","token: ApplePayEncryptedToken"],"sources":["../src/payment-methods/airwallex-apple-pay-adapter.ts"],"sourcesContent":["/**\n * Airwallex Apple Pay Adapter\n *\n * Uses native ApplePaySession API directly (not Stripe.js) to show the payment sheet\n * and extract the encrypted payment token for Airwallex processing.\n *\n * Flow:\n * 1. initialize() - Checks if ApplePaySession is available\n * 2. canMakePayment() - Checks if user can pay with Apple Pay\n * 3. showPaymentSheet() - Shows Apple Pay sheet with merchant validation callback\n *\n * The key difference from Stripe's approach is that we use the native\n * ApplePaySession API and handle merchant validation via Airwallex's\n * payment_session/start API which validates with Apple.\n *\n * Mock scenarios are supported for E2E testing without real Apple Pay.\n */\n\n/// <reference types=\"@types/applepayjs\" />\n\nexport enum AirwallexApplePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n// Apple Pay token structure from payment.token\nexport interface ApplePayEncryptedToken {\n paymentData: {\n version?: string;\n data: string;\n signature: string;\n header: {\n ephemeralPublicKey: string;\n publicKeyHash: string;\n transactionId: string;\n };\n };\n paymentMethod: {\n displayName: string;\n network: string;\n type: string;\n };\n transactionIdentifier: string;\n}\n\nexport interface AirwallexApplePayConfig {\n amount: number; // Amount in atomic units (cents)\n currency: string; // e.g., \"USD\"\n country: string; // e.g., \"US\"\n merchantName?: string; // Display name on Apple Pay sheet\n}\n\nexport type AirwallexApplePayShowResult =\n | {\n success: true;\n token: ApplePayEncryptedToken;\n payerEmail?: string;\n complete: (status: \"success\" | \"fail\") => void;\n }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\n// Merchant validation callback type - called during onvalidatemerchant\nexport type MerchantValidationCallback = (\n validationUrl: string,\n) => Promise<{ merchantSession?: object; error?: string }>;\n\nexport class AirwallexApplePayAdapter {\n private config: AirwallexApplePayConfig | null = null;\n private mockScenario: AirwallexApplePayMockScenario;\n\n constructor(mockScenario?: AirwallexApplePayMockScenario) {\n this.mockScenario = mockScenario ?? AirwallexApplePayMockScenario.None;\n }\n\n /**\n * Initialize the adapter with payment configuration.\n * Returns true if Apple Pay is available on this device.\n */\n initialize(config: AirwallexApplePayConfig): boolean {\n // Mock scenarios bypass real Apple Pay initialization\n if (this.mockScenario !== AirwallexApplePayMockScenario.None) {\n console.log(\"[MockApplePay:Airwallex] initialize called (mock mode)\");\n this.config = config;\n return true;\n }\n\n // Check if ApplePaySession is available (Safari on iOS/macOS only)\n if (typeof window === \"undefined\" || !window.ApplePaySession) {\n console.error(\"[ApplePay:Airwallex] ApplePaySession not available (not Safari or unsupported device)\");\n return false;\n }\n\n this.config = config;\n return true;\n }\n\n /**\n * Check if the user can make a payment with Apple Pay.\n * Returns true if Apple Pay is set up on this device.\n */\n async canMakePayment(): Promise<boolean> {\n // Mock scenarios always return true\n if (this.mockScenario !== AirwallexApplePayMockScenario.None) {\n console.log(\"[MockApplePay:Airwallex] canMakePayment: true (mock mode)\");\n return true;\n }\n\n if (!window.ApplePaySession) {\n return false;\n }\n\n try {\n const canMake = window.ApplePaySession.canMakePayments();\n console.log(\"[ApplePay:Airwallex] canMakePayments:\", canMake);\n return canMake;\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] canMakePayment error:\", error);\n return false;\n }\n }\n\n /**\n * Convert atomic units (cents) to display format for Apple Pay.\n * Apple Pay expects a string like \"10.00\" for $10.00.\n */\n private formatAmount(amountAtom: number, currency: string): string {\n // Most currencies use 2 decimal places, some like JPY use 0\n const zeroDecimalCurrencies = [\n \"BIF\",\n \"CLP\",\n \"DJF\",\n \"GNF\",\n \"ISK\",\n \"JPY\",\n \"KMF\",\n \"KRW\",\n \"PYG\",\n \"RWF\",\n \"UGX\",\n \"VND\",\n \"VUV\",\n \"XAF\",\n \"XOF\",\n \"XPF\",\n ];\n const isZeroDecimal = zeroDecimalCurrencies.includes(currency.toUpperCase());\n\n if (isZeroDecimal) {\n return amountAtom.toString();\n }\n\n return (amountAtom / 100).toFixed(2);\n }\n\n /**\n * Show the Apple Pay payment sheet and return the encrypted token.\n *\n * This uses the native ApplePaySession API with a two-step flow:\n * 1. onvalidatemerchant - Called by Apple to validate the merchant\n * The callback should call our backend which calls Airwallex's payment_session/start\n * 2. onpaymentauthorized - Called when user authorizes with Face ID/Touch ID\n * Returns the encrypted token for processing\n *\n * @param onMerchantValidation - Callback to validate merchant with backend\n * @returns Promise with token or error\n */\n async showPaymentSheet(onMerchantValidation: MerchantValidationCallback): Promise<AirwallexApplePayShowResult> {\n // Handle mock scenarios\n if (this.mockScenario === AirwallexApplePayMockScenario.Success) {\n console.log(\"[MockApplePay:Airwallex] showPaymentSheet: returning mock success token\");\n const mockToken: ApplePayEncryptedToken = {\n paymentData: {\n version: \"EC_v1\",\n data: \"MOCK_ENCRYPTED_DATA\",\n signature: \"MOCK_SIGNATURE\",\n header: {\n ephemeralPublicKey: \"MOCK_PUBLIC_KEY\",\n publicKeyHash: \"MOCK_HASH\",\n transactionId: \"mock_txn_123\",\n },\n },\n paymentMethod: {\n displayName: \"Visa 4242\",\n network: \"Visa\",\n type: \"debit\",\n },\n transactionIdentifier: \"MOCK_TXN_ID\",\n };\n return {\n success: true,\n token: mockToken,\n payerEmail: \"mock@example.com\",\n complete: (status) => console.log(`[MockApplePay:Airwallex] complete: ${status}`),\n };\n }\n\n if (this.mockScenario === AirwallexApplePayMockScenario.Cancelled) {\n console.log(\"[MockApplePay:Airwallex] showPaymentSheet: returning mock cancelled\");\n return { success: false, cancelled: true };\n }\n\n // Real Apple Pay flow\n if (!this.config) {\n return { success: false, error: \"Apple Pay not initialized\" };\n }\n\n if (!window.ApplePaySession) {\n return { success: false, error: \"ApplePaySession not available\" };\n }\n\n const config = this.config;\n const amount = this.formatAmount(config.amount, config.currency);\n\n // Create the Apple Pay payment request\n const paymentRequest: ApplePayJS.ApplePayPaymentRequest = {\n countryCode: config.country.toUpperCase(),\n currencyCode: config.currency.toUpperCase(),\n supportedNetworks: [\"visa\", \"masterCard\", \"amex\", \"discover\"],\n merchantCapabilities: [\"supports3DS\"],\n total: {\n label: config.merchantName || \"Total\",\n amount: amount,\n type: \"final\",\n },\n // Surface the payer's email so the backend can fill missing customer email.\n requiredBillingContactFields: [\"email\"],\n };\n\n return new Promise((resolve) => {\n try {\n // Create ApplePaySession (version 3 is widely supported)\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession is guaranteed to exist (checked in canMakePayments)\n const session = new window.ApplePaySession!(3, paymentRequest);\n\n // Capture status constants at creation time (before optional chaining could yield undefined)\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession existence verified above\n const STATUS_SUCCESS = window.ApplePaySession!.STATUS_SUCCESS;\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession existence verified above\n const STATUS_FAILURE = window.ApplePaySession!.STATUS_FAILURE;\n\n // Handle merchant validation\n session.onvalidatemerchant = async (event: ApplePayJS.ApplePayValidateMerchantEvent) => {\n console.log(\"[ApplePay:Airwallex] onvalidatemerchant called\", event.validationURL);\n\n try {\n const validationResult = await onMerchantValidation(event.validationURL);\n\n if (validationResult.error || !validationResult.merchantSession) {\n console.error(\"[ApplePay:Airwallex] Merchant validation failed:\", validationResult.error);\n session.abort();\n resolve({\n success: false,\n error: validationResult.error || \"Merchant validation failed\",\n });\n return;\n }\n\n // Complete merchant validation with the session from Apple\n session.completeMerchantValidation(validationResult.merchantSession);\n console.log(\"[ApplePay:Airwallex] Merchant validation completed\");\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] Merchant validation error:\", error);\n session.abort();\n resolve({\n success: false,\n error: `Merchant validation error: ${error}`,\n });\n }\n };\n\n // Handle payment authorization (user approved with Face ID/Touch ID)\n session.onpaymentauthorized = (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => {\n console.log(\"[ApplePay:Airwallex] onpaymentauthorized called\");\n\n // Extract the encrypted token\n const payment = event.payment;\n const token: ApplePayEncryptedToken = {\n paymentData: payment.token.paymentData as ApplePayEncryptedToken[\"paymentData\"],\n paymentMethod: {\n displayName: payment.token.paymentMethod.displayName,\n network: payment.token.paymentMethod.network,\n type: payment.token.paymentMethod.type,\n },\n transactionIdentifier: payment.token.transactionIdentifier,\n };\n\n const payerEmail = payment.billingContact?.emailAddress ?? payment.shippingContact?.emailAddress ?? undefined;\n\n // Create the complete callback that the caller will use after confirming\n const complete = (status: \"success\" | \"fail\") => {\n console.log(\"[ApplePay:Airwallex] completing session with status:\", status);\n const appleStatus = status === \"success\" ? STATUS_SUCCESS : STATUS_FAILURE;\n session.completePayment({ status: appleStatus });\n };\n\n resolve({\n success: true,\n token,\n payerEmail,\n complete,\n });\n };\n\n // Handle cancellation\n session.oncancel = () => {\n console.log(\"[ApplePay:Airwallex] oncancel - user cancelled\");\n resolve({ success: false, cancelled: true });\n };\n\n // Start the session - this shows the Apple Pay sheet\n console.log(\"[ApplePay:Airwallex] Starting Apple Pay session\");\n session.begin();\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] Session creation error:\", error);\n resolve({\n success: false,\n error: `Failed to create Apple Pay session: ${error}`,\n });\n }\n });\n }\n}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AQ,IAAI,qDAAqD;cAC1D,OAAO;AACd,cAAQ,MAAM,mDAAmD,MAAM;AACvE,cAAQ,OAAO;AACf,cAAQ;OACN,SAAS;OACT,OAAO,8BAA8B;OACtC,CAAC;;;AAKN,YAAQ,uBAAuB,UAAqD;AAClF,aAAQ,IAAI,kDAAkD;KAG9D,MAAM,UAAU,MAAM;KACtB,MAAMC,QAAgC;MACpC,aAAa,QAAQ,MAAM;MAC3B,eAAe;OACb,aAAa,QAAQ,MAAM,cAAc;OACzC,SAAS,QAAQ,MAAM,cAAc;OACrC,MAAM,QAAQ,MAAM,cAAc;OACnC;MACD,uBAAuB,QAAQ,MAAM;MACtC;KAED,MAAM,aAAa,QAAQ,gBAAgB,gBAAgB,QAAQ,iBAAiB,gBAAgB;KAGpG,MAAM,YAAY,WAA+B;AAC/C,cAAQ,IAAI,wDAAwD,OAAO;MAC3E,MAAM,cAAc,WAAW,YAAY,iBAAiB;AAC5D,cAAQ,gBAAgB,EAAE,QAAQ,aAAa,CAAC;;AAGlD,aAAQ;MACN,SAAS;MACT;MACA;MACA;MACD,CAAC;;AAIJ,YAAQ,iBAAiB;AACvB,aAAQ,IAAI,iDAAiD;AAC7D,aAAQ;MAAE,SAAS;MAAO,WAAW;MAAM,CAAC;;AAI9C,YAAQ,IAAI,kDAAkD;AAC9D,YAAQ,OAAO;YACR,OAAO;AACd,YAAQ,MAAM,gDAAgD,MAAM;AACpE,YAAQ;KACN,SAAS;KACT,OAAO,uCAAuC;KAC/C,CAAC;;IAEJ"}
|
package/dist/{airwallex-google-pay-adapter-B5xmg7b8.mjs → airwallex-google-pay-adapter-C8JTp01q.mjs}
RENAMED
|
@@ -168,4 +168,4 @@ var AirwallexGooglePayAdapter = class {
|
|
|
168
168
|
|
|
169
169
|
//#endregion
|
|
170
170
|
export { AirwallexGooglePayMockScenario as n, AirwallexGooglePayAdapter as t };
|
|
171
|
-
//# sourceMappingURL=airwallex-google-pay-adapter-
|
|
171
|
+
//# sourceMappingURL=airwallex-google-pay-adapter-C8JTp01q.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"airwallex-google-pay-adapter-B5xmg7b8.mjs","names":["baseMethod: AllowedPaymentMethod","request: IsReadyToPayRequest","request: PaymentDataRequest"],"sources":["../src/payment-methods/airwallex-google-pay-adapter.ts"],"sourcesContent":["/**\n * Airwallex Google Pay Adapter\n *\n * Uses Google Pay API directly (not Stripe.js) to show the payment sheet\n * and extract the encrypted payment token for Airwallex processing.\n *\n * Flow:\n * 1. initialize() - Checks if Google Pay API is available\n * 2. createPaymentDataRequest() - Configures the payment request\n * 3. canMakePayment() - Checks if user can pay with Google Pay\n * 4. showPaymentSheet() - Shows Google Pay sheet and returns encrypted token\n *\n * Mock scenarios are supported for E2E testing without real Google Pay.\n */\n\nexport enum AirwallexGooglePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n// Google Pay API types\n// See: https://developers.google.com/pay/api/web/reference/request-objects\ndeclare global {\n interface Window {\n google?: {\n payments: {\n api: {\n PaymentsClient: new (config: GooglePayClientConfig) => GooglePaymentsClient;\n };\n };\n };\n }\n}\n\ninterface GooglePayClientConfig {\n environment: \"TEST\" | \"PRODUCTION\";\n}\n\ninterface GooglePaymentsClient {\n isReadyToPay(request: IsReadyToPayRequest): Promise<IsReadyToPayResponse>;\n loadPaymentData(request: PaymentDataRequest): Promise<PaymentData>;\n}\n\ninterface IsReadyToPayRequest {\n apiVersion: number;\n apiVersionMinor: number;\n allowedPaymentMethods: AllowedPaymentMethod[];\n}\n\ninterface IsReadyToPayResponse {\n result: boolean;\n}\n\ninterface AllowedPaymentMethod {\n type: \"CARD\";\n parameters: {\n allowedAuthMethods: (\"PAN_ONLY\" | \"CRYPTOGRAM_3DS\")[];\n allowedCardNetworks: (\"VISA\" | \"MASTERCARD\" | \"AMEX\" | \"DISCOVER\" | \"JCB\")[];\n };\n tokenizationSpecification?: TokenizationSpecification;\n}\n\ninterface TokenizationSpecification {\n type: \"PAYMENT_GATEWAY\";\n parameters: {\n gateway: string;\n gatewayMerchantId: string;\n };\n}\n\ninterface PaymentDataRequest extends IsReadyToPayRequest {\n merchantInfo: {\n merchantId?: string;\n merchantName: string;\n };\n transactionInfo: {\n totalPriceStatus: \"FINAL\" | \"ESTIMATED\";\n totalPrice: string;\n currencyCode: string;\n countryCode: string;\n };\n emailRequired?: boolean;\n}\n\ninterface PaymentData {\n email?: string;\n paymentMethodData: {\n type: string;\n tokenizationData: {\n type: string;\n token: string; // JSON string containing the encrypted payment token\n };\n info?: {\n cardNetwork: string;\n cardDetails: string;\n };\n };\n}\n\n// Google Pay encrypted token structure (what's inside tokenizationData.token)\nexport interface GooglePayEncryptedToken {\n protocolVersion: string;\n signature: string;\n intermediateSigningKey: {\n signedKey: string;\n signatures: string[];\n };\n signedMessage: string;\n}\n\nexport interface AirwallexGooglePayConfig {\n merchantId: string; // Business name for display\n gatewayMerchantId: string; // Airwallex account ID (acct_xxxx)\n amountDisplay: string; // Formatted amount for Google Pay (e.g., \"100.00\" for USD, \"1000\" for JPY)\n currency: string; // e.g., \"usd\"\n country: string; // e.g., \"US\"\n isProduction?: boolean; // Default: false (TEST environment)\n googleMerchantId?: string; // Google-assigned merchant ID for production (BCR2DN...)\n}\n\nexport type AirwallexShowPaymentResult =\n | { success: true; token: GooglePayEncryptedToken; payerEmail?: string }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\nexport class AirwallexGooglePayAdapter {\n private client: GooglePaymentsClient | null = null;\n private config: AirwallexGooglePayConfig | null = null;\n private mockScenario: AirwallexGooglePayMockScenario;\n\n constructor(mockScenario?: AirwallexGooglePayMockScenario) {\n this.mockScenario = mockScenario ?? AirwallexGooglePayMockScenario.None;\n }\n\n /**\n * Initialize the Google Pay client.\n * Returns true if Google Pay API is available.\n */\n initialize(config: AirwallexGooglePayConfig): boolean {\n // Mock scenarios bypass real Google Pay initialization\n if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {\n console.log(\"[MockGooglePay:Airwallex] initialize called (mock mode)\");\n this.config = config;\n return true;\n }\n\n if (!window.google?.payments?.api?.PaymentsClient) {\n console.error(\"[GooglePay:Airwallex] Google Pay API not loaded\");\n return false;\n }\n\n this.config = config;\n this.client = new window.google.payments.api.PaymentsClient({\n environment: config.isProduction ? \"PRODUCTION\" : \"TEST\",\n });\n\n return this.client !== null;\n }\n\n /**\n * Build the allowed payment methods configuration for Google Pay.\n */\n private getAllowedPaymentMethods(includeTokenization: boolean): AllowedPaymentMethod[] {\n if (!this.config) {\n throw new Error(\"Config not set. Call initialize() first.\");\n }\n\n const baseMethod: AllowedPaymentMethod = {\n type: \"CARD\",\n parameters: {\n allowedAuthMethods: [\"PAN_ONLY\", \"CRYPTOGRAM_3DS\"],\n allowedCardNetworks: [\"VISA\", \"MASTERCARD\", \"AMEX\", \"DISCOVER\", \"JCB\"],\n },\n };\n\n if (includeTokenization) {\n baseMethod.tokenizationSpecification = {\n type: \"PAYMENT_GATEWAY\",\n parameters: {\n gateway: \"airwallex\",\n gatewayMerchantId: this.config.gatewayMerchantId,\n },\n };\n }\n\n return [baseMethod];\n }\n\n /**\n * Check if the user can make a payment with Google Pay.\n */\n async canMakePayment(): Promise<boolean> {\n // Mock scenarios always return true\n if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {\n console.log(\"[MockGooglePay:Airwallex] canMakePayment: true (mock mode)\");\n return true;\n }\n\n if (!this.client) {\n return false;\n }\n\n try {\n const request: IsReadyToPayRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: this.getAllowedPaymentMethods(false),\n };\n\n const response = await this.client.isReadyToPay(request);\n return response.result;\n } catch (error) {\n console.error(\"[GooglePay:Airwallex] canMakePayment error:\", error);\n return false;\n }\n }\n\n /**\n * Show the Google Pay payment sheet and return the encrypted token.\n */\n async showPaymentSheet(): Promise<AirwallexShowPaymentResult> {\n // Handle mock scenarios\n if (this.mockScenario === AirwallexGooglePayMockScenario.Success) {\n console.log(\"[MockGooglePay:Airwallex] showPaymentSheet: returning mock success token\");\n // Return a mock token that the backend will recognize as mock\n const mockToken: GooglePayEncryptedToken = {\n protocolVersion: \"ECv2\",\n signature: \"MOCK_SIGNATURE\",\n intermediateSigningKey: {\n signedKey: \"MOCK_SIGNED_KEY\",\n signatures: [\"MOCK_SIGNATURE\"],\n },\n signedMessage: \"MOCK_SIGNED_MESSAGE\",\n };\n return { success: true, token: mockToken, payerEmail: \"mock@example.com\" };\n }\n\n if (this.mockScenario === AirwallexGooglePayMockScenario.Cancelled) {\n console.log(\"[MockGooglePay:Airwallex] showPaymentSheet: returning mock cancelled\");\n return { success: false, cancelled: true };\n }\n\n // Real Google Pay flow\n if (!this.client || !this.config) {\n return { success: false, error: \"Google Pay not initialized\" };\n }\n\n try {\n const totalPrice = this.config.amountDisplay;\n\n const request: PaymentDataRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: this.getAllowedPaymentMethods(true),\n merchantInfo: {\n merchantName: this.config.merchantId,\n // merchantId is required in PRODUCTION environment\n // It's the Google-assigned merchant ID from Google Pay Business Console\n ...(this.config.isProduction && this.config.googleMerchantId\n ? { merchantId: this.config.googleMerchantId }\n : {}),\n },\n transactionInfo: {\n totalPriceStatus: \"FINAL\",\n totalPrice: totalPrice,\n currencyCode: this.config.currency.toUpperCase(),\n countryCode: this.config.country.toUpperCase(),\n },\n emailRequired: true,\n };\n\n const paymentData = await this.client.loadPaymentData(request);\n\n // Parse the encrypted token from the response\n const tokenString = paymentData.paymentMethodData.tokenizationData.token;\n const token: GooglePayEncryptedToken = JSON.parse(tokenString);\n\n return { success: true, token, payerEmail: paymentData.email };\n } catch (error) {\n // Google Pay API throws an error when user cancels\n if (error instanceof Error && error.message?.includes(\"CANCELED\")) {\n return { success: false, cancelled: true };\n }\n\n // Check for statusCode which indicates user cancelled\n const gpayError = error as { statusCode?: string };\n if (gpayError.statusCode === \"CANCELED\") {\n return { success: false, cancelled: true };\n }\n\n console.error(\"[GooglePay:Airwallex] Payment sheet error:\", error);\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return { success: false, error: errorMessage };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAY,4FAAL;AACL;AACA;AACA;;;AA4GF,IAAa,4BAAb,MAAuC;CACrC,AAAQ,SAAsC;CAC9C,AAAQ,SAA0C;CAClD,AAAQ;CAER,YAAY,cAA+C;AACzD,OAAK,eAAe,gBAAgB,+BAA+B;;;;;;CAOrE,WAAW,QAA2C;AAEpD,MAAI,KAAK,iBAAiB,+BAA+B,MAAM;AAC7D,WAAQ,IAAI,0DAA0D;AACtE,QAAK,SAAS;AACd,UAAO;;AAGT,MAAI,CAAC,OAAO,QAAQ,UAAU,KAAK,gBAAgB;AACjD,WAAQ,MAAM,kDAAkD;AAChE,UAAO;;AAGT,OAAK,SAAS;AACd,OAAK,SAAS,IAAI,OAAO,OAAO,SAAS,IAAI,eAAe,EAC1D,aAAa,OAAO,eAAe,eAAe,QACnD,CAAC;AAEF,SAAO,KAAK,WAAW;;;;;CAMzB,AAAQ,yBAAyB,qBAAsD;AACrF,MAAI,CAAC,KAAK,OACR,OAAM,IAAI,MAAM,2CAA2C;EAG7D,MAAMA,aAAmC;GACvC,MAAM;GACN,YAAY;IACV,oBAAoB,CAAC,YAAY,iBAAiB;IAClD,qBAAqB;KAAC;KAAQ;KAAc;KAAQ;KAAY;KAAM;IACvE;GACF;AAED,MAAI,oBACF,YAAW,4BAA4B;GACrC,MAAM;GACN,YAAY;IACV,SAAS;IACT,mBAAmB,KAAK,OAAO;IAChC;GACF;AAGH,SAAO,CAAC,WAAW;;;;;CAMrB,MAAM,iBAAmC;AAEvC,MAAI,KAAK,iBAAiB,+BAA+B,MAAM;AAC7D,WAAQ,IAAI,6DAA6D;AACzE,UAAO;;AAGT,MAAI,CAAC,KAAK,OACR,QAAO;AAGT,MAAI;GACF,MAAMC,UAA+B;IACnC,YAAY;IACZ,iBAAiB;IACjB,uBAAuB,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AAE,SAAS;IAAO,WAAW;IAAM;AAK5C,OADkB,MACJ,eAAe,WAC3B,QAAO;IAAE,SAAS;IAAO,WAAW;IAAM;AAG5C,WAAQ,MAAM,8CAA8C,MAAM;AAElE,UAAO;IAAE,SAAS;IAAO,OADJ,iBAAiB,QAAQ,MAAM,UAAU;IAChB"}
|
|
1
|
+
{"version":3,"file":"airwallex-google-pay-adapter-C8JTp01q.mjs","names":["baseMethod: AllowedPaymentMethod","request: IsReadyToPayRequest","request: PaymentDataRequest"],"sources":["../src/payment-methods/airwallex-google-pay-adapter.ts"],"sourcesContent":["/**\n * Airwallex Google Pay Adapter\n *\n * Uses Google Pay API directly (not Stripe.js) to show the payment sheet\n * and extract the encrypted payment token for Airwallex processing.\n *\n * Flow:\n * 1. initialize() - Checks if Google Pay API is available\n * 2. createPaymentDataRequest() - Configures the payment request\n * 3. canMakePayment() - Checks if user can pay with Google Pay\n * 4. showPaymentSheet() - Shows Google Pay sheet and returns encrypted token\n *\n * Mock scenarios are supported for E2E testing without real Google Pay.\n */\n\nexport enum AirwallexGooglePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n// Google Pay API types\n// See: https://developers.google.com/pay/api/web/reference/request-objects\ndeclare global {\n interface Window {\n google?: {\n payments: {\n api: {\n PaymentsClient: new (config: GooglePayClientConfig) => GooglePaymentsClient;\n };\n };\n };\n }\n}\n\ninterface GooglePayClientConfig {\n environment: \"TEST\" | \"PRODUCTION\";\n}\n\ninterface GooglePaymentsClient {\n isReadyToPay(request: IsReadyToPayRequest): Promise<IsReadyToPayResponse>;\n loadPaymentData(request: PaymentDataRequest): Promise<PaymentData>;\n}\n\ninterface IsReadyToPayRequest {\n apiVersion: number;\n apiVersionMinor: number;\n allowedPaymentMethods: AllowedPaymentMethod[];\n}\n\ninterface IsReadyToPayResponse {\n result: boolean;\n}\n\ninterface AllowedPaymentMethod {\n type: \"CARD\";\n parameters: {\n allowedAuthMethods: (\"PAN_ONLY\" | \"CRYPTOGRAM_3DS\")[];\n allowedCardNetworks: (\"VISA\" | \"MASTERCARD\" | \"AMEX\" | \"DISCOVER\" | \"JCB\")[];\n };\n tokenizationSpecification?: TokenizationSpecification;\n}\n\ninterface TokenizationSpecification {\n type: \"PAYMENT_GATEWAY\";\n parameters: {\n gateway: string;\n gatewayMerchantId: string;\n };\n}\n\ninterface PaymentDataRequest extends IsReadyToPayRequest {\n merchantInfo: {\n merchantId?: string;\n merchantName: string;\n };\n transactionInfo: {\n totalPriceStatus: \"FINAL\" | \"ESTIMATED\";\n totalPrice: string;\n currencyCode: string;\n countryCode: string;\n };\n emailRequired?: boolean;\n}\n\ninterface PaymentData {\n email?: string;\n paymentMethodData: {\n type: string;\n tokenizationData: {\n type: string;\n token: string; // JSON string containing the encrypted payment token\n };\n info?: {\n cardNetwork: string;\n cardDetails: string;\n };\n };\n}\n\n// Google Pay encrypted token structure (what's inside tokenizationData.token)\nexport interface GooglePayEncryptedToken {\n protocolVersion: string;\n signature: string;\n intermediateSigningKey: {\n signedKey: string;\n signatures: string[];\n };\n signedMessage: string;\n}\n\nexport interface AirwallexGooglePayConfig {\n merchantId: string; // Business name for display\n gatewayMerchantId: string; // Airwallex account ID (acct_xxxx)\n amountDisplay: string; // Formatted amount for Google Pay (e.g., \"100.00\" for USD, \"1000\" for JPY)\n currency: string; // e.g., \"usd\"\n country: string; // e.g., \"US\"\n isProduction?: boolean; // Default: false (TEST environment)\n googleMerchantId?: string; // Google-assigned merchant ID for production (BCR2DN...)\n}\n\nexport type AirwallexShowPaymentResult =\n | { success: true; token: GooglePayEncryptedToken; payerEmail?: string }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\nexport class AirwallexGooglePayAdapter {\n private client: GooglePaymentsClient | null = null;\n private config: AirwallexGooglePayConfig | null = null;\n private mockScenario: AirwallexGooglePayMockScenario;\n\n constructor(mockScenario?: AirwallexGooglePayMockScenario) {\n this.mockScenario = mockScenario ?? AirwallexGooglePayMockScenario.None;\n }\n\n /**\n * Initialize the Google Pay client.\n * Returns true if Google Pay API is available.\n */\n initialize(config: AirwallexGooglePayConfig): boolean {\n // Mock scenarios bypass real Google Pay initialization\n if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {\n console.log(\"[MockGooglePay:Airwallex] initialize called (mock mode)\");\n this.config = config;\n return true;\n }\n\n if (!window.google?.payments?.api?.PaymentsClient) {\n console.error(\"[GooglePay:Airwallex] Google Pay API not loaded\");\n return false;\n }\n\n this.config = config;\n this.client = new window.google.payments.api.PaymentsClient({\n environment: config.isProduction ? \"PRODUCTION\" : \"TEST\",\n });\n\n return this.client !== null;\n }\n\n /**\n * Build the allowed payment methods configuration for Google Pay.\n */\n private getAllowedPaymentMethods(includeTokenization: boolean): AllowedPaymentMethod[] {\n if (!this.config) {\n throw new Error(\"Config not set. Call initialize() first.\");\n }\n\n const baseMethod: AllowedPaymentMethod = {\n type: \"CARD\",\n parameters: {\n allowedAuthMethods: [\"PAN_ONLY\", \"CRYPTOGRAM_3DS\"],\n allowedCardNetworks: [\"VISA\", \"MASTERCARD\", \"AMEX\", \"DISCOVER\", \"JCB\"],\n },\n };\n\n if (includeTokenization) {\n baseMethod.tokenizationSpecification = {\n type: \"PAYMENT_GATEWAY\",\n parameters: {\n gateway: \"airwallex\",\n gatewayMerchantId: this.config.gatewayMerchantId,\n },\n };\n }\n\n return [baseMethod];\n }\n\n /**\n * Check if the user can make a payment with Google Pay.\n */\n async canMakePayment(): Promise<boolean> {\n // Mock scenarios always return true\n if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {\n console.log(\"[MockGooglePay:Airwallex] canMakePayment: true (mock mode)\");\n return true;\n }\n\n if (!this.client) {\n return false;\n }\n\n try {\n const request: IsReadyToPayRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: this.getAllowedPaymentMethods(false),\n };\n\n const response = await this.client.isReadyToPay(request);\n return response.result;\n } catch (error) {\n console.error(\"[GooglePay:Airwallex] canMakePayment error:\", error);\n return false;\n }\n }\n\n /**\n * Show the Google Pay payment sheet and return the encrypted token.\n */\n async showPaymentSheet(): Promise<AirwallexShowPaymentResult> {\n // Handle mock scenarios\n if (this.mockScenario === AirwallexGooglePayMockScenario.Success) {\n console.log(\"[MockGooglePay:Airwallex] showPaymentSheet: returning mock success token\");\n // Return a mock token that the backend will recognize as mock\n const mockToken: GooglePayEncryptedToken = {\n protocolVersion: \"ECv2\",\n signature: \"MOCK_SIGNATURE\",\n intermediateSigningKey: {\n signedKey: \"MOCK_SIGNED_KEY\",\n signatures: [\"MOCK_SIGNATURE\"],\n },\n signedMessage: \"MOCK_SIGNED_MESSAGE\",\n };\n return { success: true, token: mockToken, payerEmail: \"mock@example.com\" };\n }\n\n if (this.mockScenario === AirwallexGooglePayMockScenario.Cancelled) {\n console.log(\"[MockGooglePay:Airwallex] showPaymentSheet: returning mock cancelled\");\n return { success: false, cancelled: true };\n }\n\n // Real Google Pay flow\n if (!this.client || !this.config) {\n return { success: false, error: \"Google Pay not initialized\" };\n }\n\n try {\n const totalPrice = this.config.amountDisplay;\n\n const request: PaymentDataRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: this.getAllowedPaymentMethods(true),\n merchantInfo: {\n merchantName: this.config.merchantId,\n // merchantId is required in PRODUCTION environment\n // It's the Google-assigned merchant ID from Google Pay Business Console\n ...(this.config.isProduction && this.config.googleMerchantId\n ? { merchantId: this.config.googleMerchantId }\n : {}),\n },\n transactionInfo: {\n totalPriceStatus: \"FINAL\",\n totalPrice: totalPrice,\n currencyCode: this.config.currency.toUpperCase(),\n countryCode: this.config.country.toUpperCase(),\n },\n emailRequired: true,\n };\n\n const paymentData = await this.client.loadPaymentData(request);\n\n // Parse the encrypted token from the response\n const tokenString = paymentData.paymentMethodData.tokenizationData.token;\n const token: GooglePayEncryptedToken = JSON.parse(tokenString);\n\n return { success: true, token, payerEmail: paymentData.email };\n } catch (error) {\n // Google Pay API throws an error when user cancels\n if (error instanceof Error && error.message?.includes(\"CANCELED\")) {\n return { success: false, cancelled: true };\n }\n\n // Check for statusCode which indicates user cancelled\n const gpayError = error as { statusCode?: string };\n if (gpayError.statusCode === \"CANCELED\") {\n return { success: false, cancelled: true };\n }\n\n console.error(\"[GooglePay:Airwallex] Payment sheet error:\", error);\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return { success: false, error: errorMessage };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAY,4FAAL;AACL;AACA;AACA;;;AA4GF,IAAa,4BAAb,MAAuC;CACrC,AAAQ,SAAsC;CAC9C,AAAQ,SAA0C;CAClD,AAAQ;CAER,YAAY,cAA+C;AACzD,OAAK,eAAe,gBAAgB,+BAA+B;;;;;;CAOrE,WAAW,QAA2C;AAEpD,MAAI,KAAK,iBAAiB,+BAA+B,MAAM;AAC7D,WAAQ,IAAI,0DAA0D;AACtE,QAAK,SAAS;AACd,UAAO;;AAGT,MAAI,CAAC,OAAO,QAAQ,UAAU,KAAK,gBAAgB;AACjD,WAAQ,MAAM,kDAAkD;AAChE,UAAO;;AAGT,OAAK,SAAS;AACd,OAAK,SAAS,IAAI,OAAO,OAAO,SAAS,IAAI,eAAe,EAC1D,aAAa,OAAO,eAAe,eAAe,QACnD,CAAC;AAEF,SAAO,KAAK,WAAW;;;;;CAMzB,AAAQ,yBAAyB,qBAAsD;AACrF,MAAI,CAAC,KAAK,OACR,OAAM,IAAI,MAAM,2CAA2C;EAG7D,MAAMA,aAAmC;GACvC,MAAM;GACN,YAAY;IACV,oBAAoB,CAAC,YAAY,iBAAiB;IAClD,qBAAqB;KAAC;KAAQ;KAAc;KAAQ;KAAY;KAAM;IACvE;GACF;AAED,MAAI,oBACF,YAAW,4BAA4B;GACrC,MAAM;GACN,YAAY;IACV,SAAS;IACT,mBAAmB,KAAK,OAAO;IAChC;GACF;AAGH,SAAO,CAAC,WAAW;;;;;CAMrB,MAAM,iBAAmC;AAEvC,MAAI,KAAK,iBAAiB,+BAA+B,MAA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,UAAO;IAAE,SAAS;IAAM,OAFe,KAAK,MAAM,YAAY;IAE/B,YAAY,YAAY;IAAO;WACvD,OAAO;AAEd,OAAI,iBAAiB,SAAS,MAAM,SAAS,SAAS,WAAW,CAC/D,QAAO;IAAE,SAAS;IAAO,WAAW;IAAM;AAK5C,OADkB,MACJ,eAAe,WAC3B,QAAO;IAAE,SAAS;IAAO,WAAW;IAAM;AAG5C,WAAQ,MAAM,8CAA8C,MAAM;AAElE,UAAO;IAAE,SAAS;IAAO,OADJ,iBAAiB,QAAQ,MAAM,UAAU;IAChB"}
|
|
@@ -140,4 +140,4 @@ declare class AirwallexGooglePayAdapter {
|
|
|
140
140
|
}
|
|
141
141
|
//#endregion
|
|
142
142
|
export { GooglePayEncryptedToken as a, AirwallexShowPaymentResult as i, AirwallexGooglePayConfig as n, AirwallexGooglePayMockScenario as r, AirwallexGooglePayAdapter as t };
|
|
143
|
-
//# sourceMappingURL=airwallex-google-pay-adapter-
|
|
143
|
+
//# sourceMappingURL=airwallex-google-pay-adapter-adaDktQM.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"airwallex-google-pay-adapter-
|
|
1
|
+
{"version":3,"file":"airwallex-google-pay-adapter-adaDktQM.d.mts","names":[],"sources":["../src/payment-methods/airwallex-google-pay-adapter.ts"],"sourcesContent":[],"mappings":";;AAeA;AAIC;;;;;AASoF;AAOtD;;;;;;AAMiB,aA1BpC,8BAAA;EA0B2C,IAAA,GAAA,MAAA;EAG7C,OAAA,GAAA,SAAA;EAMA,SAAA,GAAA,WAAoB;AAAA;AAUyB,QAG7C,MAAA,CAAA;EAQA,UAAA,MAAA,CAAA;IAcA,MAAA,CAAA,EAAA;MAgBO,QAAA,EAAA;QAUA,GAAA,EAAA;UAUL,cAA0B,EAAA,KAAA,MACV,EA9FW,qBA8FY,EAAA,GA9Fc,oBA8Fd;QAItC,CAAA;MAKgB,CAAA;IAQR,CAAA;EAqDK;;UA7JhB,qBAAA,CA0LkB;EAAO,WAAA,EAAA,MAAA,GAAA,YAAA;;UAtLzB,oBAAA;wBACc,sBAAsB,QAAQ;2BAC3B,qBAAqB,QAAQ;;UAG9C,mBAAA;;;yBAGe;;UAGf,oBAAA;;;UAIA,oBAAA;;;;;;8BAMoB;;UAGpB,yBAAA;;;;;;;UAQA,kBAAA,SAA2B;;;;;;;;;;;;;UAc3B,WAAA;;;;;;;;;;;;;;UAgBO,uBAAA;;;;;;;;;UAUA,wBAAA;;;;;;;;;KAUL,0BAAA;;SACgB;;;;;;;;;cAIf,yBAAA;;;;6BAKgB;;;;;qBAQR;;;;;;;;oBAqDK;;;;sBA6BE,QAAQ"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { r as PaymentMethod } from "./types-CQ8xbgoh.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/payment-methods/bnpl-shared.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared BNPL (Buy Now Pay Later) payment method factory.
|
|
7
|
+
* Used by Klarna, Afterpay, and Affirm payment methods.
|
|
8
|
+
*/
|
|
9
|
+
type BnplCustomerInfo = {
|
|
10
|
+
first_name: string;
|
|
11
|
+
last_name: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
};
|
|
14
|
+
type BnplStartRequest = {
|
|
15
|
+
processor_id: string;
|
|
16
|
+
customer_info: BnplCustomerInfo;
|
|
17
|
+
fraud_metadata: {
|
|
18
|
+
ipAddress?: string;
|
|
19
|
+
browserInfo?: {
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
processorFraudInfo?: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
setup_future_usage?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type BnplStartResponse = {
|
|
29
|
+
approval_url: string;
|
|
30
|
+
popup_token: string;
|
|
31
|
+
checkout_attempt_id: string;
|
|
32
|
+
};
|
|
33
|
+
type BnplStatusResponse = {
|
|
34
|
+
completed: boolean;
|
|
35
|
+
status: "success" | "failed" | "cancelled";
|
|
36
|
+
result?: unknown;
|
|
37
|
+
error?: string;
|
|
38
|
+
};
|
|
39
|
+
type BnplCheckoutResponse = {
|
|
40
|
+
id: string;
|
|
41
|
+
checkoutAttemptId: string;
|
|
42
|
+
checkoutSessionId: string;
|
|
43
|
+
state: string;
|
|
44
|
+
customerId?: string;
|
|
45
|
+
paymentMethodId?: string;
|
|
46
|
+
processorUsed?: string;
|
|
47
|
+
subscriptionId?: string;
|
|
48
|
+
invoiceId?: string;
|
|
49
|
+
invoiceNumber?: number;
|
|
50
|
+
};
|
|
51
|
+
type BnplSubmitOptions = {
|
|
52
|
+
processorId: string;
|
|
53
|
+
customerInfo: BnplCustomerInfo;
|
|
54
|
+
setupFutureUsage?: boolean;
|
|
55
|
+
};
|
|
56
|
+
type BnplProviderConfig = {
|
|
57
|
+
name: string;
|
|
58
|
+
endpointPath: string;
|
|
59
|
+
supportsSetupFutureUsage?: boolean;
|
|
60
|
+
};
|
|
61
|
+
declare function createBnplPaymentMethod(config: BnplProviderConfig): PaymentMethod<{}, string>;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { BnplStartResponse as a, createBnplPaymentMethod as c, BnplStartRequest as i, BnplCustomerInfo as n, BnplStatusResponse as o, BnplProviderConfig as r, BnplSubmitOptions as s, BnplCheckoutResponse as t };
|
|
64
|
+
//# sourceMappingURL=bnpl-shared-B-en2sPr.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bnpl-shared-B-en2sPr.d.mts","names":[],"sources":["../src/payment-methods/bnpl-shared.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAMY,KANA,gBAAA,GAMgB;EAWhB,UAAA,EAAA,MAAA;EAMA,SAAA,EAAA,MAAA;EAOA,KAAA,CAAA,EAAA,MAAA;AAaZ,CAAA;AAWY,KAhDA,gBAAA,GAgDkB;EAiKd,YAAA,EAAA,MAAA;iBA/MC;;;;;;;;;;;;KASL,iBAAA;;;;;KAMA,kBAAA;;;;;;KAOA,oBAAA;;;;;;;;;;;;KAaA,iBAAA;;gBAEI;;;KASJ,kBAAA;;;;;iBAiKI,uBAAA,SAAgC,qBAAkB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { i as definePaymentMethod, n as collectFraudMetadata, o as getOrCreateCheckoutRequestId } from "./utils-B70Y8YcZ.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/payment-methods/bnpl-shared.ts
|
|
4
|
+
const createSubmitPayment = (states, config) => {
|
|
5
|
+
const { name, endpointPath, supportsSetupFutureUsage } = config;
|
|
6
|
+
const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
7
|
+
const submitPayment = async (_fields, options) => {
|
|
8
|
+
const { apiBaseUrl, secureToken, environment } = states;
|
|
9
|
+
const bnplOptions = options;
|
|
10
|
+
if (!bnplOptions?.processorId) return { errors: { processor_id: "Processor ID is required" } };
|
|
11
|
+
if (!bnplOptions?.customerInfo?.first_name || !bnplOptions?.customerInfo?.last_name) return { errors: { customer_name: "Customer first and last name are required" } };
|
|
12
|
+
try {
|
|
13
|
+
const checkoutRequestId = getOrCreateCheckoutRequestId(environment);
|
|
14
|
+
const requestBody = {
|
|
15
|
+
processor_id: bnplOptions.processorId,
|
|
16
|
+
customer_info: bnplOptions.customerInfo,
|
|
17
|
+
fraud_metadata: collectFraudMetadata()
|
|
18
|
+
};
|
|
19
|
+
if (supportsSetupFutureUsage && bnplOptions.setupFutureUsage !== void 0) requestBody.setup_future_usage = bnplOptions.setupFutureUsage;
|
|
20
|
+
const startResponse = await fetch(`${apiBaseUrl}/api/checkout/${secureToken}/stripe/${endpointPath}/start`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
"x-request-id": checkoutRequestId
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify(requestBody)
|
|
27
|
+
});
|
|
28
|
+
if (!startResponse.ok) {
|
|
29
|
+
let errorMessage = `Failed to start ${capitalizedName} checkout (${startResponse.status})`;
|
|
30
|
+
try {
|
|
31
|
+
errorMessage = (await startResponse.json()).detail || errorMessage;
|
|
32
|
+
} catch {
|
|
33
|
+
errorMessage = startResponse.statusText || errorMessage;
|
|
34
|
+
}
|
|
35
|
+
return { errors: { [name]: errorMessage } };
|
|
36
|
+
}
|
|
37
|
+
const { approval_url, popup_token, checkout_attempt_id } = await startResponse.json();
|
|
38
|
+
const popup = window.open(approval_url, capitalizedName, "width=600,height=700");
|
|
39
|
+
if (!popup) return { errors: { [name]: `Failed to open ${capitalizedName} popup. Please allow popups for this site.` } };
|
|
40
|
+
states.popup = popup;
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
let popupClosedGracePolls = 0;
|
|
43
|
+
const MAX_GRACE_POLLS = 5;
|
|
44
|
+
const pollInterval = setInterval(async () => {
|
|
45
|
+
try {
|
|
46
|
+
const statusResponse = await fetch(`${apiBaseUrl}/api/checkout/${secureToken}/popup/status?popup_token=${popup_token}`);
|
|
47
|
+
if (!statusResponse.ok) {
|
|
48
|
+
clearInterval(pollInterval);
|
|
49
|
+
popup.close();
|
|
50
|
+
resolve({ errors: { [name]: `Failed to check ${capitalizedName} status` } });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const statusResult = await statusResponse.json();
|
|
54
|
+
if (statusResult.completed) {
|
|
55
|
+
clearInterval(pollInterval);
|
|
56
|
+
popup.close();
|
|
57
|
+
if (statusResult.status === "success") resolve({ data: statusResult.result || {
|
|
58
|
+
id: checkout_attempt_id,
|
|
59
|
+
checkoutAttemptId: checkout_attempt_id,
|
|
60
|
+
checkoutSessionId: secureToken,
|
|
61
|
+
state: "checkout_succeeded"
|
|
62
|
+
} });
|
|
63
|
+
else resolve({ errors: { [name]: statusResult.error || `${capitalizedName} checkout ${statusResult.status}` } });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (popup.closed) {
|
|
67
|
+
popupClosedGracePolls++;
|
|
68
|
+
if (popupClosedGracePolls >= MAX_GRACE_POLLS) {
|
|
69
|
+
clearInterval(pollInterval);
|
|
70
|
+
resolve({ errors: { [name]: `${capitalizedName} popup closed by user` } });
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
clearInterval(pollInterval);
|
|
76
|
+
popup.close();
|
|
77
|
+
resolve({ errors: { [name]: `Polling error: ${error}` } });
|
|
78
|
+
}
|
|
79
|
+
}, 2e3);
|
|
80
|
+
states.pollInterval = pollInterval;
|
|
81
|
+
});
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return { errors: { [name]: `${capitalizedName} checkout error: ${error}` } };
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return submitPayment;
|
|
87
|
+
};
|
|
88
|
+
function createBnplPaymentMethod(config) {
|
|
89
|
+
return definePaymentMethod((paymentKitStates) => {
|
|
90
|
+
const localStates = { ...paymentKitStates };
|
|
91
|
+
return {
|
|
92
|
+
name: config.name,
|
|
93
|
+
externalFuncs: {},
|
|
94
|
+
internalFuncs: {
|
|
95
|
+
submitPayment: createSubmitPayment(localStates, config),
|
|
96
|
+
cleanup: () => {
|
|
97
|
+
if (localStates.pollInterval) clearInterval(localStates.pollInterval);
|
|
98
|
+
if (localStates.popup && !localStates.popup.closed) localStates.popup.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { createBnplPaymentMethod as t };
|
|
107
|
+
//# sourceMappingURL=bnpl-shared-CEAXTL3Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bnpl-shared-CEAXTL3Q.mjs","names":["submitPayment: TInternalFuncs[\"submitPayment\"]","requestBody: BnplStartRequest","localStates: BnplStates"],"sources":["../src/payment-methods/bnpl-shared.ts"],"sourcesContent":["/**\n * Shared BNPL (Buy Now Pay Later) payment method factory.\n * Used by Klarna, Afterpay, and Affirm payment methods.\n */\n\nimport type { PaymentKitErrors, PaymentKitStates, TInternalFuncs } from \"../types\";\nimport { collectFraudMetadata, definePaymentMethod, getOrCreateCheckoutRequestId } from \"../utils\";\n\nexport type BnplCustomerInfo = {\n first_name: string;\n last_name: string;\n email?: string;\n};\n\nexport type BnplStartRequest = {\n processor_id: string;\n customer_info: BnplCustomerInfo;\n fraud_metadata: {\n ipAddress?: string;\n browserInfo?: { [key: string]: unknown };\n processorFraudInfo?: { [key: string]: unknown };\n };\n setup_future_usage?: boolean;\n};\n\nexport type BnplStartResponse = {\n approval_url: string;\n popup_token: string;\n checkout_attempt_id: string;\n};\n\nexport type BnplStatusResponse = {\n completed: boolean;\n status: \"success\" | \"failed\" | \"cancelled\";\n result?: unknown;\n error?: string;\n};\n\nexport type BnplCheckoutResponse = {\n id: string;\n checkoutAttemptId: string;\n checkoutSessionId: string;\n state: string;\n customerId?: string;\n paymentMethodId?: string;\n processorUsed?: string;\n subscriptionId?: string;\n invoiceId?: string;\n invoiceNumber?: number;\n};\n\nexport type BnplSubmitOptions = {\n processorId: string;\n customerInfo: BnplCustomerInfo;\n setupFutureUsage?: boolean;\n};\n\ntype BnplStates = PaymentKitStates & {\n popup?: Window | null;\n pollInterval?: ReturnType<typeof setInterval>;\n};\n\nexport type BnplProviderConfig = {\n name: string;\n endpointPath: string;\n supportsSetupFutureUsage?: boolean;\n};\n\nconst createSubmitPayment = (states: BnplStates, config: BnplProviderConfig) => {\n const { name, endpointPath, supportsSetupFutureUsage } = config;\n const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);\n\n const submitPayment: TInternalFuncs[\"submitPayment\"] = async (_fields, options) => {\n const { apiBaseUrl, secureToken, environment } = states;\n const bnplOptions = options as BnplSubmitOptions;\n\n if (!bnplOptions?.processorId) {\n return { errors: { processor_id: \"Processor ID is required\" } as PaymentKitErrors };\n }\n\n if (!bnplOptions?.customerInfo?.first_name || !bnplOptions?.customerInfo?.last_name) {\n return {\n errors: {\n customer_name: \"Customer first and last name are required\",\n } as PaymentKitErrors,\n };\n }\n\n try {\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n\n const requestBody: BnplStartRequest = {\n processor_id: bnplOptions.processorId,\n customer_info: bnplOptions.customerInfo,\n fraud_metadata: collectFraudMetadata(),\n };\n\n if (supportsSetupFutureUsage && bnplOptions.setupFutureUsage !== undefined) {\n requestBody.setup_future_usage = bnplOptions.setupFutureUsage;\n }\n\n const startResponse = await fetch(`${apiBaseUrl}/api/checkout/${secureToken}/stripe/${endpointPath}/start`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-request-id\": checkoutRequestId,\n },\n body: JSON.stringify(requestBody),\n });\n\n if (!startResponse.ok) {\n let errorMessage = `Failed to start ${capitalizedName} checkout (${startResponse.status})`;\n try {\n const errorData = await startResponse.json();\n errorMessage = errorData.detail || errorMessage;\n } catch {\n errorMessage = startResponse.statusText || errorMessage;\n }\n return {\n errors: {\n [name]: errorMessage,\n } as PaymentKitErrors,\n };\n }\n\n const { approval_url, popup_token, checkout_attempt_id } = (await startResponse.json()) as BnplStartResponse;\n\n const popup = window.open(approval_url, capitalizedName, \"width=600,height=700\");\n\n if (!popup) {\n return {\n errors: {\n [name]: `Failed to open ${capitalizedName} popup. Please allow popups for this site.`,\n } as PaymentKitErrors,\n };\n }\n\n states.popup = popup;\n\n return new Promise((resolve) => {\n let popupClosedGracePolls = 0;\n const MAX_GRACE_POLLS = 5;\n\n const pollInterval = setInterval(async () => {\n try {\n const statusResponse = await fetch(\n `${apiBaseUrl}/api/checkout/${secureToken}/popup/status?popup_token=${popup_token}`,\n );\n\n if (!statusResponse.ok) {\n clearInterval(pollInterval);\n popup.close();\n resolve({\n errors: {\n [name]: `Failed to check ${capitalizedName} status`,\n } as PaymentKitErrors,\n });\n return;\n }\n\n const statusResult = (await statusResponse.json()) as BnplStatusResponse;\n\n if (statusResult.completed) {\n clearInterval(pollInterval);\n popup.close();\n\n if (statusResult.status === \"success\") {\n // Result is returned directly from popup status endpoint\n const result = statusResult.result || {\n id: checkout_attempt_id,\n checkoutAttemptId: checkout_attempt_id,\n checkoutSessionId: secureToken,\n state: \"checkout_succeeded\",\n };\n\n resolve({ data: result });\n } else {\n resolve({\n errors: {\n [name]: statusResult.error || `${capitalizedName} checkout ${statusResult.status}`,\n } as PaymentKitErrors,\n });\n }\n return;\n }\n\n if (popup.closed) {\n popupClosedGracePolls++;\n if (popupClosedGracePolls >= MAX_GRACE_POLLS) {\n clearInterval(pollInterval);\n resolve({\n errors: {\n [name]: `${capitalizedName} popup closed by user`,\n } as PaymentKitErrors,\n });\n }\n return;\n }\n } catch (error) {\n clearInterval(pollInterval);\n popup.close();\n resolve({\n errors: {\n [name]: `Polling error: ${error}`,\n } as PaymentKitErrors,\n });\n }\n }, 2000);\n\n states.pollInterval = pollInterval;\n });\n } catch (error) {\n return {\n errors: {\n [name]: `${capitalizedName} checkout error: ${error}`,\n } as PaymentKitErrors,\n };\n }\n };\n\n return submitPayment;\n};\n\nexport function createBnplPaymentMethod(config: BnplProviderConfig) {\n return definePaymentMethod((paymentKitStates) => {\n const localStates: BnplStates = { ...paymentKitStates };\n\n return {\n name: config.name,\n externalFuncs: {},\n internalFuncs: {\n submitPayment: createSubmitPayment(localStates, config),\n cleanup: () => {\n if (localStates.pollInterval) {\n clearInterval(localStates.pollInterval);\n }\n if (localStates.popup && !localStates.popup.closed) {\n localStates.popup.close();\n }\n },\n },\n };\n });\n}\n"],"mappings":";;;AAoEA,MAAM,uBAAuB,QAAoB,WAA+B;CAC9E,MAAM,EAAE,MAAM,cAAc,6BAA6B;CACzD,MAAM,kBAAkB,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;CAEpE,MAAMA,gBAAiD,OAAO,SAAS,YAAY;EACjF,MAAM,EAAE,YAAY,aAAa,gBAAgB;EACjD,MAAM,cAAc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