@tap-payments/apple-pay-button 0.0.75-development → 0.0.77-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.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { MerchantResponse, CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody } from './@types';
|
|
2
2
|
export declare const setAxiosGlobalHeaders: (headers: Record<string, string>) => void;
|
|
3
3
|
export declare const getAxiosGlobalHeaders: () => {
|
|
4
|
-
[x: string]: import("axios").
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
[x: string]: (string | number | boolean | string[] | import("axios").AxiosHeaders | null) | undefined;
|
|
5
|
+
head?: import("axios").AxiosHeaders | undefined;
|
|
6
|
+
link?: import("axios").AxiosHeaders | undefined;
|
|
7
|
+
post?: import("axios").AxiosHeaders | undefined;
|
|
8
|
+
get?: import("axios").AxiosHeaders | undefined;
|
|
9
|
+
delete?: import("axios").AxiosHeaders | undefined;
|
|
10
|
+
options?: import("axios").AxiosHeaders | undefined;
|
|
11
|
+
put?: import("axios").AxiosHeaders | undefined;
|
|
12
|
+
patch?: import("axios").AxiosHeaders | undefined;
|
|
13
|
+
purge?: import("axios").AxiosHeaders | undefined;
|
|
14
|
+
unlink?: import("axios").AxiosHeaders | undefined;
|
|
15
|
+
common?: import("axios").AxiosHeaders | undefined;
|
|
11
16
|
};
|
|
12
17
|
declare class APPService {
|
|
13
18
|
setHttpHeaders(headers: Record<string, string>): Promise<void>;
|
|
@@ -20,7 +25,7 @@ declare class APPService {
|
|
|
20
25
|
merchant: any;
|
|
21
26
|
payment_options: any;
|
|
22
27
|
}>;
|
|
23
|
-
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string
|
|
28
|
+
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string): Promise<any>;
|
|
24
29
|
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
25
30
|
createCharge(request: ChargeRequestBody): Promise<any>;
|
|
26
31
|
createAuthorize(request: AuthorizeRequestBody): Promise<any>;
|
package/build/api.js
CHANGED
|
@@ -149,7 +149,7 @@ var APPService = (function () {
|
|
|
149
149
|
enumerable: false,
|
|
150
150
|
configurable: true,
|
|
151
151
|
writable: true,
|
|
152
|
-
value: function (merchant, validationURL, merchantRegisteredDomain, merchantIdentifier
|
|
152
|
+
value: function (merchant, validationURL, merchantRegisteredDomain, merchantIdentifier) {
|
|
153
153
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
154
|
var body, data;
|
|
155
155
|
return __generator(this, function (_a) {
|
|
@@ -160,8 +160,7 @@ var APPService = (function () {
|
|
|
160
160
|
origin: merchantRegisteredDomain,
|
|
161
161
|
merchantIdentifier: merchantIdentifier,
|
|
162
162
|
merchantId: merchant.id,
|
|
163
|
-
merchantName: merchant.name
|
|
164
|
-
domainValidator: domainValidator
|
|
163
|
+
merchantName: merchant.name
|
|
165
164
|
};
|
|
166
165
|
return [4, axiosInstance.post('/validatemerchant', body)];
|
|
167
166
|
case 1:
|
|
@@ -17,6 +17,10 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
17
17
|
edges?: import("@tap-payments/acceptance-sdk").Edges | undefined;
|
|
18
18
|
colorStyle?: import("@tap-payments/acceptance-sdk").ColorStyle | undefined;
|
|
19
19
|
loader?: boolean | undefined;
|
|
20
|
+
userExperience?: "popup" | "page" | undefined;
|
|
21
|
+
powered?: boolean | undefined;
|
|
22
|
+
direction?: import("@tap-payments/acceptance-sdk").Direction | undefined;
|
|
23
|
+
cardDirection?: import("@tap-payments/acceptance-sdk").Direction | undefined;
|
|
20
24
|
} | undefined;
|
|
21
25
|
operator: {
|
|
22
26
|
publicKey: string;
|
|
@@ -52,20 +52,20 @@ import { Scope } from '../@types';
|
|
|
52
52
|
import { useMerchantApplePay } from './useMerchantApplePay';
|
|
53
53
|
import { getApplePayPaymentMethod, getDefaultThemeMode } from '../utils';
|
|
54
54
|
import appService, { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api';
|
|
55
|
-
import { ChargeCode,
|
|
55
|
+
import { ChargeCode, mappingInterface } from '@tap-payments/acceptance-sdk';
|
|
56
56
|
export var useApplePay = function (_a) {
|
|
57
|
-
var _b
|
|
57
|
+
var _b;
|
|
58
58
|
var buttonProps = _a.buttonProps;
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var mappedProps = __assign(__assign({}, buttonProps), { interface:
|
|
59
|
+
var _c = useState(), applePayRequestData = _c[0], setApplePayRequestData = _c[1];
|
|
60
|
+
var _d = useState(), applePayRequestConfiguration = _d[0], setApplePayRequestConfiguration = _d[1];
|
|
61
|
+
var _e = useState(), profileData = _e[0], setProfile = _e[1];
|
|
62
|
+
var _f = useState(false), disabled = _f[0], setDisabled = _f[1];
|
|
63
|
+
var _g = useState(false), initialLoading = _g[0], setInitialLoading = _g[1];
|
|
64
|
+
var _h = useState(false), error = _h[0], setError = _h[1];
|
|
65
|
+
var _j = useState(false), success = _j[0], setSuccess = _j[1];
|
|
66
|
+
var _k = useState(false), loading = _k[0], setLoading = _k[1];
|
|
67
|
+
var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
|
|
68
|
+
var mappedProps = __assign(__assign({}, buttonProps), { interface: mappingInterface(buttonProps.interface) });
|
|
69
69
|
var interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady, metaData = mappedProps.metaData, headers = mappedProps.headers, operator = mappedProps.operator, order = mappedProps.order, onOrderCreated = mappedProps.onOrderCreated, transaction = mappedProps.transaction, post = mappedProps.post, redirect = mappedProps.redirect;
|
|
70
70
|
var isIframeIntegration = buttonProps.integration === 'iframe';
|
|
71
71
|
useMerchantApplePay({
|
|
@@ -92,7 +92,7 @@ export var useApplePay = function (_a) {
|
|
|
92
92
|
return getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
|
|
93
93
|
}, [profileData]);
|
|
94
94
|
var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
-
var
|
|
95
|
+
var headers_1, data, err_1;
|
|
96
96
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
97
97
|
return __generator(this, function (_o) {
|
|
98
98
|
switch (_o.label) {
|
|
@@ -105,9 +105,11 @@ export var useApplePay = function (_a) {
|
|
|
105
105
|
throw new Error('The device/customer is not eligible to use ApplePay');
|
|
106
106
|
}
|
|
107
107
|
if (metaData) {
|
|
108
|
-
|
|
108
|
+
headers_1 = metaData.headers;
|
|
109
109
|
setAxiosGlobalHeaders(__assign({}, headers_1));
|
|
110
|
-
setProfile(
|
|
110
|
+
setProfile(metaData);
|
|
111
|
+
setApplePayRequestData(prepareApplePayRequest(__assign(__assign({}, metaData), { order: order, acceptance: acceptance, customer: customer })));
|
|
112
|
+
setInitialLoading(false);
|
|
111
113
|
return [2];
|
|
112
114
|
}
|
|
113
115
|
if (!headers) return [3, 3];
|
|
@@ -158,8 +160,7 @@ export var useApplePay = function (_a) {
|
|
|
158
160
|
if (debug)
|
|
159
161
|
console.log('merchant configuration: ', data);
|
|
160
162
|
setProfile(data);
|
|
161
|
-
|
|
162
|
-
setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
|
|
163
|
+
setApplePayRequestData(prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer })));
|
|
163
164
|
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);
|
|
164
165
|
setApplePayRequestConfiguration({
|
|
165
166
|
BASE_URL: MW_BASE_URL,
|
|
@@ -178,16 +179,6 @@ export var useApplePay = function (_a) {
|
|
|
178
179
|
}
|
|
179
180
|
});
|
|
180
181
|
}); };
|
|
181
|
-
var isTapIdentifier = function (id) { return (id.toLowerCase().includes('knet') ? 'knet' : 'tap'); };
|
|
182
|
-
var domainValidator = useMemo(function () {
|
|
183
|
-
var _a, _b, _c;
|
|
184
|
-
if (merchant.identifier)
|
|
185
|
-
return isTapIdentifier(merchant.identifier);
|
|
186
|
-
if (!((_a = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _a === void 0 ? void 0 : _a.payment_methods))
|
|
187
|
-
return '';
|
|
188
|
-
var identifier = (_c = (_b = getApplePayPaymentMethod(profileData.payment_options.payment_methods)) === null || _b === void 0 ? void 0 : _b.identifier) !== null && _c !== void 0 ? _c : '';
|
|
189
|
-
return isTapIdentifier(identifier);
|
|
190
|
-
}, [(_c = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _c === void 0 ? void 0 : _c.payment_methods, merchant === null || merchant === void 0 ? void 0 : merchant.identifier]);
|
|
191
182
|
var onApplePayButtonClicked = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
192
183
|
var ApplePaySession, session_1;
|
|
193
184
|
var _a;
|
|
@@ -229,7 +220,7 @@ export var useApplePay = function (_a) {
|
|
|
229
220
|
if (debug) {
|
|
230
221
|
console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(window.location.hostname));
|
|
231
222
|
}
|
|
232
|
-
return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, merchant.identifier || merchant.id || profileData.merchant.id
|
|
223
|
+
return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, merchant.identifier || merchant.id || profileData.merchant.id)];
|
|
233
224
|
case 2:
|
|
234
225
|
merchantSession = _a.sent();
|
|
235
226
|
if (debug)
|
package/build/utils/config.d.ts
CHANGED
|
@@ -7,8 +7,5 @@ export declare const getApplePayRequest: ({ order, customer, supportedNetworks,
|
|
|
7
7
|
countryCode: string;
|
|
8
8
|
name: string;
|
|
9
9
|
}) => ApplePayRequestData;
|
|
10
|
-
export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) =>
|
|
11
|
-
applePaySessionRequest: ApplePayRequestData;
|
|
12
|
-
paymentMethod: PaymentMethod;
|
|
13
|
-
};
|
|
10
|
+
export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => ApplePayRequestData;
|
|
14
11
|
export declare const shallRenderApplePay: () => boolean;
|
package/build/utils/config.js
CHANGED
|
@@ -57,7 +57,7 @@ export var prepareApplePayRequest = function (_a) {
|
|
|
57
57
|
merchantCapabilities: getMerchantCapabilities(acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedFundSource),
|
|
58
58
|
name: merchant.name
|
|
59
59
|
});
|
|
60
|
-
return
|
|
60
|
+
return request;
|
|
61
61
|
};
|
|
62
62
|
export var shallRenderApplePay = function () {
|
|
63
63
|
var https = window.location.protocol === 'https:';
|
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.77-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.46",
|
|
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",
|