paymob-pixel-alpha 1.0.8 → 1.1.0
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 +225 -103
- package/package.json +1 -1
- package/styles.css +4 -0
package/main.js
CHANGED
|
@@ -10055,10 +10055,18 @@ function useWidth() {
|
|
|
10055
10055
|
const [isMobile, setIsMobile] = (0,react.useState)(false);
|
|
10056
10056
|
(0,react.useEffect)(() => {
|
|
10057
10057
|
const handleResize = () => {
|
|
10058
|
-
if (window.
|
|
10059
|
-
|
|
10058
|
+
if (window.visualViewport) {
|
|
10059
|
+
if (window.visualViewport.width <= 644) {
|
|
10060
|
+
setIsMobile(true);
|
|
10061
|
+
} else {
|
|
10062
|
+
setIsMobile(false);
|
|
10063
|
+
}
|
|
10060
10064
|
} else {
|
|
10061
|
-
|
|
10065
|
+
if (window.innerWidth <= 644) {
|
|
10066
|
+
setIsMobile(true);
|
|
10067
|
+
} else {
|
|
10068
|
+
setIsMobile(false);
|
|
10069
|
+
}
|
|
10062
10070
|
}
|
|
10063
10071
|
};
|
|
10064
10072
|
handleResize();
|
|
@@ -17637,6 +17645,7 @@ function TermsConditions_TermsConditions() {
|
|
|
17637
17645
|
|
|
17638
17646
|
|
|
17639
17647
|
|
|
17648
|
+
|
|
17640
17649
|
|
|
17641
17650
|
|
|
17642
17651
|
;// CONCATENATED MODULE: ../../node_modules/react-loading-skeleton/dist/index.js
|
|
@@ -18753,12 +18762,16 @@ function mobileCardFormViewTwo_MobileCard(props) {
|
|
|
18753
18762
|
|
|
18754
18763
|
|
|
18755
18764
|
function IframeCard(props) {
|
|
18756
|
-
var _subType$type;
|
|
18757
18765
|
const {
|
|
18758
18766
|
loading,
|
|
18759
18767
|
handleCardSubmit,
|
|
18768
|
+
handleOTPSubmit,
|
|
18760
18769
|
getCardLogo,
|
|
18761
|
-
useHookForm
|
|
18770
|
+
useHookForm,
|
|
18771
|
+
isOmanNetCard,
|
|
18772
|
+
setIsOmanNetCard,
|
|
18773
|
+
hasOmanNetIntegration,
|
|
18774
|
+
setHasOmanNetIntegration
|
|
18762
18775
|
} = props;
|
|
18763
18776
|
const [iframeCardHight, setIframeCardHight] = useState();
|
|
18764
18777
|
const [iframeCustomStyles, setIframeCustomStyles] = useState({});
|
|
@@ -18771,7 +18784,6 @@ function IframeCard(props) {
|
|
|
18771
18784
|
const [cardHolderError, setCardHolderError] = useState();
|
|
18772
18785
|
const [cardHolderNameHidden, setCardHolderNameHidden] = useState(false);
|
|
18773
18786
|
const [currency, setCurrency] = useState('');
|
|
18774
|
-
const hasOmanNetIntegration = (subType == null || (_subType$type = subType.type) == null ? void 0 : _subType$type.toLowerCase()) === CARD_TYPES.OMAN;
|
|
18775
18787
|
const {
|
|
18776
18788
|
handleSubmit,
|
|
18777
18789
|
errors,
|
|
@@ -18791,11 +18803,16 @@ function IframeCard(props) {
|
|
|
18791
18803
|
window.addEventListener('message', handleDataFromSDK);
|
|
18792
18804
|
return () => window.removeEventListener('message', handleDataFromSDK);
|
|
18793
18805
|
}, []);
|
|
18806
|
+
useEffect(() => {
|
|
18807
|
+
setIsOmanNetCard == null || setIsOmanNetCard(cardType === CARD_TYPES.OMAN);
|
|
18808
|
+
}, [cardType, setIsOmanNetCard]);
|
|
18794
18809
|
const handleDataFromSDK = event => {
|
|
18795
18810
|
if (event.data.type === 'setPrevFocus') {
|
|
18796
18811
|
handlePrevFocusFromSDK(event.data.payload);
|
|
18797
18812
|
} else if (event.data.type === 'cardData') {
|
|
18798
18813
|
handleCardDataFromSDK(event.data.payload);
|
|
18814
|
+
} else if (event.data.type === 'otpData') {
|
|
18815
|
+
handleOTPSubmit(event.data.payload);
|
|
18799
18816
|
} else if (event.data.type === 'customStyles') {
|
|
18800
18817
|
handleCardStylesFromSDK(event.data.payload);
|
|
18801
18818
|
} else if (event.data.type === 'cardHolderError') {
|
|
@@ -18825,7 +18842,9 @@ function IframeCard(props) {
|
|
|
18825
18842
|
setPaymentToken(payload.paymentToken);
|
|
18826
18843
|
}
|
|
18827
18844
|
if ((_payload$subType = payload.subType) != null && _payload$subType.paymentToken && (_payload$subType2 = payload.subType) != null && _payload$subType2.type) {
|
|
18845
|
+
var _payload$subType$type;
|
|
18828
18846
|
setSubType(payload.subType);
|
|
18847
|
+
setHasOmanNetIntegration(((_payload$subType$type = payload.subType.type) == null ? void 0 : _payload$subType$type.toLowerCase()) === CARD_TYPES.OMAN);
|
|
18829
18848
|
}
|
|
18830
18849
|
if (payload.tenure) {
|
|
18831
18850
|
setTenure(payload.tenure);
|
|
@@ -18870,8 +18889,8 @@ function IframeCard(props) {
|
|
|
18870
18889
|
handleCardSubmit({
|
|
18871
18890
|
data,
|
|
18872
18891
|
cardHolderName,
|
|
18873
|
-
paymentToken: hasOmanNetIntegration &&
|
|
18874
|
-
subType: hasOmanNetIntegration &&
|
|
18892
|
+
paymentToken: hasOmanNetIntegration && isOmanNetCard ? subType.paymentToken : paymentToken,
|
|
18893
|
+
subType: hasOmanNetIntegration && isOmanNetCard ? subType.type : 'CARD',
|
|
18875
18894
|
saveCard,
|
|
18876
18895
|
tenure
|
|
18877
18896
|
});
|
|
@@ -19869,7 +19888,9 @@ function CardElement({
|
|
|
19869
19888
|
onCardValidationChanged,
|
|
19870
19889
|
showPaymobLogo,
|
|
19871
19890
|
hideCardHolderName,
|
|
19872
|
-
isLoading
|
|
19891
|
+
isLoading,
|
|
19892
|
+
onProcessingPayment,
|
|
19893
|
+
isProcessingPayment
|
|
19873
19894
|
}) {
|
|
19874
19895
|
var _customStyle$containe;
|
|
19875
19896
|
const {
|
|
@@ -19882,6 +19903,7 @@ function CardElement({
|
|
|
19882
19903
|
const {
|
|
19883
19904
|
t
|
|
19884
19905
|
} = useTranslation_useTranslation('card');
|
|
19906
|
+
const isMobile = useWidth();
|
|
19885
19907
|
const [loading, setLoading] = (0,react.useState)(false);
|
|
19886
19908
|
const [cardHolderName, setCardHolderName] = (0,react.useState)('');
|
|
19887
19909
|
const [isActionBtnDisabled, setIsActionBtnDisabled] = (0,react.useState)(false);
|
|
@@ -19899,6 +19921,10 @@ function CardElement({
|
|
|
19899
19921
|
const [selectedCardCVV, setSelectedCardCVV] = (0,react.useState)('');
|
|
19900
19922
|
const [showCardModal, setShowCardModal] = (0,react.useState)(false);
|
|
19901
19923
|
const [showCVVTooltipModal, setShowCVVTooltipModal] = (0,react.useState)(false);
|
|
19924
|
+
const [showOTP, setShowOTP] = (0,react.useState)(false);
|
|
19925
|
+
const [sendOTPLoading, setSendOTPLoading] = (0,react.useState)(false);
|
|
19926
|
+
const previousValidationRef = (0,react.useRef)(false);
|
|
19927
|
+
const [startCardPay, setStartCardPay] = (0,react.useState)(false);
|
|
19902
19928
|
const isCardValid = hideCardHolderName ? !isActionBtnDisabled : !(isActionBtnDisabled || !cardHolderName);
|
|
19903
19929
|
const isAmexCardSelected = (selectedCard == null ? void 0 : selectedCard.type) === constants_CARD_TYPES.AMEX;
|
|
19904
19930
|
const selectedCardCvvLength = selectedCardCVV.length;
|
|
@@ -19941,24 +19967,31 @@ function CardElement({
|
|
|
19941
19967
|
setShowCVVTooltipModal(true);
|
|
19942
19968
|
}
|
|
19943
19969
|
};
|
|
19944
|
-
const handlePaymentResponse =
|
|
19945
|
-
|
|
19970
|
+
const handlePaymentResponse = ({
|
|
19971
|
+
res,
|
|
19972
|
+
requiresOTP
|
|
19973
|
+
}) => {
|
|
19974
|
+
var _res$data, _res$data2, _res$data3;
|
|
19946
19975
|
setShouldSubmitData(false);
|
|
19976
|
+
setSendOTPLoading(false);
|
|
19947
19977
|
const cardHolderInput = document.getElementById('name');
|
|
19948
19978
|
if (cardHolderInput) {
|
|
19949
19979
|
setTimeout(() => cardHolderInput.disabled = false, 1000);
|
|
19950
19980
|
}
|
|
19951
|
-
if (
|
|
19981
|
+
if (requiresOTP) {
|
|
19982
|
+
setShowOTP(true);
|
|
19983
|
+
} else if (onAfterPaymentComplete && ((_res$data = res.data) == null ? void 0 : _res$data.is_3d_secure) !== 'true') {
|
|
19952
19984
|
onAfterPaymentComplete(res);
|
|
19953
|
-
} else if (res.status === 200 && (_res$data2 = res.data) != null && _res$data2.redirection_url) {
|
|
19954
|
-
|
|
19985
|
+
} else if (res.status === 200 && ((_res$data2 = res.data) != null && _res$data2.redirection_url || (_res$data3 = res.data) != null && _res$data3.redirect_url)) {
|
|
19986
|
+
var _res$data4, _res$data5;
|
|
19987
|
+
window.location.href = ((_res$data4 = res.data) == null ? void 0 : _res$data4.redirection_url) || ((_res$data5 = res.data) == null ? void 0 : _res$data5.redirect_url);
|
|
19955
19988
|
} else if (res.status === 400) {
|
|
19956
|
-
var _res$
|
|
19957
|
-
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$
|
|
19989
|
+
var _res$data6, _res$data7, _res$data8;
|
|
19990
|
+
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$data6 = res.data) == null ? void 0 : _res$data6.msg) === 'Retry limit reached.') {
|
|
19958
19991
|
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
19959
|
-
} else if (((_res$
|
|
19992
|
+
} else if (((_res$data7 = res.data) == null ? void 0 : _res$data7.message) === 'Session Error') {
|
|
19960
19993
|
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
19961
|
-
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$
|
|
19994
|
+
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$data8 = res.data) == null ? void 0 : _res$data8.msg) === 'Order has already paid.') {
|
|
19962
19995
|
setErrorMessage(t('ERR_MSG_ALREADY_PAID'));
|
|
19963
19996
|
} else {
|
|
19964
19997
|
setErrorMessage(t('ERR_MSG_DECLINED'));
|
|
@@ -20006,7 +20039,6 @@ function CardElement({
|
|
|
20006
20039
|
(0,react.useEffect)(() => {
|
|
20007
20040
|
if (iframe && shouldSubmitData) {
|
|
20008
20041
|
const handlePay = async () => {
|
|
20009
|
-
var _iframe$contentWindow;
|
|
20010
20042
|
if (loading) return;
|
|
20011
20043
|
const cardHolderInput = document.getElementById('name');
|
|
20012
20044
|
if (cardHolderInput) {
|
|
@@ -20014,56 +20046,46 @@ function CardElement({
|
|
|
20014
20046
|
}
|
|
20015
20047
|
setLoading(true);
|
|
20016
20048
|
if (onBeforePaymentComplete) {
|
|
20017
|
-
const result = await onBeforePaymentComplete();
|
|
20049
|
+
const result = await onBeforePaymentComplete(payment.name);
|
|
20018
20050
|
if (!result) {
|
|
20019
20051
|
setShouldSubmitData(false);
|
|
20020
20052
|
setLoading(false);
|
|
20021
20053
|
return;
|
|
20022
20054
|
}
|
|
20023
20055
|
}
|
|
20024
|
-
(
|
|
20025
|
-
|
|
20026
|
-
payload: {
|
|
20027
|
-
cardHolderName,
|
|
20028
|
-
saveCard: forceSaveCard || saveCard,
|
|
20029
|
-
tenure,
|
|
20030
|
-
shouldSubmitData
|
|
20031
|
-
}
|
|
20032
|
-
}, '*');
|
|
20056
|
+
setStartCardPay(true);
|
|
20057
|
+
onProcessingPayment(true);
|
|
20033
20058
|
setShouldSubmitData(false);
|
|
20034
20059
|
};
|
|
20035
20060
|
handlePay();
|
|
20036
20061
|
}
|
|
20037
20062
|
}, [cardHolderName, saveCard, shouldSubmitData, iframe]);
|
|
20038
20063
|
(0,react.useEffect)(() => {
|
|
20039
|
-
if (isIframeLoaded) {
|
|
20040
|
-
var _iframe$
|
|
20041
|
-
(_iframe$
|
|
20064
|
+
if (isIframeLoaded || startCardPay && isProcessingPayment) {
|
|
20065
|
+
var _iframe$contentWindow, _payment$subType, _payment$subType2;
|
|
20066
|
+
(_iframe$contentWindow = iframe.contentWindow) == null || _iframe$contentWindow.postMessage({
|
|
20042
20067
|
type: 'cardData',
|
|
20043
20068
|
payload: {
|
|
20044
|
-
paymentToken: token,
|
|
20069
|
+
paymentToken: payment.token,
|
|
20045
20070
|
subType: {
|
|
20046
20071
|
paymentToken: (_payment$subType = payment.subType) == null ? void 0 : _payment$subType.token,
|
|
20047
20072
|
type: (_payment$subType2 = payment.subType) == null ? void 0 : _payment$subType2.type
|
|
20048
20073
|
},
|
|
20049
|
-
currency: currency
|
|
20050
|
-
}
|
|
20051
|
-
}, '*');
|
|
20052
|
-
(_iframe$contentWindow3 = iframe.contentWindow) == null || _iframe$contentWindow3.postMessage({
|
|
20053
|
-
type: 'paymentInfo',
|
|
20054
|
-
payload: {
|
|
20055
|
-
amount,
|
|
20056
20074
|
currency,
|
|
20057
|
-
|
|
20058
|
-
|
|
20075
|
+
cardHolderName,
|
|
20076
|
+
saveCard: forceSaveCard || saveCard,
|
|
20077
|
+
tenure,
|
|
20078
|
+
shouldSubmitData: startCardPay && isProcessingPayment
|
|
20059
20079
|
}
|
|
20060
20080
|
}, '*');
|
|
20081
|
+
setStartCardPay(false);
|
|
20082
|
+
onProcessingPayment(false);
|
|
20061
20083
|
}
|
|
20062
|
-
}, [isIframeLoaded, payment]);
|
|
20084
|
+
}, [isIframeLoaded, payment, isProcessingPayment]);
|
|
20063
20085
|
(0,react.useEffect)(() => {
|
|
20064
20086
|
if (isIframeLoaded) {
|
|
20065
|
-
var _iframe$
|
|
20066
|
-
(_iframe$
|
|
20087
|
+
var _iframe$contentWindow2;
|
|
20088
|
+
(_iframe$contentWindow2 = iframe.contentWindow) == null || _iframe$contentWindow2.postMessage({
|
|
20067
20089
|
type: 'customStyles',
|
|
20068
20090
|
payload: {
|
|
20069
20091
|
styling: customStyle,
|
|
@@ -20075,8 +20097,8 @@ function CardElement({
|
|
|
20075
20097
|
}
|
|
20076
20098
|
}, [isIframeLoaded, iframeRef.current]);
|
|
20077
20099
|
(0,react.useEffect)(() => {
|
|
20078
|
-
var _iframe$
|
|
20079
|
-
iframe == null || (_iframe$
|
|
20100
|
+
var _iframe$contentWindow3;
|
|
20101
|
+
iframe == null || (_iframe$contentWindow3 = iframe.contentWindow) == null || _iframe$contentWindow3.postMessage({
|
|
20080
20102
|
type: 'cardHolderError',
|
|
20081
20103
|
payload: {
|
|
20082
20104
|
error: errors['name']
|
|
@@ -20084,16 +20106,22 @@ function CardElement({
|
|
|
20084
20106
|
}, '*');
|
|
20085
20107
|
}, [errors.name]);
|
|
20086
20108
|
(0,react.useEffect)(() => {
|
|
20087
|
-
|
|
20109
|
+
const isSavedCardView = (savedCards == null ? void 0 : savedCards.length) && !showCardModal;
|
|
20110
|
+
const correctErrorsCount = Object.keys(errors).length === 4;
|
|
20111
|
+
if (isSavedCardView && previousValidationRef.current !== !shouldDisablePayBtn) {
|
|
20112
|
+
onCardValidationChanged == null || onCardValidationChanged(!shouldDisablePayBtn);
|
|
20113
|
+
previousValidationRef.current = !shouldDisablePayBtn;
|
|
20114
|
+
} else if (correctErrorsCount && previousValidationRef.current !== isCardValid) {
|
|
20088
20115
|
onCardValidationChanged == null || onCardValidationChanged(isCardValid);
|
|
20116
|
+
previousValidationRef.current = isCardValid;
|
|
20089
20117
|
}
|
|
20090
|
-
}, [isCardValid]);
|
|
20118
|
+
}, [isCardValid, shouldDisablePayBtn]);
|
|
20091
20119
|
const handlePayWithoutButton = () => {
|
|
20092
20120
|
setShouldSubmitData(true);
|
|
20093
20121
|
};
|
|
20094
20122
|
const handleFocusToPrevInput = () => {
|
|
20095
|
-
var _iframe$
|
|
20096
|
-
(_iframe$
|
|
20123
|
+
var _iframe$contentWindow4;
|
|
20124
|
+
(_iframe$contentWindow4 = iframe.contentWindow) == null || _iframe$contentWindow4.postMessage({
|
|
20097
20125
|
type: 'setPrevFocus',
|
|
20098
20126
|
payload: {
|
|
20099
20127
|
shouldFocusOnCVV: true
|
|
@@ -20124,7 +20152,7 @@ function CardElement({
|
|
|
20124
20152
|
if (loading) return;
|
|
20125
20153
|
setLoading(true);
|
|
20126
20154
|
if (onBeforePaymentComplete) {
|
|
20127
|
-
const result = await onBeforePaymentComplete();
|
|
20155
|
+
const result = await onBeforePaymentComplete(payment.name);
|
|
20128
20156
|
if (!result) {
|
|
20129
20157
|
setSelectedCard(null);
|
|
20130
20158
|
setSelectedCardCVV('');
|
|
@@ -20155,12 +20183,12 @@ function CardElement({
|
|
|
20155
20183
|
window.location.href = res.data.redirection_url;
|
|
20156
20184
|
}
|
|
20157
20185
|
} else if (res.status === 400) {
|
|
20158
|
-
var _res$
|
|
20159
|
-
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$
|
|
20186
|
+
var _res$data9, _res$data10, _res$data11;
|
|
20187
|
+
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$data9 = res.data) == null ? void 0 : _res$data9.msg) === 'Retry limit reached.') {
|
|
20160
20188
|
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
20161
|
-
} else if (((_res$
|
|
20189
|
+
} else if (((_res$data10 = res.data) == null ? void 0 : _res$data10.message) === 'Session Error') {
|
|
20162
20190
|
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
20163
|
-
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$
|
|
20191
|
+
} 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.') {
|
|
20164
20192
|
setErrorMessage(t('ERR_MSG_ALREADY_PAID'));
|
|
20165
20193
|
} else {
|
|
20166
20194
|
setErrorMessage(t('ERR_MSG_DECLINED'));
|
|
@@ -20177,22 +20205,65 @@ function CardElement({
|
|
|
20177
20205
|
setErrorMessage(t('ERR_MSG_SOMETHING_WENT_WRONG'));
|
|
20178
20206
|
}
|
|
20179
20207
|
};
|
|
20208
|
+
const handleOTPSubmit = async otp => {
|
|
20209
|
+
var _iframe$contentWindow5, _payment$subType3;
|
|
20210
|
+
setSendOTPLoading(true);
|
|
20211
|
+
(_iframe$contentWindow5 = iframe.contentWindow) == null || _iframe$contentWindow5.postMessage({
|
|
20212
|
+
type: 'otpData',
|
|
20213
|
+
payload: {
|
|
20214
|
+
paymentToken: payment.token,
|
|
20215
|
+
subType: {
|
|
20216
|
+
paymentToken: (_payment$subType3 = payment.subType) == null ? void 0 : _payment$subType3.token
|
|
20217
|
+
},
|
|
20218
|
+
otp
|
|
20219
|
+
}
|
|
20220
|
+
}, '*');
|
|
20221
|
+
};
|
|
20180
20222
|
const handleShowNewCardForm = () => {
|
|
20181
20223
|
if (loading) return;
|
|
20182
20224
|
setSelectedCard(null);
|
|
20183
20225
|
setSelectedCardCVV('');
|
|
20184
20226
|
setShowCardModal(true);
|
|
20227
|
+
if (previousValidationRef.current) {
|
|
20228
|
+
onCardValidationChanged == null || onCardValidationChanged(false);
|
|
20229
|
+
previousValidationRef.current = false;
|
|
20230
|
+
}
|
|
20185
20231
|
};
|
|
20186
20232
|
const handleViewSavedCards = () => {
|
|
20187
20233
|
setShowCardModal(false);
|
|
20188
20234
|
setIsIframeLoaded(false);
|
|
20235
|
+
setCardHolderName('');
|
|
20236
|
+
if (previousValidationRef.current) {
|
|
20237
|
+
onCardValidationChanged == null || onCardValidationChanged(false);
|
|
20238
|
+
previousValidationRef.current = false;
|
|
20239
|
+
}
|
|
20240
|
+
};
|
|
20241
|
+
const handleCloseOTP = () => {
|
|
20242
|
+
setShowOTP(false);
|
|
20243
|
+
setErrorMessage('');
|
|
20189
20244
|
};
|
|
20190
20245
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
20191
20246
|
className: customStyle != null && (_customStyle$containe = customStyle.container) != null && _customStyle$containe.fontFamily ? '' : card_module['gotham'],
|
|
20192
20247
|
style: Object.assign({}, customStyle == null ? void 0 : customStyle.container, isList && {
|
|
20193
20248
|
padding: 'unset'
|
|
20194
20249
|
}),
|
|
20195
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(
|
|
20250
|
+
children: [isMobile && showOTP && /*#__PURE__*/(0,jsx_runtime.jsx)(MobileOTPModal_MobileOTPModal, {
|
|
20251
|
+
onClose: handleCloseOTP,
|
|
20252
|
+
onSubmit: handleOTPSubmit,
|
|
20253
|
+
length: 4,
|
|
20254
|
+
modalHeader: `${4}-digit code`,
|
|
20255
|
+
loading: sendOTPLoading
|
|
20256
|
+
}), !isMobile && showOTP && /*#__PURE__*/(0,jsx_runtime.jsx)(ModalView_ModalView, {
|
|
20257
|
+
showModal: showOTP,
|
|
20258
|
+
onClose: handleCloseOTP,
|
|
20259
|
+
children: /*#__PURE__*/(0,jsx_runtime.jsx)(OTPModal_OTPModal, {
|
|
20260
|
+
onClose: handleCloseOTP,
|
|
20261
|
+
onSubmit: handleOTPSubmit,
|
|
20262
|
+
length: 4,
|
|
20263
|
+
modalHeader: `${4}-digit code`,
|
|
20264
|
+
loading: sendOTPLoading
|
|
20265
|
+
})
|
|
20266
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsx)(CVVToolTipModal_CVVToolTipModal, {
|
|
20196
20267
|
onClose: () => setShowCVVTooltipModal(false),
|
|
20197
20268
|
showModal: showCVVTooltipModal
|
|
20198
20269
|
}), errorMessage && /*#__PURE__*/(0,jsx_runtime.jsx)(ErrorMessageViewTwo_ErrorMessage, {
|
|
@@ -26818,7 +26889,9 @@ function ApplePay(props) {
|
|
|
26818
26889
|
customStyle,
|
|
26819
26890
|
checkDiscount,
|
|
26820
26891
|
isPixel,
|
|
26821
|
-
isLoading
|
|
26892
|
+
isLoading,
|
|
26893
|
+
paymentName,
|
|
26894
|
+
onLayerClick
|
|
26822
26895
|
} = props;
|
|
26823
26896
|
const [loading, setLoading] = (0,react.useState)(false);
|
|
26824
26897
|
const [discount, setDiscount] = (0,react.useState)({
|
|
@@ -26865,13 +26938,6 @@ function ApplePay(props) {
|
|
|
26865
26938
|
payload.requiredShippingContactFields = ['email', 'phone', 'name'];
|
|
26866
26939
|
}
|
|
26867
26940
|
const session = new window.ApplePaySession(3, payload);
|
|
26868
|
-
if (onBeforePaymentComplete) {
|
|
26869
|
-
const result = await onBeforePaymentComplete();
|
|
26870
|
-
if (!result) {
|
|
26871
|
-
setLoading(false);
|
|
26872
|
-
return;
|
|
26873
|
-
}
|
|
26874
|
-
}
|
|
26875
26941
|
session.onvalidatemerchant = async event => {
|
|
26876
26942
|
console.log("start validation request");
|
|
26877
26943
|
console.log(`validationURL: ${event.validationURL}`);
|
|
@@ -26967,7 +27033,7 @@ function ApplePay(props) {
|
|
|
26967
27033
|
session.begin();
|
|
26968
27034
|
};
|
|
26969
27035
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
26970
|
-
className: `w-full ${discount.hasDiscount ? `flex flex-col gap-2 !h-auto ${!isPixel ? 'sm:mb-6' : ''}` : ''}`,
|
|
27036
|
+
className: `w-full ${isPixel ? 'relative' : ''} ${discount.hasDiscount ? `flex flex-col gap-2 !h-auto ${!isPixel ? 'sm:mb-6' : ''}` : ''}`,
|
|
26971
27037
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button, {
|
|
26972
27038
|
id: "apple-pay-button",
|
|
26973
27039
|
icon: apple_pay_namespaceObject,
|
|
@@ -26977,6 +27043,9 @@ function ApplePay(props) {
|
|
|
26977
27043
|
customStyle: customStyle,
|
|
26978
27044
|
disabled: loading || isLoading,
|
|
26979
27045
|
loading: loading || isLoading
|
|
27046
|
+
}), isPixel && /*#__PURE__*/(0,jsx_runtime.jsx)("button", {
|
|
27047
|
+
onClick: () => onLayerClick == null ? void 0 : onLayerClick(setLoading),
|
|
27048
|
+
className: "absolute inset-0 cursor-pointer"
|
|
26980
27049
|
}), discount.hasDiscount && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
26981
27050
|
className: "flex text-center flex-col justify-center text-green-400 text-sm font-medium leading-6 tracking-[0.01rem]",
|
|
26982
27051
|
children: discount.discountMessage
|
|
@@ -27170,7 +27239,9 @@ function GooglePayElement({
|
|
|
27170
27239
|
onBeforePaymentComplete,
|
|
27171
27240
|
onAfterPaymentComplete,
|
|
27172
27241
|
onErrorMessage,
|
|
27173
|
-
isLoading
|
|
27242
|
+
isLoading,
|
|
27243
|
+
onProcessingPayment,
|
|
27244
|
+
isProcessingPayment
|
|
27174
27245
|
}) {
|
|
27175
27246
|
var _String;
|
|
27176
27247
|
const {
|
|
@@ -27179,22 +27250,33 @@ function GooglePayElement({
|
|
|
27179
27250
|
keyPrefix: 'googlePay'
|
|
27180
27251
|
});
|
|
27181
27252
|
const [loading, setLoading] = (0,react.useState)(false);
|
|
27253
|
+
const [startGooglePay, setStartGooglePay] = (0,react.useState)(false);
|
|
27182
27254
|
const {
|
|
27183
27255
|
amount,
|
|
27184
27256
|
currency
|
|
27185
27257
|
} = payment;
|
|
27186
27258
|
const googlePay = payment;
|
|
27187
27259
|
const integrationId = googlePay == null ? void 0 : googlePay.integrationId;
|
|
27188
|
-
|
|
27189
|
-
|
|
27260
|
+
(0,react.useEffect)(() => {
|
|
27261
|
+
if (startGooglePay && isProcessingPayment) {
|
|
27262
|
+
const googlePayButton = document.getElementById('gpay-button-online-api-id');
|
|
27263
|
+
googlePayButton == null || googlePayButton.click();
|
|
27264
|
+
}
|
|
27265
|
+
}, [startGooglePay, isProcessingPayment]);
|
|
27266
|
+
const handleLayerClick = async () => {
|
|
27190
27267
|
setLoading(true);
|
|
27191
27268
|
if (onBeforePaymentComplete) {
|
|
27192
|
-
const result = await onBeforePaymentComplete();
|
|
27269
|
+
const result = await onBeforePaymentComplete(payment.name);
|
|
27193
27270
|
if (!result) {
|
|
27194
27271
|
setLoading(false);
|
|
27195
27272
|
return;
|
|
27196
27273
|
}
|
|
27197
27274
|
}
|
|
27275
|
+
setStartGooglePay(true);
|
|
27276
|
+
onProcessingPayment(true);
|
|
27277
|
+
};
|
|
27278
|
+
const handleSubmit = async (paymentToken, googlePayload) => {
|
|
27279
|
+
var _res$data;
|
|
27198
27280
|
const res = await payWithGooglePay(paymentToken, integrationId, googlePayload);
|
|
27199
27281
|
setLoading(false);
|
|
27200
27282
|
const redirectionUrl = (_res$data = res.data) == null ? void 0 : _res$data.redirection_url;
|
|
@@ -27240,17 +27322,23 @@ function GooglePayElement({
|
|
|
27240
27322
|
}
|
|
27241
27323
|
};
|
|
27242
27324
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
27243
|
-
children: [/*#__PURE__*/(0,jsx_runtime.
|
|
27244
|
-
|
|
27245
|
-
|
|
27246
|
-
|
|
27247
|
-
|
|
27248
|
-
|
|
27249
|
-
|
|
27250
|
-
|
|
27251
|
-
|
|
27252
|
-
|
|
27253
|
-
|
|
27325
|
+
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
27326
|
+
className: "relative w-full",
|
|
27327
|
+
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(GooglePay, {
|
|
27328
|
+
onSubmit: handleSubmit,
|
|
27329
|
+
paymentToken: (googlePay == null ? void 0 : googlePay.token) || '',
|
|
27330
|
+
paymentGateway: (googlePay == null ? void 0 : googlePay.gateway) || '',
|
|
27331
|
+
isLiveIntegration: googlePay == null ? void 0 : googlePay.live,
|
|
27332
|
+
merchantIdentifier: googlePay == null ? void 0 : googlePay.merchantIdentifier,
|
|
27333
|
+
amount: (_String = String(amount)) == null ? void 0 : _String.replace(/,/g, ''),
|
|
27334
|
+
currency: currency,
|
|
27335
|
+
countryCode: currency == null ? void 0 : currency.slice(0, 2),
|
|
27336
|
+
customStyle: customStyle,
|
|
27337
|
+
isLoading: isLoading
|
|
27338
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsx)("button", {
|
|
27339
|
+
onClick: handleLayerClick,
|
|
27340
|
+
className: "absolute inset-0 cursor-pointer"
|
|
27341
|
+
})]
|
|
27254
27342
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(LoadingModal, {
|
|
27255
27343
|
show: loading,
|
|
27256
27344
|
text: t('LOADING_MSG')
|
|
@@ -27286,21 +27374,43 @@ const checkDiscount = paymentToken => {
|
|
|
27286
27374
|
|
|
27287
27375
|
|
|
27288
27376
|
|
|
27377
|
+
|
|
27289
27378
|
function ApplePayElements({
|
|
27290
27379
|
payment,
|
|
27291
27380
|
customStyle,
|
|
27292
27381
|
onBeforePaymentComplete,
|
|
27293
27382
|
onAfterPaymentComplete,
|
|
27294
27383
|
onPaymentCancel,
|
|
27295
|
-
isLoading
|
|
27384
|
+
isLoading,
|
|
27385
|
+
onProcessingPayment,
|
|
27386
|
+
isProcessingPayment
|
|
27296
27387
|
}) {
|
|
27297
27388
|
var _amount$toString;
|
|
27389
|
+
const [startApplePay, setStartApplePay] = (0,react.useState)(false);
|
|
27298
27390
|
const {
|
|
27299
27391
|
amount,
|
|
27300
27392
|
currency,
|
|
27301
27393
|
merchantName
|
|
27302
27394
|
} = payment;
|
|
27303
27395
|
const applePay = payment;
|
|
27396
|
+
(0,react.useEffect)(() => {
|
|
27397
|
+
if (startApplePay && isProcessingPayment) {
|
|
27398
|
+
const applePayButton = document.getElementById('apple-pay-button');
|
|
27399
|
+
applePayButton == null || applePayButton.click();
|
|
27400
|
+
}
|
|
27401
|
+
}, [startApplePay, isProcessingPayment]);
|
|
27402
|
+
const handleLayerClick = async setLoading => {
|
|
27403
|
+
setLoading(true);
|
|
27404
|
+
if (onBeforePaymentComplete) {
|
|
27405
|
+
const result = await onBeforePaymentComplete(payment.name);
|
|
27406
|
+
if (!result) {
|
|
27407
|
+
setLoading(false);
|
|
27408
|
+
return;
|
|
27409
|
+
}
|
|
27410
|
+
}
|
|
27411
|
+
setStartApplePay(true);
|
|
27412
|
+
onProcessingPayment(true);
|
|
27413
|
+
};
|
|
27304
27414
|
const handleSubmit = (status, resData) => {
|
|
27305
27415
|
window.location.href = resData.redirection_url;
|
|
27306
27416
|
};
|
|
@@ -27320,7 +27430,9 @@ function ApplePayElements({
|
|
|
27320
27430
|
customStyle: customStyle,
|
|
27321
27431
|
checkDiscount: checkDiscount,
|
|
27322
27432
|
isPixel: true,
|
|
27323
|
-
isLoading: isLoading
|
|
27433
|
+
isLoading: isLoading,
|
|
27434
|
+
paymentName: payment.name,
|
|
27435
|
+
onLayerClick: handleLayerClick
|
|
27324
27436
|
});
|
|
27325
27437
|
}
|
|
27326
27438
|
/* harmony default export */ const Payments_ApplePay = (ApplePayElements);
|
|
@@ -27431,25 +27543,29 @@ function PaymentsList(props) {
|
|
|
27431
27543
|
const [savedCardsList, setSavedCardsList] = (0,react.useState)(savedCards);
|
|
27432
27544
|
const [errorMessage, setErrorMessage] = (0,react.useState)('');
|
|
27433
27545
|
const [isLoading, setIsLoading] = (0,react.useState)(false);
|
|
27546
|
+
const [isProcessingPayment, setIsProcessingPayment] = (0,react.useState)(false);
|
|
27434
27547
|
(0,react.useEffect)(() => {
|
|
27435
|
-
async function getData() {
|
|
27436
|
-
setIsLoading(true);
|
|
27437
|
-
const {
|
|
27438
|
-
res,
|
|
27439
|
-
paymentList,
|
|
27440
|
-
savedCards
|
|
27441
|
-
} = await fetchPayments(publicKey, clientSecret, selectedPaymentMethods);
|
|
27442
|
-
setIsLoading(false);
|
|
27443
|
-
if (res.status === 200) {
|
|
27444
|
-
setPaymentList(paymentList);
|
|
27445
|
-
setSavedCardsList(savedCards);
|
|
27446
|
-
}
|
|
27447
|
-
}
|
|
27448
27548
|
window.addEventListener('updateIntentionData', getData);
|
|
27449
27549
|
return () => {
|
|
27450
27550
|
window.removeEventListener('updateIntentionData', getData);
|
|
27451
27551
|
};
|
|
27452
27552
|
}, []);
|
|
27553
|
+
const getData = async () => {
|
|
27554
|
+
setIsLoading(true);
|
|
27555
|
+
const {
|
|
27556
|
+
res,
|
|
27557
|
+
paymentList,
|
|
27558
|
+
savedCards
|
|
27559
|
+
} = await fetchPayments(publicKey, clientSecret, selectedPaymentMethods);
|
|
27560
|
+
setIsLoading(false);
|
|
27561
|
+
if (res.status === 200) {
|
|
27562
|
+
setPaymentList(paymentList);
|
|
27563
|
+
setSavedCardsList(savedCards);
|
|
27564
|
+
}
|
|
27565
|
+
};
|
|
27566
|
+
const handleOnBeforePaymentComplete = async paymentMethod => {
|
|
27567
|
+
return await onBeforePaymentComplete(paymentMethod, getData);
|
|
27568
|
+
};
|
|
27453
27569
|
const hasOnlyXPays = () => {
|
|
27454
27570
|
const xPays = ['apple-pay', 'google-pay'];
|
|
27455
27571
|
return paymentList.every(method => xPays.includes(method.name));
|
|
@@ -27494,18 +27610,22 @@ function PaymentsList(props) {
|
|
|
27494
27610
|
}) : /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
27495
27611
|
children: [isApplePay() && /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_ApplePay, {
|
|
27496
27612
|
payment: applePaymentMethod,
|
|
27497
|
-
onBeforePaymentComplete: onBeforePaymentComplete,
|
|
27613
|
+
onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
|
|
27498
27614
|
onAfterPaymentComplete: onAfterPaymentComplete,
|
|
27499
27615
|
onPaymentCancel: onPaymentCancel,
|
|
27500
27616
|
customStyle: customStyle == null ? void 0 : customStyle.button,
|
|
27501
|
-
isLoading: isLoading
|
|
27617
|
+
isLoading: isLoading,
|
|
27618
|
+
onProcessingPayment: setIsProcessingPayment,
|
|
27619
|
+
isProcessingPayment: isProcessingPayment
|
|
27502
27620
|
}), isGooglePay() && /*#__PURE__*/(0,jsx_runtime.jsx)(GooglePayElement, {
|
|
27503
27621
|
payment: googlePaymentMethod,
|
|
27504
27622
|
customStyle: customStyle == null ? void 0 : customStyle.button,
|
|
27505
|
-
onBeforePaymentComplete: onBeforePaymentComplete,
|
|
27623
|
+
onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
|
|
27506
27624
|
onAfterPaymentComplete: onAfterPaymentComplete,
|
|
27507
27625
|
onErrorMessage: setErrorMessage,
|
|
27508
|
-
isLoading: isLoading
|
|
27626
|
+
isLoading: isLoading,
|
|
27627
|
+
onProcessingPayment: setIsProcessingPayment,
|
|
27628
|
+
isProcessingPayment: isProcessingPayment
|
|
27509
27629
|
})]
|
|
27510
27630
|
})
|
|
27511
27631
|
}), paymentList.length === 0 ? /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
@@ -27538,12 +27658,14 @@ function PaymentsList(props) {
|
|
|
27538
27658
|
savedCards: savedCardsList,
|
|
27539
27659
|
forceSaveCard,
|
|
27540
27660
|
showSaveCard,
|
|
27541
|
-
onBeforePaymentComplete,
|
|
27661
|
+
onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
|
|
27542
27662
|
onAfterPaymentComplete,
|
|
27543
27663
|
onCardValidationChanged,
|
|
27544
27664
|
showPaymobLogo,
|
|
27545
27665
|
hideCardHolderName,
|
|
27546
27666
|
isLoading,
|
|
27667
|
+
onProcessingPayment: setIsProcessingPayment,
|
|
27668
|
+
isProcessingPayment,
|
|
27547
27669
|
isList: true
|
|
27548
27670
|
})
|
|
27549
27671
|
})]
|
|
@@ -31437,9 +31559,9 @@ class Pixel {
|
|
|
31437
31559
|
this.render();
|
|
31438
31560
|
}
|
|
31439
31561
|
}
|
|
31440
|
-
async handleBeforePaymentComplete() {
|
|
31562
|
+
async handleBeforePaymentComplete(paymentMethod, updateIntentionData) {
|
|
31441
31563
|
if (this._options.beforePaymentComplete) {
|
|
31442
|
-
const result = await this._options.beforePaymentComplete();
|
|
31564
|
+
const result = await this._options.beforePaymentComplete(paymentMethod, updateIntentionData);
|
|
31443
31565
|
if (result === false) return false;
|
|
31444
31566
|
return true;
|
|
31445
31567
|
}
|
package/package.json
CHANGED