@tap-payments/apple-pay-button 1.2.6 → 1.2.7
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/build/hooks/useApplePay.js +14 -8
- package/package.json +1 -1
|
@@ -155,7 +155,7 @@ export var useApplePay = function (_a) {
|
|
|
155
155
|
initialize(metaData);
|
|
156
156
|
}, [isScriptLoaded, initialize, metaData]);
|
|
157
157
|
var onApplePayButtonClicked = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
-
var ApplePaySession,
|
|
158
|
+
var ApplePaySession, paymentMethod, currency, cardBrands, request, session_1;
|
|
159
159
|
return __generator(this, function (_a) {
|
|
160
160
|
ApplePaySession = window.ApplePaySession;
|
|
161
161
|
if (!ApplePaySession) {
|
|
@@ -169,9 +169,15 @@ export var useApplePay = function (_a) {
|
|
|
169
169
|
return [2];
|
|
170
170
|
}
|
|
171
171
|
try {
|
|
172
|
-
|
|
173
|
-
currency = validateCurrency(transaction.currency,
|
|
174
|
-
cardBrands = validateSupportedNetworks(
|
|
172
|
+
paymentMethod = getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
|
|
173
|
+
currency = validateCurrency(transaction.currency, paymentMethod.supported_currencies);
|
|
174
|
+
cardBrands = validateSupportedNetworks(paymentMethod.supported_card_brands, acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedBrands);
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
onError === null || onError === void 0 ? void 0 : onError([{ description: e.message, code: '400' }]);
|
|
178
|
+
return [2];
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
175
181
|
request = getApplePayRequest({
|
|
176
182
|
features: features,
|
|
177
183
|
countryCode: profileData.merchant.country_code,
|
|
@@ -204,7 +210,7 @@ export var useApplePay = function (_a) {
|
|
|
204
210
|
console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
|
|
205
211
|
}
|
|
206
212
|
return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id }), event.validationURL, merchant.domain, integration === Integration.Webview
|
|
207
|
-
?
|
|
213
|
+
? paymentMethod.identifier || FALLBACK_MERCHANT_IDENTIFIER
|
|
208
214
|
: merchant.identifier || merchant.id)];
|
|
209
215
|
case 2:
|
|
210
216
|
merchantSession = _a.sent();
|
|
@@ -230,7 +236,7 @@ export var useApplePay = function (_a) {
|
|
|
230
236
|
});
|
|
231
237
|
}); };
|
|
232
238
|
session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
233
|
-
var _a, token, rest, newEvent, _b, _c, paymentData,
|
|
239
|
+
var _a, token, rest, newEvent, _b, _c, paymentData, paymentMethod_1, transactionIdentifier, data, error_2;
|
|
234
240
|
var _d, _e;
|
|
235
241
|
return __generator(this, function (_f) {
|
|
236
242
|
switch (_f.label) {
|
|
@@ -255,8 +261,8 @@ export var useApplePay = function (_a) {
|
|
|
255
261
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
256
262
|
return [3, 8];
|
|
257
263
|
case 4:
|
|
258
|
-
_c = (_e = event.payment.token) !== null && _e !== void 0 ? _e : {}, paymentData = _c.paymentData,
|
|
259
|
-
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod:
|
|
264
|
+
_c = (_e = event.payment.token) !== null && _e !== void 0 ? _e : {}, paymentData = _c.paymentData, paymentMethod_1 = _c.paymentMethod, transactionIdentifier = _c.transactionIdentifier;
|
|
265
|
+
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod_1, transactionIdentifier: transactionIdentifier }))];
|
|
260
266
|
case 5:
|
|
261
267
|
data = _f.sent();
|
|
262
268
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data, newEvent))];
|