@tap-payments/apple-pay-button 0.0.45-development → 0.0.47-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.
- package/build/api/app.service.d.ts +14 -3
- package/build/api/app.service.js +28 -5
- package/build/hooks/useApplePay.js +18 -29
- package/package.json +1 -1
|
@@ -14,12 +14,23 @@ declare class APPService extends BaseService {
|
|
|
14
14
|
pk: string;
|
|
15
15
|
domain: string;
|
|
16
16
|
}): Promise<void>;
|
|
17
|
+
getHttpHeaders(): Promise<{
|
|
18
|
+
[x: string]: (string | number | boolean | string[] | import("axios").AxiosHeaders | null) | undefined;
|
|
19
|
+
head?: import("axios").AxiosHeaders | undefined;
|
|
20
|
+
link?: import("axios").AxiosHeaders | undefined;
|
|
21
|
+
get?: import("axios").AxiosHeaders | undefined;
|
|
22
|
+
delete?: import("axios").AxiosHeaders | undefined;
|
|
23
|
+
options?: import("axios").AxiosHeaders | undefined;
|
|
24
|
+
post?: import("axios").AxiosHeaders | undefined;
|
|
25
|
+
put?: import("axios").AxiosHeaders | undefined;
|
|
26
|
+
patch?: import("axios").AxiosHeaders | undefined;
|
|
27
|
+
purge?: import("axios").AxiosHeaders | undefined;
|
|
28
|
+
unlink?: import("axios").AxiosHeaders | undefined;
|
|
29
|
+
common?: import("axios").AxiosHeaders | undefined;
|
|
30
|
+
}>;
|
|
17
31
|
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
18
32
|
merchant: any;
|
|
19
33
|
payment_options: any;
|
|
20
|
-
headers: import("axios").AxiosResponseHeaders | Partial<Record<string, string> & {
|
|
21
|
-
"set-cookie"?: string[] | undefined;
|
|
22
|
-
}>;
|
|
23
34
|
}>;
|
|
24
35
|
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string): Promise<any>;
|
|
25
36
|
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
package/build/api/app.service.js
CHANGED
|
@@ -13,6 +13,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
16
27
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
28
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
29
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -193,23 +204,35 @@ var APPService = (function (_super) {
|
|
|
193
204
|
});
|
|
194
205
|
}
|
|
195
206
|
});
|
|
207
|
+
Object.defineProperty(APPService.prototype, "getHttpHeaders", {
|
|
208
|
+
enumerable: false,
|
|
209
|
+
configurable: true,
|
|
210
|
+
writable: true,
|
|
211
|
+
value: function () {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
return [2, __assign({}, httpClient.defaults.headers.common)];
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
196
219
|
Object.defineProperty(APPService.prototype, "checkoutProfile", {
|
|
197
220
|
enumerable: false,
|
|
198
221
|
configurable: true,
|
|
199
222
|
writable: true,
|
|
200
223
|
value: function (request) {
|
|
201
224
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
-
var
|
|
203
|
-
return __generator(this, function (
|
|
204
|
-
switch (
|
|
225
|
+
var data, merchant, payment_options, session;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
205
228
|
case 0: return [4, this.post(this.baseUrl + '/checkoutprofile', request)];
|
|
206
229
|
case 1:
|
|
207
|
-
|
|
230
|
+
data = (_a.sent()).data;
|
|
208
231
|
if (data.errors)
|
|
209
232
|
throw data;
|
|
210
233
|
merchant = data.merchant, payment_options = data.payment_options, session = data.session;
|
|
211
234
|
setAxiosGlobalHeaders({ session: session });
|
|
212
|
-
return [2, { merchant: merchant, payment_options: payment_options
|
|
235
|
+
return [2, { merchant: merchant, payment_options: payment_options }];
|
|
213
236
|
}
|
|
214
237
|
});
|
|
215
238
|
});
|
|
@@ -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,
|
|
88
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
89
|
-
return __generator(this, function (
|
|
90
|
-
switch (
|
|
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
|
-
|
|
85
|
+
_m.label = 1;
|
|
97
86
|
case 1:
|
|
98
|
-
|
|
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
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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: (
|
|
129
|
-
first_name: ((
|
|
130
|
-
last_name: ((
|
|
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: (
|
|
133
|
-
number: (
|
|
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
|
-
|
|
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((
|
|
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:
|
|
146
|
+
headers: __assign({}, appService.getHttpHeaders()),
|
|
158
147
|
merchant: data.merchant
|
|
159
148
|
});
|
|
160
149
|
return [3, 9];
|
|
161
150
|
case 7:
|
|
162
|
-
err_1 =
|
|
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:
|