@tap-payments/apple-pay-button 0.0.94-development → 0.0.95-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 +0 -1
- package/build/@types/index.js +0 -1
- package/build/api.d.ts +5 -29
- package/build/api.js +28 -180
- package/build/hooks/useApplePay.js +16 -10
- package/build/hooks/useMerchantApplePay.d.ts +1 -1
- package/build/hooks/useMerchantApplePay.js +26 -49
- package/package.json +2 -2
- package/build/@types/charge.d.ts +0 -51
- package/build/@types/charge.js +0 -1
package/build/@types/index.d.ts
CHANGED
package/build/@types/index.js
CHANGED
package/build/api.d.ts
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}) => void;
|
|
5
|
-
export declare const getAxiosGlobalHeaders: () => {
|
|
6
|
-
[x: string]: import("axios").AxiosHeaderValue | undefined;
|
|
7
|
-
Accept?: import("axios").AxiosHeaderValue | undefined;
|
|
8
|
-
"Content-Length"?: import("axios").AxiosHeaderValue | undefined;
|
|
9
|
-
"User-Agent"?: import("axios").AxiosHeaderValue | undefined;
|
|
10
|
-
"Content-Encoding"?: import("axios").AxiosHeaderValue | undefined;
|
|
11
|
-
Authorization?: import("axios").AxiosHeaderValue | undefined;
|
|
12
|
-
'Content-Type'?: import("axios").AxiosHeaderValue | undefined;
|
|
13
|
-
};
|
|
14
|
-
declare class APPService {
|
|
15
|
-
setHttpHeaders(headers: Record<string, string>): Promise<void>;
|
|
16
|
-
setBrowserHeaders({ locale, pk, domain }: {
|
|
17
|
-
locale: string;
|
|
18
|
-
pk: string;
|
|
19
|
-
domain: string;
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
22
|
-
merchant: any;
|
|
23
|
-
payment_options: any;
|
|
24
|
-
}>;
|
|
1
|
+
import { MerchantValidationRequestData } from './@types';
|
|
2
|
+
import { CheckoutService as CheckoutServiceBase } from '@tap-payments/acceptance-sdk';
|
|
3
|
+
declare class CheckoutService extends CheckoutServiceBase {
|
|
25
4
|
appleSession(body: MerchantValidationRequestData): Promise<any>;
|
|
26
|
-
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
27
|
-
createCharge(request: ChargeRequestBody): Promise<any>;
|
|
28
|
-
createAuthorize(request: AuthorizeRequestBody): Promise<any>;
|
|
29
5
|
}
|
|
30
|
-
declare const
|
|
31
|
-
export
|
|
6
|
+
export declare const checkoutService: CheckoutService;
|
|
7
|
+
export {};
|
package/build/api.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
for (var p in
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
9
7
|
};
|
|
10
|
-
return
|
|
11
|
-
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
12
16
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
17
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
18
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,107 +49,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
50
|
}
|
|
47
51
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
import BrowserInfo from '@tap-payments/browser-info';
|
|
60
|
-
import { MW_BASE_URL, RSA_MW_PUBLIC_KEY } from './constants';
|
|
61
|
-
import axios from 'axios';
|
|
62
|
-
import { generateApplicationHeader, rsaSetup } from '@tap-payments/acceptance-sdk';
|
|
63
|
-
var axiosInstance = axios.create({
|
|
64
|
-
baseURL: MW_BASE_URL,
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type': 'application/json'
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
export var setAxiosGlobalHeaders = function (headers) {
|
|
70
|
-
Object.entries(headers).forEach(function (_a) {
|
|
71
|
-
var key = _a[0], value = _a[1];
|
|
72
|
-
axiosInstance.defaults.headers.common[key] = value;
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
export var getAxiosGlobalHeaders = function () {
|
|
76
|
-
return __assign({}, axiosInstance.defaults.headers.common);
|
|
77
|
-
};
|
|
78
|
-
var APPService = (function () {
|
|
79
|
-
function APPService() {
|
|
52
|
+
import { RSA_MW_PUBLIC_KEY } from './constants';
|
|
53
|
+
import { CheckoutService as CheckoutServiceBase } from '@tap-payments/acceptance-sdk';
|
|
54
|
+
var CheckoutService = (function (_super) {
|
|
55
|
+
__extends(CheckoutService, _super);
|
|
56
|
+
function CheckoutService() {
|
|
57
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
80
58
|
}
|
|
81
|
-
Object.defineProperty(
|
|
82
|
-
enumerable: false,
|
|
83
|
-
configurable: true,
|
|
84
|
-
writable: true,
|
|
85
|
-
value: function (headers) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
setAxiosGlobalHeaders(headers);
|
|
89
|
-
return [2];
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
Object.defineProperty(APPService.prototype, "setBrowserHeaders", {
|
|
95
|
-
enumerable: false,
|
|
96
|
-
configurable: true,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: function (_a) {
|
|
99
|
-
var locale = _a.locale, pk = _a.pk, domain = _a.domain;
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
var encryptString, encryptedHeaders, mdn, authorization, rest, application;
|
|
102
|
-
return __generator(this, function (_b) {
|
|
103
|
-
switch (_b.label) {
|
|
104
|
-
case 0:
|
|
105
|
-
encryptString = rsaSetup(RSA_MW_PUBLIC_KEY);
|
|
106
|
-
return [4, new BrowserInfo.BrowserInfo({
|
|
107
|
-
app: { name: '@tap-payments/apple-pay-button', language: locale },
|
|
108
|
-
credentials: { mdn: domain, pk: pk },
|
|
109
|
-
encrypt: function (_key, value) { return encryptString(value.substring(0, 115)); }
|
|
110
|
-
}).get()];
|
|
111
|
-
case 1:
|
|
112
|
-
encryptedHeaders = _b.sent();
|
|
113
|
-
mdn = encryptedHeaders.mdn, authorization = encryptedHeaders.authorization, rest = __rest(encryptedHeaders, ["mdn", "authorization"]);
|
|
114
|
-
application = generateApplicationHeader(rest);
|
|
115
|
-
setAxiosGlobalHeaders({
|
|
116
|
-
authorization: pk,
|
|
117
|
-
mdn: mdn,
|
|
118
|
-
application: application
|
|
119
|
-
});
|
|
120
|
-
return [2];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(APPService.prototype, "checkoutProfile", {
|
|
127
|
-
enumerable: false,
|
|
128
|
-
configurable: true,
|
|
129
|
-
writable: true,
|
|
130
|
-
value: function (request) {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
-
var data, merchant, payment_options, session;
|
|
133
|
-
return __generator(this, function (_a) {
|
|
134
|
-
switch (_a.label) {
|
|
135
|
-
case 0: return [4, axiosInstance.post('/checkoutprofile', request)];
|
|
136
|
-
case 1:
|
|
137
|
-
data = (_a.sent()).data;
|
|
138
|
-
if (data.errors)
|
|
139
|
-
throw data;
|
|
140
|
-
merchant = data.merchant, payment_options = data.payment_options, session = data.session;
|
|
141
|
-
setAxiosGlobalHeaders({ session: session });
|
|
142
|
-
return [2, { merchant: merchant, payment_options: payment_options }];
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
Object.defineProperty(APPService.prototype, "appleSession", {
|
|
59
|
+
Object.defineProperty(CheckoutService.prototype, "appleSession", {
|
|
149
60
|
enumerable: false,
|
|
150
61
|
configurable: true,
|
|
151
62
|
writable: true,
|
|
@@ -154,7 +65,7 @@ var APPService = (function () {
|
|
|
154
65
|
var data;
|
|
155
66
|
return __generator(this, function (_a) {
|
|
156
67
|
switch (_a.label) {
|
|
157
|
-
case 0: return [4, axiosInstance.post('/validatemerchant', body)];
|
|
68
|
+
case 0: return [4, this.axiosInstance.post('/validatemerchant', body)];
|
|
158
69
|
case 1:
|
|
159
70
|
data = (_a.sent()).data;
|
|
160
71
|
if (data.errors)
|
|
@@ -165,72 +76,9 @@ var APPService = (function () {
|
|
|
165
76
|
});
|
|
166
77
|
}
|
|
167
78
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var body, data;
|
|
175
|
-
return __generator(this, function (_a) {
|
|
176
|
-
switch (_a.label) {
|
|
177
|
-
case 0:
|
|
178
|
-
body = {
|
|
179
|
-
type: 'applepay',
|
|
180
|
-
token_data: applePaymentData
|
|
181
|
-
};
|
|
182
|
-
return [4, axiosInstance.post('/token', body)];
|
|
183
|
-
case 1:
|
|
184
|
-
data = (_a.sent()).data;
|
|
185
|
-
if (data.errors)
|
|
186
|
-
throw data;
|
|
187
|
-
return [2, data];
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
Object.defineProperty(APPService.prototype, "createCharge", {
|
|
194
|
-
enumerable: false,
|
|
195
|
-
configurable: true,
|
|
196
|
-
writable: true,
|
|
197
|
-
value: function (request) {
|
|
198
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
-
var data;
|
|
200
|
-
return __generator(this, function (_a) {
|
|
201
|
-
switch (_a.label) {
|
|
202
|
-
case 0: return [4, axiosInstance.post('/charge', request)];
|
|
203
|
-
case 1:
|
|
204
|
-
data = (_a.sent()).data;
|
|
205
|
-
if (data.errors)
|
|
206
|
-
throw data;
|
|
207
|
-
return [2, data];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
Object.defineProperty(APPService.prototype, "createAuthorize", {
|
|
214
|
-
enumerable: false,
|
|
215
|
-
configurable: true,
|
|
216
|
-
writable: true,
|
|
217
|
-
value: function (request) {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
-
var data;
|
|
220
|
-
return __generator(this, function (_a) {
|
|
221
|
-
switch (_a.label) {
|
|
222
|
-
case 0: return [4, axiosInstance.post('/authorize', request)];
|
|
223
|
-
case 1:
|
|
224
|
-
data = (_a.sent()).data;
|
|
225
|
-
if (data.errors)
|
|
226
|
-
throw data;
|
|
227
|
-
return [2, data];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
return APPService;
|
|
234
|
-
}());
|
|
235
|
-
var appService = new APPService();
|
|
236
|
-
export default appService;
|
|
79
|
+
return CheckoutService;
|
|
80
|
+
}(CheckoutServiceBase));
|
|
81
|
+
export var checkoutService = new CheckoutService({
|
|
82
|
+
rsaMWPublicKey: RSA_MW_PUBLIC_KEY,
|
|
83
|
+
sdkName: '@tap-payments/apple-pay-button'
|
|
84
|
+
});
|
|
@@ -51,7 +51,7 @@ import { PAYMENT_METHOD_KEY, prepareApplePayRequest, shallRenderApplePay } from
|
|
|
51
51
|
import { IntegrationType } from '../@types';
|
|
52
52
|
import { useMerchantApplePay } from './useMerchantApplePay';
|
|
53
53
|
import { getDefaultThemeMode } from '../utils';
|
|
54
|
-
import
|
|
54
|
+
import { checkoutService } from '../api';
|
|
55
55
|
import { areAllTheObjectStringValuesValid, ChargeCode, getPaymentMethod, getSelectedCurrency, mappingInterface, Scope, useScript } from '@tap-payments/acceptance-sdk';
|
|
56
56
|
var FALLBACK_MERCHANT_IDENTIFIER = 'merchant.tap.gosell';
|
|
57
57
|
export var useApplePay = function (_a) {
|
|
@@ -120,13 +120,13 @@ export var useApplePay = function (_a) {
|
|
|
120
120
|
throw new Error('000::Profile data is not available');
|
|
121
121
|
}
|
|
122
122
|
session = headers === null || headers === void 0 ? void 0 : headers.session;
|
|
123
|
-
setAxiosGlobalHeaders({ session: session });
|
|
123
|
+
checkoutService.setAxiosGlobalHeaders({ session: session });
|
|
124
124
|
if (!(headers && areAllTheObjectStringValuesValid(headers))) return [3, 2];
|
|
125
|
-
return [4,
|
|
125
|
+
return [4, checkoutService.setHttpHeaders(__assign(__assign({}, headers), { authorization: operator.publicKey }))];
|
|
126
126
|
case 1:
|
|
127
127
|
_e.sent();
|
|
128
128
|
return [3, 4];
|
|
129
|
-
case 2: return [4,
|
|
129
|
+
case 2: return [4, checkoutService.setHttpHeadersWithEncryption({
|
|
130
130
|
locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
|
|
131
131
|
domain: window.location.origin,
|
|
132
132
|
pk: operator.publicKey
|
|
@@ -148,7 +148,7 @@ export var useApplePay = function (_a) {
|
|
|
148
148
|
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_c = (_b = profileData.payment_options) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.id);
|
|
149
149
|
setApplePayRequestConfiguration({
|
|
150
150
|
BASE_URL: MW_BASE_URL,
|
|
151
|
-
headers: getAxiosGlobalHeaders(),
|
|
151
|
+
headers: checkoutService.getAxiosGlobalHeaders(),
|
|
152
152
|
merchant: __assign(__assign({}, profileData.merchant), { id: merchant.id || ((_d = profileData.merchant) === null || _d === void 0 ? void 0 : _d.id) })
|
|
153
153
|
});
|
|
154
154
|
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
@@ -206,7 +206,7 @@ export var useApplePay = function (_a) {
|
|
|
206
206
|
if (!merchantValidationRequestData) {
|
|
207
207
|
throw new Error('Merchant Validation Request Data is not prepared!');
|
|
208
208
|
}
|
|
209
|
-
return [4,
|
|
209
|
+
return [4, checkoutService.appleSession(__assign(__assign({}, merchantValidationRequestData), { validationUrl: event.validationURL }))];
|
|
210
210
|
case 2:
|
|
211
211
|
merchantSession = _a.sent();
|
|
212
212
|
if (debug)
|
|
@@ -253,7 +253,10 @@ export var useApplePay = function (_a) {
|
|
|
253
253
|
return [3, 15];
|
|
254
254
|
case 4:
|
|
255
255
|
setLoading(true);
|
|
256
|
-
return [4,
|
|
256
|
+
return [4, checkoutService.tokenize({
|
|
257
|
+
type: 'applepay',
|
|
258
|
+
token_data: __assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier })
|
|
259
|
+
})];
|
|
257
260
|
case 5:
|
|
258
261
|
data = _e.sent();
|
|
259
262
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
@@ -264,7 +267,10 @@ export var useApplePay = function (_a) {
|
|
|
264
267
|
return [3, 15];
|
|
265
268
|
case 7:
|
|
266
269
|
setLoading(true);
|
|
267
|
-
return [4,
|
|
270
|
+
return [4, checkoutService.tokenize({
|
|
271
|
+
type: 'applepay',
|
|
272
|
+
token_data: __assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier })
|
|
273
|
+
})];
|
|
268
274
|
case 8:
|
|
269
275
|
tokenId = (_e.sent()).id;
|
|
270
276
|
supportedCurrency = getSelectedCurrency((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.supported_currencies) || [], order, applePayPaymentMethodOptions);
|
|
@@ -276,11 +282,11 @@ export var useApplePay = function (_a) {
|
|
|
276
282
|
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' }
|
|
277
283
|
};
|
|
278
284
|
if (!(scope === Scope.AUTHORIZE)) return [3, 10];
|
|
279
|
-
return [4,
|
|
285
|
+
return [4, checkoutService.authorize(transactionRequest)];
|
|
280
286
|
case 9:
|
|
281
287
|
_c = _e.sent();
|
|
282
288
|
return [3, 12];
|
|
283
|
-
case 10: return [4,
|
|
289
|
+
case 10: return [4, checkoutService.charge(transactionRequest)];
|
|
284
290
|
case 11:
|
|
285
291
|
_c = _e.sent();
|
|
286
292
|
_e.label = 12;
|
|
@@ -18,5 +18,5 @@ interface ApplePayRequestData {
|
|
|
18
18
|
post?: ApplePayButtonProps['post'];
|
|
19
19
|
features?: ApplePayButtonProps['features'];
|
|
20
20
|
}
|
|
21
|
-
export declare const useMerchantApplePay: ({ isIframeIntegration, onError, onSuccess, setLoading, setError, setSuccess, scope, profileData, order, customer, transaction, operator, redirect, post
|
|
21
|
+
export declare const useMerchantApplePay: ({ isIframeIntegration, onError, onSuccess, setLoading, setError, setSuccess, scope, profileData, order, customer, transaction, operator, redirect, post }: ApplePayRequestData) => void;
|
|
22
22
|
export {};
|
|
@@ -46,29 +46,29 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import * as React from 'react';
|
|
49
|
-
import
|
|
49
|
+
import { checkoutService } from '../api';
|
|
50
50
|
import { CHARGE_CODE } from '../@types';
|
|
51
51
|
import { getPaymentMethod, Scope, getSelectedCurrency } from '@tap-payments/acceptance-sdk';
|
|
52
52
|
import { PAYMENT_METHOD_KEY } from '../utils';
|
|
53
53
|
var EVENT_NAME = 'TAP_BUTTON::APPLE_PAY_ON_PAYMENT_AUTHORIZED';
|
|
54
54
|
export var useMerchantApplePay = function (_a) {
|
|
55
|
-
var isIframeIntegration = _a.isIframeIntegration, onError = _a.onError, onSuccess = _a.onSuccess, setLoading = _a.setLoading, setError = _a.setError, setSuccess = _a.setSuccess, scope = _a.scope, profileData = _a.profileData, order = _a.order, customer = _a.customer, transaction = _a.transaction, operator = _a.operator, redirect = _a.redirect, post = _a.post
|
|
55
|
+
var isIframeIntegration = _a.isIframeIntegration, onError = _a.onError, onSuccess = _a.onSuccess, setLoading = _a.setLoading, setError = _a.setError, setSuccess = _a.setSuccess, scope = _a.scope, profileData = _a.profileData, order = _a.order, customer = _a.customer, transaction = _a.transaction, operator = _a.operator, redirect = _a.redirect, post = _a.post;
|
|
56
56
|
var onMessageReceived = React.useCallback(function (_a) {
|
|
57
57
|
var message = _a.data;
|
|
58
58
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
59
59
|
var _b, event, data, _c, paymentData, paymentMethod, transactionIdentifier, applyPayPaymentMethod, _d, response, tokenId, supportedCurrency, transactionRequest, transactionResponse, _e, successState, e_1;
|
|
60
|
-
var _f
|
|
61
|
-
return __generator(this, function (
|
|
62
|
-
switch (
|
|
60
|
+
var _f;
|
|
61
|
+
return __generator(this, function (_g) {
|
|
62
|
+
switch (_g.label) {
|
|
63
63
|
case 0:
|
|
64
64
|
_b = message !== null && message !== void 0 ? message : {}, event = _b.event, data = _b.data;
|
|
65
65
|
if (!data || event !== EVENT_NAME)
|
|
66
66
|
return [2];
|
|
67
67
|
_c = data !== null && data !== void 0 ? data : {}, paymentData = _c.paymentData, paymentMethod = _c.paymentMethod, transactionIdentifier = _c.transactionIdentifier;
|
|
68
68
|
applyPayPaymentMethod = getPaymentMethod((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.payment_methods) || [], PAYMENT_METHOD_KEY);
|
|
69
|
-
|
|
69
|
+
_g.label = 1;
|
|
70
70
|
case 1:
|
|
71
|
-
|
|
71
|
+
_g.trys.push([1, 13, 14, 15]);
|
|
72
72
|
_d = scope;
|
|
73
73
|
switch (_d) {
|
|
74
74
|
case Scope.APPLE_PAY_TOKEN: return [3, 2];
|
|
@@ -82,63 +82,40 @@ export var useMerchantApplePay = function (_a) {
|
|
|
82
82
|
return [3, 12];
|
|
83
83
|
case 3:
|
|
84
84
|
setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
|
|
85
|
-
return [4,
|
|
85
|
+
return [4, checkoutService.tokenize({
|
|
86
|
+
type: 'applepay',
|
|
87
|
+
token_data: __assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier })
|
|
88
|
+
})];
|
|
86
89
|
case 4:
|
|
87
|
-
response =
|
|
90
|
+
response = _g.sent();
|
|
88
91
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
89
92
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response);
|
|
90
93
|
return [3, 12];
|
|
91
94
|
case 5:
|
|
92
95
|
setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
|
|
93
|
-
return [4,
|
|
96
|
+
return [4, checkoutService.tokenize({
|
|
97
|
+
type: 'applepay',
|
|
98
|
+
token_data: __assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier })
|
|
99
|
+
})];
|
|
94
100
|
case 6:
|
|
95
|
-
tokenId = (
|
|
101
|
+
tokenId = (_g.sent()).id;
|
|
96
102
|
supportedCurrency = getSelectedCurrency((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.supported_currencies) || [], order, applyPayPaymentMethod);
|
|
97
103
|
transactionRequest = {
|
|
98
|
-
|
|
99
|
-
amount: (_j = (_h = (_g = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _g === void 0 ? void 0 : _g.order) === null || _h === void 0 ? void 0 : _h.amount) !== null && _j !== void 0 ? _j : order.amount,
|
|
100
|
-
currency: (_m = (_l = (_k = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _k === void 0 ? void 0 : _k.order) === null || _l === void 0 ? void 0 : _l.currency) !== null && _m !== void 0 ? _m : order.currency,
|
|
104
|
+
intent: transaction === null || transaction === void 0 ? void 0 : transaction.intent,
|
|
101
105
|
selected_amount: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.amount,
|
|
102
106
|
selected_currency: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.currency,
|
|
103
|
-
customer: (customer === null || customer === void 0 ? void 0 : customer.id)
|
|
104
|
-
? { id: customer === null || customer === void 0 ? void 0 : customer.id }
|
|
105
|
-
: {
|
|
106
|
-
email: (_o = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _o === void 0 ? void 0 : _o.email,
|
|
107
|
-
first_name: ((_p = customer === null || customer === void 0 ? void 0 : customer.name) === null || _p === void 0 ? void 0 : _p.length) ? customer.name[0].first : '',
|
|
108
|
-
last_name: ((_q = customer === null || customer === void 0 ? void 0 : customer.name) === null || _q === void 0 ? void 0 : _q.length) ? customer.name[0].last : '',
|
|
109
|
-
phone: {
|
|
110
|
-
country_code: (_t = (_s = (_r = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _r === void 0 ? void 0 : _r.phone) === null || _s === void 0 ? void 0 : _s.countryCode) !== null && _t !== void 0 ? _t : '',
|
|
111
|
-
number: (_w = (_v = (_u = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _u === void 0 ? void 0 : _u.phone) === null || _v === void 0 ? void 0 : _v.number) !== null && _w !== void 0 ? _w : ''
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
merchant: {
|
|
115
|
-
id: (_y = (_x = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _x === void 0 ? void 0 : _x.id) !== null && _y !== void 0 ? _y : ''
|
|
116
|
-
},
|
|
117
|
-
order: (_z = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _z === void 0 ? void 0 : _z.order,
|
|
118
107
|
product: 'Apple-Pay-Button',
|
|
119
|
-
|
|
120
|
-
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' },
|
|
121
|
-
threeDSecure: (_2 = (_1 = transaction === null || transaction === void 0 ? void 0 : transaction.authenticate) === null || _1 === void 0 ? void 0 : _1.required) !== null && _2 !== void 0 ? _2 : true,
|
|
122
|
-
hashstring: operator.hashstring,
|
|
123
|
-
redirect: redirect,
|
|
124
|
-
metadata: transaction === null || transaction === void 0 ? void 0 : transaction.metadata,
|
|
125
|
-
post: post,
|
|
126
|
-
payment_agreement: transaction === null || transaction === void 0 ? void 0 : transaction.paymentAgreement,
|
|
127
|
-
destinations: transaction === null || transaction === void 0 ? void 0 : transaction.destinations,
|
|
128
|
-
reference: {
|
|
129
|
-
order: order === null || order === void 0 ? void 0 : order.reference,
|
|
130
|
-
transaction: transaction === null || transaction === void 0 ? void 0 : transaction.reference
|
|
131
|
-
}
|
|
108
|
+
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' }
|
|
132
109
|
};
|
|
133
110
|
if (!(scope === Scope.AUTHORIZE)) return [3, 8];
|
|
134
|
-
return [4,
|
|
111
|
+
return [4, checkoutService.authorize(transactionRequest)];
|
|
135
112
|
case 7:
|
|
136
|
-
_e =
|
|
113
|
+
_e = _g.sent();
|
|
137
114
|
return [3, 10];
|
|
138
|
-
case 8: return [4,
|
|
115
|
+
case 8: return [4, checkoutService.charge(transactionRequest)];
|
|
139
116
|
case 9:
|
|
140
|
-
_e =
|
|
141
|
-
|
|
117
|
+
_e = _g.sent();
|
|
118
|
+
_g.label = 10;
|
|
142
119
|
case 10:
|
|
143
120
|
transactionResponse = _e;
|
|
144
121
|
successState = scope === Scope.AUTHORIZE ? CHARGE_CODE.AUTHORIZED : CHARGE_CODE.SUCCESS;
|
|
@@ -156,14 +133,14 @@ export var useMerchantApplePay = function (_a) {
|
|
|
156
133
|
return [3, 12];
|
|
157
134
|
case 12: return [3, 15];
|
|
158
135
|
case 13:
|
|
159
|
-
e_1 =
|
|
136
|
+
e_1 = _g.sent();
|
|
160
137
|
if (!onError)
|
|
161
138
|
return [2];
|
|
162
139
|
if (e_1.errors) {
|
|
163
140
|
onError(e_1.errors);
|
|
164
141
|
return [2];
|
|
165
142
|
}
|
|
166
|
-
if ((
|
|
143
|
+
if ((_f = e_1.response) === null || _f === void 0 ? void 0 : _f.data.errors) {
|
|
167
144
|
onError(e_1.response.data.errors);
|
|
168
145
|
return [2];
|
|
169
146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/apple-pay-button",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.95-development",
|
|
4
4
|
"description": "Apple Pay Button React Component",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "ISC",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tap-payments/acceptance-sdk": "0.0.
|
|
32
|
+
"@tap-payments/acceptance-sdk": "0.0.71",
|
|
33
33
|
"@tap-payments/browser-info": "^1.0.2",
|
|
34
34
|
"@tap-payments/web-error-handing": "^1.0.1",
|
|
35
35
|
"axios": "^1.2.2",
|
package/build/@types/charge.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ChargeRequestBodyBase } from '@tap-payments/acceptance-sdk';
|
|
2
|
-
export interface ChargeRequestBody extends ChargeRequestBodyBase {
|
|
3
|
-
amount?: number;
|
|
4
|
-
currency?: string;
|
|
5
|
-
product: 'Apple-Pay-Button';
|
|
6
|
-
threeDSecure?: boolean;
|
|
7
|
-
save_card?: boolean;
|
|
8
|
-
customer?: {
|
|
9
|
-
id?: string;
|
|
10
|
-
first_name?: string;
|
|
11
|
-
middle_name?: string;
|
|
12
|
-
last_name?: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
phone?: {
|
|
15
|
-
country_code: string;
|
|
16
|
-
number: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
hashstring?: string;
|
|
20
|
-
metadata?: Record<string, string>;
|
|
21
|
-
post?: {
|
|
22
|
-
url: string;
|
|
23
|
-
};
|
|
24
|
-
redirect?: {
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
merchant?: {
|
|
28
|
-
id: string;
|
|
29
|
-
};
|
|
30
|
-
order?: {
|
|
31
|
-
id: string;
|
|
32
|
-
};
|
|
33
|
-
payment_agreement?: {
|
|
34
|
-
id: string;
|
|
35
|
-
contract?: {
|
|
36
|
-
id: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
destinations?: Record<string, any>;
|
|
40
|
-
reference?: {
|
|
41
|
-
order?: string;
|
|
42
|
-
transaction?: string;
|
|
43
|
-
};
|
|
44
|
-
description?: string;
|
|
45
|
-
}
|
|
46
|
-
export interface AuthorizeRequestBody extends ChargeRequestBody {
|
|
47
|
-
auto?: {
|
|
48
|
-
type: string;
|
|
49
|
-
time: string;
|
|
50
|
-
};
|
|
51
|
-
}
|
package/build/@types/charge.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|