paymob-pixel-alpha 1.1.28 → 1.1.29
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 +45 -36
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -22078,7 +22078,6 @@ function IframeCard(props) {
|
|
|
22078
22078
|
const {
|
|
22079
22079
|
loading,
|
|
22080
22080
|
handleCardSubmit,
|
|
22081
|
-
handleOTPSubmit,
|
|
22082
22081
|
getCardLogo,
|
|
22083
22082
|
useHookForm,
|
|
22084
22083
|
isOmanNetCard,
|
|
@@ -22144,8 +22143,6 @@ function IframeCard(props) {
|
|
|
22144
22143
|
handlePrevFocusFromSDK(event.data.payload);
|
|
22145
22144
|
} else if (event.data.type === 'cardData') {
|
|
22146
22145
|
handleCardDataFromSDK(event.data.payload);
|
|
22147
|
-
} else if (event.data.type === 'otpData') {
|
|
22148
|
-
handleOTPSubmit(event.data.payload);
|
|
22149
22146
|
} else if (event.data.type === 'customStyles') {
|
|
22150
22147
|
handleCardStylesFromSDK(event.data.payload);
|
|
22151
22148
|
} else if (event.data.type === 'cardHolderError') {
|
|
@@ -23415,7 +23412,14 @@ const checkDiscount = (payment_token, integration_id, identifier, isSavedCard) =
|
|
|
23415
23412
|
identifier: identifier.replace(/\s/g, '')
|
|
23416
23413
|
}, isSavedCard && {
|
|
23417
23414
|
saved_card_token: identifier
|
|
23418
|
-
}))
|
|
23415
|
+
}));
|
|
23416
|
+
};
|
|
23417
|
+
const sendOTP = payload => {
|
|
23418
|
+
return lib_axios.post(`/api/acceptance/omannet_callback/otp_verify`, {
|
|
23419
|
+
payment_id: payload.paymentId,
|
|
23420
|
+
otp: payload.otp,
|
|
23421
|
+
payment_token: payload.token
|
|
23422
|
+
}).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
23419
23423
|
};
|
|
23420
23424
|
;// ./src/utils/getErrorMsg.ts
|
|
23421
23425
|
const getErrorMsg_isString = data => typeof data === 'string';
|
|
@@ -23551,6 +23555,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
23551
23555
|
const [sendOTPLoading, setSendOTPLoading] = (0,react.useState)(false);
|
|
23552
23556
|
const [paymentId, setPaymentId] = (0,react.useState)('');
|
|
23553
23557
|
const [otpErrorMessage, setOTPErrorMessage] = (0,react.useState)('');
|
|
23558
|
+
const [isOmanNetCard, setIsOmanNetCard] = (0,react.useState)(false);
|
|
23554
23559
|
const tokenizationResolve = (0,react.useRef)(null);
|
|
23555
23560
|
const isCardValid = hideCardHolderName ? !isActionBtnDisabled : !(isActionBtnDisabled || !cardHolderName);
|
|
23556
23561
|
const isAmexCardSelected = (selectedCard == null ? void 0 : selectedCard.type) === src_constants_CARD_TYPES.AMEX;
|
|
@@ -23620,29 +23625,23 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
23620
23625
|
const handlePaymentResponse = ({
|
|
23621
23626
|
res,
|
|
23622
23627
|
requiresOTP,
|
|
23623
|
-
|
|
23628
|
+
isOmanNetCard
|
|
23624
23629
|
}) => {
|
|
23625
23630
|
var _iframeRef$current3, _res$data, _res$data2, _res$data3;
|
|
23626
23631
|
setShouldSubmitData(false);
|
|
23627
23632
|
setSendOTPLoading(false);
|
|
23633
|
+
setIsOmanNetCard(false);
|
|
23628
23634
|
const cardHolderInput = (_iframeRef$current3 = iframeRef.current) == null || (_iframeRef$current3 = _iframeRef$current3.nextElementSibling) == null ? void 0 : _iframeRef$current3.querySelector(`input[name=name]`);
|
|
23629
23635
|
if (cardHolderInput) {
|
|
23630
23636
|
setTimeout(() => cardHolderInput.disabled = false, 1000);
|
|
23631
23637
|
}
|
|
23632
23638
|
const redirectionUrl = ((_res$data = res.data) == null ? void 0 : _res$data.redirection_url) || ((_res$data2 = res.data) == null ? void 0 : _res$data2.redirect_url);
|
|
23633
23639
|
if (requiresOTP) {
|
|
23640
|
+
setIsOmanNetCard(!!isOmanNetCard);
|
|
23634
23641
|
setPaymentId(res.data.payment_id);
|
|
23635
23642
|
setShowOTP(true);
|
|
23636
23643
|
} else if (onAfterPaymentComplete && ((_res$data3 = res.data) == null ? void 0 : _res$data3.is_3d_secure) !== 'true') {
|
|
23637
23644
|
onAfterPaymentComplete(res);
|
|
23638
|
-
} else if (res.status === 200 && isOTPResponse) {
|
|
23639
|
-
if (redirectionUrl && (res.data.result === 'CAPTURED' || res.data.result === 'APPROVED')) {
|
|
23640
|
-
window.location.href = redirectionUrl;
|
|
23641
|
-
} else {
|
|
23642
|
-
setOTPErrorMessage(getErrorMsg(res));
|
|
23643
|
-
}
|
|
23644
|
-
} else if (res.status !== 200 && isOTPResponse) {
|
|
23645
|
-
setOTPErrorMessage(getErrorMsg(res));
|
|
23646
23645
|
} else if (res.status === 200 && redirectionUrl) {
|
|
23647
23646
|
window.location.href = redirectionUrl;
|
|
23648
23647
|
} else if (res.status === 400) {
|
|
@@ -23905,7 +23904,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
23905
23904
|
setSelectedDeleteCard(card);
|
|
23906
23905
|
};
|
|
23907
23906
|
const handleSavedCardSubmit = async () => {
|
|
23908
|
-
var _payment$subType6;
|
|
23907
|
+
var _payment$subType6, _res$data8, _res$data9, _res$data0;
|
|
23909
23908
|
if (loading) return;
|
|
23910
23909
|
setLoading(true);
|
|
23911
23910
|
if (onBeforePaymentComplete) {
|
|
@@ -23917,13 +23916,14 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
23917
23916
|
return;
|
|
23918
23917
|
}
|
|
23919
23918
|
}
|
|
23919
|
+
const isOmanNet = (selectedCard == null ? void 0 : selectedCard.type) === constants_SAVED_CARD_TYPES.OMAN_NET;
|
|
23920
23920
|
const data = {
|
|
23921
23921
|
identifier: selectedCard == null ? void 0 : selectedCard.identifier,
|
|
23922
23922
|
cvv: selectedCardCVV
|
|
23923
23923
|
};
|
|
23924
23924
|
const payload = Object.assign({
|
|
23925
23925
|
identifier: data.identifier,
|
|
23926
|
-
token:
|
|
23926
|
+
token: isOmanNet ? payment == null || (_payment$subType6 = payment.subType) == null ? void 0 : _payment$subType6.token : payment == null ? void 0 : payment.token
|
|
23927
23927
|
}, data.cvv && {
|
|
23928
23928
|
cvv: data.cvv
|
|
23929
23929
|
}, {
|
|
@@ -23931,21 +23931,25 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
23931
23931
|
});
|
|
23932
23932
|
const res = await payWithSavedCard(payload);
|
|
23933
23933
|
setLoading(false);
|
|
23934
|
+
setIsOmanNetCard(false);
|
|
23935
|
+
const isSuccess = String((_res$data8 = res.data) == null ? void 0 : _res$data8.success) === 'true';
|
|
23936
|
+
const isPending = String((_res$data9 = res.data) == null ? void 0 : _res$data9.pending) === 'true';
|
|
23937
|
+
const isOTPGeneration = String((_res$data0 = res.data) == null ? void 0 : _res$data0.otp_generation) === 'true';
|
|
23934
23938
|
if (res.status === 200) {
|
|
23935
|
-
if (
|
|
23936
|
-
|
|
23937
|
-
|
|
23938
|
-
|
|
23939
|
+
if (isOmanNet && isOTPGeneration && !isSuccess && isPending) {
|
|
23940
|
+
setIsOmanNetCard(true);
|
|
23941
|
+
setPaymentId(res.data.payment_id);
|
|
23942
|
+
setShowOTP(true);
|
|
23939
23943
|
} else {
|
|
23940
23944
|
window.location.href = res.data.redirection_url;
|
|
23941
23945
|
}
|
|
23942
23946
|
} else if (res.status === 400) {
|
|
23943
|
-
var _res$
|
|
23944
|
-
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$
|
|
23947
|
+
var _res$data1, _res$data10, _res$data11;
|
|
23948
|
+
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$data1 = res.data) == null ? void 0 : _res$data1.msg) === 'Retry limit reached.') {
|
|
23945
23949
|
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
23946
|
-
} else if (((_res$
|
|
23950
|
+
} else if (((_res$data10 = res.data) == null ? void 0 : _res$data10.message) === 'Session Error') {
|
|
23947
23951
|
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
23948
|
-
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$
|
|
23952
|
+
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$data11 = res.data) == null ? void 0 : _res$data11.msg) === 'Order has already paid.') {
|
|
23949
23953
|
setErrorMessage(t('ERR_MSG_ALREADY_PAID'));
|
|
23950
23954
|
} else {
|
|
23951
23955
|
setErrorMessage(t('ERR_MSG_DECLINED'));
|
|
@@ -23963,19 +23967,24 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
|
|
|
23963
23967
|
}
|
|
23964
23968
|
};
|
|
23965
23969
|
const handleOTPSubmit = async otp => {
|
|
23966
|
-
var
|
|
23970
|
+
var _payment$subType7, _res$data12, _res$data13;
|
|
23967
23971
|
setSendOTPLoading(true);
|
|
23968
|
-
|
|
23969
|
-
|
|
23970
|
-
|
|
23971
|
-
|
|
23972
|
-
|
|
23973
|
-
|
|
23974
|
-
|
|
23975
|
-
|
|
23976
|
-
|
|
23972
|
+
const res = await sendOTP({
|
|
23973
|
+
token: isOmanNetCard ? (_payment$subType7 = payment.subType) == null ? void 0 : _payment$subType7.token : payment.token,
|
|
23974
|
+
otp,
|
|
23975
|
+
paymentId
|
|
23976
|
+
});
|
|
23977
|
+
const redirectionUrl = ((_res$data12 = res.data) == null ? void 0 : _res$data12.redirection_url) || ((_res$data13 = res.data) == null ? void 0 : _res$data13.redirect_url);
|
|
23978
|
+
if (res.status === 200) {
|
|
23979
|
+
if (redirectionUrl && (res.data.result === 'CAPTURED' || res.data.result === 'APPROVED')) {
|
|
23980
|
+
window.location.href = redirectionUrl;
|
|
23981
|
+
} else {
|
|
23982
|
+
setOTPErrorMessage(getErrorMsg(res));
|
|
23977
23983
|
}
|
|
23978
|
-
}
|
|
23984
|
+
} else if (res.status !== 200) {
|
|
23985
|
+
setOTPErrorMessage(getErrorMsg(res));
|
|
23986
|
+
}
|
|
23987
|
+
setSendOTPLoading(false);
|
|
23979
23988
|
};
|
|
23980
23989
|
const handleShowNewCardForm = () => {
|
|
23981
23990
|
if (loading) return;
|
|
@@ -27703,7 +27712,7 @@ const payForsa = (phone, down_payment, selected_plan, tenure, token) => {
|
|
|
27703
27712
|
payment_token: token
|
|
27704
27713
|
}).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
27705
27714
|
};
|
|
27706
|
-
const
|
|
27715
|
+
const forsaService_sendOTP = (otp, token, reference) => {
|
|
27707
27716
|
return lib_axios.post(`/api/acceptance/forsa_online/submit_loan`, {
|
|
27708
27717
|
otp: otp,
|
|
27709
27718
|
payment_token: token,
|
|
@@ -27866,7 +27875,7 @@ function ForsaElements({
|
|
|
27866
27875
|
const handleOTPSubmit = async otp => {
|
|
27867
27876
|
setLoading(true);
|
|
27868
27877
|
resetErrorMessage();
|
|
27869
|
-
const res = await
|
|
27878
|
+
const res = await forsaService_sendOTP(otp, token, reference);
|
|
27870
27879
|
if (res.status === 200) {
|
|
27871
27880
|
if (window.top) {
|
|
27872
27881
|
window.top.location.href = res.data.redirection_url;
|