paymob-pixel-alpha 1.1.69 → 1.1.71
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/main.js +88 -40
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -83754,6 +83754,10 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
83754
83754
|
const [instantRefundAmount, setInstantRefundAmount] = (0,react.useState)('');
|
|
83755
83755
|
const [isInquiringInstantRefund, setIsInquiringInstantRefund] = (0,react.useState)(false);
|
|
83756
83756
|
const [isInstantRefundChecked, setIsInstantRefundChecked] = (0,react.useState)(false);
|
|
83757
|
+
const checkInstantRefundGeographicEligibility = () => {
|
|
83758
|
+
const countriesCurrencies = ["EGP"];
|
|
83759
|
+
return countriesCurrencies.includes(currency);
|
|
83760
|
+
};
|
|
83757
83761
|
const showCvvInput = paymentMethodType === constants_PAYMENT_METHODS_TYPES.MOTO && useCvv || paymentMethodType === constants_PAYMENT_METHODS_TYPES.ONLINE;
|
|
83758
83762
|
const shouldDisablePayBtn = showCvvInput ? loading || (isAmexCardSelected ? selectedCardCvvLength !== src_constants_AMEX_CVV_LENGTH : selectedCardCvvLength !== constants_CVV_LENGTH) : !selectedCardId;
|
|
83759
83763
|
const resetInstantRefundState = () => {
|
|
@@ -83843,9 +83847,14 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
83843
83847
|
res
|
|
83844
83848
|
} = toggleResponse != null ? toggleResponse : {};
|
|
83845
83849
|
if (success && res) {
|
|
83846
|
-
|
|
83850
|
+
if (res.status === 200) {
|
|
83851
|
+
handleDiscount(res);
|
|
83852
|
+
}
|
|
83847
83853
|
}
|
|
83848
|
-
instantRefundToggleResolve.current == null || instantRefundToggleResolve.current(
|
|
83854
|
+
instantRefundToggleResolve.current == null || instantRefundToggleResolve.current({
|
|
83855
|
+
ok: !!success,
|
|
83856
|
+
res
|
|
83857
|
+
});
|
|
83849
83858
|
instantRefundToggleResolve.current = null;
|
|
83850
83859
|
setIsInquiringInstantRefund(false);
|
|
83851
83860
|
}
|
|
@@ -84008,10 +84017,11 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84008
84017
|
type: 'INSTANT_REFUND_TOGGLE',
|
|
84009
84018
|
payload: {
|
|
84010
84019
|
enabled: isInstantRefundChecked,
|
|
84011
|
-
instantRefundAmount: (_instantRefundData$in = instantRefundData == null ? void 0 : instantRefundData.instant_refund_fees) != null ? _instantRefundData$in :
|
|
84020
|
+
instantRefundAmount: Number((_instantRefundData$in = instantRefundData == null ? void 0 : instantRefundData.instant_refund_fees) != null ? _instantRefundData$in : 0) / 100,
|
|
84012
84021
|
eligible: (_instantRefundData$el = instantRefundData == null ? void 0 : instantRefundData.eligible) != null ? _instantRefundData$el : false,
|
|
84013
84022
|
totalAmount,
|
|
84014
|
-
originalAmount: payment == null ? void 0 : payment.amount
|
|
84023
|
+
originalAmount: payment == null ? void 0 : payment.amount,
|
|
84024
|
+
currency
|
|
84015
84025
|
}
|
|
84016
84026
|
});
|
|
84017
84027
|
}, [isInstantRefundChecked, instantRefundData, totalAmount]);
|
|
@@ -84257,7 +84267,10 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84257
84267
|
}, '*');
|
|
84258
84268
|
instantRefundToggleTimeoutRef.current = setTimeout(() => {
|
|
84259
84269
|
if (instantRefundToggleResolve.current) {
|
|
84260
|
-
instantRefundToggleResolve.current(
|
|
84270
|
+
instantRefundToggleResolve.current({
|
|
84271
|
+
ok: false,
|
|
84272
|
+
res: undefined
|
|
84273
|
+
});
|
|
84261
84274
|
instantRefundToggleResolve.current = null;
|
|
84262
84275
|
setIsInquiringInstantRefund(false);
|
|
84263
84276
|
}
|
|
@@ -84268,13 +84281,25 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84268
84281
|
const discountIntegrationId = getDiscountIntegrationId();
|
|
84269
84282
|
if (!discountIntegrationId) {
|
|
84270
84283
|
applyNoDiscountInstantRefundAmounts(nextChecked);
|
|
84271
|
-
return
|
|
84284
|
+
return {
|
|
84285
|
+
ok: true,
|
|
84286
|
+
res: undefined
|
|
84287
|
+
};
|
|
84272
84288
|
}
|
|
84273
84289
|
const token = nextChecked ? instantRefundData == null ? void 0 : instantRefundData.new_payment_token : payment == null ? void 0 : payment.token;
|
|
84274
84290
|
const res = await checkDiscount(token, payment.id, selectedCard.identifier, selectedCard.type);
|
|
84275
|
-
if ((res == null ? void 0 : res.status) !== 200)
|
|
84291
|
+
if ((res == null ? void 0 : res.status) !== 200) {
|
|
84292
|
+
return {
|
|
84293
|
+
ok: true,
|
|
84294
|
+
res: res
|
|
84295
|
+
};
|
|
84296
|
+
}
|
|
84297
|
+
;
|
|
84276
84298
|
handleDiscount(res);
|
|
84277
|
-
return
|
|
84299
|
+
return {
|
|
84300
|
+
ok: true,
|
|
84301
|
+
res: res
|
|
84302
|
+
};
|
|
84278
84303
|
};
|
|
84279
84304
|
const handleInstantRefundToggleChange = async currentChecked => {
|
|
84280
84305
|
if (!payment || !(instantRefundData != null && instantRefundData.eligible)) return false;
|
|
@@ -84282,10 +84307,11 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84282
84307
|
const isSavedCardContext = !!(savedCards != null && savedCards.length) && !showCardModal && !!selectedCard;
|
|
84283
84308
|
setIsInquiringInstantRefund(true);
|
|
84284
84309
|
try {
|
|
84285
|
-
|
|
84286
|
-
|
|
84310
|
+
var _response$res;
|
|
84311
|
+
const response = isSavedCardContext ? await handleSavedCardToggle(nextChecked) : await postToggleToIframe(nextChecked);
|
|
84312
|
+
if (!response.ok) return false;
|
|
84287
84313
|
setIsInstantRefundChecked(nextChecked);
|
|
84288
|
-
if (!hasDiscountForPayment) {
|
|
84314
|
+
if (!hasDiscountForPayment || ((_response$res = response.res) == null ? void 0 : _response$res.status) !== 200) {
|
|
84289
84315
|
applyNoDiscountInstantRefundAmounts(nextChecked);
|
|
84290
84316
|
}
|
|
84291
84317
|
return true;
|
|
@@ -84471,7 +84497,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84471
84497
|
fontFamily: currencyFontFamily
|
|
84472
84498
|
},
|
|
84473
84499
|
children: displayCurrency
|
|
84474
|
-
}), ' ',
|
|
84500
|
+
}), ' ', formattedAmount]
|
|
84475
84501
|
})]
|
|
84476
84502
|
}), discountedAmount && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
84477
84503
|
className: "flex justify-between items-center text-green-600",
|
|
@@ -84662,7 +84688,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84662
84688
|
customError: customStyle == null || (_customStyle$errorTex4 = customStyle.errorText) == null ? void 0 : _customStyle$errorTex4.holderName
|
|
84663
84689
|
})
|
|
84664
84690
|
})]
|
|
84665
|
-
}), isInstantRefundActive && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
|
|
84691
|
+
}), isInstantRefundActive && checkInstantRefundGeographicEligibility() && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
|
|
84666
84692
|
checked: isInstantRefundChecked,
|
|
84667
84693
|
onChange: handleInstantRefundToggleChange,
|
|
84668
84694
|
instantRefundData: instantRefundData,
|
|
@@ -84748,7 +84774,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
84748
84774
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
84749
84775
|
children: discountAppliedMessage
|
|
84750
84776
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(icons_CircleCheck, {})]
|
|
84751
|
-
}), isInstantRefundActive && selectedCard && !showCardModal && card.id === selectedCardId && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
|
|
84777
|
+
}), isInstantRefundActive && selectedCard && !showCardModal && card.id === selectedCardId && checkInstantRefundGeographicEligibility() && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
|
|
84752
84778
|
checked: isInstantRefundChecked,
|
|
84753
84779
|
onChange: handleInstantRefundToggleChange,
|
|
84754
84780
|
instantRefundData: instantRefundData,
|
|
@@ -94743,11 +94769,21 @@ function KnetApplePay(props) {
|
|
|
94743
94769
|
}
|
|
94744
94770
|
}
|
|
94745
94771
|
session.onvalidatemerchant = async event => {
|
|
94746
|
-
|
|
94747
|
-
|
|
94772
|
+
try {
|
|
94773
|
+
const merchantSession = await validatemerchant(event.validationURL, integrationId);
|
|
94774
|
+
if (!merchantSession || typeof merchantSession !== 'object' || merchantSession.status === 0) {
|
|
94775
|
+
session.abort();
|
|
94776
|
+
setLoading(false);
|
|
94777
|
+
return;
|
|
94778
|
+
}
|
|
94779
|
+
session.completeMerchantValidation(merchantSession);
|
|
94780
|
+
} catch (e) {
|
|
94781
|
+
session.abort();
|
|
94782
|
+
setLoading(false);
|
|
94783
|
+
}
|
|
94748
94784
|
};
|
|
94749
94785
|
session.onpaymentauthorized = async event => {
|
|
94750
|
-
var _payRes$data, _payRes$data2, _payRes$data3;
|
|
94786
|
+
var _event$payment, _payRes$data, _payRes$data2, _payRes$data3;
|
|
94751
94787
|
let clientData = null;
|
|
94752
94788
|
if (!clientInfo) {
|
|
94753
94789
|
try {
|
|
@@ -94769,7 +94805,7 @@ function KnetApplePay(props) {
|
|
|
94769
94805
|
console.log(e);
|
|
94770
94806
|
}
|
|
94771
94807
|
}
|
|
94772
|
-
const payRes = await knetApplePayPayment(JSON.stringify(event.payment.token.paymentData), paymentToken, clientData);
|
|
94808
|
+
const payRes = await knetApplePayPayment(JSON.stringify((_event$payment = event.payment) == null || (_event$payment = _event$payment.token) == null ? void 0 : _event$payment.paymentData), paymentToken, clientData);
|
|
94773
94809
|
setLoading(false);
|
|
94774
94810
|
let status;
|
|
94775
94811
|
let resStatus = '';
|
|
@@ -94804,15 +94840,19 @@ function KnetApplePay(props) {
|
|
|
94804
94840
|
resStatus = 'invalid';
|
|
94805
94841
|
}
|
|
94806
94842
|
if (onAfterPaymentComplete) {
|
|
94807
|
-
|
|
94808
|
-
|
|
94809
|
-
|
|
94843
|
+
try {
|
|
94844
|
+
session.completePayment({
|
|
94845
|
+
status
|
|
94846
|
+
});
|
|
94847
|
+
} catch (_) {}
|
|
94810
94848
|
onAfterPaymentComplete(payRes);
|
|
94811
94849
|
} else {
|
|
94812
94850
|
onSubmit(resStatus, payRes.data);
|
|
94813
|
-
|
|
94814
|
-
|
|
94815
|
-
|
|
94851
|
+
try {
|
|
94852
|
+
session.completePayment({
|
|
94853
|
+
status
|
|
94854
|
+
});
|
|
94855
|
+
} catch (_) {}
|
|
94816
94856
|
}
|
|
94817
94857
|
};
|
|
94818
94858
|
session.oncancel = () => {
|
|
@@ -95100,14 +95140,18 @@ function apple_pay_ApplePay(props) {
|
|
|
95100
95140
|
}
|
|
95101
95141
|
}
|
|
95102
95142
|
session.onvalidatemerchant = async event => {
|
|
95103
|
-
|
|
95104
|
-
|
|
95105
|
-
|
|
95106
|
-
|
|
95107
|
-
|
|
95108
|
-
|
|
95109
|
-
|
|
95110
|
-
|
|
95143
|
+
try {
|
|
95144
|
+
const merchantSession = await validatemerchant(event.validationURL, integrationId, displayName);
|
|
95145
|
+
if (!merchantSession || typeof merchantSession !== 'object' || merchantSession.status === 0) {
|
|
95146
|
+
session.abort();
|
|
95147
|
+
setLoading(false);
|
|
95148
|
+
return;
|
|
95149
|
+
}
|
|
95150
|
+
session.completeMerchantValidation(merchantSession);
|
|
95151
|
+
} catch (e) {
|
|
95152
|
+
session.abort();
|
|
95153
|
+
setLoading(false);
|
|
95154
|
+
}
|
|
95111
95155
|
};
|
|
95112
95156
|
session.onshippingcontactselected = async event => {
|
|
95113
95157
|
console.log({
|
|
@@ -95135,7 +95179,7 @@ function apple_pay_ApplePay(props) {
|
|
|
95135
95179
|
});
|
|
95136
95180
|
};
|
|
95137
95181
|
session.onpaymentauthorized = async event => {
|
|
95138
|
-
var _payRes$data, _payRes$data2, _payRes$data3;
|
|
95182
|
+
var _event$payment, _payRes$data, _payRes$data2, _payRes$data3;
|
|
95139
95183
|
let clientData = null;
|
|
95140
95184
|
if (!clientInfo) {
|
|
95141
95185
|
const billingAddress = event.payment.billingContact;
|
|
@@ -95182,7 +95226,7 @@ function apple_pay_ApplePay(props) {
|
|
|
95182
95226
|
// dispatch(addClientInfo(clientData));
|
|
95183
95227
|
// }
|
|
95184
95228
|
console.log("start pay request");
|
|
95185
|
-
const payRes = await paymentauthorized(JSON.stringify(event.payment.token.paymentData), paymentToken, clientData);
|
|
95229
|
+
const payRes = await paymentauthorized(JSON.stringify((_event$payment = event.payment) == null || (_event$payment = _event$payment.token) == null ? void 0 : _event$payment.paymentData), paymentToken, clientData);
|
|
95186
95230
|
setLoading(false);
|
|
95187
95231
|
let status;
|
|
95188
95232
|
let resStatus = '';
|
|
@@ -95217,15 +95261,19 @@ function apple_pay_ApplePay(props) {
|
|
|
95217
95261
|
resStatus = 'invalid';
|
|
95218
95262
|
}
|
|
95219
95263
|
if (onAfterPaymentComplete) {
|
|
95220
|
-
|
|
95221
|
-
|
|
95222
|
-
|
|
95264
|
+
try {
|
|
95265
|
+
session.completePayment({
|
|
95266
|
+
status
|
|
95267
|
+
});
|
|
95268
|
+
} catch (_) {}
|
|
95223
95269
|
onAfterPaymentComplete(payRes);
|
|
95224
95270
|
} else {
|
|
95225
95271
|
onSubmit(resStatus, payRes.data);
|
|
95226
|
-
|
|
95227
|
-
|
|
95228
|
-
|
|
95272
|
+
try {
|
|
95273
|
+
session.completePayment({
|
|
95274
|
+
status
|
|
95275
|
+
});
|
|
95276
|
+
} catch (_) {}
|
|
95229
95277
|
}
|
|
95230
95278
|
//}
|
|
95231
95279
|
};
|