@payment-kit-js/vanilla 0.5.12 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{airwallex-apple-pay-adapter-BCYt7Jzc.d.mts → airwallex-apple-pay-adapter-Bb0CreWN.d.mts} +1 -1
- package/dist/{airwallex-apple-pay-adapter-BCYt7Jzc.d.mts.map → airwallex-apple-pay-adapter-Bb0CreWN.d.mts.map} +1 -1
- package/dist/{airwallex-apple-pay-adapter-BFsoDoSf.mjs → airwallex-apple-pay-adapter-CHAnLP_x.mjs} +1 -1
- package/dist/{airwallex-apple-pay-adapter-BFsoDoSf.mjs.map → airwallex-apple-pay-adapter-CHAnLP_x.mjs.map} +1 -1
- package/dist/{airwallex-google-pay-adapter-B5xmg7b8.mjs → airwallex-google-pay-adapter-C8JTp01q.mjs} +1 -1
- package/dist/{airwallex-google-pay-adapter-B5xmg7b8.mjs.map → airwallex-google-pay-adapter-C8JTp01q.mjs.map} +1 -1
- package/dist/{airwallex-google-pay-adapter-DvEB6t5i.d.mts → airwallex-google-pay-adapter-adaDktQM.d.mts} +1 -1
- package/dist/{airwallex-google-pay-adapter-DvEB6t5i.d.mts.map → airwallex-google-pay-adapter-adaDktQM.d.mts.map} +1 -1
- package/dist/bnpl-shared-B-en2sPr.d.mts +64 -0
- package/dist/bnpl-shared-B-en2sPr.d.mts.map +1 -0
- package/dist/bnpl-shared-CEAXTL3Q.mjs +107 -0
- package/dist/bnpl-shared-CEAXTL3Q.mjs.map +1 -0
- package/dist/cdn/paymentkit.js +355 -15
- package/dist/cdn/paymentkit.js.map +4 -4
- package/dist/cdn/paymentkit.min.js +9 -9
- package/dist/cdn/paymentkit.min.js.map +4 -4
- package/dist/{connect-card-Cxy51W6t.d.mts → connect-card-Cra_F1cC.d.mts} +1 -1
- package/dist/{connect-card-Cxy51W6t.d.mts.map → connect-card-Cra_F1cC.d.mts.map} +1 -1
- package/dist/{connect-card-CMZkeppE.mjs → connect-card-D3Je4V7p.mjs} +1 -1
- package/dist/{connect-card-CMZkeppE.mjs.map → connect-card-D3Je4V7p.mjs.map} +1 -1
- package/dist/{connect-tunnel-x-lv6Wtdme.d.mts → connect-tunnel-x-Wh-JG1O5.d.mts} +1 -1
- package/dist/{connect-tunnel-x-lv6Wtdme.d.mts.map → connect-tunnel-x-Wh-JG1O5.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{next-action-handlers-CTx8tRt0.mjs → next-action-handlers-BZs04hYb.mjs} +1 -1
- package/dist/{next-action-handlers-CTx8tRt0.mjs.map → next-action-handlers-BZs04hYb.mjs.map} +1 -1
- package/dist/payment-methods/affirm.d.mts +13 -0
- package/dist/payment-methods/affirm.d.mts.map +1 -0
- package/dist/payment-methods/affirm.mjs +14 -0
- package/dist/payment-methods/affirm.mjs.map +1 -0
- package/dist/payment-methods/afterpay.d.mts +13 -0
- package/dist/payment-methods/afterpay.d.mts.map +1 -0
- package/dist/payment-methods/afterpay.mjs +14 -0
- package/dist/payment-methods/afterpay.mjs.map +1 -0
- package/dist/payment-methods/airwallex-apple-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/airwallex-apple-pay-adapter.mjs +1 -1
- package/dist/payment-methods/airwallex-google-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/airwallex-google-pay-adapter.mjs +1 -1
- package/dist/payment-methods/apple-pay.d.mts +36 -7
- package/dist/payment-methods/apple-pay.d.mts.map +1 -1
- package/dist/payment-methods/apple-pay.mjs +162 -11
- package/dist/payment-methods/apple-pay.mjs.map +1 -1
- package/dist/payment-methods/bnpl-shared.d.mts +5 -0
- package/dist/payment-methods/bnpl-shared.mjs +4 -0
- package/dist/payment-methods/card.d.mts +3 -3
- package/dist/payment-methods/card.mjs +3 -3
- package/dist/payment-methods/google-pay.d.mts +5 -5
- package/dist/payment-methods/google-pay.mjs +3 -3
- package/dist/payment-methods/klarna.d.mts +13 -0
- package/dist/payment-methods/klarna.d.mts.map +1 -0
- package/dist/payment-methods/klarna.mjs +14 -0
- package/dist/payment-methods/klarna.mjs.map +1 -0
- package/dist/payment-methods/next-action-handlers.mjs +1 -1
- package/dist/payment-methods/paypal.d.mts +9 -3
- package/dist/payment-methods/paypal.d.mts.map +1 -1
- package/dist/payment-methods/paypal.mjs.map +1 -1
- package/dist/payment-methods/stripe-apple-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/stripe-apple-pay-adapter.mjs +1 -1
- package/dist/payment-methods/stripe-google-pay-adapter.d.mts +1 -1
- package/dist/payment-methods/stripe-google-pay-adapter.mjs +1 -1
- package/dist/payment-methods/vgs-collect-loader.mjs +1 -1
- package/dist/penpal/connect-card.d.mts +1 -1
- package/dist/penpal/connect-card.mjs +1 -1
- package/dist/penpal/connect-tunnel-x.d.mts +1 -1
- package/dist/{stripe-apple-pay-adapter-Cd9LVNnp.mjs → stripe-apple-pay-adapter-BLRjqgDf.mjs} +1 -1
- package/dist/{stripe-apple-pay-adapter-Cd9LVNnp.mjs.map → stripe-apple-pay-adapter-BLRjqgDf.mjs.map} +1 -1
- package/dist/{stripe-apple-pay-adapter-DhpGclW9.d.mts → stripe-apple-pay-adapter-DcuGlQqQ.d.mts} +1 -1
- package/dist/{stripe-apple-pay-adapter-DhpGclW9.d.mts.map → stripe-apple-pay-adapter-DcuGlQqQ.d.mts.map} +1 -1
- package/dist/{stripe-google-pay-adapter-Bdox4xBq.d.mts → stripe-google-pay-adapter-BlQ2jVpE.d.mts} +1 -1
- package/dist/{stripe-google-pay-adapter-Bdox4xBq.d.mts.map → stripe-google-pay-adapter-BlQ2jVpE.d.mts.map} +1 -1
- package/dist/{stripe-google-pay-adapter-3cx0KNjK.mjs → stripe-google-pay-adapter-CIkgjhw8.mjs} +1 -1
- package/dist/{stripe-google-pay-adapter-3cx0KNjK.mjs.map → stripe-google-pay-adapter-CIkgjhw8.mjs.map} +1 -1
- package/dist/{types-D88-nhWu.d.mts → types-CQ8xbgoh.d.mts} +3 -3
- package/dist/{types-D88-nhWu.d.mts.map → types-CQ8xbgoh.d.mts.map} +1 -1
- package/dist/{vgs-collect-loader-BZj36d8r.mjs → vgs-collect-loader-l5_Pnmhz.mjs} +1 -1
- package/dist/{vgs-collect-loader-BZj36d8r.mjs.map → vgs-collect-loader-l5_Pnmhz.mjs.map} +1 -1
- package/package.json +6 -2
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { i as definePaymentMethod, n as collectFraudMetadata, o as getOrCreateCheckoutRequestId } from "../utils-B70Y8YcZ.mjs";
|
|
2
|
-
import { n as AirwallexApplePayMockScenario, t as AirwallexApplePayAdapter } from "../airwallex-apple-pay-adapter-
|
|
3
|
-
import { t as handleNextAction } from "../next-action-handlers-
|
|
4
|
-
import { n as StripeApplePayAdapter, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-
|
|
2
|
+
import { n as AirwallexApplePayMockScenario, t as AirwallexApplePayAdapter } from "../airwallex-apple-pay-adapter-CHAnLP_x.mjs";
|
|
3
|
+
import { t as handleNextAction } from "../next-action-handlers-BZs04hYb.mjs";
|
|
4
|
+
import { n as StripeApplePayAdapter, t as ApplePayMockScenario } from "../stripe-apple-pay-adapter-BLRjqgDf.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/payment-methods/apple-pay.ts
|
|
7
7
|
let preparedStripeState = null;
|
|
8
8
|
let preparedAirwallexState = null;
|
|
9
|
+
let applePayScriptLoadPromise = null;
|
|
10
|
+
async function loadApplePayScript() {
|
|
11
|
+
if (typeof window === "undefined") return;
|
|
12
|
+
if (window.ApplePaySession) return;
|
|
13
|
+
if (document.getElementById("__pk_apple_pay_sdk")) return applePayScriptLoadPromise ?? Promise.resolve();
|
|
14
|
+
applePayScriptLoadPromise = new Promise((resolve, reject) => {
|
|
15
|
+
const script = document.createElement("script");
|
|
16
|
+
script.id = "__pk_apple_pay_sdk";
|
|
17
|
+
script.src = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
|
|
18
|
+
script.crossOrigin = "anonymous";
|
|
19
|
+
script.onload = () => resolve();
|
|
20
|
+
script.onerror = () => {
|
|
21
|
+
applePayScriptLoadPromise = null;
|
|
22
|
+
document.getElementById("__pk_apple_pay_sdk")?.remove();
|
|
23
|
+
reject(/* @__PURE__ */ new Error("Failed to load Apple Pay SDK"));
|
|
24
|
+
};
|
|
25
|
+
document.head.appendChild(script);
|
|
26
|
+
});
|
|
27
|
+
return applePayScriptLoadPromise;
|
|
28
|
+
}
|
|
9
29
|
async function apiCall(url, options, checkoutRequestId) {
|
|
10
30
|
const headers = new Headers(options.headers);
|
|
11
31
|
if (checkoutRequestId) headers.set("x-request-id", checkoutRequestId);
|
|
@@ -90,6 +110,9 @@ async function callStripeConfirmEndpoint(apiBaseUrl, secureToken, paymentMethodI
|
|
|
90
110
|
*
|
|
91
111
|
* For Stripe: pre-fetches data and prepares PaymentRequest for immediate show.
|
|
92
112
|
* For Airwallex: returns success with processor="airwallex" so submit uses native ApplePaySession.
|
|
113
|
+
*
|
|
114
|
+
* @deprecated The SDK now calls this automatically on init. Use `onApplePayReady` to observe
|
|
115
|
+
* readiness and `notifyAmountChanged` to trigger re-prepare after amount changes.
|
|
93
116
|
*/
|
|
94
117
|
async function prepareApplePay(apiBaseUrl, secureToken, options, environment) {
|
|
95
118
|
console.log("[ApplePay] prepareApplePay called");
|
|
@@ -98,7 +121,31 @@ async function prepareApplePay(apiBaseUrl, secureToken, options, environment) {
|
|
|
98
121
|
const checkoutRequestId = getOrCreateCheckoutRequestId(environment);
|
|
99
122
|
console.log(`[ApplePay] Using checkout_request_id: ${checkoutRequestId}`);
|
|
100
123
|
if (options.processorType === "airwallex") {
|
|
101
|
-
console.log("[ApplePay] Airwallex processor - fetching session info for amount");
|
|
124
|
+
console.log("[ApplePay] Airwallex processor - loading Apple Pay SDK, fetching session info for amount");
|
|
125
|
+
if (!mockScenarioStr) {
|
|
126
|
+
try {
|
|
127
|
+
await loadApplePayScript();
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.error("[ApplePay] Failed to load Apple Pay SDK:", err);
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
error: "Failed to load Apple Pay"
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
let canMake = false;
|
|
136
|
+
try {
|
|
137
|
+
canMake = !!window.ApplePaySession?.canMakePayments();
|
|
138
|
+
} catch {
|
|
139
|
+
canMake = false;
|
|
140
|
+
}
|
|
141
|
+
if (!canMake) {
|
|
142
|
+
console.log("[ApplePay] Apple Pay not available on this device/browser");
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: "Apple Pay not available on this device"
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
102
149
|
const sessionInfoResult = await callAirwallexSessionInfoEndpoint(apiBaseUrl, secureToken, checkoutRequestId);
|
|
103
150
|
if (sessionInfoResult.error || !sessionInfoResult.data) {
|
|
104
151
|
console.error("[ApplePay] Failed to fetch session info:", sessionInfoResult.error);
|
|
@@ -111,7 +158,7 @@ async function prepareApplePay(apiBaseUrl, secureToken, options, environment) {
|
|
|
111
158
|
const resolvedAmount = sessionInfoResult.data.amount;
|
|
112
159
|
const resolvedCurrency = sessionInfoResult.data.currency;
|
|
113
160
|
preparedAirwallexState = {
|
|
114
|
-
country:
|
|
161
|
+
country: sessionInfoResult.data.country || options.country,
|
|
115
162
|
currency: resolvedCurrency,
|
|
116
163
|
amount: resolvedAmount,
|
|
117
164
|
merchantName: options.merchantName
|
|
@@ -172,7 +219,7 @@ async function prepareApplePay(apiBaseUrl, secureToken, options, environment) {
|
|
|
172
219
|
* Check if Apple Pay has been prepared and is ready.
|
|
173
220
|
*/
|
|
174
221
|
function isApplePayPrepared() {
|
|
175
|
-
return preparedStripeState?.adapter.isPrepared() ?? false;
|
|
222
|
+
return (preparedStripeState?.adapter.isPrepared() ?? false) || preparedAirwallexState !== null;
|
|
176
223
|
}
|
|
177
224
|
/**
|
|
178
225
|
* Clear prepared state (call on unmount or when checkout changes).
|
|
@@ -275,6 +322,14 @@ async function runAirwallexFlow(apiBaseUrl, secureToken, options, mockScenarioSt
|
|
|
275
322
|
if (options.mockScenario === ApplePayMockScenario.Success) airwallexMockScenario = AirwallexApplePayMockScenario.Success;
|
|
276
323
|
else if (options.mockScenario === ApplePayMockScenario.Cancelled) airwallexMockScenario = AirwallexApplePayMockScenario.Cancelled;
|
|
277
324
|
if (!options.country) return { errors: { apple_pay: "Country is required for Airwallex Apple Pay" } };
|
|
325
|
+
if (!options.amount) {
|
|
326
|
+
const sessionInfoResult = await callAirwallexSessionInfoEndpoint(apiBaseUrl, secureToken, checkoutRequestId);
|
|
327
|
+
if (sessionInfoResult.data) {
|
|
328
|
+
options.amount = sessionInfoResult.data.amount;
|
|
329
|
+
options.currency = options.currency || sessionInfoResult.data.currency;
|
|
330
|
+
options.country = options.country || sessionInfoResult.data.country;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
278
333
|
const adapter = new AirwallexApplePayAdapter(airwallexMockScenario);
|
|
279
334
|
const config = {
|
|
280
335
|
amount: options.amount || 0,
|
|
@@ -282,7 +337,7 @@ async function runAirwallexFlow(apiBaseUrl, secureToken, options, mockScenarioSt
|
|
|
282
337
|
country: options.country.toUpperCase(),
|
|
283
338
|
merchantName: options.merchantName || "Total"
|
|
284
339
|
};
|
|
285
|
-
if (!adapter.initialize(config)) return { errors: { apple_pay: "Apple Pay not available on this device
|
|
340
|
+
if (!adapter.initialize(config)) return { errors: { apple_pay: "Apple Pay not available on this device" } };
|
|
286
341
|
if (!await adapter.canMakePayment()) return { errors: { apple_pay: "Apple Pay not available on this device" } };
|
|
287
342
|
const initiativeContext = typeof window !== "undefined" ? window.location.hostname : "";
|
|
288
343
|
if (airwallexMockScenario !== AirwallexApplePayMockScenario.None) {
|
|
@@ -329,10 +384,13 @@ async function runAirwallexFlow(apiBaseUrl, secureToken, options, mockScenarioSt
|
|
|
329
384
|
complete(response.charge_status === "success" ? "success" : "fail");
|
|
330
385
|
return toApplePayResult(response, secureToken);
|
|
331
386
|
}
|
|
332
|
-
const defSubmitPayment = (states) => {
|
|
387
|
+
const defSubmitPayment = (states, getAutoPrepareConfig, onClearPrepared) => {
|
|
333
388
|
const submitPayment = async (_fields, options) => {
|
|
334
389
|
const { apiBaseUrl, secureToken, environment } = states;
|
|
335
390
|
const applePayOptions = options;
|
|
391
|
+
const autoPrepareConfig = getAutoPrepareConfig();
|
|
392
|
+
if (!applePayOptions.processorId && autoPrepareConfig?.processorId) applePayOptions.processorId = autoPrepareConfig.processorId;
|
|
393
|
+
if (!applePayOptions.processorType && autoPrepareConfig?.processorType) applePayOptions.processorType = autoPrepareConfig.processorType;
|
|
336
394
|
const validationError = validateOptions(applePayOptions);
|
|
337
395
|
if (validationError) return { errors: validationError };
|
|
338
396
|
try {
|
|
@@ -404,19 +462,112 @@ const defSubmitPayment = (states) => {
|
|
|
404
462
|
return confirmResult;
|
|
405
463
|
}
|
|
406
464
|
} catch (error) {
|
|
407
|
-
|
|
465
|
+
onClearPrepared();
|
|
408
466
|
return { errors: { apple_pay: `Apple Pay error: ${error}` } };
|
|
409
467
|
}
|
|
410
468
|
};
|
|
411
469
|
return submitPayment;
|
|
412
470
|
};
|
|
413
471
|
const ApplePayPaymentMethod = definePaymentMethod((paymentKitStates) => {
|
|
472
|
+
const { apiBaseUrl, secureToken, environment } = paymentKitStates;
|
|
473
|
+
let autoPrepareConfig = null;
|
|
474
|
+
let onApplePayReadyCallbacks = [];
|
|
475
|
+
let isApplePayReadyState = false;
|
|
476
|
+
let autoPrepareInProgress = false;
|
|
477
|
+
let cleanupGeneration = 0;
|
|
478
|
+
let pendingAutoPrepareArgs = null;
|
|
479
|
+
let pendingPrepareResolvers = [];
|
|
480
|
+
function instanceSetApplePayReady(ready) {
|
|
481
|
+
isApplePayReadyState = ready;
|
|
482
|
+
for (const cb of onApplePayReadyCallbacks) cb(ready);
|
|
483
|
+
}
|
|
484
|
+
function instanceClearPreparedApplePay() {
|
|
485
|
+
clearPreparedApplePay();
|
|
486
|
+
instanceSetApplePayReady(false);
|
|
487
|
+
}
|
|
488
|
+
async function instanceAutoPrepare(apBase, sToken, env) {
|
|
489
|
+
if (autoPrepareInProgress) {
|
|
490
|
+
pendingAutoPrepareArgs = {
|
|
491
|
+
apiBaseUrl: apBase,
|
|
492
|
+
secureToken: sToken,
|
|
493
|
+
environment: env
|
|
494
|
+
};
|
|
495
|
+
return new Promise((resolve) => pendingPrepareResolvers.push(resolve));
|
|
496
|
+
}
|
|
497
|
+
autoPrepareInProgress = true;
|
|
498
|
+
const capturedGeneration = cleanupGeneration;
|
|
499
|
+
instanceSetApplePayReady(false);
|
|
500
|
+
try {
|
|
501
|
+
const result = await apiCall(`${apBase}/api/checkout-sessions/token/${sToken}`, { method: "GET" });
|
|
502
|
+
if (cleanupGeneration !== capturedGeneration) return;
|
|
503
|
+
if (result.error || !result.data) {
|
|
504
|
+
console.warn("[ApplePay] Auto-prepare: failed to fetch session config:", result.error);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const processorId = result.data.express_checkout_processor_id;
|
|
508
|
+
if (!processorId) {
|
|
509
|
+
console.log("[ApplePay] Auto-prepare: no express checkout processor configured");
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const processorTypeRaw = result.data.express_checkout_processor_type;
|
|
513
|
+
const processorType = processorTypeRaw === "airwallex" || processorTypeRaw === "stripe" ? processorTypeRaw : void 0;
|
|
514
|
+
autoPrepareConfig = {
|
|
515
|
+
processorId,
|
|
516
|
+
processorType
|
|
517
|
+
};
|
|
518
|
+
const prepareResult = await prepareApplePay(apBase, sToken, {
|
|
519
|
+
processorId,
|
|
520
|
+
processorType,
|
|
521
|
+
customerInfo: {
|
|
522
|
+
first_name: "",
|
|
523
|
+
last_name: ""
|
|
524
|
+
}
|
|
525
|
+
}, env);
|
|
526
|
+
if (cleanupGeneration !== capturedGeneration) return;
|
|
527
|
+
instanceSetApplePayReady(prepareResult.success && prepareResult.applePay === true);
|
|
528
|
+
} catch (err) {
|
|
529
|
+
if (cleanupGeneration === capturedGeneration) console.error("[ApplePay] Auto-prepare failed:", err);
|
|
530
|
+
} finally {
|
|
531
|
+
autoPrepareInProgress = false;
|
|
532
|
+
const stale = cleanupGeneration !== capturedGeneration;
|
|
533
|
+
const pending = pendingAutoPrepareArgs;
|
|
534
|
+
const resolvers = pendingPrepareResolvers.splice(0);
|
|
535
|
+
if (!stale && pending) {
|
|
536
|
+
pendingAutoPrepareArgs = null;
|
|
537
|
+
instanceAutoPrepare(pending.apiBaseUrl, pending.secureToken, pending.environment).then(() => {
|
|
538
|
+
for (const r of resolvers) r();
|
|
539
|
+
});
|
|
540
|
+
} else {
|
|
541
|
+
pendingAutoPrepareArgs = null;
|
|
542
|
+
for (const r of resolvers) r();
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
instanceAutoPrepare(apiBaseUrl, secureToken, environment).catch((err) => console.error("[ApplePay] Unhandled init error:", err));
|
|
414
547
|
return {
|
|
415
548
|
name: "apple_pay",
|
|
416
|
-
externalFuncs: {
|
|
549
|
+
externalFuncs: {
|
|
550
|
+
prepareApplePay: (options) => prepareApplePay(apiBaseUrl, secureToken, options, environment),
|
|
551
|
+
onApplePayReady: (callback) => {
|
|
552
|
+
onApplePayReadyCallbacks.push(callback);
|
|
553
|
+
callback(isApplePayReadyState);
|
|
554
|
+
},
|
|
555
|
+
notifyAmountChanged: () => {
|
|
556
|
+
instanceClearPreparedApplePay();
|
|
557
|
+
autoPrepareConfig = null;
|
|
558
|
+
return instanceAutoPrepare(apiBaseUrl, secureToken, environment);
|
|
559
|
+
}
|
|
560
|
+
},
|
|
417
561
|
internalFuncs: {
|
|
418
|
-
submitPayment: defSubmitPayment(paymentKitStates),
|
|
562
|
+
submitPayment: defSubmitPayment(paymentKitStates, () => autoPrepareConfig, instanceClearPreparedApplePay),
|
|
419
563
|
cleanup: () => {
|
|
564
|
+
cleanupGeneration++;
|
|
565
|
+
onApplePayReadyCallbacks = [];
|
|
566
|
+
isApplePayReadyState = false;
|
|
567
|
+
autoPrepareConfig = null;
|
|
568
|
+
pendingAutoPrepareArgs = null;
|
|
569
|
+
pendingPrepareResolvers = [];
|
|
570
|
+
autoPrepareInProgress = false;
|
|
420
571
|
clearPreparedApplePay();
|
|
421
572
|
}
|
|
422
573
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple-pay.mjs","names":["preparedStripeState: PreparedStripeApplePayState | null","preparedAirwallexState: PreparedAirwallexState | null","airwallexMockScenario: AirwallexApplePayMockScenario","config: AirwallexApplePayConfig","submitPayment: TInternalFuncs[\"submitPayment\"]","paymentResult","confirmResult","paymentMethodId","billingDetails"],"sources":["../../src/payment-methods/apple-pay.ts"],"sourcesContent":["import type { PaymentKitErrors, PaymentKitStates, TInternalFuncs } from \"../types\";\nimport { collectFraudMetadata, definePaymentMethod, getOrCreateCheckoutRequestId } from \"../utils\";\nimport {\n AirwallexApplePayAdapter,\n type AirwallexApplePayConfig,\n AirwallexApplePayMockScenario,\n type ApplePayEncryptedToken,\n} from \"./airwallex-apple-pay-adapter\";\nimport { handleNextAction } from \"./next-action-handlers\";\nimport { ApplePayMockScenario, StripeApplePayAdapter } from \"./stripe-apple-pay-adapter\";\n\n// Apple Pay-specific types\nexport type ApplePayCustomerInfo = {\n first_name: string;\n last_name: string;\n email?: string;\n};\n\nexport type ApplePayStartRequest = {\n processor_id: string;\n customer_info: ApplePayCustomerInfo;\n fraud_metadata: {\n ipAddress?: string;\n browserInfo?: { [key: string]: unknown };\n processorFraudInfo?: { [key: string]: unknown };\n };\n mock_scenario?: string;\n // Airwallex-specific fields (sent on /start for merchant validation)\n validation_url?: string;\n initiative_context?: string;\n};\n\nexport type ApplePayStartResponse = {\n checkout_attempt_id: string;\n amount: number;\n currency: string;\n country: string;\n\n // Processor discriminator\n processor: \"stripe\" | \"airwallex\";\n\n // Stripe-specific fields (when processor=\"stripe\")\n client_secret?: string;\n stripe_pk?: string;\n\n // Airwallex-specific fields (when processor=\"airwallex\")\n merchant_session?: { [key: string]: unknown }; // Apple merchant session for completeMerchantValidation()\n};\n\n// Airwallex 3DS next action type (matches backend snake_case response)\nexport type Airwallex3dsNextAction = {\n type: \"airwallex_3ds\";\n url: string;\n};\n\nexport type ApplePayConfirmRequest = {\n // Stripe: Send PaymentMethod ID\n payment_method_id?: string;\n // Airwallex: Send encrypted Apple Pay token\n apple_pay_token?: ApplePayEncryptedToken | { [key: string]: unknown };\n // Email from payment sheet (Stripe Apple Pay) — used to fill missing customer email\n payer_email?: string;\n mock_scenario?: string;\n};\n\nexport type ApplePayConfirmResponse = {\n charge_status: \"success\" | \"fail\" | \"pending\";\n transaction_id?: string;\n error_code?: string;\n error_message_for_customer?: string;\n error_message_for_debug?: string;\n checkout_attempt_id: string;\n checkout_session_id?: string;\n next_action?: Airwallex3dsNextAction; // Present when charge_status=\"pending\" for 3DS\n payment_intent_id?: string;\n customer_id?: string;\n payment_method_id?: string;\n processor_used?: string;\n subscription_id?: string;\n invoice_id?: string;\n invoice_number?: number;\n card_brand?: string;\n card_last4?: string;\n card_exp_month?: number;\n card_exp_year?: number;\n};\n\nexport type ApplePaySubmitOptions = {\n processorId: string;\n processorType?: \"stripe\" | \"airwallex\";\n customerInfo: ApplePayCustomerInfo;\n mockScenario?: ApplePayMockScenario;\n amount?: number; // Amount in atomic units (cents) for Apple Pay sheet display\n currency?: string; // Currency code (e.g., \"usd\")\n country: string; // Country code (e.g., \"US\") for Apple Pay sheet — required\n merchantName?: string; // Merchant display name on Apple Pay sheet\n};\n\ntype ApplePayResult =\n | { data: { [key: string]: unknown }; errors?: undefined }\n | { data?: undefined; errors: PaymentKitErrors };\n\n// =============================================================================\n// Prepared Payment State (for Stripe pre-fetching before click)\n// =============================================================================\n\ntype PreparedStripeApplePayState = {\n processor: \"stripe\";\n adapter: StripeApplePayAdapter;\n startData: ApplePayStartResponse;\n mockScenarioStr?: string;\n checkoutRequestId: string;\n};\n\n// Global state to store prepared Apple Pay data (Stripe only - Airwallex uses native session)\nlet preparedStripeState: PreparedStripeApplePayState | null = null;\n\n// Prepared Airwallex state — persists options from prepare call for use at submit time\n// The amount field is fetched from the session via /session-info endpoint to fix\n// the $0.00 bug where options.amount was undefined and defaulted to 0.\ntype PreparedAirwallexState = {\n country: string;\n currency?: string;\n amount?: number;\n merchantName?: string;\n};\nlet preparedAirwallexState: PreparedAirwallexState | null = null;\n\n// Response type for Airwallex Apple Pay session-info endpoint\ntype AirwallexSessionInfoResponse = {\n amount: number;\n currency: string;\n country: string;\n};\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\nasync function apiCall<T>(\n url: string,\n options: RequestInit,\n checkoutRequestId?: string,\n): Promise<{ data?: T; error?: string }> {\n const headers = new Headers(options.headers);\n if (checkoutRequestId) {\n headers.set(\"x-request-id\", checkoutRequestId);\n }\n\n const response = await fetch(url, { ...options, headers });\n if (!response.ok) {\n let errorMessage = `Request failed (${response.status})`;\n try {\n const errorData = await response.json();\n errorMessage = errorData.detail || errorMessage;\n } catch {\n errorMessage = response.statusText || errorMessage;\n }\n return { error: errorMessage };\n }\n return { data: await response.json() };\n}\n\nfunction validateOptions(options: ApplePaySubmitOptions): PaymentKitErrors | null {\n if (!options?.processorId) {\n return { processor_id: \"Processor ID is required\" };\n }\n // For Airwallex, country is required (either directly or from prepared state)\n if (options.processorType === \"airwallex\" && !options.country && !preparedAirwallexState?.country) {\n return { country: \"Country is required for Airwallex Apple Pay\" };\n }\n return null;\n}\n\nfunction getMockScenarioStr(mockScenario?: ApplePayMockScenario): string | undefined {\n return mockScenario && mockScenario !== ApplePayMockScenario.None ? mockScenario : undefined;\n}\n\n// =============================================================================\n// Stripe Apple Pay Flow\n// =============================================================================\n\nasync function callStripeStartEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n): Promise<{ data?: ApplePayStartResponse; error?: string }> {\n return apiCall<ApplePayStartResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/apple-pay/start`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n processor_id: options.processorId,\n customer_info: options.customerInfo,\n fraud_metadata: collectFraudMetadata(),\n mock_scenario: mockScenarioStr,\n } as ApplePayStartRequest),\n },\n checkoutRequestId,\n );\n}\n\nfunction initializeStripeAdapter(\n stripePk: string,\n mockScenario?: ApplePayMockScenario,\n): { adapter?: StripeApplePayAdapter; error?: string } {\n const adapter = new StripeApplePayAdapter(mockScenario);\n\n if (!adapter.initialize(stripePk)) {\n return { error: 'Stripe.js not loaded. Add <script src=\"https://js.stripe.com/v3/\"></script> to your page.' };\n }\n\n return { adapter };\n}\n\nasync function callStripeConfirmEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n paymentMethodId: string,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n payerEmail?: string,\n): Promise<ApplePayResult> {\n const result = await apiCall<ApplePayConfirmResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/apple-pay/confirm`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n payment_method_id: paymentMethodId,\n payer_email: payerEmail,\n mock_scenario: mockScenarioStr,\n } as ApplePayConfirmRequest),\n },\n checkoutRequestId,\n );\n\n if (result.error || !result.data) {\n return { errors: { apple_pay: result.error || \"Failed to confirm payment\" } };\n }\n\n const confirmData = result.data;\n\n if (confirmData.charge_status === \"success\") {\n return {\n data: {\n id: confirmData.transaction_id,\n checkoutAttemptId: confirmData.checkout_attempt_id,\n checkoutSessionId: confirmData.checkout_session_id ?? secureToken,\n state: \"checkout_succeeded\",\n paymentIntentId: confirmData.payment_intent_id,\n customerId: confirmData.customer_id,\n paymentMethodId: confirmData.payment_method_id,\n processorUsed: confirmData.processor_used,\n subscriptionId: confirmData.subscription_id,\n invoiceId: confirmData.invoice_id,\n invoiceNumber: confirmData.invoice_number,\n cardBrand: confirmData.card_brand,\n cardLast4: confirmData.card_last4,\n cardExpMonth: confirmData.card_exp_month,\n cardExpYear: confirmData.card_exp_year,\n errorCode: confirmData.error_code,\n errorMessageForCustomer: confirmData.error_message_for_customer,\n errorMessageForDebug: confirmData.error_message_for_debug,\n nextAction: confirmData.next_action,\n },\n };\n }\n\n return {\n errors: {\n apple_pay: confirmData.error_message_for_customer || confirmData.error_message_for_debug || \"Payment failed\",\n },\n };\n}\n\n// =============================================================================\n// Prepare Function (call BEFORE the click handler)\n// =============================================================================\n\n/**\n * Pre-fetch Apple Pay data and prepare the PaymentRequest.\n * Call this when the checkout page loads, NOT in the click handler.\n *\n * For Stripe: pre-fetches data and prepares PaymentRequest for immediate show.\n * For Airwallex: returns success with processor=\"airwallex\" so submit uses native ApplePaySession.\n */\nexport async function prepareApplePay(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n environment: string,\n): Promise<{ success: boolean; error?: string; applePay?: boolean }> {\n console.log(\"[ApplePay] prepareApplePay called\");\n\n // Clear any previous state\n preparedStripeState = null;\n\n const mockScenarioStr = getMockScenarioStr(options.mockScenario);\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[ApplePay] Using checkout_request_id: ${checkoutRequestId}`);\n\n // Airwallex: Fetch session info to get the correct amount from line items\n // This fixes the $0.00 bug where options.amount was undefined and defaulted to 0\n if (options.processorType === \"airwallex\") {\n console.log(\"[ApplePay] Airwallex processor - fetching session info for amount\");\n\n // Fetch session info (amount, currency, country) from backend\n const sessionInfoResult = await callAirwallexSessionInfoEndpoint(apiBaseUrl, secureToken, checkoutRequestId);\n\n // Session info is required for Airwallex Apple Pay - fail if unavailable\n if (sessionInfoResult.error || !sessionInfoResult.data) {\n console.error(\"[ApplePay] Failed to fetch session info:\", sessionInfoResult.error);\n return { success: false, error: sessionInfoResult.error || \"Failed to fetch Apple Pay session info\" };\n }\n\n console.log(\"[ApplePay] Got session info:\", sessionInfoResult.data);\n const resolvedAmount = sessionInfoResult.data.amount;\n const resolvedCurrency = sessionInfoResult.data.currency;\n // Use session country if options.country not provided\n const resolvedCountry = options.country || sessionInfoResult.data.country;\n\n // Persist options so submit-time call can merge them into runAirwallexFlow\n preparedAirwallexState = {\n country: resolvedCountry,\n currency: resolvedCurrency,\n amount: resolvedAmount,\n merchantName: options.merchantName,\n };\n console.log(\"[ApplePay] Airwallex prepared state:\", preparedAirwallexState);\n return { success: true, applePay: true };\n }\n\n // Call Stripe start endpoint to get PaymentIntent details\n const startResult = await callStripeStartEndpoint(\n apiBaseUrl,\n secureToken,\n options,\n mockScenarioStr,\n checkoutRequestId,\n );\n if (startResult.error || !startResult.data) {\n return { success: false, error: startResult.error || \"Failed to start Apple Pay\" };\n }\n\n const startData = startResult.data;\n\n // Initialize Stripe adapter\n if (!startData.stripe_pk) {\n return { success: false, error: \"Stripe publishable key not provided\" };\n }\n\n const { adapter, error: adapterError } = initializeStripeAdapter(startData.stripe_pk, options.mockScenario);\n if (!adapter) {\n return { success: false, error: adapterError };\n }\n\n // Create PaymentRequest and call canMakePayment() (required before show())\n const prepareResult = await adapter.preparePaymentRequest({\n country: startData.country,\n currency: startData.currency.toLowerCase(),\n total: {\n label: \"Total\",\n amount: startData.amount,\n },\n });\n\n if (!prepareResult.success) {\n return {\n success: false,\n error: prepareResult.error || \"Failed to prepare payment request\",\n applePay: prepareResult.applePay,\n };\n }\n\n if (!prepareResult.applePay) {\n return {\n success: false,\n error: \"Apple Pay is not available on this device or Stripe account\",\n applePay: false,\n };\n }\n\n // Store the prepared state\n preparedStripeState = {\n processor: \"stripe\",\n adapter,\n startData,\n mockScenarioStr,\n checkoutRequestId,\n };\n\n console.log(\"[ApplePay] prepareApplePay success (Stripe), ready for click\");\n return { success: true, applePay: true };\n}\n\n/**\n * Check if Apple Pay has been prepared and is ready.\n */\nexport function isApplePayPrepared(): boolean {\n return preparedStripeState?.adapter.isPrepared() ?? false;\n}\n\n/**\n * Clear prepared state (call on unmount or when checkout changes).\n */\nexport function clearPreparedApplePay(): void {\n if (preparedStripeState) {\n preparedStripeState.adapter.clearPrepared();\n }\n preparedStripeState = null;\n preparedAirwallexState = null;\n}\n\n// =============================================================================\n// Airwallex Apple Pay Flow\n// =============================================================================\n\n/**\n * Fetch session info (amount, currency, country) from the backend.\n * Called during prepareApplePay to get the correct amount BEFORE showing the payment sheet.\n * This fixes the $0.00 bug where options.amount was undefined and defaulted to 0.\n */\nasync function callAirwallexSessionInfoEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n checkoutRequestId?: string,\n): Promise<{ data?: AirwallexSessionInfoResponse; error?: string }> {\n return apiCall<AirwallexSessionInfoResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/session-info`,\n {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n },\n checkoutRequestId,\n );\n}\n\nasync function callAirwallexStartEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n validationUrl: string,\n initiativeContext: string,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n): Promise<{ data?: ApplePayStartResponse; error?: string }> {\n return apiCall<ApplePayStartResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/start`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n processor_id: options.processorId,\n customer_info: options.customerInfo,\n fraud_metadata: collectFraudMetadata(),\n validation_url: validationUrl,\n initiative_context: initiativeContext,\n mock_scenario: mockScenarioStr,\n } as ApplePayStartRequest),\n },\n checkoutRequestId,\n );\n}\n\nasync function callAirwallexConfirmEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n applePayToken: ApplePayEncryptedToken,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n payerEmail?: string,\n): Promise<ApplePayConfirmResponse> {\n const result = await apiCall<ApplePayConfirmResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/confirm`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n apple_pay_token: applePayToken,\n payer_email: payerEmail,\n mock_scenario: mockScenarioStr,\n } as ApplePayConfirmRequest),\n },\n checkoutRequestId,\n );\n\n if (result.error || !result.data) {\n return {\n charge_status: \"fail\",\n error_message_for_debug: result.error || \"Failed to confirm payment\",\n checkout_attempt_id: \"\",\n };\n }\n\n return result.data;\n}\n\nasync function callAirwallexVerifyEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n checkoutRequestId?: string,\n): Promise<ApplePayConfirmResponse> {\n const result = await apiCall<ApplePayConfirmResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/verify`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n },\n checkoutRequestId,\n );\n\n if (result.error || !result.data) {\n return {\n charge_status: \"fail\",\n error_message_for_debug: result.error || \"Failed to verify payment\",\n checkout_attempt_id: \"\",\n };\n }\n\n return result.data;\n}\n\nfunction toApplePayResult(response: ApplePayConfirmResponse, secureToken: string): ApplePayResult {\n if (response.charge_status === \"success\") {\n return {\n data: {\n id: response.transaction_id,\n checkoutAttemptId: response.checkout_attempt_id,\n checkoutSessionId: response.checkout_session_id ?? secureToken,\n state: \"checkout_succeeded\",\n paymentIntentId: response.payment_intent_id,\n customerId: response.customer_id,\n paymentMethodId: response.payment_method_id,\n processorUsed: response.processor_used,\n subscriptionId: response.subscription_id,\n invoiceId: response.invoice_id,\n invoiceNumber: response.invoice_number,\n cardBrand: response.card_brand,\n cardLast4: response.card_last4,\n cardExpMonth: response.card_exp_month,\n cardExpYear: response.card_exp_year,\n errorCode: response.error_code,\n errorMessageForCustomer: response.error_message_for_customer,\n errorMessageForDebug: response.error_message_for_debug,\n nextAction: response.next_action,\n },\n };\n }\n return {\n errors: {\n apple_pay: response.error_message_for_customer || response.error_message_for_debug || \"Payment failed\",\n },\n };\n}\n\nconst MAX_USER_ACTIONS = 5;\n\n/**\n * Run the Airwallex Apple Pay flow with 3DS loop support.\n *\n * Flow:\n * 1. Show native ApplePaySession, call /start for merchant validation\n * 2. On payment authorized, call /confirm with token\n * 3. If 3DS required, handle it and call /verify\n * 4. Loop if more 3DS needed\n */\nasync function runAirwallexFlow(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n): Promise<ApplePayResult> {\n // Convert mock scenario\n let airwallexMockScenario: AirwallexApplePayMockScenario = AirwallexApplePayMockScenario.None;\n if (options.mockScenario === ApplePayMockScenario.Success) {\n airwallexMockScenario = AirwallexApplePayMockScenario.Success;\n } else if (options.mockScenario === ApplePayMockScenario.Cancelled) {\n airwallexMockScenario = AirwallexApplePayMockScenario.Cancelled;\n }\n\n // Defense-in-depth: validateOptions should catch this earlier, but guard against\n // future callers that bypass validation to avoid an unhandled TypeError on `.toUpperCase()`\n if (!options.country) {\n return { errors: { apple_pay: \"Country is required for Airwallex Apple Pay\" } };\n }\n\n // Initialize adapter\n const adapter = new AirwallexApplePayAdapter(airwallexMockScenario);\n\n const config: AirwallexApplePayConfig = {\n amount: options.amount || 0,\n currency: (options.currency || \"USD\").toUpperCase(),\n country: options.country.toUpperCase(),\n merchantName: options.merchantName || \"Total\",\n };\n\n if (!adapter.initialize(config)) {\n return { errors: { apple_pay: \"Apple Pay not available on this device (requires Safari)\" } };\n }\n\n const canPay = await adapter.canMakePayment();\n if (!canPay) {\n return { errors: { apple_pay: \"Apple Pay not available on this device\" } };\n }\n\n // Get current domain for initiative_context\n const initiativeContext = typeof window !== \"undefined\" ? window.location.hostname : \"\";\n\n // In mock mode, call /start first to create checkout attempt (mock adapter skips merchant validation)\n if (airwallexMockScenario !== AirwallexApplePayMockScenario.None) {\n const startResult = await callAirwallexStartEndpoint(\n apiBaseUrl,\n secureToken,\n options,\n \"https://mock-apple-pay-gateway.example.com/paymentservices/startSession\",\n initiativeContext,\n mockScenarioStr,\n checkoutRequestId,\n );\n if (startResult.error || !startResult.data) {\n return { errors: { apple_pay: startResult.error || \"Failed to start mock checkout\" } };\n }\n }\n\n // Show Apple Pay sheet with merchant validation callback\n const paymentResult = await adapter.showPaymentSheet(async (validationUrl: string) => {\n // Call /start endpoint for merchant validation\n const startResult = await callAirwallexStartEndpoint(\n apiBaseUrl,\n secureToken,\n options,\n validationUrl,\n initiativeContext,\n mockScenarioStr,\n checkoutRequestId,\n );\n\n if (startResult.error || !startResult.data) {\n return { error: startResult.error || \"Merchant validation failed\" };\n }\n\n if (!startResult.data.merchant_session) {\n return { error: \"No merchant session returned from server\" };\n }\n\n return { merchantSession: startResult.data.merchant_session };\n });\n\n if (!paymentResult.success) {\n if (\"cancelled\" in paymentResult && paymentResult.cancelled) {\n return { errors: { apple_pay: \"Apple Pay cancelled by user\" } };\n }\n return { errors: { apple_pay: paymentResult.error || \"Apple Pay failed\" } };\n }\n\n const { token, complete, payerEmail } = paymentResult;\n\n // Call /confirm with the token\n let response = await callAirwallexConfirmEndpoint(\n apiBaseUrl,\n secureToken,\n token,\n mockScenarioStr,\n checkoutRequestId,\n payerEmail,\n );\n\n // Handle 3DS loop\n let userActionCount = 0;\n while (response.charge_status === \"pending\" && response.next_action && userActionCount < MAX_USER_ACTIONS) {\n userActionCount++;\n\n // Handle 3DS challenge — Airwallex3dsNextAction is structurally identical to SDK's Airwallex3dsAction\n const nextAction = response.next_action as Airwallex3dsNextAction;\n const actionResult = await handleNextAction({ type: nextAction.type, url: nextAction.url });\n\n // Call verify endpoint\n const verifyResponse = await callAirwallexVerifyEndpoint(apiBaseUrl, secureToken, checkoutRequestId);\n\n // Check if another 3DS action is required\n if (verifyResponse.charge_status === \"pending\" && verifyResponse.next_action) {\n if (!actionResult.success) {\n console.log(\"[ApplePay:Airwallex] 3DS failed but retry available, continuing loop...\");\n }\n response = verifyResponse;\n continue;\n }\n\n // No more actions - check final result\n if (!actionResult.success) {\n complete(\"fail\");\n return {\n errors: {\n apple_pay:\n verifyResponse.error_message_for_customer ||\n verifyResponse.error_message_for_debug ||\n actionResult.error ||\n \"3DS authentication failed\",\n },\n };\n }\n\n // 3DS succeeded\n complete(verifyResponse.charge_status === \"success\" ? \"success\" : \"fail\");\n return toApplePayResult(verifyResponse, secureToken);\n }\n\n // Check for max attempts exceeded\n if (userActionCount >= MAX_USER_ACTIONS) {\n complete(\"fail\");\n return { errors: { apple_pay: \"Too many authentication attempts. Please try again.\" } };\n }\n\n // No 3DS required - complete with result\n complete(response.charge_status === \"success\" ? \"success\" : \"fail\");\n return toApplePayResult(response, secureToken);\n}\n\n// =============================================================================\n// Main Submit Function\n// =============================================================================\n\nconst defSubmitPayment = (states: PaymentKitStates) => {\n const submitPayment: TInternalFuncs[\"submitPayment\"] = async (_fields, options) => {\n const { apiBaseUrl, secureToken, environment } = states;\n const applePayOptions = options as ApplePaySubmitOptions;\n\n // Validate options\n const validationError = validateOptions(applePayOptions);\n if (validationError) {\n return { errors: validationError };\n }\n\n try {\n const mockScenarioStr = getMockScenarioStr(applePayOptions.mockScenario);\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[ApplePay] Using checkout_request_id: ${checkoutRequestId}`);\n\n // Check if we have prepared Stripe state\n if (preparedStripeState?.adapter.isPrepared()) {\n console.log(\"[ApplePay] Using prepared Stripe state for immediate sheet display\");\n\n // Show Apple Pay sheet IMMEDIATELY using the prepared PaymentRequest\n const paymentResultPromise = preparedStripeState.adapter.showPreparedPaymentSheet();\n const paymentResult = await paymentResultPromise;\n\n if (!paymentResult.success) {\n clearPreparedApplePay();\n\n if (\"cancelled\" in paymentResult && paymentResult.cancelled) {\n return { errors: { apple_pay: \"Apple Pay cancelled by user\" } };\n }\n const errorMessage = \"error\" in paymentResult ? paymentResult.error : \"Unknown error\";\n return { errors: { apple_pay: errorMessage } };\n }\n\n const { paymentMethodId, paymentMethodEvent, billingDetails } = paymentResult;\n\n // Confirm with backend using the PaymentMethod ID\n const confirmResult = await callStripeConfirmEndpoint(\n apiBaseUrl,\n secureToken,\n paymentMethodId,\n mockScenarioStr,\n preparedStripeState.checkoutRequestId,\n billingDetails?.email,\n );\n\n // Complete Apple Pay UI based on result\n if (confirmResult.data) {\n paymentMethodEvent.complete(\"success\");\n clearPreparedApplePay();\n return confirmResult;\n } else {\n paymentMethodEvent.complete(\"fail\");\n clearPreparedApplePay();\n return confirmResult;\n }\n }\n\n // Check if this is an Airwallex processor - route directly to Airwallex flow\n if (applePayOptions.processorType === \"airwallex\") {\n console.log(\"[ApplePay] Running Airwallex flow (processorType=airwallex)\");\n // Merge prepare-time state into submit options so country/currency/amount/merchantName\n // are available even if the merchant only provided them at prepare time\n if (preparedAirwallexState) {\n if (applePayOptions.country == null) applePayOptions.country = preparedAirwallexState.country;\n if (applePayOptions.currency == null) applePayOptions.currency = preparedAirwallexState.currency;\n if (applePayOptions.amount == null) applePayOptions.amount = preparedAirwallexState.amount;\n if (applePayOptions.merchantName == null) applePayOptions.merchantName = preparedAirwallexState.merchantName;\n }\n try {\n return await runAirwallexFlow(apiBaseUrl, secureToken, applePayOptions, mockScenarioStr, checkoutRequestId);\n } finally {\n preparedAirwallexState = null;\n }\n }\n\n // No prepared state for Stripe - call start endpoint\n const startResult = await callStripeStartEndpoint(\n apiBaseUrl,\n secureToken,\n applePayOptions,\n mockScenarioStr,\n checkoutRequestId,\n );\n\n if (startResult.error || !startResult.data) {\n return { errors: { apple_pay: startResult.error || \"Failed to start Apple Pay\" } };\n }\n\n const startData = startResult.data;\n\n // Stripe flow without prepared state - this may fail due to user gesture requirements\n console.warn(\"[ApplePay] Stripe flow without prepared state - may fail due to user gesture requirements\");\n\n if (!startData.stripe_pk) {\n return { errors: { apple_pay: \"Stripe publishable key not provided\" } };\n }\n\n const { adapter, error: adapterError } = initializeStripeAdapter(\n startData.stripe_pk,\n applePayOptions.mockScenario,\n );\n if (!adapter) {\n return { errors: { apple_pay: adapterError || \"Failed to initialize Stripe adapter\" } };\n }\n\n // This will likely fail due to user gesture requirements\n const prepareResult = await adapter.preparePaymentRequest({\n country: startData.country,\n currency: startData.currency.toLowerCase(),\n total: { label: \"Total\", amount: startData.amount },\n });\n\n if (!prepareResult.success || !prepareResult.applePay) {\n return { errors: { apple_pay: prepareResult.error || \"Apple Pay not available\" } };\n }\n\n const paymentResult = await adapter.showPreparedPaymentSheet();\n\n if (!paymentResult.success) {\n if (\"cancelled\" in paymentResult && paymentResult.cancelled) {\n return { errors: { apple_pay: \"Apple Pay cancelled by user\" } };\n }\n const errorMessage = \"error\" in paymentResult ? paymentResult.error : \"Unknown error\";\n return { errors: { apple_pay: errorMessage } };\n }\n\n const { paymentMethodId, paymentMethodEvent, billingDetails } = paymentResult;\n\n const confirmResult = await callStripeConfirmEndpoint(\n apiBaseUrl,\n secureToken,\n paymentMethodId,\n mockScenarioStr,\n checkoutRequestId,\n billingDetails?.email,\n );\n\n if (confirmResult.data) {\n paymentMethodEvent.complete(\"success\");\n return confirmResult;\n } else {\n paymentMethodEvent.complete(\"fail\");\n return confirmResult;\n }\n } catch (error) {\n clearPreparedApplePay();\n return { errors: { apple_pay: `Apple Pay error: ${error}` } };\n }\n };\n\n return submitPayment;\n};\n\n// =============================================================================\n// Payment Method Definition\n// =============================================================================\n\nconst ApplePayPaymentMethod = definePaymentMethod((paymentKitStates) => {\n return {\n name: \"apple_pay\",\n externalFuncs: {\n prepareApplePay: (options: ApplePaySubmitOptions) =>\n prepareApplePay(\n paymentKitStates.apiBaseUrl,\n paymentKitStates.secureToken,\n options,\n paymentKitStates.environment,\n ),\n },\n internalFuncs: {\n submitPayment: defSubmitPayment(paymentKitStates),\n cleanup: () => {\n clearPreparedApplePay();\n },\n },\n };\n});\n\nexport { ApplePayMockScenario };\n\nexport default ApplePayPaymentMethod;\n"],"mappings":";;;;;;AAmHA,IAAIA,sBAA0D;AAW9D,IAAIC,yBAAwD;AAa5D,eAAe,QACb,KACA,SACA,mBACuC;CACvC,MAAM,UAAU,IAAI,QAAQ,QAAQ,QAAQ;AAC5C,KAAI,kBACF,SA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,cAAc,UAChD,QAAO,EAAE,QAAQ,EAAE,WAAW,+BAA+B,EAAE;AAGjE,WAAO,EAAE,QAAQ,EAAE,WADE,WAAW,gBAAgB,cAAc,QAAQ,iBAC1B,EAAE;;GAGhD,MAAM,EAAE,iBAAiB,oBAAoB,mBAAmB;GAEhE,MAAM,gBAAgB,MAAM,0BAC1B,YACA,aACA,iBACA,iBACA,mBACA,gBAAgB,MACjB;AAED,OAAI,cAAc,MAAM;AACtB,uBAAmB,SAAS,UAAU;AACtC,WAAO;UACF;AACL,uBAAmB,SAAS,OAAO;AACnC,WAAO;;WAEF,OAAO;AACd,0BAAuB;AACvB,UAAO,EAAE,QAAQ,EAAE,WAAW,oBAAoB,SAAS,EAAE;;;AAIjE,QAAO;;AAOT,MAAM,wBAAwB,qBAAqB,qBAAqB;AACtE,QAAO;EACL,MAAM;EACN,eAAe,EACb,kBAAkB,YAChB,gBACE,iBAAiB,YACjB,iBAAiB,aACjB,SACA,iBAAiB,YAClB,EACJ;EACD,eAAe;GACb,eAAe,iBAAiB,iBAAiB;GACjD,eAAe;AACb,2BAAuB;;GAE1B;EACF;EACD;AAIF,wBAAe"}
|
|
1
|
+
{"version":3,"file":"apple-pay.mjs","names":["preparedStripeState: PreparedStripeApplePayState | null","preparedAirwallexState: PreparedAirwallexState | null","applePayScriptLoadPromise: Promise<void> | null","airwallexMockScenario: AirwallexApplePayMockScenario","config: AirwallexApplePayConfig","submitPayment: TInternalFuncs[\"submitPayment\"]","paymentResult","confirmResult","paymentMethodId","billingDetails","autoPrepareConfig: AutoPrepareConfig | null","onApplePayReadyCallbacks: ((isReady: boolean) => void)[]","pendingAutoPrepareArgs: { apiBaseUrl: string; secureToken: string; environment: string } | null","pendingPrepareResolvers: (() => void)[]"],"sources":["../../src/payment-methods/apple-pay.ts"],"sourcesContent":["import type { PaymentKitErrors, PaymentKitStates, TInternalFuncs } from \"../types\";\nimport { collectFraudMetadata, definePaymentMethod, getOrCreateCheckoutRequestId } from \"../utils\";\nimport {\n AirwallexApplePayAdapter,\n type AirwallexApplePayConfig,\n AirwallexApplePayMockScenario,\n type ApplePayEncryptedToken,\n} from \"./airwallex-apple-pay-adapter\";\nimport { handleNextAction } from \"./next-action-handlers\";\nimport { ApplePayMockScenario, StripeApplePayAdapter } from \"./stripe-apple-pay-adapter\";\n\n// Apple Pay-specific types\nexport type ApplePayCustomerInfo = {\n first_name: string;\n last_name: string;\n email?: string;\n};\n\nexport type ApplePayStartRequest = {\n processor_id: string;\n customer_info: ApplePayCustomerInfo;\n fraud_metadata: {\n ipAddress?: string;\n browserInfo?: { [key: string]: unknown };\n processorFraudInfo?: { [key: string]: unknown };\n };\n mock_scenario?: string;\n // Airwallex-specific fields (sent on /start for merchant validation)\n validation_url?: string;\n initiative_context?: string;\n};\n\nexport type ApplePayStartResponse = {\n checkout_attempt_id: string;\n amount: number;\n currency: string;\n country: string;\n\n // Processor discriminator\n processor: \"stripe\" | \"airwallex\";\n\n // Stripe-specific fields (when processor=\"stripe\")\n client_secret?: string;\n stripe_pk?: string;\n\n // Airwallex-specific fields (when processor=\"airwallex\")\n merchant_session?: { [key: string]: unknown }; // Apple merchant session for completeMerchantValidation()\n};\n\n// Airwallex 3DS next action type (matches backend snake_case response)\nexport type Airwallex3dsNextAction = {\n type: \"airwallex_3ds\";\n url: string;\n};\n\nexport type ApplePayConfirmRequest = {\n // Stripe: Send PaymentMethod ID\n payment_method_id?: string;\n // Airwallex: Send encrypted Apple Pay token\n apple_pay_token?: ApplePayEncryptedToken | { [key: string]: unknown };\n // Email from payment sheet (Stripe Apple Pay) — used to fill missing customer email\n payer_email?: string;\n mock_scenario?: string;\n};\n\nexport type ApplePayConfirmResponse = {\n charge_status: \"success\" | \"fail\" | \"pending\";\n transaction_id?: string;\n error_code?: string;\n error_message_for_customer?: string;\n error_message_for_debug?: string;\n checkout_attempt_id: string;\n checkout_session_id?: string;\n next_action?: Airwallex3dsNextAction; // Present when charge_status=\"pending\" for 3DS\n payment_intent_id?: string;\n customer_id?: string;\n payment_method_id?: string;\n processor_used?: string;\n subscription_id?: string;\n invoice_id?: string;\n invoice_number?: number;\n card_brand?: string;\n card_last4?: string;\n card_exp_month?: number;\n card_exp_year?: number;\n};\n\nexport type ApplePaySubmitOptions = {\n /** Processor external ID — optional when using auto-prepare (SDK fetches from checkout session) */\n processorId?: string;\n processorType?: \"stripe\" | \"airwallex\";\n customerInfo: ApplePayCustomerInfo;\n mockScenario?: ApplePayMockScenario;\n amount?: number; // Amount in atomic units (cents) for Apple Pay sheet display\n currency?: string; // Currency code (e.g., \"usd\")\n /** Country code — optional when using auto-prepare (fetched from backend) */\n country?: string;\n merchantName?: string; // Merchant display name on Apple Pay sheet\n};\n\ntype ApplePayResult =\n | { data: { [key: string]: unknown }; errors?: undefined }\n | { data?: undefined; errors: PaymentKitErrors };\n\n// =============================================================================\n// Prepared Payment State (for Stripe pre-fetching before click)\n// =============================================================================\n\ntype PreparedStripeApplePayState = {\n processor: \"stripe\";\n adapter: StripeApplePayAdapter;\n startData: ApplePayStartResponse;\n mockScenarioStr?: string;\n checkoutRequestId: string;\n};\n\n// Global state to store prepared Apple Pay data (Stripe only - Airwallex uses native session)\nlet preparedStripeState: PreparedStripeApplePayState | null = null;\n\n// Prepared Airwallex state — persists options from prepare call for use at submit time\n// The amount field is fetched from the session via /session-info endpoint to fix\n// the $0.00 bug where options.amount was undefined and defaulted to 0.\ntype PreparedAirwallexState = {\n country: string;\n currency?: string;\n amount?: number;\n merchantName?: string;\n};\nlet preparedAirwallexState: PreparedAirwallexState | null = null;\n\n// Response type for Airwallex Apple Pay session-info endpoint\ntype AirwallexSessionInfoResponse = {\n amount: number;\n currency: string;\n country: string;\n};\n\n// =============================================================================\n// Auto-Prepare State\n// =============================================================================\n\ntype AutoPrepareConfig = {\n processorId: string;\n processorType: \"airwallex\" | \"stripe\" | undefined;\n};\n\ntype CheckoutSessionConfig = {\n express_checkout_processor_id?: string | null;\n express_checkout_processor_type?: string | null;\n};\n\n// =============================================================================\n// Apple Pay SDK Loader\n// =============================================================================\n\n// Loads Apple's JS SDK, which makes window.ApplePaySession available in non-Safari\n// browsers (Chrome, Firefox, etc.) and enables the \"Scan Code with iPhone\" QR flow.\nlet applePayScriptLoadPromise: Promise<void> | null = null;\nasync function loadApplePayScript(): Promise<void> {\n if (typeof window === \"undefined\") return;\n if (window.ApplePaySession) return;\n if (document.getElementById(\"__pk_apple_pay_sdk\")) {\n // Tag exists — if we have a cached promise, wait for it; otherwise the tag\n // already resolved (e.g. after a module reload) so return immediately.\n return applePayScriptLoadPromise ?? Promise.resolve();\n }\n applePayScriptLoadPromise = new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.id = \"__pk_apple_pay_sdk\";\n script.src = \"https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js\";\n script.crossOrigin = \"anonymous\";\n // NOTE: Apple doesn't publish stable SRI hashes for the 1.latest pointer,\n // so integrity checking is omitted. CSP must allow script-src https://applepay.cdn-apple.com.\n script.onload = () => resolve();\n script.onerror = () => {\n // Clear cached state so the next prepareApplePay call can retry.\n applePayScriptLoadPromise = null;\n document.getElementById(\"__pk_apple_pay_sdk\")?.remove();\n reject(new Error(\"Failed to load Apple Pay SDK\"));\n };\n document.head.appendChild(script);\n });\n return applePayScriptLoadPromise;\n}\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\nasync function apiCall<T>(\n url: string,\n options: RequestInit,\n checkoutRequestId?: string,\n): Promise<{ data?: T; error?: string }> {\n const headers = new Headers(options.headers);\n if (checkoutRequestId) {\n headers.set(\"x-request-id\", checkoutRequestId);\n }\n\n const response = await fetch(url, { ...options, headers });\n if (!response.ok) {\n let errorMessage = `Request failed (${response.status})`;\n try {\n const errorData = await response.json();\n errorMessage = errorData.detail || errorMessage;\n } catch {\n errorMessage = response.statusText || errorMessage;\n }\n return { error: errorMessage };\n }\n return { data: await response.json() };\n}\n\nfunction validateOptions(options: ApplePaySubmitOptions): PaymentKitErrors | null {\n if (!options?.processorId) {\n return { processor_id: \"Processor ID is required\" };\n }\n // For Airwallex, country is required (either directly or from prepared state)\n if (options.processorType === \"airwallex\" && !options.country && !preparedAirwallexState?.country) {\n return { country: \"Country is required for Airwallex Apple Pay\" };\n }\n return null;\n}\n\nfunction getMockScenarioStr(mockScenario?: ApplePayMockScenario): string | undefined {\n return mockScenario && mockScenario !== ApplePayMockScenario.None ? mockScenario : undefined;\n}\n\n// =============================================================================\n// Stripe Apple Pay Flow\n// =============================================================================\n\nasync function callStripeStartEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n): Promise<{ data?: ApplePayStartResponse; error?: string }> {\n return apiCall<ApplePayStartResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/apple-pay/start`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n processor_id: options.processorId,\n customer_info: options.customerInfo,\n fraud_metadata: collectFraudMetadata(),\n mock_scenario: mockScenarioStr,\n } as ApplePayStartRequest),\n },\n checkoutRequestId,\n );\n}\n\nfunction initializeStripeAdapter(\n stripePk: string,\n mockScenario?: ApplePayMockScenario,\n): { adapter?: StripeApplePayAdapter; error?: string } {\n const adapter = new StripeApplePayAdapter(mockScenario);\n\n if (!adapter.initialize(stripePk)) {\n return { error: 'Stripe.js not loaded. Add <script src=\"https://js.stripe.com/v3/\"></script> to your page.' };\n }\n\n return { adapter };\n}\n\nasync function callStripeConfirmEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n paymentMethodId: string,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n payerEmail?: string,\n): Promise<ApplePayResult> {\n const result = await apiCall<ApplePayConfirmResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/apple-pay/confirm`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n payment_method_id: paymentMethodId,\n payer_email: payerEmail,\n mock_scenario: mockScenarioStr,\n } as ApplePayConfirmRequest),\n },\n checkoutRequestId,\n );\n\n if (result.error || !result.data) {\n return { errors: { apple_pay: result.error || \"Failed to confirm payment\" } };\n }\n\n const confirmData = result.data;\n\n if (confirmData.charge_status === \"success\") {\n return {\n data: {\n id: confirmData.transaction_id,\n checkoutAttemptId: confirmData.checkout_attempt_id,\n checkoutSessionId: confirmData.checkout_session_id ?? secureToken,\n state: \"checkout_succeeded\",\n paymentIntentId: confirmData.payment_intent_id,\n customerId: confirmData.customer_id,\n paymentMethodId: confirmData.payment_method_id,\n processorUsed: confirmData.processor_used,\n subscriptionId: confirmData.subscription_id,\n invoiceId: confirmData.invoice_id,\n invoiceNumber: confirmData.invoice_number,\n cardBrand: confirmData.card_brand,\n cardLast4: confirmData.card_last4,\n cardExpMonth: confirmData.card_exp_month,\n cardExpYear: confirmData.card_exp_year,\n errorCode: confirmData.error_code,\n errorMessageForCustomer: confirmData.error_message_for_customer,\n errorMessageForDebug: confirmData.error_message_for_debug,\n nextAction: confirmData.next_action,\n },\n };\n }\n\n return {\n errors: {\n apple_pay: confirmData.error_message_for_customer || confirmData.error_message_for_debug || \"Payment failed\",\n },\n };\n}\n\n// =============================================================================\n// Prepare Function (call BEFORE the click handler)\n// =============================================================================\n\n/**\n * Pre-fetch Apple Pay data and prepare the PaymentRequest.\n * Call this when the checkout page loads, NOT in the click handler.\n *\n * For Stripe: pre-fetches data and prepares PaymentRequest for immediate show.\n * For Airwallex: returns success with processor=\"airwallex\" so submit uses native ApplePaySession.\n *\n * @deprecated The SDK now calls this automatically on init. Use `onApplePayReady` to observe\n * readiness and `notifyAmountChanged` to trigger re-prepare after amount changes.\n */\nexport async function prepareApplePay(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n environment: string,\n): Promise<{ success: boolean; error?: string; applePay?: boolean }> {\n console.log(\"[ApplePay] prepareApplePay called\");\n\n // Clear any previous state\n preparedStripeState = null;\n\n const mockScenarioStr = getMockScenarioStr(options.mockScenario);\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[ApplePay] Using checkout_request_id: ${checkoutRequestId}`);\n\n // Airwallex: Load Apple Pay SDK (enables QR code flow in non-Safari browsers),\n // then fetch session info to get the correct amount from line items.\n // This fixes the $0.00 bug where options.amount was undefined and defaulted to 0.\n if (options.processorType === \"airwallex\") {\n console.log(\"[ApplePay] Airwallex processor - loading Apple Pay SDK, fetching session info for amount\");\n\n // In mock mode, skip SDK loading and availability check (jsdom has no ApplePaySession)\n if (!mockScenarioStr) {\n try {\n await loadApplePayScript();\n } catch (err) {\n console.error(\"[ApplePay] Failed to load Apple Pay SDK:\", err);\n return { success: false, error: \"Failed to load Apple Pay\" };\n }\n\n let canMake = false;\n try {\n canMake = !!window.ApplePaySession?.canMakePayments();\n } catch {\n canMake = false;\n }\n if (!canMake) {\n console.log(\"[ApplePay] Apple Pay not available on this device/browser\");\n return { success: false, error: \"Apple Pay not available on this device\" };\n }\n }\n\n // Fetch session info (amount, currency, country) from backend\n const sessionInfoResult = await callAirwallexSessionInfoEndpoint(apiBaseUrl, secureToken, checkoutRequestId);\n\n if (sessionInfoResult.error || !sessionInfoResult.data) {\n console.error(\"[ApplePay] Failed to fetch session info:\", sessionInfoResult.error);\n return { success: false, error: sessionInfoResult.error || \"Failed to fetch Apple Pay session info\" };\n }\n\n console.log(\"[ApplePay] Got session info:\", sessionInfoResult.data);\n const resolvedAmount = sessionInfoResult.data.amount;\n const resolvedCurrency = sessionInfoResult.data.currency;\n const resolvedCountry = sessionInfoResult.data.country || options.country;\n\n preparedAirwallexState = {\n country: resolvedCountry,\n currency: resolvedCurrency,\n amount: resolvedAmount,\n merchantName: options.merchantName,\n };\n console.log(\"[ApplePay] Airwallex prepared state:\", preparedAirwallexState);\n return { success: true, applePay: true };\n }\n\n // Call Stripe start endpoint to get PaymentIntent details\n const startResult = await callStripeStartEndpoint(\n apiBaseUrl,\n secureToken,\n options,\n mockScenarioStr,\n checkoutRequestId,\n );\n if (startResult.error || !startResult.data) {\n return { success: false, error: startResult.error || \"Failed to start Apple Pay\" };\n }\n\n const startData = startResult.data;\n\n // Initialize Stripe adapter\n if (!startData.stripe_pk) {\n return { success: false, error: \"Stripe publishable key not provided\" };\n }\n\n const { adapter, error: adapterError } = initializeStripeAdapter(startData.stripe_pk, options.mockScenario);\n if (!adapter) {\n return { success: false, error: adapterError };\n }\n\n // Create PaymentRequest and call canMakePayment() (required before show())\n const prepareResult = await adapter.preparePaymentRequest({\n country: startData.country,\n currency: startData.currency.toLowerCase(),\n total: {\n label: \"Total\",\n amount: startData.amount,\n },\n });\n\n if (!prepareResult.success) {\n return {\n success: false,\n error: prepareResult.error || \"Failed to prepare payment request\",\n applePay: prepareResult.applePay,\n };\n }\n\n if (!prepareResult.applePay) {\n return {\n success: false,\n error: \"Apple Pay is not available on this device or Stripe account\",\n applePay: false,\n };\n }\n\n // Store the prepared state\n preparedStripeState = {\n processor: \"stripe\",\n adapter,\n startData,\n mockScenarioStr,\n checkoutRequestId,\n };\n\n console.log(\"[ApplePay] prepareApplePay success (Stripe), ready for click\");\n return { success: true, applePay: true };\n}\n\n/**\n * Check if Apple Pay has been prepared and is ready.\n */\nexport function isApplePayPrepared(): boolean {\n return (preparedStripeState?.adapter.isPrepared() ?? false) || preparedAirwallexState !== null;\n}\n\n/**\n * Clear prepared state (call on unmount or when checkout changes).\n */\nexport function clearPreparedApplePay(): void {\n if (preparedStripeState) {\n preparedStripeState.adapter.clearPrepared();\n }\n preparedStripeState = null;\n preparedAirwallexState = null;\n}\n\n// =============================================================================\n// Airwallex Apple Pay Flow\n// =============================================================================\n\n/**\n * Fetch session info (amount, currency, country) from the backend.\n * Called during prepareApplePay to get the correct amount BEFORE showing the payment sheet.\n * This fixes the $0.00 bug where options.amount was undefined and defaulted to 0.\n */\nasync function callAirwallexSessionInfoEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n checkoutRequestId?: string,\n): Promise<{ data?: AirwallexSessionInfoResponse; error?: string }> {\n return apiCall<AirwallexSessionInfoResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/session-info`,\n {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n },\n checkoutRequestId,\n );\n}\n\nasync function callAirwallexStartEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n validationUrl: string,\n initiativeContext: string,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n): Promise<{ data?: ApplePayStartResponse; error?: string }> {\n return apiCall<ApplePayStartResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/start`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n processor_id: options.processorId,\n customer_info: options.customerInfo,\n fraud_metadata: collectFraudMetadata(),\n validation_url: validationUrl,\n initiative_context: initiativeContext,\n mock_scenario: mockScenarioStr,\n } as ApplePayStartRequest),\n },\n checkoutRequestId,\n );\n}\n\nasync function callAirwallexConfirmEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n applePayToken: ApplePayEncryptedToken,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n payerEmail?: string,\n): Promise<ApplePayConfirmResponse> {\n const result = await apiCall<ApplePayConfirmResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/confirm`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n apple_pay_token: applePayToken,\n payer_email: payerEmail,\n mock_scenario: mockScenarioStr,\n } as ApplePayConfirmRequest),\n },\n checkoutRequestId,\n );\n\n if (result.error || !result.data) {\n return {\n charge_status: \"fail\",\n error_message_for_debug: result.error || \"Failed to confirm payment\",\n checkout_attempt_id: \"\",\n };\n }\n\n return result.data;\n}\n\nasync function callAirwallexVerifyEndpoint(\n apiBaseUrl: string,\n secureToken: string,\n checkoutRequestId?: string,\n): Promise<ApplePayConfirmResponse> {\n const result = await apiCall<ApplePayConfirmResponse>(\n `${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/verify`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n },\n checkoutRequestId,\n );\n\n if (result.error || !result.data) {\n return {\n charge_status: \"fail\",\n error_message_for_debug: result.error || \"Failed to verify payment\",\n checkout_attempt_id: \"\",\n };\n }\n\n return result.data;\n}\n\nfunction toApplePayResult(response: ApplePayConfirmResponse, secureToken: string): ApplePayResult {\n if (response.charge_status === \"success\") {\n return {\n data: {\n id: response.transaction_id,\n checkoutAttemptId: response.checkout_attempt_id,\n checkoutSessionId: response.checkout_session_id ?? secureToken,\n state: \"checkout_succeeded\",\n paymentIntentId: response.payment_intent_id,\n customerId: response.customer_id,\n paymentMethodId: response.payment_method_id,\n processorUsed: response.processor_used,\n subscriptionId: response.subscription_id,\n invoiceId: response.invoice_id,\n invoiceNumber: response.invoice_number,\n cardBrand: response.card_brand,\n cardLast4: response.card_last4,\n cardExpMonth: response.card_exp_month,\n cardExpYear: response.card_exp_year,\n errorCode: response.error_code,\n errorMessageForCustomer: response.error_message_for_customer,\n errorMessageForDebug: response.error_message_for_debug,\n nextAction: response.next_action,\n },\n };\n }\n return {\n errors: {\n apple_pay: response.error_message_for_customer || response.error_message_for_debug || \"Payment failed\",\n },\n };\n}\n\nconst MAX_USER_ACTIONS = 5;\n\n/**\n * Run the Airwallex Apple Pay flow with 3DS loop support.\n *\n * Flow:\n * 1. Show native ApplePaySession, call /start for merchant validation\n * 2. On payment authorized, call /confirm with token\n * 3. If 3DS required, handle it and call /verify\n * 4. Loop if more 3DS needed\n */\nasync function runAirwallexFlow(\n apiBaseUrl: string,\n secureToken: string,\n options: ApplePaySubmitOptions,\n mockScenarioStr?: string,\n checkoutRequestId?: string,\n): Promise<ApplePayResult> {\n // Convert mock scenario\n let airwallexMockScenario: AirwallexApplePayMockScenario = AirwallexApplePayMockScenario.None;\n if (options.mockScenario === ApplePayMockScenario.Success) {\n airwallexMockScenario = AirwallexApplePayMockScenario.Success;\n } else if (options.mockScenario === ApplePayMockScenario.Cancelled) {\n airwallexMockScenario = AirwallexApplePayMockScenario.Cancelled;\n }\n\n // Defense-in-depth: validateOptions should catch this earlier, but guard against\n // future callers that bypass validation to avoid an unhandled TypeError on `.toUpperCase()`\n if (!options.country) {\n return { errors: { apple_pay: \"Country is required for Airwallex Apple Pay\" } };\n }\n\n // Auto-fetch amount from session if not provided (e.g. merchant didn't call prepareApplePay first)\n if (!options.amount) {\n const sessionInfoResult = await callAirwallexSessionInfoEndpoint(apiBaseUrl, secureToken, checkoutRequestId);\n if (sessionInfoResult.data) {\n options.amount = sessionInfoResult.data.amount;\n options.currency = options.currency || sessionInfoResult.data.currency;\n options.country = options.country || sessionInfoResult.data.country;\n }\n }\n\n // Initialize adapter\n const adapter = new AirwallexApplePayAdapter(airwallexMockScenario);\n\n const config: AirwallexApplePayConfig = {\n amount: options.amount || 0,\n currency: (options.currency || \"USD\").toUpperCase(),\n country: options.country.toUpperCase(),\n merchantName: options.merchantName || \"Total\",\n };\n\n if (!adapter.initialize(config)) {\n return { errors: { apple_pay: \"Apple Pay not available on this device\" } };\n }\n\n const canPay = await adapter.canMakePayment();\n if (!canPay) {\n return { errors: { apple_pay: \"Apple Pay not available on this device\" } };\n }\n\n // Get current domain for initiative_context\n const initiativeContext = typeof window !== \"undefined\" ? window.location.hostname : \"\";\n\n // In mock mode, call /start first to create checkout attempt (mock adapter skips merchant validation)\n if (airwallexMockScenario !== AirwallexApplePayMockScenario.None) {\n const startResult = await callAirwallexStartEndpoint(\n apiBaseUrl,\n secureToken,\n options,\n \"https://mock-apple-pay-gateway.example.com/paymentservices/startSession\",\n initiativeContext,\n mockScenarioStr,\n checkoutRequestId,\n );\n if (startResult.error || !startResult.data) {\n return { errors: { apple_pay: startResult.error || \"Failed to start mock checkout\" } };\n }\n }\n\n // Show Apple Pay sheet with merchant validation callback\n const paymentResult = await adapter.showPaymentSheet(async (validationUrl: string) => {\n // Call /start endpoint for merchant validation\n const startResult = await callAirwallexStartEndpoint(\n apiBaseUrl,\n secureToken,\n options,\n validationUrl,\n initiativeContext,\n mockScenarioStr,\n checkoutRequestId,\n );\n\n if (startResult.error || !startResult.data) {\n return { error: startResult.error || \"Merchant validation failed\" };\n }\n\n if (!startResult.data.merchant_session) {\n return { error: \"No merchant session returned from server\" };\n }\n\n return { merchantSession: startResult.data.merchant_session };\n });\n\n if (!paymentResult.success) {\n if (\"cancelled\" in paymentResult && paymentResult.cancelled) {\n return { errors: { apple_pay: \"Apple Pay cancelled by user\" } };\n }\n return { errors: { apple_pay: paymentResult.error || \"Apple Pay failed\" } };\n }\n\n const { token, complete, payerEmail } = paymentResult;\n\n // Call /confirm with the token\n let response = await callAirwallexConfirmEndpoint(\n apiBaseUrl,\n secureToken,\n token,\n mockScenarioStr,\n checkoutRequestId,\n payerEmail,\n );\n\n // Handle 3DS loop\n let userActionCount = 0;\n while (response.charge_status === \"pending\" && response.next_action && userActionCount < MAX_USER_ACTIONS) {\n userActionCount++;\n\n // Handle 3DS challenge — Airwallex3dsNextAction is structurally identical to SDK's Airwallex3dsAction\n const nextAction = response.next_action as Airwallex3dsNextAction;\n const actionResult = await handleNextAction({ type: nextAction.type, url: nextAction.url });\n\n // Call verify endpoint\n const verifyResponse = await callAirwallexVerifyEndpoint(apiBaseUrl, secureToken, checkoutRequestId);\n\n // Check if another 3DS action is required\n if (verifyResponse.charge_status === \"pending\" && verifyResponse.next_action) {\n if (!actionResult.success) {\n console.log(\"[ApplePay:Airwallex] 3DS failed but retry available, continuing loop...\");\n }\n response = verifyResponse;\n continue;\n }\n\n // No more actions - check final result\n if (!actionResult.success) {\n complete(\"fail\");\n return {\n errors: {\n apple_pay:\n verifyResponse.error_message_for_customer ||\n verifyResponse.error_message_for_debug ||\n actionResult.error ||\n \"3DS authentication failed\",\n },\n };\n }\n\n // 3DS succeeded\n complete(verifyResponse.charge_status === \"success\" ? \"success\" : \"fail\");\n return toApplePayResult(verifyResponse, secureToken);\n }\n\n // Check for max attempts exceeded\n if (userActionCount >= MAX_USER_ACTIONS) {\n complete(\"fail\");\n return { errors: { apple_pay: \"Too many authentication attempts. Please try again.\" } };\n }\n\n // No 3DS required - complete with result\n complete(response.charge_status === \"success\" ? \"success\" : \"fail\");\n return toApplePayResult(response, secureToken);\n}\n\n// =============================================================================\n// Main Submit Function\n// =============================================================================\n\nconst defSubmitPayment = (\n states: PaymentKitStates,\n getAutoPrepareConfig: () => AutoPrepareConfig | null,\n onClearPrepared: () => void,\n) => {\n const submitPayment: TInternalFuncs[\"submitPayment\"] = async (_fields, options) => {\n const { apiBaseUrl, secureToken, environment } = states;\n const applePayOptions = options as ApplePaySubmitOptions;\n\n // Fill in processorId/processorType from auto-prepare config if merchant didn't provide them\n const autoPrepareConfig = getAutoPrepareConfig();\n if (!applePayOptions.processorId && autoPrepareConfig?.processorId) {\n applePayOptions.processorId = autoPrepareConfig.processorId;\n }\n if (!applePayOptions.processorType && autoPrepareConfig?.processorType) {\n applePayOptions.processorType = autoPrepareConfig.processorType;\n }\n\n // Validate options\n const validationError = validateOptions(applePayOptions);\n if (validationError) {\n return { errors: validationError };\n }\n\n try {\n const mockScenarioStr = getMockScenarioStr(applePayOptions.mockScenario);\n const checkoutRequestId = getOrCreateCheckoutRequestId(environment);\n console.log(`[ApplePay] Using checkout_request_id: ${checkoutRequestId}`);\n\n // Check if we have prepared Stripe state\n if (preparedStripeState?.adapter.isPrepared()) {\n console.log(\"[ApplePay] Using prepared Stripe state for immediate sheet display\");\n\n // Show Apple Pay sheet IMMEDIATELY using the prepared PaymentRequest\n const paymentResultPromise = preparedStripeState.adapter.showPreparedPaymentSheet();\n const paymentResult = await paymentResultPromise;\n\n if (!paymentResult.success) {\n clearPreparedApplePay();\n\n if (\"cancelled\" in paymentResult && paymentResult.cancelled) {\n return { errors: { apple_pay: \"Apple Pay cancelled by user\" } };\n }\n const errorMessage = \"error\" in paymentResult ? paymentResult.error : \"Unknown error\";\n return { errors: { apple_pay: errorMessage } };\n }\n\n const { paymentMethodId, paymentMethodEvent, billingDetails } = paymentResult;\n\n // Confirm with backend using the PaymentMethod ID\n const confirmResult = await callStripeConfirmEndpoint(\n apiBaseUrl,\n secureToken,\n paymentMethodId,\n mockScenarioStr,\n preparedStripeState.checkoutRequestId,\n billingDetails?.email,\n );\n\n // Complete Apple Pay UI based on result\n if (confirmResult.data) {\n paymentMethodEvent.complete(\"success\");\n clearPreparedApplePay();\n return confirmResult;\n } else {\n paymentMethodEvent.complete(\"fail\");\n clearPreparedApplePay();\n return confirmResult;\n }\n }\n\n // Check if this is an Airwallex processor - route directly to Airwallex flow\n if (applePayOptions.processorType === \"airwallex\") {\n console.log(\"[ApplePay] Running Airwallex flow (processorType=airwallex)\");\n // Merge prepare-time state into submit options so country/currency/amount/merchantName\n // are available even if the merchant only provided them at prepare time\n if (preparedAirwallexState) {\n if (applePayOptions.country == null) applePayOptions.country = preparedAirwallexState.country;\n if (applePayOptions.currency == null) applePayOptions.currency = preparedAirwallexState.currency;\n if (applePayOptions.amount == null) applePayOptions.amount = preparedAirwallexState.amount;\n if (applePayOptions.merchantName == null) applePayOptions.merchantName = preparedAirwallexState.merchantName;\n }\n try {\n return await runAirwallexFlow(apiBaseUrl, secureToken, applePayOptions, mockScenarioStr, checkoutRequestId);\n } finally {\n preparedAirwallexState = null;\n }\n }\n\n // No prepared state for Stripe - call start endpoint\n const startResult = await callStripeStartEndpoint(\n apiBaseUrl,\n secureToken,\n applePayOptions,\n mockScenarioStr,\n checkoutRequestId,\n );\n\n if (startResult.error || !startResult.data) {\n return { errors: { apple_pay: startResult.error || \"Failed to start Apple Pay\" } };\n }\n\n const startData = startResult.data;\n\n // Stripe flow without prepared state - this may fail due to user gesture requirements\n console.warn(\"[ApplePay] Stripe flow without prepared state - may fail due to user gesture requirements\");\n\n if (!startData.stripe_pk) {\n return { errors: { apple_pay: \"Stripe publishable key not provided\" } };\n }\n\n const { adapter, error: adapterError } = initializeStripeAdapter(\n startData.stripe_pk,\n applePayOptions.mockScenario,\n );\n if (!adapter) {\n return { errors: { apple_pay: adapterError || \"Failed to initialize Stripe adapter\" } };\n }\n\n // This will likely fail due to user gesture requirements\n const prepareResult = await adapter.preparePaymentRequest({\n country: startData.country,\n currency: startData.currency.toLowerCase(),\n total: { label: \"Total\", amount: startData.amount },\n });\n\n if (!prepareResult.success || !prepareResult.applePay) {\n return { errors: { apple_pay: prepareResult.error || \"Apple Pay not available\" } };\n }\n\n const paymentResult = await adapter.showPreparedPaymentSheet();\n\n if (!paymentResult.success) {\n if (\"cancelled\" in paymentResult && paymentResult.cancelled) {\n return { errors: { apple_pay: \"Apple Pay cancelled by user\" } };\n }\n const errorMessage = \"error\" in paymentResult ? paymentResult.error : \"Unknown error\";\n return { errors: { apple_pay: errorMessage } };\n }\n\n const { paymentMethodId, paymentMethodEvent, billingDetails } = paymentResult;\n\n const confirmResult = await callStripeConfirmEndpoint(\n apiBaseUrl,\n secureToken,\n paymentMethodId,\n mockScenarioStr,\n checkoutRequestId,\n billingDetails?.email,\n );\n\n if (confirmResult.data) {\n paymentMethodEvent.complete(\"success\");\n return confirmResult;\n } else {\n paymentMethodEvent.complete(\"fail\");\n return confirmResult;\n }\n } catch (error) {\n onClearPrepared();\n return { errors: { apple_pay: `Apple Pay error: ${error}` } };\n }\n };\n\n return submitPayment;\n};\n\n// =============================================================================\n// Payment Method Definition\n// =============================================================================\n\nconst ApplePayPaymentMethod = definePaymentMethod((paymentKitStates) => {\n const { apiBaseUrl, secureToken, environment } = paymentKitStates;\n\n // Per-instance auto-prepare state — isolated from other ApplePayPaymentMethod instances.\n // Note: preparedStripeState and preparedAirwallexState remain module-level globals (pre-existing\n // architectural constraint shared across the file). Full per-instance isolation for those fields\n // would require threading them through prepareApplePay, runAirwallexFlow, validateOptions, and\n // defSubmitPayment — tracked as tech debt.\n let autoPrepareConfig: AutoPrepareConfig | null = null;\n let onApplePayReadyCallbacks: ((isReady: boolean) => void)[] = [];\n let isApplePayReadyState = false;\n let autoPrepareInProgress = false;\n // Incremented by cleanup() so that in-flight prepares can detect staleness and skip writes.\n let cleanupGeneration = 0;\n // Stores pending retry args when notifyAmountChanged is called while a prepare is in flight.\n let pendingAutoPrepareArgs: { apiBaseUrl: string; secureToken: string; environment: string } | null = null;\n // Resolvers waiting for a queued retry to complete (for correct notifyAmountChanged await).\n let pendingPrepareResolvers: (() => void)[] = [];\n\n function instanceSetApplePayReady(ready: boolean): void {\n isApplePayReadyState = ready;\n for (const cb of onApplePayReadyCallbacks) cb(ready);\n }\n\n function instanceClearPreparedApplePay(): void {\n clearPreparedApplePay();\n instanceSetApplePayReady(false);\n }\n\n async function instanceAutoPrepare(apBase: string, sToken: string, env: string): Promise<void> {\n if (autoPrepareInProgress) {\n // A prepare is already in flight; queue a retry and return a promise that resolves after it.\n pendingAutoPrepareArgs = { apiBaseUrl: apBase, secureToken: sToken, environment: env };\n return new Promise<void>((resolve) => pendingPrepareResolvers.push(resolve));\n }\n autoPrepareInProgress = true;\n // Capture generation so we can detect if cleanup() is called while we await.\n const capturedGeneration = cleanupGeneration;\n instanceSetApplePayReady(false);\n\n try {\n const result = await apiCall<CheckoutSessionConfig>(`${apBase}/api/checkout-sessions/token/${sToken}`, {\n method: \"GET\",\n });\n\n if (cleanupGeneration !== capturedGeneration) return;\n\n if (result.error || !result.data) {\n console.warn(\"[ApplePay] Auto-prepare: failed to fetch session config:\", result.error);\n return;\n }\n\n const processorId = result.data.express_checkout_processor_id;\n if (!processorId) {\n console.log(\"[ApplePay] Auto-prepare: no express checkout processor configured\");\n return;\n }\n\n const processorTypeRaw = result.data.express_checkout_processor_type;\n const processorType =\n processorTypeRaw === \"airwallex\" || processorTypeRaw === \"stripe\" ? processorTypeRaw : undefined;\n\n autoPrepareConfig = { processorId, processorType };\n\n const prepareResult = await prepareApplePay(\n apBase,\n sToken,\n { processorId, processorType, customerInfo: { first_name: \"\", last_name: \"\" } },\n env,\n );\n\n if (cleanupGeneration !== capturedGeneration) return;\n\n instanceSetApplePayReady(prepareResult.success && prepareResult.applePay === true);\n } catch (err) {\n if (cleanupGeneration === capturedGeneration) {\n console.error(\"[ApplePay] Auto-prepare failed:\", err);\n }\n } finally {\n autoPrepareInProgress = false;\n const stale = cleanupGeneration !== capturedGeneration;\n const pending = pendingAutoPrepareArgs;\n const resolvers = pendingPrepareResolvers.splice(0);\n if (!stale && pending) {\n pendingAutoPrepareArgs = null;\n // Run the retry and resolve all callers that were waiting for it.\n instanceAutoPrepare(pending.apiBaseUrl, pending.secureToken, pending.environment).then(() => {\n for (const r of resolvers) r();\n });\n } else {\n pendingAutoPrepareArgs = null;\n for (const r of resolvers) r();\n }\n }\n }\n\n // Start auto-prepare immediately so the button is ready before first user interaction.\n instanceAutoPrepare(apiBaseUrl, secureToken, environment).catch((err) =>\n console.error(\"[ApplePay] Unhandled init error:\", err),\n );\n\n return {\n name: \"apple_pay\",\n externalFuncs: {\n /**\n * @deprecated The SDK now prepares automatically on init. Use `onApplePayReady` to observe\n * readiness and `notifyAmountChanged` to trigger re-prepare after amount changes.\n */\n prepareApplePay: (options: ApplePaySubmitOptions) =>\n prepareApplePay(apiBaseUrl, secureToken, options, environment),\n\n /**\n * Register a callback to be notified when Apple Pay becomes ready (or stops being ready).\n * Fires immediately with the current state, then on every state change.\n * Multiple registrations are all notified — none are silently overwritten.\n *\n * @example\n * paymentKit.apple_pay.onApplePayReady((isReady) => {\n * applePayButton.disabled = !isReady;\n * });\n */\n onApplePayReady: (callback: (isReady: boolean) => void): void => {\n onApplePayReadyCallbacks.push(callback);\n // Fire immediately with current state so caller doesn't miss a completed prepare.\n callback(isApplePayReadyState);\n },\n\n /**\n * Notify the SDK that the payment amount has changed (e.g. coupon applied).\n * The SDK will disable Apple Pay, re-prepare with the new amount, then re-enable.\n * The returned promise resolves when re-prepare is fully complete.\n *\n * @example\n * await paymentKit.apple_pay.notifyAmountChanged();\n */\n notifyAmountChanged: (): Promise<void> => {\n instanceClearPreparedApplePay();\n autoPrepareConfig = null;\n return instanceAutoPrepare(apiBaseUrl, secureToken, environment);\n },\n },\n internalFuncs: {\n submitPayment: defSubmitPayment(paymentKitStates, () => autoPrepareConfig, instanceClearPreparedApplePay),\n cleanup: () => {\n cleanupGeneration++;\n onApplePayReadyCallbacks = [];\n isApplePayReadyState = false;\n autoPrepareConfig = null;\n pendingAutoPrepareArgs = null;\n pendingPrepareResolvers = [];\n autoPrepareInProgress = false;\n clearPreparedApplePay();\n },\n },\n };\n});\n\nexport { ApplePayMockScenario };\n\nexport default ApplePayPaymentMethod;\n"],"mappings":";;;;;;AAqHA,IAAIA,sBAA0D;AAW9D,IAAIC,yBAAwD;AA6B5D,IAAIC,4BAAkD;AACtD,eAAe,qBAAoC;AACjD,KAAI,OAAO,WAAW,YAAa;AACnC,KAAI,OAAO,gBAAiB;AAC5B,KAAI,SAAS,eAAe,qBAAqB,CAG/C,QAAO,6BAA6B,QAAQ,SAAS;AAEvD,6BAA4B,IAAI,SAAe,SAAS,WAAW;EACjE,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,SAAO,KAAK;AACZ,SAAO,MAAM;AACb,SAAO,cAAc;AAGrB,SAAO,eAAe,SAAS;AAC/B,SAAO,gBAAgB;AAErB,+BAA4B;AAC5B,YAAS,eAAe,qBAAqB,EAAE,QAAQ;AACvD,0BAAO,IAAI,MAAM,+BAA+B,CAAC;;AAEnD,WAAS,KAAK,YAAY,OAAO;GACjC;AACF,QAAO;;AAOT,eAAe,QACb,KACA,SACA,mBACuC;CACvC,MAAM,UAAU,IAAI,QAAQ,QAAQ,QAAQ;AAC5C,KAAI,kBACF,SAAQ,IAAI,gBAAgB,kBAAkB;CAGhD,MAAM,WAAW,MAAM,MAAM,KAAK;EAAE,GAAG;EAAS;EAAS,CAAC;AAC1D,KAAI,CAAC,SAAS,IAAI;EAChB,IAAI,eAAe,mBAAmB,SAAS,OAAO;AACtD,MAAI;AAEF,mBADkB,MAAM,SAAS,MAAM,EACd,UAAU;UAC7B;AACN,kBAAe,SAAS,cAAc;;AAExC,SAAO,EAA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,wBAAoB,QAAQ,YAAY,QAAQ,aAAa,QAAQ,YAAY,CAAC,WAAW;AAC3F,UAAK,MAAM,KAAK,UAAW,IAAG;MAC9B;UACG;AACL,6BAAyB;AACzB,SAAK,MAAM,KAAK,UAAW,IAAG;;;;AAMpC,qBAAoB,YAAY,aAAa,YAAY,CAAC,OAAO,QAC/D,QAAQ,MAAM,oCAAoC,IAAI,CACvD;AAED,QAAO;EACL,MAAM;EACN,eAAe;GAKb,kBAAkB,YAChB,gBAAgB,YAAY,aAAa,SAAS,YAAY;GAYhE,kBAAkB,aAA+C;AAC/D,6BAAyB,KAAK,SAAS;AAEvC,aAAS,qBAAqB;;GAWhC,2BAA0C;AACxC,mCAA+B;AAC/B,wBAAoB;AACpB,WAAO,oBAAoB,YAAY,aAAa,YAAY;;GAEnE;EACD,eAAe;GACb,eAAe,iBAAiB,wBAAwB,mBAAmB,8BAA8B;GACzG,eAAe;AACb;AACA,+BAA2B,EAAE;AAC7B,2BAAuB;AACvB,wBAAoB;AACpB,6BAAyB;AACzB,8BAA0B,EAAE;AAC5B,4BAAwB;AACxB,2BAAuB;;GAE1B;EACF;EACD;AAIF,wBAAe"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "../types-CQ8xbgoh.mjs";
|
|
2
|
+
import "../connect-card-Cra_F1cC.mjs";
|
|
3
|
+
import "../connect-tunnel-x-Wh-JG1O5.mjs";
|
|
4
|
+
import { a as BnplStartResponse, c as createBnplPaymentMethod, i as BnplStartRequest, n as BnplCustomerInfo, o as BnplStatusResponse, r as BnplProviderConfig, s as BnplSubmitOptions, t as BnplCheckoutResponse } from "../bnpl-shared-B-en2sPr.mjs";
|
|
5
|
+
export { BnplCheckoutResponse, BnplCustomerInfo, BnplProviderConfig, BnplStartRequest, BnplStartResponse, BnplStatusResponse, BnplSubmitOptions, createBnplPaymentMethod };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as PaymentMethod } from "../types-
|
|
2
|
-
import { n as CardInputType$1, o as connectToCardIframe, r as CheckoutResponse$1 } from "../connect-card-
|
|
3
|
-
import "../connect-tunnel-x-
|
|
1
|
+
import { r as PaymentMethod } from "../types-CQ8xbgoh.mjs";
|
|
2
|
+
import { n as CardInputType$1, o as connectToCardIframe, r as CheckoutResponse$1 } from "../connect-card-Cra_F1cC.mjs";
|
|
3
|
+
import "../connect-tunnel-x-Wh-JG1O5.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/payment-methods/card.d.ts
|
|
6
6
|
type CardInputType = CardInputType$1;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../penpal-BFKeZTVz.mjs";
|
|
2
2
|
import { t as TunnelXManager } from "../connect-tunnel-x-BhVAej5Q.mjs";
|
|
3
3
|
import { a as validateFormFields, i as definePaymentMethod, n as collectFraudMetadata, r as createCheckoutIFrame, s as withRequestId, t as $ } from "../utils-B70Y8YcZ.mjs";
|
|
4
|
-
import { t as handleNextAction } from "../next-action-handlers-
|
|
5
|
-
import { t as connectToCardIframe } from "../connect-card-
|
|
6
|
-
import { n as initVgsCollect, r as loadVgsCollectScript, t as createVgsCardFields } from "../vgs-collect-loader-
|
|
4
|
+
import { t as handleNextAction } from "../next-action-handlers-BZs04hYb.mjs";
|
|
5
|
+
import { t as connectToCardIframe } from "../connect-card-D3Je4V7p.mjs";
|
|
6
|
+
import { n as initVgsCollect, r as loadVgsCollectScript, t as createVgsCardFields } from "../vgs-collect-loader-l5_Pnmhz.mjs";
|
|
7
7
|
|
|
8
8
|
//#region src/payment-methods/card.ts
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as PaymentMethod } from "../types-
|
|
2
|
-
import "../connect-card-
|
|
3
|
-
import "../connect-tunnel-x-
|
|
4
|
-
import { a as GooglePayEncryptedToken } from "../airwallex-google-pay-adapter-
|
|
5
|
-
import { n as GooglePayMockScenario } from "../stripe-google-pay-adapter-
|
|
1
|
+
import { r as PaymentMethod } from "../types-CQ8xbgoh.mjs";
|
|
2
|
+
import "../connect-card-Cra_F1cC.mjs";
|
|
3
|
+
import "../connect-tunnel-x-Wh-JG1O5.mjs";
|
|
4
|
+
import { a as GooglePayEncryptedToken } from "../airwallex-google-pay-adapter-adaDktQM.mjs";
|
|
5
|
+
import { n as GooglePayMockScenario } from "../stripe-google-pay-adapter-BlQ2jVpE.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/payment-methods/google-pay.d.ts
|
|
8
8
|
type GooglePayCustomerInfo = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as definePaymentMethod, n as collectFraudMetadata, o as getOrCreateCheckoutRequestId } from "../utils-B70Y8YcZ.mjs";
|
|
2
|
-
import { n as AirwallexGooglePayMockScenario, t as AirwallexGooglePayAdapter } from "../airwallex-google-pay-adapter-
|
|
3
|
-
import { t as handleNextAction } from "../next-action-handlers-
|
|
4
|
-
import { n as StripeGooglePayAdapter, t as GooglePayMockScenario } from "../stripe-google-pay-adapter-
|
|
2
|
+
import { n as AirwallexGooglePayMockScenario, t as AirwallexGooglePayAdapter } from "../airwallex-google-pay-adapter-C8JTp01q.mjs";
|
|
3
|
+
import { t as handleNextAction } from "../next-action-handlers-BZs04hYb.mjs";
|
|
4
|
+
import { n as StripeGooglePayAdapter, t as GooglePayMockScenario } from "../stripe-google-pay-adapter-CIkgjhw8.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/payment-methods/google-pay.ts
|
|
7
7
|
async function apiCall(url, options, checkoutRequestId) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { r as PaymentMethod } from "../types-CQ8xbgoh.mjs";
|
|
2
|
+
import "../connect-card-Cra_F1cC.mjs";
|
|
3
|
+
import "../connect-tunnel-x-Wh-JG1O5.mjs";
|
|
4
|
+
import { n as BnplCustomerInfo, s as BnplSubmitOptions, t as BnplCheckoutResponse } from "../bnpl-shared-B-en2sPr.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/payment-methods/klarna.d.ts
|
|
7
|
+
type KlarnaCustomerInfo = BnplCustomerInfo;
|
|
8
|
+
type KlarnaSubmitOptions = BnplSubmitOptions;
|
|
9
|
+
type KlarnaCheckoutResponse = BnplCheckoutResponse;
|
|
10
|
+
declare const KlarnaPaymentMethod: PaymentMethod<{}, string>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { KlarnaCheckoutResponse, KlarnaCustomerInfo, KlarnaSubmitOptions, KlarnaPaymentMethod as default };
|
|
13
|
+
//# sourceMappingURL=klarna.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klarna.d.mts","names":[],"sources":["../../src/payment-methods/klarna.ts"],"sourcesContent":[],"mappings":";;;;;;KAWY,kBAAA,GAAqB;KAErB,mBAAA,GAAsB;AAFtB,KAIA,sBAAA,GAAyB,oBAJY;AAEjD,cAIM,mBAJyB,EAQ7B,aARiD,CAAA,CAAA,CAAA,EAAA,MAAA,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../utils-B70Y8YcZ.mjs";
|
|
2
|
+
import { t as createBnplPaymentMethod } from "../bnpl-shared-CEAXTL3Q.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/payment-methods/klarna.ts
|
|
5
|
+
const KlarnaPaymentMethod = createBnplPaymentMethod({
|
|
6
|
+
name: "klarna",
|
|
7
|
+
endpointPath: "klarna",
|
|
8
|
+
supportsSetupFutureUsage: true
|
|
9
|
+
});
|
|
10
|
+
var klarna_default = KlarnaPaymentMethod;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { klarna_default as default };
|
|
14
|
+
//# sourceMappingURL=klarna.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klarna.mjs","names":[],"sources":["../../src/payment-methods/klarna.ts"],"sourcesContent":["/**\n * Klarna payment method - uses shared BNPL factory.\n */\n\nimport {\n type BnplCheckoutResponse,\n type BnplCustomerInfo,\n type BnplSubmitOptions,\n createBnplPaymentMethod,\n} from \"./bnpl-shared\";\n\nexport type KlarnaCustomerInfo = BnplCustomerInfo;\n\nexport type KlarnaSubmitOptions = BnplSubmitOptions;\n\nexport type KlarnaCheckoutResponse = BnplCheckoutResponse;\n\nconst KlarnaPaymentMethod = createBnplPaymentMethod({\n name: \"klarna\",\n endpointPath: \"klarna\",\n supportsSetupFutureUsage: true,\n});\n\nexport default KlarnaPaymentMethod;\n"],"mappings":";;;;AAiBA,MAAM,sBAAsB,wBAAwB;CAClD,MAAM;CACN,cAAc;CACd,0BAA0B;CAC3B,CAAC;AAEF,qBAAe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as PaymentMethod } from "../types-
|
|
2
|
-
import "../connect-card-
|
|
3
|
-
import "../connect-tunnel-x-
|
|
1
|
+
import { r as PaymentMethod } from "../types-CQ8xbgoh.mjs";
|
|
2
|
+
import "../connect-card-Cra_F1cC.mjs";
|
|
3
|
+
import "../connect-tunnel-x-Wh-JG1O5.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/payment-methods/paypal.d.ts
|
|
6
6
|
type PayPalCustomerInfo = {
|
|
@@ -36,6 +36,12 @@ type PayPalCheckoutResponse = {
|
|
|
36
36
|
checkoutAttemptId: string;
|
|
37
37
|
checkoutSessionId: string;
|
|
38
38
|
state: string;
|
|
39
|
+
customerId?: string;
|
|
40
|
+
paymentMethodId?: string;
|
|
41
|
+
processorUsed?: string;
|
|
42
|
+
subscriptionId?: string;
|
|
43
|
+
invoiceId?: string;
|
|
44
|
+
invoiceNumber?: number;
|
|
39
45
|
};
|
|
40
46
|
type PayPalSubmitOptions = {
|
|
41
47
|
processorId: string;
|
|
@@ -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;
|
|
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;MAaA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAmB,OAAA;IA+JzB,CAAA;;;;;;KAzLM,mBAAA;;;;;KAMA,oBAAA;;;;;;KAOA,sBAAA;;;;;;;;;;;;KAaA,mBAAA;;gBAEI;;cA6JV,qBAqBJ"}
|