@tap-payments/apple-pay-button 1.1.2 → 1.1.4
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 +17 -14
- package/package.json +1 -1
|
@@ -206,6 +206,7 @@ export var useApplePay = function (_a) {
|
|
|
206
206
|
return [3, 4];
|
|
207
207
|
case 3:
|
|
208
208
|
error_1 = _a.sent();
|
|
209
|
+
setLoading(false);
|
|
209
210
|
onMerchantValidation === null || onMerchantValidation === void 0 ? void 0 : onMerchantValidation('error');
|
|
210
211
|
if (debug)
|
|
211
212
|
console.error('error in onvalidatemerchant', error_1);
|
|
@@ -218,18 +219,18 @@ export var useApplePay = function (_a) {
|
|
|
218
219
|
});
|
|
219
220
|
}); };
|
|
220
221
|
session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
221
|
-
var _a, token, rest, newEvent, _b, data, error_2;
|
|
222
|
-
var
|
|
223
|
-
return __generator(this, function (
|
|
224
|
-
switch (
|
|
222
|
+
var _a, token, rest, newEvent, _b, _c, paymentData, paymentMethod_1, transactionIdentifier, data, error_2;
|
|
223
|
+
var _d, _e;
|
|
224
|
+
return __generator(this, function (_f) {
|
|
225
|
+
switch (_f.label) {
|
|
225
226
|
case 0:
|
|
226
227
|
setLoading(true);
|
|
227
228
|
if (debug)
|
|
228
229
|
console.info('onpaymentauthorized event', event);
|
|
229
|
-
|
|
230
|
+
_f.label = 1;
|
|
230
231
|
case 1:
|
|
231
|
-
|
|
232
|
-
_a = (
|
|
232
|
+
_f.trys.push([1, 9, 10, 11]);
|
|
233
|
+
_a = (_d = event.payment) !== null && _d !== void 0 ? _d : {}, token = _a.token, rest = __rest(_a, ["token"]);
|
|
233
234
|
newEvent = { payment: rest };
|
|
234
235
|
_b = scope;
|
|
235
236
|
switch (_b) {
|
|
@@ -237,27 +238,29 @@ export var useApplePay = function (_a) {
|
|
|
237
238
|
case 'TapToken': return [3, 4];
|
|
238
239
|
}
|
|
239
240
|
return [3, 7];
|
|
240
|
-
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token
|
|
241
|
+
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token, newEvent))];
|
|
241
242
|
case 3:
|
|
242
|
-
|
|
243
|
+
_f.sent();
|
|
243
244
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
244
245
|
return [3, 8];
|
|
245
|
-
case 4:
|
|
246
|
+
case 4:
|
|
247
|
+
_c = (_e = event.payment.token) !== null && _e !== void 0 ? _e : {}, paymentData = _c.paymentData, paymentMethod_1 = _c.paymentMethod, transactionIdentifier = _c.transactionIdentifier;
|
|
248
|
+
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod_1, transactionIdentifier: transactionIdentifier }))];
|
|
246
249
|
case 5:
|
|
247
|
-
data =
|
|
250
|
+
data = _f.sent();
|
|
248
251
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data, newEvent))];
|
|
249
252
|
case 6:
|
|
250
|
-
|
|
253
|
+
_f.sent();
|
|
251
254
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
252
255
|
return [3, 8];
|
|
253
256
|
case 7:
|
|
254
257
|
console.error('We only support AppleToken and TapToken for now');
|
|
255
258
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
256
259
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
257
|
-
|
|
260
|
+
_f.label = 8;
|
|
258
261
|
case 8: return [3, 11];
|
|
259
262
|
case 9:
|
|
260
|
-
error_2 =
|
|
263
|
+
error_2 = _f.sent();
|
|
261
264
|
if (debug)
|
|
262
265
|
console.error('error in onpaymentauthorized', error_2);
|
|
263
266
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|