@tap-payments/apple-pay-button 1.2.3 → 1.2.5
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 +6 -20
- package/build/utils/error.d.ts +1 -0
- package/build/utils/error.js +13 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -61,6 +61,7 @@ import appService from '../api/app.service';
|
|
|
61
61
|
import { ApplePayVersion, FALLBACK_MERCHANT_IDENTIFIER, Integration } from '../constants';
|
|
62
62
|
import { setAxiosGlobalHeaders } from '../api/httpClient';
|
|
63
63
|
import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
|
|
64
|
+
import { shapeApplePayError } from '../utils';
|
|
64
65
|
import { getMerchantCapaplities } from '../utils/defaultValues';
|
|
65
66
|
import { useApplePayScript } from './useApplePayScript';
|
|
66
67
|
export var useApplePay = function (_a) {
|
|
@@ -135,14 +136,14 @@ export var useApplePay = function (_a) {
|
|
|
135
136
|
if (debug)
|
|
136
137
|
console.log('merchant configuration: ', data);
|
|
137
138
|
setProfile(data);
|
|
139
|
+
onReady && onReady();
|
|
138
140
|
return [3, 6];
|
|
139
141
|
case 4:
|
|
140
142
|
err_1 = _h.sent();
|
|
141
|
-
onError && onError(err_1
|
|
143
|
+
onError && onError(shapeApplePayError(err_1));
|
|
142
144
|
return [3, 6];
|
|
143
145
|
case 5:
|
|
144
146
|
setLoading(false);
|
|
145
|
-
onReady && onReady();
|
|
146
147
|
return [7];
|
|
147
148
|
case 6: return [2];
|
|
148
149
|
}
|
|
@@ -155,8 +156,7 @@ export var useApplePay = function (_a) {
|
|
|
155
156
|
}, [isScriptLoaded, initialize, metaData]);
|
|
156
157
|
var onApplePayButtonClicked = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
157
158
|
var ApplePaySession, paymentMethod_1, currency, cardBrands, request, session_1;
|
|
158
|
-
|
|
159
|
-
return __generator(this, function (_b) {
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
160
|
ApplePaySession = window.ApplePaySession;
|
|
161
161
|
if (!ApplePaySession) {
|
|
162
162
|
setDisabled(true);
|
|
@@ -268,7 +268,7 @@ export var useApplePay = function (_a) {
|
|
|
268
268
|
console.error('We only support AppleToken and TapToken for now');
|
|
269
269
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
270
270
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
271
|
-
|
|
271
|
+
throw new Error('We only support AppleToken and TapToken for now');
|
|
272
272
|
case 8: return [3, 11];
|
|
273
273
|
case 9:
|
|
274
274
|
error_2 = _f.sent();
|
|
@@ -367,21 +367,7 @@ export var useApplePay = function (_a) {
|
|
|
367
367
|
session_1.begin();
|
|
368
368
|
}
|
|
369
369
|
catch (e) {
|
|
370
|
-
|
|
371
|
-
return [2];
|
|
372
|
-
if (e.errors) {
|
|
373
|
-
onError(e.errors);
|
|
374
|
-
return [2];
|
|
375
|
-
}
|
|
376
|
-
if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data.errors) {
|
|
377
|
-
onError(e.response.data.errors);
|
|
378
|
-
return [2];
|
|
379
|
-
}
|
|
380
|
-
if (e.message) {
|
|
381
|
-
onError([{ description: e.message, code: '400' }]);
|
|
382
|
-
return [2];
|
|
383
|
-
}
|
|
384
|
-
onError(e);
|
|
370
|
+
onError && onError(shapeApplePayError(e));
|
|
385
371
|
}
|
|
386
372
|
return [2];
|
|
387
373
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shapeApplePayError: (error: any) => any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var shapeApplePayError = function (error) {
|
|
2
|
+
var _a, _b;
|
|
3
|
+
if (error === null || error === void 0 ? void 0 : error.errors) {
|
|
4
|
+
return error.errors;
|
|
5
|
+
}
|
|
6
|
+
if ((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) {
|
|
7
|
+
return error.response.data.errors;
|
|
8
|
+
}
|
|
9
|
+
if (error === null || error === void 0 ? void 0 : error.message) {
|
|
10
|
+
return [{ description: error.message, code: '400' }];
|
|
11
|
+
}
|
|
12
|
+
return error;
|
|
13
|
+
};
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED