@tap-payments/apple-pay-button 0.0.80-development → 0.0.82-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.
|
@@ -104,7 +104,7 @@ export interface ApplePayButtonProps {
|
|
|
104
104
|
onOrderCreated?: (orderId: string) => void;
|
|
105
105
|
onCancel?: () => void;
|
|
106
106
|
onError?: (error: any) => void;
|
|
107
|
-
onSuccess?: (data: Record<string, any>) => void
|
|
107
|
+
onSuccess?: (data: Record<string, any>) => Promise<void>;
|
|
108
108
|
onClick?: (data?: ApplePayDataToLunchSDKFromMerchantSide) => void;
|
|
109
109
|
onReady?: () => void;
|
|
110
110
|
metaData?: MetaData;
|
|
@@ -71,7 +71,7 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
71
71
|
onOrderCreated?: ((orderId: string) => void) | undefined;
|
|
72
72
|
onCancel?: (() => void) | undefined;
|
|
73
73
|
onError?: ((error: any) => void) | undefined;
|
|
74
|
-
onSuccess?: ((data: Record<string, any>) => void) | undefined;
|
|
74
|
+
onSuccess?: ((data: Record<string, any>) => Promise<void>) | undefined;
|
|
75
75
|
onClick?: ((data?: ApplePayDataToLunchSDKFromMerchantSide | undefined) => void) | undefined;
|
|
76
76
|
onReady?: (() => void) | undefined;
|
|
77
77
|
metaData?: MetaData | undefined;
|
|
@@ -263,33 +263,36 @@ export var useApplePay = function (_a) {
|
|
|
263
263
|
console.info('onpaymentauthorized event', event);
|
|
264
264
|
_v.label = 1;
|
|
265
265
|
case 1:
|
|
266
|
-
_v.trys.push([1,
|
|
266
|
+
_v.trys.push([1, 16, 17, 18]);
|
|
267
267
|
_a = scope;
|
|
268
268
|
switch (_a) {
|
|
269
269
|
case Scope.APPLE_PAY_TOKEN: return [3, 2];
|
|
270
|
-
case Scope.TAP_TOKEN: return [3,
|
|
271
|
-
case Scope.AUTHORIZE: return [3,
|
|
272
|
-
case Scope.CHARGE: return [3,
|
|
270
|
+
case Scope.TAP_TOKEN: return [3, 4];
|
|
271
|
+
case Scope.AUTHORIZE: return [3, 7];
|
|
272
|
+
case Scope.CHARGE: return [3, 7];
|
|
273
273
|
}
|
|
274
|
-
return [3,
|
|
275
|
-
case 2:
|
|
276
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token);
|
|
277
|
-
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
278
|
-
return [3, 12];
|
|
274
|
+
return [3, 14];
|
|
275
|
+
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token))];
|
|
279
276
|
case 3:
|
|
277
|
+
_v.sent();
|
|
278
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
279
|
+
return [3, 15];
|
|
280
|
+
case 4:
|
|
280
281
|
setLoading(true);
|
|
281
282
|
_b = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _b.paymentData, paymentMethod = _b.paymentMethod, transactionIdentifier = _b.transactionIdentifier;
|
|
282
283
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
283
|
-
case
|
|
284
|
+
case 5:
|
|
284
285
|
data = _v.sent();
|
|
285
286
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
286
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
setLoading(true);
|
|
287
|
+
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data))];
|
|
288
|
+
case 6:
|
|
289
|
+
_v.sent();
|
|
290
290
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
291
|
+
return [3, 15];
|
|
292
|
+
case 7:
|
|
293
|
+
setLoading(true);
|
|
291
294
|
return [4, appService.tapTokenization(__assign(__assign(__assign({}, event.payment.token.paymentData), event.payment.token), { paymentData: undefined }))];
|
|
292
|
-
case
|
|
295
|
+
case 8:
|
|
293
296
|
tokenId = (_v.sent()).id;
|
|
294
297
|
supportCurrency = ((_f = (_e = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _e === void 0 ? void 0 : _e.supported_currencies) !== null && _f !== void 0 ? _f : [])[0];
|
|
295
298
|
transactionRequest = {
|
|
@@ -329,16 +332,16 @@ export var useApplePay = function (_a) {
|
|
|
329
332
|
transaction: transaction === null || transaction === void 0 ? void 0 : transaction.reference
|
|
330
333
|
}
|
|
331
334
|
};
|
|
332
|
-
if (!(scope === Scope.AUTHORIZE)) return [3,
|
|
335
|
+
if (!(scope === Scope.AUTHORIZE)) return [3, 10];
|
|
333
336
|
return [4, appService.createAuthorize(transactionRequest)];
|
|
334
|
-
case 7:
|
|
335
|
-
_c = _v.sent();
|
|
336
|
-
return [3, 10];
|
|
337
|
-
case 8: return [4, appService.createCharge(transactionRequest)];
|
|
338
337
|
case 9:
|
|
339
338
|
_c = _v.sent();
|
|
340
|
-
|
|
341
|
-
case 10:
|
|
339
|
+
return [3, 12];
|
|
340
|
+
case 10: return [4, appService.createCharge(transactionRequest)];
|
|
341
|
+
case 11:
|
|
342
|
+
_c = _v.sent();
|
|
343
|
+
_v.label = 12;
|
|
344
|
+
case 12:
|
|
342
345
|
transactionResponse = _c;
|
|
343
346
|
successState = scope === Scope.AUTHORIZE ? ChargeCode.AUTHORIZED : ChargeCode.SUCCESS;
|
|
344
347
|
if ((transactionResponse === null || transactionResponse === void 0 ? void 0 : transactionResponse.response.code) === successState) {
|
|
@@ -347,25 +350,28 @@ export var useApplePay = function (_a) {
|
|
|
347
350
|
else {
|
|
348
351
|
setError === null || setError === void 0 ? void 0 : setError(true);
|
|
349
352
|
}
|
|
350
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionResponse);
|
|
351
|
-
|
|
352
|
-
|
|
353
|
+
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionResponse))];
|
|
354
|
+
case 13:
|
|
355
|
+
_v.sent();
|
|
356
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
357
|
+
return [3, 15];
|
|
358
|
+
case 14:
|
|
353
359
|
console.error('We only support AppleToken and TapToken for now');
|
|
354
360
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
355
361
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
356
|
-
_v.label =
|
|
357
|
-
case
|
|
358
|
-
case
|
|
362
|
+
_v.label = 15;
|
|
363
|
+
case 15: return [3, 18];
|
|
364
|
+
case 16:
|
|
359
365
|
error_2 = _v.sent();
|
|
360
366
|
if (debug)
|
|
361
367
|
console.error('error in onpaymentauthorized', error_2);
|
|
362
368
|
setError(true);
|
|
363
369
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
364
370
|
throw error_2;
|
|
365
|
-
case
|
|
371
|
+
case 17:
|
|
366
372
|
setLoading(false);
|
|
367
373
|
return [7];
|
|
368
|
-
case
|
|
374
|
+
case 18: return [2];
|
|
369
375
|
}
|
|
370
376
|
});
|
|
371
377
|
}); };
|