@tap-payments/apple-pay-button 0.0.83-development → 0.0.85-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.
@@ -109,7 +109,7 @@ export interface ApplePayButtonProps {
109
109
  onReady?: () => void;
110
110
  metaData?: MetaData;
111
111
  debug?: boolean;
112
- integration?: 'sdk' | 'iframe';
112
+ integration?: 'sdk' | 'iframe' | 'webview';
113
113
  headers?: {
114
114
  mdn: string;
115
115
  application: string;
@@ -76,7 +76,7 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
76
76
  onReady?: (() => void) | undefined;
77
77
  metaData?: MetaData | undefined;
78
78
  debug?: boolean | undefined;
79
- integration?: "iframe" | "sdk" | undefined;
79
+ integration?: "iframe" | "sdk" | "webview" | undefined;
80
80
  headers?: {
81
81
  mdn: string;
82
82
  application: string;
@@ -77,8 +77,9 @@ export var useApplePay = function (_a) {
77
77
  var _k = useState(false), loading = _k[0], setLoading = _k[1];
78
78
  var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
79
79
  var mappedProps = __assign(__assign({}, buttonProps), { interface: mappingInterface(buttonProps.interface) });
80
- var interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady, metaData = mappedProps.metaData, headers = mappedProps.headers, operator = mappedProps.operator, order = mappedProps.order, onOrderCreated = mappedProps.onOrderCreated, transaction = mappedProps.transaction, post = mappedProps.post, redirect = mappedProps.redirect;
81
- var isIframeIntegration = buttonProps.integration === 'iframe';
80
+ var interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady, metaData = mappedProps.metaData, headers = mappedProps.headers, operator = mappedProps.operator, order = mappedProps.order, onOrderCreated = mappedProps.onOrderCreated, transaction = mappedProps.transaction, post = mappedProps.post, redirect = mappedProps.redirect, integration = mappedProps.integration;
81
+ var isIframeIntegration = integration === 'iframe';
82
+ var isWebViewIntegration = integration === 'webview';
82
83
  useMerchantApplePay({
83
84
  isIframeIntegration: isIframeIntegration,
84
85
  onError: onError,
@@ -233,7 +234,8 @@ export var useApplePay = function (_a) {
233
234
  if (debug) {
234
235
  console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(window.location.hostname));
235
236
  }
236
- return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, merchant.identifier || merchant.id || profileData.merchant.id)];
237
+ return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, (isWebViewIntegration ? applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier : merchant.identifier || merchant.id) ||
238
+ profileData.merchant.id)];
237
239
  case 2:
238
240
  merchantSession = _a.sent();
239
241
  if (debug)
@@ -254,7 +256,7 @@ export var useApplePay = function (_a) {
254
256
  });
255
257
  }); };
256
258
  session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
257
- var _a, _b, paymentData, paymentMethod, transactionIdentifier, data, tokenId, supportCurrency, transactionRequest, transactionResponse, _c, successState, error_2;
259
+ var _a, paymentData, paymentMethod, transactionIdentifier, _b, data, tokenId, supportCurrency, transactionRequest, transactionResponse, _c, successState, error_2;
258
260
  var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
259
261
  return __generator(this, function (_1) {
260
262
  switch (_1.label) {
@@ -264,8 +266,9 @@ export var useApplePay = function (_a) {
264
266
  _1.label = 1;
265
267
  case 1:
266
268
  _1.trys.push([1, 16, 17, 18]);
267
- _a = scope;
268
- switch (_a) {
269
+ _a = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _a.paymentData, paymentMethod = _a.paymentMethod, transactionIdentifier = _a.transactionIdentifier;
270
+ _b = scope;
271
+ switch (_b) {
269
272
  case Scope.APPLE_PAY_TOKEN: return [3, 2];
270
273
  case Scope.TAP_TOKEN: return [3, 4];
271
274
  case Scope.AUTHORIZE: return [3, 7];
@@ -279,7 +282,6 @@ export var useApplePay = function (_a) {
279
282
  return [3, 15];
280
283
  case 4:
281
284
  setLoading(true);
282
- _b = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _b.paymentData, paymentMethod = _b.paymentMethod, transactionIdentifier = _b.transactionIdentifier;
283
285
  return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
284
286
  case 5:
285
287
  data = _1.sent();
@@ -291,7 +293,7 @@ export var useApplePay = function (_a) {
291
293
  return [3, 15];
292
294
  case 7:
293
295
  setLoading(true);
294
- return [4, appService.tapTokenization(__assign(__assign(__assign({}, event.payment.token.paymentData), event.payment.token), { paymentData: undefined }))];
296
+ return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
295
297
  case 8:
296
298
  tokenId = (_1.sent()).id;
297
299
  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];
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,19 +54,20 @@ export var useMerchantApplePay = function (_a) {
43
54
  var onMessageReceived = React.useCallback(function (_a) {
44
55
  var message = _a.data;
45
56
  return __awaiter(void 0, void 0, void 0, function () {
46
- var _b, event, data, _c, response, tokenId, supportCurrency, transactionRequest, transactionResponse, _d, successState, e_1;
47
- var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
48
- return __generator(this, function (_2) {
49
- switch (_2.label) {
57
+ var _b, event, data, _c, paymentData, paymentMethod, transactionIdentifier, _d, response, tokenId, supportCurrency, transactionRequest, transactionResponse, _e, successState, e_1;
58
+ var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
59
+ return __generator(this, function (_3) {
60
+ switch (_3.label) {
50
61
  case 0:
51
62
  _b = message !== null && message !== void 0 ? message : {}, event = _b.event, data = _b.data;
52
63
  if (!data || event !== EVENT_NAME)
53
64
  return [2];
54
- _2.label = 1;
65
+ _c = data !== null && data !== void 0 ? data : {}, paymentData = _c.paymentData, paymentMethod = _c.paymentMethod, transactionIdentifier = _c.transactionIdentifier;
66
+ _3.label = 1;
55
67
  case 1:
56
- _2.trys.push([1, 13, 14, 15]);
57
- _c = scope;
58
- switch (_c) {
68
+ _3.trys.push([1, 13, 14, 15]);
69
+ _d = scope;
70
+ switch (_d) {
59
71
  case Scope.APPLE_PAY_TOKEN: return [3, 2];
60
72
  case Scope.TAP_TOKEN: return [3, 3];
61
73
  case Scope.AUTHORIZE: return [3, 5];
@@ -67,40 +79,40 @@ export var useMerchantApplePay = function (_a) {
67
79
  return [3, 12];
68
80
  case 3:
69
81
  setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
70
- return [4, appService.tapTokenization(data)];
82
+ return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
71
83
  case 4:
72
- response = _2.sent();
84
+ response = _3.sent();
73
85
  setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
74
86
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response);
75
87
  return [3, 12];
76
88
  case 5:
77
89
  setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
78
- return [4, appService.tapTokenization(data)];
90
+ return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
79
91
  case 6:
80
- tokenId = (_2.sent()).id;
81
- 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];
92
+ tokenId = (_3.sent()).id;
93
+ supportCurrency = ((_g = (_f = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _f === void 0 ? void 0 : _f.supported_currencies) !== null && _g !== void 0 ? _g : [])[0];
82
94
  transactionRequest = {
83
- auto: (_g = transaction === null || transaction === void 0 ? void 0 : transaction.authorize) === null || _g === void 0 ? void 0 : _g.auto,
84
- amount: (_k = (_j = (_h = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _h === void 0 ? void 0 : _h.order) === null || _j === void 0 ? void 0 : _j.amount) !== null && _k !== void 0 ? _k : order.amount,
85
- currency: (_o = (_m = (_l = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _l === void 0 ? void 0 : _l.order) === null || _m === void 0 ? void 0 : _m.currency) !== null && _o !== void 0 ? _o : order.currency,
95
+ auto: (_h = transaction === null || transaction === void 0 ? void 0 : transaction.authorize) === null || _h === void 0 ? void 0 : _h.auto,
96
+ amount: (_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.amount) !== null && _l !== void 0 ? _l : order.amount,
97
+ currency: (_p = (_o = (_m = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _m === void 0 ? void 0 : _m.order) === null || _o === void 0 ? void 0 : _o.currency) !== null && _p !== void 0 ? _p : order.currency,
86
98
  selected_amount: supportCurrency === null || supportCurrency === void 0 ? void 0 : supportCurrency.amount,
87
99
  selected_currency: supportCurrency === null || supportCurrency === void 0 ? void 0 : supportCurrency.currency,
88
100
  customer: (customer === null || customer === void 0 ? void 0 : customer.id)
89
101
  ? { id: customer === null || customer === void 0 ? void 0 : customer.id }
90
102
  : {
91
- email: (_p = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _p === void 0 ? void 0 : _p.email,
92
- first_name: ((_q = customer === null || customer === void 0 ? void 0 : customer.name) === null || _q === void 0 ? void 0 : _q.length) ? customer.name[0].first : '',
93
- last_name: ((_r = customer === null || customer === void 0 ? void 0 : customer.name) === null || _r === void 0 ? void 0 : _r.length) ? customer.name[0].last : '',
103
+ email: (_q = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _q === void 0 ? void 0 : _q.email,
104
+ first_name: ((_r = customer === null || customer === void 0 ? void 0 : customer.name) === null || _r === void 0 ? void 0 : _r.length) ? customer.name[0].first : '',
105
+ last_name: ((_s = customer === null || customer === void 0 ? void 0 : customer.name) === null || _s === void 0 ? void 0 : _s.length) ? customer.name[0].last : '',
94
106
  phone: {
95
- country_code: (_u = (_t = (_s = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _s === void 0 ? void 0 : _s.phone) === null || _t === void 0 ? void 0 : _t.countryCode) !== null && _u !== void 0 ? _u : '',
96
- number: (_x = (_w = (_v = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _v === void 0 ? void 0 : _v.phone) === null || _w === void 0 ? void 0 : _w.number) !== null && _x !== void 0 ? _x : ''
107
+ country_code: (_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.countryCode) !== null && _v !== void 0 ? _v : '',
108
+ number: (_y = (_x = (_w = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _w === void 0 ? void 0 : _w.phone) === null || _x === void 0 ? void 0 : _x.number) !== null && _y !== void 0 ? _y : ''
97
109
  }
98
110
  },
99
111
  fee: 0,
100
112
  merchant: {
101
- id: (_z = (_y = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _y === void 0 ? void 0 : _y.id) !== null && _z !== void 0 ? _z : ''
113
+ id: (_0 = (_z = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _z === void 0 ? void 0 : _z.id) !== null && _0 !== void 0 ? _0 : ''
102
114
  },
103
- order: (_0 = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _0 === void 0 ? void 0 : _0.order,
115
+ order: (_1 = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _1 === void 0 ? void 0 : _1.order,
104
116
  product: 'Apple-Pay-Button',
105
117
  save_card: false,
106
118
  source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' },
@@ -119,14 +131,14 @@ export var useMerchantApplePay = function (_a) {
119
131
  if (!(scope === Scope.AUTHORIZE)) return [3, 8];
120
132
  return [4, appService.createAuthorize(transactionRequest)];
121
133
  case 7:
122
- _d = _2.sent();
134
+ _e = _3.sent();
123
135
  return [3, 10];
124
136
  case 8: return [4, appService.createCharge(transactionRequest)];
125
137
  case 9:
126
- _d = _2.sent();
127
- _2.label = 10;
138
+ _e = _3.sent();
139
+ _3.label = 10;
128
140
  case 10:
129
- transactionResponse = _d;
141
+ transactionResponse = _e;
130
142
  successState = scope === Scope.AUTHORIZE ? CHARGE_CODE.AUTHORIZED : CHARGE_CODE.SUCCESS;
131
143
  if ((transactionResponse === null || transactionResponse === void 0 ? void 0 : transactionResponse.response.code) === successState) {
132
144
  setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
@@ -142,14 +154,14 @@ export var useMerchantApplePay = function (_a) {
142
154
  return [3, 12];
143
155
  case 12: return [3, 15];
144
156
  case 13:
145
- e_1 = _2.sent();
157
+ e_1 = _3.sent();
146
158
  if (!onError)
147
159
  return [2];
148
160
  if (e_1.errors) {
149
161
  onError(e_1.errors);
150
162
  return [2];
151
163
  }
152
- if ((_1 = e_1.response) === null || _1 === void 0 ? void 0 : _1.data.errors) {
164
+ if ((_2 = e_1.response) === null || _2 === void 0 ? void 0 : _2.data.errors) {
153
165
  onError(e_1.response.data.errors);
154
166
  return [2];
155
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.83-development",
3
+ "version": "0.0.85-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",