@tap-payments/apple-pay-button 0.0.6-staging → 0.0.7-staging
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/charge.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
amount: number;
|
|
7
|
-
currency: string;
|
|
8
|
-
selected_amount?: number;
|
|
9
|
-
selected_currency?: string;
|
|
10
|
-
product: string;
|
|
1
|
+
import { ChargeRequestBodyBase } from '@tap-payments/acceptance-sdk';
|
|
2
|
+
export interface ChargeRequestBody extends ChargeRequestBodyBase {
|
|
3
|
+
amount?: number;
|
|
4
|
+
currency?: string;
|
|
5
|
+
product: 'Apple-Pay-Button';
|
|
11
6
|
threeDSecure?: boolean;
|
|
12
|
-
save_card
|
|
13
|
-
customer
|
|
7
|
+
save_card?: boolean;
|
|
8
|
+
customer?: {
|
|
14
9
|
id?: string;
|
|
15
10
|
first_name?: string;
|
|
16
11
|
middle_name?: string;
|
|
@@ -68,6 +68,9 @@ export declare const useApplePay: ({ buttonProps }: UseApplePayParams) => {
|
|
|
68
68
|
onCancel?: (() => void) | undefined;
|
|
69
69
|
onSuccess?: ((data: any) => void) | undefined;
|
|
70
70
|
onBinIdentification?: ((data: any) => void) | undefined;
|
|
71
|
+
onIntentCreated?: ((intent: Partial<import("@tap-payments/acceptance-sdk").IntentAPI.Response> & {
|
|
72
|
+
[x: string]: any;
|
|
73
|
+
}) => Promise<void>) | undefined;
|
|
71
74
|
onChargeCreated?: ((charge: Record<string, any>) => void) | undefined;
|
|
72
75
|
onOrderCreated?: ((orderId: string) => void) | undefined;
|
|
73
76
|
};
|
|
@@ -228,15 +228,15 @@ export var useApplePay = function (_a) {
|
|
|
228
228
|
}); };
|
|
229
229
|
session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
230
230
|
var _a, paymentData, paymentMethod, transactionIdentifier, _b, data, tokenId, supportedCurrency, transactionRequest, transactionResponse, _c, successState, error_2;
|
|
231
|
-
var _d
|
|
232
|
-
return __generator(this, function (
|
|
233
|
-
switch (
|
|
231
|
+
var _d;
|
|
232
|
+
return __generator(this, function (_e) {
|
|
233
|
+
switch (_e.label) {
|
|
234
234
|
case 0:
|
|
235
235
|
if (debug)
|
|
236
236
|
console.info('onpaymentauthorized event', event);
|
|
237
|
-
|
|
237
|
+
_e.label = 1;
|
|
238
238
|
case 1:
|
|
239
|
-
|
|
239
|
+
_e.trys.push([1, 16, 17, 18]);
|
|
240
240
|
_a = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _a.paymentData, paymentMethod = _a.paymentMethod, transactionIdentifier = _a.transactionIdentifier;
|
|
241
241
|
_b = scope;
|
|
242
242
|
switch (_b) {
|
|
@@ -248,71 +248,42 @@ export var useApplePay = function (_a) {
|
|
|
248
248
|
return [3, 14];
|
|
249
249
|
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token))];
|
|
250
250
|
case 3:
|
|
251
|
-
|
|
251
|
+
_e.sent();
|
|
252
252
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
253
253
|
return [3, 15];
|
|
254
254
|
case 4:
|
|
255
255
|
setLoading(true);
|
|
256
256
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
257
257
|
case 5:
|
|
258
|
-
data =
|
|
258
|
+
data = _e.sent();
|
|
259
259
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
260
260
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data))];
|
|
261
261
|
case 6:
|
|
262
|
-
|
|
262
|
+
_e.sent();
|
|
263
263
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
264
264
|
return [3, 15];
|
|
265
265
|
case 7:
|
|
266
266
|
setLoading(true);
|
|
267
267
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
268
268
|
case 8:
|
|
269
|
-
tokenId = (
|
|
269
|
+
tokenId = (_e.sent()).id;
|
|
270
270
|
supportedCurrency = getSelectedCurrency((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.supported_currencies) || [], order, applePayPaymentMethodOptions);
|
|
271
271
|
transactionRequest = {
|
|
272
|
-
|
|
273
|
-
amount: (_h = (_g = (_f = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _f === void 0 ? void 0 : _f.order) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : order.amount,
|
|
274
|
-
currency: (_l = (_k = (_j = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _j === void 0 ? void 0 : _j.order) === null || _k === void 0 ? void 0 : _k.currency) !== null && _l !== void 0 ? _l : order.currency,
|
|
272
|
+
intent: transaction === null || transaction === void 0 ? void 0 : transaction.intent,
|
|
275
273
|
selected_amount: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.amount,
|
|
276
274
|
selected_currency: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.currency,
|
|
277
|
-
customer: (customer === null || customer === void 0 ? void 0 : customer.id)
|
|
278
|
-
? { id: customer === null || customer === void 0 ? void 0 : customer.id }
|
|
279
|
-
: {
|
|
280
|
-
email: (_m = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _m === void 0 ? void 0 : _m.email,
|
|
281
|
-
first_name: ((_o = customer === null || customer === void 0 ? void 0 : customer.name) === null || _o === void 0 ? void 0 : _o.length) ? customer.name[0].first : '',
|
|
282
|
-
last_name: ((_p = customer === null || customer === void 0 ? void 0 : customer.name) === null || _p === void 0 ? void 0 : _p.length) ? customer.name[0].last : '',
|
|
283
|
-
phone: {
|
|
284
|
-
country_code: (_s = (_r = (_q = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _q === void 0 ? void 0 : _q.phone) === null || _r === void 0 ? void 0 : _r.countryCode) !== null && _s !== void 0 ? _s : '',
|
|
285
|
-
number: (_v = (_u = (_t = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _t === void 0 ? void 0 : _t.phone) === null || _u === void 0 ? void 0 : _u.number) !== null && _v !== void 0 ? _v : ''
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
merchant: {
|
|
289
|
-
id: (_x = (_w = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _w === void 0 ? void 0 : _w.id) !== null && _x !== void 0 ? _x : ''
|
|
290
|
-
},
|
|
291
|
-
order: (_y = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _y === void 0 ? void 0 : _y.order,
|
|
292
275
|
product: 'Apple-Pay-Button',
|
|
293
|
-
|
|
294
|
-
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' },
|
|
295
|
-
threeDSecure: (_1 = (_0 = transaction === null || transaction === void 0 ? void 0 : transaction.authenticate) === null || _0 === void 0 ? void 0 : _0.required) !== null && _1 !== void 0 ? _1 : true,
|
|
296
|
-
hashstring: operator.hashstring,
|
|
297
|
-
redirect: redirect,
|
|
298
|
-
metadata: transaction === null || transaction === void 0 ? void 0 : transaction.metadata,
|
|
299
|
-
post: post,
|
|
300
|
-
payment_agreement: transaction === null || transaction === void 0 ? void 0 : transaction.paymentAgreement,
|
|
301
|
-
destinations: transaction === null || transaction === void 0 ? void 0 : transaction.destinations,
|
|
302
|
-
reference: {
|
|
303
|
-
order: order === null || order === void 0 ? void 0 : order.reference,
|
|
304
|
-
transaction: transaction === null || transaction === void 0 ? void 0 : transaction.reference
|
|
305
|
-
}
|
|
276
|
+
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' }
|
|
306
277
|
};
|
|
307
278
|
if (!(scope === Scope.AUTHORIZE)) return [3, 10];
|
|
308
279
|
return [4, appService.createAuthorize(transactionRequest)];
|
|
309
280
|
case 9:
|
|
310
|
-
_c =
|
|
281
|
+
_c = _e.sent();
|
|
311
282
|
return [3, 12];
|
|
312
283
|
case 10: return [4, appService.createCharge(transactionRequest)];
|
|
313
284
|
case 11:
|
|
314
|
-
_c =
|
|
315
|
-
|
|
285
|
+
_c = _e.sent();
|
|
286
|
+
_e.label = 12;
|
|
316
287
|
case 12:
|
|
317
288
|
transactionResponse = _c;
|
|
318
289
|
successState = scope === Scope.AUTHORIZE ? ChargeCode.AUTHORIZED : ChargeCode.SUCCESS;
|
|
@@ -324,17 +295,17 @@ export var useApplePay = function (_a) {
|
|
|
324
295
|
}
|
|
325
296
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionResponse))];
|
|
326
297
|
case 13:
|
|
327
|
-
|
|
298
|
+
_e.sent();
|
|
328
299
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
329
300
|
return [3, 15];
|
|
330
301
|
case 14:
|
|
331
302
|
console.error('We only support AppleToken and TapToken for now');
|
|
332
303
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
333
304
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
334
|
-
|
|
305
|
+
_e.label = 15;
|
|
335
306
|
case 15: return [3, 18];
|
|
336
307
|
case 16:
|
|
337
|
-
error_2 =
|
|
308
|
+
error_2 = _e.sent();
|
|
338
309
|
if (debug)
|
|
339
310
|
console.error('error in onpaymentauthorized', error_2);
|
|
340
311
|
setError(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/apple-pay-button",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-staging",
|
|
4
4
|
"description": "Apple Pay Button React Component",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "ISC",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tap-payments/acceptance-sdk": "0.0.
|
|
32
|
+
"@tap-payments/acceptance-sdk": "0.0.67",
|
|
33
33
|
"@tap-payments/browser-info": "^1.0.2",
|
|
34
34
|
"@tap-payments/web-error-handing": "^1.0.1",
|
|
35
35
|
"axios": "^1.2.2",
|