@payment-kit-js/vanilla 0.4.1 → 0.5.2
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-BE15xREr.mjs +237 -0
- package/dist/airwallex-apple-pay-adapter-BE15xREr.mjs.map +1 -0
- package/dist/airwallex-apple-pay-adapter-I_pnNYdy.d.mts +98 -0
- package/dist/airwallex-apple-pay-adapter-I_pnNYdy.d.mts.map +1 -0
- package/dist/{airwallex-google-pay-adapter-BCmTZip5.mjs → airwallex-google-pay-adapter-CHol_8f2.mjs} +1 -1
- package/dist/{airwallex-google-pay-adapter-BCmTZip5.mjs.map → airwallex-google-pay-adapter-CHol_8f2.mjs.map} +1 -1
- package/dist/{airwallex-google-pay-adapter-Be2Af4N9.d.mts → airwallex-google-pay-adapter-CY379Rre.d.mts} +1 -1
- package/dist/{airwallex-google-pay-adapter-Be2Af4N9.d.mts.map → airwallex-google-pay-adapter-CY379Rre.d.mts.map} +1 -1
- package/dist/cdn/paymentkit.js +789 -420
- package/dist/cdn/paymentkit.js.map +4 -4
- package/dist/cdn/paymentkit.min.js +6 -6
- package/dist/cdn/paymentkit.min.js.map +4 -4
- package/dist/{connect-card-BrtCmsjz.mjs → connect-card-CMZkeppE.mjs} +1 -1
- package/dist/{connect-card-BrtCmsjz.mjs.map → connect-card-CMZkeppE.mjs.map} +1 -1
- package/dist/{connect-card-DTfXuTsW.d.mts → connect-card-Cxy51W6t.d.mts} +1 -1
- package/dist/{connect-card-DTfXuTsW.d.mts.map → connect-card-Cxy51W6t.d.mts.map} +1 -1
- package/dist/connect-tunnel-x-BhVAej5Q.mjs.map +1 -1
- package/dist/{connect-tunnel-x-Dxcg5Y7Y.d.mts → connect-tunnel-x-lv6Wtdme.d.mts} +6 -1
- package/dist/connect-tunnel-x-lv6Wtdme.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +76 -14
- package/dist/index.mjs.map +1 -1
- package/dist/{next-action-handlers-BZs04hYb.mjs → next-action-handlers-CTx8tRt0.mjs} +1 -1
- package/dist/{next-action-handlers-BZs04hYb.mjs.map → next-action-handlers-CTx8tRt0.mjs.map} +1 -1
- package/dist/payment-methods/airwallex-apple-pay-adapter.d.mts +2 -0
- package/dist/payment-methods/airwallex-apple-pay-adapter.mjs +3 -0
- 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 +37 -17
- package/dist/payment-methods/apple-pay.d.mts.map +1 -1
- package/dist/payment-methods/apple-pay.mjs +203 -37
- package/dist/payment-methods/apple-pay.mjs.map +1 -1
- package/dist/payment-methods/card.d.mts +3 -3
- package/dist/payment-methods/card.d.mts.map +1 -1
- package/dist/payment-methods/card.mjs +208 -41
- package/dist/payment-methods/card.mjs.map +1 -1
- package/dist/payment-methods/google-pay.d.mts +5 -5
- package/dist/payment-methods/google-pay.d.mts.map +1 -1
- package/dist/payment-methods/google-pay.mjs +6 -7
- package/dist/payment-methods/google-pay.mjs.map +1 -1
- package/dist/payment-methods/next-action-handlers.mjs +1 -1
- package/dist/payment-methods/paypal.d.mts +3 -3
- package/dist/payment-methods/paypal.mjs +3 -3
- 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.d.mts +28 -0
- package/dist/payment-methods/vgs-collect-loader.d.mts.map +1 -0
- package/dist/payment-methods/vgs-collect-loader.mjs +3 -0
- 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-Bg7nCy3P.mjs → stripe-apple-pay-adapter-Cd9LVNnp.mjs} +1 -1
- package/dist/{stripe-apple-pay-adapter-Bg7nCy3P.mjs.map → stripe-apple-pay-adapter-Cd9LVNnp.mjs.map} +1 -1
- package/dist/{stripe-apple-pay-adapter-Bq3f1mqv.d.mts → stripe-apple-pay-adapter-DhpGclW9.d.mts} +1 -1
- package/dist/{stripe-apple-pay-adapter-Bq3f1mqv.d.mts.map → stripe-apple-pay-adapter-DhpGclW9.d.mts.map} +1 -1
- package/dist/{stripe-google-pay-adapter-xktEycOD.d.mts → stripe-google-pay-adapter-C3NCBSO3.d.mts} +1 -1
- package/dist/{stripe-google-pay-adapter-xktEycOD.d.mts.map → stripe-google-pay-adapter-C3NCBSO3.d.mts.map} +1 -1
- package/dist/{stripe-google-pay-adapter-DjrgDYWe.mjs → stripe-google-pay-adapter-CqcUEoM3.mjs} +1 -1
- package/dist/{stripe-google-pay-adapter-DjrgDYWe.mjs.map → stripe-google-pay-adapter-CqcUEoM3.mjs.map} +1 -1
- package/dist/{types-CPuloCtF.d.mts → types-CZk3V0Qt.d.mts} +24 -6
- package/dist/types-CZk3V0Qt.d.mts.map +1 -0
- package/dist/{utils-Dgyk7RkM.mjs → utils-B70Y8YcZ.mjs} +20 -9
- package/dist/utils-B70Y8YcZ.mjs.map +1 -0
- package/dist/vgs-collect-loader-D3_xOA-G.mjs +93 -0
- package/dist/vgs-collect-loader-D3_xOA-G.mjs.map +1 -0
- package/package.json +4 -2
- package/dist/connect-tunnel-x-Dxcg5Y7Y.d.mts.map +0 -1
- package/dist/types-CPuloCtF.d.mts.map +0 -1
- package/dist/utils-Dgyk7RkM.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal.mjs","names":["submitPayment: TInternalFuncs[\"submitPayment\"]","localStates: PayPalStates"],"sources":["../../src/payment-methods/paypal.ts"],"sourcesContent":["import type { PaymentKitErrors, PaymentKitStates, TInternalFuncs } from \"../types\";\nimport { collectFraudMetadata, definePaymentMethod,
|
|
1
|
+
{"version":3,"file":"paypal.mjs","names":["submitPayment: TInternalFuncs[\"submitPayment\"]","localStates: PayPalStates"],"sources":["../../src/payment-methods/paypal.ts"],"sourcesContent":["import type { PaymentKitErrors, PaymentKitStates, TInternalFuncs } from \"../types\";\nimport { collectFraudMetadata, definePaymentMethod, getOrCreateCheckoutRequestId } from \"../utils\";\n\n// PayPal-specific types\nexport type PayPalCustomerInfo = {\n first_name: string;\n last_name: string;\n};\n\nexport type PayPalStartRequest = {\n processor_id: string;\n customer_info: PayPalCustomerInfo;\n fraud_metadata: {\n ipAddress?: string;\n browserInfo?: { [key: string]: unknown };\n processorFraudInfo?: { [key: string]: unknown };\n };\n};\n\nexport type PayPalStartResponse = {\n approval_url: string;\n popup_token: string;\n checkout_attempt_id: string;\n};\n\nexport type PayPalStatusResponse = {\n completed: boolean;\n status: \"success\" | \"failed\" | \"cancelled\";\n result?: unknown;\n error?: string;\n};\n\nexport type PayPalCheckoutResponse = {\n id: string;\n checkoutAttemptId: string;\n checkoutSessionId: string;\n state: string;\n};\n\nexport type PayPalSubmitOptions = {\n processorId: string;\n customerInfo: PayPalCustomerInfo;\n};\n\ntype PayPalStates = PaymentKitStates & {\n popup?: Window | null;\n pollInterval?: number;\n};\n\nconst defSubmitPayment = (states: PayPalStates) => {\n const submitPayment: TInternalFuncs[\"submitPayment\"] = async (_fields, options) => {\n const { apiBaseUrl, secureToken, environment } = states;\n const paypalOptions = options as PayPalSubmitOptions;\n\n if (!paypalOptions?.processorId) {\n return { errors: { processor_id: \"Processor ID is required\" } as PaymentKitErrors };\n }\n\n if (!paypalOptions?.customerInfo?.first_name || !paypalOptions?.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 // Get or create checkout request ID for correlating all API calls\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[PayPal] Using checkout_request_id: ${checkoutRequestId}`);\n\n // Step 1: Call PayPal start endpoint\n const startResponse = await fetch(`${apiBaseUrl}/api/checkout/${secureToken}/paypal/start`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-request-id\": checkoutRequestId,\n },\n body: JSON.stringify({\n processor_id: paypalOptions.processorId,\n customer_info: paypalOptions.customerInfo,\n fraud_metadata: collectFraudMetadata(),\n } as PayPalStartRequest),\n });\n\n if (!startResponse.ok) {\n let errorMessage = `Failed to start PayPal checkout (${startResponse.status})`;\n try {\n const errorData = await startResponse.json();\n errorMessage = errorData.detail || errorMessage;\n } catch {\n // Response body is not JSON, use status text\n errorMessage = startResponse.statusText || errorMessage;\n }\n return {\n errors: {\n paypal: errorMessage,\n } as PaymentKitErrors,\n };\n }\n\n const { approval_url, popup_token, checkout_attempt_id } = (await startResponse.json()) as PayPalStartResponse;\n\n // Step 2: Open PayPal popup\n const popup = window.open(approval_url, \"PayPal\", \"width=600,height=700\");\n\n if (!popup) {\n return {\n errors: {\n paypal: \"Failed to open PayPal popup. Please allow popups for this site.\",\n } as PaymentKitErrors,\n };\n }\n\n states.popup = popup;\n\n // Step 3: Poll for completion\n return new Promise((resolve) => {\n const pollInterval = setInterval(async () => {\n try {\n // Check status FIRST - popup might close after successful callback\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 paypal: \"Failed to check PayPal status\",\n } as PaymentKitErrors,\n });\n return;\n }\n\n const statusResult = (await statusResponse.json()) as PayPalStatusResponse;\n\n if (statusResult.completed) {\n clearInterval(pollInterval);\n popup.close();\n\n if (statusResult.status === \"success\") {\n // Use result 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 }) as { [key: string]: unknown };\n\n resolve({ data: result });\n } else {\n resolve({\n errors: {\n paypal: statusResult.error || `PayPal checkout ${statusResult.status}`,\n } as PaymentKitErrors,\n });\n }\n return;\n }\n\n // Only check popup.closed AFTER confirming status is not completed\n // This avoids race condition where popup closes from successful callback\n if (popup.closed) {\n clearInterval(pollInterval);\n resolve({\n errors: {\n paypal: \"PayPal popup closed by user\",\n } as PaymentKitErrors,\n });\n return;\n }\n } catch (error) {\n clearInterval(pollInterval);\n popup.close();\n resolve({\n errors: {\n paypal: `Polling error: ${error}`,\n } as PaymentKitErrors,\n });\n }\n }, 2000); // Poll every 2 seconds\n\n states.pollInterval = pollInterval as unknown as number;\n });\n } catch (error) {\n return {\n errors: {\n paypal: `PayPal checkout error: ${error}`,\n } as PaymentKitErrors,\n };\n }\n };\n\n return submitPayment;\n};\n\nconst PayPalPaymentMethod = definePaymentMethod((paymentKitStates) => {\n const localStates: PayPalStates = { ...paymentKitStates };\n\n return {\n name: \"paypal\",\n externalFuncs: {\n // PayPal doesn't need createElement like card iframes\n },\n internalFuncs: {\n submitPayment: defSubmitPayment(localStates),\n cleanup: () => {\n // Clean up popup and polling interval if still active\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\nexport default PayPalPaymentMethod;\n"],"mappings":";;;AAiDA,MAAM,oBAAoB,WAAyB;CACjD,MAAMA,gBAAiD,OAAO,SAAS,YAAY;EACjF,MAAM,EAAE,YAAY,aAAa,gBAAgB;EACjD,MAAM,gBAAgB;AAEtB,MAAI,CAAC,eAAe,YAClB,QAAO,EAAE,QAAQ,EAAE,cAAc,4BAA4B,EAAsB;AAGrF,MAAI,CAAC,eAAe,cAAc,cAAc,CAAC,eAAe,cAAc,UAC5E,QAAO,EACL,QAAQ,EACN,eAAe,6CAChB,EACF;AAGH,MAAI;GAEF,MAAM,oBAAoB,6BAA6B,YAAY;AACnE,WAAQ,IAAI,uCAAuC,oBA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AAC;AAEJ;;AAKF,UAAI,MAAM,QAAQ;AAChB,qBAAc,aAAa;AAC3B,eAAQ,EACN,QAAQ,EACN,QAAQ,+BACT,EACF,CAAC;AACF;;cAEK,OAAO;AACd,oBAAc,aAAa;AAC3B,YAAM,OAAO;AACb,cAAQ,EACN,QAAQ,EACN,QAAQ,kBAAkB,SAC3B,EACF,CAAC;;OAEH,IAAK;AAER,WAAO,eAAe;KACtB;WACK,OAAO;AACd,UAAO,EACL,QAAQ,EACN,QAAQ,0BAA0B,SACnC,EACF;;;AAIL,QAAO;;AAGT,MAAM,sBAAsB,qBAAqB,qBAAqB;CACpE,MAAMC,cAA4B,EAAE,GAAG,kBAAkB;AAEzD,QAAO;EACL,MAAM;EACN,eAAe,EAEd;EACD,eAAe;GACb,eAAe,iBAAiB,YAAY;GAC5C,eAAe;AAEb,QAAI,YAAY,aACd,eAAc,YAAY,aAAa;AAEzC,QAAI,YAAY,SAAS,CAAC,YAAY,MAAM,OAC1C,aAAY,MAAM,OAAO;;GAG9B;EACF;EACD;AAEF,qBAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as StripeApplePayAdapter, i as ShowApplePaySheetResult, n as ApplePayPaymentRequestConfig, r as ConfirmResult, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-
|
|
1
|
+
import { a as StripeApplePayAdapter, i as ShowApplePaySheetResult, n as ApplePayPaymentRequestConfig, r as ConfirmResult, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-DhpGclW9.mjs";
|
|
2
2
|
export { ApplePayMockScenario, ApplePayPaymentRequestConfig, ConfirmResult, ShowApplePaySheetResult, StripeApplePayAdapter };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as StripeApplePayAdapter, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-
|
|
1
|
+
import { n as StripeApplePayAdapter, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-Cd9LVNnp.mjs";
|
|
2
2
|
|
|
3
3
|
export { ApplePayMockScenario, StripeApplePayAdapter };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as StripeGooglePayAdapter, i as ShowPaymentSheetResult, n as GooglePayMockScenario, r as PaymentRequestConfig, t as ConfirmResult } from "../stripe-google-pay-adapter-
|
|
1
|
+
import { a as StripeGooglePayAdapter, i as ShowPaymentSheetResult, n as GooglePayMockScenario, r as PaymentRequestConfig, t as ConfirmResult } from "../stripe-google-pay-adapter-C3NCBSO3.mjs";
|
|
2
2
|
export { ConfirmResult, GooglePayMockScenario, PaymentRequestConfig, ShowPaymentSheetResult, StripeGooglePayAdapter };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as StripeGooglePayAdapter, t as GooglePayMockScenario } from "../stripe-google-pay-adapter-
|
|
1
|
+
import { n as StripeGooglePayAdapter, t as GooglePayMockScenario } from "../stripe-google-pay-adapter-CqcUEoM3.mjs";
|
|
2
2
|
|
|
3
3
|
export { GooglePayMockScenario, StripeGooglePayAdapter };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/payment-methods/vgs-collect-loader.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Loads VGS Collect JS from CDN. Idempotent — subsequent calls return the same promise.
|
|
4
|
+
*/
|
|
5
|
+
declare function loadVgsCollectScript(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Initializes a VGS Collect form instance.
|
|
8
|
+
*/
|
|
9
|
+
declare function initVgsCollect(vaultId: string, environment: string): VGSCollectForm;
|
|
10
|
+
/**
|
|
11
|
+
* Creates and mounts VGS Collect card fields using CMP-specific field methods.
|
|
12
|
+
*
|
|
13
|
+
* Uses cardNumberField(), cardExpirationDateField(), cardCVCField() which are
|
|
14
|
+
* required for the CMP createCard() flow. After mounting, call form.createCard()
|
|
15
|
+
* to create a card in the VGS vault, which returns aliases for PAN and CVC.
|
|
16
|
+
*
|
|
17
|
+
* @param form - VGS Collect form instance
|
|
18
|
+
* @param mountPoints - CSS selectors for PAN, expiry, and CVC containers
|
|
19
|
+
* @param css - Optional CSS to apply to VGS Collect iframe fields
|
|
20
|
+
*/
|
|
21
|
+
declare function createVgsCardFields(form: VGSCollectForm, mountPoints: {
|
|
22
|
+
pan: string;
|
|
23
|
+
exp: string;
|
|
24
|
+
cvc: string;
|
|
25
|
+
}, css?: Record<string, string>, onFocusChangeCallbacks?: Partial<Record<string, (isFocused: boolean) => void>>): void;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createVgsCardFields, initVgsCollect, loadVgsCollectScript };
|
|
28
|
+
//# sourceMappingURL=vgs-collect-loader.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vgs-collect-loader.d.mts","names":[],"sources":["../../src/payment-methods/vgs-collect-loader.ts"],"sourcesContent":[],"mappings":";;AAOA;AAmCA;AAkBgB,iBArDA,oBAAA,CAAA,CAqDmB,EArDK,OAqDL,CAAA,IAAA,CAAA;;;;AAIR,iBAtBX,cAAA,CAsBW,OAAA,EAAA,MAAA,EAAA,WAAA,EAAA,MAAA,CAAA,EAtB2C,cAsB3C;;;;;;;;;;;;iBAJX,mBAAA,OACR;;;;SAEA,iDACmB,QAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ParentConnection, i as IFrameConnection, n as CardInputType, o as connectToCardIframe, r as CheckoutResponse, s as connectToCardParent, t as CardErrorCode } from "../connect-card-
|
|
1
|
+
import { a as ParentConnection, i as IFrameConnection, n as CardInputType, o as connectToCardIframe, r as CheckoutResponse, s as connectToCardParent, t as CardErrorCode } from "../connect-card-Cxy51W6t.mjs";
|
|
2
2
|
export { CardErrorCode, CardInputType, CheckoutResponse, IFrameConnection, ParentConnection, connectToCardIframe, connectToCardParent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../penpal-BFKeZTVz.mjs";
|
|
2
|
-
import { n as connectToCardParent, t as connectToCardIframe } from "../connect-card-
|
|
2
|
+
import { n as connectToCardParent, t as connectToCardIframe } from "../connect-card-CMZkeppE.mjs";
|
|
3
3
|
|
|
4
4
|
export { connectToCardIframe, connectToCardParent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as connectToTunnelXParent, i as connectToTunnelXIframe, n as TunnelXManager, r as TunnelXParentConnection, t as TunnelXIFrameConnection } from "../connect-tunnel-x-
|
|
1
|
+
import { a as connectToTunnelXParent, i as connectToTunnelXIframe, n as TunnelXManager, r as TunnelXParentConnection, t as TunnelXIFrameConnection } from "../connect-tunnel-x-lv6Wtdme.mjs";
|
|
2
2
|
export { TunnelXIFrameConnection, TunnelXManager, TunnelXParentConnection, connectToTunnelXIframe, connectToTunnelXParent };
|
package/dist/{stripe-apple-pay-adapter-Bg7nCy3P.mjs.map → stripe-apple-pay-adapter-Cd9LVNnp.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-apple-pay-adapter-Bg7nCy3P.mjs","names":[],"sources":["../src/payment-methods/stripe-apple-pay-adapter.ts"],"sourcesContent":["/// <reference types=\"@types/applepayjs\" />\nimport type { PaymentRequest, PaymentRequestPaymentMethodEvent, Stripe, StripeConstructor } from \"@stripe/stripe-js\";\n\n// Stripe.js must be loaded via script tag for PCI compliance\ndeclare global {\n interface Window {\n Stripe?: StripeConstructor;\n ApplePaySession?: typeof ApplePaySession;\n }\n}\n\nexport interface ApplePayPaymentRequestConfig {\n country: string;\n currency: string;\n total: { label: string; amount: number }; // Amount in cents (atomic units)\n supportedNetworks?: string[];\n merchantCapabilities?: string[];\n}\n\nexport type ShowApplePaySheetResult =\n | {\n success: true;\n paymentMethodId: string;\n paymentMethodEvent: PaymentRequestPaymentMethodEvent;\n billingDetails?: {\n email?: string;\n name?: string;\n address?: {\n city?: string | null;\n country?: string | null;\n line1?: string | null;\n line2?: string | null;\n postal_code?: string | null;\n state?: string | null;\n } | null;\n };\n }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\nexport type ConfirmResult = { success: true } | { success: false; error: string };\n\nexport enum ApplePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n/**\n * Stripe Apple Pay Adapter using Stripe's PaymentRequest API.\n *\n * This uses Stripe's PaymentRequest API instead of the native ApplePaySession API.\n * The key benefit is that Stripe handles merchant validation automatically,\n * which is required for Apple Pay to work correctly.\n *\n * IMPORTANT: To comply with browser security requirements, Apple Pay must be shown\n * synchronously from a user click. The flow is:\n *\n * 1. Call preparePaymentRequest() BEFORE user clicks (e.g., when page loads)\n * - This creates the PaymentRequest and calls canMakePayment()\n * 2. On user click, call showPreparedPaymentSheet()\n * - This calls show() on the pre-created PaymentRequest (no async!)\n * 3. Handle the paymentmethod event and call complete()\n */\nexport class StripeApplePayAdapter {\n private stripe: Stripe | null = null;\n private mockScenario: ApplePayMockScenario;\n private preparedPaymentRequest: PaymentRequest | null = null;\n\n constructor(mockScenario?: ApplePayMockScenario) {\n this.mockScenario = mockScenario ?? ApplePayMockScenario.None;\n }\n\n initialize(publishableKey: string): boolean {\n switch (this.mockScenario) {\n case ApplePayMockScenario.None: {\n console.log(\"[ApplePay] initialize called\");\n if (!window.Stripe) {\n console.log(\"[ApplePay] Stripe.js not loaded\");\n return false;\n }\n this.stripe = window.Stripe(publishableKey);\n const success = this.stripe !== null;\n console.log(\"[ApplePay] initialize result:\", success);\n return success;\n }\n case ApplePayMockScenario.Success:\n case ApplePayMockScenario.Cancelled: {\n console.log(\"[MockApplePay] initialize called\");\n console.log(\"[MockApplePay] initialize result:\", true);\n return true;\n }\n }\n }\n\n /**\n * Check if Apple Pay is available on this device/browser.\n * Uses Stripe's PaymentRequest.canMakePayment() which is more reliable\n * than checking ApplePaySession directly.\n */\n static isAvailable(): boolean {\n // Basic check - ApplePaySession must exist (Safari on iOS/macOS)\n if (typeof window === \"undefined\" || !window.ApplePaySession) {\n console.log(\"[ApplePay] ApplePaySession not available\");\n return false;\n }\n\n // Check if device supports Apple Pay\n const canMakePayments = window.ApplePaySession.canMakePayments();\n console.log(\"[ApplePay] canMakePayments:\", canMakePayments);\n return canMakePayments;\n }\n\n /**\n * Check availability using Stripe's PaymentRequest API.\n * This is more accurate as it checks Stripe's configuration too.\n */\n async canMakePayment(): Promise<{ applePay: boolean; googlePay: boolean } | null> {\n if (!this.stripe) {\n console.log(\"[ApplePay] Stripe not initialized\");\n return null;\n }\n\n // Create a temporary payment request to check availability\n const pr = this.stripe.paymentRequest({\n country: \"US\",\n currency: \"usd\",\n total: { label: \"Check\", amount: 100 },\n });\n\n const result = await pr.canMakePayment();\n console.log(\"[ApplePay] canMakePayment result:\", result);\n\n if (!result) {\n return null;\n }\n\n // Map Stripe's result to our expected format\n return {\n applePay: result.applePay ?? false,\n googlePay: result.googlePay ?? false,\n };\n }\n\n /**\n * Prepare a PaymentRequest for later use. Call this BEFORE the user clicks.\n * This creates the PaymentRequest and calls canMakePayment() to validate.\n *\n * @returns Promise with success status and whether Apple Pay is available\n */\n async preparePaymentRequest(config: ApplePayPaymentRequestConfig): Promise<{\n success: boolean;\n applePay?: boolean;\n googlePay?: boolean;\n error?: string;\n }> {\n if (this.mockScenario !== ApplePayMockScenario.None) {\n console.log(\"[MockApplePay] preparePaymentRequest called\");\n this.preparedConfig = config;\n return { success: true, applePay: true, googlePay: false };\n }\n\n console.log(\"[ApplePay] preparePaymentRequest called\", config);\n\n if (!this.stripe) {\n return { success: false, error: \"Stripe not initialized\" };\n }\n\n // Create the PaymentRequest\n const paymentRequest = this.stripe.paymentRequest({\n country: config.country,\n currency: config.currency.toLowerCase(),\n total: {\n label: config.total.label,\n amount: config.total.amount,\n },\n requestPayerName: true,\n requestPayerEmail: true,\n });\n\n // Check availability - this MUST be called before show()\n const canMakePaymentResult = await paymentRequest.canMakePayment();\n console.log(\"[ApplePay] preparePaymentRequest canMakePayment:\", canMakePaymentResult);\n\n if (!canMakePaymentResult) {\n return {\n success: false,\n error: \"Payment methods not available on this device/browser\",\n applePay: false,\n googlePay: false,\n };\n }\n\n // Store the prepared PaymentRequest for later use\n this.preparedPaymentRequest = paymentRequest;\n this.preparedConfig = config;\n\n return {\n success: true,\n applePay: canMakePaymentResult.applePay ?? false,\n googlePay: canMakePaymentResult.googlePay ?? false,\n };\n }\n\n /**\n * Check if a PaymentRequest has been prepared and is ready to show.\n */\n isPrepared(): boolean {\n return this.preparedPaymentRequest !== null || this.mockScenario !== ApplePayMockScenario.None;\n }\n\n /**\n * Clear the prepared PaymentRequest.\n */\n clearPrepared(): void {\n this.preparedPaymentRequest = null;\n this.preparedConfig = null;\n }\n\n /**\n * Show the prepared Apple Pay payment sheet.\n * MUST be called synchronously from a user click handler.\n * Call preparePaymentRequest() before the click to set up the PaymentRequest.\n */\n showPreparedPaymentSheet(): Promise<ShowApplePaySheetResult> {\n switch (this.mockScenario) {\n case ApplePayMockScenario.None: {\n console.log(\"[ApplePay] showPreparedPaymentSheet called\");\n\n if (!this.preparedPaymentRequest) {\n console.error(\"[ApplePay] No prepared PaymentRequest! Call preparePaymentRequest() first.\");\n return Promise.resolve({\n success: false,\n error: \"PaymentRequest not prepared. Call preparePaymentRequest() before showing the sheet.\",\n });\n }\n\n const paymentRequest = this.preparedPaymentRequest;\n\n // Return a promise that resolves when the user completes or cancels\n return new Promise((resolve) => {\n // Handle successful payment method creation\n paymentRequest.on(\"paymentmethod\", (evt: PaymentRequestPaymentMethodEvent) => {\n console.log(\"[ApplePay] paymentmethod event received\", {\n paymentMethodId: evt.paymentMethod.id,\n payerEmail: evt.payerEmail,\n payerName: evt.payerName,\n });\n\n // Clear the prepared request after use\n this.preparedPaymentRequest = null;\n\n resolve({\n success: true,\n paymentMethodId: evt.paymentMethod.id,\n paymentMethodEvent: evt,\n billingDetails: {\n email: evt.payerEmail ?? undefined,\n name: evt.payerName ?? undefined,\n address: evt.paymentMethod.billing_details?.address ?? undefined,\n },\n });\n });\n\n // Handle cancellation\n paymentRequest.on(\"cancel\", () => {\n console.log(\"[ApplePay] cancel event - user cancelled\");\n // Clear the prepared request after cancellation\n this.preparedPaymentRequest = null;\n resolve({ success: false, cancelled: true });\n });\n\n // Show the payment sheet immediately (no async operations before this!)\n console.log(\"[ApplePay] showing payment sheet\");\n paymentRequest.show();\n });\n }\n\n case ApplePayMockScenario.Success: {\n console.log(\"[MockApplePay] showPreparedPaymentSheet: success\");\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve({\n success: true,\n paymentMethodId: \"pm_mock_apple_pay_test\",\n paymentMethodEvent: {\n complete: (status: string) => console.log(`[MockApplePay] complete: ${status}`),\n paymentMethod: {\n id: \"pm_mock_apple_pay_test\",\n object: \"payment_method\",\n type: \"card\",\n card: {\n brand: \"visa\",\n last4: \"4242\",\n exp_month: 12,\n exp_year: 2030,\n },\n billing_details: {\n email: \"test@example.com\",\n name: \"Test User\",\n },\n },\n payerEmail: \"test@example.com\",\n payerName: \"Test User\",\n } as unknown as PaymentRequestPaymentMethodEvent,\n billingDetails: {\n email: \"test@example.com\",\n name: \"Test User\",\n },\n });\n }, 500);\n });\n }\n\n case ApplePayMockScenario.Cancelled: {\n console.log(\"[MockApplePay] showPreparedPaymentSheet: cancelled\");\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve({ success: false, cancelled: true });\n }, 500);\n });\n }\n }\n }\n\n /**\n * @deprecated Use preparePaymentRequest() + showPreparedPaymentSheet() instead.\n * This method creates a new PaymentRequest and shows it, which doesn't work\n * with browser security requirements (show() must be called synchronously).\n */\n async showPaymentSheet(config: ApplePayPaymentRequestConfig): Promise<ShowApplePaySheetResult> {\n console.warn(\n \"[ApplePay] showPaymentSheet is deprecated. Use preparePaymentRequest() + showPreparedPaymentSheet() instead.\",\n );\n\n // Try to prepare and show in one go (will likely fail due to user gesture requirement)\n const prepareResult = await this.preparePaymentRequest(config);\n if (!prepareResult.success) {\n return { success: false, error: prepareResult.error ?? \"Failed to prepare payment request\" };\n }\n\n return this.showPreparedPaymentSheet();\n }\n\n /**\n * Complete the payment flow in the Apple Pay sheet.\n * Call this after confirming the payment on the server.\n *\n * @param evt - The PaymentRequestPaymentMethodEvent from showPaymentSheet\n * @param status - 'success' or 'fail'\n */\n completePayment(evt: PaymentRequestPaymentMethodEvent, status: \"success\" | \"fail\"): void {\n console.log(\"[ApplePay] completePayment:\", status);\n evt.complete(status);\n }\n\n /**\n * Confirm PaymentIntent with the PaymentMethod.\n * This is called after showPaymentSheet to finalize the payment.\n *\n * @deprecated - Server-side confirmation is preferred. The backend should\n * call stripe.PaymentIntent.confirm() with the payment_method_id.\n */\n async confirmPaymentIntent(clientSecret: string, paymentMethodId: string): Promise<ConfirmResult> {\n switch (this.mockScenario) {\n case ApplePayMockScenario.None: {\n console.log(\"[ApplePay] confirmPaymentIntent called\", {\n clientSecret: `${clientSecret.slice(0, 20)}...`,\n paymentMethodId,\n });\n if (!this.stripe) {\n console.log(\"[ApplePay] confirmPaymentIntent: Stripe not initialized\");\n return { success: false, error: \"Stripe not initialized\" };\n }\n\n const { error } = await this.stripe.confirmCardPayment(clientSecret, {\n payment_method: paymentMethodId,\n });\n\n if (error) {\n console.log(\"[ApplePay] confirmPaymentIntent error:\", error);\n return { success: false, error: error.message ?? \"Payment failed\" };\n }\n\n console.log(\"[ApplePay] confirmPaymentIntent success\");\n return { success: true };\n }\n case ApplePayMockScenario.Success: {\n console.log(\"[MockApplePay] confirmPaymentIntent called\", { clientSecret, paymentMethodId });\n return { success: true };\n }\n case ApplePayMockScenario.Cancelled: {\n throw new Error(\"confirmPaymentIntent should not be called when scenario is Cancelled\");\n }\n }\n }\n}\n"],"mappings":";AA0CA,IAAY,wEAAL;AACL;AACA;AACA;;;;;;;;;;;;;;;;;;;AAmBF,IAAa,wBAAb,MAAmC;CACjC,AAAQ,SAAwB;CAChC,AAAQ;CACR,AAAQ,yBAAgD;CAExD,YAAY,cAAqC;AAC/C,OAAK,eAAe,gBAAgB,qBAAqB;;CAG3D,WAAW,gBAAiC;AAC1C,UAAQ,KAAK,cAAb;GACE,KAAK,qBAAqB,MAAM;AAC9B,YAAQ,IAAI,+BAA+B;AAC3C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CAAC;AACF,QAAI,CAAC,KAAK,QAAQ;AAChB,aAAQ,IAAI,0DAA0D;AACtE,YAAO;MAAE,SAAS;MAAO,OAAO;MAA0B;;IAG5D,MAAM,EAAE,UAAU,MAAM,KAAK,OAAO,mBAAmB,cAAc,EACnE,gBAAgB,iBACjB,CAAC;AAEF,QAAI,OAAO;AACT,aAAQ,IAAI,0CAA0C,MAAM;AAC5D,YAAO;MAAE,SAAS;MAAO,OAAO,MAAM,WAAW;MAAkB;;AAGrE,YAAQ,IAAI,0CAA0C;AACtD,WAAO,EAAE,SAAS,MAAM;;GAE1B,KAAK,qBAAqB;AACxB,YAAQ,IAAI,8CAA8C;KAAE;KAAc;KAAiB,CAAC;AAC5F,WAAO,EAAE,SAAS,MAAM;GAE1B,KAAK,qBAAqB,UACxB,OAAM,IAAI,MAAM,uEAAuE"}
|
|
1
|
+
{"version":3,"file":"stripe-apple-pay-adapter-Cd9LVNnp.mjs","names":[],"sources":["../src/payment-methods/stripe-apple-pay-adapter.ts"],"sourcesContent":["/// <reference types=\"@types/applepayjs\" />\nimport type { PaymentRequest, PaymentRequestPaymentMethodEvent, Stripe, StripeConstructor } from \"@stripe/stripe-js\";\n\n// Stripe.js must be loaded via script tag for PCI compliance\ndeclare global {\n interface Window {\n Stripe?: StripeConstructor;\n ApplePaySession?: typeof ApplePaySession;\n }\n}\n\nexport interface ApplePayPaymentRequestConfig {\n country: string;\n currency: string;\n total: { label: string; amount: number }; // Amount in cents (atomic units)\n supportedNetworks?: string[];\n merchantCapabilities?: string[];\n}\n\nexport type ShowApplePaySheetResult =\n | {\n success: true;\n paymentMethodId: string;\n paymentMethodEvent: PaymentRequestPaymentMethodEvent;\n billingDetails?: {\n email?: string;\n name?: string;\n address?: {\n city?: string | null;\n country?: string | null;\n line1?: string | null;\n line2?: string | null;\n postal_code?: string | null;\n state?: string | null;\n } | null;\n };\n }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\nexport type ConfirmResult = { success: true } | { success: false; error: string };\n\nexport enum ApplePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n/**\n * Stripe Apple Pay Adapter using Stripe's PaymentRequest API.\n *\n * This uses Stripe's PaymentRequest API instead of the native ApplePaySession API.\n * The key benefit is that Stripe handles merchant validation automatically,\n * which is required for Apple Pay to work correctly.\n *\n * IMPORTANT: To comply with browser security requirements, Apple Pay must be shown\n * synchronously from a user click. The flow is:\n *\n * 1. Call preparePaymentRequest() BEFORE user clicks (e.g., when page loads)\n * - This creates the PaymentRequest and calls canMakePayment()\n * 2. On user click, call showPreparedPaymentSheet()\n * - This calls show() on the pre-created PaymentRequest (no async!)\n * 3. Handle the paymentmethod event and call complete()\n */\nexport class StripeApplePayAdapter {\n private stripe: Stripe | null = null;\n private mockScenario: ApplePayMockScenario;\n private preparedPaymentRequest: PaymentRequest | null = null;\n\n constructor(mockScenario?: ApplePayMockScenario) {\n this.mockScenario = mockScenario ?? ApplePayMockScenario.None;\n }\n\n initialize(publishableKey: string): boolean {\n switch (this.mockScenario) {\n case ApplePayMockScenario.None: {\n console.log(\"[ApplePay] initialize called\");\n if (!window.Stripe) {\n console.log(\"[ApplePay] Stripe.js not loaded\");\n return false;\n }\n this.stripe = window.Stripe(publishableKey);\n const success = this.stripe !== null;\n console.log(\"[ApplePay] initialize result:\", success);\n return success;\n }\n case ApplePayMockScenario.Success:\n case ApplePayMockScenario.Cancelled: {\n console.log(\"[MockApplePay] initialize called\");\n console.log(\"[MockApplePay] initialize result:\", true);\n return true;\n }\n }\n }\n\n /**\n * Check if Apple Pay is available on this device/browser.\n * Uses Stripe's PaymentRequest.canMakePayment() which is more reliable\n * than checking ApplePaySession directly.\n */\n static isAvailable(): boolean {\n // Basic check - ApplePaySession must exist (Safari on iOS/macOS)\n if (typeof window === \"undefined\" || !window.ApplePaySession) {\n console.log(\"[ApplePay] ApplePaySession not available\");\n return false;\n }\n\n // Check if device supports Apple Pay\n const canMakePayments = window.ApplePaySession.canMakePayments();\n console.log(\"[ApplePay] canMakePayments:\", canMakePayments);\n return canMakePayments;\n }\n\n /**\n * Check availability using Stripe's PaymentRequest API.\n * This is more accurate as it checks Stripe's configuration too.\n */\n async canMakePayment(): Promise<{ applePay: boolean; googlePay: boolean } | null> {\n if (!this.stripe) {\n console.log(\"[ApplePay] Stripe not initialized\");\n return null;\n }\n\n // Create a temporary payment request to check availability\n const pr = this.stripe.paymentRequest({\n country: \"US\",\n currency: \"usd\",\n total: { label: \"Check\", amount: 100 },\n });\n\n const result = await pr.canMakePayment();\n console.log(\"[ApplePay] canMakePayment result:\", result);\n\n if (!result) {\n return null;\n }\n\n // Map Stripe's result to our expected format\n return {\n applePay: result.applePay ?? false,\n googlePay: result.googlePay ?? false,\n };\n }\n\n /**\n * Prepare a PaymentRequest for later use. Call this BEFORE the user clicks.\n * This creates the PaymentRequest and calls canMakePayment() to validate.\n *\n * @returns Promise with success status and whether Apple Pay is available\n */\n async preparePaymentRequest(config: ApplePayPaymentRequestConfig): Promise<{\n success: boolean;\n applePay?: boolean;\n googlePay?: boolean;\n error?: string;\n }> {\n if (this.mockScenario !== ApplePayMockScenario.None) {\n console.log(\"[MockApplePay] preparePaymentRequest called\");\n this.preparedConfig = config;\n return { success: true, applePay: true, googlePay: false };\n }\n\n console.log(\"[ApplePay] preparePaymentRequest called\", config);\n\n if (!this.stripe) {\n return { success: false, error: \"Stripe not initialized\" };\n }\n\n // Create the PaymentRequest\n const paymentRequest = this.stripe.paymentRequest({\n country: config.country,\n currency: config.currency.toLowerCase(),\n total: {\n label: config.total.label,\n amount: config.total.amount,\n },\n requestPayerName: true,\n requestPayerEmail: true,\n });\n\n // Check availability - this MUST be called before show()\n const canMakePaymentResult = await paymentRequest.canMakePayment();\n console.log(\"[ApplePay] preparePaymentRequest canMakePayment:\", canMakePaymentResult);\n\n if (!canMakePaymentResult) {\n return {\n success: false,\n error: \"Payment methods not available on this device/browser\",\n applePay: false,\n googlePay: false,\n };\n }\n\n // Store the prepared PaymentRequest for later use\n this.preparedPaymentRequest = paymentRequest;\n this.preparedConfig = config;\n\n return {\n success: true,\n applePay: canMakePaymentResult.applePay ?? false,\n googlePay: canMakePaymentResult.googlePay ?? false,\n };\n }\n\n /**\n * Check if a PaymentRequest has been prepared and is ready to show.\n */\n isPrepared(): boolean {\n return this.preparedPaymentRequest !== null || this.mockScenario !== ApplePayMockScenario.None;\n }\n\n /**\n * Clear the prepared PaymentRequest.\n */\n clearPrepared(): void {\n this.preparedPaymentRequest = null;\n this.preparedConfig = null;\n }\n\n /**\n * Show the prepared Apple Pay payment sheet.\n * MUST be called synchronously from a user click handler.\n * Call preparePaymentRequest() before the click to set up the PaymentRequest.\n */\n showPreparedPaymentSheet(): Promise<ShowApplePaySheetResult> {\n switch (this.mockScenario) {\n case ApplePayMockScenario.None: {\n console.log(\"[ApplePay] showPreparedPaymentSheet called\");\n\n if (!this.preparedPaymentRequest) {\n console.error(\"[ApplePay] No prepared PaymentRequest! Call preparePaymentRequest() first.\");\n return Promise.resolve({\n success: false,\n error: \"PaymentRequest not prepared. Call preparePaymentRequest() before showing the sheet.\",\n });\n }\n\n const paymentRequest = this.preparedPaymentRequest;\n\n // Return a promise that resolves when the user completes or cancels\n return new Promise((resolve) => {\n // Handle successful payment method creation\n paymentRequest.on(\"paymentmethod\", (evt: PaymentRequestPaymentMethodEvent) => {\n console.log(\"[ApplePay] paymentmethod event received\", {\n paymentMethodId: evt.paymentMethod.id,\n payerEmail: evt.payerEmail,\n payerName: evt.payerName,\n });\n\n // Clear the prepared request after use\n this.preparedPaymentRequest = null;\n\n resolve({\n success: true,\n paymentMethodId: evt.paymentMethod.id,\n paymentMethodEvent: evt,\n billingDetails: {\n email: evt.payerEmail ?? undefined,\n name: evt.payerName ?? undefined,\n address: evt.paymentMethod.billing_details?.address ?? undefined,\n },\n });\n });\n\n // Handle cancellation\n paymentRequest.on(\"cancel\", () => {\n console.log(\"[ApplePay] cancel event - user cancelled\");\n // Clear the prepared request after cancellation\n this.preparedPaymentRequest = null;\n resolve({ success: false, cancelled: true });\n });\n\n // Show the payment sheet immediately (no async operations before this!)\n console.log(\"[ApplePay] showing payment sheet\");\n paymentRequest.show();\n });\n }\n\n case ApplePayMockScenario.Success: {\n console.log(\"[MockApplePay] showPreparedPaymentSheet: success\");\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve({\n success: true,\n paymentMethodId: \"pm_mock_apple_pay_test\",\n paymentMethodEvent: {\n complete: (status: string) => console.log(`[MockApplePay] complete: ${status}`),\n paymentMethod: {\n id: \"pm_mock_apple_pay_test\",\n object: \"payment_method\",\n type: \"card\",\n card: {\n brand: \"visa\",\n last4: \"4242\",\n exp_month: 12,\n exp_year: 2030,\n },\n billing_details: {\n email: \"test@example.com\",\n name: \"Test User\",\n },\n },\n payerEmail: \"test@example.com\",\n payerName: \"Test User\",\n } as unknown as PaymentRequestPaymentMethodEvent,\n billingDetails: {\n email: \"test@example.com\",\n name: \"Test User\",\n },\n });\n }, 500);\n });\n }\n\n case ApplePayMockScenario.Cancelled: {\n console.log(\"[MockApplePay] showPreparedPaymentSheet: cancelled\");\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve({ success: false, cancelled: true });\n }, 500);\n });\n }\n }\n }\n\n /**\n * @deprecated Use preparePaymentRequest() + showPreparedPaymentSheet() instead.\n * This method creates a new PaymentRequest and shows it, which doesn't work\n * with browser security requirements (show() must be called synchronously).\n */\n async showPaymentSheet(config: ApplePayPaymentRequestConfig): Promise<ShowApplePaySheetResult> {\n console.warn(\n \"[ApplePay] showPaymentSheet is deprecated. Use preparePaymentRequest() + showPreparedPaymentSheet() instead.\",\n );\n\n // Try to prepare and show in one go (will likely fail due to user gesture requirement)\n const prepareResult = await this.preparePaymentRequest(config);\n if (!prepareResult.success) {\n return { success: false, error: prepareResult.error ?? \"Failed to prepare payment request\" };\n }\n\n return this.showPreparedPaymentSheet();\n }\n\n /**\n * Complete the payment flow in the Apple Pay sheet.\n * Call this after confirming the payment on the server.\n *\n * @param evt - The PaymentRequestPaymentMethodEvent from showPaymentSheet\n * @param status - 'success' or 'fail'\n */\n completePayment(evt: PaymentRequestPaymentMethodEvent, status: \"success\" | \"fail\"): void {\n console.log(\"[ApplePay] completePayment:\", status);\n evt.complete(status);\n }\n\n /**\n * Confirm PaymentIntent with the PaymentMethod.\n * This is called after showPaymentSheet to finalize the payment.\n *\n * @deprecated - Server-side confirmation is preferred. The backend should\n * call stripe.PaymentIntent.confirm() with the payment_method_id.\n */\n async confirmPaymentIntent(clientSecret: string, paymentMethodId: string): Promise<ConfirmResult> {\n switch (this.mockScenario) {\n case ApplePayMockScenario.None: {\n console.log(\"[ApplePay] confirmPaymentIntent called\", {\n clientSecret: `${clientSecret.slice(0, 20)}...`,\n paymentMethodId,\n });\n if (!this.stripe) {\n console.log(\"[ApplePay] confirmPaymentIntent: Stripe not initialized\");\n return { success: false, error: \"Stripe not initialized\" };\n }\n\n const { error } = await this.stripe.confirmCardPayment(clientSecret, {\n payment_method: paymentMethodId,\n });\n\n if (error) {\n console.log(\"[ApplePay] confirmPaymentIntent error:\", error);\n return { success: false, error: error.message ?? \"Payment failed\" };\n }\n\n console.log(\"[ApplePay] confirmPaymentIntent success\");\n return { success: true };\n }\n case ApplePayMockScenario.Success: {\n console.log(\"[MockApplePay] confirmPaymentIntent called\", { clientSecret, paymentMethodId });\n return { success: true };\n }\n case ApplePayMockScenario.Cancelled: {\n throw new Error(\"confirmPaymentIntent should not be called when scenario is Cancelled\");\n }\n }\n }\n}\n"],"mappings":";AA0CA,IAAY,wEAAL;AACL;AACA;AACA;;;;;;;;;;;;;;;;;;;AAmBF,IAAa,wBAAb,MAAmC;CACjC,AAAQ,SAAwB;CAChC,AAAQ;CACR,AAAQ,yBAAgD;CAExD,YAAY,cAAqC;AAC/C,OAAK,eAAe,gBAAgB,qBAAqB;;CAG3D,WAAW,gBAAiC;AAC1C,UAAQ,KAAK,cAAb;GACE,KAAK,qBAAqB,MAAM;AAC9B,YAAQ,IAAI,+BAA+B;AAC3C,Q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AC;AACF,QAAI,CAAC,KAAK,QAAQ;AAChB,aAAQ,IAAI,0DAA0D;AACtE,YAAO;MAAE,SAAS;MAAO,OAAO;MAA0B;;IAG5D,MAAM,EAAE,UAAU,MAAM,KAAK,OAAO,mBAAmB,cAAc,EACnE,gBAAgB,iBACjB,CAAC;AAEF,QAAI,OAAO;AACT,aAAQ,IAAI,0CAA0C,MAAM;AAC5D,YAAO;MAAE,SAAS;MAAO,OAAO,MAAM,WAAW;MAAkB;;AAGrE,YAAQ,IAAI,0CAA0C;AACtD,WAAO,EAAE,SAAS,MAAM;;GAE1B,KAAK,qBAAqB;AACxB,YAAQ,IAAI,8CAA8C;KAAE;KAAc;KAAiB,CAAC;AAC5F,WAAO,EAAE,SAAS,MAAM;GAE1B,KAAK,qBAAqB,UACxB,OAAM,IAAI,MAAM,uEAAuE"}
|
package/dist/{stripe-apple-pay-adapter-Bq3f1mqv.d.mts → stripe-apple-pay-adapter-DhpGclW9.d.mts}
RENAMED
|
@@ -138,4 +138,4 @@ declare class StripeApplePayAdapter {
|
|
|
138
138
|
}
|
|
139
139
|
//#endregion
|
|
140
140
|
export { StripeApplePayAdapter as a, ShowApplePaySheetResult as i, ApplePayPaymentRequestConfig as n, ConfirmResult as r, ApplePayMockScenario as t };
|
|
141
|
-
//# sourceMappingURL=stripe-apple-pay-adapter-
|
|
141
|
+
//# sourceMappingURL=stripe-apple-pay-adapter-DhpGclW9.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-apple-pay-adapter-
|
|
1
|
+
{"version":3,"file":"stripe-apple-pay-adapter-DhpGclW9.d.mts","names":[],"sources":["../src/payment-methods/stripe-apple-pay-adapter.ts"],"sourcesContent":[],"mappings":";;;;;IACqH,MAAA,CAAA,EAKxG,iBALwG;IAAA,eAAA,CAAA,EAAA,OAMxF,eANwF;;;AAMzE,UAI3B,4BAAA,CAJ2B;EAI3B,OAAA,EAAA,MAAA;EAQL,QAAA,EAAA,MAAA;EAqBA,KAAA,EAAA;IAEA,KAAA,EAAA,MAAA;IAsBC,MAAA,EAAA,MAAA;EAKgB,CAAA;EAgDH,iBAAA,CAAA,EAAA,MAAA,EAAA;EAiCY,oBAAA,CAAA,EAAA,MAAA,EAAA;;AA0EA,KA7M1B,uBAAA,GA6M0B;EAAR,OAAA,EAAA,IAAA;EA0GG,eAAA,EAAA,MAAA;EAAuC,kBAAA,EAnT9C,gCAmT8C;EAAR,cAAA,CAAA,EAAA;IAqBzC,KAAA,CAAA,EAAA,MAAA;IAY8D,IAAA,CAAA,EAAA,MAAA;IAAR,OAAA,CAAA,EAAA;MAAO,IAAA,CAAA,EAAA,MAAA,GAAA,IAAA;;;;;;;;;;;;;;;KAnUxE,aAAA;;;;;;aAEA,oBAAA;;;;;;;;;;;;;;;;;;;;;cAsBC,qBAAA;;;;6BAKgB;;;;;;;;;;;;oBAgDH;;;;;;;;;;gCAiCY,+BAA+B;;;;;;;;;;;;;;;;;;;8BA0EvC,QAAQ;;;;;;2BA0GL,+BAA+B,QAAQ;;;;;;;;uBAqBjD;;;;;;;;uEAYsD,QAAQ"}
|
package/dist/{stripe-google-pay-adapter-xktEycOD.d.mts → stripe-google-pay-adapter-C3NCBSO3.d.mts}
RENAMED
|
@@ -51,4 +51,4 @@ declare class StripeGooglePayAdapter {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
export { StripeGooglePayAdapter as a, ShowPaymentSheetResult as i, GooglePayMockScenario as n, PaymentRequestConfig as r, ConfirmResult as t };
|
|
54
|
-
//# sourceMappingURL=stripe-google-pay-adapter-
|
|
54
|
+
//# sourceMappingURL=stripe-google-pay-adapter-C3NCBSO3.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-google-pay-adapter-
|
|
1
|
+
{"version":3,"file":"stripe-google-pay-adapter-C3NCBSO3.d.mts","names":[],"sources":["../src/payment-methods/stripe-google-pay-adapter.ts"],"sourcesContent":[],"mappings":";;;;;IAAqH,MAAA,CAAA,EAKxG,iBALwG;EAAA;;AAKvF,UAIb,oBAAA,CAJa;EAAA,OAAA,EAAA,MAAA;EAIb,QAAA,EAAA,MAAA;EAQL,KAAA,EAAA;IAKA,KAAA,EAAA,MAAa;IAEb,MAAA,EAAA,MAAA;EAMC,CAAA;EAKgB,gBAAA,EAAA,OAAA;EA0BE,iBAAA,EAAA,OAAA;;AAyCK,KArFxB,sBAAA,GAqFwB;EAAR,OAAA,EAAA,IAAA;EAqDqD,eAAA,EAAA,MAAA;EAAR,QAAA,EAAA,CAAA,MAAA,EAAA,SAAA,GAAA,MAAA,EAAA,GAAA,IAAA;CAAO,GAAA;;;;;;;KArIpE,aAAA;;;;;;aAEA,qBAAA;;;;;cAMC,sBAAA;;;;6BAKgB;;+BA0BE;oBAmBL;sBAsBE,QAAQ;mEAqDqC,QAAQ"}
|
package/dist/{stripe-google-pay-adapter-DjrgDYWe.mjs → stripe-google-pay-adapter-CqcUEoM3.mjs}
RENAMED
|
@@ -160,4 +160,4 @@ var StripeGooglePayAdapter = class {
|
|
|
160
160
|
|
|
161
161
|
//#endregion
|
|
162
162
|
export { StripeGooglePayAdapter as n, GooglePayMockScenario as t };
|
|
163
|
-
//# sourceMappingURL=stripe-google-pay-adapter-
|
|
163
|
+
//# sourceMappingURL=stripe-google-pay-adapter-CqcUEoM3.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-google-pay-adapter-
|
|
1
|
+
{"version":3,"file":"stripe-google-pay-adapter-CqcUEoM3.mjs","names":[],"sources":["../src/payment-methods/stripe-google-pay-adapter.ts"],"sourcesContent":["import type { PaymentRequest, PaymentRequestPaymentMethodEvent, Stripe, StripeConstructor } from \"@stripe/stripe-js\";\n\n// Stripe.js must be loaded via script tag for PCI compliance\ndeclare global {\n interface Window {\n Stripe?: StripeConstructor;\n }\n}\n\nexport interface PaymentRequestConfig {\n country: string;\n currency: string;\n total: { label: string; amount: number };\n requestPayerName: boolean;\n requestPayerEmail: boolean;\n}\n\nexport type ShowPaymentSheetResult =\n | { success: true; paymentMethodId: string; complete: (status: \"success\" | \"fail\") => void }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\nexport type ConfirmResult = { success: true } | { success: false; error: string };\n\nexport enum GooglePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\nexport class StripeGooglePayAdapter {\n private stripe: Stripe | null = null;\n private paymentRequest: PaymentRequest | null = null;\n private mockScenario: GooglePayMockScenario;\n\n constructor(mockScenario?: GooglePayMockScenario) {\n this.mockScenario = mockScenario ?? GooglePayMockScenario.None;\n }\n\n initialize(publishableKey: string): boolean {\n switch (this.mockScenario) {\n case GooglePayMockScenario.None: {\n console.log(\"[GooglePay] initialize called\");\n if (!window.Stripe) {\n console.log(\"[GooglePay] Stripe.js not loaded\");\n return false;\n }\n this.stripe = window.Stripe(publishableKey);\n const success = this.stripe !== null;\n console.log(\"[GooglePay] initialize result:\", success);\n return success;\n }\n case GooglePayMockScenario.Success:\n case GooglePayMockScenario.Cancelled: {\n console.log(\"[MockGooglePay] initialize called\");\n console.log(\"[MockGooglePay] initialize result:\", true);\n return true;\n }\n }\n }\n\n createPaymentRequest(config: PaymentRequestConfig): void {\n switch (this.mockScenario) {\n case GooglePayMockScenario.None: {\n console.log(\"[GooglePay] createPaymentRequest called\", config);\n if (!this.stripe) {\n throw new Error(\"Stripe not initialized\");\n }\n this.paymentRequest = this.stripe.paymentRequest(config);\n console.log(\"[GooglePay] paymentRequest created\");\n return;\n }\n case GooglePayMockScenario.Success:\n case GooglePayMockScenario.Cancelled: {\n console.log(\"[MockGooglePay] createPaymentRequest called\", config);\n return;\n }\n }\n }\n\n async canMakePayment(): Promise<boolean> {\n switch (this.mockScenario) {\n case GooglePayMockScenario.None: {\n console.log(\"[GooglePay] canMakePayment called\");\n if (!this.paymentRequest) {\n console.log(\"[GooglePay] canMakePayment: no paymentRequest\");\n return false;\n }\n const result = await this.paymentRequest.canMakePayment();\n const isAvailable = result?.googlePay ?? false;\n console.log(\"[GooglePay] canMakePayment result:\", { result, isAvailable });\n return isAvailable;\n }\n case GooglePayMockScenario.Success:\n case GooglePayMockScenario.Cancelled: {\n console.log(\"[MockGooglePay] canMakePayment called\");\n console.log(\"[MockGooglePay] canMakePayment result:\", { result: { googlePay: true }, isAvailable: true });\n return true;\n }\n }\n }\n\n async showPaymentSheet(): Promise<ShowPaymentSheetResult> {\n switch (this.mockScenario) {\n case GooglePayMockScenario.None: {\n console.log(\"[GooglePay] showPaymentSheet called\");\n if (!this.paymentRequest) {\n console.log(\"[GooglePay] showPaymentSheet: no paymentRequest\");\n return { success: false, error: \"Payment request not created\" };\n }\n\n return new Promise((resolve) => {\n // biome-ignore lint/style/noNonNullAssertion: checked above\n this.paymentRequest!.on(\"paymentmethod\", (event: PaymentRequestPaymentMethodEvent) => {\n console.log(\"[GooglePay] showPaymentSheet: paymentmethod event\", {\n paymentMethodId: event.paymentMethod.id,\n });\n resolve({\n success: true,\n paymentMethodId: event.paymentMethod.id,\n complete: (status) => {\n console.log(\"[GooglePay] complete called:\", status);\n event.complete(status);\n },\n });\n });\n\n // biome-ignore lint/style/noNonNullAssertion: checked above\n this.paymentRequest!.on(\"cancel\", () => {\n console.log(\"[GooglePay] showPaymentSheet: cancelled by user\");\n resolve({ success: false, cancelled: true });\n });\n\n console.log(\"[GooglePay] showing payment sheet...\");\n // biome-ignore lint/style/noNonNullAssertion: checked above\n this.paymentRequest!.show();\n });\n }\n case GooglePayMockScenario.Success: {\n console.log(\"[MockGooglePay] showPaymentSheet: success\");\n await new Promise((resolve) => setTimeout(resolve, 500));\n return {\n success: true,\n paymentMethodId: \"pm_mock_123456789\",\n complete: (status) => console.log(`[MockGooglePay] complete: ${status}`),\n };\n }\n case GooglePayMockScenario.Cancelled: {\n console.log(\"[MockGooglePay] showPaymentSheet: cancelled\");\n await new Promise((resolve) => setTimeout(resolve, 500));\n return { success: false, cancelled: true };\n }\n }\n }\n\n async confirmCardSetup(clientSecret: string, paymentMethodId: string): Promise<ConfirmResult> {\n switch (this.mockScenario) {\n case GooglePayMockScenario.None: {\n console.log(\"[GooglePay] confirmCardSetup called\", {\n clientSecret: `${clientSecret.slice(0, 20)}...`,\n paymentMethodId,\n });\n if (!this.stripe) {\n console.log(\"[GooglePay] confirmCardSetup: Stripe not initialized\");\n return { success: false, error: \"Stripe not initialized\" };\n }\n\n const { error } = await this.stripe.confirmCardSetup(clientSecret, {\n payment_method: paymentMethodId,\n });\n\n if (error) {\n console.log(\"[GooglePay] confirmCardSetup error:\", error);\n return { success: false, error: error.message ?? \"Card setup failed\" };\n }\n\n console.log(\"[GooglePay] confirmCardSetup success\");\n return { success: true };\n }\n case GooglePayMockScenario.Success: {\n console.log(\"[MockGooglePay] confirmCardSetup called\", { clientSecret, paymentMethodId });\n return { success: true };\n }\n case GooglePayMockScenario.Cancelled: {\n throw new Error(\"confirmCardSetup should not be called when scenario is Cancelled\");\n }\n }\n }\n}\n"],"mappings":";AAwBA,IAAY,0EAAL;AACL;AACA;AACA;;;AAGF,IAAa,yBAAb,MAAoC;CAClC,AAAQ,SAAwB;CAChC,AAAQ,iBAAwC;CAChD,AAAQ;CAER,YAAY,cAAsC;AAChD,OAAK,eAAe,gBAAgB,sBAAsB;;CAG5D,WAAW,gBAAiC;AAC1C,UAAQ,KAAK,cAAb;GACE,KAAK,sBAAsB,MAAM;AAC/B,YAAQ,IAAI,gCAAgC;AAC5C,QAAI,CAAC,OAAO,QAAQ;AAClB,aAAQ,IAAI,mCAAmC;AAC/C,YAAO;;AAET,SAAK,SAAS,OAAO,OAAO,eAAe;IAC3C,MAAM,UAAU,KAAK,WAAW;AAChC,YAAQ,IAAI,kCAAkC,QAAQ;AACtD,WAAO;;GAET,KAAK,sBAAsB;GAC3B,KAAK,sBAAsB;AACzB,YAAQ,IAAI,oCAAoC;AAChD,YAAQ,IAAI,sCAAsC,KAAK;AACvD,WAAO;;;CAKb,qBAAqB,QAAoC;AACvD,UAAQ,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AmE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as CardErrorCode } from "./connect-card-
|
|
2
|
-
import { t as TunnelXIFrameConnection } from "./connect-tunnel-x-
|
|
1
|
+
import { t as CardErrorCode } from "./connect-card-Cxy51W6t.mjs";
|
|
2
|
+
import { t as TunnelXIFrameConnection } from "./connect-tunnel-x-lv6Wtdme.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/analytics/checkout-timing.d.ts
|
|
5
5
|
|
|
@@ -10,7 +10,8 @@ import { t as TunnelXIFrameConnection } from "./connect-tunnel-x-Dxcg5Y7Y.mjs";
|
|
|
10
10
|
* at appropriate points in the checkout flow.
|
|
11
11
|
*
|
|
12
12
|
* Usage:
|
|
13
|
-
* const
|
|
13
|
+
* const requestId = getOrCreateCheckoutRequestId(environment);
|
|
14
|
+
* const tracker = new CheckoutTimingTracker(secureToken, requestId);
|
|
14
15
|
* tracker.trackPageReady();
|
|
15
16
|
* // ... iframe loads ...
|
|
16
17
|
* tracker.trackInputReady();
|
|
@@ -23,8 +24,9 @@ declare class CheckoutTimingTracker {
|
|
|
23
24
|
private static pageReadyTracked;
|
|
24
25
|
private startTime;
|
|
25
26
|
private checkoutSessionId;
|
|
27
|
+
private requestId;
|
|
26
28
|
private inputReadyTracked;
|
|
27
|
-
constructor(checkoutSessionId: string);
|
|
29
|
+
constructor(checkoutSessionId: string, requestId: string);
|
|
28
30
|
/**
|
|
29
31
|
* Track when SDK is initialized and ready.
|
|
30
32
|
* Call immediately after PaymentKit() initialization.
|
|
@@ -81,6 +83,12 @@ type PaymentKit = <T extends readonly PaymentMethod<unknown>[]>(options: {
|
|
|
81
83
|
environment: string;
|
|
82
84
|
secureToken: string;
|
|
83
85
|
paymentMethods: T;
|
|
86
|
+
/** Card tokenization mode from checkout session */
|
|
87
|
+
cardTokenizationMode?: "direct" | "vgs";
|
|
88
|
+
/** VGS vault ID from checkout session */
|
|
89
|
+
vgsVaultId?: string;
|
|
90
|
+
/** VGS environment from checkout session */
|
|
91
|
+
vgsEnvironment?: string;
|
|
84
92
|
/** @internal Enable analytics test mode for e2e testing */
|
|
85
93
|
__enableAnalyticsTestMode?: boolean;
|
|
86
94
|
}) => ExternalFuncsMapByPm<T> & {
|
|
@@ -88,7 +96,7 @@ type PaymentKit = <T extends readonly PaymentMethod<unknown>[]>(options: {
|
|
|
88
96
|
cleanup: () => void;
|
|
89
97
|
};
|
|
90
98
|
type PaymentKitSubmitHandler<T extends readonly PaymentMethod<unknown>[]> = <N extends keyof ExternalFuncsMapByPm<T>>(options: {
|
|
91
|
-
fields: PaymentKitFields
|
|
99
|
+
fields: Partial<PaymentKitFields>;
|
|
92
100
|
paymentMethod: N;
|
|
93
101
|
options?: unknown;
|
|
94
102
|
onError: (error: PaymentKitErrors) => void;
|
|
@@ -103,6 +111,16 @@ type PaymentKitStates = {
|
|
|
103
111
|
environment: string;
|
|
104
112
|
tunnelXConnection: TunnelXIFrameConnection;
|
|
105
113
|
timingTracker: CheckoutTimingTracker;
|
|
114
|
+
/** Checkout request ID for correlating all API calls and analytics events */
|
|
115
|
+
checkoutRequestId: string;
|
|
116
|
+
/** Card tokenization mode: 'direct' (KMS) or 'vgs' (VGS Collect + proxy) */
|
|
117
|
+
cardTokenizationMode?: "direct" | "vgs";
|
|
118
|
+
/** VGS vault ID (only when cardTokenizationMode is 'vgs') */
|
|
119
|
+
vgsVaultId?: string;
|
|
120
|
+
/** VGS environment: 'sandbox' or 'live' (only when cardTokenizationMode is 'vgs') */
|
|
121
|
+
vgsEnvironment?: string;
|
|
122
|
+
/** @internal Promise that resolves when session config (incl. VGS mode) is auto-detected */
|
|
123
|
+
_sessionConfigReady?: Promise<void>;
|
|
106
124
|
};
|
|
107
125
|
type PaymentKitErrors = {
|
|
108
126
|
root?: string;
|
|
@@ -126,4 +144,4 @@ type PaymentMethod<TExternalFuncs = unknown, TName = string> = (paymentKitStates
|
|
|
126
144
|
type ExternalFuncsMapByPm<T extends readonly PaymentMethod<unknown>[]> = { [K in T[number] as ReturnType<K>["name"]]: ReturnType<K>["externalFuncs"] };
|
|
127
145
|
//#endregion
|
|
128
146
|
export { PaymentKitFields as n, PaymentMethod as r, PaymentKit as t };
|
|
129
|
-
//# sourceMappingURL=types-
|
|
147
|
+
//# sourceMappingURL=types-CZk3V0Qt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CZk3V0Qt.d.mts","names":[],"sources":["../src/analytics/checkout-timing.ts","../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAmBA;;;;AC0CC;AAID;AAEA;;;;;AAQA;;AAGkB,cD3DL,qBAAA,CC2DK;EASS,eAAA,gBAAA;EAArB,QAAA,SAAA;EAC4B,QAAA,iBAAA;EAAxB,QAAA,SAAA;EAAuB,QAAA,iBAAA;EAI5B,WAAA,CAAA,iBAAuB,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA;EAAoB;;;;;EAI/B,cAAA,CAAA,CAAA,EAAA,IAAA;EAEE;;AAInB;;;EAgBwB,eAAA,CAAA,CAAA,EAAA,IAAA;EAAO;AAG/B;;EAGa,WAAA,CAAA,CAAA,EAAA,IAAA;EACA;;;;AAUb;EAEY,YAAA,CAAA,iBAAa,EAAA,MAAA,CAAA,EAAA,IAAA;EAAgE;;;;;AAMzF;;EACQ,SAAA,CAAA,iBAAA,EAAA,MAAA,GAAA,IAAA,EAAA,SAAA,EAAA,MAAA,GAAA,IAAA,EAAA,YAAA,EAAA,MAAA,GAAA,IAAA,CAAA,EAAA,IAAA;EAAwB;;;EAAa,QAAA,YAAA;;;;;AA/E7C,KAFK,cAAA,GAEqB,eAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,mBAAA;AAEd,KAFA,cAAA,GAEc,UAAA,GAAA,SAAA;AAEd,KAFA,cAAA,GAEA;EAEkF,aAAA,EAAA,CAAA,MAAA,EAFlF,gBAEkF,EAAA,OAAA,CAAA,EAAA,OAAA,EAAA,GAAvF,OAAuF,CAAA;IAAvF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K;EACA,OAAA,EAAA,MAAA;EAAc,UAAA,EAAA,MAAA;EAGnB,WAAA,EAAA,MAAA;EAAwC,WAAA,EAAA,MAAA;EAC5C,iBAAA,EArCa,uBAqCb;EAAwB,aAAA,EApCf,qBAoCe;EAAX;EAAmC,iBAAA,EAAA,MAAA;EAAX;EAAU,oBAAA,CAAA,EAAA,QAAA,GAAA,KAAA;;;;;;wBA1B/B;;KAGZ,gBAAA;;aAEC;aACA;aACA;;;;;;;;cAQC,kBAAkB;KAEpB,gBAAA,aAA6B;KAE7B,6EAA6E;QACjF;iBACS;iBACA;;KAGL,wCAAwC,oCAC5C,aAAa,WAAW,aAAa,WAAW"}
|
|
@@ -8,12 +8,13 @@ import * as v from "valibot";
|
|
|
8
8
|
*/
|
|
9
9
|
const ENV_TO_SLUG = {
|
|
10
10
|
local: "dev",
|
|
11
|
-
|
|
11
|
+
tunnel: "dev",
|
|
12
12
|
sandbox: "stg",
|
|
13
13
|
production: "prod"
|
|
14
14
|
};
|
|
15
|
+
const WINDOW_KEY = "__paymentKitRequestId__";
|
|
15
16
|
/**
|
|
16
|
-
* Generates a checkout request ID for correlating all API calls within a
|
|
17
|
+
* Generates a checkout request ID for correlating all API calls within a checkout session.
|
|
17
18
|
*
|
|
18
19
|
* Format: pk_{env}_{nanoid(12)}
|
|
19
20
|
* - pk = PaymentKit.js (client-generated)
|
|
@@ -21,16 +22,26 @@ const ENV_TO_SLUG = {
|
|
|
21
22
|
* - nanoid(12) = 12 character random string
|
|
22
23
|
*
|
|
23
24
|
* Example: pk_stg_a1b2c3d4e5f6
|
|
24
|
-
*
|
|
25
|
-
* This ID should be:
|
|
26
|
-
* 1. Generated once when user clicks submit
|
|
27
|
-
* 2. Passed via x-request-id header on ALL checkout API calls
|
|
28
|
-
* 3. Used to correlate logs across the checkout flow
|
|
29
25
|
*/
|
|
30
26
|
function generateCheckoutRequestId(environment) {
|
|
31
27
|
return `pk_${ENV_TO_SLUG[environment] || "dev"}_${nanoid(12)}`;
|
|
32
28
|
}
|
|
33
29
|
/**
|
|
30
|
+
* Gets or creates a checkout request ID, storing it in window for idempotency.
|
|
31
|
+
*
|
|
32
|
+
* This ensures the same request ID is used across:
|
|
33
|
+
* - Multiple PaymentKit instantiations on the same page
|
|
34
|
+
* - All analytics events and API calls within a checkout session
|
|
35
|
+
*
|
|
36
|
+
* The ID is generated once on first call and reused thereafter.
|
|
37
|
+
*/
|
|
38
|
+
function getOrCreateCheckoutRequestId(environment) {
|
|
39
|
+
if (typeof window !== "undefined" && window[WINDOW_KEY]) return window[WINDOW_KEY];
|
|
40
|
+
const requestId = generateCheckoutRequestId(environment);
|
|
41
|
+
if (typeof window !== "undefined") window[WINDOW_KEY] = requestId;
|
|
42
|
+
return requestId;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
34
45
|
* Creates RequestOptions with the x-request-id header set.
|
|
35
46
|
*/
|
|
36
47
|
function withRequestId(checkoutRequestId) {
|
|
@@ -96,5 +107,5 @@ function collectFraudMetadata() {
|
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
//#endregion
|
|
99
|
-
export { validateFormFields as a, definePaymentMethod as i, collectFraudMetadata as n,
|
|
100
|
-
//# sourceMappingURL=utils-
|
|
110
|
+
export { validateFormFields as a, definePaymentMethod as i, collectFraudMetadata as n, getOrCreateCheckoutRequestId as o, createCheckoutIFrame as r, withRequestId as s, $ as t };
|
|
111
|
+
//# sourceMappingURL=utils-B70Y8YcZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-B70Y8YcZ.mjs","names":["ENV_TO_SLUG: Record<string, string>"],"sources":["../src/utils/checkout-request-id.ts","../src/utils/validate-form-fields.ts","../src/utils/index.ts"],"sourcesContent":["import { nanoid } from \"nanoid\";\n\n/**\n * Maps PaymentKit environment to request ID env slug.\n * This must match the backend's env slug format.\n */\nconst ENV_TO_SLUG: Record<string, string> = {\n local: \"dev\",\n tunnel: \"dev\",\n sandbox: \"stg\",\n production: \"prod\",\n};\n\n// Window key for storing the request ID across PaymentKit instantiations\nconst WINDOW_KEY = \"__paymentKitRequestId__\";\n\n/**\n * Generates a checkout request ID for correlating all API calls within a checkout session.\n *\n * Format: pk_{env}_{nanoid(12)}\n * - pk = PaymentKit.js (client-generated)\n * - env = dev, stg, or prod\n * - nanoid(12) = 12 character random string\n *\n * Example: pk_stg_a1b2c3d4e5f6\n */\nexport function generateCheckoutRequestId(environment: string): string {\n const envSlug = ENV_TO_SLUG[environment] || \"dev\";\n const randomPart = nanoid(12);\n return `pk_${envSlug}_${randomPart}`;\n}\n\n/**\n * Gets or creates a checkout request ID, storing it in window for idempotency.\n *\n * This ensures the same request ID is used across:\n * - Multiple PaymentKit instantiations on the same page\n * - All analytics events and API calls within a checkout session\n *\n * The ID is generated once on first call and reused thereafter.\n */\nexport function getOrCreateCheckoutRequestId(environment: string): string {\n if (typeof window !== \"undefined\" && window[WINDOW_KEY]) {\n return window[WINDOW_KEY] as string;\n }\n\n const requestId = generateCheckoutRequestId(environment);\n\n if (typeof window !== \"undefined\") {\n (window as Record<string, unknown>)[WINDOW_KEY] = requestId;\n }\n\n return requestId;\n}\n\n/**\n * Creates RequestOptions with the x-request-id header set.\n */\nexport function withRequestId(checkoutRequestId: string) {\n return {\n headers: {\n \"x-request-id\": checkoutRequestId,\n },\n };\n}\n","import * as v from \"valibot\";\nimport type { FormErrorCodes, PaymentKitErrors, PaymentKitFields } from \"../types\";\n\ntype Options = {\n optionalZipCode?: boolean;\n};\n\nexport const validateFormFields = async (fields: PaymentKitFields, options: Options = {}) => {\n const schema = v.object({\n customer_name: v.pipe(\n v.string(\"required\"),\n v.nonEmpty(\"required\"),\n v.minLength(4, \"invalid\"),\n v.maxLength(40, \"invalid\"),\n ),\n customer_email: v.pipe(v.string(\"required\"), v.nonEmpty(\"required\"), v.email(\"invalid\")),\n customer_country: v.pipe(v.string(\"required\"), v.nonEmpty(\"required\")),\n customer_zip_code: options.optionalZipCode\n ? v.pipe(v.string(\"required\"))\n : v.pipe(v.string(\"required\"), v.nonEmpty(\"required\")),\n });\n\n const result = v.safeParse(schema, fields);\n\n if (result.issues) {\n const errors = result.issues.reduce((errors, issue) => {\n const field = v.getDotPath(issue) as keyof PaymentKitErrors;\n\n errors[field] = issue.kind === \"schema\" ? \"required\" : (issue.message as FormErrorCodes);\n return errors;\n }, {} as PaymentKitErrors);\n return { isSuccess: false, errors };\n }\n\n return { isSuccess: true };\n};\n","import type { PaymentMethod } from \"../types\";\n\nexport { generateCheckoutRequestId, getOrCreateCheckoutRequestId, withRequestId } from \"./checkout-request-id\";\nexport { validateFormFields } from \"./validate-form-fields\";\n\nexport const $ = (selector: string) => {\n const ele = document.querySelector(selector);\n if (!ele) {\n throw new Error(`Cannot find element with selector: ${selector}`);\n }\n return ele;\n};\n\nexport const definePaymentMethod = <TExternalFuncs, TName extends string>(\n paymentMethod: PaymentMethod<TExternalFuncs, TName>,\n) => paymentMethod;\n\nexport const createCheckoutIFrame = (type: string, baseUrl: string, params?: Record<string, string>) => {\n const iframe = document.createElement(\"iframe\");\n\n const searchParams = new URLSearchParams(params);\n const searchParamsStr = searchParams.toString();\n\n iframe.src = `${baseUrl}/embeds/v1/${type}${searchParamsStr ? `?${searchParamsStr}` : \"\"}`;\n\n Object.assign(iframe.style, { width: \"100%\", height: \"100%\", border: \"none\" });\n\n return iframe;\n};\n\n/**\n * Collects browser and client information for fraud detection.\n */\nexport function collectFraudMetadata() {\n return {\n ipAddress: undefined, // IP address should be collected server-side\n browserInfo: {\n userAgent: navigator.userAgent,\n language: navigator.language,\n screenHeight: window.screen.height,\n screenWidth: window.screen.width,\n colorDepth: window.screen.colorDepth,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n processorFraudInfo: undefined,\n };\n}\n\ntype AddressInput = {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n zip_code?: string;\n country?: string;\n};\n\ntype AddressOutput = {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n zipCode?: string;\n country?: string;\n};\n\n/**\n * Maps address fields from snake_case to camelCase format.\n */\nexport function mapAddress(address?: AddressInput): AddressOutput | undefined {\n if (!address) return undefined;\n\n return {\n line1: address.line1,\n line2: address.line2,\n city: address.city,\n state: address.state,\n zipCode: address.zip_code,\n country: address.country,\n };\n}\n"],"mappings":";;;;;;;;AAMA,MAAMA,cAAsC;CAC1C,OAAO;CACP,QAAQ;CACR,SAAS;CACT,YAAY;CACb;AAGD,MAAM,aAAa;;;;;;;;;;;AAYnB,SAAgB,0BAA0B,aAA6B;AAGrE,QAAO,MAFS,YAAY,gBAAgB,MAEvB,GADF,OAAO,GAAG;;;;;;;;;;;AAa/B,SAAgB,6BAA6B,aAA6B;AACxE,KAAI,OAAO,WAAW,eAAe,OAAO,YAC1C,QAAO,OAAO;CAGhB,MAAM,YAAY,0BAA0B,YAAY;AAExD,KAAI,OAAO,WAAW,YACpB,CAAC,OAAmC,cAAc;AAGpD,QAAO;;;;;AAMT,SAAgB,cAAc,mBAA2B;AACvD,QAAO,EACL,SAAS,EACP,gBAAgB,mBACjB,EACF;;;;;ACxDH,MAAa,qBAAqB,OAAO,QAA0B,UAAmB,EAAE,KAAK;CAC3F,MAAM,SAAS,EAAE,OAAO;EACtB,eAAe,EAAE,KACf,EAAE,OAAO,WAAW,EACpB,EAAE,SAAS,WAAW,EACtB,EAAE,UAAU,GAAG,UAAU,EACzB,EAAE,UAAU,IAAI,UAAU,CAC3B;EACD,gBAAgB,EAAE,KAAK,EAAE,OAAO,WAAW,EAAE,EAAE,SAAS,WAAW,EAAE,EAAE,MAAM,UAAU,CAAC;EACxF,kBAAkB,EAAE,KAAK,EAAE,OAAO,WAAW,EAAE,EAAE,SAAS,WAAW,CAAC;EACtE,mBAAmB,QAAQ,kBACvB,EAAE,KAAK,EAAE,OAAO,WAAW,CAAC,GAC5B,EAAE,KAAK,EAAE,OAAO,WAAW,EAAE,EAAE,SAAS,WAAW,CAAC;EACzD,CAAC;CAEF,MAAM,SAAS,EAAE,UAAU,QAAQ,OAAO;AAE1C,KAAI,OAAO,OAOT,QAAO;EAAE,WAAW;EAAO,QANZ,OAAO,OAAO,QAAQ,QAAQ,UAAU;GACrD,MAAM,QAAQ,EAAE,WAAW,MAAM;AAEjC,UAAO,SAAS,MAAM,SAAS,WAAW,aAAc,MAAM;AAC9D,UAAO;KACN,EAAE,CAAqB;EACS;AAGrC,QAAO,EAAE,WAAW,MAAM;;;;;AC7B5B,MAAa,KAAK,aAAqB;CACrC,MAAM,MAAM,SAAS,cAAc,SAAS;AAC5C,KAAI,CAAC,IACH,OAAM,IAAI,MAAM,sCAAsC,WAAW;AAEnE,QAAO;;AAGT,MAAa,uBACX,kBACG;AAEL,MAAa,wBAAwB,MAAc,SAAiB,WAAoC;CACtG,MAAM,SAAS,SAAS,cAAc,SAAS;CAG/C,MAAM,kBADe,IAAI,gBAAgB,OAAO,CACX,UAAU;AAE/C,QAAO,MAAM,GAAG,QAAQ,aAAa,OAAO,kBAAkB,IAAI,oBAAoB;AAEtF,QAAO,OAAO,OAAO,OAAO;EAAE,OAAO;EAAQ,QAAQ;EAAQ,QAAQ;EAAQ,CAAC;AAE9E,QAAO;;;;;AAMT,SAAgB,uBAAuB;AACrC,QAAO;EACL,WAAW;EACX,aAAa;GACX,WAAW,UAAU;GACrB,UAAU,UAAU;GACpB,cAAc,OAAO,OAAO;GAC5B,aAAa,OAAO,OAAO;GAC3B,YAAY,OAAO,OAAO;GAC1B,UAAU,KAAK,gBAAgB,CAAC,iBAAiB,CAAC;GACnD;EACD,oBAAoB;EACrB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region src/payment-methods/vgs-collect-loader.ts
|
|
2
|
+
const VGS_COLLECT_CDN = "https://js.verygoodvault.com/vgs-collect/3.2.1/vgs-collect.js";
|
|
3
|
+
let loadPromise = null;
|
|
4
|
+
/**
|
|
5
|
+
* Loads VGS Collect JS from CDN. Idempotent — subsequent calls return the same promise.
|
|
6
|
+
*/
|
|
7
|
+
function loadVgsCollectScript() {
|
|
8
|
+
if (loadPromise) {
|
|
9
|
+
console.log("[PaymentKit] VGS Collect CDN load already in progress — reusing promise");
|
|
10
|
+
return loadPromise;
|
|
11
|
+
}
|
|
12
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
13
|
+
if (typeof window !== "undefined" && window.VGSCollect) {
|
|
14
|
+
console.log("[PaymentKit] VGS Collect JS already available on window");
|
|
15
|
+
resolve();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.log(`[PaymentKit] Loading VGS Collect JS from CDN: ${VGS_COLLECT_CDN}`);
|
|
19
|
+
const script = document.createElement("script");
|
|
20
|
+
script.src = VGS_COLLECT_CDN;
|
|
21
|
+
script.async = true;
|
|
22
|
+
script.onload = () => {
|
|
23
|
+
console.log("[PaymentKit] VGS Collect JS loaded successfully from CDN");
|
|
24
|
+
resolve();
|
|
25
|
+
};
|
|
26
|
+
script.onerror = () => {
|
|
27
|
+
console.error(`[PaymentKit] Failed to load VGS Collect JS from CDN: ${VGS_COLLECT_CDN}`);
|
|
28
|
+
loadPromise = null;
|
|
29
|
+
reject(/* @__PURE__ */ new Error("Failed to load VGS Collect JS"));
|
|
30
|
+
};
|
|
31
|
+
document.head.appendChild(script);
|
|
32
|
+
});
|
|
33
|
+
return loadPromise;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Initializes a VGS Collect form instance.
|
|
37
|
+
*/
|
|
38
|
+
function initVgsCollect(vaultId, environment) {
|
|
39
|
+
if (!window.VGSCollect) throw new Error("VGS Collect JS not loaded. Call loadVgsCollectScript() first.");
|
|
40
|
+
return window.VGSCollect.create(vaultId, environment, () => {});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates and mounts VGS Collect card fields using CMP-specific field methods.
|
|
44
|
+
*
|
|
45
|
+
* Uses cardNumberField(), cardExpirationDateField(), cardCVCField() which are
|
|
46
|
+
* required for the CMP createCard() flow. After mounting, call form.createCard()
|
|
47
|
+
* to create a card in the VGS vault, which returns aliases for PAN and CVC.
|
|
48
|
+
*
|
|
49
|
+
* @param form - VGS Collect form instance
|
|
50
|
+
* @param mountPoints - CSS selectors for PAN, expiry, and CVC containers
|
|
51
|
+
* @param css - Optional CSS to apply to VGS Collect iframe fields
|
|
52
|
+
*/
|
|
53
|
+
function createVgsCardFields(form, mountPoints, css, onFocusChangeCallbacks) {
|
|
54
|
+
const fieldCss = css ?? {
|
|
55
|
+
height: "46px",
|
|
56
|
+
"font-size": "1rem",
|
|
57
|
+
color: "#18181b",
|
|
58
|
+
"font-family": "ui-sans-serif, system-ui, sans-serif"
|
|
59
|
+
};
|
|
60
|
+
const panField = form.cardNumberField(mountPoints.pan, {
|
|
61
|
+
placeholder: "Card number",
|
|
62
|
+
validations: ["required", "validCardNumber"],
|
|
63
|
+
css: fieldCss
|
|
64
|
+
});
|
|
65
|
+
const expField = form.cardExpirationDateField(mountPoints.exp, {
|
|
66
|
+
placeholder: "MM / YY",
|
|
67
|
+
validations: ["required", "validCardExpirationDate"],
|
|
68
|
+
css: fieldCss
|
|
69
|
+
});
|
|
70
|
+
const cvcField = form.cardCVCField(mountPoints.cvc, {
|
|
71
|
+
placeholder: "123",
|
|
72
|
+
validations: ["required", "validCardSecurityCode"],
|
|
73
|
+
css: fieldCss
|
|
74
|
+
});
|
|
75
|
+
if (onFocusChangeCallbacks) {
|
|
76
|
+
const fieldMap = [
|
|
77
|
+
[panField, "card_pan"],
|
|
78
|
+
[expField, "card_exp"],
|
|
79
|
+
[cvcField, "card_cvc"]
|
|
80
|
+
];
|
|
81
|
+
for (const [field, key] of fieldMap) {
|
|
82
|
+
const cb = onFocusChangeCallbacks[key];
|
|
83
|
+
if (cb) {
|
|
84
|
+
field.on("focus", () => cb(true));
|
|
85
|
+
field.on("blur", () => cb(false));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { initVgsCollect as n, loadVgsCollectScript as r, createVgsCardFields as t };
|
|
93
|
+
//# sourceMappingURL=vgs-collect-loader-D3_xOA-G.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vgs-collect-loader-D3_xOA-G.mjs","names":["loadPromise: Promise<void> | null","fieldMap: [VGSCollectField, string][]"],"sources":["../src/payment-methods/vgs-collect-loader.ts"],"sourcesContent":["const VGS_COLLECT_CDN = \"https://js.verygoodvault.com/vgs-collect/3.2.1/vgs-collect.js\";\n\nlet loadPromise: Promise<void> | null = null;\n\n/**\n * Loads VGS Collect JS from CDN. Idempotent — subsequent calls return the same promise.\n */\nexport function loadVgsCollectScript(): Promise<void> {\n if (loadPromise) {\n console.log(\"[PaymentKit] VGS Collect CDN load already in progress — reusing promise\");\n return loadPromise;\n }\n\n loadPromise = new Promise<void>((resolve, reject) => {\n if (typeof window !== \"undefined\" && window.VGSCollect) {\n console.log(\"[PaymentKit] VGS Collect JS already available on window\");\n resolve();\n return;\n }\n\n console.log(`[PaymentKit] Loading VGS Collect JS from CDN: ${VGS_COLLECT_CDN}`);\n const script = document.createElement(\"script\");\n script.src = VGS_COLLECT_CDN;\n script.async = true;\n script.onload = () => {\n console.log(\"[PaymentKit] VGS Collect JS loaded successfully from CDN\");\n resolve();\n };\n script.onerror = () => {\n console.error(`[PaymentKit] Failed to load VGS Collect JS from CDN: ${VGS_COLLECT_CDN}`);\n loadPromise = null;\n reject(new Error(\"Failed to load VGS Collect JS\"));\n };\n document.head.appendChild(script);\n });\n\n return loadPromise;\n}\n\n/**\n * Initializes a VGS Collect form instance.\n */\nexport function initVgsCollect(vaultId: string, environment: string): VGSCollectForm {\n if (!window.VGSCollect) {\n throw new Error(\"VGS Collect JS not loaded. Call loadVgsCollectScript() first.\");\n }\n return window.VGSCollect.create(vaultId, environment, () => {});\n}\n\n/**\n * Creates and mounts VGS Collect card fields using CMP-specific field methods.\n *\n * Uses cardNumberField(), cardExpirationDateField(), cardCVCField() which are\n * required for the CMP createCard() flow. After mounting, call form.createCard()\n * to create a card in the VGS vault, which returns aliases for PAN and CVC.\n *\n * @param form - VGS Collect form instance\n * @param mountPoints - CSS selectors for PAN, expiry, and CVC containers\n * @param css - Optional CSS to apply to VGS Collect iframe fields\n */\nexport function createVgsCardFields(\n form: VGSCollectForm,\n mountPoints: { pan: string; exp: string; cvc: string },\n css?: Record<string, string>,\n onFocusChangeCallbacks?: Partial<Record<string, (isFocused: boolean) => void>>,\n) {\n const fieldCss = css ?? {\n height: \"46px\",\n \"font-size\": \"1rem\",\n color: \"#18181b\",\n \"font-family\": \"ui-sans-serif, system-ui, sans-serif\",\n };\n\n const panField = form.cardNumberField(mountPoints.pan, {\n placeholder: \"Card number\",\n validations: [\"required\", \"validCardNumber\"],\n css: fieldCss,\n });\n\n const expField = form.cardExpirationDateField(mountPoints.exp, {\n placeholder: \"MM / YY\",\n validations: [\"required\", \"validCardExpirationDate\"],\n css: fieldCss,\n });\n\n const cvcField = form.cardCVCField(mountPoints.cvc, {\n placeholder: \"123\",\n validations: [\"required\", \"validCardSecurityCode\"],\n css: fieldCss,\n });\n\n if (onFocusChangeCallbacks) {\n const fieldMap: [VGSCollectField, string][] = [\n [panField, \"card_pan\"],\n [expField, \"card_exp\"],\n [cvcField, \"card_cvc\"],\n ];\n for (const [field, key] of fieldMap) {\n const cb = onFocusChangeCallbacks[key];\n if (cb) {\n field.on(\"focus\", () => cb(true));\n field.on(\"blur\", () => cb(false));\n }\n }\n }\n}\n"],"mappings":";AAAA,MAAM,kBAAkB;AAExB,IAAIA,cAAoC;;;;AAKxC,SAAgB,uBAAsC;AACpD,KAAI,aAAa;AACf,UAAQ,IAAI,0EAA0E;AACtF,SAAO;;AAGT,eAAc,IAAI,SAAe,SAAS,WAAW;AACnD,MAAI,OAAO,WAAW,eAAe,OAAO,YAAY;AACtD,WAAQ,IAAI,0DAA0D;AACtE,YAAS;AACT;;AAGF,UAAQ,IAAI,iDAAiD,kBAAkB;EAC/E,MAAM,SAAS,SA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
|
"name": "@payment-kit-js/vanilla",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"types": "./dist/index.d.mts",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dist/index.mjs",
|
|
9
|
+
"./payment-methods/airwallex-apple-pay-adapter": "./dist/payment-methods/airwallex-apple-pay-adapter.mjs",
|
|
9
10
|
"./payment-methods/airwallex-google-pay-adapter": "./dist/payment-methods/airwallex-google-pay-adapter.mjs",
|
|
10
11
|
"./payment-methods/apple-pay": "./dist/payment-methods/apple-pay.mjs",
|
|
11
12
|
"./payment-methods/card": "./dist/payment-methods/card.mjs",
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
"./payment-methods/paypal": "./dist/payment-methods/paypal.mjs",
|
|
15
16
|
"./payment-methods/stripe-apple-pay-adapter": "./dist/payment-methods/stripe-apple-pay-adapter.mjs",
|
|
16
17
|
"./payment-methods/stripe-google-pay-adapter": "./dist/payment-methods/stripe-google-pay-adapter.mjs",
|
|
18
|
+
"./payment-methods/vgs-collect-loader": "./dist/payment-methods/vgs-collect-loader.mjs",
|
|
17
19
|
"./penpal/connect-card": "./dist/penpal/connect-card.mjs",
|
|
18
20
|
"./penpal/connect-tunnel-x": "./dist/penpal/connect-tunnel-x.mjs",
|
|
19
21
|
"./package.json": "./package.json"
|
|
@@ -46,5 +48,5 @@
|
|
|
46
48
|
"tsdown": "^0.15.10",
|
|
47
49
|
"typescript": "^5.9.3"
|
|
48
50
|
},
|
|
49
|
-
"stableVersion": "0.
|
|
51
|
+
"stableVersion": "0.5.2"
|
|
50
52
|
}
|