@tap-payments/apple-pay-button 0.0.71-development → 0.0.73-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/ApplePayButtonProps.d.ts +0 -1
- package/build/api.d.ts +1 -1
- package/build/api.js +2 -2
- package/build/hooks/useApplePay.js +17 -24
- package/package.json +1 -1
package/build/api.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare class APPService {
|
|
|
20
20
|
merchant: any;
|
|
21
21
|
payment_options: any;
|
|
22
22
|
}>;
|
|
23
|
-
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string,
|
|
23
|
+
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string, domainValidator: string): Promise<any>;
|
|
24
24
|
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
25
25
|
createCharge(request: ChargeRequestBody): Promise<any>;
|
|
26
26
|
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, domainValidator) {
|
|
153
153
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
154
|
var body, data;
|
|
155
155
|
return __generator(this, function (_a) {
|
|
@@ -161,7 +161,7 @@ var APPService = (function () {
|
|
|
161
161
|
merchantIdentifier: merchantIdentifier,
|
|
162
162
|
merchantId: merchant.id,
|
|
163
163
|
merchantName: merchant.name,
|
|
164
|
-
|
|
164
|
+
domainValidator: domainValidator
|
|
165
165
|
};
|
|
166
166
|
return [4, axiosInstance.post('/validatemerchant', body)];
|
|
167
167
|
case 1:
|
|
@@ -66,7 +66,7 @@ export var useApplePay = function (_a) {
|
|
|
66
66
|
var _k = useState(false), success = _k[0], setSuccess = _k[1];
|
|
67
67
|
var _l = useState(false), loading = _l[0], setLoading = _l[1];
|
|
68
68
|
var _m = useState(false), isRounded = _m[0], setIsRounded = _m[1];
|
|
69
|
-
var
|
|
69
|
+
var domainValidator = useMemo(function () {
|
|
70
70
|
return (paymentMethodIdentifier !== null && paymentMethodIdentifier !== void 0 ? paymentMethodIdentifier : '').toLowerCase().includes('knet') ? 'knet' : 'tap';
|
|
71
71
|
}, [paymentMethodIdentifier]);
|
|
72
72
|
var mappedProps = __assign(__assign({}, buttonProps), { interface: mapingInterface(buttonProps.interface) });
|
|
@@ -97,14 +97,14 @@ export var useApplePay = function (_a) {
|
|
|
97
97
|
}, [profileData]);
|
|
98
98
|
var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
99
|
var merchantProfile, payment_options, headers_1, data, applePayPreparedData, err_1;
|
|
100
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
101
|
-
return __generator(this, function (
|
|
102
|
-
switch (
|
|
100
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
101
|
+
return __generator(this, function (_p) {
|
|
102
|
+
switch (_p.label) {
|
|
103
103
|
case 0:
|
|
104
104
|
setInitialLoading(true);
|
|
105
|
-
|
|
105
|
+
_p.label = 1;
|
|
106
106
|
case 1:
|
|
107
|
-
|
|
107
|
+
_p.trys.push([1, 7, , 8]);
|
|
108
108
|
if (!shallRenderApplePay()) {
|
|
109
109
|
throw new Error('The device/customer is not eligible to use ApplePay');
|
|
110
110
|
}
|
|
@@ -117,7 +117,7 @@ export var useApplePay = function (_a) {
|
|
|
117
117
|
if (!headers) return [3, 3];
|
|
118
118
|
return [4, appService.setHttpHeaders(__assign(__assign({}, headers), { authorization: operator.publicKey }))];
|
|
119
119
|
case 2:
|
|
120
|
-
|
|
120
|
+
_p.sent();
|
|
121
121
|
return [3, 5];
|
|
122
122
|
case 3: return [4, appService.setBrowserHeaders({
|
|
123
123
|
locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
|
|
@@ -125,8 +125,8 @@ export var useApplePay = function (_a) {
|
|
|
125
125
|
pk: operator.publicKey
|
|
126
126
|
})];
|
|
127
127
|
case 4:
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
_p.sent();
|
|
129
|
+
_p.label = 5;
|
|
130
130
|
case 5: return [4, appService.checkoutProfile({
|
|
131
131
|
supported_payment_methods: ['APPLE_PAY'],
|
|
132
132
|
supported_currencies: [order.currency],
|
|
@@ -158,24 +158,24 @@ export var useApplePay = function (_a) {
|
|
|
158
158
|
] })
|
|
159
159
|
})];
|
|
160
160
|
case 6:
|
|
161
|
-
data =
|
|
161
|
+
data = _p.sent();
|
|
162
162
|
if (debug)
|
|
163
163
|
console.log('merchant configuration: ', data);
|
|
164
164
|
setProfile(data);
|
|
165
165
|
applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer }));
|
|
166
166
|
setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
|
|
167
|
-
setPaymentMethodIdentifier(applePayPreparedData.paymentMethod.identifier);
|
|
168
|
-
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((
|
|
167
|
+
setPaymentMethodIdentifier((_k = merchant.identifier) !== null && _k !== void 0 ? _k : applePayPreparedData.paymentMethod.identifier);
|
|
168
|
+
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);
|
|
169
169
|
setApplePayRequestConfiguration({
|
|
170
170
|
BASE_URL: MW_BASE_URL,
|
|
171
171
|
headers: getAxiosGlobalHeaders(),
|
|
172
|
-
merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((
|
|
172
|
+
merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((_o = data.merchant) === null || _o === void 0 ? void 0 : _o.id) })
|
|
173
173
|
});
|
|
174
174
|
setInitialLoading(false);
|
|
175
175
|
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
176
176
|
return [3, 8];
|
|
177
177
|
case 7:
|
|
178
|
-
err_1 =
|
|
178
|
+
err_1 = _p.sent();
|
|
179
179
|
onError === null || onError === void 0 ? void 0 : onError(err_1.errors || err_1);
|
|
180
180
|
console.log('error in initialize', err_1);
|
|
181
181
|
return [3, 8];
|
|
@@ -224,7 +224,7 @@ export var useApplePay = function (_a) {
|
|
|
224
224
|
if (debug) {
|
|
225
225
|
console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(window.location.hostname));
|
|
226
226
|
}
|
|
227
|
-
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,
|
|
227
|
+
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, domainValidator)];
|
|
228
228
|
case 2:
|
|
229
229
|
merchantSession = _a.sent();
|
|
230
230
|
if (debug)
|
|
@@ -390,19 +390,12 @@ export var useApplePay = function (_a) {
|
|
|
390
390
|
var handleClick = useCallback(function () {
|
|
391
391
|
var _a, _b;
|
|
392
392
|
if (isIframeIntegration) {
|
|
393
|
-
(_a = buttonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(buttonProps, __assign(__assign({}, applePayRequestConfiguration), { applePayRequestData: applePayRequestData
|
|
393
|
+
(_a = buttonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(buttonProps, __assign(__assign({}, applePayRequestConfiguration), { applePayRequestData: applePayRequestData }));
|
|
394
394
|
return;
|
|
395
395
|
}
|
|
396
396
|
onApplePayButtonClicked();
|
|
397
397
|
(_b = buttonProps.onClick) === null || _b === void 0 ? void 0 : _b.call(buttonProps);
|
|
398
|
-
}, [
|
|
399
|
-
applePayRequestConfiguration,
|
|
400
|
-
applePayRequestData,
|
|
401
|
-
buttonProps,
|
|
402
|
-
isIframeIntegration,
|
|
403
|
-
onApplePayButtonClicked,
|
|
404
|
-
paymentProcessor
|
|
405
|
-
]);
|
|
398
|
+
}, [applePayRequestConfiguration, applePayRequestData, buttonProps, isIframeIntegration, onApplePayButtonClicked]);
|
|
406
399
|
useEffect(function () {
|
|
407
400
|
initialize(metaData);
|
|
408
401
|
}, []);
|