@tap-payments/apple-pay-button 0.0.72-development → 0.0.73-development
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 +13 -13
- package/package.json +1 -1
|
@@ -97,14 +97,14 @@ export var useApplePay = function (_a) {
|
|
|
97
97
|
}, [profileData]);
|
|
98
98
|
var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
99
|
var merchantProfile, payment_options, headers_1, data, applePayPreparedData, err_1;
|
|
100
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
101
|
-
return __generator(this, function (
|
|
102
|
-
switch (
|
|
100
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
101
|
+
return __generator(this, function (_p) {
|
|
102
|
+
switch (_p.label) {
|
|
103
103
|
case 0:
|
|
104
104
|
setInitialLoading(true);
|
|
105
|
-
|
|
105
|
+
_p.label = 1;
|
|
106
106
|
case 1:
|
|
107
|
-
|
|
107
|
+
_p.trys.push([1, 7, , 8]);
|
|
108
108
|
if (!shallRenderApplePay()) {
|
|
109
109
|
throw new Error('The device/customer is not eligible to use ApplePay');
|
|
110
110
|
}
|
|
@@ -117,7 +117,7 @@ export var useApplePay = function (_a) {
|
|
|
117
117
|
if (!headers) return [3, 3];
|
|
118
118
|
return [4, appService.setHttpHeaders(__assign(__assign({}, headers), { authorization: operator.publicKey }))];
|
|
119
119
|
case 2:
|
|
120
|
-
|
|
120
|
+
_p.sent();
|
|
121
121
|
return [3, 5];
|
|
122
122
|
case 3: return [4, appService.setBrowserHeaders({
|
|
123
123
|
locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
|
|
@@ -125,8 +125,8 @@ export var useApplePay = function (_a) {
|
|
|
125
125
|
pk: operator.publicKey
|
|
126
126
|
})];
|
|
127
127
|
case 4:
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
_p.sent();
|
|
129
|
+
_p.label = 5;
|
|
130
130
|
case 5: return [4, appService.checkoutProfile({
|
|
131
131
|
supported_payment_methods: ['APPLE_PAY'],
|
|
132
132
|
supported_currencies: [order.currency],
|
|
@@ -158,24 +158,24 @@ export var useApplePay = function (_a) {
|
|
|
158
158
|
] })
|
|
159
159
|
})];
|
|
160
160
|
case 6:
|
|
161
|
-
data =
|
|
161
|
+
data = _p.sent();
|
|
162
162
|
if (debug)
|
|
163
163
|
console.log('merchant configuration: ', data);
|
|
164
164
|
setProfile(data);
|
|
165
165
|
applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer }));
|
|
166
166
|
setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
|
|
167
|
-
setPaymentMethodIdentifier(applePayPreparedData.paymentMethod.identifier);
|
|
168
|
-
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((
|
|
167
|
+
setPaymentMethodIdentifier((_k = merchant.identifier) !== null && _k !== void 0 ? _k : applePayPreparedData.paymentMethod.identifier);
|
|
168
|
+
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_m = (_l = data.payment_options) === null || _l === void 0 ? void 0 : _l.order) === null || _m === void 0 ? void 0 : _m.id);
|
|
169
169
|
setApplePayRequestConfiguration({
|
|
170
170
|
BASE_URL: MW_BASE_URL,
|
|
171
171
|
headers: getAxiosGlobalHeaders(),
|
|
172
|
-
merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((
|
|
172
|
+
merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((_o = data.merchant) === null || _o === void 0 ? void 0 : _o.id) })
|
|
173
173
|
});
|
|
174
174
|
setInitialLoading(false);
|
|
175
175
|
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
176
176
|
return [3, 8];
|
|
177
177
|
case 7:
|
|
178
|
-
err_1 =
|
|
178
|
+
err_1 = _p.sent();
|
|
179
179
|
onError === null || onError === void 0 ? void 0 : onError(err_1.errors || err_1);
|
|
180
180
|
console.log('error in initialize', err_1);
|
|
181
181
|
return [3, 8];
|