@tap-payments/apple-pay-button 0.0.45-development → 0.0.46-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.
@@ -14,12 +14,12 @@ declare class APPService extends BaseService {
14
14
  pk: string;
15
15
  domain: string;
16
16
  }): Promise<void>;
17
+ getHttpHeaders(): Promise<import("axios").HeadersDefaults & {
18
+ [key: string]: string | number | boolean | string[] | import("axios").AxiosHeaders | null;
19
+ }>;
17
20
  checkoutProfile(request: CheckoutProfileRequest): Promise<{
18
21
  merchant: any;
19
22
  payment_options: any;
20
- headers: import("axios").AxiosResponseHeaders | Partial<Record<string, string> & {
21
- "set-cookie"?: string[] | undefined;
22
- }>;
23
23
  }>;
24
24
  appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string): Promise<any>;
25
25
  tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
@@ -193,23 +193,35 @@ var APPService = (function (_super) {
193
193
  });
194
194
  }
195
195
  });
196
+ Object.defineProperty(APPService.prototype, "getHttpHeaders", {
197
+ enumerable: false,
198
+ configurable: true,
199
+ writable: true,
200
+ value: function () {
201
+ return __awaiter(this, void 0, void 0, function () {
202
+ return __generator(this, function (_a) {
203
+ return [2, httpClient.defaults.headers];
204
+ });
205
+ });
206
+ }
207
+ });
196
208
  Object.defineProperty(APPService.prototype, "checkoutProfile", {
197
209
  enumerable: false,
198
210
  configurable: true,
199
211
  writable: true,
200
212
  value: function (request) {
201
213
  return __awaiter(this, void 0, void 0, function () {
202
- var _a, data, headers, merchant, payment_options, session;
203
- return __generator(this, function (_b) {
204
- switch (_b.label) {
214
+ var data, merchant, payment_options, session;
215
+ return __generator(this, function (_a) {
216
+ switch (_a.label) {
205
217
  case 0: return [4, this.post(this.baseUrl + '/checkoutprofile', request)];
206
218
  case 1:
207
- _a = _b.sent(), data = _a.data, headers = _a.headers;
219
+ data = (_a.sent()).data;
208
220
  if (data.errors)
209
221
  throw data;
210
222
  merchant = data.merchant, payment_options = data.payment_options, session = data.session;
211
223
  setAxiosGlobalHeaders({ session: session });
212
- return [2, { merchant: merchant, payment_options: payment_options, headers: headers }];
224
+ return [2, { merchant: merchant, payment_options: payment_options }];
213
225
  }
214
226
  });
215
227
  });
@@ -45,17 +45,6 @@ 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
- };
59
48
  import { useCallback, useEffect, useState } from 'react';
60
49
  import appService from '../api/app.service';
61
50
  import { ApplePayVersion, Scope } from '../constants';
@@ -84,18 +73,18 @@ export var useApplePay = function (_a) {
84
73
  setApplePayRequestData(request);
85
74
  };
86
75
  var initialize = useCallback(function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
87
- var merchantProfile, payment_options, headers_1, _a, httpHeaders, data, err_1;
88
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
89
- return __generator(this, function (_o) {
90
- switch (_o.label) {
76
+ var merchantProfile, payment_options, headers_1, data, err_1;
77
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
78
+ return __generator(this, function (_m) {
79
+ switch (_m.label) {
91
80
  case 0:
92
81
  console.log('environment, interfaceObj?.locale, order, customer, merchant, scope', environment, interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale, order, customer, merchant, scope);
93
82
  setLoading(true);
94
83
  appService.setEnv(environment);
95
84
  appService.setBaseUrl();
96
- _o.label = 1;
85
+ _m.label = 1;
97
86
  case 1:
98
- _o.trys.push([1, 7, 8, 9]);
87
+ _m.trys.push([1, 7, 8, 9]);
99
88
  if (metaData) {
100
89
  merchantProfile = metaData.merchant, payment_options = metaData.payment_options, headers_1 = metaData.headers;
101
90
  setAxiosGlobalHeaders(__assign({}, headers_1));
@@ -105,7 +94,7 @@ export var useApplePay = function (_a) {
105
94
  if (!headers) return [3, 3];
106
95
  return [4, appService.setHttpHeaders(__assign(__assign({}, headers), { pk: operator.publicKey }))];
107
96
  case 2:
108
- _o.sent();
97
+ _m.sent();
109
98
  return [3, 5];
110
99
  case 3: return [4, appService.setBrowserHeaders({
111
100
  locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
@@ -113,8 +102,8 @@ export var useApplePay = function (_a) {
113
102
  pk: operator.publicKey
114
103
  })];
115
104
  case 4:
116
- _o.sent();
117
- _o.label = 5;
105
+ _m.sent();
106
+ _m.label = 5;
118
107
  case 5: return [4, appService.checkoutProfile({
119
108
  supported_payment_methods: ['APPLE_PAY'],
120
109
  supported_currencies: [order.currency],
@@ -125,12 +114,12 @@ export var useApplePay = function (_a) {
125
114
  order: __assign(__assign({ id: order === null || order === void 0 ? void 0 : order.id, amount: Number(order.amount), currency: order.currency, description: order === null || order === void 0 ? void 0 : order.description, metadata: order === null || order === void 0 ? void 0 : order.metadata }, (customer && {
126
115
  customer: {
127
116
  id: customer === null || customer === void 0 ? void 0 : customer.id,
128
- email: (_b = customer.contact) === null || _b === void 0 ? void 0 : _b.email,
129
- first_name: ((_c = customer.name) === null || _c === void 0 ? void 0 : _c.length) ? customer.name[0].first : '',
130
- last_name: ((_d = customer.name) === null || _d === void 0 ? void 0 : _d.length) ? customer.name[0].last : '',
117
+ email: (_a = customer.contact) === null || _a === void 0 ? void 0 : _a.email,
118
+ first_name: ((_b = customer.name) === null || _b === void 0 ? void 0 : _b.length) ? customer.name[0].first : '',
119
+ last_name: ((_c = customer.name) === null || _c === void 0 ? void 0 : _c.length) ? customer.name[0].last : '',
131
120
  phone: {
132
- country_code: (_g = (_f = (_e = customer.contact) === null || _e === void 0 ? void 0 : _e.phone) === null || _f === void 0 ? void 0 : _f.countryCode) !== null && _g !== void 0 ? _g : '',
133
- number: (_k = (_j = (_h = customer.contact) === null || _h === void 0 ? void 0 : _h.phone) === null || _j === void 0 ? void 0 : _j.number) !== null && _k !== void 0 ? _k : ''
121
+ country_code: (_f = (_e = (_d = customer.contact) === null || _d === void 0 ? void 0 : _d.phone) === null || _e === void 0 ? void 0 : _e.countryCode) !== null && _f !== void 0 ? _f : '',
122
+ number: (_j = (_h = (_g = customer.contact) === null || _g === void 0 ? void 0 : _g.phone) === null || _h === void 0 ? void 0 : _h.number) !== null && _j !== void 0 ? _j : ''
134
123
  }
135
124
  }
136
125
  })), { merchant: {
@@ -146,20 +135,20 @@ export var useApplePay = function (_a) {
146
135
  ] })
147
136
  })];
148
137
  case 6:
149
- _a = _o.sent(), httpHeaders = _a.headers, data = __rest(_a, ["headers"]);
138
+ data = _m.sent();
150
139
  if (debug)
151
140
  console.log('merchant configuration: ', data);
152
141
  setProfile(data);
153
142
  prepareApplePayRequest(data);
154
- onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_m = (_l = data.payment_options) === null || _l === void 0 ? void 0 : _l.order) === null || _m === void 0 ? void 0 : _m.id);
143
+ onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_l = (_k = data.payment_options) === null || _k === void 0 ? void 0 : _k.order) === null || _l === void 0 ? void 0 : _l.id);
155
144
  setApplePayRequestConfiguration({
156
145
  BASE_URL: appService.getBaseUrl(),
157
- headers: httpHeaders,
146
+ headers: __assign({}, appService.getHttpHeaders()),
158
147
  merchant: data.merchant
159
148
  });
160
149
  return [3, 9];
161
150
  case 7:
162
- err_1 = _o.sent();
151
+ err_1 = _m.sent();
163
152
  onError === null || onError === void 0 ? void 0 : onError(err_1.errors || err_1);
164
153
  return [3, 9];
165
154
  case 8:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.45-development",
3
+ "version": "0.0.46-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",