@tap-payments/apple-pay-button 0.0.43-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.
package/build/@types/index.d.ts
CHANGED
|
@@ -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>;
|
package/build/api/app.service.js
CHANGED
|
@@ -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
|
|
203
|
-
return __generator(this, function (
|
|
204
|
-
switch (
|
|
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
|
-
|
|
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
|
|
224
|
+
return [2, { merchant: merchant, payment_options: payment_options }];
|
|
213
225
|
}
|
|
214
226
|
});
|
|
215
227
|
});
|
|
@@ -20,7 +20,7 @@ import './ApplePayButton.css';
|
|
|
20
20
|
var ApplePay = React.memo(function (props) {
|
|
21
21
|
var mappedProps = getDefaultValues(props);
|
|
22
22
|
var _a = useApplePay(mappedProps), loading = _a.loading, onApplePayButtonClicked = _a.onApplePayButtonClicked, disabled = _a.disabled, applePayRequestData = _a.applePayRequestData, applePayRequestConfiguration = _a.applePayRequestConfiguration;
|
|
23
|
-
var
|
|
23
|
+
var isIframeIntegration = props.integration === 'iframe';
|
|
24
24
|
React.useEffect(function () {
|
|
25
25
|
if (props.debug) {
|
|
26
26
|
console.log('ApplePayButtonProps', props);
|
|
@@ -32,7 +32,7 @@ var ApplePay = React.memo(function (props) {
|
|
|
32
32
|
borderRadius: mappedProps.interface.edges === Edges.STRAIGHT ? '0' : '10px'
|
|
33
33
|
}, onClick: function () {
|
|
34
34
|
var _a, _b;
|
|
35
|
-
if (
|
|
35
|
+
if (isIframeIntegration) {
|
|
36
36
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, __assign(__assign({}, applePayRequestConfiguration), { applePayRequestData: applePayRequestData }));
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -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:
|
|
@@ -60,7 +60,7 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
|
|
|
60
60
|
onReady?: (() => void) | undefined;
|
|
61
61
|
metaData?: import("../@types").MetaData | undefined;
|
|
62
62
|
debug?: boolean | undefined;
|
|
63
|
-
integration?: "
|
|
63
|
+
integration?: "sdk" | "iframe" | undefined;
|
|
64
64
|
headers?: {
|
|
65
65
|
mdn: string;
|
|
66
66
|
application: string;
|