@tap-payments/apple-pay-button 1.1.0 → 1.1.2

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.
@@ -72,7 +72,7 @@ export interface ApplePayButtonProps {
72
72
  features: Features;
73
73
  onCancel?: () => void;
74
74
  onError?: (error: any) => void;
75
- onSuccess?: (data: Record<string, any>) => Promise<void>;
75
+ onSuccess?: (data: Record<string, any>, event?: Record<string, any>) => Promise<void>;
76
76
  onClick?: () => void;
77
77
  onReady?: () => void;
78
78
  onMerchantValidation?: (status: 'initiated' | 'completed' | 'error') => void;
@@ -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,43 +218,46 @@ 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 _a, data, error_2;
211
- return __generator(this, function (_b) {
212
- switch (_b.label) {
221
+ var _a, token, rest, newEvent, _b, data, error_2;
222
+ var _c;
223
+ return __generator(this, function (_d) {
224
+ switch (_d.label) {
213
225
  case 0:
214
226
  setLoading(true);
215
227
  if (debug)
216
228
  console.info('onpaymentauthorized event', event);
217
- _b.label = 1;
229
+ _d.label = 1;
218
230
  case 1:
219
- _b.trys.push([1, 9, 10, 11]);
220
- _a = scope;
221
- switch (_a) {
231
+ _d.trys.push([1, 9, 10, 11]);
232
+ _a = (_c = event.payment) !== null && _c !== void 0 ? _c : {}, token = _a.token, rest = __rest(_a, ["token"]);
233
+ newEvent = { payment: rest };
234
+ _b = scope;
235
+ switch (_b) {
222
236
  case 'AppleToken': return [3, 2];
223
237
  case 'TapToken': return [3, 4];
224
238
  }
225
239
  return [3, 7];
226
- case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token.paymentData))];
240
+ case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token.paymentData, newEvent))];
227
241
  case 3:
228
- _b.sent();
242
+ _d.sent();
229
243
  session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
230
244
  return [3, 8];
231
245
  case 4: return [4, appService.tapTokenization(event.payment.token.paymentData)];
232
246
  case 5:
233
- data = _b.sent();
234
- return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data))];
247
+ data = _d.sent();
248
+ return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data, newEvent))];
235
249
  case 6:
236
- _b.sent();
250
+ _d.sent();
237
251
  session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
238
252
  return [3, 8];
239
253
  case 7:
240
254
  console.error('We only support AppleToken and TapToken for now');
241
255
  console.info('Completing payment with status: STATUS_FAILURE');
242
256
  session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
243
- _b.label = 8;
257
+ _d.label = 8;
244
258
  case 8: return [3, 11];
245
259
  case 9:
246
- error_2 = _b.sent();
260
+ error_2 = _d.sent();
247
261
  if (debug)
248
262
  console.error('error in onpaymentauthorized', error_2);
249
263
  session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
@@ -20,7 +20,7 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
20
20
  features: import("../@types").Features;
21
21
  onCancel?: (() => void) | undefined;
22
22
  onError?: ((error: any) => void) | undefined;
23
- onSuccess?: ((data: Record<string, any>) => Promise<void>) | undefined;
23
+ onSuccess?: ((data: Record<string, any>, event?: Record<string, any> | undefined) => Promise<void>) | undefined;
24
24
  onClick?: (() => void) | undefined;
25
25
  onReady?: (() => void) | undefined;
26
26
  onMerchantValidation?: ((status: "initiated" | "completed" | "error") => void) | undefined;
@@ -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")[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",