@tap-payments/apple-pay-button 0.0.72-development → 0.0.74-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/hooks/useApplePay.js +11 -8
- package/package.json +1 -1
|
@@ -54,11 +54,10 @@ import { getApplePayPaymentMethod, getDefaultThemeMode } from '../utils';
|
|
|
54
54
|
import appService, { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api';
|
|
55
55
|
import { ChargeCode, mapingInterface } from '@tap-payments/acceptance-sdk';
|
|
56
56
|
export var useApplePay = function (_a) {
|
|
57
|
-
var _b;
|
|
57
|
+
var _b, _c;
|
|
58
58
|
var buttonProps = _a.buttonProps;
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var _e = useState(), paymentMethodIdentifier = _e[0], setPaymentMethodIdentifier = _e[1];
|
|
59
|
+
var _d = useState(), applePayRequestData = _d[0], setApplePayRequestData = _d[1];
|
|
60
|
+
var _e = useState(), applePayRequestConfiguration = _e[0], setApplePayRequestConfiguration = _e[1];
|
|
62
61
|
var _f = useState(), profileData = _f[0], setProfile = _f[1];
|
|
63
62
|
var _g = useState(false), disabled = _g[0], setDisabled = _g[1];
|
|
64
63
|
var _h = useState(false), initialLoading = _h[0], setInitialLoading = _h[1];
|
|
@@ -66,9 +65,6 @@ export var useApplePay = function (_a) {
|
|
|
66
65
|
var _k = useState(false), success = _k[0], setSuccess = _k[1];
|
|
67
66
|
var _l = useState(false), loading = _l[0], setLoading = _l[1];
|
|
68
67
|
var _m = useState(false), isRounded = _m[0], setIsRounded = _m[1];
|
|
69
|
-
var domainValidator = useMemo(function () {
|
|
70
|
-
return (paymentMethodIdentifier !== null && paymentMethodIdentifier !== void 0 ? paymentMethodIdentifier : '').toLowerCase().includes('knet') ? 'knet' : 'tap';
|
|
71
|
-
}, [paymentMethodIdentifier]);
|
|
72
68
|
var mappedProps = __assign(__assign({}, buttonProps), { interface: mapingInterface(buttonProps.interface) });
|
|
73
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;
|
|
74
70
|
var isIframeIntegration = buttonProps.integration === 'iframe';
|
|
@@ -164,7 +160,6 @@ export var useApplePay = function (_a) {
|
|
|
164
160
|
setProfile(data);
|
|
165
161
|
applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer }));
|
|
166
162
|
setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
|
|
167
|
-
setPaymentMethodIdentifier(applePayPreparedData.paymentMethod.identifier);
|
|
168
163
|
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);
|
|
169
164
|
setApplePayRequestConfiguration({
|
|
170
165
|
BASE_URL: MW_BASE_URL,
|
|
@@ -183,6 +178,14 @@ export var useApplePay = function (_a) {
|
|
|
183
178
|
}
|
|
184
179
|
});
|
|
185
180
|
}); };
|
|
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
|
+
var identifier = (_c = (_b = getApplePayPaymentMethod(((_a = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _a === void 0 ? void 0 : _a.payment_methods) || [])) === null || _b === void 0 ? void 0 : _b.identifier) !== null && _c !== void 0 ? _c : '';
|
|
187
|
+
return isTapIdentifier(identifier);
|
|
188
|
+
}, [(_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]);
|
|
186
189
|
var onApplePayButtonClicked = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
190
|
var ApplePaySession, session_1;
|
|
188
191
|
var _a;
|