@payment-kit-js/vanilla 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/airwallex-google-pay-adapter-BCmTZip5.mjs +167 -0
- package/dist/airwallex-google-pay-adapter-BCmTZip5.mjs.map +1 -0
- package/dist/airwallex-google-pay-adapter-Be2Af4N9.d.mts +140 -0
- package/dist/airwallex-google-pay-adapter-Be2Af4N9.d.mts.map +1 -0
- package/dist/cdn/paymentkit.js +5768 -83
- package/dist/cdn/paymentkit.js.map +4 -4
- package/dist/cdn/paymentkit.min.js +58 -3
- package/dist/cdn/paymentkit.min.js.map +4 -4
- package/dist/{connect-card-DO2EJxu6.mjs → connect-card-BrtCmsjz.mjs} +1 -1
- package/dist/{connect-card-DO2EJxu6.mjs.map → connect-card-BrtCmsjz.mjs.map} +1 -1
- package/dist/{connect-card-C582hcWw.d.mts → connect-card-DTfXuTsW.d.mts} +1 -1
- package/dist/{connect-card-C582hcWw.d.mts.map → connect-card-DTfXuTsW.d.mts.map} +1 -1
- package/dist/connect-tunnel-x-BhVAej5Q.mjs.map +1 -1
- package/dist/{connect-tunnel-x-B7iMQ7DX.d.mts → connect-tunnel-x-Dxcg5Y7Y.d.mts} +6 -5
- package/dist/connect-tunnel-x-Dxcg5Y7Y.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +337 -5
- package/dist/index.mjs.map +1 -1
- package/dist/next-action-handlers-BZs04hYb.mjs +271 -0
- package/dist/next-action-handlers-BZs04hYb.mjs.map +1 -0
- package/dist/payment-methods/airwallex-google-pay-adapter.d.mts +2 -0
- package/dist/payment-methods/airwallex-google-pay-adapter.mjs +3 -0
- package/dist/payment-methods/apple-pay.d.mts +78 -0
- package/dist/payment-methods/apple-pay.d.mts.map +1 -0
- package/dist/payment-methods/apple-pay.mjs +188 -0
- package/dist/payment-methods/apple-pay.mjs.map +1 -0
- package/dist/payment-methods/card.d.mts +3 -3
- package/dist/payment-methods/card.d.mts.map +1 -1
- package/dist/payment-methods/card.mjs +40 -12
- package/dist/payment-methods/card.mjs.map +1 -1
- package/dist/payment-methods/google-pay.d.mts +25 -7
- package/dist/payment-methods/google-pay.d.mts.map +1 -1
- package/dist/payment-methods/google-pay.mjs +165 -30
- package/dist/payment-methods/google-pay.mjs.map +1 -1
- package/dist/payment-methods/next-action-handlers.d.mts.map +1 -1
- package/dist/payment-methods/next-action-handlers.mjs +1 -1
- package/dist/payment-methods/paypal.d.mts +3 -3
- package/dist/payment-methods/paypal.d.mts.map +1 -1
- package/dist/payment-methods/paypal.mjs +8 -3
- package/dist/payment-methods/paypal.mjs.map +1 -1
- package/dist/payment-methods/stripe-apple-pay-adapter.d.mts +2 -0
- package/dist/payment-methods/stripe-apple-pay-adapter.mjs +3 -0
- 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/penpal/connect-card.d.mts +1 -1
- package/dist/penpal/connect-card.mjs +1 -1
- package/dist/penpal/connect-tunnel-x.d.mts +1 -1
- package/dist/stripe-apple-pay-adapter-Bg7nCy3P.mjs +313 -0
- package/dist/stripe-apple-pay-adapter-Bg7nCy3P.mjs.map +1 -0
- package/dist/stripe-apple-pay-adapter-Bq3f1mqv.d.mts +141 -0
- package/dist/stripe-apple-pay-adapter-Bq3f1mqv.d.mts.map +1 -0
- package/dist/{stripe-google-pay-adapter-DMDArVp2.mjs → stripe-google-pay-adapter-DjrgDYWe.mjs} +1 -1
- package/dist/{stripe-google-pay-adapter-DMDArVp2.mjs.map → stripe-google-pay-adapter-DjrgDYWe.mjs.map} +1 -1
- package/dist/{stripe-google-pay-adapter-DUUB46SG.d.mts → stripe-google-pay-adapter-xktEycOD.d.mts} +1 -1
- package/dist/{stripe-google-pay-adapter-DUUB46SG.d.mts.map → stripe-google-pay-adapter-xktEycOD.d.mts.map} +1 -1
- package/dist/types-CPuloCtF.d.mts +129 -0
- package/dist/types-CPuloCtF.d.mts.map +1 -0
- package/dist/{utils-h0dxplHy.mjs → utils-Dgyk7RkM.mjs} +40 -2
- package/dist/utils-Dgyk7RkM.mjs.map +1 -0
- package/package.json +9 -3
- package/dist/connect-tunnel-x-B7iMQ7DX.d.mts.map +0 -1
- package/dist/next-action-handlers-DTsWjUIA.mjs +0 -53
- package/dist/next-action-handlers-DTsWjUIA.mjs.map +0 -1
- package/dist/types-DsVMq4jZ.d.mts +0 -64
- package/dist/types-DsVMq4jZ.d.mts.map +0 -1
- package/dist/utils-h0dxplHy.mjs.map +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
//#region src/payment-methods/airwallex-google-pay-adapter.ts
|
|
2
|
+
/**
|
|
3
|
+
* Airwallex Google Pay Adapter
|
|
4
|
+
*
|
|
5
|
+
* Uses Google Pay API directly (not Stripe.js) to show the payment sheet
|
|
6
|
+
* and extract the encrypted payment token for Airwallex processing.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. initialize() - Checks if Google Pay API is available
|
|
10
|
+
* 2. createPaymentDataRequest() - Configures the payment request
|
|
11
|
+
* 3. canMakePayment() - Checks if user can pay with Google Pay
|
|
12
|
+
* 4. showPaymentSheet() - Shows Google Pay sheet and returns encrypted token
|
|
13
|
+
*
|
|
14
|
+
* Mock scenarios are supported for E2E testing without real Google Pay.
|
|
15
|
+
*/
|
|
16
|
+
let AirwallexGooglePayMockScenario = /* @__PURE__ */ function(AirwallexGooglePayMockScenario$1) {
|
|
17
|
+
AirwallexGooglePayMockScenario$1["None"] = "none";
|
|
18
|
+
AirwallexGooglePayMockScenario$1["Success"] = "success";
|
|
19
|
+
AirwallexGooglePayMockScenario$1["Cancelled"] = "cancelled";
|
|
20
|
+
return AirwallexGooglePayMockScenario$1;
|
|
21
|
+
}({});
|
|
22
|
+
var AirwallexGooglePayAdapter = class {
|
|
23
|
+
client = null;
|
|
24
|
+
config = null;
|
|
25
|
+
mockScenario;
|
|
26
|
+
constructor(mockScenario) {
|
|
27
|
+
this.mockScenario = mockScenario ?? AirwallexGooglePayMockScenario.None;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the Google Pay client.
|
|
31
|
+
* Returns true if Google Pay API is available.
|
|
32
|
+
*/
|
|
33
|
+
initialize(config) {
|
|
34
|
+
if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {
|
|
35
|
+
console.log("[MockGooglePay:Airwallex] initialize called (mock mode)");
|
|
36
|
+
this.config = config;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (!window.google?.payments?.api?.PaymentsClient) {
|
|
40
|
+
console.error("[GooglePay:Airwallex] Google Pay API not loaded");
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
this.config = config;
|
|
44
|
+
this.client = new window.google.payments.api.PaymentsClient({ environment: config.isProduction ? "PRODUCTION" : "TEST" });
|
|
45
|
+
return this.client !== null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build the allowed payment methods configuration for Google Pay.
|
|
49
|
+
*/
|
|
50
|
+
getAllowedPaymentMethods(includeTokenization) {
|
|
51
|
+
if (!this.config) throw new Error("Config not set. Call initialize() first.");
|
|
52
|
+
const baseMethod = {
|
|
53
|
+
type: "CARD",
|
|
54
|
+
parameters: {
|
|
55
|
+
allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
|
|
56
|
+
allowedCardNetworks: [
|
|
57
|
+
"VISA",
|
|
58
|
+
"MASTERCARD",
|
|
59
|
+
"AMEX",
|
|
60
|
+
"DISCOVER",
|
|
61
|
+
"JCB"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (includeTokenization) baseMethod.tokenizationSpecification = {
|
|
66
|
+
type: "PAYMENT_GATEWAY",
|
|
67
|
+
parameters: {
|
|
68
|
+
gateway: "airwallex",
|
|
69
|
+
gatewayMerchantId: this.config.gatewayMerchantId
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return [baseMethod];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if the user can make a payment with Google Pay.
|
|
76
|
+
*/
|
|
77
|
+
async canMakePayment() {
|
|
78
|
+
if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {
|
|
79
|
+
console.log("[MockGooglePay:Airwallex] canMakePayment: true (mock mode)");
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (!this.client) return false;
|
|
83
|
+
try {
|
|
84
|
+
const request = {
|
|
85
|
+
apiVersion: 2,
|
|
86
|
+
apiVersionMinor: 0,
|
|
87
|
+
allowedPaymentMethods: this.getAllowedPaymentMethods(false)
|
|
88
|
+
};
|
|
89
|
+
return (await this.client.isReadyToPay(request)).result;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error("[GooglePay:Airwallex] canMakePayment error:", error);
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Show the Google Pay payment sheet and return the encrypted token.
|
|
97
|
+
*/
|
|
98
|
+
async showPaymentSheet() {
|
|
99
|
+
if (this.mockScenario === AirwallexGooglePayMockScenario.Success) {
|
|
100
|
+
console.log("[MockGooglePay:Airwallex] showPaymentSheet: returning mock success token");
|
|
101
|
+
return {
|
|
102
|
+
success: true,
|
|
103
|
+
token: {
|
|
104
|
+
protocolVersion: "ECv2",
|
|
105
|
+
signature: "MOCK_SIGNATURE",
|
|
106
|
+
intermediateSigningKey: {
|
|
107
|
+
signedKey: "MOCK_SIGNED_KEY",
|
|
108
|
+
signatures: ["MOCK_SIGNATURE"]
|
|
109
|
+
},
|
|
110
|
+
signedMessage: "MOCK_SIGNED_MESSAGE"
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (this.mockScenario === AirwallexGooglePayMockScenario.Cancelled) {
|
|
115
|
+
console.log("[MockGooglePay:Airwallex] showPaymentSheet: returning mock cancelled");
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
cancelled: true
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (!this.client || !this.config) return {
|
|
122
|
+
success: false,
|
|
123
|
+
error: "Google Pay not initialized"
|
|
124
|
+
};
|
|
125
|
+
try {
|
|
126
|
+
const totalPrice = this.config.amountDisplay;
|
|
127
|
+
const request = {
|
|
128
|
+
apiVersion: 2,
|
|
129
|
+
apiVersionMinor: 0,
|
|
130
|
+
allowedPaymentMethods: this.getAllowedPaymentMethods(true),
|
|
131
|
+
merchantInfo: {
|
|
132
|
+
merchantName: this.config.merchantId,
|
|
133
|
+
...this.config.isProduction && this.config.googleMerchantId ? { merchantId: this.config.googleMerchantId } : {}
|
|
134
|
+
},
|
|
135
|
+
transactionInfo: {
|
|
136
|
+
totalPriceStatus: "FINAL",
|
|
137
|
+
totalPrice,
|
|
138
|
+
currencyCode: this.config.currency.toUpperCase(),
|
|
139
|
+
countryCode: this.config.country.toUpperCase()
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const tokenString = (await this.client.loadPaymentData(request)).paymentMethodData.tokenizationData.token;
|
|
143
|
+
return {
|
|
144
|
+
success: true,
|
|
145
|
+
token: JSON.parse(tokenString)
|
|
146
|
+
};
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (error instanceof Error && error.message?.includes("CANCELED")) return {
|
|
149
|
+
success: false,
|
|
150
|
+
cancelled: true
|
|
151
|
+
};
|
|
152
|
+
if (error.statusCode === "CANCELED") return {
|
|
153
|
+
success: false,
|
|
154
|
+
cancelled: true
|
|
155
|
+
};
|
|
156
|
+
console.error("[GooglePay:Airwallex] Payment sheet error:", error);
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
export { AirwallexGooglePayMockScenario as n, AirwallexGooglePayAdapter as t };
|
|
167
|
+
//# sourceMappingURL=airwallex-google-pay-adapter-BCmTZip5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airwallex-google-pay-adapter-BCmTZip5.mjs","names":["baseMethod: AllowedPaymentMethod","request: IsReadyToPayRequest","request: PaymentDataRequest"],"sources":["../src/payment-methods/airwallex-google-pay-adapter.ts"],"sourcesContent":["/**\n * Airwallex Google Pay Adapter\n *\n * Uses Google Pay 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 Google Pay API is available\n * 2. createPaymentDataRequest() - Configures the payment request\n * 3. canMakePayment() - Checks if user can pay with Google Pay\n * 4. showPaymentSheet() - Shows Google Pay sheet and returns encrypted token\n *\n * Mock scenarios are supported for E2E testing without real Google Pay.\n */\n\nexport enum AirwallexGooglePayMockScenario {\n None = \"none\",\n Success = \"success\",\n Cancelled = \"cancelled\",\n}\n\n// Google Pay API types\n// See: https://developers.google.com/pay/api/web/reference/request-objects\ndeclare global {\n interface Window {\n google?: {\n payments: {\n api: {\n PaymentsClient: new (config: GooglePayClientConfig) => GooglePaymentsClient;\n };\n };\n };\n }\n}\n\ninterface GooglePayClientConfig {\n environment: \"TEST\" | \"PRODUCTION\";\n}\n\ninterface GooglePaymentsClient {\n isReadyToPay(request: IsReadyToPayRequest): Promise<IsReadyToPayResponse>;\n loadPaymentData(request: PaymentDataRequest): Promise<PaymentData>;\n}\n\ninterface IsReadyToPayRequest {\n apiVersion: number;\n apiVersionMinor: number;\n allowedPaymentMethods: AllowedPaymentMethod[];\n}\n\ninterface IsReadyToPayResponse {\n result: boolean;\n}\n\ninterface AllowedPaymentMethod {\n type: \"CARD\";\n parameters: {\n allowedAuthMethods: (\"PAN_ONLY\" | \"CRYPTOGRAM_3DS\")[];\n allowedCardNetworks: (\"VISA\" | \"MASTERCARD\" | \"AMEX\" | \"DISCOVER\" | \"JCB\")[];\n };\n tokenizationSpecification?: TokenizationSpecification;\n}\n\ninterface TokenizationSpecification {\n type: \"PAYMENT_GATEWAY\";\n parameters: {\n gateway: string;\n gatewayMerchantId: string;\n };\n}\n\ninterface PaymentDataRequest extends IsReadyToPayRequest {\n merchantInfo: {\n merchantId?: string;\n merchantName: string;\n };\n transactionInfo: {\n totalPriceStatus: \"FINAL\" | \"ESTIMATED\";\n totalPrice: string;\n currencyCode: string;\n countryCode: string;\n };\n}\n\ninterface PaymentData {\n paymentMethodData: {\n type: string;\n tokenizationData: {\n type: string;\n token: string; // JSON string containing the encrypted payment token\n };\n info?: {\n cardNetwork: string;\n cardDetails: string;\n };\n };\n}\n\n// Google Pay encrypted token structure (what's inside tokenizationData.token)\nexport interface GooglePayEncryptedToken {\n protocolVersion: string;\n signature: string;\n intermediateSigningKey: {\n signedKey: string;\n signatures: string[];\n };\n signedMessage: string;\n}\n\nexport interface AirwallexGooglePayConfig {\n merchantId: string; // Business name for display\n gatewayMerchantId: string; // Airwallex account ID (acct_xxxx)\n amountDisplay: string; // Formatted amount for Google Pay (e.g., \"100.00\" for USD, \"1000\" for JPY)\n currency: string; // e.g., \"usd\"\n country: string; // e.g., \"US\"\n isProduction?: boolean; // Default: false (TEST environment)\n googleMerchantId?: string; // Google-assigned merchant ID for production (BCR2DN...)\n}\n\nexport type AirwallexShowPaymentResult =\n | { success: true; token: GooglePayEncryptedToken }\n | { success: false; cancelled: true }\n | { success: false; error: string };\n\nexport class AirwallexGooglePayAdapter {\n private client: GooglePaymentsClient | null = null;\n private config: AirwallexGooglePayConfig | null = null;\n private mockScenario: AirwallexGooglePayMockScenario;\n\n constructor(mockScenario?: AirwallexGooglePayMockScenario) {\n this.mockScenario = mockScenario ?? AirwallexGooglePayMockScenario.None;\n }\n\n /**\n * Initialize the Google Pay client.\n * Returns true if Google Pay API is available.\n */\n initialize(config: AirwallexGooglePayConfig): boolean {\n // Mock scenarios bypass real Google Pay initialization\n if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {\n console.log(\"[MockGooglePay:Airwallex] initialize called (mock mode)\");\n this.config = config;\n return true;\n }\n\n if (!window.google?.payments?.api?.PaymentsClient) {\n console.error(\"[GooglePay:Airwallex] Google Pay API not loaded\");\n return false;\n }\n\n this.config = config;\n this.client = new window.google.payments.api.PaymentsClient({\n environment: config.isProduction ? \"PRODUCTION\" : \"TEST\",\n });\n\n return this.client !== null;\n }\n\n /**\n * Build the allowed payment methods configuration for Google Pay.\n */\n private getAllowedPaymentMethods(includeTokenization: boolean): AllowedPaymentMethod[] {\n if (!this.config) {\n throw new Error(\"Config not set. Call initialize() first.\");\n }\n\n const baseMethod: AllowedPaymentMethod = {\n type: \"CARD\",\n parameters: {\n allowedAuthMethods: [\"PAN_ONLY\", \"CRYPTOGRAM_3DS\"],\n allowedCardNetworks: [\"VISA\", \"MASTERCARD\", \"AMEX\", \"DISCOVER\", \"JCB\"],\n },\n };\n\n if (includeTokenization) {\n baseMethod.tokenizationSpecification = {\n type: \"PAYMENT_GATEWAY\",\n parameters: {\n gateway: \"airwallex\",\n gatewayMerchantId: this.config.gatewayMerchantId,\n },\n };\n }\n\n return [baseMethod];\n }\n\n /**\n * Check if the user can make a payment with Google Pay.\n */\n async canMakePayment(): Promise<boolean> {\n // Mock scenarios always return true\n if (this.mockScenario !== AirwallexGooglePayMockScenario.None) {\n console.log(\"[MockGooglePay:Airwallex] canMakePayment: true (mock mode)\");\n return true;\n }\n\n if (!this.client) {\n return false;\n }\n\n try {\n const request: IsReadyToPayRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: this.getAllowedPaymentMethods(false),\n };\n\n const response = await this.client.isReadyToPay(request);\n return response.result;\n } catch (error) {\n console.error(\"[GooglePay:Airwallex] canMakePayment error:\", error);\n return false;\n }\n }\n\n /**\n * Show the Google Pay payment sheet and return the encrypted token.\n */\n async showPaymentSheet(): Promise<AirwallexShowPaymentResult> {\n // Handle mock scenarios\n if (this.mockScenario === AirwallexGooglePayMockScenario.Success) {\n console.log(\"[MockGooglePay:Airwallex] showPaymentSheet: returning mock success token\");\n // Return a mock token that the backend will recognize as mock\n const mockToken: GooglePayEncryptedToken = {\n protocolVersion: \"ECv2\",\n signature: \"MOCK_SIGNATURE\",\n intermediateSigningKey: {\n signedKey: \"MOCK_SIGNED_KEY\",\n signatures: [\"MOCK_SIGNATURE\"],\n },\n signedMessage: \"MOCK_SIGNED_MESSAGE\",\n };\n return { success: true, token: mockToken };\n }\n\n if (this.mockScenario === AirwallexGooglePayMockScenario.Cancelled) {\n console.log(\"[MockGooglePay:Airwallex] showPaymentSheet: returning mock cancelled\");\n return { success: false, cancelled: true };\n }\n\n // Real Google Pay flow\n if (!this.client || !this.config) {\n return { success: false, error: \"Google Pay not initialized\" };\n }\n\n try {\n const totalPrice = this.config.amountDisplay;\n\n const request: PaymentDataRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: this.getAllowedPaymentMethods(true),\n merchantInfo: {\n merchantName: this.config.merchantId,\n // merchantId is required in PRODUCTION environment\n // It's the Google-assigned merchant ID from Google Pay Business Console\n ...(this.config.isProduction && this.config.googleMerchantId\n ? { merchantId: this.config.googleMerchantId }\n : {}),\n },\n transactionInfo: {\n totalPriceStatus: \"FINAL\",\n totalPrice: totalPrice,\n currencyCode: this.config.currency.toUpperCase(),\n countryCode: this.config.country.toUpperCase(),\n },\n };\n\n const paymentData = await this.client.loadPaymentData(request);\n\n // Parse the encrypted token from the response\n const tokenString = paymentData.paymentMethodData.tokenizationData.token;\n const token: GooglePayEncryptedToken = JSON.parse(tokenString);\n\n return { success: true, token };\n } catch (error) {\n // Google Pay API throws an error when user cancels\n if (error instanceof Error && error.message?.includes(\"CANCELED\")) {\n return { success: false, cancelled: true };\n }\n\n // Check for statusCode which indicates user cancelled\n const gpayError = error as { statusCode?: string };\n if (gpayError.statusCode === \"CANCELED\") {\n return { success: false, cancelled: true };\n }\n\n console.error(\"[GooglePay:Airwallex] Payment sheet error:\", error);\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return { success: false, error: errorMessage };\n }\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
//#region src/payment-methods/airwallex-google-pay-adapter.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Airwallex Google Pay Adapter
|
|
4
|
+
*
|
|
5
|
+
* Uses Google Pay API directly (not Stripe.js) to show the payment sheet
|
|
6
|
+
* and extract the encrypted payment token for Airwallex processing.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. initialize() - Checks if Google Pay API is available
|
|
10
|
+
* 2. createPaymentDataRequest() - Configures the payment request
|
|
11
|
+
* 3. canMakePayment() - Checks if user can pay with Google Pay
|
|
12
|
+
* 4. showPaymentSheet() - Shows Google Pay sheet and returns encrypted token
|
|
13
|
+
*
|
|
14
|
+
* Mock scenarios are supported for E2E testing without real Google Pay.
|
|
15
|
+
*/
|
|
16
|
+
declare enum AirwallexGooglePayMockScenario {
|
|
17
|
+
None = "none",
|
|
18
|
+
Success = "success",
|
|
19
|
+
Cancelled = "cancelled",
|
|
20
|
+
}
|
|
21
|
+
declare global {
|
|
22
|
+
interface Window {
|
|
23
|
+
google?: {
|
|
24
|
+
payments: {
|
|
25
|
+
api: {
|
|
26
|
+
PaymentsClient: new (config: GooglePayClientConfig) => GooglePaymentsClient;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
interface GooglePayClientConfig {
|
|
33
|
+
environment: "TEST" | "PRODUCTION";
|
|
34
|
+
}
|
|
35
|
+
interface GooglePaymentsClient {
|
|
36
|
+
isReadyToPay(request: IsReadyToPayRequest): Promise<IsReadyToPayResponse>;
|
|
37
|
+
loadPaymentData(request: PaymentDataRequest): Promise<PaymentData>;
|
|
38
|
+
}
|
|
39
|
+
interface IsReadyToPayRequest {
|
|
40
|
+
apiVersion: number;
|
|
41
|
+
apiVersionMinor: number;
|
|
42
|
+
allowedPaymentMethods: AllowedPaymentMethod[];
|
|
43
|
+
}
|
|
44
|
+
interface IsReadyToPayResponse {
|
|
45
|
+
result: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface AllowedPaymentMethod {
|
|
48
|
+
type: "CARD";
|
|
49
|
+
parameters: {
|
|
50
|
+
allowedAuthMethods: ("PAN_ONLY" | "CRYPTOGRAM_3DS")[];
|
|
51
|
+
allowedCardNetworks: ("VISA" | "MASTERCARD" | "AMEX" | "DISCOVER" | "JCB")[];
|
|
52
|
+
};
|
|
53
|
+
tokenizationSpecification?: TokenizationSpecification;
|
|
54
|
+
}
|
|
55
|
+
interface TokenizationSpecification {
|
|
56
|
+
type: "PAYMENT_GATEWAY";
|
|
57
|
+
parameters: {
|
|
58
|
+
gateway: string;
|
|
59
|
+
gatewayMerchantId: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface PaymentDataRequest extends IsReadyToPayRequest {
|
|
63
|
+
merchantInfo: {
|
|
64
|
+
merchantId?: string;
|
|
65
|
+
merchantName: string;
|
|
66
|
+
};
|
|
67
|
+
transactionInfo: {
|
|
68
|
+
totalPriceStatus: "FINAL" | "ESTIMATED";
|
|
69
|
+
totalPrice: string;
|
|
70
|
+
currencyCode: string;
|
|
71
|
+
countryCode: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
interface PaymentData {
|
|
75
|
+
paymentMethodData: {
|
|
76
|
+
type: string;
|
|
77
|
+
tokenizationData: {
|
|
78
|
+
type: string;
|
|
79
|
+
token: string;
|
|
80
|
+
};
|
|
81
|
+
info?: {
|
|
82
|
+
cardNetwork: string;
|
|
83
|
+
cardDetails: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
interface GooglePayEncryptedToken {
|
|
88
|
+
protocolVersion: string;
|
|
89
|
+
signature: string;
|
|
90
|
+
intermediateSigningKey: {
|
|
91
|
+
signedKey: string;
|
|
92
|
+
signatures: string[];
|
|
93
|
+
};
|
|
94
|
+
signedMessage: string;
|
|
95
|
+
}
|
|
96
|
+
interface AirwallexGooglePayConfig {
|
|
97
|
+
merchantId: string;
|
|
98
|
+
gatewayMerchantId: string;
|
|
99
|
+
amountDisplay: string;
|
|
100
|
+
currency: string;
|
|
101
|
+
country: string;
|
|
102
|
+
isProduction?: boolean;
|
|
103
|
+
googleMerchantId?: string;
|
|
104
|
+
}
|
|
105
|
+
type AirwallexShowPaymentResult = {
|
|
106
|
+
success: true;
|
|
107
|
+
token: GooglePayEncryptedToken;
|
|
108
|
+
} | {
|
|
109
|
+
success: false;
|
|
110
|
+
cancelled: true;
|
|
111
|
+
} | {
|
|
112
|
+
success: false;
|
|
113
|
+
error: string;
|
|
114
|
+
};
|
|
115
|
+
declare class AirwallexGooglePayAdapter {
|
|
116
|
+
private client;
|
|
117
|
+
private config;
|
|
118
|
+
private mockScenario;
|
|
119
|
+
constructor(mockScenario?: AirwallexGooglePayMockScenario);
|
|
120
|
+
/**
|
|
121
|
+
* Initialize the Google Pay client.
|
|
122
|
+
* Returns true if Google Pay API is available.
|
|
123
|
+
*/
|
|
124
|
+
initialize(config: AirwallexGooglePayConfig): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Build the allowed payment methods configuration for Google Pay.
|
|
127
|
+
*/
|
|
128
|
+
private getAllowedPaymentMethods;
|
|
129
|
+
/**
|
|
130
|
+
* Check if the user can make a payment with Google Pay.
|
|
131
|
+
*/
|
|
132
|
+
canMakePayment(): Promise<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* Show the Google Pay payment sheet and return the encrypted token.
|
|
135
|
+
*/
|
|
136
|
+
showPaymentSheet(): Promise<AirwallexShowPaymentResult>;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { GooglePayEncryptedToken as a, AirwallexShowPaymentResult as i, AirwallexGooglePayConfig as n, AirwallexGooglePayMockScenario as r, AirwallexGooglePayAdapter as t };
|
|
140
|
+
//# sourceMappingURL=airwallex-google-pay-adapter-Be2Af4N9.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airwallex-google-pay-adapter-Be2Af4N9.d.mts","names":[],"sources":["../src/payment-methods/airwallex-google-pay-adapter.ts"],"sourcesContent":[],"mappings":";;AAeA;AAIC;;;;;AASoF;AAOtD;;;;;;AAMiB,aA1BpC,8BAAA;EA0B2C,IAAA,GAAA,MAAA;EAG7C,OAAA,GAAA,SAAA;EAMA,SAAA,GAAA,WAAoB;AAAA;AAUyB,QAG7C,MAAA,CAAA;EAQA,UAAA,MAAA,CAAA;IAaA,MAAA,CAAA,EAAA;MAeO,QAAA,EAAA;QAUA,GAAA,EAAA;UAUL,cAA0B,EAAA,KAAA,MACV,EA5FW,qBA4FY,EAAA,GA5Fc,oBA4Fd;QAItC,CAAA;MAKgB,CAAA;IAQR,CAAA;EAqDK;;UA3JhB,qBAAA,CAwLkB;EAAO,WAAA,EAAA,MAAA,GAAA,YAAA;;UApLzB,oBAAA;wBACc,sBAAsB,QAAQ;2BAC3B,qBAAqB,QAAQ;;UAG9C,mBAAA;;;yBAGe;;UAGf,oBAAA;;;UAIA,oBAAA;;;;;;8BAMoB;;UAGpB,yBAAA;;;;;;;UAQA,kBAAA,SAA2B;;;;;;;;;;;;UAa3B,WAAA;;;;;;;;;;;;;UAeO,uBAAA;;;;;;;;;UAUA,wBAAA;;;;;;;;;KAUL,0BAAA;;SACgB;;;;;;;;cAIf,yBAAA;;;;6BAKgB;;;;;qBAQR;;;;;;;;oBAqDK;;;;sBA6BE,QAAQ"}
|