@payment-kit-js/vanilla 0.3.0 → 0.4.1

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 (67) hide show
  1. package/dist/airwallex-google-pay-adapter-BCmTZip5.mjs +167 -0
  2. package/dist/airwallex-google-pay-adapter-BCmTZip5.mjs.map +1 -0
  3. package/dist/airwallex-google-pay-adapter-Be2Af4N9.d.mts +140 -0
  4. package/dist/airwallex-google-pay-adapter-Be2Af4N9.d.mts.map +1 -0
  5. package/dist/cdn/paymentkit.js +5768 -83
  6. package/dist/cdn/paymentkit.js.map +4 -4
  7. package/dist/cdn/paymentkit.min.js +58 -3
  8. package/dist/cdn/paymentkit.min.js.map +4 -4
  9. package/dist/{connect-card-DO2EJxu6.mjs → connect-card-BrtCmsjz.mjs} +1 -1
  10. package/dist/{connect-card-DO2EJxu6.mjs.map → connect-card-BrtCmsjz.mjs.map} +1 -1
  11. package/dist/{connect-card-C582hcWw.d.mts → connect-card-DTfXuTsW.d.mts} +1 -1
  12. package/dist/{connect-card-C582hcWw.d.mts.map → connect-card-DTfXuTsW.d.mts.map} +1 -1
  13. package/dist/connect-tunnel-x-BhVAej5Q.mjs.map +1 -1
  14. package/dist/{connect-tunnel-x-B7iMQ7DX.d.mts → connect-tunnel-x-Dxcg5Y7Y.d.mts} +6 -5
  15. package/dist/connect-tunnel-x-Dxcg5Y7Y.d.mts.map +1 -0
  16. package/dist/index.d.mts +3 -3
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +337 -5
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/next-action-handlers-BZs04hYb.mjs +271 -0
  21. package/dist/next-action-handlers-BZs04hYb.mjs.map +1 -0
  22. package/dist/payment-methods/airwallex-google-pay-adapter.d.mts +2 -0
  23. package/dist/payment-methods/airwallex-google-pay-adapter.mjs +3 -0
  24. package/dist/payment-methods/apple-pay.d.mts +78 -0
  25. package/dist/payment-methods/apple-pay.d.mts.map +1 -0
  26. package/dist/payment-methods/apple-pay.mjs +188 -0
  27. package/dist/payment-methods/apple-pay.mjs.map +1 -0
  28. package/dist/payment-methods/card.d.mts +3 -3
  29. package/dist/payment-methods/card.d.mts.map +1 -1
  30. package/dist/payment-methods/card.mjs +40 -12
  31. package/dist/payment-methods/card.mjs.map +1 -1
  32. package/dist/payment-methods/google-pay.d.mts +25 -7
  33. package/dist/payment-methods/google-pay.d.mts.map +1 -1
  34. package/dist/payment-methods/google-pay.mjs +165 -30
  35. package/dist/payment-methods/google-pay.mjs.map +1 -1
  36. package/dist/payment-methods/next-action-handlers.d.mts.map +1 -1
  37. package/dist/payment-methods/next-action-handlers.mjs +1 -1
  38. package/dist/payment-methods/paypal.d.mts +3 -3
  39. package/dist/payment-methods/paypal.d.mts.map +1 -1
  40. package/dist/payment-methods/paypal.mjs +8 -3
  41. package/dist/payment-methods/paypal.mjs.map +1 -1
  42. package/dist/payment-methods/stripe-apple-pay-adapter.d.mts +2 -0
  43. package/dist/payment-methods/stripe-apple-pay-adapter.mjs +3 -0
  44. package/dist/payment-methods/stripe-google-pay-adapter.d.mts +1 -1
  45. package/dist/payment-methods/stripe-google-pay-adapter.mjs +1 -1
  46. package/dist/penpal/connect-card.d.mts +1 -1
  47. package/dist/penpal/connect-card.mjs +1 -1
  48. package/dist/penpal/connect-tunnel-x.d.mts +1 -1
  49. package/dist/stripe-apple-pay-adapter-Bg7nCy3P.mjs +313 -0
  50. package/dist/stripe-apple-pay-adapter-Bg7nCy3P.mjs.map +1 -0
  51. package/dist/stripe-apple-pay-adapter-Bq3f1mqv.d.mts +141 -0
  52. package/dist/stripe-apple-pay-adapter-Bq3f1mqv.d.mts.map +1 -0
  53. package/dist/{stripe-google-pay-adapter-DMDArVp2.mjs → stripe-google-pay-adapter-DjrgDYWe.mjs} +1 -1
  54. package/dist/{stripe-google-pay-adapter-DMDArVp2.mjs.map → stripe-google-pay-adapter-DjrgDYWe.mjs.map} +1 -1
  55. package/dist/{stripe-google-pay-adapter-DUUB46SG.d.mts → stripe-google-pay-adapter-xktEycOD.d.mts} +1 -1
  56. package/dist/{stripe-google-pay-adapter-DUUB46SG.d.mts.map → stripe-google-pay-adapter-xktEycOD.d.mts.map} +1 -1
  57. package/dist/types-CPuloCtF.d.mts +129 -0
  58. package/dist/types-CPuloCtF.d.mts.map +1 -0
  59. package/dist/{utils-h0dxplHy.mjs → utils-Dgyk7RkM.mjs} +40 -2
  60. package/dist/utils-Dgyk7RkM.mjs.map +1 -0
  61. package/package.json +9 -3
  62. package/dist/connect-tunnel-x-B7iMQ7DX.d.mts.map +0 -1
  63. package/dist/next-action-handlers-DTsWjUIA.mjs +0 -53
  64. package/dist/next-action-handlers-DTsWjUIA.mjs.map +0 -1
  65. package/dist/types-DsVMq4jZ.d.mts +0 -64
  66. package/dist/types-DsVMq4jZ.d.mts.map +0 -1
  67. package/dist/utils-h0dxplHy.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"paypal.d.mts","names":[],"sources":["../../src/payment-methods/paypal.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,kBAAA;;;;KAKA,kBAAA;EALA,YAAA,EAAA,MAAA;EAKA,aAAA,EAEK,kBAAA;EAQL,cAAA,EAAA;IAMA,SAAA,CAAA,EAAA,MAAA;IAOA,WAAA,CAAA,EAAA;MAOA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAmB,OAAA;IA0JzB,CAAA;;;;;;KA9KM,mBAAA;;;;;KAMA,oBAAA;;;;;;KAOA,sBAAA;;;;;;KAOA,mBAAA;;gBAEI;;cAwJV,qBAqBJ"}
1
+ {"version":3,"file":"paypal.d.mts","names":[],"sources":["../../src/payment-methods/paypal.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,kBAAA;;;;KAKA,kBAAA;EALA,YAAA,EAAA,MAAA;EAKA,aAAA,EAEK,kBAAA;EAQL,cAAA,EAAA;IAMA,SAAA,CAAA,EAAA,MAAA;IAOA,WAAA,CAAA,EAAA;MAOA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAmB,OAAA;IA+JzB,CAAA;;;;;;KAnLM,mBAAA;;;;;KAMA,oBAAA;;;;;;KAOA,sBAAA;;;;;;KAOA,mBAAA;;gBAEI;;cA6JV,qBAqBJ"}
@@ -1,16 +1,21 @@
1
- import { i as definePaymentMethod, n as collectFraudMetadata } from "../utils-h0dxplHy.mjs";
1
+ import { i as definePaymentMethod, n as collectFraudMetadata, o as generateCheckoutRequestId } from "../utils-Dgyk7RkM.mjs";
2
2
 
3
3
  //#region src/payment-methods/paypal.ts
4
4
  const defSubmitPayment = (states) => {
5
5
  const submitPayment = async (_fields, options) => {
6
- const { apiBaseUrl, secureToken } = states;
6
+ const { apiBaseUrl, secureToken, environment } = states;
7
7
  const paypalOptions = options;
8
8
  if (!paypalOptions?.processorId) return { errors: { processor_id: "Processor ID is required" } };
9
9
  if (!paypalOptions?.customerInfo?.first_name || !paypalOptions?.customerInfo?.last_name) return { errors: { customer_name: "Customer first and last name are required" } };
10
10
  try {
11
+ const checkoutRequestId = generateCheckoutRequestId(environment);
12
+ console.log(`[PayPal] Generated checkout_request_id: ${checkoutRequestId}`);
11
13
  const startResponse = await fetch(`${apiBaseUrl}/api/checkout/${secureToken}/paypal/start`, {
12
14
  method: "POST",
13
- headers: { "Content-Type": "application/json" },
15
+ headers: {
16
+ "Content-Type": "application/json",
17
+ "x-request-id": checkoutRequestId
18
+ },
14
19
  body: JSON.stringify({
15
20
  processor_id: paypalOptions.processorId,
16
21
  customer_info: paypalOptions.customerInfo,
@@ -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 } 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 } = 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 // 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 },\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,gBAAgB;EACpC,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,gBAAgB,MAAM,MAAM,GAAG,WAAW,gBAAgB,YAAY,gBAAgB;IAC1F,QAAQ;IACR,SAAS,EACP,gBAAgB,oBACjB;IACD,MAAM,KAAK,UAAU;KACnB,cAAc,cAAc;KAC5B,eAAe,cAAc;KAC7B,gBAAgB,sBAAsB;KACvC,CAAuB;IACzB,CAAC;AAEF,OAAI,CAAC,cAAc,IAAI;IACrB,IAAI,eAAe,oCAAoC,cAAc,OAAO;AAC5E,QAAI;AAEF,qBADkB,MAAM,cAAc,MAAM,EACnB,UAAU;YAC7B;AAEN,oBAAe,cAAc,cAAc;;AAE7C,WAAO,EACL,QAAQ,EACN,QAAQ,cACT,EACF;;GAGH,MAAM,EAAE,cAAc,aAAa,wBAAyB,MAAM,cAAc,MAAM;GAGtF,MAAM,QAAQ,OAAO,KAAK,cAAc,UAAU,uBAAuB;AAEzE,OAAI,C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AY,SAAS,CAAC,YAAY,MAAM,OAC1C,aAAY,MAAM,OAAO;;GAG9B;EACF;EACD;AAEF,qBAAe"}
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, generateCheckoutRequestId } 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 // Generate checkout request ID for correlating all API calls in this submission\n const checkoutRequestId = generateCheckoutRequestId(environment);\n console.log(`[PayPal] Generated 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,0BAA0B,YAAY;A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S,mBAAmB,aAAa,UAC/D,EACF,CAAC;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"}
@@ -0,0 +1,2 @@
1
+ import { a as StripeApplePayAdapter, i as ShowApplePaySheetResult, n as ApplePayPaymentRequestConfig, r as ConfirmResult, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-Bq3f1mqv.mjs";
2
+ export { ApplePayMockScenario, ApplePayPaymentRequestConfig, ConfirmResult, ShowApplePaySheetResult, StripeApplePayAdapter };
@@ -0,0 +1,3 @@
1
+ import { n as StripeApplePayAdapter, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-Bg7nCy3P.mjs";
2
+
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-DUUB46SG.mjs";
1
+ import { a as StripeGooglePayAdapter, i as ShowPaymentSheetResult, n as GooglePayMockScenario, r as PaymentRequestConfig, t as ConfirmResult } from "../stripe-google-pay-adapter-xktEycOD.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-DMDArVp2.mjs";
1
+ import { n as StripeGooglePayAdapter, t as GooglePayMockScenario } from "../stripe-google-pay-adapter-DjrgDYWe.mjs";
2
2
 
3
3
  export { GooglePayMockScenario, StripeGooglePayAdapter };
@@ -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-C582hcWw.mjs";
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-DTfXuTsW.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-DO2EJxu6.mjs";
2
+ import { n as connectToCardParent, t as connectToCardIframe } from "../connect-card-BrtCmsjz.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-B7iMQ7DX.mjs";
1
+ import { a as connectToTunnelXParent, i as connectToTunnelXIframe, n as TunnelXManager, r as TunnelXParentConnection, t as TunnelXIFrameConnection } from "../connect-tunnel-x-Dxcg5Y7Y.mjs";
2
2
  export { TunnelXIFrameConnection, TunnelXManager, TunnelXParentConnection, connectToTunnelXIframe, connectToTunnelXParent };
@@ -0,0 +1,313 @@
1
+ //#region src/payment-methods/stripe-apple-pay-adapter.ts
2
+ let ApplePayMockScenario = /* @__PURE__ */ function(ApplePayMockScenario$1) {
3
+ ApplePayMockScenario$1["None"] = "none";
4
+ ApplePayMockScenario$1["Success"] = "success";
5
+ ApplePayMockScenario$1["Cancelled"] = "cancelled";
6
+ return ApplePayMockScenario$1;
7
+ }({});
8
+ /**
9
+ * Stripe Apple Pay Adapter using Stripe's PaymentRequest API.
10
+ *
11
+ * This uses Stripe's PaymentRequest API instead of the native ApplePaySession API.
12
+ * The key benefit is that Stripe handles merchant validation automatically,
13
+ * which is required for Apple Pay to work correctly.
14
+ *
15
+ * IMPORTANT: To comply with browser security requirements, Apple Pay must be shown
16
+ * synchronously from a user click. The flow is:
17
+ *
18
+ * 1. Call preparePaymentRequest() BEFORE user clicks (e.g., when page loads)
19
+ * - This creates the PaymentRequest and calls canMakePayment()
20
+ * 2. On user click, call showPreparedPaymentSheet()
21
+ * - This calls show() on the pre-created PaymentRequest (no async!)
22
+ * 3. Handle the paymentmethod event and call complete()
23
+ */
24
+ var StripeApplePayAdapter = class {
25
+ stripe = null;
26
+ mockScenario;
27
+ preparedPaymentRequest = null;
28
+ constructor(mockScenario) {
29
+ this.mockScenario = mockScenario ?? ApplePayMockScenario.None;
30
+ }
31
+ initialize(publishableKey) {
32
+ switch (this.mockScenario) {
33
+ case ApplePayMockScenario.None: {
34
+ console.log("[ApplePay] initialize called");
35
+ if (!window.Stripe) {
36
+ console.log("[ApplePay] Stripe.js not loaded");
37
+ return false;
38
+ }
39
+ this.stripe = window.Stripe(publishableKey);
40
+ const success = this.stripe !== null;
41
+ console.log("[ApplePay] initialize result:", success);
42
+ return success;
43
+ }
44
+ case ApplePayMockScenario.Success:
45
+ case ApplePayMockScenario.Cancelled:
46
+ console.log("[MockApplePay] initialize called");
47
+ console.log("[MockApplePay] initialize result:", true);
48
+ return true;
49
+ }
50
+ }
51
+ /**
52
+ * Check if Apple Pay is available on this device/browser.
53
+ * Uses Stripe's PaymentRequest.canMakePayment() which is more reliable
54
+ * than checking ApplePaySession directly.
55
+ */
56
+ static isAvailable() {
57
+ if (typeof window === "undefined" || !window.ApplePaySession) {
58
+ console.log("[ApplePay] ApplePaySession not available");
59
+ return false;
60
+ }
61
+ const canMakePayments = window.ApplePaySession.canMakePayments();
62
+ console.log("[ApplePay] canMakePayments:", canMakePayments);
63
+ return canMakePayments;
64
+ }
65
+ /**
66
+ * Check availability using Stripe's PaymentRequest API.
67
+ * This is more accurate as it checks Stripe's configuration too.
68
+ */
69
+ async canMakePayment() {
70
+ if (!this.stripe) {
71
+ console.log("[ApplePay] Stripe not initialized");
72
+ return null;
73
+ }
74
+ const result = await this.stripe.paymentRequest({
75
+ country: "US",
76
+ currency: "usd",
77
+ total: {
78
+ label: "Check",
79
+ amount: 100
80
+ }
81
+ }).canMakePayment();
82
+ console.log("[ApplePay] canMakePayment result:", result);
83
+ if (!result) return null;
84
+ return {
85
+ applePay: result.applePay ?? false,
86
+ googlePay: result.googlePay ?? false
87
+ };
88
+ }
89
+ /**
90
+ * Prepare a PaymentRequest for later use. Call this BEFORE the user clicks.
91
+ * This creates the PaymentRequest and calls canMakePayment() to validate.
92
+ *
93
+ * @returns Promise with success status and whether Apple Pay is available
94
+ */
95
+ async preparePaymentRequest(config) {
96
+ if (this.mockScenario !== ApplePayMockScenario.None) {
97
+ console.log("[MockApplePay] preparePaymentRequest called");
98
+ this.preparedConfig = config;
99
+ return {
100
+ success: true,
101
+ applePay: true,
102
+ googlePay: false
103
+ };
104
+ }
105
+ console.log("[ApplePay] preparePaymentRequest called", config);
106
+ if (!this.stripe) return {
107
+ success: false,
108
+ error: "Stripe not initialized"
109
+ };
110
+ const paymentRequest = this.stripe.paymentRequest({
111
+ country: config.country,
112
+ currency: config.currency.toLowerCase(),
113
+ total: {
114
+ label: config.total.label,
115
+ amount: config.total.amount
116
+ },
117
+ requestPayerName: true,
118
+ requestPayerEmail: true
119
+ });
120
+ const canMakePaymentResult = await paymentRequest.canMakePayment();
121
+ console.log("[ApplePay] preparePaymentRequest canMakePayment:", canMakePaymentResult);
122
+ if (!canMakePaymentResult) return {
123
+ success: false,
124
+ error: "Payment methods not available on this device/browser",
125
+ applePay: false,
126
+ googlePay: false
127
+ };
128
+ this.preparedPaymentRequest = paymentRequest;
129
+ this.preparedConfig = config;
130
+ return {
131
+ success: true,
132
+ applePay: canMakePaymentResult.applePay ?? false,
133
+ googlePay: canMakePaymentResult.googlePay ?? false
134
+ };
135
+ }
136
+ /**
137
+ * Check if a PaymentRequest has been prepared and is ready to show.
138
+ */
139
+ isPrepared() {
140
+ return this.preparedPaymentRequest !== null || this.mockScenario !== ApplePayMockScenario.None;
141
+ }
142
+ /**
143
+ * Clear the prepared PaymentRequest.
144
+ */
145
+ clearPrepared() {
146
+ this.preparedPaymentRequest = null;
147
+ this.preparedConfig = null;
148
+ }
149
+ /**
150
+ * Show the prepared Apple Pay payment sheet.
151
+ * MUST be called synchronously from a user click handler.
152
+ * Call preparePaymentRequest() before the click to set up the PaymentRequest.
153
+ */
154
+ showPreparedPaymentSheet() {
155
+ switch (this.mockScenario) {
156
+ case ApplePayMockScenario.None: {
157
+ console.log("[ApplePay] showPreparedPaymentSheet called");
158
+ if (!this.preparedPaymentRequest) {
159
+ console.error("[ApplePay] No prepared PaymentRequest! Call preparePaymentRequest() first.");
160
+ return Promise.resolve({
161
+ success: false,
162
+ error: "PaymentRequest not prepared. Call preparePaymentRequest() before showing the sheet."
163
+ });
164
+ }
165
+ const paymentRequest = this.preparedPaymentRequest;
166
+ return new Promise((resolve) => {
167
+ paymentRequest.on("paymentmethod", (evt) => {
168
+ console.log("[ApplePay] paymentmethod event received", {
169
+ paymentMethodId: evt.paymentMethod.id,
170
+ payerEmail: evt.payerEmail,
171
+ payerName: evt.payerName
172
+ });
173
+ this.preparedPaymentRequest = null;
174
+ resolve({
175
+ success: true,
176
+ paymentMethodId: evt.paymentMethod.id,
177
+ paymentMethodEvent: evt,
178
+ billingDetails: {
179
+ email: evt.payerEmail ?? void 0,
180
+ name: evt.payerName ?? void 0,
181
+ address: evt.paymentMethod.billing_details?.address ?? void 0
182
+ }
183
+ });
184
+ });
185
+ paymentRequest.on("cancel", () => {
186
+ console.log("[ApplePay] cancel event - user cancelled");
187
+ this.preparedPaymentRequest = null;
188
+ resolve({
189
+ success: false,
190
+ cancelled: true
191
+ });
192
+ });
193
+ console.log("[ApplePay] showing payment sheet");
194
+ paymentRequest.show();
195
+ });
196
+ }
197
+ case ApplePayMockScenario.Success:
198
+ console.log("[MockApplePay] showPreparedPaymentSheet: success");
199
+ return new Promise((resolve) => {
200
+ setTimeout(() => {
201
+ resolve({
202
+ success: true,
203
+ paymentMethodId: "pm_mock_apple_pay_test",
204
+ paymentMethodEvent: {
205
+ complete: (status) => console.log(`[MockApplePay] complete: ${status}`),
206
+ paymentMethod: {
207
+ id: "pm_mock_apple_pay_test",
208
+ object: "payment_method",
209
+ type: "card",
210
+ card: {
211
+ brand: "visa",
212
+ last4: "4242",
213
+ exp_month: 12,
214
+ exp_year: 2030
215
+ },
216
+ billing_details: {
217
+ email: "test@example.com",
218
+ name: "Test User"
219
+ }
220
+ },
221
+ payerEmail: "test@example.com",
222
+ payerName: "Test User"
223
+ },
224
+ billingDetails: {
225
+ email: "test@example.com",
226
+ name: "Test User"
227
+ }
228
+ });
229
+ }, 500);
230
+ });
231
+ case ApplePayMockScenario.Cancelled:
232
+ console.log("[MockApplePay] showPreparedPaymentSheet: cancelled");
233
+ return new Promise((resolve) => {
234
+ setTimeout(() => {
235
+ resolve({
236
+ success: false,
237
+ cancelled: true
238
+ });
239
+ }, 500);
240
+ });
241
+ }
242
+ }
243
+ /**
244
+ * @deprecated Use preparePaymentRequest() + showPreparedPaymentSheet() instead.
245
+ * This method creates a new PaymentRequest and shows it, which doesn't work
246
+ * with browser security requirements (show() must be called synchronously).
247
+ */
248
+ async showPaymentSheet(config) {
249
+ console.warn("[ApplePay] showPaymentSheet is deprecated. Use preparePaymentRequest() + showPreparedPaymentSheet() instead.");
250
+ const prepareResult = await this.preparePaymentRequest(config);
251
+ if (!prepareResult.success) return {
252
+ success: false,
253
+ error: prepareResult.error ?? "Failed to prepare payment request"
254
+ };
255
+ return this.showPreparedPaymentSheet();
256
+ }
257
+ /**
258
+ * Complete the payment flow in the Apple Pay sheet.
259
+ * Call this after confirming the payment on the server.
260
+ *
261
+ * @param evt - The PaymentRequestPaymentMethodEvent from showPaymentSheet
262
+ * @param status - 'success' or 'fail'
263
+ */
264
+ completePayment(evt, status) {
265
+ console.log("[ApplePay] completePayment:", status);
266
+ evt.complete(status);
267
+ }
268
+ /**
269
+ * Confirm PaymentIntent with the PaymentMethod.
270
+ * This is called after showPaymentSheet to finalize the payment.
271
+ *
272
+ * @deprecated - Server-side confirmation is preferred. The backend should
273
+ * call stripe.PaymentIntent.confirm() with the payment_method_id.
274
+ */
275
+ async confirmPaymentIntent(clientSecret, paymentMethodId) {
276
+ switch (this.mockScenario) {
277
+ case ApplePayMockScenario.None: {
278
+ console.log("[ApplePay] confirmPaymentIntent called", {
279
+ clientSecret: `${clientSecret.slice(0, 20)}...`,
280
+ paymentMethodId
281
+ });
282
+ if (!this.stripe) {
283
+ console.log("[ApplePay] confirmPaymentIntent: Stripe not initialized");
284
+ return {
285
+ success: false,
286
+ error: "Stripe not initialized"
287
+ };
288
+ }
289
+ const { error } = await this.stripe.confirmCardPayment(clientSecret, { payment_method: paymentMethodId });
290
+ if (error) {
291
+ console.log("[ApplePay] confirmPaymentIntent error:", error);
292
+ return {
293
+ success: false,
294
+ error: error.message ?? "Payment failed"
295
+ };
296
+ }
297
+ console.log("[ApplePay] confirmPaymentIntent success");
298
+ return { success: true };
299
+ }
300
+ case ApplePayMockScenario.Success:
301
+ console.log("[MockApplePay] confirmPaymentIntent called", {
302
+ clientSecret,
303
+ paymentMethodId
304
+ });
305
+ return { success: true };
306
+ case ApplePayMockScenario.Cancelled: throw new Error("confirmPaymentIntent should not be called when scenario is Cancelled");
307
+ }
308
+ }
309
+ };
310
+
311
+ //#endregion
312
+ export { StripeApplePayAdapter as n, ApplePayMockScenario as t };
313
+ //# sourceMappingURL=stripe-apple-pay-adapter-Bg7nCy3P.mjs.map
@@ -0,0 +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,QAAI,CAAC,OAAO,QAAQ;AAClB,aAAQ,IAAI,kCAAkC;AAC9C,YAAO;;AAET,SAAK,SAAS,OAAO,OAAO,eAAe;IAC3C,MAAM,UAAU,KAAK,WAAW;AAChC,YAAQ,IAAI,iCAAiC,QAAQ;AACrD,WAAO;;GAET,KAAK,qBAAqB;GAC1B,KAAK,qBAAqB;AACxB,YAAQ,IAAI,mCAAmC;AAC/C,YAAQ,IAAI,qCAAqC,KAAK;AACtD,WAAO;;;;;;;;CAUb,OAAO,cAAuB;AAE5B,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,iBA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K,qBAAqB;AACxB,YAAQ,IAAI,8CAA8C;KAAE;KAAc;KAAiB,CAAC;AAC5F,WAAO,EAAE,SAAS,MAAM;GAE1B,KAAK,qBAAqB,UACxB,OAAM,IAAI,MAAM,uEAAuE"}
@@ -0,0 +1,141 @@
1
+ import { PaymentRequestPaymentMethodEvent, StripeConstructor } from "@stripe/stripe-js";
2
+
3
+ //#region src/payment-methods/stripe-apple-pay-adapter.d.ts
4
+ declare global {
5
+ interface Window {
6
+ Stripe?: StripeConstructor;
7
+ ApplePaySession?: typeof ApplePaySession;
8
+ }
9
+ }
10
+ interface ApplePayPaymentRequestConfig {
11
+ country: string;
12
+ currency: string;
13
+ total: {
14
+ label: string;
15
+ amount: number;
16
+ };
17
+ supportedNetworks?: string[];
18
+ merchantCapabilities?: string[];
19
+ }
20
+ type ShowApplePaySheetResult = {
21
+ success: true;
22
+ paymentMethodId: string;
23
+ paymentMethodEvent: PaymentRequestPaymentMethodEvent;
24
+ billingDetails?: {
25
+ email?: string;
26
+ name?: string;
27
+ address?: {
28
+ city?: string | null;
29
+ country?: string | null;
30
+ line1?: string | null;
31
+ line2?: string | null;
32
+ postal_code?: string | null;
33
+ state?: string | null;
34
+ } | null;
35
+ };
36
+ } | {
37
+ success: false;
38
+ cancelled: true;
39
+ } | {
40
+ success: false;
41
+ error: string;
42
+ };
43
+ type ConfirmResult = {
44
+ success: true;
45
+ } | {
46
+ success: false;
47
+ error: string;
48
+ };
49
+ declare enum ApplePayMockScenario {
50
+ None = "none",
51
+ Success = "success",
52
+ Cancelled = "cancelled",
53
+ }
54
+ /**
55
+ * Stripe Apple Pay Adapter using Stripe's PaymentRequest API.
56
+ *
57
+ * This uses Stripe's PaymentRequest API instead of the native ApplePaySession API.
58
+ * The key benefit is that Stripe handles merchant validation automatically,
59
+ * which is required for Apple Pay to work correctly.
60
+ *
61
+ * IMPORTANT: To comply with browser security requirements, Apple Pay must be shown
62
+ * synchronously from a user click. The flow is:
63
+ *
64
+ * 1. Call preparePaymentRequest() BEFORE user clicks (e.g., when page loads)
65
+ * - This creates the PaymentRequest and calls canMakePayment()
66
+ * 2. On user click, call showPreparedPaymentSheet()
67
+ * - This calls show() on the pre-created PaymentRequest (no async!)
68
+ * 3. Handle the paymentmethod event and call complete()
69
+ */
70
+ declare class StripeApplePayAdapter {
71
+ private stripe;
72
+ private mockScenario;
73
+ private preparedPaymentRequest;
74
+ constructor(mockScenario?: ApplePayMockScenario);
75
+ initialize(publishableKey: string): boolean;
76
+ /**
77
+ * Check if Apple Pay is available on this device/browser.
78
+ * Uses Stripe's PaymentRequest.canMakePayment() which is more reliable
79
+ * than checking ApplePaySession directly.
80
+ */
81
+ static isAvailable(): boolean;
82
+ /**
83
+ * Check availability using Stripe's PaymentRequest API.
84
+ * This is more accurate as it checks Stripe's configuration too.
85
+ */
86
+ canMakePayment(): Promise<{
87
+ applePay: boolean;
88
+ googlePay: boolean;
89
+ } | null>;
90
+ /**
91
+ * Prepare a PaymentRequest for later use. Call this BEFORE the user clicks.
92
+ * This creates the PaymentRequest and calls canMakePayment() to validate.
93
+ *
94
+ * @returns Promise with success status and whether Apple Pay is available
95
+ */
96
+ preparePaymentRequest(config: ApplePayPaymentRequestConfig): Promise<{
97
+ success: boolean;
98
+ applePay?: boolean;
99
+ googlePay?: boolean;
100
+ error?: string;
101
+ }>;
102
+ /**
103
+ * Check if a PaymentRequest has been prepared and is ready to show.
104
+ */
105
+ isPrepared(): boolean;
106
+ /**
107
+ * Clear the prepared PaymentRequest.
108
+ */
109
+ clearPrepared(): void;
110
+ /**
111
+ * Show the prepared Apple Pay payment sheet.
112
+ * MUST be called synchronously from a user click handler.
113
+ * Call preparePaymentRequest() before the click to set up the PaymentRequest.
114
+ */
115
+ showPreparedPaymentSheet(): Promise<ShowApplePaySheetResult>;
116
+ /**
117
+ * @deprecated Use preparePaymentRequest() + showPreparedPaymentSheet() instead.
118
+ * This method creates a new PaymentRequest and shows it, which doesn't work
119
+ * with browser security requirements (show() must be called synchronously).
120
+ */
121
+ showPaymentSheet(config: ApplePayPaymentRequestConfig): Promise<ShowApplePaySheetResult>;
122
+ /**
123
+ * Complete the payment flow in the Apple Pay sheet.
124
+ * Call this after confirming the payment on the server.
125
+ *
126
+ * @param evt - The PaymentRequestPaymentMethodEvent from showPaymentSheet
127
+ * @param status - 'success' or 'fail'
128
+ */
129
+ completePayment(evt: PaymentRequestPaymentMethodEvent, status: "success" | "fail"): void;
130
+ /**
131
+ * Confirm PaymentIntent with the PaymentMethod.
132
+ * This is called after showPaymentSheet to finalize the payment.
133
+ *
134
+ * @deprecated - Server-side confirmation is preferred. The backend should
135
+ * call stripe.PaymentIntent.confirm() with the payment_method_id.
136
+ */
137
+ confirmPaymentIntent(clientSecret: string, paymentMethodId: string): Promise<ConfirmResult>;
138
+ }
139
+ //#endregion
140
+ export { StripeApplePayAdapter as a, ShowApplePaySheetResult as i, ApplePayPaymentRequestConfig as n, ConfirmResult as r, ApplePayMockScenario as t };
141
+ //# sourceMappingURL=stripe-apple-pay-adapter-Bq3f1mqv.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripe-apple-pay-adapter-Bq3f1mqv.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"}
@@ -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-DMDArVp2.mjs.map
163
+ //# sourceMappingURL=stripe-google-pay-adapter-DjrgDYWe.mjs.map