@payment-kit-js/vanilla 0.5.17 → 0.5.18

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.
Files changed (45) hide show
  1. package/dist/{bnpl-shared-DGs1YzS9.mjs → bnpl-shared-CL900HFN.mjs} +2 -2
  2. package/dist/{bnpl-shared-DGs1YzS9.mjs.map → bnpl-shared-CL900HFN.mjs.map} +1 -1
  3. package/dist/{bnpl-shared-BQwCBD45.d.mts → bnpl-shared-D-Kd58Qz.d.mts} +2 -2
  4. package/dist/{bnpl-shared-BQwCBD45.d.mts.map → bnpl-shared-D-Kd58Qz.d.mts.map} +1 -1
  5. package/dist/cdn/paymentkit.js +186 -51
  6. package/dist/cdn/paymentkit.js.map +3 -3
  7. package/dist/cdn/paymentkit.min.js +24 -24
  8. package/dist/cdn/paymentkit.min.js.map +3 -3
  9. package/dist/connect-card-CZhzK_Tp.d.mts.map +1 -1
  10. package/dist/index.d.mts +2 -2
  11. package/dist/index.mjs +11 -4
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/{next-action-handlers-CLOt1wzO.mjs → next-action-handlers-BZ5gynXe.mjs} +18 -18
  14. package/dist/next-action-handlers-BZ5gynXe.mjs.map +1 -0
  15. package/dist/payment-methods/affirm.d.mts +2 -2
  16. package/dist/payment-methods/affirm.mjs +2 -2
  17. package/dist/payment-methods/afterpay.d.mts +2 -2
  18. package/dist/payment-methods/afterpay.mjs +2 -2
  19. package/dist/payment-methods/apple-pay.d.mts +2 -2
  20. package/dist/payment-methods/apple-pay.d.mts.map +1 -1
  21. package/dist/payment-methods/apple-pay.mjs +2 -2
  22. package/dist/payment-methods/apple-pay.mjs.map +1 -1
  23. package/dist/payment-methods/bnpl-shared.d.mts +2 -2
  24. package/dist/payment-methods/bnpl-shared.mjs +2 -2
  25. package/dist/payment-methods/card.d.mts +1 -1
  26. package/dist/payment-methods/card.d.mts.map +1 -1
  27. package/dist/payment-methods/card.mjs +8 -4
  28. package/dist/payment-methods/card.mjs.map +1 -1
  29. package/dist/payment-methods/google-pay.d.mts +25 -3
  30. package/dist/payment-methods/google-pay.d.mts.map +1 -1
  31. package/dist/payment-methods/google-pay.mjs +131 -10
  32. package/dist/payment-methods/google-pay.mjs.map +1 -1
  33. package/dist/payment-methods/klarna.d.mts +2 -2
  34. package/dist/payment-methods/klarna.mjs +2 -2
  35. package/dist/payment-methods/next-action-handlers.mjs +1 -1
  36. package/dist/payment-methods/paypal.d.mts +1 -1
  37. package/dist/payment-methods/paypal.mjs +1 -1
  38. package/dist/{types-B3mjYfOm.d.mts → types-Cjcc3xak.d.mts} +6 -9
  39. package/dist/types-Cjcc3xak.d.mts.map +1 -0
  40. package/dist/{utils-Dc6zwOe1.mjs → utils-DIqrx4XF.mjs} +10 -7
  41. package/dist/utils-DIqrx4XF.mjs.map +1 -0
  42. package/package.json +2 -2
  43. package/dist/next-action-handlers-CLOt1wzO.mjs.map +0 -1
  44. package/dist/types-B3mjYfOm.d.mts.map +0 -1
  45. package/dist/utils-Dc6zwOe1.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"connect-card-CZhzK_Tp.d.mts","names":[],"sources":["../src/penpal/connect-card.ts"],"sourcesContent":[],"mappings":";;;KAIK,iBAAA;EAAA,QAAA,EAAA,CAAA,iBAAiB,EAAA,MAAA,EAAA,GACqB,OADrB,CAC6B,eAD7B,GAAA;IAC6B,KAAA,EAA2B,aAA3B;EAA2B,CAAA,CAAA;EAAnC,UAAA,EAAA,GAAA,GACvB,OADuB,CACf,aADe,GAAA,SAAA,CAAA;CACf;KAGvB,iBAAA,GAHe;EAAO,QAAA,EAAA,GAAA,GAAA,IAAA;EAGtB,aAAA,EAAA,CAAA,SAAiB,EAAA,OAAA,EAAA,GAAA,IAAA;AAKtB,CAAA;AAEY,KAFA,aAAA,GAEa,UAAA,GAAA,UAAA,GAAA,UAAA;AAOb,KAPA,aAAA,GAOgB,SAAc,GAAA,UAAA,GAAA,eAAD,GAAA,sBAAA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BAJ2D,EAAA,CAAA,OAAA,EAI3B,iBAJ2B,EAAA,GAIV,UAJU,CAIV,iBAJU,CAAA"}
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { n as PaymentKitFields, t as PaymentKit$1 } from "./types-B3mjYfOm.mjs";
1
+ import { n as PaymentKitEnvironment, r as PaymentKitFields, t as PaymentKit$1 } from "./types-Cjcc3xak.mjs";
2
2
  import "./connect-card-CZhzK_Tp.mjs";
3
3
  import "./connect-tunnel-x-BKtMfoGh.mjs";
4
4
 
5
5
  //#region src/index.d.ts
6
6
  declare const PaymentKit: PaymentKit$1;
7
7
  //#endregion
8
- export { type PaymentKitFields, PaymentKit as default };
8
+ export { type PaymentKitEnvironment, type PaymentKitFields, PaymentKit as default };
9
9
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { n as AnalyticsService, t as CheckoutTimingTracker } from "./analytics-Blvs2DW7.mjs";
2
2
  import "./penpal-CBrj43M5.mjs";
3
3
  import { n as connectToTunnelXIframe } from "./connect-tunnel-x-5XOct5Tm.mjs";
4
- import { o as getOrCreateCheckoutRequestId, r as createCheckoutIFrame } from "./utils-Dc6zwOe1.mjs";
4
+ import { o as getOrCreateCheckoutRequestId, r as createCheckoutIFrame } from "./utils-DIqrx4XF.mjs";
5
5
 
6
6
  //#region package.json
7
- var version = "0.5.17";
7
+ var version = "0.5.18";
8
8
 
9
9
  //#endregion
10
10
  //#region src/types.ts
@@ -14,6 +14,10 @@ const STATIC_ENVIRONMENT_URLS = {
14
14
  apiBaseUrl: "http://localhost:9000"
15
15
  },
16
16
  sandbox: {
17
+ baseUrl: "https://app.paymentkit.com/customer",
18
+ apiBaseUrl: "https://app.paymentkit.com"
19
+ },
20
+ staging: {
17
21
  baseUrl: "https://staging.paymentkit.com/customer",
18
22
  apiBaseUrl: "https://staging.paymentkit.com"
19
23
  },
@@ -43,7 +47,10 @@ function getTunnelUrls() {
43
47
  function getUrlsForEnvironment(environment) {
44
48
  if (environment === "tunnel") return getTunnelUrls();
45
49
  const urls = STATIC_ENVIRONMENT_URLS[environment];
46
- if (!urls) throw new Error(`Invalid environment: ${environment}. Must be one of: local, tunnel, sandbox, production`);
50
+ if (!urls) {
51
+ console.warn(`[PaymentKit] Invalid environment "${environment}", falling back to local`);
52
+ return STATIC_ENVIRONMENT_URLS.local;
53
+ }
47
54
  return urls;
48
55
  }
49
56
 
@@ -71,7 +78,7 @@ const createTunnelXConnection = (baseUrl, apiBaseUrl, token) => {
71
78
  connection
72
79
  };
73
80
  };
74
- const PaymentKit = ({ environment, secureToken, paymentMethods, cardTokenizationMode, vgsVaultId, vgsEnvironment, __enableAnalyticsTestMode }) => {
81
+ const PaymentKit = ({ environment = "production", secureToken, paymentMethods, cardTokenizationMode, vgsVaultId, vgsEnvironment, __enableAnalyticsTestMode }) => {
75
82
  const { baseUrl, apiBaseUrl } = getUrlsForEnvironment(environment);
76
83
  console.log(`[PaymentKit] v${version} initialized (env: ${environment})`);
77
84
  const checkoutRequestId = getOrCreateCheckoutRequestId(environment);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["STATIC_ENVIRONMENT_URLS: Record<Exclude<PaymentKitEnvironment, \"tunnel\">, EnvironmentUrls>","PaymentKit: PaymentKitType","PACKAGE_VERSION","externalFuncsMapByPm: ExternalFuncsMapByPm<PaymentMethods>","submit: PaymentKitReturnType[\"submit\"]"],"sources":["../package.json","../src/types.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@payment-kit-js/vanilla\",\n \"version\": \"0.5.17\",\n \"main\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": \"./dist/index.mjs\",\n \"./payment-methods/affirm\": \"./dist/payment-methods/affirm.mjs\",\n \"./payment-methods/afterpay\": \"./dist/payment-methods/afterpay.mjs\",\n \"./payment-methods/airwallex-apple-pay-adapter\": \"./dist/payment-methods/airwallex-apple-pay-adapter.mjs\",\n \"./payment-methods/airwallex-google-pay-adapter\": \"./dist/payment-methods/airwallex-google-pay-adapter.mjs\",\n \"./payment-methods/apple-pay\": \"./dist/payment-methods/apple-pay.mjs\",\n \"./payment-methods/bnpl-shared\": \"./dist/payment-methods/bnpl-shared.mjs\",\n \"./payment-methods/card\": \"./dist/payment-methods/card.mjs\",\n \"./payment-methods/google-pay\": \"./dist/payment-methods/google-pay.mjs\",\n \"./payment-methods/klarna\": \"./dist/payment-methods/klarna.mjs\",\n \"./payment-methods/next-action-handlers\": \"./dist/payment-methods/next-action-handlers.mjs\",\n \"./payment-methods/paypal\": \"./dist/payment-methods/paypal.mjs\",\n \"./payment-methods/stripe-apple-pay-adapter\": \"./dist/payment-methods/stripe-apple-pay-adapter.mjs\",\n \"./payment-methods/stripe-google-pay-adapter\": \"./dist/payment-methods/stripe-google-pay-adapter.mjs\",\n \"./payment-methods/vgs-collect-loader\": \"./dist/payment-methods/vgs-collect-loader.mjs\",\n \"./penpal/connect-card\": \"./dist/penpal/connect-card.mjs\",\n \"./penpal/connect-tunnel-x\": \"./dist/penpal/connect-tunnel-x.mjs\",\n \"./package.json\": \"./package.json\"\n },\n \"license\": \"MIT\",\n \"description\": \"Vanilla package for PaymentKit\",\n \"files\": [\n \"dist\",\n \"dist/cdn\"\n ],\n \"scripts\": {\n \"dev\": \"yarn tsdown --watch ./src\",\n \"build:npm\": \"yarn tsdown\",\n \"build:cdn\": \"node build-cdn.mjs\",\n \"build\": \"yarn build:npm && yarn build:cdn\"\n },\n \"packageManager\": \"yarn@4.10.3\",\n \"dependencies\": {\n \"nanoid\": \"^5.0.7\",\n \"penpal\": \"^7.0.4\",\n \"posthog-js\": \"^1.196.0\",\n \"valibot\": \"^1.1.0\"\n },\n \"devDependencies\": {\n \"@pkg/sdk\": \"workspace:*\",\n \"@pkg/tsconfig\": \"workspace:*\",\n \"@stripe/stripe-js\": \"^8.6.1\",\n \"@types/applepayjs\": \"^14.0.9\",\n \"esbuild\": \"^0.24.2\",\n \"tsdown\": \"^0.15.10\",\n \"typescript\": \"^5.9.3\"\n },\n \"stableVersion\": \"0.5.17\"\n}\n","import type { CheckoutTimingTracker } from \"./analytics\";\nimport type { CardErrorCode } from \"./penpal/connect-card\";\nimport type { TunnelXIFrameConnection } from \"./penpal/connect-tunnel-x\";\n\nexport type PaymentKitEnvironment = \"local\" | \"tunnel\" | \"sandbox\" | \"production\";\n\ntype EnvironmentUrls = {\n baseUrl: string;\n apiBaseUrl: string;\n};\n\n// TODO: Cleanup this after launch to only use SDK instead of plain fetch.\nconst STATIC_ENVIRONMENT_URLS: Record<Exclude<PaymentKitEnvironment, \"tunnel\">, EnvironmentUrls> = {\n local: {\n baseUrl: \"http://localhost:9101\",\n apiBaseUrl: \"http://localhost:9000\",\n },\n sandbox: {\n baseUrl: \"https://staging.paymentkit.com/customer\",\n apiBaseUrl: \"https://staging.paymentkit.com\",\n },\n production: {\n baseUrl: \"https://app.paymentkit.com/customer\",\n apiBaseUrl: \"https://app.paymentkit.com\",\n },\n};\n\nfunction getTunnelUrls(): EnvironmentUrls {\n if (typeof window !== \"undefined\") {\n const params = new URLSearchParams(window.location.search);\n const apiBaseUrl = params.get(\"api_base_url\");\n if (apiBaseUrl) {\n return {\n baseUrl: window.location.origin,\n apiBaseUrl,\n };\n }\n // For loclx-style tunnels where API hostname is derived from the current hostname\n const hostname = window.location.hostname;\n if (hostname.includes(\"loclx.io\")) {\n const apiHostname = hostname.replace(/cportal|playground/, \"api\");\n return {\n baseUrl: `https://${hostname}`,\n apiBaseUrl: `https://${apiHostname}`,\n };\n }\n }\n // Fallback\n return STATIC_ENVIRONMENT_URLS.local;\n}\n\nexport function getUrlsForEnvironment(environment: string): EnvironmentUrls {\n if (environment === \"tunnel\") {\n return getTunnelUrls();\n }\n const env = environment as Exclude<PaymentKitEnvironment, \"tunnel\">;\n const urls = STATIC_ENVIRONMENT_URLS[env];\n if (!urls) {\n throw new Error(`Invalid environment: ${environment}. Must be one of: local, tunnel, sandbox, production`);\n }\n return urls;\n}\n\ntype FormFieldNames =\n | \"customer_name\"\n | \"customer_email\"\n | \"customer_country\"\n | \"customer_zip_code\"\n | \"customer_business_name\"\n | \"customer_address_line1\"\n | \"customer_address_line2\"\n | \"customer_city\"\n | \"customer_state\"\n | \"customer_tax_ids\"\n | \"shipping_address_line1\"\n | \"shipping_address_line2\"\n | \"shipping_city\"\n | \"shipping_state\"\n | \"shipping_zip_code\"\n | \"shipping_country\";\n\nexport type FormErrorCodes = \"required\" | \"invalid\";\n\nexport type CardSubmitOptions = {\n skipCustomerValidation?: boolean;\n};\n\nexport type TInternalFuncs = {\n submitPayment: (\n fields: PaymentKitFields,\n options?: CardSubmitOptions,\n ) => Promise<{ data: { [key: string]: unknown }; errors?: never } | { data?: never; errors: PaymentKitErrors }>;\n cleanup?: () => void;\n};\n\nexport type PaymentKit = <T extends readonly PaymentMethod<unknown>[]>(options: {\n environment: string;\n secureToken: string;\n paymentMethods: T;\n /** Card tokenization mode from checkout session */\n cardTokenizationMode?: \"direct\" | \"vgs\";\n /** VGS vault ID from checkout session */\n vgsVaultId?: string;\n /** VGS environment from checkout session */\n vgsEnvironment?: string;\n /** @internal Enable analytics test mode for e2e testing */\n __enableAnalyticsTestMode?: boolean;\n}) => ExternalFuncsMapByPm<T> & {\n submit: PaymentKitSubmitHandler<T>;\n cleanup: () => void;\n};\n\ntype PaymentKitSubmitHandler<T extends readonly PaymentMethod<unknown>[]> = <\n N extends keyof ExternalFuncsMapByPm<T>,\n>(options: {\n fields: Partial<PaymentKitFields>;\n paymentMethod: N;\n options?: unknown;\n onError: (error: PaymentKitErrors) => void;\n onSuccess: (data: { [key: string]: unknown }) => void;\n}) => void;\n\nexport type PaymentKitStates = {\n baseUrl: string;\n apiBaseUrl: string;\n secureToken: string;\n environment: string;\n tunnelXConnection: TunnelXIFrameConnection;\n timingTracker: CheckoutTimingTracker;\n /** Checkout request ID for correlating all API calls and analytics events */\n checkoutRequestId: string;\n /** Card tokenization mode: 'direct' (KMS) or 'vgs' (VGS Collect + proxy) */\n cardTokenizationMode?: \"direct\" | \"vgs\";\n /** VGS vault ID (only when cardTokenizationMode is 'vgs') */\n vgsVaultId?: string;\n /** VGS environment: 'sandbox' or 'live' (only when cardTokenizationMode is 'vgs') */\n vgsEnvironment?: string;\n /** @internal Promise that resolves when session config (incl. VGS mode) is auto-detected */\n _sessionConfigReady?: Promise<void>;\n};\n\nexport type PaymentKitErrors = {\n root?: string;\n card_pan?: CardErrorCode;\n card_exp?: CardErrorCode;\n card_cvc?: CardErrorCode;\n paypal?: string;\n google_pay?: string;\n apple_pay?: string;\n processor_id?: string;\n amount?: string;\n currency?: string;\n country?: string;\n} & { [key in FormFieldNames]?: FormErrorCodes | string };\n\nexport type PaymentKitFields = { [key in FormFieldNames]: string };\n\nexport type PaymentMethod<TExternalFuncs = unknown, TName = string> = (paymentKitStates: PaymentKitStates) => {\n name: TName;\n externalFuncs: TExternalFuncs;\n internalFuncs: TInternalFuncs;\n};\n\nexport type ExternalFuncsMapByPm<T extends readonly PaymentMethod<unknown>[]> = {\n [K in T[number] as ReturnType<K>[\"name\"]]: ReturnType<K>[\"externalFuncs\"];\n};\n","import { version as PACKAGE_VERSION } from \"../package.json\";\nimport { AnalyticsService, CheckoutTimingTracker } from \"./analytics\";\nimport { connectToTunnelXIframe } from \"./penpal/connect-tunnel-x\";\nimport type { ExternalFuncsMapByPm, PaymentKitFields, PaymentKit as PaymentKitType } from \"./types\";\nimport { getUrlsForEnvironment } from \"./types\";\nimport { createCheckoutIFrame } from \"./utils\";\nimport { getOrCreateCheckoutRequestId } from \"./utils/checkout-request-id\";\n\ntype PaymentKitReturnType = ReturnType<PaymentKitType>;\n\nconst createTunnelXConnection = (baseUrl: string, apiBaseUrl: string, token: string) => {\n const iframe = createCheckoutIFrame(\"tunnel-x\", baseUrl, {\n checkout_token: token,\n api_base_url: apiBaseUrl,\n });\n // Tunnel-X is a hidden communication iframe, not a visible UI element\n Object.assign(iframe.style, { width: \"0\", height: \"0\", position: \"absolute\", visibility: \"hidden\" });\n document.body.appendChild(iframe);\n\n const connection = connectToTunnelXIframe(iframe, {});\n\n const unmount = () => {\n connection.destroy();\n document.body.removeChild(iframe);\n };\n\n return { unmount, connection };\n};\n\nconst PaymentKit: PaymentKitType = ({\n environment,\n secureToken,\n paymentMethods,\n cardTokenizationMode,\n vgsVaultId,\n vgsEnvironment,\n __enableAnalyticsTestMode,\n}) => {\n type PaymentMethods = typeof paymentMethods;\n\n // Resolve URLs from environment\n const { baseUrl, apiBaseUrl } = getUrlsForEnvironment(environment);\n\n // Log version for debugging\n console.log(`[PaymentKit] v${PACKAGE_VERSION} initialized (env: ${environment})`);\n\n // Generate checkout request ID for correlating all API calls and analytics events\n // This is idempotent - same ID is reused across multiple PaymentKit instantiations\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[PaymentKit] checkout_request_id: ${checkoutRequestId}`);\n\n // Initialize analytics and identify with secure token for correlation\n AnalyticsService.init(apiBaseUrl, __enableAnalyticsTestMode);\n AnalyticsService.identify(secureToken);\n\n // Create timing tracker for this checkout session\n const timingTracker = new CheckoutTimingTracker(secureToken, checkoutRequestId);\n\n // Track page ready immediately\n timingTracker.trackPageReady();\n\n const { connection: tunnelXConnection, unmount: unmountTunnelX } = createTunnelXConnection(\n baseUrl,\n apiBaseUrl,\n secureToken,\n );\n\n const paymentKitStates = {\n baseUrl,\n apiBaseUrl,\n secureToken,\n environment,\n tunnelXConnection,\n timingTracker,\n checkoutRequestId,\n cardTokenizationMode,\n vgsVaultId,\n vgsEnvironment,\n _sessionConfigReady: undefined as Promise<void> | undefined,\n };\n\n // Auto-detect VGS mode from session API if not explicitly provided.\n // The promise resolves before any card mount or submit needs the mode.\n if (cardTokenizationMode === undefined) {\n const sessionConfigUrl = `${apiBaseUrl}/api/checkout-sessions/token/${secureToken}`;\n console.log(\n `[PaymentKit] cardTokenizationMode not provided — auto-detecting from session API: ${sessionConfigUrl}`,\n );\n paymentKitStates._sessionConfigReady = fetch(sessionConfigUrl)\n .then((resp) => {\n if (!resp.ok) {\n console.warn(`[PaymentKit] Session config fetch failed with status ${resp.status}`);\n return null;\n }\n return resp.json();\n })\n .then((session) => {\n if (session && typeof session === \"object\" && typeof session.card_tokenization_mode === \"string\") {\n paymentKitStates.cardTokenizationMode = session.card_tokenization_mode || \"direct\";\n console.log(\n `[PaymentKit] Session config detected — cardTokenizationMode: ${paymentKitStates.cardTokenizationMode}`,\n );\n\n // Validate VGS config from API before trusting it\n const vaultId = session.vgs_vault_id;\n const vgsEnv = session.vgs_environment;\n if (vaultId && /^tnt[a-z0-9]+$/.test(vaultId) && (vgsEnv === \"sandbox\" || vgsEnv === \"live\")) {\n paymentKitStates.vgsVaultId = vaultId;\n paymentKitStates.vgsEnvironment = vgsEnv;\n console.log(`[PaymentKit] VGS config valid — vaultId: ${vaultId}, environment: ${vgsEnv}`);\n } else if (paymentKitStates.cardTokenizationMode === \"vgs\") {\n console.warn(\n `[PaymentKit] Invalid VGS config from session API (vaultId: ${vaultId}, env: ${vgsEnv}), falling back to direct mode`,\n );\n paymentKitStates.cardTokenizationMode = \"direct\";\n }\n } else {\n console.log(\"[PaymentKit] Session response missing card_tokenization_mode — defaulting to direct mode\");\n paymentKitStates.cardTokenizationMode = \"direct\";\n }\n })\n .catch((err) => {\n console.error(\"[PaymentKit] Session config fetch error — falling back to direct mode:\", err);\n paymentKitStates.cardTokenizationMode = \"direct\";\n });\n } else {\n console.log(`[PaymentKit] cardTokenizationMode explicitly set: ${cardTokenizationMode}`);\n }\n\n const pmInstances = paymentMethods.map((paymentMethod) => paymentMethod(paymentKitStates));\n\n const externalFuncsMapByPm: ExternalFuncsMapByPm<PaymentMethods> = pmInstances.reduce(\n (acc, { name, externalFuncs }) => {\n // @ts-expect-error - typecase this better in future\n acc[name] = externalFuncs;\n return acc;\n },\n {} as ExternalFuncsMapByPm<PaymentMethods>,\n );\n\n const submit: PaymentKitReturnType[\"submit\"] = ({\n paymentMethod: paymentMethodName,\n fields,\n options,\n onSuccess,\n onError,\n }) => {\n const paymentMethod = pmInstances.find(({ name }) => name === paymentMethodName);\n if (!paymentMethod) {\n onError({ root: \"payment_method_not_found\" });\n return;\n }\n paymentMethod.internalFuncs\n .submitPayment(fields, options)\n .then(({ data, errors }) => {\n errors ? onError(errors) : onSuccess(data);\n })\n .catch((e) => {\n console.error(\"PaymentKit:submit:catch\", e);\n\n // Try to extract error message from response\n if (e?.response?.data) {\n onError(e.response.data);\n } else if (e?.message) {\n onError({ root: e.message });\n } else {\n onError({ root: \"unknown_error\" });\n }\n });\n };\n\n const cleanup = () => {\n // Clean up all payment method instances\n for (const pm of pmInstances) {\n if (pm.internalFuncs.cleanup) {\n pm.internalFuncs.cleanup();\n }\n }\n unmountTunnelX();\n };\n\n return {\n submit,\n cleanup,\n ...externalFuncsMapByPm,\n };\n};\n\nexport type { PaymentKitFields };\n\nexport default PaymentKit;\n"],"mappings":";;;;;;cAEa;;;;ACUb,MAAMA,0BAA6F;CACjG,OAAO;EACL,SAAS;EACT,YAAY;EACb;CACD,SAAS;EACP,SAAS;EACT,YAAY;EACb;CACD,YAAY;EACV,SAAS;EACT,YAAY;EACb;CACF;AAED,SAAS,gBAAiC;AACxC,KAAI,OAAO,WAAW,aAAa;EAEjC,MAAM,aADS,IAAI,gBAAgB,OAAO,SAAS,OAAO,CAChC,IAAI,eAAe;AAC7C,MAAI,WACF,QAAO;GACL,SAAS,OAAO,SAAS;GACzB;GACD;EAGH,MAAM,WAAW,OAAO,SAAS;AACjC,MAAI,SAAS,SAAS,WAAW,EAAE;GACjC,MAAM,cAAc,SAAS,QAAQ,sBAAsB,MAAM;AACjE,UAAO;IACL,SAAS,WAAW;IACpB,YAAY,WAAW;IACxB;;;AAIL,QAAO,wBAAwB;;AAGjC,SAAgB,sBAAsB,aAAsC;AAC1E,KAAI,gBAAgB,SAClB,QAAO,eAAe;CAGxB,MAAM,OAAO,wBADD;AAEZ,KAAI,CAAC,KACH,OA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AAU,KACf,SAAQ,EAAE,SAAS,KAAK;YACf,GAAG,QACZ,SAAQ,EAAE,MAAM,EAAE,SAAS,CAAC;OAE5B,SAAQ,EAAE,MAAM,iBAAiB,CAAC;IAEpC;;CAGN,MAAM,gBAAgB;AAEpB,OAAK,MAAM,MAAM,YACf,KAAI,GAAG,cAAc,QACnB,IAAG,cAAc,SAAS;AAG9B,kBAAgB;;AAGlB,QAAO;EACL;EACA;EACA,GAAG;EACJ;;AAKH,kBAAe"}
1
+ {"version":3,"file":"index.mjs","names":["STATIC_ENVIRONMENT_URLS: Record<Exclude<PaymentKitEnvironment, \"tunnel\">, EnvironmentUrls>","PaymentKit: PaymentKitType","PACKAGE_VERSION","externalFuncsMapByPm: ExternalFuncsMapByPm<PaymentMethods>","submit: PaymentKitReturnType[\"submit\"]"],"sources":["../package.json","../src/types.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@payment-kit-js/vanilla\",\n \"version\": \"0.5.18\",\n \"main\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": \"./dist/index.mjs\",\n \"./payment-methods/affirm\": \"./dist/payment-methods/affirm.mjs\",\n \"./payment-methods/afterpay\": \"./dist/payment-methods/afterpay.mjs\",\n \"./payment-methods/airwallex-apple-pay-adapter\": \"./dist/payment-methods/airwallex-apple-pay-adapter.mjs\",\n \"./payment-methods/airwallex-google-pay-adapter\": \"./dist/payment-methods/airwallex-google-pay-adapter.mjs\",\n \"./payment-methods/apple-pay\": \"./dist/payment-methods/apple-pay.mjs\",\n \"./payment-methods/bnpl-shared\": \"./dist/payment-methods/bnpl-shared.mjs\",\n \"./payment-methods/card\": \"./dist/payment-methods/card.mjs\",\n \"./payment-methods/google-pay\": \"./dist/payment-methods/google-pay.mjs\",\n \"./payment-methods/klarna\": \"./dist/payment-methods/klarna.mjs\",\n \"./payment-methods/next-action-handlers\": \"./dist/payment-methods/next-action-handlers.mjs\",\n \"./payment-methods/paypal\": \"./dist/payment-methods/paypal.mjs\",\n \"./payment-methods/stripe-apple-pay-adapter\": \"./dist/payment-methods/stripe-apple-pay-adapter.mjs\",\n \"./payment-methods/stripe-google-pay-adapter\": \"./dist/payment-methods/stripe-google-pay-adapter.mjs\",\n \"./payment-methods/vgs-collect-loader\": \"./dist/payment-methods/vgs-collect-loader.mjs\",\n \"./penpal/connect-card\": \"./dist/penpal/connect-card.mjs\",\n \"./penpal/connect-tunnel-x\": \"./dist/penpal/connect-tunnel-x.mjs\",\n \"./package.json\": \"./package.json\"\n },\n \"license\": \"MIT\",\n \"description\": \"Vanilla package for PaymentKit\",\n \"files\": [\n \"dist\",\n \"dist/cdn\"\n ],\n \"scripts\": {\n \"dev\": \"yarn tsdown --watch ./src\",\n \"build:npm\": \"yarn tsdown\",\n \"build:cdn\": \"node build-cdn.mjs\",\n \"build\": \"yarn build:npm && yarn build:cdn\"\n },\n \"packageManager\": \"yarn@4.10.3\",\n \"dependencies\": {\n \"nanoid\": \"^5.0.7\",\n \"penpal\": \"^7.0.4\",\n \"posthog-js\": \"^1.196.0\",\n \"valibot\": \"^1.1.0\"\n },\n \"devDependencies\": {\n \"@pkg/sdk\": \"workspace:*\",\n \"@pkg/tsconfig\": \"workspace:*\",\n \"@stripe/stripe-js\": \"^8.6.1\",\n \"@types/applepayjs\": \"^14.0.9\",\n \"esbuild\": \"^0.24.2\",\n \"tsdown\": \"^0.15.10\",\n \"typescript\": \"^5.9.3\"\n },\n \"stableVersion\": \"0.5.18\"\n}\n","import type { CheckoutTimingTracker } from \"./analytics\";\nimport type { CardErrorCode } from \"./penpal/connect-card\";\nimport type { TunnelXIFrameConnection } from \"./penpal/connect-tunnel-x\";\n\nexport type PaymentKitEnvironment = \"local\" | \"tunnel\" | \"sandbox\" | \"staging\" | \"production\";\n\ntype EnvironmentUrls = {\n baseUrl: string;\n apiBaseUrl: string;\n};\n\n// TODO: Cleanup this after launch to only use SDK instead of plain fetch.\nconst STATIC_ENVIRONMENT_URLS: Record<Exclude<PaymentKitEnvironment, \"tunnel\">, EnvironmentUrls> = {\n local: {\n baseUrl: \"http://localhost:9101\",\n apiBaseUrl: \"http://localhost:9000\",\n },\n sandbox: {\n baseUrl: \"https://app.paymentkit.com/customer\",\n apiBaseUrl: \"https://app.paymentkit.com\",\n },\n staging: {\n baseUrl: \"https://staging.paymentkit.com/customer\",\n apiBaseUrl: \"https://staging.paymentkit.com\",\n },\n production: {\n baseUrl: \"https://app.paymentkit.com/customer\",\n apiBaseUrl: \"https://app.paymentkit.com\",\n },\n};\n\nfunction getTunnelUrls(): EnvironmentUrls {\n if (typeof window !== \"undefined\") {\n const params = new URLSearchParams(window.location.search);\n const apiBaseUrl = params.get(\"api_base_url\");\n if (apiBaseUrl) {\n return {\n baseUrl: window.location.origin,\n apiBaseUrl,\n };\n }\n // For loclx-style tunnels where API hostname is derived from the current hostname\n const hostname = window.location.hostname;\n if (hostname.includes(\"loclx.io\")) {\n const apiHostname = hostname.replace(/cportal|playground/, \"api\");\n return {\n baseUrl: `https://${hostname}`,\n apiBaseUrl: `https://${apiHostname}`,\n };\n }\n }\n // Fallback\n return STATIC_ENVIRONMENT_URLS.local;\n}\n\nexport function getUrlsForEnvironment(environment: PaymentKitEnvironment): EnvironmentUrls {\n if (environment === \"tunnel\") {\n return getTunnelUrls();\n }\n const urls = STATIC_ENVIRONMENT_URLS[environment];\n if (!urls) {\n console.warn(`[PaymentKit] Invalid environment \"${environment}\", falling back to local`);\n return STATIC_ENVIRONMENT_URLS.local;\n }\n return urls;\n}\n\ntype FormFieldNames =\n | \"customer_name\"\n | \"customer_email\"\n | \"customer_country\"\n | \"customer_zip_code\"\n | \"customer_business_name\"\n | \"customer_address_line1\"\n | \"customer_address_line2\"\n | \"customer_city\"\n | \"customer_state\"\n | \"customer_tax_ids\"\n | \"shipping_address_line1\"\n | \"shipping_address_line2\"\n | \"shipping_city\"\n | \"shipping_state\"\n | \"shipping_zip_code\"\n | \"shipping_country\";\n\nexport type FormErrorCodes = \"required\" | \"invalid\";\n\nexport type CardSubmitOptions = {\n skipCustomerValidation?: boolean;\n};\n\nexport type TInternalFuncs = {\n submitPayment: (\n fields: Partial<PaymentKitFields>,\n options?: unknown,\n ) => Promise<{ data: { [key: string]: unknown }; errors?: never } | { data?: never; errors: PaymentKitErrors }>;\n cleanup?: () => void;\n};\n\nexport type PaymentKit = <T extends readonly PaymentMethod<unknown>[]>(options: {\n environment?: PaymentKitEnvironment;\n secureToken: string;\n paymentMethods: T;\n /** Card tokenization mode from checkout session */\n cardTokenizationMode?: \"direct\" | \"vgs\";\n /** VGS vault ID from checkout session */\n vgsVaultId?: string;\n /** VGS environment from checkout session */\n vgsEnvironment?: string;\n /** @internal Enable analytics test mode for e2e testing */\n __enableAnalyticsTestMode?: boolean;\n}) => ExternalFuncsMapByPm<T> & {\n submit: PaymentKitSubmitHandler<T>;\n cleanup: () => void;\n};\n\ntype PaymentKitSubmitHandler<T extends readonly PaymentMethod<unknown>[]> = <\n N extends keyof ExternalFuncsMapByPm<T>,\n>(options: {\n fields: Partial<PaymentKitFields>;\n paymentMethod: N;\n options?: unknown;\n onError: (error: PaymentKitErrors) => void;\n onSuccess: (data: { [key: string]: unknown }) => void;\n}) => void;\n\nexport type PaymentKitStates = {\n baseUrl: string;\n apiBaseUrl: string;\n secureToken: string;\n environment: PaymentKitEnvironment;\n tunnelXConnection: TunnelXIFrameConnection;\n timingTracker: CheckoutTimingTracker;\n /** Checkout request ID for correlating all API calls and analytics events */\n checkoutRequestId: string;\n /** Card tokenization mode: 'direct' (KMS) or 'vgs' (VGS Collect + proxy) */\n cardTokenizationMode?: \"direct\" | \"vgs\";\n /** VGS vault ID (only when cardTokenizationMode is 'vgs') */\n vgsVaultId?: string;\n /** VGS environment: 'sandbox' or 'live' (only when cardTokenizationMode is 'vgs') */\n vgsEnvironment?: string;\n /** @internal Promise that resolves when session config (incl. VGS mode) is auto-detected */\n _sessionConfigReady?: Promise<void>;\n};\n\nexport type PaymentKitErrors = {\n root?: string;\n card_pan?: CardErrorCode;\n card_exp?: CardErrorCode;\n card_cvc?: CardErrorCode;\n paypal?: string;\n google_pay?: string;\n apple_pay?: string;\n processor_id?: string;\n amount?: string;\n currency?: string;\n country?: string;\n} & { [key in FormFieldNames]?: FormErrorCodes | string };\n\nexport type PaymentKitFields = { [key in FormFieldNames]: string };\n\nexport type PaymentMethod<TExternalFuncs = unknown, TName = string> = (paymentKitStates: PaymentKitStates) => {\n name: TName;\n externalFuncs: TExternalFuncs;\n internalFuncs: TInternalFuncs;\n};\n\nexport type ExternalFuncsMapByPm<T extends readonly PaymentMethod<unknown>[]> = {\n [K in T[number] as ReturnType<K>[\"name\"]]: ReturnType<K>[\"externalFuncs\"];\n};\n","import { version as PACKAGE_VERSION } from \"../package.json\";\nimport { AnalyticsService, CheckoutTimingTracker } from \"./analytics\";\nimport { connectToTunnelXIframe } from \"./penpal/connect-tunnel-x\";\nimport type { ExternalFuncsMapByPm, PaymentKitFields, PaymentKit as PaymentKitType } from \"./types\";\nimport { getUrlsForEnvironment } from \"./types\";\nimport { createCheckoutIFrame } from \"./utils\";\nimport { getOrCreateCheckoutRequestId } from \"./utils/checkout-request-id\";\n\ntype PaymentKitReturnType = ReturnType<PaymentKitType>;\n\nconst createTunnelXConnection = (baseUrl: string, apiBaseUrl: string, token: string) => {\n const iframe = createCheckoutIFrame(\"tunnel-x\", baseUrl, {\n checkout_token: token,\n api_base_url: apiBaseUrl,\n });\n // Tunnel-X is a hidden communication iframe, not a visible UI element\n Object.assign(iframe.style, { width: \"0\", height: \"0\", position: \"absolute\", visibility: \"hidden\" });\n document.body.appendChild(iframe);\n\n const connection = connectToTunnelXIframe(iframe, {});\n\n const unmount = () => {\n connection.destroy();\n document.body.removeChild(iframe);\n };\n\n return { unmount, connection };\n};\n\nconst PaymentKit: PaymentKitType = ({\n environment = \"production\",\n secureToken,\n paymentMethods,\n cardTokenizationMode,\n vgsVaultId,\n vgsEnvironment,\n __enableAnalyticsTestMode,\n}) => {\n type PaymentMethods = typeof paymentMethods;\n\n // Resolve URLs from environment\n const { baseUrl, apiBaseUrl } = getUrlsForEnvironment(environment);\n\n // Log version for debugging\n console.log(`[PaymentKit] v${PACKAGE_VERSION} initialized (env: ${environment})`);\n\n // Generate checkout request ID for correlating all API calls and analytics events\n // This is idempotent - same ID is reused across multiple PaymentKit instantiations\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[PaymentKit] checkout_request_id: ${checkoutRequestId}`);\n\n // Initialize analytics and identify with secure token for correlation\n AnalyticsService.init(apiBaseUrl, __enableAnalyticsTestMode);\n AnalyticsService.identify(secureToken);\n\n // Create timing tracker for this checkout session\n const timingTracker = new CheckoutTimingTracker(secureToken, checkoutRequestId);\n\n // Track page ready immediately\n timingTracker.trackPageReady();\n\n const { connection: tunnelXConnection, unmount: unmountTunnelX } = createTunnelXConnection(\n baseUrl,\n apiBaseUrl,\n secureToken,\n );\n\n const paymentKitStates = {\n baseUrl,\n apiBaseUrl,\n secureToken,\n environment,\n tunnelXConnection,\n timingTracker,\n checkoutRequestId,\n cardTokenizationMode,\n vgsVaultId,\n vgsEnvironment,\n _sessionConfigReady: undefined as Promise<void> | undefined,\n };\n\n // Auto-detect VGS mode from session API if not explicitly provided.\n // The promise resolves before any card mount or submit needs the mode.\n if (cardTokenizationMode === undefined) {\n const sessionConfigUrl = `${apiBaseUrl}/api/checkout-sessions/token/${secureToken}`;\n console.log(\n `[PaymentKit] cardTokenizationMode not provided — auto-detecting from session API: ${sessionConfigUrl}`,\n );\n paymentKitStates._sessionConfigReady = fetch(sessionConfigUrl)\n .then((resp) => {\n if (!resp.ok) {\n console.warn(`[PaymentKit] Session config fetch failed with status ${resp.status}`);\n return null;\n }\n return resp.json();\n })\n .then((session) => {\n if (session && typeof session === \"object\" && typeof session.card_tokenization_mode === \"string\") {\n paymentKitStates.cardTokenizationMode = session.card_tokenization_mode || \"direct\";\n console.log(\n `[PaymentKit] Session config detected — cardTokenizationMode: ${paymentKitStates.cardTokenizationMode}`,\n );\n\n // Validate VGS config from API before trusting it\n const vaultId = session.vgs_vault_id;\n const vgsEnv = session.vgs_environment;\n if (vaultId && /^tnt[a-z0-9]+$/.test(vaultId) && (vgsEnv === \"sandbox\" || vgsEnv === \"live\")) {\n paymentKitStates.vgsVaultId = vaultId;\n paymentKitStates.vgsEnvironment = vgsEnv;\n console.log(`[PaymentKit] VGS config valid — vaultId: ${vaultId}, environment: ${vgsEnv}`);\n } else if (paymentKitStates.cardTokenizationMode === \"vgs\") {\n console.warn(\n `[PaymentKit] Invalid VGS config from session API (vaultId: ${vaultId}, env: ${vgsEnv}), falling back to direct mode`,\n );\n paymentKitStates.cardTokenizationMode = \"direct\";\n }\n } else {\n console.log(\"[PaymentKit] Session response missing card_tokenization_mode — defaulting to direct mode\");\n paymentKitStates.cardTokenizationMode = \"direct\";\n }\n })\n .catch((err) => {\n console.error(\"[PaymentKit] Session config fetch error — falling back to direct mode:\", err);\n paymentKitStates.cardTokenizationMode = \"direct\";\n });\n } else {\n console.log(`[PaymentKit] cardTokenizationMode explicitly set: ${cardTokenizationMode}`);\n }\n\n const pmInstances = paymentMethods.map((paymentMethod) => paymentMethod(paymentKitStates));\n\n const externalFuncsMapByPm: ExternalFuncsMapByPm<PaymentMethods> = pmInstances.reduce(\n (acc, { name, externalFuncs }) => {\n // @ts-expect-error - typecase this better in future\n acc[name] = externalFuncs;\n return acc;\n },\n {} as ExternalFuncsMapByPm<PaymentMethods>,\n );\n\n const submit: PaymentKitReturnType[\"submit\"] = ({\n paymentMethod: paymentMethodName,\n fields,\n options,\n onSuccess,\n onError,\n }) => {\n const paymentMethod = pmInstances.find(({ name }) => name === paymentMethodName);\n if (!paymentMethod) {\n onError({ root: \"payment_method_not_found\" });\n return;\n }\n paymentMethod.internalFuncs\n .submitPayment(fields, options)\n .then(({ data, errors }) => {\n errors ? onError(errors) : onSuccess(data);\n })\n .catch((e) => {\n console.error(\"PaymentKit:submit:catch\", e);\n\n // Try to extract error message from response\n if (e?.response?.data) {\n onError(e.response.data);\n } else if (e?.message) {\n onError({ root: e.message });\n } else {\n onError({ root: \"unknown_error\" });\n }\n });\n };\n\n const cleanup = () => {\n // Clean up all payment method instances\n for (const pm of pmInstances) {\n if (pm.internalFuncs.cleanup) {\n pm.internalFuncs.cleanup();\n }\n }\n unmountTunnelX();\n };\n\n return {\n submit,\n cleanup,\n ...externalFuncsMapByPm,\n };\n};\n\nexport type { PaymentKitEnvironment, PaymentKitFields } from \"./types\";\n\nexport default PaymentKit;\n"],"mappings":";;;;;;cAEa;;;;ACUb,MAAMA,0BAA6F;CACjG,OAAO;EACL,SAAS;EACT,YAAY;EACb;CACD,SAAS;EACP,SAAS;EACT,YAAY;EACb;CACD,SAAS;EACP,SAAS;EACT,YAAY;EACb;CACD,YAAY;EACV,SAAS;EACT,YAAY;EACb;CACF;AAED,SAAS,gBAAiC;AACxC,KAAI,OAAO,WAAW,aAAa;EAEjC,MAAM,aADS,IAAI,gBAAgB,OAAO,SAAS,OAAO,CAChC,IAAI,eAAe;AAC7C,MAAI,WACF,QAAO;GACL,SAAS,OAAO,SAAS;GACzB;GACD;EAGH,MAAM,WAAW,OAAO,SAAS;AACjC,MAAI,SAAS,SAAS,WAAW,EAAE;GACjC,MAAM,cAAc,SAAS,QAAQ,sBAAsB,MAAM;AACjE,UAAO;IACL,SAAS,WAAW;IACpB,YAAY,WAAW;IACxB;;;AAIL,QAAO,wBAAwB;;AAGjC,SAAgB,sBAAsB,aAAqD;AACzF,KAAI,gBAAgB,SAClB,QAAO,eAAe;CAExB,MAAM,OAAO,wBAAwB;AACrC,KAAI,CAAC,MAAM;AACT,UAAQ,KAAK,qCAAqC,YAAY,0BAA0B;AACxF,SAAO,wBAAwB;;AAEjC,QAAO;;;;;ACtDT,MAAM,2BAA2B,SAAiB,YAAoB,UAAkB;CACtF,MAAM,SAAS,qBAAqB,YAAY,SAAS;EACvD,gBAAgB;EAChB,cAAc;EACf,CAAC;AAEF,QAAO,OAAO,O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,KAAI,GAAG,cAAc,QACnB,IAAG,cAAc,SAAS;AAG9B,kBAAgB;;AAGlB,QAAO;EACL;EACA;EACA,GAAG;EACJ;;AAKH,kBAAe"}
@@ -71,21 +71,21 @@ function show3DSIframeModal(options) {
71
71
  closeButton.setAttribute("aria-label", "Cancel verification");
72
72
  closeButton.setAttribute("type", "button");
73
73
  closeButton.style.cssText = `
74
- position: absolute;
75
- top: -40px;
76
- right: 0;
77
- width: 32px;
78
- height: 32px;
79
- border: none;
80
- background: white;
81
- border-radius: 8px;
82
- cursor: pointer;
83
- display: flex;
84
- align-items: center;
85
- justify-content: center;
86
- z-index: 10;
87
- transition: background 0.15s ease;
88
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
74
+ position: absolute !important;
75
+ top: 8px !important;
76
+ right: 8px !important;
77
+ width: 32px !important;
78
+ height: 32px !important;
79
+ border: none !important;
80
+ background: white !important;
81
+ border-radius: 8px !important;
82
+ cursor: pointer !important;
83
+ display: flex !important;
84
+ align-items: center !important;
85
+ justify-content: center !important;
86
+ z-index: 10 !important;
87
+ transition: background 0.15s ease !important;
88
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
89
89
  `;
90
90
  closeButton.innerHTML = `
91
91
  <svg width="12" height="12" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -93,10 +93,10 @@ function show3DSIframeModal(options) {
93
93
  </svg>
94
94
  `;
95
95
  closeButton.onmouseenter = () => {
96
- closeButton.style.background = "#f5f5f5";
96
+ closeButton.style.setProperty("background", "#f5f5f5", "important");
97
97
  };
98
98
  closeButton.onmouseleave = () => {
99
- closeButton.style.background = "white";
99
+ closeButton.style.setProperty("background", "white", "important");
100
100
  };
101
101
  const iframe = document.createElement("iframe");
102
102
  iframe.src = url;
@@ -268,4 +268,4 @@ const handleNextAction = async (nextAction) => {
268
268
 
269
269
  //#endregion
270
270
  export { handleNextAction as t };
271
- //# sourceMappingURL=next-action-handlers-CLOt1wzO.mjs.map
271
+ //# sourceMappingURL=next-action-handlers-BZ5gynXe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-action-handlers-BZ5gynXe.mjs","names":[],"sources":["../src/utils/3ds-iframe-modal.ts","../src/payment-methods/next-action-handlers.ts"],"sourcesContent":["/**\n * 3DS iframe modal for displaying authentication pages.\n *\n * This module provides an iframe modal used by payment processors\n * that need to display a 3DS authentication page.\n */\n\ntype IframeModalResult = { success: true; data: Record<string, unknown> } | { success: false; error: string };\n\ntype ThreeDSCompleteMessage = {\n type: \"3ds_complete\";\n processor: string | null;\n isSuccess: boolean;\n error?: string;\n};\n\ntype IframeModalMessageHandler = (\n event: MessageEvent<ThreeDSCompleteMessage>,\n) => { handled: true; result: IframeModalResult } | { handled: false };\n\ninterface IframeModalOptions {\n /** URL to load in the iframe */\n url: string;\n /** Size of the iframe in pixels */\n size: { width: number; height: number };\n /** Border radius for the iframe in pixels (default: 16) */\n radius?: number;\n /** Handler to process postMessage events from the iframe */\n onMessage: IframeModalMessageHandler;\n}\n\n/**\n * Shows an iframe modal and waits for a result via postMessage.\n *\n * Features:\n * - Close/cancel button positioned outside the iframe\n * - Responsive design (works on mobile)\n * - Keyboard accessibility (Escape to close, focus trap)\n * - Fade-in/fade-out animations\n * - Iframe load error handling\n *\n * @param options - Modal configuration options\n * @returns Promise that resolves with success/failure result\n *\n * @example\n * ```ts\n * const result = await show3DSIframeModal({\n * url: \"https://bank.com/3ds-auth\",\n * size: { width: 605, height: 500 },\n * radius: 6,\n * onMessage: (event) => {\n * if (event.data?.type === \"auth_complete\") {\n * return {\n * handled: true,\n * result: event.data.succeeded\n * ? { success: true, data: { id: event.data.id } }\n * : { success: false, error: event.data.error }\n * };\n * }\n * return { handled: false };\n * },\n * });\n * ```\n */\n\nexport default function show3DSIframeModal(options: IframeModalOptions): Promise<IframeModalResult> {\n const { url, size, radius = 6, onMessage } = options;\n\n return new Promise((resolve) => {\n let resolved = false;\n\n // Create modal overlay with fade-in animation\n const overlay = document.createElement(\"div\");\n overlay.id = \"pk-iframe-modal-overlay\";\n overlay.setAttribute(\"role\", \"dialog\");\n overlay.setAttribute(\"aria-modal\", \"true\");\n overlay.setAttribute(\"aria-label\", \"3D Secure Verification\");\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n `;\n\n // Create container for iframe and close button\n const container = document.createElement(\"div\");\n container.style.cssText = `\n position: relative;\n width: ${size.width}px;\n height: ${size.height}px;\n max-width: calc(100vw - 32px);\n max-height: calc(100vh - 64px);\n overflow: visible;\n opacity: 0;\n transform: scale(0.95) translateY(10px);\n transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n `;\n\n // Create close button (positioned inside top-right of container)\n // Uses !important to prevent merchant CSS from hiding/repositioning the button\n const closeButton = document.createElement(\"button\");\n closeButton.id = \"pk-iframe-modal-close\";\n closeButton.setAttribute(\"aria-label\", \"Cancel verification\");\n closeButton.setAttribute(\"type\", \"button\");\n closeButton.style.cssText = `\n position: absolute !important;\n top: 8px !important;\n right: 8px !important;\n width: 32px !important;\n height: 32px !important;\n border: none !important;\n background: white !important;\n border-radius: 8px !important;\n cursor: pointer !important;\n display: flex !important;\n align-items: center !important;\n justify-content: center !important;\n z-index: 10 !important;\n transition: background 0.15s ease !important;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;\n `;\n closeButton.innerHTML = `\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 14 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M1 1L13 13M1 13L13 1\" stroke=\"#666\" stroke-width=\"2\" stroke-linecap=\"round\"/>\n </svg>\n `;\n closeButton.onmouseenter = (): void => {\n closeButton.style.setProperty(\"background\", \"#f5f5f5\", \"important\");\n };\n closeButton.onmouseleave = (): void => {\n closeButton.style.setProperty(\"background\", \"white\", \"important\");\n };\n\n // Create iframe (hidden initially until loaded)\n const iframe = document.createElement(\"iframe\");\n iframe.src = url;\n iframe.setAttribute(\"title\", \"3D Secure Verification\");\n iframe.style.cssText = `\n width: 100%;\n height: 100%;\n border: none;\n opacity: 0;\n border-radius: ${radius}px;\n background: white;\n transition: opacity 0.2s ease;\n position: relative;\n z-index: 1;\n `;\n\n // Handle iframe load success\n iframe.onload = (): void => {\n iframe.style.opacity = \"1\";\n };\n\n // Handle iframe load error\n iframe.onerror = (): void => {\n if (!resolved) {\n console.error(\"[IframeModal] Failed to load iframe\");\n cleanupWithAnimation();\n resolve({ success: false, error: \"Failed to load verification page. Please try again.\" });\n }\n };\n\n container.appendChild(closeButton);\n container.appendChild(iframe);\n overlay.appendChild(container);\n document.body.appendChild(overlay);\n\n // Trigger fade-in animation\n requestAnimationFrame(() => {\n overlay.style.background = \"rgba(0, 0, 0, 0.5)\";\n container.style.opacity = \"1\";\n container.style.transform = \"scale(1) translateY(0)\";\n });\n\n // Cleanup with fade-out animation\n const cleanupWithAnimation = (): void => {\n if (resolved) return;\n resolved = true;\n\n window.removeEventListener(\"message\", handleMessage);\n window.removeEventListener(\"keydown\", handleKeydown);\n\n // Use requestAnimationFrame to ensure transition is applied\n requestAnimationFrame(() => {\n overlay.style.background = \"rgba(0, 0, 0, 0)\";\n container.style.opacity = \"0\";\n container.style.transform = \"scale(0.95) translateY(10px)\";\n\n setTimeout(() => {\n if (overlay.parentNode) {\n overlay.parentNode.removeChild(overlay);\n }\n }, 250);\n });\n };\n\n // Handle close button click\n const handleCancel = (): void => {\n if (!resolved) {\n console.log(\"[IframeModal] User cancelled\");\n cleanupWithAnimation();\n resolve({ success: false, error: \"Verification cancelled\" });\n }\n };\n\n closeButton.onclick = handleCancel;\n\n // Handle Escape key\n const handleKeydown = (event: KeyboardEvent): void => {\n if (event.key === \"Escape\") {\n handleCancel();\n }\n // Trap focus within modal (Tab key cycles through close button and iframe)\n if (event.key === \"Tab\") {\n event.preventDefault();\n if (document.activeElement === closeButton) {\n iframe.focus();\n } else {\n closeButton.focus();\n }\n }\n };\n\n window.addEventListener(\"keydown\", handleKeydown);\n\n // Set initial focus to close button for accessibility\n closeButton.focus();\n\n const handleMessage = (event: MessageEvent): void => {\n const messageResult = onMessage(event);\n if (messageResult.handled) {\n cleanupWithAnimation();\n resolve(messageResult.result);\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n });\n}\n","/**\n * Next action handlers for processor-specific user actions (e.g., 3DS authentication).\n *\n * This module abstracts processor-specific logic away from the generic card payment flow.\n * Each handler implements the logic needed for a specific next action type.\n */\n\nimport type { PublicCardCheckoutResponse } from \"@pkg/sdk/models\";\nimport type { Stripe } from \"@stripe/stripe-js\";\nimport show3DSIframeModal from \"../utils/3ds-iframe-modal\";\n\n// Helper to wait for a condition\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n// Check if Stripe.js is loaded via script tag\nconst isStripeJsPresent = (): boolean => \"Stripe\" in window;\n\n/**\n * Get the Stripe instance from the global window object.\n * Expects Stripe.js to be loaded via HTML script tag.\n * Polls for up to 5 seconds waiting for Stripe to be available.\n */\nconst getLoadedStripe = async (publishableKey: string): Promise<Stripe> => {\n // Poll for Stripe.js to be loaded (up to 5 seconds)\n for (let i = 0; i < 10; i++) {\n if (isStripeJsPresent()) {\n break;\n }\n await sleep(500);\n }\n\n if (!isStripeJsPresent()) {\n throw new Error(\n \"Stripe.js not loaded. Add this script tag to your HTML <head>:\\n\" +\n '<script src=\"https://js.stripe.com/v3/\"></script>',\n );\n }\n\n // @ts-expect-error Stripe is loaded globally via script tag\n const stripe: Stripe = new window.Stripe(publishableKey);\n return stripe;\n};\n\n/**\n * Result of handling a next action.\n */\nexport type NextActionResult = { success: true } | { success: false; error: string };\n\n/**\n * Handle Stripe 3DS authentication.\n */\nconst handleStripe3ds = async (\n nextAction: Extract<PublicCardCheckoutResponse[\"nextAction\"], { type: \"stripe_3ds\" }>,\n): Promise<NextActionResult> => {\n const { clientSecret, stripePk } = nextAction;\n\n const stripe = await getLoadedStripe(stripePk);\n\n // Show 3DS modal\n const { error: stripeError } = await stripe.confirmCardPayment(clientSecret);\n\n if (stripeError) {\n console.error(\"[3DS:Stripe] Authentication failed:\", stripeError.message);\n return { success: false, error: stripeError.message || \"3DS authentication failed\" };\n }\n\n return { success: true };\n};\n\n/**\n * Handle Airwallex 3DS authentication via iframe.\n *\n * Renders an iframe with the 3DS authentication URL. The iframe will redirect\n * to the 3DS callback page which sends a postMessage back to complete the flow.\n */\nconst handleAirwallex3ds = async (\n nextAction: Extract<PublicCardCheckoutResponse[\"nextAction\"], { type: \"airwallex_3ds\" }>,\n): Promise<NextActionResult> => {\n return show3DSIframeModal({\n url: nextAction.url,\n size: { width: 605, height: 550 },\n onMessage: (event) => {\n if (event.data.type !== \"3ds_complete\") {\n return { handled: false };\n }\n\n const { isSuccess, error } = event.data;\n\n if (isSuccess) {\n return { handled: true, result: { success: true, data: {} } };\n } else {\n console.error(\"[3DS:Airwallex] Authentication failed:\", error);\n return {\n handled: true,\n result: { success: false, error: error || \"3DS authentication failed\" },\n };\n }\n },\n });\n};\n\n/**\n * Handle a next action based on its type.\n * Routes to the appropriate processor-specific handler.\n *\n * @param nextAction - The next action from the checkout response\n * @returns Result indicating success or failure with error message\n */\nexport const handleNextAction = async (\n nextAction: NonNullable<PublicCardCheckoutResponse[\"nextAction\"]>,\n): Promise<NextActionResult> => {\n switch (nextAction.type) {\n case \"stripe_3ds\":\n return handleStripe3ds(nextAction);\n case \"airwallex_3ds\":\n return handleAirwallex3ds(nextAction);\n default:\n // TypeScript will catch if we miss a case when new action types are added\n return { success: false, error: `Unknown next action type: ${(nextAction as { type: string }).type}` };\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAwB,mBAAmB,SAAyD;CAClG,MAAM,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ACtB,eAC8B;CAC9B,MAAM,EAAE,cAAc,aAAa;CAKnC,MAAM,EAAE,OAAO,gBAAgB,OAHhB,MAAM,gBAAgB,SAAS,EAGF,mBAAmB,aAAa;AAE5E,KAAI,aAAa;AACf,UAAQ,MAAM,uCAAuC,YAAY,QAAQ;AACzE,SAAO;GAAE,SAAS;GAAO,OAAO,YAAY,WAAW;GAA6B;;AAGtF,QAAO,EAAE,SAAS,MAAM;;;;;;;;AAS1B,MAAM,qBAAqB,OACzB,eAC8B;AAC9B,QAAO,mBAAmB;EACxB,KAAK,WAAW;EAChB,MAAM;GAAE,OAAO;GAAK,QAAQ;GAAK;EACjC,YAAY,UAAU;AACpB,OAAI,MAAM,KAAK,SAAS,eACtB,QAAO,EAAE,SAAS,OAAO;GAG3B,MAAM,EAAE,WAAW,UAAU,MAAM;AAEnC,OAAI,UACF,QAAO;IAAE,SAAS;IAAM,QAAQ;KAAE,SAAS;KAAM,MAAM,EAAE;KAAE;IAAE;QACxD;AACL,YAAQ,MAAM,0CAA0C,MAAM;AAC9D,WAAO;KACL,SAAS;KACT,QAAQ;MAAE,SAAS;MAAO,OAAO,SAAS;MAA6B;KACxE;;;EAGN,CAAC;;;;;;;;;AAUJ,MAAa,mBAAmB,OAC9B,eAC8B;AAC9B,SAAQ,WAAW,MAAnB;EACE,KAAK,aACH,QAAO,gBAAgB,WAAW;EACpC,KAAK,gBACH,QAAO,mBAAmB,WAAW;EACvC,QAEE,QAAO;GAAE,SAAS;GAAO,OAAO,6BAA8B,WAAgC;GAAQ"}
@@ -1,7 +1,7 @@
1
- import { r as PaymentMethod } from "../types-B3mjYfOm.mjs";
1
+ import { i as PaymentMethod } from "../types-Cjcc3xak.mjs";
2
2
  import "../connect-card-CZhzK_Tp.mjs";
3
3
  import "../connect-tunnel-x-BKtMfoGh.mjs";
4
- import { n as BnplCustomerInfo, s as BnplSubmitOptions, t as BnplCheckoutResponse } from "../bnpl-shared-BQwCBD45.mjs";
4
+ import { n as BnplCustomerInfo, s as BnplSubmitOptions, t as BnplCheckoutResponse } from "../bnpl-shared-D-Kd58Qz.mjs";
5
5
 
6
6
  //#region src/payment-methods/affirm.d.ts
7
7
  type AffirmCustomerInfo = BnplCustomerInfo;
@@ -1,5 +1,5 @@
1
- import "../utils-Dc6zwOe1.mjs";
2
- import { t as createBnplPaymentMethod } from "../bnpl-shared-DGs1YzS9.mjs";
1
+ import "../utils-DIqrx4XF.mjs";
2
+ import { t as createBnplPaymentMethod } from "../bnpl-shared-CL900HFN.mjs";
3
3
 
4
4
  //#region src/payment-methods/affirm.ts
5
5
  const AffirmPaymentMethod = createBnplPaymentMethod({
@@ -1,7 +1,7 @@
1
- import { r as PaymentMethod } from "../types-B3mjYfOm.mjs";
1
+ import { i as PaymentMethod } from "../types-Cjcc3xak.mjs";
2
2
  import "../connect-card-CZhzK_Tp.mjs";
3
3
  import "../connect-tunnel-x-BKtMfoGh.mjs";
4
- import { n as BnplCustomerInfo, s as BnplSubmitOptions, t as BnplCheckoutResponse } from "../bnpl-shared-BQwCBD45.mjs";
4
+ import { n as BnplCustomerInfo, s as BnplSubmitOptions, t as BnplCheckoutResponse } from "../bnpl-shared-D-Kd58Qz.mjs";
5
5
 
6
6
  //#region src/payment-methods/afterpay.d.ts
7
7
  type AfterpayCustomerInfo = BnplCustomerInfo;
@@ -1,5 +1,5 @@
1
- import "../utils-Dc6zwOe1.mjs";
2
- import { t as createBnplPaymentMethod } from "../bnpl-shared-DGs1YzS9.mjs";
1
+ import "../utils-DIqrx4XF.mjs";
2
+ import { t as createBnplPaymentMethod } from "../bnpl-shared-CL900HFN.mjs";
3
3
 
4
4
  //#region src/payment-methods/afterpay.ts
5
5
  const AfterpayPaymentMethod = createBnplPaymentMethod({
@@ -1,4 +1,4 @@
1
- import { r as PaymentMethod } from "../types-B3mjYfOm.mjs";
1
+ import { i as PaymentMethod, n as PaymentKitEnvironment } from "../types-Cjcc3xak.mjs";
2
2
  import "../connect-card-CZhzK_Tp.mjs";
3
3
  import "../connect-tunnel-x-BKtMfoGh.mjs";
4
4
  import { a as ApplePayEncryptedToken } from "../airwallex-apple-pay-adapter-CnnZ7VL6.mjs";
@@ -104,7 +104,7 @@ type ApplePaySubmitOptions = {
104
104
  * @deprecated The SDK now calls this automatically on init. Use `onApplePayReady` to observe
105
105
  * readiness and `notifyAmountChanged` to trigger re-prepare after amount changes.
106
106
  */
107
- declare function prepareApplePay(apiBaseUrl: string, secureToken: string, options: ApplePaySubmitOptions, environment: string): Promise<{
107
+ declare function prepareApplePay(apiBaseUrl: string, secureToken: string, options: ApplePaySubmitOptions, environment: PaymentKitEnvironment): Promise<{
108
108
  success: boolean;
109
109
  error?: string;
110
110
  applePay?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"apple-pay.d.mts","names":[],"sources":["../../src/payment-methods/apple-pay.ts"],"sourcesContent":[],"mappings":";;;;;;;KAYY,oBAAA;;;;;AAAA,KAMA,oBAAA,GANoB;EAMpB,YAAA,EAAA,MAAA;EAiBA,aAAA,CAAA,EAZM,oBAYe;EAerB,cAAA,CAAA,EAAA;IAKA,SAAA,CAAA,EAAA,MAAA;IAuBA,WAAA,CAAA,EAAA;MAsBA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAqB;IAsQX,CAAA;IAkIN,kBAAkB,CAAA,EAAA;MAOlB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAqB;IA0f/B,CAAA;EA4G2B,CAAA;EAAqB,aAAA,CAAA,EAAA,MAAA;EA2BvB,cAAA,CAAA,EAAA,MAAA;EAAO,kBAAA,CAAA,EAAA,MAAA;CAvIX;KA18Bf,qBAAA;;;;;;;;;;KAeA,sBAAA;;;;KAKA,sBAAA;;kBAKM;;;;;;;;;;;oBASE;;;;;;;;KASR,uBAAA;;;;;;;;gBAQI;;;;;;;;;;;;;KAcJ,qBAAA;;;;gBAII;iBACC;;;;;;;;;;;;;;;;;iBAiQK,eAAA,mDAGX,6CAER;;;;;;;;iBA6Ha,kBAAA,CAAA;;;;iBAOA,qBAAA,CAAA;cA0fV,uBAuIgC;;;;;6BA3BL,0BAAqB;;;;;;;;;;;;;;;;;;;;;;;;6BA2BvB"}
1
+ {"version":3,"file":"apple-pay.d.mts","names":[],"sources":["../../src/payment-methods/apple-pay.ts"],"sourcesContent":[],"mappings":";;;;;;;KAYY,oBAAA;;;;AAAZ,CAAA;AAMY,KAAA,oBAAA,GAAoB;EAiBpB,YAAA,EAAA,MAAA;EAeA,aAAA,CAAA,EA3BM,oBA2BgB;EAKtB,cAAA,CAAA,EAAA;IAuBA,SAAA,CAAA,EAAA,MAAA;IAsBA,WAAA,CAAA,EAAA;MAsQU,CAAA,GAAA,EAAA,MAAe,CAAA,EAAA,OAAA;IAG1B,CAAA;IACI,kBAAA,CAAA,EAAA;MACZ,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;IAAO,CAAA;EAwHM,CAAA;EAOA,aAAA,CAAA,EAAA,MAAA;EAqfV,cAAA,CAAA,EAAA,MAAA;EA6G2B,kBAAA,CAAA,EAAA,MAAA;CAAqB;AA2BvB,KAxkCnB,qBAAA,GAwkCmB;EAAO,MAAA,EAAA,MAAA;EAxIX,QAAA,EAAA,MAAA;;;;;;;;KAj7Bf,sBAAA;;;;KAKA,sBAAA;;kBAKM;;;;;;;;;;;oBASE;;;;;;;;KASR,uBAAA;;;;;;;;gBAQI;;;;;;;;;;;;;KAcJ,qBAAA;;;;gBAII;iBACC;;;;;;;;;;;;;;;;;iBAiQK,eAAA,mDAGX,oCACI,wBACZ;;;;;;;;iBAwHa,kBAAA,CAAA;;;;iBAOA,qBAAA,CAAA;cAqfV,uBAwIgC;;;;;6BA3BL,0BAAqB;;;;;;;;;;;;;;;;;;;;;;;;6BA2BvB"}
@@ -1,6 +1,6 @@
1
- import { i as definePaymentMethod, n as collectFraudMetadata, o as getOrCreateCheckoutRequestId } from "../utils-Dc6zwOe1.mjs";
1
+ import { i as definePaymentMethod, n as collectFraudMetadata, o as getOrCreateCheckoutRequestId } from "../utils-DIqrx4XF.mjs";
2
2
  import { n as AirwallexApplePayMockScenario, t as AirwallexApplePayAdapter } from "../airwallex-apple-pay-adapter-CPz54c9e.mjs";
3
- import { t as handleNextAction } from "../next-action-handlers-CLOt1wzO.mjs";
3
+ import { t as handleNextAction } from "../next-action-handlers-BZ5gynXe.mjs";
4
4
  import { n as StripeApplePayAdapter, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-7rF6xRIG.mjs";
5
5
 
6
6
  //#region src/payment-methods/apple-pay.ts