@tap-payments/apple-pay-button 0.0.83-development → 0.0.84-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.
@@ -254,7 +254,7 @@ export var useApplePay = function (_a) {
254
254
  });
255
255
  }); };
256
256
  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;
257
+ var _a, paymentData, paymentMethod, transactionIdentifier, _b, data, tokenId, supportCurrency, transactionRequest, transactionResponse, _c, successState, error_2;
258
258
  var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
259
259
  return __generator(this, function (_1) {
260
260
  switch (_1.label) {
@@ -264,8 +264,9 @@ export var useApplePay = function (_a) {
264
264
  _1.label = 1;
265
265
  case 1:
266
266
  _1.trys.push([1, 16, 17, 18]);
267
- _a = scope;
268
- switch (_a) {
267
+ _a = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _a.paymentData, paymentMethod = _a.paymentMethod, transactionIdentifier = _a.transactionIdentifier;
268
+ _b = scope;
269
+ switch (_b) {
269
270
  case Scope.APPLE_PAY_TOKEN: return [3, 2];
270
271
  case Scope.TAP_TOKEN: return [3, 4];
271
272
  case Scope.AUTHORIZE: return [3, 7];
@@ -279,7 +280,6 @@ export var useApplePay = function (_a) {
279
280
  return [3, 15];
280
281
  case 4:
281
282
  setLoading(true);
282
- _b = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _b.paymentData, paymentMethod = _b.paymentMethod, transactionIdentifier = _b.transactionIdentifier;
283
283
  return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
284
284
  case 5:
285
285
  data = _1.sent();
@@ -291,7 +291,7 @@ export var useApplePay = function (_a) {
291
291
  return [3, 15];
292
292
  case 7:
293
293
  setLoading(true);
294
- return [4, appService.tapTokenization(__assign(__assign(__assign({}, event.payment.token.paymentData), event.payment.token), { paymentData: undefined }))];
294
+ return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
295
295
  case 8:
296
296
  tokenId = (_1.sent()).id;
297
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];
@@ -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.84-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",