@tap-payments/apple-pay-button 1.1.1 → 1.1.3
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/@types/index.d.ts
CHANGED
|
@@ -80,8 +80,8 @@ export interface ApplePayButtonProps {
|
|
|
80
80
|
onShippingContactSelected?: (shippingContact: ApplePayPaymentContact) => Promise<ApplePayUpdateData>;
|
|
81
81
|
onPaymentMethodSelected?: (paymentMethod: ApplePayPaymentMethod) => Promise<ApplePayUpdateData>;
|
|
82
82
|
onCouponChanged?: (couponCode: string) => Promise<ApplePayUpdateData>;
|
|
83
|
-
metaData?: MetaData;
|
|
84
83
|
debug?: boolean;
|
|
84
|
+
metaData?: MetaData;
|
|
85
85
|
}
|
|
86
86
|
export interface MerchantResponse {
|
|
87
87
|
id: string;
|
|
@@ -45,6 +45,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
48
59
|
import { useCallback, useEffect, useState } from 'react';
|
|
49
60
|
import appService from '../api/app.service';
|
|
50
61
|
import { ApplePayVersion } from '../constants';
|
|
@@ -207,45 +218,48 @@ export var useApplePay = function (_a) {
|
|
|
207
218
|
});
|
|
208
219
|
}); };
|
|
209
220
|
session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
210
|
-
var newEvent,
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
var _a, token, rest, newEvent, _b, _c, paymentData, paymentMethod_1, transactionIdentifier, data, error_2;
|
|
222
|
+
var _d, _e;
|
|
223
|
+
return __generator(this, function (_f) {
|
|
224
|
+
switch (_f.label) {
|
|
213
225
|
case 0:
|
|
214
226
|
setLoading(true);
|
|
215
227
|
if (debug)
|
|
216
228
|
console.info('onpaymentauthorized event', event);
|
|
217
|
-
|
|
229
|
+
_f.label = 1;
|
|
218
230
|
case 1:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
switch (
|
|
231
|
+
_f.trys.push([1, 9, 10, 11]);
|
|
232
|
+
_a = (_d = event.payment) !== null && _d !== void 0 ? _d : {}, token = _a.token, rest = __rest(_a, ["token"]);
|
|
233
|
+
newEvent = { payment: rest };
|
|
234
|
+
_b = scope;
|
|
235
|
+
switch (_b) {
|
|
224
236
|
case 'AppleToken': return [3, 2];
|
|
225
237
|
case 'TapToken': return [3, 4];
|
|
226
238
|
}
|
|
227
239
|
return [3, 7];
|
|
228
|
-
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token
|
|
240
|
+
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token, newEvent))];
|
|
229
241
|
case 3:
|
|
230
|
-
|
|
242
|
+
_f.sent();
|
|
231
243
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
232
244
|
return [3, 8];
|
|
233
|
-
case 4:
|
|
245
|
+
case 4:
|
|
246
|
+
_c = (_e = event.payment.token) !== null && _e !== void 0 ? _e : {}, paymentData = _c.paymentData, paymentMethod_1 = _c.paymentMethod, transactionIdentifier = _c.transactionIdentifier;
|
|
247
|
+
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod_1, transactionIdentifier: transactionIdentifier }))];
|
|
234
248
|
case 5:
|
|
235
|
-
data =
|
|
249
|
+
data = _f.sent();
|
|
236
250
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data, newEvent))];
|
|
237
251
|
case 6:
|
|
238
|
-
|
|
252
|
+
_f.sent();
|
|
239
253
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
240
254
|
return [3, 8];
|
|
241
255
|
case 7:
|
|
242
256
|
console.error('We only support AppleToken and TapToken for now');
|
|
243
257
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
244
258
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
245
|
-
|
|
259
|
+
_f.label = 8;
|
|
246
260
|
case 8: return [3, 11];
|
|
247
261
|
case 9:
|
|
248
|
-
error_2 =
|
|
262
|
+
error_2 = _f.sent();
|
|
249
263
|
if (debug)
|
|
250
264
|
console.error('error in onpaymentauthorized', error_2);
|
|
251
265
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
@@ -28,7 +28,7 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
|
|
|
28
28
|
onShippingContactSelected?: ((shippingContact: import("../@types").ApplePayPaymentContact) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
29
29
|
onPaymentMethodSelected?: ((paymentMethod: import("../@types").ApplePayPaymentMethod) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
30
30
|
onCouponChanged?: ((couponCode: string) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
31
|
-
metaData?: import("../@types").MetaData | undefined;
|
|
32
31
|
debug?: boolean | undefined;
|
|
32
|
+
metaData?: import("../@types").MetaData | undefined;
|
|
33
33
|
};
|
|
34
34
|
export declare const getMerchantCapaplities: (supportedCards?: Array<string>) => ("supports3DS" | "supportsCredit" | "supportsDebit")[];
|