@payment-kit-js/vanilla 0.5.14 → 0.5.15
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-CHAnLP_x.mjs → airwallex-apple-pay-adapter-Bs8AdQKY.mjs} +8 -2
- package/dist/airwallex-apple-pay-adapter-Bs8AdQKY.mjs.map +1 -0
- package/dist/{airwallex-apple-pay-adapter-Bb0CreWN.d.mts → airwallex-apple-pay-adapter-D8enI9Vq.d.mts} +3 -1
- package/dist/airwallex-apple-pay-adapter-D8enI9Vq.d.mts.map +1 -0
- package/dist/cdn/paymentkit.js +17 -7
- package/dist/cdn/paymentkit.js.map +2 -2
- package/dist/cdn/paymentkit.min.js +9 -9
- package/dist/cdn/paymentkit.min.js.map +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- 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/apple-pay.d.mts +3 -1
- package/dist/payment-methods/apple-pay.d.mts.map +1 -1
- package/dist/payment-methods/apple-pay.mjs +6 -4
- package/dist/payment-methods/apple-pay.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/airwallex-apple-pay-adapter-Bb0CreWN.d.mts.map +0 -1
- package/dist/airwallex-apple-pay-adapter-CHAnLP_x.mjs.map +0 -1
package/dist/{airwallex-apple-pay-adapter-CHAnLP_x.mjs → airwallex-apple-pay-adapter-Bs8AdQKY.mjs}
RENAMED
|
@@ -125,6 +125,8 @@ var AirwallexApplePayAdapter = class {
|
|
|
125
125
|
transactionIdentifier: "MOCK_TXN_ID"
|
|
126
126
|
},
|
|
127
127
|
payerEmail: "mock@example.com",
|
|
128
|
+
payerFirstName: "Mock",
|
|
129
|
+
payerLastName: "User",
|
|
128
130
|
complete: (status) => console.log(`[MockApplePay:Airwallex] complete: ${status}`)
|
|
129
131
|
};
|
|
130
132
|
}
|
|
@@ -160,7 +162,7 @@ var AirwallexApplePayAdapter = class {
|
|
|
160
162
|
amount,
|
|
161
163
|
type: "final"
|
|
162
164
|
},
|
|
163
|
-
requiredBillingContactFields: ["email"]
|
|
165
|
+
requiredBillingContactFields: ["email", "name"]
|
|
164
166
|
};
|
|
165
167
|
return new Promise((resolve) => {
|
|
166
168
|
try {
|
|
@@ -204,6 +206,8 @@ var AirwallexApplePayAdapter = class {
|
|
|
204
206
|
transactionIdentifier: payment.token.transactionIdentifier
|
|
205
207
|
};
|
|
206
208
|
const payerEmail = payment.billingContact?.emailAddress ?? payment.shippingContact?.emailAddress ?? void 0;
|
|
209
|
+
const payerFirstName = payment.billingContact?.givenName ?? payment.shippingContact?.givenName ?? void 0;
|
|
210
|
+
const payerLastName = payment.billingContact?.familyName ?? payment.shippingContact?.familyName ?? void 0;
|
|
207
211
|
const complete = (status) => {
|
|
208
212
|
console.log("[ApplePay:Airwallex] completing session with status:", status);
|
|
209
213
|
const appleStatus = status === "success" ? STATUS_SUCCESS : STATUS_FAILURE;
|
|
@@ -213,6 +217,8 @@ var AirwallexApplePayAdapter = class {
|
|
|
213
217
|
success: true,
|
|
214
218
|
token,
|
|
215
219
|
payerEmail,
|
|
220
|
+
payerFirstName,
|
|
221
|
+
payerLastName,
|
|
216
222
|
complete
|
|
217
223
|
});
|
|
218
224
|
};
|
|
@@ -238,4 +244,4 @@ var AirwallexApplePayAdapter = class {
|
|
|
238
244
|
|
|
239
245
|
//#endregion
|
|
240
246
|
export { AirwallexApplePayMockScenario as n, AirwallexApplePayAdapter as t };
|
|
241
|
-
//# sourceMappingURL=airwallex-apple-pay-adapter-
|
|
247
|
+
//# sourceMappingURL=airwallex-apple-pay-adapter-Bs8AdQKY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airwallex-apple-pay-adapter-Bs8AdQKY.mjs","names":["paymentRequest: ApplePayJS.ApplePayPaymentRequest","token: ApplePayEncryptedToken"],"sources":["../src/payment-methods/airwallex-apple-pay-adapter.ts"],"sourcesContent":["/**\n * Airwallex Apple Pay Adapter\n *\n * Uses native ApplePaySession API directly (not Stripe.js) to show the payment sheet\n * and extract the encrypted payment token for Airwallex processing.\n *\n * Flow:\n * 1. initialize() - Checks if ApplePaySession is available\n * 2. canMakePayment() - Checks if user can pay with Apple Pay\n * 3. showPaymentSheet() - Shows Apple Pay sheet with merchant validation callback\n *\n * The key difference from Stripe's approach is that we use the native\n * ApplePaySession API and handle merchant validation via Airwallex's\n * payment_session/start API which validates with Apple.\n *\n * Mock scenarios are supported for E2E testing without real Apple Pay.\n */\n\n/// <reference types=\"@types/applepayjs\" />\n\nexport enum AirwallexApplePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n// Apple Pay token structure from payment.token\nexport interface ApplePayEncryptedToken {\n paymentData: {\n version?: string;\n data: string;\n signature: string;\n header: {\n ephemeralPublicKey: string;\n publicKeyHash: string;\n transactionId: string;\n };\n };\n paymentMethod: {\n displayName: string;\n network: string;\n type: string;\n };\n transactionIdentifier: string;\n}\n\nexport interface AirwallexApplePayConfig {\n amount: number; // Amount in atomic units (cents)\n currency: string; // e.g., \"USD\"\n country: string; // e.g., \"US\"\n merchantName?: string; // Display name on Apple Pay sheet\n}\n\nexport type AirwallexApplePayShowResult =\n | {\n success: true;\n token: ApplePayEncryptedToken;\n payerEmail?: string;\n payerFirstName?: string;\n payerLastName?: string;\n complete: (status: \"success\" | \"fail\") => void;\n }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\n// Merchant validation callback type - called during onvalidatemerchant\nexport type MerchantValidationCallback = (\n validationUrl: string,\n) => Promise<{ merchantSession?: object; error?: string }>;\n\nexport class AirwallexApplePayAdapter {\n private config: AirwallexApplePayConfig | null = null;\n private mockScenario: AirwallexApplePayMockScenario;\n\n constructor(mockScenario?: AirwallexApplePayMockScenario) {\n this.mockScenario = mockScenario ?? AirwallexApplePayMockScenario.None;\n }\n\n /**\n * Initialize the adapter with payment configuration.\n * Returns true if Apple Pay is available on this device.\n */\n initialize(config: AirwallexApplePayConfig): boolean {\n // Mock scenarios bypass real Apple Pay initialization\n if (this.mockScenario !== AirwallexApplePayMockScenario.None) {\n console.log(\"[MockApplePay:Airwallex] initialize called (mock mode)\");\n this.config = config;\n return true;\n }\n\n // Check if ApplePaySession is available (Safari on iOS/macOS only)\n if (typeof window === \"undefined\" || !window.ApplePaySession) {\n console.error(\"[ApplePay:Airwallex] ApplePaySession not available (not Safari or unsupported device)\");\n return false;\n }\n\n this.config = config;\n return true;\n }\n\n /**\n * Check if the user can make a payment with Apple Pay.\n * Returns true if Apple Pay is set up on this device.\n */\n async canMakePayment(): Promise<boolean> {\n // Mock scenarios always return true\n if (this.mockScenario !== AirwallexApplePayMockScenario.None) {\n console.log(\"[MockApplePay:Airwallex] canMakePayment: true (mock mode)\");\n return true;\n }\n\n if (!window.ApplePaySession) {\n return false;\n }\n\n try {\n const canMake = window.ApplePaySession.canMakePayments();\n console.log(\"[ApplePay:Airwallex] canMakePayments:\", canMake);\n return canMake;\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] canMakePayment error:\", error);\n return false;\n }\n }\n\n /**\n * Convert atomic units (cents) to display format for Apple Pay.\n * Apple Pay expects a string like \"10.00\" for $10.00.\n */\n private formatAmount(amountAtom: number, currency: string): string {\n // Most currencies use 2 decimal places, some like JPY use 0\n const zeroDecimalCurrencies = [\n \"BIF\",\n \"CLP\",\n \"DJF\",\n \"GNF\",\n \"ISK\",\n \"JPY\",\n \"KMF\",\n \"KRW\",\n \"PYG\",\n \"RWF\",\n \"UGX\",\n \"VND\",\n \"VUV\",\n \"XAF\",\n \"XOF\",\n \"XPF\",\n ];\n const isZeroDecimal = zeroDecimalCurrencies.includes(currency.toUpperCase());\n\n if (isZeroDecimal) {\n return amountAtom.toString();\n }\n\n return (amountAtom / 100).toFixed(2);\n }\n\n /**\n * Show the Apple Pay payment sheet and return the encrypted token.\n *\n * This uses the native ApplePaySession API with a two-step flow:\n * 1. onvalidatemerchant - Called by Apple to validate the merchant\n * The callback should call our backend which calls Airwallex's payment_session/start\n * 2. onpaymentauthorized - Called when user authorizes with Face ID/Touch ID\n * Returns the encrypted token for processing\n *\n * @param onMerchantValidation - Callback to validate merchant with backend\n * @returns Promise with token or error\n */\n async showPaymentSheet(onMerchantValidation: MerchantValidationCallback): Promise<AirwallexApplePayShowResult> {\n // Handle mock scenarios\n if (this.mockScenario === AirwallexApplePayMockScenario.Success) {\n console.log(\"[MockApplePay:Airwallex] showPaymentSheet: returning mock success token\");\n const mockToken: ApplePayEncryptedToken = {\n paymentData: {\n version: \"EC_v1\",\n data: \"MOCK_ENCRYPTED_DATA\",\n signature: \"MOCK_SIGNATURE\",\n header: {\n ephemeralPublicKey: \"MOCK_PUBLIC_KEY\",\n publicKeyHash: \"MOCK_HASH\",\n transactionId: \"mock_txn_123\",\n },\n },\n paymentMethod: {\n displayName: \"Visa 4242\",\n network: \"Visa\",\n type: \"debit\",\n },\n transactionIdentifier: \"MOCK_TXN_ID\",\n };\n return {\n success: true,\n token: mockToken,\n payerEmail: \"mock@example.com\",\n payerFirstName: \"Mock\",\n payerLastName: \"User\",\n complete: (status) => console.log(`[MockApplePay:Airwallex] complete: ${status}`),\n };\n }\n\n if (this.mockScenario === AirwallexApplePayMockScenario.Cancelled) {\n console.log(\"[MockApplePay:Airwallex] showPaymentSheet: returning mock cancelled\");\n return { success: false, cancelled: true };\n }\n\n // Real Apple Pay flow\n if (!this.config) {\n return { success: false, error: \"Apple Pay not initialized\" };\n }\n\n if (!window.ApplePaySession) {\n return { success: false, error: \"ApplePaySession not available\" };\n }\n\n const config = this.config;\n const amount = this.formatAmount(config.amount, config.currency);\n\n // Create the Apple Pay payment request\n const paymentRequest: ApplePayJS.ApplePayPaymentRequest = {\n countryCode: config.country.toUpperCase(),\n currencyCode: config.currency.toUpperCase(),\n supportedNetworks: [\"visa\", \"masterCard\", \"amex\", \"discover\"],\n merchantCapabilities: [\"supports3DS\"],\n total: {\n label: config.merchantName || \"Total\",\n amount: amount,\n type: \"final\",\n },\n // Surface the payer's email and name so the backend can fill missing customer info.\n requiredBillingContactFields: [\"email\", \"name\"],\n };\n\n return new Promise((resolve) => {\n try {\n // Create ApplePaySession (version 3 is widely supported)\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession is guaranteed to exist (checked in canMakePayments)\n const session = new window.ApplePaySession!(3, paymentRequest);\n\n // Capture status constants at creation time (before optional chaining could yield undefined)\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession existence verified above\n const STATUS_SUCCESS = window.ApplePaySession!.STATUS_SUCCESS;\n // biome-ignore lint/style/noNonNullAssertion: ApplePaySession existence verified above\n const STATUS_FAILURE = window.ApplePaySession!.STATUS_FAILURE;\n\n // Handle merchant validation\n session.onvalidatemerchant = async (event: ApplePayJS.ApplePayValidateMerchantEvent) => {\n console.log(\"[ApplePay:Airwallex] onvalidatemerchant called\", event.validationURL);\n\n try {\n const validationResult = await onMerchantValidation(event.validationURL);\n\n if (validationResult.error || !validationResult.merchantSession) {\n console.error(\"[ApplePay:Airwallex] Merchant validation failed:\", validationResult.error);\n session.abort();\n resolve({\n success: false,\n error: validationResult.error || \"Merchant validation failed\",\n });\n return;\n }\n\n // Complete merchant validation with the session from Apple\n session.completeMerchantValidation(validationResult.merchantSession);\n console.log(\"[ApplePay:Airwallex] Merchant validation completed\");\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] Merchant validation error:\", error);\n session.abort();\n resolve({\n success: false,\n error: `Merchant validation error: ${error}`,\n });\n }\n };\n\n // Handle payment authorization (user approved with Face ID/Touch ID)\n session.onpaymentauthorized = (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => {\n console.log(\"[ApplePay:Airwallex] onpaymentauthorized called\");\n\n // Extract the encrypted token\n const payment = event.payment;\n const token: ApplePayEncryptedToken = {\n paymentData: payment.token.paymentData as ApplePayEncryptedToken[\"paymentData\"],\n paymentMethod: {\n displayName: payment.token.paymentMethod.displayName,\n network: payment.token.paymentMethod.network,\n type: payment.token.paymentMethod.type,\n },\n transactionIdentifier: payment.token.transactionIdentifier,\n };\n\n const payerEmail = payment.billingContact?.emailAddress ?? payment.shippingContact?.emailAddress ?? undefined;\n const payerFirstName = payment.billingContact?.givenName ?? payment.shippingContact?.givenName ?? undefined;\n const payerLastName = payment.billingContact?.familyName ?? payment.shippingContact?.familyName ?? undefined;\n\n // Create the complete callback that the caller will use after confirming\n const complete = (status: \"success\" | \"fail\") => {\n console.log(\"[ApplePay:Airwallex] completing session with status:\", status);\n const appleStatus = status === \"success\" ? STATUS_SUCCESS : STATUS_FAILURE;\n session.completePayment({ status: appleStatus });\n };\n\n resolve({\n success: true,\n token,\n payerEmail,\n payerFirstName,\n payerLastName,\n complete,\n });\n };\n\n // Handle cancellation\n session.oncancel = () => {\n console.log(\"[ApplePay:Airwallex] oncancel - user cancelled\");\n resolve({ success: false, cancelled: true });\n };\n\n // Start the session - this shows the Apple Pay sheet\n console.log(\"[ApplePay:Airwallex] Starting Apple Pay session\");\n session.begin();\n } catch (error) {\n console.error(\"[ApplePay:Airwallex] Session creation error:\", error);\n resolve({\n success: false,\n error: `Failed to create Apple Pay session: ${error}`,\n });\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,IAAY,0FAAL;AACL;AACA;AACA;;;AA+CF,IAAa,2BAAb,MAAsC;CACpC,AAAQ,SAAyC;CACjD,AAAQ;CAER,YAAY,cAA8C;AACxD,OAAK,eAAe,gBAAgB,8BAA8B;;;;;;CAOpE,WAAW,QAA0C;AAEnD,MAAI,KAAK,iBAAiB,8BAA8B,MAAM;AAC5D,WAAQ,IAAI,yDAAyD;AACrE,QAAK,SAAS;AACd,UAAO;;AAIT,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,iBAAiB;AAC5D,WAAQ,MAAM,wFAAwF;AACtG,UAAO;;AAGT,OAAK,SAAS;AACd,SAAO;;;;;;CAOT,MAAM,iBAAmC;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QAAQ,gBAAgB,gBAAgB,QAAQ,iBAAiB,gBAAgB;KACpG,MAAM,iBAAiB,QAAQ,gBAAgB,aAAa,QAAQ,iBAAiB,aAAa;KAClG,MAAM,gBAAgB,QAAQ,gBAAgB,cAAc,QAAQ,iBAAiB,cAAc;KAGnG,MAAM,YAAY,WAA+B;AAC/C,cAAQ,IAAI,wDAAwD,OAAO;MAC3E,MAAM,cAAc,WAAW,YAAY,iBAAiB;AAC5D,cAAQ,gBAAgB,EAAE,QAAQ,aAAa,CAAC;;AAGlD,aAAQ;MACN,SAAS;MACT;MACA;MACA;MACA;MACA;MACD,CAAC;;AAIJ,YAAQ,iBAAiB;AACvB,aAAQ,IAAI,iDAAiD;AAC7D,aAAQ;MAAE,SAAS;MAAO,WAAW;MAAM,CAAC;;AAI9C,YAAQ,IAAI,kDAAkD;AAC9D,YAAQ,OAAO;YACR,OAAO;AACd,YAAQ,MAAM,gDAAgD,MAAM;AACpE,YAAQ;KACN,SAAS;KACT,OAAO,uCAAuC;KAC/C,CAAC;;IAEJ"}
|
|
@@ -49,6 +49,8 @@ type AirwallexApplePayShowResult = {
|
|
|
49
49
|
success: true;
|
|
50
50
|
token: ApplePayEncryptedToken;
|
|
51
51
|
payerEmail?: string;
|
|
52
|
+
payerFirstName?: string;
|
|
53
|
+
payerLastName?: string;
|
|
52
54
|
complete: (status: "success" | "fail") => void;
|
|
53
55
|
} | {
|
|
54
56
|
success: false;
|
|
@@ -96,4 +98,4 @@ declare class AirwallexApplePayAdapter {
|
|
|
96
98
|
}
|
|
97
99
|
//#endregion
|
|
98
100
|
export { ApplePayEncryptedToken as a, AirwallexApplePayShowResult as i, AirwallexApplePayConfig as n, MerchantValidationCallback as o, AirwallexApplePayMockScenario as r, AirwallexApplePayAdapter as t };
|
|
99
|
-
//# sourceMappingURL=airwallex-apple-pay-adapter-
|
|
101
|
+
//# sourceMappingURL=airwallex-apple-pay-adapter-D8enI9Vq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airwallex-apple-pay-adapter-D8enI9Vq.d.mts","names":[],"sources":["../src/payment-methods/airwallex-apple-pay-adapter.ts"],"sourcesContent":[],"mappings":";;AAoBA;AAOA;AAmBA;AAOA;AAaA;AAIA;;;;;;;;;;;aAlDY,6BAAA;;;;;UAOK,sBAAA;;;;;;;;;;;;;;;;;;UAmBA,uBAAA;;;;;;KAOL,2BAAA;;SAGC;;;;;;;;;;;;KAUD,0BAAA,8BAEP;;;;cAEQ,wBAAA;;;6BAIgB;;;;;qBAQR;;;;;oBAsBK;;;;;;;;;;;;;;;;;;yCAkEqB,6BAA6B,QAAQ"}
|
package/dist/cdn/paymentkit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PaymentKit.js v0.5.
|
|
2
|
+
* PaymentKit.js v0.5.15
|
|
3
3
|
* https://paymentkit.com
|
|
4
4
|
*
|
|
5
5
|
* @license MIT
|
|
@@ -42,7 +42,7 @@ var PaymentKit = (() => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// package.json
|
|
45
|
-
var version = "0.5.
|
|
45
|
+
var version = "0.5.15";
|
|
46
46
|
|
|
47
47
|
// src/analytics/mock-adapter.ts
|
|
48
48
|
var MockAnalyticsAdapter = class {
|
|
@@ -6878,6 +6878,8 @@ var PaymentKit = (() => {
|
|
|
6878
6878
|
success: true,
|
|
6879
6879
|
token: mockToken,
|
|
6880
6880
|
payerEmail: "mock@example.com",
|
|
6881
|
+
payerFirstName: "Mock",
|
|
6882
|
+
payerLastName: "User",
|
|
6881
6883
|
complete: (status) => console.log(`[MockApplePay:Airwallex] complete: ${status}`)
|
|
6882
6884
|
};
|
|
6883
6885
|
}
|
|
@@ -6903,8 +6905,8 @@ var PaymentKit = (() => {
|
|
|
6903
6905
|
amount,
|
|
6904
6906
|
type: "final"
|
|
6905
6907
|
},
|
|
6906
|
-
// Surface the payer's email so the backend can fill missing customer
|
|
6907
|
-
requiredBillingContactFields: ["email"]
|
|
6908
|
+
// Surface the payer's email and name so the backend can fill missing customer info.
|
|
6909
|
+
requiredBillingContactFields: ["email", "name"]
|
|
6908
6910
|
};
|
|
6909
6911
|
return new Promise((resolve) => {
|
|
6910
6912
|
try {
|
|
@@ -6948,6 +6950,8 @@ var PaymentKit = (() => {
|
|
|
6948
6950
|
transactionIdentifier: payment.token.transactionIdentifier
|
|
6949
6951
|
};
|
|
6950
6952
|
const payerEmail = payment.billingContact?.emailAddress ?? payment.shippingContact?.emailAddress ?? void 0;
|
|
6953
|
+
const payerFirstName = payment.billingContact?.givenName ?? payment.shippingContact?.givenName ?? void 0;
|
|
6954
|
+
const payerLastName = payment.billingContact?.familyName ?? payment.shippingContact?.familyName ?? void 0;
|
|
6951
6955
|
const complete = (status) => {
|
|
6952
6956
|
console.log("[ApplePay:Airwallex] completing session with status:", status);
|
|
6953
6957
|
const appleStatus = status === "success" ? STATUS_SUCCESS : STATUS_FAILURE;
|
|
@@ -6957,6 +6961,8 @@ var PaymentKit = (() => {
|
|
|
6957
6961
|
success: true,
|
|
6958
6962
|
token,
|
|
6959
6963
|
payerEmail,
|
|
6964
|
+
payerFirstName,
|
|
6965
|
+
payerLastName,
|
|
6960
6966
|
complete
|
|
6961
6967
|
});
|
|
6962
6968
|
};
|
|
@@ -7722,7 +7728,7 @@ var PaymentKit = (() => {
|
|
|
7722
7728
|
checkoutRequestId
|
|
7723
7729
|
);
|
|
7724
7730
|
}
|
|
7725
|
-
async function callAirwallexConfirmEndpoint(apiBaseUrl, secureToken, applePayToken, mockScenarioStr, checkoutRequestId, payerEmail) {
|
|
7731
|
+
async function callAirwallexConfirmEndpoint(apiBaseUrl, secureToken, applePayToken, mockScenarioStr, checkoutRequestId, payerEmail, payerFirstName, payerLastName) {
|
|
7726
7732
|
const result = await apiCall(
|
|
7727
7733
|
`${apiBaseUrl}/api/checkout/${secureToken}/airwallex/apple-pay/confirm`,
|
|
7728
7734
|
{
|
|
@@ -7731,6 +7737,8 @@ var PaymentKit = (() => {
|
|
|
7731
7737
|
body: JSON.stringify({
|
|
7732
7738
|
apple_pay_token: applePayToken,
|
|
7733
7739
|
payer_email: payerEmail,
|
|
7740
|
+
payer_first_name: payerFirstName,
|
|
7741
|
+
payer_last_name: payerLastName,
|
|
7734
7742
|
mock_scenario: mockScenarioStr
|
|
7735
7743
|
})
|
|
7736
7744
|
},
|
|
@@ -7867,14 +7875,16 @@ var PaymentKit = (() => {
|
|
|
7867
7875
|
}
|
|
7868
7876
|
return { errors: { apple_pay: paymentResult.error || "Apple Pay failed" } };
|
|
7869
7877
|
}
|
|
7870
|
-
const { token, complete, payerEmail } = paymentResult;
|
|
7878
|
+
const { token, complete, payerEmail, payerFirstName, payerLastName } = paymentResult;
|
|
7871
7879
|
let response = await callAirwallexConfirmEndpoint(
|
|
7872
7880
|
apiBaseUrl,
|
|
7873
7881
|
secureToken,
|
|
7874
7882
|
token,
|
|
7875
7883
|
mockScenarioStr,
|
|
7876
7884
|
checkoutRequestId,
|
|
7877
|
-
payerEmail
|
|
7885
|
+
payerEmail,
|
|
7886
|
+
payerFirstName,
|
|
7887
|
+
payerLastName
|
|
7878
7888
|
);
|
|
7879
7889
|
let userActionCount = 0;
|
|
7880
7890
|
while (response.charge_status === "pending" && response.next_action && userActionCount < MAX_USER_ACTIONS) {
|