paymob-pixel-alpha 1.1.47 → 1.1.49
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.css +0 -1
- package/main.js +63 -1341
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -81178,7 +81178,6 @@ function Knet(props) {
|
|
|
81178
81178
|
const formattedAmount = formatNumber(Number(amount), currency);
|
|
81179
81179
|
const formattedEquivalentAmount = formatNumber(Number(EquivalentAmount || amount), KnetCurrency || currency);
|
|
81180
81180
|
const displayAmount = formattedEquivalentAmount || formattedAmount;
|
|
81181
|
-
const displayCurrenc = KnetCurrency || currency;
|
|
81182
81181
|
const {
|
|
81183
81182
|
displayCurrency,
|
|
81184
81183
|
currencyFontFamily
|
|
@@ -81225,7 +81224,7 @@ function Knet(props) {
|
|
|
81225
81224
|
})
|
|
81226
81225
|
}), !disablePay && /*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button, {
|
|
81227
81226
|
id: "pay-button",
|
|
81228
|
-
label: `${(_customStyle$knetText7 = customStyle == null || (_customStyle$knetText8 = customStyle.knetText) == null ? void 0 : _customStyle$knetText8.PAY_KNET_BUTTON) != null ? _customStyle$knetText7 : t('PAY')} ${
|
|
81227
|
+
label: `${(_customStyle$knetText7 = customStyle == null || (_customStyle$knetText8 = customStyle.knetText) == null ? void 0 : _customStyle$knetText8.PAY_KNET_BUTTON) != null ? _customStyle$knetText7 : t('PAY')} ${displayCurrency} ${displayAmount}`,
|
|
81229
81228
|
fullWidth: true,
|
|
81230
81229
|
color: 'primary',
|
|
81231
81230
|
customStyle: customStyle == null ? void 0 : customStyle.button,
|
|
@@ -81267,9 +81266,7 @@ function KnetElement({
|
|
|
81267
81266
|
payment,
|
|
81268
81267
|
customStyle,
|
|
81269
81268
|
paymentMethodsCount,
|
|
81270
|
-
disablePay
|
|
81271
|
-
onPaymentStart,
|
|
81272
|
-
onPaymentEnd
|
|
81269
|
+
disablePay
|
|
81273
81270
|
}) {
|
|
81274
81271
|
const [loading, setLoading] = (0,react.useState)(false);
|
|
81275
81272
|
const {
|
|
@@ -81287,7 +81284,6 @@ function KnetElement({
|
|
|
81287
81284
|
const handlePay = async () => {
|
|
81288
81285
|
try {
|
|
81289
81286
|
var _res$data, _res$data2;
|
|
81290
|
-
onPaymentStart == null || onPaymentStart(payment.type);
|
|
81291
81287
|
setLoading(true);
|
|
81292
81288
|
const res = await payWithKnet(payment == null ? void 0 : payment.token, String(amountInCents));
|
|
81293
81289
|
const redirectionUrl = ((_res$data = res.data) == null ? void 0 : _res$data.redirection_url) || ((_res$data2 = res.data) == null ? void 0 : _res$data2.redirect_url);
|
|
@@ -81296,7 +81292,6 @@ function KnetElement({
|
|
|
81296
81292
|
}
|
|
81297
81293
|
} catch (error) {
|
|
81298
81294
|
console.error('Payment error:', error);
|
|
81299
|
-
onPaymentEnd == null || onPaymentEnd();
|
|
81300
81295
|
} finally {
|
|
81301
81296
|
setLoading(false);
|
|
81302
81297
|
}
|
|
@@ -81596,7 +81591,7 @@ const knetApplePayPayment = async (applePaytoken, paymentToken, clientData) => {
|
|
|
81596
81591
|
};
|
|
81597
81592
|
;// ./src/components/Payments/KnetApplePay/index.tsx
|
|
81598
81593
|
|
|
81599
|
-
const KnetApplePay_excluded = ["payment", "customStyle", "onBeforePaymentComplete", "onAfterPaymentComplete", "onPaymentCancel", "isLoading", "country", "paymentMethodsCount"
|
|
81594
|
+
const KnetApplePay_excluded = ["payment", "customStyle", "onBeforePaymentComplete", "onAfterPaymentComplete", "onPaymentCancel", "isLoading", "country", "paymentMethodsCount"];
|
|
81600
81595
|
|
|
81601
81596
|
|
|
81602
81597
|
|
|
@@ -81611,9 +81606,7 @@ function KnetApplePayElement(_ref) {
|
|
|
81611
81606
|
onPaymentCancel,
|
|
81612
81607
|
isLoading,
|
|
81613
81608
|
country,
|
|
81614
|
-
paymentMethodsCount
|
|
81615
|
-
onPaymentStart,
|
|
81616
|
-
onPaymentEnd
|
|
81609
|
+
paymentMethodsCount
|
|
81617
81610
|
} = _ref,
|
|
81618
81611
|
restProps = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(_ref, KnetApplePay_excluded);
|
|
81619
81612
|
const {
|
|
@@ -81644,15 +81637,9 @@ function KnetApplePayElement(_ref) {
|
|
|
81644
81637
|
validatemerchant: validatemerchant,
|
|
81645
81638
|
knetApplePayPayment: knetApplePayPayment,
|
|
81646
81639
|
onSubmit: handleSubmit,
|
|
81647
|
-
onBeforePaymentComplete:
|
|
81648
|
-
onPaymentStart == null || onPaymentStart(payment.type);
|
|
81649
|
-
return onBeforePaymentComplete == null ? void 0 : onBeforePaymentComplete(data);
|
|
81650
|
-
},
|
|
81640
|
+
onBeforePaymentComplete: onBeforePaymentComplete,
|
|
81651
81641
|
onAfterPaymentComplete: onAfterPaymentComplete,
|
|
81652
|
-
onPaymentCancel:
|
|
81653
|
-
onPaymentEnd == null || onPaymentEnd();
|
|
81654
|
-
onPaymentCancel == null || onPaymentCancel();
|
|
81655
|
-
},
|
|
81642
|
+
onPaymentCancel: onPaymentCancel,
|
|
81656
81643
|
customStyle: customStyle,
|
|
81657
81644
|
isLoading: isLoading,
|
|
81658
81645
|
paymentName: payment.name,
|
|
@@ -82410,7 +82397,7 @@ const renderSelectedPaymentMethod = (selectedPaymentMethod, restProps = {}) => {
|
|
|
82410
82397
|
;// ./src/constants/paymentNames.ts
|
|
82411
82398
|
const PAYMENT_NAMES = {
|
|
82412
82399
|
"CARD": 'Card',
|
|
82413
|
-
"KNET": 'KNET ',
|
|
82400
|
+
"KNET": 'KNET Card',
|
|
82414
82401
|
"KNET_APPLE_PAY": 'KNET Apple Pay'
|
|
82415
82402
|
};
|
|
82416
82403
|
;// ./src/utils/classNames.ts
|
|
@@ -82424,8 +82411,7 @@ const TabElement = ({
|
|
|
82424
82411
|
selectedPaymentMethodType,
|
|
82425
82412
|
setSelectedPayment,
|
|
82426
82413
|
icon,
|
|
82427
|
-
customStyle
|
|
82428
|
-
disabled
|
|
82414
|
+
customStyle
|
|
82429
82415
|
}) => {
|
|
82430
82416
|
var _customStyle$button;
|
|
82431
82417
|
const {
|
|
@@ -82443,11 +82429,8 @@ const TabElement = ({
|
|
|
82443
82429
|
};
|
|
82444
82430
|
const isSelected = selectedPaymentMethodType === type;
|
|
82445
82431
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
82446
|
-
onClick: () =>
|
|
82447
|
-
|
|
82448
|
-
setSelectedPayment(paymentMethod);
|
|
82449
|
-
},
|
|
82450
|
-
className: classNames('text-gray-500 font-semibold text-sm flex flex-col items-start gap-2 border p-3 relative rounded-xl transition-all duration-300 cursor-pointer text-start flex-1', 'w-full sm:w-1/3 md:w-1/4 lg:w-1/6', isSelected ? 'text-blue-500 border-blue-500' : 'border-gray-200', disabled && 'opacity-50 cursor-not-allowed'),
|
|
82432
|
+
onClick: () => setSelectedPayment(paymentMethod),
|
|
82433
|
+
className: classNames('text-gray-500 font-semibold text-sm flex flex-col items-start gap-2 border p-3 relative rounded-xl transition-all duration-300 cursor-pointer text-start flex-1', 'w-full sm:w-1/3 md:w-1/4 lg:w-1/6', isSelected ? 'text-blue-500 border-blue-500' : 'border-gray-200'),
|
|
82451
82434
|
style: customStyle != null && (_customStyle$button = customStyle.button) != null && _customStyle$button.borderColor && isSelected ? {
|
|
82452
82435
|
borderColor: customStyle.button.borderColor,
|
|
82453
82436
|
borderRadius: customStyle.tabs.borderRadius
|
|
@@ -82467,7 +82450,7 @@ const TabElement = ({
|
|
|
82467
82450
|
};
|
|
82468
82451
|
;// ./src/components/Payments/List/TabView.tsx
|
|
82469
82452
|
|
|
82470
|
-
const TabView_excluded = ["paymentMethods"
|
|
82453
|
+
const TabView_excluded = ["paymentMethods"];
|
|
82471
82454
|
|
|
82472
82455
|
|
|
82473
82456
|
|
|
@@ -82476,8 +82459,7 @@ const TabView_excluded = ["paymentMethods", "isPaymentInProgress"];
|
|
|
82476
82459
|
function TabView(props) {
|
|
82477
82460
|
var _restProps$customStyl;
|
|
82478
82461
|
const {
|
|
82479
|
-
paymentMethods
|
|
82480
|
-
isPaymentInProgress
|
|
82462
|
+
paymentMethods
|
|
82481
82463
|
} = props,
|
|
82482
82464
|
restProps = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(props, TabView_excluded);
|
|
82483
82465
|
const firstPaymentMethod = (paymentMethods == null ? void 0 : paymentMethods[0]) || null;
|
|
@@ -82502,23 +82484,19 @@ function TabView(props) {
|
|
|
82502
82484
|
paymentMethod: paymentMethod,
|
|
82503
82485
|
icon: getPaymentLogo_getPaymentLogo(paymentMethod.type),
|
|
82504
82486
|
setSelectedPayment: selected => {
|
|
82505
|
-
if (isPaymentInProgress) return;
|
|
82506
82487
|
setSelectedPaymentMethod(Object.assign({}, selected, {
|
|
82507
82488
|
userSelected: true
|
|
82508
82489
|
}));
|
|
82509
82490
|
},
|
|
82510
|
-
customStyle: restProps.customStyle
|
|
82511
|
-
disabled: isPaymentInProgress && isPaymentInProgress !== paymentMethod.type
|
|
82491
|
+
customStyle: restProps.customStyle
|
|
82512
82492
|
}, paymentMethod.type))
|
|
82513
|
-
}), renderSelectedPaymentMethod(selectedPaymentMethod,
|
|
82514
|
-
isPaymentInProgress
|
|
82515
|
-
}))]
|
|
82493
|
+
}), renderSelectedPaymentMethod(selectedPaymentMethod, restProps)]
|
|
82516
82494
|
});
|
|
82517
82495
|
}
|
|
82518
82496
|
/* harmony default export */ const List_TabView = (TabView);
|
|
82519
82497
|
;// ./src/components/Payments/List/ListView.tsx
|
|
82520
82498
|
|
|
82521
|
-
const ListView_excluded = ["paymentMethods", "customStyle"
|
|
82499
|
+
const ListView_excluded = ["paymentMethods", "customStyle"];
|
|
82522
82500
|
|
|
82523
82501
|
|
|
82524
82502
|
|
|
@@ -82528,8 +82506,7 @@ const ListView = _ref => {
|
|
|
82528
82506
|
var _customStyle$paymentM2;
|
|
82529
82507
|
let {
|
|
82530
82508
|
paymentMethods,
|
|
82531
|
-
customStyle
|
|
82532
|
-
isPaymentInProgress
|
|
82509
|
+
customStyle
|
|
82533
82510
|
} = _ref,
|
|
82534
82511
|
restProps = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(_ref, ListView_excluded);
|
|
82535
82512
|
const [selectedPaymentMethod, setSelectedPaymentMethod] = (0,react.useState)(null);
|
|
@@ -82550,7 +82527,6 @@ const ListView = _ref => {
|
|
|
82550
82527
|
return PAYMENT_NAMES[normalized];
|
|
82551
82528
|
};
|
|
82552
82529
|
const toggleAccordion = (index, payment) => {
|
|
82553
|
-
if (isPaymentInProgress) return;
|
|
82554
82530
|
setOpenIndex(prevIndex => prevIndex === index ? null : index);
|
|
82555
82531
|
setSelectedPaymentMethod(Object.assign({}, payment, {
|
|
82556
82532
|
userSelected: true
|
|
@@ -82568,133 +82544,16 @@ const ListView = _ref => {
|
|
|
82568
82544
|
type: paymentMethod.type,
|
|
82569
82545
|
isOpen: openIndex === index,
|
|
82570
82546
|
toggleAccordion: () => toggleAccordion(index, paymentMethod),
|
|
82571
|
-
disabled: isPaymentInProgress && isPaymentInProgress !== paymentMethod.type,
|
|
82572
82547
|
content: openIndex === index ? renderSelectedPaymentMethod(paymentMethod, Object.assign({}, restProps, {
|
|
82573
|
-
customStyle
|
|
82574
|
-
isPaymentInProgress
|
|
82548
|
+
customStyle
|
|
82575
82549
|
})) : null
|
|
82576
82550
|
}, paymentMethod.id))]
|
|
82577
82551
|
});
|
|
82578
82552
|
};
|
|
82579
82553
|
/* harmony default export */ const List_ListView = ((/* unused pure expression or super */ null && (ListView)));
|
|
82580
|
-
;//
|
|
82581
|
-
// This file can be replaced during build by using the `fileReplacements` array.
|
|
82582
|
-
// When building for production, this file is replaced with `environment.prod.ts`.
|
|
82554
|
+
;// ./src/components/Payments/List/index.tsx
|
|
82583
82555
|
|
|
82584
|
-
const environment_environment = {
|
|
82585
|
-
production: false,
|
|
82586
|
-
API_URL_EG: 'https://accept-alpha.paymob.com',
|
|
82587
|
-
API_URL_AE: 'https://international-staging.paymob.com',
|
|
82588
|
-
API_URL_SA: 'https://international-staging.paymob.com',
|
|
82589
|
-
API_URL_PK: 'https://international-staging.paymob.com',
|
|
82590
|
-
API_URL_OM: 'https://international-staging.paymob.com',
|
|
82591
|
-
API_URL_DEFAULT: 'https://accept-alpha.paymob.com',
|
|
82592
|
-
IFRAME_PATH: 'unifiedcheckout/iframe-card',
|
|
82593
|
-
PIXEL_CSS_LINKS: ['https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/styles.css', 'https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/main.css', 'https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/Inter.woff2', 'https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/Inter.woff', 'https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/Inter.ttf']
|
|
82594
|
-
};
|
|
82595
|
-
;// ../../apps/elements/src/components/Payments/Card/card.module.scss
|
|
82596
|
-
// extracted by mini-css-extract-plugin
|
|
82597
|
-
/* harmony default export */ const Card_card_module = ({"action-btn":"card_action-btn__crD1m","gotham":"card_gotham__H601r","iframe":"card_iframe__eUHY1"});
|
|
82598
|
-
;// ../../apps/elements/src/services/cardService.ts
|
|
82599
82556
|
|
|
82600
|
-
const cardService_payWithSavedCard = payload => {
|
|
82601
|
-
return lib_axios.post(`/api/acceptance/payments/pay`, {
|
|
82602
|
-
source: {
|
|
82603
|
-
identifier: payload.identifier,
|
|
82604
|
-
subtype: 'TOKEN',
|
|
82605
|
-
cvn: payload.cvv,
|
|
82606
|
-
unified_checkout: payload.isElements ? 'False' : 'True'
|
|
82607
|
-
},
|
|
82608
|
-
payment_token: payload.token,
|
|
82609
|
-
unified_checkout: payload.isElements ? 'False' : 'True',
|
|
82610
|
-
api_source: 'PIXEL'
|
|
82611
|
-
}).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
82612
|
-
};
|
|
82613
|
-
const cardService_checkDiscount = (payment_token, integration_id, identifier, isSavedCard) => {
|
|
82614
|
-
return lib_axios.post(`/api/acceptance/transaction_discount/use-discount`, Object.assign({
|
|
82615
|
-
payment_token,
|
|
82616
|
-
integration_id,
|
|
82617
|
-
subtype: 'CARD'
|
|
82618
|
-
}, !isSavedCard && {
|
|
82619
|
-
identifier: identifier.replace(/\s/g, '')
|
|
82620
|
-
}, isSavedCard && {
|
|
82621
|
-
saved_card_token: identifier
|
|
82622
|
-
})).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
82623
|
-
};
|
|
82624
|
-
const cardService_lookupFees = (payment_token, identifier) => {
|
|
82625
|
-
return lib_axios.post(`/api/acceptance/caf-fee-lookup/lookup-fees`, {
|
|
82626
|
-
payment_token,
|
|
82627
|
-
card_token: identifier
|
|
82628
|
-
}).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
82629
|
-
};
|
|
82630
|
-
const cardService_sendOTP = payload => {
|
|
82631
|
-
return lib_axios.post(`/api/acceptance/omannet_callback/otp_verify`, {
|
|
82632
|
-
payment_id: payload.paymentId,
|
|
82633
|
-
otp: payload.otp,
|
|
82634
|
-
payment_token: payload.token
|
|
82635
|
-
}).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
82636
|
-
};
|
|
82637
|
-
;// ../../apps/elements/src/utils/getErrorMsg.ts
|
|
82638
|
-
const utils_getErrorMsg_isString = data => typeof data === 'string';
|
|
82639
|
-
const getErrorMsg_DECLINED_MESSAGE = 'Payment is declined';
|
|
82640
|
-
const getErrorMsg_getErrorMsg = err => {
|
|
82641
|
-
var _data$data, _data$data2;
|
|
82642
|
-
const data = err == null ? void 0 : err.data;
|
|
82643
|
-
if (!err) {
|
|
82644
|
-
return getErrorMsg_DECLINED_MESSAGE;
|
|
82645
|
-
}
|
|
82646
|
-
if (utils_getErrorMsg_isString(err)) {
|
|
82647
|
-
return err;
|
|
82648
|
-
}
|
|
82649
|
-
if (data != null && data['data.message'] && utils_getErrorMsg_isString(data['data.message'])) {
|
|
82650
|
-
return data['data.message'];
|
|
82651
|
-
}
|
|
82652
|
-
if (data != null && data.message && utils_getErrorMsg_isString(data.message)) {
|
|
82653
|
-
return data.message;
|
|
82654
|
-
}
|
|
82655
|
-
if (data != null && data.msg && utils_getErrorMsg_isString(data.msg)) {
|
|
82656
|
-
return data.msg;
|
|
82657
|
-
}
|
|
82658
|
-
if (data != null && data.detail && utils_getErrorMsg_isString(data.detail)) {
|
|
82659
|
-
return data.detail;
|
|
82660
|
-
}
|
|
82661
|
-
if (data != null && data.error && utils_getErrorMsg_isString(data.error)) {
|
|
82662
|
-
return data.error;
|
|
82663
|
-
}
|
|
82664
|
-
if (data != null && data.error_message && utils_getErrorMsg_isString(data.error_message)) {
|
|
82665
|
-
return data.error_message;
|
|
82666
|
-
}
|
|
82667
|
-
if (data != null && (_data$data = data.data) != null && _data$data.message && utils_getErrorMsg_isString((_data$data2 = data.data) == null ? void 0 : _data$data2.message)) {
|
|
82668
|
-
var _data$data3;
|
|
82669
|
-
return (_data$data3 = data.data) == null ? void 0 : _data$data3.message;
|
|
82670
|
-
}
|
|
82671
|
-
if (Array.isArray(data) && utils_getErrorMsg_isString(data[0])) {
|
|
82672
|
-
return data[0];
|
|
82673
|
-
}
|
|
82674
|
-
return getErrorMsg_DECLINED_MESSAGE;
|
|
82675
|
-
};
|
|
82676
|
-
;// ../../apps/elements/src/constants/index.ts
|
|
82677
|
-
const constants_INTEGRATION_TYPE = {
|
|
82678
|
-
DIRECT_PAYMENT: 'directPayment',
|
|
82679
|
-
TOKENIZATION: 'tokenization'
|
|
82680
|
-
};
|
|
82681
|
-
;// ../../apps/elements/src/utils/getFieldErrorMessage.ts
|
|
82682
|
-
const getFieldErrorMessage_isRequiredError = error => error.includes('required');
|
|
82683
|
-
function getFieldErrorMessage_getFieldErrorMessage({
|
|
82684
|
-
nativeError,
|
|
82685
|
-
customError
|
|
82686
|
-
}) {
|
|
82687
|
-
if (!customError) return nativeError;
|
|
82688
|
-
if (typeof customError === 'string') return customError;
|
|
82689
|
-
if (getFieldErrorMessage_isRequiredError(nativeError) && customError.required) {
|
|
82690
|
-
return customError.required;
|
|
82691
|
-
}
|
|
82692
|
-
if (!getFieldErrorMessage_isRequiredError(nativeError) && customError.invalid) {
|
|
82693
|
-
return customError.invalid;
|
|
82694
|
-
}
|
|
82695
|
-
return nativeError;
|
|
82696
|
-
}
|
|
82697
|
-
;// ../../apps/elements/src/components/Payments/Card/index.tsx
|
|
82698
82557
|
|
|
82699
82558
|
|
|
82700
82559
|
|
|
@@ -82702,1180 +82561,58 @@ function getFieldErrorMessage_getFieldErrorMessage({
|
|
|
82702
82561
|
|
|
82703
82562
|
|
|
82704
82563
|
|
|
82705
|
-
// import { DeleteCard } from '@unified-checkout/card';
|
|
82706
82564
|
|
|
82707
82565
|
|
|
82708
82566
|
|
|
82709
82567
|
|
|
82710
82568
|
|
|
82711
|
-
|
|
82712
|
-
|
|
82713
|
-
|
|
82714
|
-
tenure,
|
|
82715
|
-
baseUrl,
|
|
82716
|
-
savedCards,
|
|
82717
|
-
disablePay,
|
|
82718
|
-
forceSaveCard,
|
|
82719
|
-
showSaveCard,
|
|
82720
|
-
isList,
|
|
82721
|
-
onBeforePaymentComplete,
|
|
82722
|
-
onAfterPaymentComplete,
|
|
82723
|
-
onCardValidationChanged,
|
|
82724
|
-
showPaymobLogo,
|
|
82725
|
-
hideCardHolderName,
|
|
82726
|
-
isLoading,
|
|
82727
|
-
country,
|
|
82728
|
-
integrationType,
|
|
82729
|
-
publicKey,
|
|
82730
|
-
discounts,
|
|
82731
|
-
onPaymentCancel
|
|
82732
|
-
}, ref) => {
|
|
82733
|
-
var _customStyle$discount, _customStyle$containe, _customStyle$containe2, _customStyle$button, _customStyle$containe3, _customStyle$labelTex, _customStyle$buttonTe, _customStyle$placehol, _customStyle$discount2, _customStyle$discount3, _customStyle$errorTex, _customStyle$errorTex2, _customStyle$errorTex3, _customStyle$errorTex4, _customStyle$hintText, _customStyle$labelTex2, _customStyle$buttonTe2, _customStyle$labelTex3, _customStyle$buttonTe3, _customStyle$buttonTe4;
|
|
82569
|
+
|
|
82570
|
+
const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
82571
|
+
var _customStyle$containe;
|
|
82734
82572
|
const {
|
|
82735
|
-
|
|
82736
|
-
|
|
82737
|
-
|
|
82738
|
-
|
|
82739
|
-
|
|
82573
|
+
payments,
|
|
82574
|
+
customStyle,
|
|
82575
|
+
baseUrl,
|
|
82576
|
+
savedCards,
|
|
82577
|
+
forceSaveCard,
|
|
82578
|
+
showSaveCard,
|
|
82579
|
+
disablePay,
|
|
82580
|
+
onBeforePaymentComplete,
|
|
82581
|
+
onAfterPaymentComplete,
|
|
82582
|
+
onPaymentCancel,
|
|
82583
|
+
onCardValidationChanged,
|
|
82584
|
+
showPaymobLogo,
|
|
82585
|
+
hideCardHolderName,
|
|
82586
|
+
publicKey,
|
|
82587
|
+
clientSecret,
|
|
82588
|
+
selectedPaymentMethods,
|
|
82589
|
+
integrationType,
|
|
82590
|
+
discounts,
|
|
82591
|
+
viewMode
|
|
82592
|
+
} = props;
|
|
82740
82593
|
const {
|
|
82741
82594
|
t
|
|
82742
|
-
} = useTranslation_useTranslation('card');
|
|
82743
|
-
const {
|
|
82744
|
-
t: tPaymentLayout
|
|
82745
82595
|
} = useTranslation_useTranslation('flash', {
|
|
82746
|
-
keyPrefix: '
|
|
82596
|
+
keyPrefix: 'paymentsList'
|
|
82747
82597
|
});
|
|
82748
|
-
const
|
|
82749
|
-
const [
|
|
82750
|
-
const [cardHolderName, setCardHolderName] = (0,react.useState)('');
|
|
82751
|
-
const [isActionBtnDisabled, setIsActionBtnDisabled] = (0,react.useState)(false);
|
|
82752
|
-
const [shouldSubmitData, setShouldSubmitData] = (0,react.useState)(false);
|
|
82753
|
-
const [saveCard, setSaveCard] = (0,react.useState)(false);
|
|
82754
|
-
const [height, setHeight] = (0,react.useState)(80);
|
|
82598
|
+
const [paymentList, setPaymentList] = (0,react.useState)(payments);
|
|
82599
|
+
const [savedCardsList, setSavedCardsList] = (0,react.useState)(savedCards);
|
|
82755
82600
|
const [errorMessage, setErrorMessage] = (0,react.useState)('');
|
|
82756
|
-
const
|
|
82757
|
-
const
|
|
82758
|
-
const
|
|
82759
|
-
|
|
82760
|
-
|
|
82761
|
-
|
|
82762
|
-
|
|
82763
|
-
|
|
82764
|
-
|
|
82765
|
-
|
|
82766
|
-
|
|
82767
|
-
|
|
82768
|
-
|
|
82769
|
-
|
|
82770
|
-
|
|
82771
|
-
const [isOmanNetCard, setIsOmanNetCard] = (0,react.useState)(false);
|
|
82772
|
-
const tokenizationResolve = (0,react.useRef)(null);
|
|
82773
|
-
const isCardValid = hideCardHolderName ? !isActionBtnDisabled : !(isActionBtnDisabled || !cardHolderName);
|
|
82774
|
-
const isAmexCardSelected = (selectedCard == null ? void 0 : selectedCard.type) === src_constants_CARD_TYPES.AMEX;
|
|
82775
|
-
const selectedCardCvvLength = selectedCardCVV.length;
|
|
82776
|
-
const selectedCardId = selectedCard == null ? void 0 : selectedCard.id;
|
|
82777
|
-
const [discountAppliedMessage, setDiscountAppliedMessage] = (0,react.useState)(null);
|
|
82778
|
-
const [discountErrorMessage, setDiscountErrorMessage] = (0,react.useState)('');
|
|
82779
|
-
const [totalAmount, setTotalAmount] = (0,react.useState)('');
|
|
82780
|
-
const {
|
|
82781
|
-
displayCurrency,
|
|
82782
|
-
currencyFontFamily
|
|
82783
|
-
} = formatCurrencyForDisplay_formatCurrencyForDisplay(currency);
|
|
82784
|
-
const [showFeesDetails, setShowFeesDetails] = (0,react.useState)(false);
|
|
82785
|
-
const [discountedAmount, setDiscountedAmount] = (0,react.useState)('');
|
|
82786
|
-
const [feesAmount, setFeesAmount] = (0,react.useState)((payment == null ? void 0 : payment.feesAmount) || '');
|
|
82787
|
-
const [updatedPaymentToken, setUpdatedPaymentToken] = (0,react.useState)('');
|
|
82788
|
-
const showCvvInput = paymentMethodType === constants_PAYMENT_METHODS_TYPES.MOTO && useCvv || paymentMethodType === constants_PAYMENT_METHODS_TYPES.ONLINE;
|
|
82789
|
-
const shouldDisablePayBtn = showCvvInput ? loading || (isAmexCardSelected ? selectedCardCvvLength !== src_constants_AMEX_CVV_LENGTH : selectedCardCvvLength !== constants_CVV_LENGTH) : !selectedCardId;
|
|
82790
|
-
(0,react.useEffect)(() => {
|
|
82791
|
-
const handleDataFromIframe = event => {
|
|
82792
|
-
var _iframeRef$current, _event$data, _event$data2, _event$data3, _event$data4, _event$data5, _event$data6;
|
|
82793
|
-
if (!event.data) return;
|
|
82794
|
-
if (!event.data.type) return;
|
|
82795
|
-
const isFromCVVIframe = Object.values(iframeCVVRefs.current).some(ref => (ref == null || ref.getContentWindow == null ? void 0 : ref.getContentWindow()) === event.source);
|
|
82796
|
-
if (!isFromCVVIframe && event.source !== ((_iframeRef$current = iframeRef.current) == null ? void 0 : _iframeRef$current.contentWindow)) {
|
|
82797
|
-
return;
|
|
82798
|
-
}
|
|
82799
|
-
if (event.data.shouldFocusOnCardName) {
|
|
82800
|
-
var _iframeRef$current2;
|
|
82801
|
-
const cardNameField = (_iframeRef$current2 = iframeRef.current) == null || (_iframeRef$current2 = _iframeRef$current2.nextElementSibling) == null ? void 0 : _iframeRef$current2.querySelector(`input[name=name]`);
|
|
82802
|
-
if (cardNameField !== null) {
|
|
82803
|
-
cardNameField == null || cardNameField.focus();
|
|
82804
|
-
}
|
|
82805
|
-
}
|
|
82806
|
-
if (event.data.iframeCardHight) {
|
|
82807
|
-
setHeight(event.data.iframeCardHight);
|
|
82808
|
-
}
|
|
82809
|
-
if (event.data.selectedCardCVV) {
|
|
82810
|
-
setSelectedCardCVV(event.data.selectedCardCVV);
|
|
82811
|
-
}
|
|
82812
|
-
if (event.data.showCardModal !== undefined) {
|
|
82813
|
-
setShowCardModal(event.data.showCardModal);
|
|
82814
|
-
}
|
|
82815
|
-
if (event.data.errors) {
|
|
82816
|
-
setErrors(event.data.errors);
|
|
82817
|
-
}
|
|
82818
|
-
if (event.data.shouldDisableActionBtn !== undefined) {
|
|
82819
|
-
setIsActionBtnDisabled(event.data.shouldDisableActionBtn);
|
|
82820
|
-
}
|
|
82821
|
-
if (event.data.loading !== undefined) {
|
|
82822
|
-
setLoading(event.data.loading);
|
|
82823
|
-
}
|
|
82824
|
-
if ((event == null || (_event$data = event.data) == null ? void 0 : _event$data.type) === 'paymentResponse') {
|
|
82825
|
-
handlePaymentResponse(event.data.response);
|
|
82826
|
-
}
|
|
82827
|
-
if ((event == null || (_event$data2 = event.data) == null ? void 0 : _event$data2.type) === 'openCVVToolTipModal') {
|
|
82828
|
-
setShowCVVTooltipModal(true);
|
|
82829
|
-
}
|
|
82830
|
-
if ((event == null || (_event$data3 = event.data) == null ? void 0 : _event$data3.type) === 'tokenizationResponse' && tokenizationResolve.current) {
|
|
82831
|
-
tokenizationResolve.current(event.data.response.res);
|
|
82832
|
-
tokenizationResolve.current = null;
|
|
82833
|
-
}
|
|
82834
|
-
if ((event == null || (_event$data4 = event.data) == null ? void 0 : _event$data4.type) === 'discountResponse') {
|
|
82835
|
-
var _event$data$response;
|
|
82836
|
-
handleDiscount((_event$data$response = event.data.response) == null ? void 0 : _event$data$response.res);
|
|
82837
|
-
}
|
|
82838
|
-
if ((event == null || (_event$data5 = event.data) == null ? void 0 : _event$data5.type) === 'isIframeLoaded') {
|
|
82839
|
-
setIsIframeLoaded(true);
|
|
82840
|
-
}
|
|
82841
|
-
if ((event == null || (_event$data6 = event.data) == null ? void 0 : _event$data6.type) === 'feesResponse') {
|
|
82842
|
-
var _event$data$response2;
|
|
82843
|
-
handleFees((_event$data$response2 = event.data.response) == null ? void 0 : _event$data$response2.res);
|
|
82844
|
-
}
|
|
82845
|
-
};
|
|
82846
|
-
const handlePaymentResponse = ({
|
|
82847
|
-
res,
|
|
82848
|
-
requiresOTP,
|
|
82849
|
-
isOmanNetCard
|
|
82850
|
-
}) => {
|
|
82851
|
-
var _iframeRef$current3, _res$data, _res$data2, _res$data3;
|
|
82852
|
-
setShouldSubmitData(false);
|
|
82853
|
-
setSendOTPLoading(false);
|
|
82854
|
-
setIsOmanNetCard(false);
|
|
82855
|
-
const cardHolderInput = (_iframeRef$current3 = iframeRef.current) == null || (_iframeRef$current3 = _iframeRef$current3.nextElementSibling) == null ? void 0 : _iframeRef$current3.querySelector(`input[name=name]`);
|
|
82856
|
-
if (cardHolderInput) {
|
|
82857
|
-
setTimeout(() => cardHolderInput.disabled = false, 1000);
|
|
82858
|
-
}
|
|
82859
|
-
const redirectionUrl = ((_res$data = res.data) == null ? void 0 : _res$data.redirection_url) || ((_res$data2 = res.data) == null ? void 0 : _res$data2.redirect_url);
|
|
82860
|
-
if (requiresOTP) {
|
|
82861
|
-
setIsOmanNetCard(!!isOmanNetCard);
|
|
82862
|
-
setPaymentId(res.data.payment_id);
|
|
82863
|
-
setShowOTP(true);
|
|
82864
|
-
} else if (onAfterPaymentComplete && ((_res$data3 = res.data) == null ? void 0 : _res$data3.is_3d_secure) !== 'true') {
|
|
82865
|
-
onAfterPaymentComplete(res);
|
|
82866
|
-
} else if (res.status === 200 && redirectionUrl) {
|
|
82867
|
-
window.location.href = redirectionUrl;
|
|
82868
|
-
} else if (res.status === 400) {
|
|
82869
|
-
var _res$data4, _res$data5, _res$data6;
|
|
82870
|
-
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$data4 = res.data) == null ? void 0 : _res$data4.msg) === 'Retry limit reached.') {
|
|
82871
|
-
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
82872
|
-
} else if (((_res$data5 = res.data) == null ? void 0 : _res$data5.message) === 'Session Error') {
|
|
82873
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
82874
|
-
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$data6 = res.data) == null ? void 0 : _res$data6.msg) === 'Order has already paid.') {
|
|
82875
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PAID'));
|
|
82876
|
-
} else {
|
|
82877
|
-
setErrorMessage(t('ERR_MSG_DECLINED'));
|
|
82878
|
-
}
|
|
82879
|
-
} else if (res.status === 401) {
|
|
82880
|
-
setErrorMessage(t('ERR_MSG_EXPIRED'));
|
|
82881
|
-
} else if (res.status === 422) {
|
|
82882
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
82883
|
-
} else if (res.status === 403) {
|
|
82884
|
-
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
82885
|
-
} else if (res.status === 406) {
|
|
82886
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
82887
|
-
} else {
|
|
82888
|
-
setErrorMessage(t('ERR_MSG_SOMETHING_WENT_WRONG'));
|
|
82889
|
-
}
|
|
82890
|
-
};
|
|
82891
|
-
window.addEventListener('message', handleDataFromIframe);
|
|
82892
|
-
return () => {
|
|
82893
|
-
window.removeEventListener('message', handleDataFromIframe);
|
|
82894
|
-
};
|
|
82895
|
-
}, []);
|
|
82896
|
-
(0,react.useEffect)(() => {
|
|
82897
|
-
const hasSavedCards = savedCards == null ? void 0 : savedCards.length;
|
|
82898
|
-
const shouldListenToSavedCardSubmit = hasSavedCards && !shouldDisablePayBtn && !showCardModal;
|
|
82899
|
-
const shouldListenToPayWithoutButton = hasSavedCards && showCardModal && isCardValid || !hasSavedCards && isCardValid;
|
|
82900
|
-
if (disablePay) {
|
|
82901
|
-
if (shouldListenToSavedCardSubmit) {
|
|
82902
|
-
window.addEventListener('payFromOutside', handleSavedCardSubmit);
|
|
82903
|
-
} else {
|
|
82904
|
-
window.removeEventListener('payFromOutside', handleSavedCardSubmit);
|
|
82905
|
-
}
|
|
82906
|
-
if (shouldListenToPayWithoutButton) {
|
|
82907
|
-
window.addEventListener('payFromOutside', handlePayWithoutButton);
|
|
82908
|
-
} else {
|
|
82909
|
-
window.removeEventListener('payFromOutside', handlePayWithoutButton);
|
|
82910
|
-
}
|
|
82911
|
-
}
|
|
82912
|
-
return () => {
|
|
82913
|
-
if (disablePay) {
|
|
82914
|
-
window.removeEventListener('payFromOutside', handlePayWithoutButton);
|
|
82915
|
-
window.removeEventListener('payFromOutside', handleSavedCardSubmit);
|
|
82916
|
-
}
|
|
82917
|
-
};
|
|
82918
|
-
}, [isCardValid, shouldDisablePayBtn, showCardModal, savedCards == null ? void 0 : savedCards.length]);
|
|
82919
|
-
(0,react.useEffect)(() => {
|
|
82920
|
-
if (iframeRef.current && shouldSubmitData) {
|
|
82921
|
-
const handlePay = async () => {
|
|
82922
|
-
var _iframeRef$current4;
|
|
82923
|
-
if (loading) return;
|
|
82924
|
-
const cardHolderInput = (_iframeRef$current4 = iframeRef.current) == null || (_iframeRef$current4 = _iframeRef$current4.nextElementSibling) == null ? void 0 : _iframeRef$current4.querySelector(`input[name=name]`);
|
|
82925
|
-
if (cardHolderInput) {
|
|
82926
|
-
cardHolderInput.disabled = true;
|
|
82927
|
-
}
|
|
82928
|
-
setLoading(true);
|
|
82929
|
-
if (onBeforePaymentComplete) {
|
|
82930
|
-
const result = await onBeforePaymentComplete(payment.name);
|
|
82931
|
-
if (!result) {
|
|
82932
|
-
setShouldSubmitData(false);
|
|
82933
|
-
setLoading(false);
|
|
82934
|
-
return;
|
|
82935
|
-
}
|
|
82936
|
-
}
|
|
82937
|
-
sendCardData(true);
|
|
82938
|
-
setShouldSubmitData(false);
|
|
82939
|
-
};
|
|
82940
|
-
handlePay();
|
|
82941
|
-
}
|
|
82942
|
-
}, [cardHolderName, saveCard, shouldSubmitData, iframeRef.current]);
|
|
82943
|
-
(0,react.useEffect)(() => {
|
|
82944
|
-
if (isIframeLoaded) {
|
|
82945
|
-
sendCardData();
|
|
82946
|
-
}
|
|
82947
|
-
}, [isIframeLoaded, payment]);
|
|
82948
|
-
(0,react.useEffect)(() => {
|
|
82949
|
-
let resizeObserver = null;
|
|
82950
|
-
if (isIframeLoaded) {
|
|
82951
|
-
var _iframeRef$current5, _iframeRef$current6;
|
|
82952
|
-
(_iframeRef$current5 = iframeRef.current) == null || (_iframeRef$current5 = _iframeRef$current5.contentWindow) == null || _iframeRef$current5.postMessage({
|
|
82953
|
-
type: 'customStyles',
|
|
82954
|
-
payload: {
|
|
82955
|
-
styling: customStyle,
|
|
82956
|
-
options: {
|
|
82957
|
-
hideCardHolderName: hideCardHolderName
|
|
82958
|
-
}
|
|
82959
|
-
}
|
|
82960
|
-
}, '*');
|
|
82961
|
-
const nextElement = (_iframeRef$current6 = iframeRef.current) == null ? void 0 : _iframeRef$current6.nextElementSibling;
|
|
82962
|
-
resizeObserver = new ResizeObserver(entries => {
|
|
82963
|
-
for (let entry of entries) {
|
|
82964
|
-
const width = Math.floor(entry.contentRect.width - 0.5);
|
|
82965
|
-
if (nextElement) {
|
|
82966
|
-
nextElement.style.width = `${width}px`;
|
|
82967
|
-
}
|
|
82968
|
-
}
|
|
82969
|
-
});
|
|
82970
|
-
iframeRef.current && resizeObserver.observe(iframeRef.current);
|
|
82971
|
-
}
|
|
82972
|
-
return () => {
|
|
82973
|
-
var _resizeObserver;
|
|
82974
|
-
(_resizeObserver = resizeObserver) == null || _resizeObserver.disconnect();
|
|
82975
|
-
};
|
|
82976
|
-
}, [isIframeLoaded, iframeRef.current]);
|
|
82977
|
-
(0,react.useEffect)(() => {
|
|
82978
|
-
var _iframeRef$current7;
|
|
82979
|
-
(_iframeRef$current7 = iframeRef.current) == null || (_iframeRef$current7 = _iframeRef$current7.contentWindow) == null || _iframeRef$current7.postMessage({
|
|
82980
|
-
type: 'cardHolderError',
|
|
82981
|
-
payload: {
|
|
82982
|
-
error: errors['name']
|
|
82983
|
-
}
|
|
82984
|
-
}, '*');
|
|
82985
|
-
}, [errors.name]);
|
|
82986
|
-
(0,react.useEffect)(() => {
|
|
82987
|
-
const isSavedCardView = (savedCards == null ? void 0 : savedCards.length) && !showCardModal;
|
|
82988
|
-
const correctErrorsCount = Object.keys(errors).length === 4;
|
|
82989
|
-
if (isSavedCardView && previousValidationRef.current !== !shouldDisablePayBtn) {
|
|
82990
|
-
onCardValidationChanged == null || onCardValidationChanged(!shouldDisablePayBtn);
|
|
82991
|
-
previousValidationRef.current = !shouldDisablePayBtn;
|
|
82992
|
-
} else if (correctErrorsCount && previousValidationRef.current !== isCardValid) {
|
|
82993
|
-
onCardValidationChanged == null || onCardValidationChanged(isCardValid);
|
|
82994
|
-
previousValidationRef.current = isCardValid;
|
|
82995
|
-
}
|
|
82996
|
-
}, [isCardValid, shouldDisablePayBtn]);
|
|
82997
|
-
(0,react.useImperativeHandle)(ref, () => ({
|
|
82998
|
-
handleGenerateToken
|
|
82999
|
-
}));
|
|
83000
|
-
async function handleGenerateToken() {
|
|
83001
|
-
return new Promise((resolve, reject) => {
|
|
83002
|
-
var _iframeRef$current8;
|
|
83003
|
-
if (loading || !isCardValid || isLoading) {
|
|
83004
|
-
return reject();
|
|
83005
|
-
}
|
|
83006
|
-
tokenizationResolve.current = resolve;
|
|
83007
|
-
(_iframeRef$current8 = iframeRef.current) == null || (_iframeRef$current8 = _iframeRef$current8.contentWindow) == null || _iframeRef$current8.postMessage({
|
|
83008
|
-
type: 'tokenizeCard',
|
|
83009
|
-
payload: {
|
|
83010
|
-
publicKey,
|
|
83011
|
-
cardHolderName,
|
|
83012
|
-
shouldSubmitData: true
|
|
83013
|
-
}
|
|
83014
|
-
}, '*');
|
|
83015
|
-
});
|
|
83016
|
-
}
|
|
83017
|
-
;
|
|
83018
|
-
const sendCardData = shouldSubmitData => {
|
|
83019
|
-
var _iframeRef$current9, _payment$subType, _payment$subType2, _payment$subType3;
|
|
83020
|
-
(_iframeRef$current9 = iframeRef.current) == null || (_iframeRef$current9 = _iframeRef$current9.contentWindow) == null || _iframeRef$current9.postMessage({
|
|
83021
|
-
type: 'cardData',
|
|
83022
|
-
payload: {
|
|
83023
|
-
paymentToken: payment == null ? void 0 : payment.token,
|
|
83024
|
-
subType: {
|
|
83025
|
-
paymentToken: payment == null || (_payment$subType = payment.subType) == null ? void 0 : _payment$subType.token,
|
|
83026
|
-
type: payment == null || (_payment$subType2 = payment.subType) == null ? void 0 : _payment$subType2.type,
|
|
83027
|
-
integrationId: payment == null || (_payment$subType3 = payment.subType) == null ? void 0 : _payment$subType3.integrationId
|
|
83028
|
-
},
|
|
83029
|
-
currency,
|
|
83030
|
-
cardHolderName,
|
|
83031
|
-
saveCard: forceSaveCard || saveCard,
|
|
83032
|
-
tenure,
|
|
83033
|
-
shouldSubmitData: shouldSubmitData,
|
|
83034
|
-
country,
|
|
83035
|
-
integrationId: payment == null ? void 0 : payment.id,
|
|
83036
|
-
discounts,
|
|
83037
|
-
checkBinFees: payment == null ? void 0 : payment.checkBinFees,
|
|
83038
|
-
feesAmount: payment == null ? void 0 : payment.feesAmount
|
|
83039
|
-
}
|
|
83040
|
-
}, '*');
|
|
83041
|
-
};
|
|
83042
|
-
const handlePayWithoutButton = () => {
|
|
83043
|
-
setShouldSubmitData(true);
|
|
83044
|
-
};
|
|
83045
|
-
const handleFocusToPrevInput = () => {
|
|
83046
|
-
var _iframeRef$current0;
|
|
83047
|
-
(_iframeRef$current0 = iframeRef.current) == null || (_iframeRef$current0 = _iframeRef$current0.contentWindow) == null || _iframeRef$current0.postMessage({
|
|
83048
|
-
type: 'setPrevFocus',
|
|
83049
|
-
payload: {
|
|
83050
|
-
shouldFocusOnCVV: true
|
|
83051
|
-
}
|
|
83052
|
-
}, '*');
|
|
83053
|
-
};
|
|
83054
|
-
const handleCardHolderChange = e => {
|
|
83055
|
-
setCardHolderName(e.target.value);
|
|
83056
|
-
};
|
|
83057
|
-
const handleResetDiscountMessages = () => {
|
|
83058
|
-
setDiscountErrorMessage("");
|
|
83059
|
-
setDiscountAppliedMessage(null);
|
|
83060
|
-
setTotalAmount("");
|
|
83061
|
-
setDiscountedAmount("");
|
|
83062
|
-
};
|
|
83063
|
-
const handleSavedCardDiscount = async (identifier, hasDiscount, savedCardType, updatedPaymentToken) => {
|
|
83064
|
-
var _payment$subType4, _payment$subType5, _discounts$data;
|
|
83065
|
-
handleResetDiscountMessages();
|
|
83066
|
-
const paymentToken = savedCardType === constants_SAVED_CARD_TYPES.OMAN_NET ? payment == null || (_payment$subType4 = payment.subType) == null ? void 0 : _payment$subType4.token : payment == null ? void 0 : payment.token;
|
|
83067
|
-
const integrationId = savedCardType === constants_SAVED_CARD_TYPES.OMAN_NET ? payment == null || (_payment$subType5 = payment.subType) == null ? void 0 : _payment$subType5.integrationId : payment == null ? void 0 : payment.id;
|
|
83068
|
-
const discountIntegrationId = discounts == null || (_discounts$data = discounts.data) == null || (_discounts$data = _discounts$data.find(discount => (discount == null ? void 0 : discount.integration_id) === integrationId)) == null ? void 0 : _discounts$data.integration_id;
|
|
83069
|
-
if (!hasDiscount || !discountIntegrationId) return;
|
|
83070
|
-
const res = await cardService_checkDiscount(updatedPaymentToken || paymentToken, discountIntegrationId, identifier, savedCardType);
|
|
83071
|
-
handleDiscount(res);
|
|
83072
|
-
if (res.status === 200) return true;
|
|
83073
|
-
};
|
|
83074
|
-
const handleDiscount = res => {
|
|
83075
|
-
handleResetDiscountMessages();
|
|
83076
|
-
if (!res) return;
|
|
83077
|
-
if (res.status === 200) {
|
|
83078
|
-
const {
|
|
83079
|
-
discount_amount_cents,
|
|
83080
|
-
discounted_amount_cents,
|
|
83081
|
-
caf,
|
|
83082
|
-
updatedPaymentToken
|
|
83083
|
-
} = res.data;
|
|
83084
|
-
const discountedAmount = formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(discounted_amount_cents, currency);
|
|
83085
|
-
const totalAmount = formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(discount_amount_cents, currency);
|
|
83086
|
-
if (discount_amount_cents < 0) {
|
|
83087
|
-
setDiscountErrorMessage(t('DISCOUNT_EXCEEDS_ORDER'));
|
|
83088
|
-
} else if (discounted_amount_cents > 0) {
|
|
83089
|
-
setDiscountAppliedMessage(/*#__PURE__*/(0,jsx_runtime.jsx)(Trans_Trans, {
|
|
83090
|
-
ns: "card",
|
|
83091
|
-
i18nKey: "DISCOUNT_APPLIED",
|
|
83092
|
-
values: {
|
|
83093
|
-
currency: tPaymentLayout(displayCurrency),
|
|
83094
|
-
amount: discountedAmount
|
|
83095
|
-
},
|
|
83096
|
-
components: {
|
|
83097
|
-
span: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83098
|
-
style: {
|
|
83099
|
-
fontFamily: currencyFontFamily
|
|
83100
|
-
}
|
|
83101
|
-
})
|
|
83102
|
-
}
|
|
83103
|
-
}));
|
|
83104
|
-
setTotalAmount(totalAmount);
|
|
83105
|
-
setDiscountedAmount(discountedAmount);
|
|
83106
|
-
if (caf > 0) {
|
|
83107
|
-
const feesAmount = formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(caf, currency);
|
|
83108
|
-
setFeesAmount(feesAmount);
|
|
83109
|
-
setShowFeesDetails(true);
|
|
83110
|
-
setUpdatedPaymentToken(updatedPaymentToken);
|
|
83111
|
-
}
|
|
83112
|
-
}
|
|
83113
|
-
} else if (res.status !== 500) {
|
|
83114
|
-
setDiscountErrorMessage(getErrorMsg_getErrorMsg(res));
|
|
83115
|
-
}
|
|
83116
|
-
};
|
|
83117
|
-
const handleFeesReset = () => {
|
|
83118
|
-
setTotalAmount("");
|
|
83119
|
-
setFeesAmount((payment == null ? void 0 : payment.feesAmount) || '');
|
|
83120
|
-
setShowFeesDetails(false);
|
|
83121
|
-
setUpdatedPaymentToken("");
|
|
83122
|
-
handleResetDiscountMessages();
|
|
83123
|
-
};
|
|
83124
|
-
const handleSavedCardFees = async (identifier, savedCardType, hasDiscount) => {
|
|
83125
|
-
handleFeesReset();
|
|
83126
|
-
if (!payment.checkBinFees && payment.feesAmount) {
|
|
83127
|
-
setShowFeesDetails(true);
|
|
83128
|
-
handleSavedCardDiscount(identifier, hasDiscount, savedCardType);
|
|
83129
|
-
} else if (payment.checkBinFees) {
|
|
83130
|
-
var _payment$subType6;
|
|
83131
|
-
const paymentToken = savedCardType === constants_SAVED_CARD_TYPES.OMAN_NET ? payment == null || (_payment$subType6 = payment.subType) == null ? void 0 : _payment$subType6.token : payment == null ? void 0 : payment.token;
|
|
83132
|
-
const res = await cardService_lookupFees(paymentToken, identifier);
|
|
83133
|
-
if (res.status === 200) {
|
|
83134
|
-
const {
|
|
83135
|
-
updated_payment_token
|
|
83136
|
-
} = res.data;
|
|
83137
|
-
const discountApplied = await handleSavedCardDiscount(identifier, hasDiscount, savedCardType, updated_payment_token);
|
|
83138
|
-
if (discountApplied) return;
|
|
83139
|
-
handleFees(res);
|
|
83140
|
-
} else {
|
|
83141
|
-
handleSavedCardDiscount(identifier, hasDiscount, savedCardType);
|
|
83142
|
-
}
|
|
83143
|
-
}
|
|
83144
|
-
};
|
|
83145
|
-
const handleFees = res => {
|
|
83146
|
-
handleFeesReset();
|
|
83147
|
-
if (!res) return;
|
|
83148
|
-
const {
|
|
83149
|
-
checkBinFees,
|
|
83150
|
-
feesAmount
|
|
83151
|
-
} = payment || {};
|
|
83152
|
-
if (!checkBinFees && feesAmount && res.showFeesDetails) {
|
|
83153
|
-
setShowFeesDetails(true);
|
|
83154
|
-
} else if (res.status === 200) {
|
|
83155
|
-
const {
|
|
83156
|
-
total_fees_cents,
|
|
83157
|
-
new_amount_cents,
|
|
83158
|
-
updated_payment_token
|
|
83159
|
-
} = res.data;
|
|
83160
|
-
if (total_fees_cents > 0) {
|
|
83161
|
-
const _feesAmount = formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(total_fees_cents, currency);
|
|
83162
|
-
const totalAmount = formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(new_amount_cents, currency);
|
|
83163
|
-
setTotalAmount(totalAmount);
|
|
83164
|
-
setFeesAmount(_feesAmount);
|
|
83165
|
-
setShowFeesDetails(true);
|
|
83166
|
-
setUpdatedPaymentToken(updated_payment_token);
|
|
83167
|
-
}
|
|
83168
|
-
}
|
|
83169
|
-
};
|
|
83170
|
-
const handleCloseDeleteCardModal = () => {
|
|
83171
|
-
setShowDeleteCardModal(false);
|
|
83172
|
-
setSelectedDeleteCard(null);
|
|
83173
|
-
};
|
|
83174
|
-
const handleDeleteCard = () => {
|
|
83175
|
-
//
|
|
83176
|
-
};
|
|
83177
|
-
const handleSelectCard = card => {
|
|
83178
|
-
if (card.expired) return;
|
|
83179
|
-
setSelectedCardCVV('');
|
|
83180
|
-
if ((selectedCard == null ? void 0 : selectedCard.id) === card.id) setSelectedCard(null);else {
|
|
83181
|
-
setSelectedCard(card);
|
|
83182
|
-
if (payment != null && payment.checkBinFees || payment != null && payment.feesAmount) {
|
|
83183
|
-
handleSavedCardFees == null || handleSavedCardFees(card.identifier, card.type, !!card.identifier && !!card.hasDiscount);
|
|
83184
|
-
}
|
|
83185
|
-
if (!(payment != null && payment.checkBinFees) && !(payment != null && payment.feesAmount)) {
|
|
83186
|
-
handleSavedCardDiscount == null || handleSavedCardDiscount(card.identifier, !!card.identifier && !!card.hasDiscount, card.type);
|
|
83187
|
-
}
|
|
83188
|
-
}
|
|
83189
|
-
};
|
|
83190
|
-
const handleSelectDeleteCard = (e, card) => {
|
|
83191
|
-
e.stopPropagation();
|
|
83192
|
-
setShowDeleteCardModal(true);
|
|
83193
|
-
setSelectedDeleteCard(card);
|
|
83194
|
-
};
|
|
83195
|
-
const handleSavedCardSubmit = async () => {
|
|
83196
|
-
var _payment$subType7, _res$data7, _res$data8, _res$data9;
|
|
83197
|
-
if (loading) return;
|
|
83198
|
-
setLoading(true);
|
|
83199
|
-
if (onBeforePaymentComplete) {
|
|
83200
|
-
const result = await onBeforePaymentComplete(payment.name);
|
|
83201
|
-
if (!result) {
|
|
83202
|
-
setSelectedCard(null);
|
|
83203
|
-
setSelectedCardCVV('');
|
|
83204
|
-
setLoading(false);
|
|
83205
|
-
return;
|
|
83206
|
-
}
|
|
83207
|
-
}
|
|
83208
|
-
const isOmanNet = (selectedCard == null ? void 0 : selectedCard.type) === constants_SAVED_CARD_TYPES.OMAN_NET;
|
|
83209
|
-
const data = {
|
|
83210
|
-
identifier: selectedCard == null ? void 0 : selectedCard.identifier,
|
|
83211
|
-
cvv: selectedCardCVV
|
|
83212
|
-
};
|
|
83213
|
-
const payload = Object.assign({
|
|
83214
|
-
identifier: data.identifier,
|
|
83215
|
-
token: updatedPaymentToken || (isOmanNet ? payment == null || (_payment$subType7 = payment.subType) == null ? void 0 : _payment$subType7.token : payment == null ? void 0 : payment.token)
|
|
83216
|
-
}, data.cvv && {
|
|
83217
|
-
cvv: data.cvv
|
|
83218
|
-
}, {
|
|
83219
|
-
isElements: true
|
|
83220
|
-
});
|
|
83221
|
-
const res = await cardService_payWithSavedCard(payload);
|
|
83222
|
-
setLoading(false);
|
|
83223
|
-
setIsOmanNetCard(false);
|
|
83224
|
-
const isSuccess = String((_res$data7 = res.data) == null ? void 0 : _res$data7.success) === 'true';
|
|
83225
|
-
const isPending = String((_res$data8 = res.data) == null ? void 0 : _res$data8.pending) === 'true';
|
|
83226
|
-
const isOTPGeneration = String((_res$data9 = res.data) == null ? void 0 : _res$data9.otp_generation) === 'true';
|
|
83227
|
-
if (res.status === 200) {
|
|
83228
|
-
if (isOmanNet && isOTPGeneration && !isSuccess && isPending) {
|
|
83229
|
-
setIsOmanNetCard(true);
|
|
83230
|
-
setPaymentId(res.data.payment_id);
|
|
83231
|
-
setShowOTP(true);
|
|
83232
|
-
} else {
|
|
83233
|
-
window.location.href = res.data.redirection_url;
|
|
83234
|
-
}
|
|
83235
|
-
} else if (res.status === 400) {
|
|
83236
|
-
var _res$data0, _res$data1, _res$data10;
|
|
83237
|
-
if (res.data instanceof Array && res.data[0] === 'Retry limit reached.' || ((_res$data0 = res.data) == null ? void 0 : _res$data0.msg) === 'Retry limit reached.') {
|
|
83238
|
-
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
83239
|
-
} else if (((_res$data1 = res.data) == null ? void 0 : _res$data1.message) === 'Session Error') {
|
|
83240
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
83241
|
-
} else if (res.data instanceof Array && res.data[0] === 'Order has already paid.' || ((_res$data10 = res.data) == null ? void 0 : _res$data10.msg) === 'Order has already paid.') {
|
|
83242
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PAID'));
|
|
83243
|
-
} else {
|
|
83244
|
-
setErrorMessage(t('ERR_MSG_DECLINED'));
|
|
83245
|
-
}
|
|
83246
|
-
} else if (res.status === 401) {
|
|
83247
|
-
setErrorMessage(t('ERR_MSG_EXPIRED'));
|
|
83248
|
-
} else if (res.status === 422) {
|
|
83249
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
83250
|
-
} else if (res.status === 403) {
|
|
83251
|
-
setErrorMessage(t('ERR_MSG_EXCEEDED_TRIALS'));
|
|
83252
|
-
} else if (res.status === 406) {
|
|
83253
|
-
setErrorMessage(t('ERR_MSG_ALREADY_PROCESSED'));
|
|
83254
|
-
} else {
|
|
83255
|
-
setErrorMessage(t('ERR_MSG_SOMETHING_WENT_WRONG'));
|
|
83256
|
-
}
|
|
83257
|
-
};
|
|
83258
|
-
const handleOTPSubmit = async otp => {
|
|
83259
|
-
var _payment$subType8, _res$data11, _res$data12;
|
|
83260
|
-
setSendOTPLoading(true);
|
|
83261
|
-
const res = await cardService_sendOTP({
|
|
83262
|
-
token: updatedPaymentToken || (isOmanNetCard ? (_payment$subType8 = payment.subType) == null ? void 0 : _payment$subType8.token : payment.token),
|
|
83263
|
-
otp,
|
|
83264
|
-
paymentId
|
|
83265
|
-
});
|
|
83266
|
-
const redirectionUrl = ((_res$data11 = res.data) == null ? void 0 : _res$data11.redirection_url) || ((_res$data12 = res.data) == null ? void 0 : _res$data12.redirect_url);
|
|
83267
|
-
if (res.status === 200) {
|
|
83268
|
-
if (redirectionUrl && (res.data.result === 'CAPTURED' || res.data.result === 'APPROVED')) {
|
|
83269
|
-
window.location.href = redirectionUrl;
|
|
83270
|
-
} else {
|
|
83271
|
-
setOTPErrorMessage(getErrorMsg_getErrorMsg(res));
|
|
83272
|
-
}
|
|
83273
|
-
} else if (res.status !== 200) {
|
|
83274
|
-
setOTPErrorMessage(getErrorMsg_getErrorMsg(res));
|
|
83275
|
-
}
|
|
83276
|
-
setSendOTPLoading(false);
|
|
83277
|
-
};
|
|
83278
|
-
const handleShowNewCardForm = () => {
|
|
83279
|
-
if (loading) return;
|
|
83280
|
-
setSelectedCard(null);
|
|
83281
|
-
setSelectedCardCVV('');
|
|
83282
|
-
setShowCardModal(true);
|
|
83283
|
-
if (previousValidationRef.current) {
|
|
83284
|
-
onCardValidationChanged == null || onCardValidationChanged(false);
|
|
83285
|
-
previousValidationRef.current = false;
|
|
83286
|
-
}
|
|
83287
|
-
handleResetDiscountMessages();
|
|
83288
|
-
handleFeesReset();
|
|
83289
|
-
};
|
|
83290
|
-
const handleViewSavedCards = () => {
|
|
83291
|
-
setShowCardModal(false);
|
|
83292
|
-
setIsIframeLoaded(false);
|
|
83293
|
-
setCardHolderName('');
|
|
83294
|
-
if (previousValidationRef.current) {
|
|
83295
|
-
onCardValidationChanged == null || onCardValidationChanged(false);
|
|
83296
|
-
previousValidationRef.current = false;
|
|
83297
|
-
}
|
|
83298
|
-
handleFeesReset();
|
|
83299
|
-
};
|
|
83300
|
-
const handleCloseOTP = () => {
|
|
83301
|
-
setShowOTP(false);
|
|
83302
|
-
setErrorMessage('');
|
|
83303
|
-
onPaymentCancel == null || onPaymentCancel();
|
|
83304
|
-
};
|
|
83305
|
-
const orderDetailsContent = discountedAmount || showFeesDetails && feesAmount ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83306
|
-
className: "flex flex-col gap-3 mt-6 text-sm leading-4",
|
|
83307
|
-
style: customStyle == null ? void 0 : customStyle.label,
|
|
83308
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83309
|
-
className: "flex justify-between items-center",
|
|
83310
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83311
|
-
children: "Order amount:"
|
|
83312
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
|
|
83313
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83314
|
-
style: {
|
|
83315
|
-
fontFamily: currencyFontFamily
|
|
83316
|
-
},
|
|
83317
|
-
children: displayCurrency
|
|
83318
|
-
}), ' ', amount]
|
|
83319
|
-
})]
|
|
83320
|
-
}), discountedAmount && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83321
|
-
className: "flex justify-between items-center text-green-600",
|
|
83322
|
-
style: customStyle == null || (_customStyle$discount = customStyle.discount) == null ? void 0 : _customStyle$discount.successMessage,
|
|
83323
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83324
|
-
children: "Discount amount:"
|
|
83325
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
|
|
83326
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83327
|
-
style: {
|
|
83328
|
-
fontFamily: currencyFontFamily
|
|
83329
|
-
},
|
|
83330
|
-
children: displayCurrency
|
|
83331
|
-
}), ' ', discountedAmount]
|
|
83332
|
-
})]
|
|
83333
|
-
}), showFeesDetails && feesAmount && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83334
|
-
className: "flex justify-between items-center",
|
|
83335
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83336
|
-
children: "Convenience fee:"
|
|
83337
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
|
|
83338
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83339
|
-
style: {
|
|
83340
|
-
fontFamily: currencyFontFamily
|
|
83341
|
-
},
|
|
83342
|
-
children: displayCurrency
|
|
83343
|
-
}), ' ', feesAmount]
|
|
83344
|
-
})]
|
|
83345
|
-
})]
|
|
83346
|
-
}) : null;
|
|
83347
|
-
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83348
|
-
className: customStyle != null && (_customStyle$containe = customStyle.container) != null && _customStyle$containe.fontFamily ? '' : Card_card_module['gotham'],
|
|
83349
|
-
style: Object.assign({}, customStyle == null ? void 0 : customStyle.container, isList && {
|
|
83350
|
-
padding: 'unset'
|
|
83351
|
-
}),
|
|
83352
|
-
children: [isMobile && showOTP && /*#__PURE__*/(0,jsx_runtime.jsx)(MobileOTPModal_MobileOTPModal, {
|
|
83353
|
-
onClose: handleCloseOTP,
|
|
83354
|
-
onSubmit: handleOTPSubmit,
|
|
83355
|
-
length: 4,
|
|
83356
|
-
modalHeader: `${4}-digit code`,
|
|
83357
|
-
loading: sendOTPLoading,
|
|
83358
|
-
onErrorMessage: setOTPErrorMessage,
|
|
83359
|
-
error: otpErrorMessage,
|
|
83360
|
-
customStyle: {
|
|
83361
|
-
container: {
|
|
83362
|
-
backgroundColor: (customStyle == null || (_customStyle$containe2 = customStyle.container) == null ? void 0 : _customStyle$containe2.backgroundColor) || '',
|
|
83363
|
-
borderRadius: (customStyle == null || (_customStyle$button = customStyle.button) == null ? void 0 : _customStyle$button.borderRadius) || ''
|
|
83364
|
-
},
|
|
83365
|
-
button: customStyle == null ? void 0 : customStyle.button,
|
|
83366
|
-
label: customStyle == null ? void 0 : customStyle.label,
|
|
83367
|
-
error: customStyle == null ? void 0 : customStyle.error
|
|
83368
|
-
}
|
|
83369
|
-
}), !isMobile && showOTP && /*#__PURE__*/(0,jsx_runtime.jsx)(ModalView_ModalView, {
|
|
83370
|
-
showModal: showOTP,
|
|
83371
|
-
onClose: handleCloseOTP,
|
|
83372
|
-
customStyle: customStyle == null ? void 0 : customStyle.button,
|
|
83373
|
-
children: /*#__PURE__*/(0,jsx_runtime.jsx)(OTPModal_OTPModal, {
|
|
83374
|
-
onClose: handleCloseOTP,
|
|
83375
|
-
onSubmit: handleOTPSubmit,
|
|
83376
|
-
length: 4,
|
|
83377
|
-
modalHeader: `${4}-digit code`,
|
|
83378
|
-
loading: sendOTPLoading,
|
|
83379
|
-
onErrorMessage: setOTPErrorMessage,
|
|
83380
|
-
error: otpErrorMessage,
|
|
83381
|
-
customStyle: {
|
|
83382
|
-
container: {
|
|
83383
|
-
backgroundColor: (customStyle == null || (_customStyle$containe3 = customStyle.container) == null ? void 0 : _customStyle$containe3.backgroundColor) || ''
|
|
83384
|
-
},
|
|
83385
|
-
cancelButton: Object.assign({}, customStyle == null ? void 0 : customStyle.button, {
|
|
83386
|
-
backgroundColor: '#fff',
|
|
83387
|
-
lineHeight: 'normal',
|
|
83388
|
-
color: ''
|
|
83389
|
-
}),
|
|
83390
|
-
button: customStyle == null ? void 0 : customStyle.button,
|
|
83391
|
-
label: customStyle == null ? void 0 : customStyle.label,
|
|
83392
|
-
error: customStyle == null ? void 0 : customStyle.error
|
|
83393
|
-
}
|
|
83394
|
-
})
|
|
83395
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsx)(CVVToolTipModal_CVVToolTipModal, {
|
|
83396
|
-
onClose: () => setShowCVVTooltipModal(false),
|
|
83397
|
-
showModal: showCVVTooltipModal,
|
|
83398
|
-
customStyle: customStyle
|
|
83399
|
-
}), errorMessage && /*#__PURE__*/(0,jsx_runtime.jsx)(ErrorMessageViewTwo_ErrorMessage, {
|
|
83400
|
-
errorMessage: errorMessage
|
|
83401
|
-
}), (!savedCards || savedCards && showCardModal) && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83402
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83403
|
-
className: `${customStyle != null && customStyle.hideCardLabel && !showCardModal ? 'hidden' : 'flex'} justify-between`,
|
|
83404
|
-
style: {
|
|
83405
|
-
marginBottom: '-8px'
|
|
83406
|
-
},
|
|
83407
|
-
children: [!(customStyle != null && customStyle.hideCardLabel) && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83408
|
-
style: Object.assign({}, customStyle == null ? void 0 : customStyle.label),
|
|
83409
|
-
className: "mt-4",
|
|
83410
|
-
children: (customStyle == null || (_customStyle$labelTex = customStyle.labelText) == null ? void 0 : _customStyle$labelTex.cardLabel) || t('CARD_INFO')
|
|
83411
|
-
}), showCardModal && /*#__PURE__*/(0,jsx_runtime.jsx)("button", {
|
|
83412
|
-
id: 'cancel-button',
|
|
83413
|
-
className: "hover:!opacity-75 underline ms-auto",
|
|
83414
|
-
style: customStyle == null ? void 0 : customStyle.label,
|
|
83415
|
-
disabled: loading,
|
|
83416
|
-
onClick: handleViewSavedCards,
|
|
83417
|
-
children: (customStyle == null || (_customStyle$buttonTe = customStyle.buttonText) == null ? void 0 : _customStyle$buttonTe.viewSavedCardsBtn) || t('VIEW_SAVED_CARDS')
|
|
83418
|
-
})]
|
|
83419
|
-
}), !!(discounts != null && discounts.count) && /*#__PURE__*/(0,jsx_runtime.jsx)(Discounts, {
|
|
83420
|
-
customStyle: customStyle == null ? void 0 : customStyle.discount,
|
|
83421
|
-
discounts: discounts.data
|
|
83422
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83423
|
-
className: "[&>div:nth-child(even)]:w-[calc(100%-1px)]",
|
|
83424
|
-
children: [(!isIframeLoaded || !(payment.token || integrationType === constants_INTEGRATION_TYPE.TOKENIZATION)) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83425
|
-
className: "-mt-1",
|
|
83426
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(dist_Skeleton, {
|
|
83427
|
-
height: 37
|
|
83428
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
83429
|
-
className: "flex gap-1 [&>*]:flex-1",
|
|
83430
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(dist_Skeleton, {
|
|
83431
|
-
height: 37
|
|
83432
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsx)(dist_Skeleton, {
|
|
83433
|
-
height: 37
|
|
83434
|
-
})]
|
|
83435
|
-
}), !hideCardHolderName && /*#__PURE__*/(0,jsx_runtime.jsx)(dist_Skeleton, {
|
|
83436
|
-
height: 37
|
|
83437
|
-
})]
|
|
83438
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", {
|
|
83439
|
-
title: 'Elements',
|
|
83440
|
-
id: "iFrame",
|
|
83441
|
-
ref: iframeRef,
|
|
83442
|
-
src: `${baseUrl}/${environment_environment['IFRAME_PATH']}/?type=card&v=2&integration_type=${integrationType}`
|
|
83443
|
-
// src={`http://localhost:9001/${environment['IFRAME_PATH']}/?type=card&v=2&integration_type=${integrationType}`}
|
|
83444
|
-
,
|
|
83445
|
-
className: Card_card_module['iframe'],
|
|
83446
|
-
style: {
|
|
83447
|
-
display: isIframeLoaded && (payment.token || integrationType === constants_INTEGRATION_TYPE.TOKENIZATION) ? 'block' : 'none'
|
|
83448
|
-
},
|
|
83449
|
-
frameBorder: "0",
|
|
83450
|
-
scrolling: "no",
|
|
83451
|
-
width: "100%",
|
|
83452
|
-
height: height
|
|
83453
|
-
}), isIframeLoaded && (payment.token || integrationType === constants_INTEGRATION_TYPE.TOKENIZATION) && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83454
|
-
children: [!hideCardHolderName && /*#__PURE__*/(0,jsx_runtime.jsx)(components_CardHolder_CardHolder, {
|
|
83455
|
-
onChange: handleCardHolderChange,
|
|
83456
|
-
focusToPrevInput: handleFocusToPrevInput,
|
|
83457
|
-
customStyle: customStyle,
|
|
83458
|
-
setErrors: setErrors,
|
|
83459
|
-
error: errors['name'],
|
|
83460
|
-
placeholder: customStyle == null || (_customStyle$placehol = customStyle.placeholderText) == null ? void 0 : _customStyle$placehol.holderName
|
|
83461
|
-
}), discountErrorMessage && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83462
|
-
className: "mt-2 text-orange-700 text-sm leading-[1.125rem] tracking-[0.01rem]",
|
|
83463
|
-
style: customStyle == null || (_customStyle$discount2 = customStyle.discount) == null ? void 0 : _customStyle$discount2.validationMessage,
|
|
83464
|
-
children: discountErrorMessage
|
|
83465
|
-
}), discountAppliedMessage && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83466
|
-
className: "mt-2 text-green-600 text-sm leading-[1.125rem] tracking-[0.01rem]",
|
|
83467
|
-
style: customStyle == null || (_customStyle$discount3 = customStyle.discount) == null ? void 0 : _customStyle$discount3.successMessage,
|
|
83468
|
-
children: discountAppliedMessage
|
|
83469
|
-
}), (errors['number'] || errors['name'] || errors['cvc'] || errors['expiry']) && /*#__PURE__*/(0,jsx_runtime.jsxs)("ul", {
|
|
83470
|
-
style: customStyle == null ? void 0 : customStyle.error,
|
|
83471
|
-
className: "my-2 text-sm text-red-600 list-disc list-inside list-item:text-red-600",
|
|
83472
|
-
children: [errors['number'] && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
83473
|
-
children: getFieldErrorMessage_getFieldErrorMessage({
|
|
83474
|
-
nativeError: errors['number'],
|
|
83475
|
-
customError: customStyle == null || (_customStyle$errorTex = customStyle.errorText) == null ? void 0 : _customStyle$errorTex.cardNumber
|
|
83476
|
-
})
|
|
83477
|
-
}), errors['expiry'] && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
83478
|
-
children: getFieldErrorMessage_getFieldErrorMessage({
|
|
83479
|
-
nativeError: errors['expiry'],
|
|
83480
|
-
customError: customStyle == null || (_customStyle$errorTex2 = customStyle.errorText) == null ? void 0 : _customStyle$errorTex2.expiryDate
|
|
83481
|
-
})
|
|
83482
|
-
}), errors['cvc'] && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
83483
|
-
children: getFieldErrorMessage_getFieldErrorMessage({
|
|
83484
|
-
nativeError: errors['cvc'],
|
|
83485
|
-
customError: customStyle == null || (_customStyle$errorTex3 = customStyle.errorText) == null ? void 0 : _customStyle$errorTex3.securityCode
|
|
83486
|
-
})
|
|
83487
|
-
}), errors['name'] && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
83488
|
-
children: getFieldErrorMessage_getFieldErrorMessage({
|
|
83489
|
-
nativeError: errors['name'],
|
|
83490
|
-
customError: customStyle == null || (_customStyle$errorTex4 = customStyle.errorText) == null ? void 0 : _customStyle$errorTex4.holderName
|
|
83491
|
-
})
|
|
83492
|
-
})]
|
|
83493
|
-
}), orderDetailsContent]
|
|
83494
|
-
})]
|
|
83495
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83496
|
-
children: [forceSaveCard && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83497
|
-
style: customStyle == null ? void 0 : customStyle.label,
|
|
83498
|
-
className: "flex h-4 flex-col justify-center text-gray-700 text-sm font-medium leading-6 tracking-[0.01rem]",
|
|
83499
|
-
children: (customStyle == null || (_customStyle$hintText = customStyle.hintText) == null ? void 0 : _customStyle$hintText.saveCardConsentHint) || t('FORCE_SAVE_CARD')
|
|
83500
|
-
}), !forceSaveCard && showSaveCard && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
83501
|
-
children: /*#__PURE__*/(0,jsx_runtime.jsx)(CheckboxViewTwo_Checkbox, {
|
|
83502
|
-
label: (customStyle == null || (_customStyle$labelTex2 = customStyle.labelText) == null ? void 0 : _customStyle$labelTex2.saveCardConsentLabel) || t('SAVE_CARD'),
|
|
83503
|
-
name: "save_card",
|
|
83504
|
-
checked: saveCard,
|
|
83505
|
-
onChange: e => setSaveCard(e.target.checked),
|
|
83506
|
-
customStyle: customStyle == null ? void 0 : customStyle.label
|
|
83507
|
-
})
|
|
83508
|
-
}), !disablePay && integrationType === constants_INTEGRATION_TYPE.DIRECT_PAYMENT && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
83509
|
-
className: Card_card_module['action-btn'],
|
|
83510
|
-
children: /*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button, {
|
|
83511
|
-
id: 'pay-button',
|
|
83512
|
-
loading: loading || isLoading,
|
|
83513
|
-
disabled: loading || !isCardValid || isLoading,
|
|
83514
|
-
label: /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83515
|
-
children: [(customStyle == null || (_customStyle$buttonTe2 = customStyle.buttonText) == null ? void 0 : _customStyle$buttonTe2.payBtn) || t('CARD_ACTION_BTN'), ' ', /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83516
|
-
style: {
|
|
83517
|
-
fontFamily: currencyFontFamily
|
|
83518
|
-
},
|
|
83519
|
-
children: displayCurrency
|
|
83520
|
-
}), ' ', totalAmount || amount, totalAmount && /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83521
|
-
className: "opacity-50 ml-2 text-white text-sm font-semibold leading-6 tracking-[0.16px]",
|
|
83522
|
-
style: {
|
|
83523
|
-
textDecoration: 'line-through'
|
|
83524
|
-
},
|
|
83525
|
-
children: amount
|
|
83526
|
-
})]
|
|
83527
|
-
}),
|
|
83528
|
-
onClick: () => setShouldSubmitData(true),
|
|
83529
|
-
customStyle: customStyle == null ? void 0 : customStyle.button,
|
|
83530
|
-
className: "w-full"
|
|
83531
|
-
})
|
|
83532
|
-
}), showPaymobLogo && integrationType === constants_INTEGRATION_TYPE.DIRECT_PAYMENT && /*#__PURE__*/(0,jsx_runtime.jsx)(CopyrightsViewTwo_Copyrights, {
|
|
83533
|
-
isElements: true
|
|
83534
|
-
})]
|
|
83535
|
-
})]
|
|
83536
|
-
}), savedCards && !showCardModal && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83537
|
-
children: [!!(discounts != null && discounts.count) && /*#__PURE__*/(0,jsx_runtime.jsx)(Discounts, {
|
|
83538
|
-
customStyle: customStyle == null ? void 0 : customStyle.discount,
|
|
83539
|
-
discounts: discounts.data
|
|
83540
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83541
|
-
style: customStyle == null ? void 0 : customStyle.label,
|
|
83542
|
-
children: (customStyle == null || (_customStyle$labelTex3 = customStyle.labelText) == null ? void 0 : _customStyle$labelTex3.savedCardsLabel) || t('SAVED_CARDS_TITLE')
|
|
83543
|
-
}), savedCards.map(card => {
|
|
83544
|
-
var _customStyle$discount4, _customStyle$discount5;
|
|
83545
|
-
return /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83546
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(SavedCardElements, {
|
|
83547
|
-
card: card,
|
|
83548
|
-
selectedCardId: selectedCard == null ? void 0 : selectedCard.id,
|
|
83549
|
-
showCvvInput: showCvvInput,
|
|
83550
|
-
selectedCardCVV: selectedCardCVV,
|
|
83551
|
-
setSelectedCardCVV: setSelectedCardCVV,
|
|
83552
|
-
onCardSelect: handleSelectCard,
|
|
83553
|
-
onDeleteCard: handleSelectDeleteCard,
|
|
83554
|
-
environment: environment_environment,
|
|
83555
|
-
height: height,
|
|
83556
|
-
customStyle: customStyle,
|
|
83557
|
-
baseURL: baseUrl,
|
|
83558
|
-
ref: el => {
|
|
83559
|
-
if (el) {
|
|
83560
|
-
iframeCVVRefs.current[card.id] = el;
|
|
83561
|
-
}
|
|
83562
|
-
}
|
|
83563
|
-
}, card.id), !showCardModal && discountErrorMessage && card.id === selectedCardId && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83564
|
-
className: "text-orange-700 text-sm leading-[1.125rem] track-[0.01rem]",
|
|
83565
|
-
style: customStyle == null || (_customStyle$discount4 = customStyle.discount) == null ? void 0 : _customStyle$discount4.validationMessage,
|
|
83566
|
-
children: discountErrorMessage
|
|
83567
|
-
}), !showCardModal && discountAppliedMessage && card.id === selectedCardId && /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83568
|
-
className: "text-green-600 text-sm leading-[1.125rem] track-[0.01rem]",
|
|
83569
|
-
style: customStyle == null || (_customStyle$discount5 = customStyle.discount) == null ? void 0 : _customStyle$discount5.successMessage,
|
|
83570
|
-
children: discountAppliedMessage
|
|
83571
|
-
}), orderDetailsContent]
|
|
83572
|
-
});
|
|
83573
|
-
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
83574
|
-
onClick: handleShowNewCardForm,
|
|
83575
|
-
className: `${loading ? 'opacity-75' : 'cursor-pointer'} mt-4 w-full flex h-[4.5rem] p-4 justify-center items-center gap-3 rounded-xl border border-dashed border-blue-200 bg-white`,
|
|
83576
|
-
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("button", {
|
|
83577
|
-
disabled: loading,
|
|
83578
|
-
className: "flex justify-center items-center gap-2 text-blue-500",
|
|
83579
|
-
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83580
|
-
className: "text-base",
|
|
83581
|
-
children: "+"
|
|
83582
|
-
}), ' ', /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
83583
|
-
className: "text-center text-sm font-semibold leading-6 tracking-[.01rem]",
|
|
83584
|
-
children: (customStyle == null || (_customStyle$buttonTe3 = customStyle.buttonText) == null ? void 0 : _customStyle$buttonTe3.addNewCardBtn) || t('ADD_NEW_CARD_BTN')
|
|
83585
|
-
})]
|
|
83586
|
-
})
|
|
83587
|
-
}), !disablePay && !!savedCards.length && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
83588
|
-
className: "mt-auto",
|
|
83589
|
-
children: /*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button, {
|
|
83590
|
-
id: "pay-button",
|
|
83591
|
-
disabled: loading || shouldDisablePayBtn || isLoading,
|
|
83592
|
-
loading: loading || isLoading,
|
|
83593
|
-
color: 'primary',
|
|
83594
|
-
onClick: handleSavedCardSubmit,
|
|
83595
|
-
label: /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
83596
|
-
children: [(customStyle == null || (_customStyle$buttonTe4 = customStyle.buttonText) == null ? void 0 : _customStyle$buttonTe4.payBtn) || t('CARD_ACTION_BTN'), ' ', /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83597
|
-
style: {
|
|
83598
|
-
fontFamily: currencyFontFamily
|
|
83599
|
-
},
|
|
83600
|
-
children: displayCurrency
|
|
83601
|
-
}), ' ', totalAmount || amount, totalAmount && /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
83602
|
-
className: "opacity-50 ml-2 text-white text-sm font-semibold leading-6 tracking-[0.16px]",
|
|
83603
|
-
style: {
|
|
83604
|
-
textDecoration: 'line-through'
|
|
83605
|
-
},
|
|
83606
|
-
children: amount
|
|
83607
|
-
})]
|
|
83608
|
-
}),
|
|
83609
|
-
customStyle: customStyle == null ? void 0 : customStyle.button,
|
|
83610
|
-
className: "w-full"
|
|
83611
|
-
})
|
|
83612
|
-
})]
|
|
83613
|
-
})]
|
|
83614
|
-
});
|
|
83615
|
-
});
|
|
83616
|
-
/* harmony default export */ const components_Payments_Card = (Card_CardElement);
|
|
83617
|
-
;// ../../apps/elements/src/services/knetService.ts
|
|
83618
|
-
|
|
83619
|
-
const knetService_payWithKnet = (token, amount) => {
|
|
83620
|
-
return lib_axios.post(`/api/acceptance/payments/pay`, {
|
|
83621
|
-
source: {
|
|
83622
|
-
identifier: 'KnetCard',
|
|
83623
|
-
amount_cents: amount,
|
|
83624
|
-
subtype: 'KNET'
|
|
83625
|
-
},
|
|
83626
|
-
payment_token: token,
|
|
83627
|
-
api_source: " PIXEL"
|
|
83628
|
-
}).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
83629
|
-
};
|
|
83630
|
-
;// ../../apps/elements/src/components/Payments/Knet/index.tsx
|
|
83631
|
-
|
|
83632
|
-
|
|
83633
|
-
|
|
83634
|
-
|
|
83635
|
-
|
|
83636
|
-
function Knet_KnetElement({
|
|
83637
|
-
payment,
|
|
83638
|
-
customStyle,
|
|
83639
|
-
paymentMethodsCount,
|
|
83640
|
-
disablePay,
|
|
83641
|
-
onPaymentStart,
|
|
83642
|
-
onPaymentEnd
|
|
83643
|
-
}) {
|
|
83644
|
-
const [loading, setLoading] = (0,react.useState)(false);
|
|
83645
|
-
const {
|
|
83646
|
-
amount,
|
|
83647
|
-
currency,
|
|
83648
|
-
KnetEquivalentAmountCents,
|
|
83649
|
-
KnetCurrency,
|
|
83650
|
-
KnetMinTransactionAmount
|
|
83651
|
-
} = payment;
|
|
83652
|
-
let KnetEquivalentAmount = null;
|
|
83653
|
-
if (KnetEquivalentAmountCents) {
|
|
83654
|
-
KnetEquivalentAmount = CURRENCIES_WITH_THOUSAND_DIVISOR.includes(KnetCurrency) ? KnetEquivalentAmountCents / 1000 : KnetEquivalentAmountCents / 100;
|
|
83655
|
-
}
|
|
83656
|
-
const amountInCents = getAmountInCentsBasedOnCurrency_getAmountInCentsBasedOnCurrency(amount, currency);
|
|
83657
|
-
const handlePay = async () => {
|
|
83658
|
-
try {
|
|
83659
|
-
var _res$data, _res$data2;
|
|
83660
|
-
onPaymentStart == null || onPaymentStart(payment.type);
|
|
83661
|
-
setLoading(true);
|
|
83662
|
-
const res = await knetService_payWithKnet(payment == null ? void 0 : payment.token, String(amountInCents));
|
|
83663
|
-
const redirectionUrl = ((_res$data = res.data) == null ? void 0 : _res$data.redirection_url) || ((_res$data2 = res.data) == null ? void 0 : _res$data2.redirect_url);
|
|
83664
|
-
if (res.status === 200 && redirectionUrl) {
|
|
83665
|
-
window.location.href = redirectionUrl;
|
|
83666
|
-
}
|
|
83667
|
-
} catch (error) {
|
|
83668
|
-
console.error('Payment error:', error);
|
|
83669
|
-
onPaymentEnd == null || onPaymentEnd();
|
|
83670
|
-
} finally {
|
|
83671
|
-
setLoading(false);
|
|
83672
|
-
}
|
|
83673
|
-
};
|
|
83674
|
-
return /*#__PURE__*/(0,jsx_runtime.jsx)(Knet, {
|
|
83675
|
-
minAmount: KnetMinTransactionAmount,
|
|
83676
|
-
onPaySubmit: handlePay,
|
|
83677
|
-
loading: loading,
|
|
83678
|
-
paymentMethodsCount: paymentMethodsCount,
|
|
83679
|
-
amount: amount,
|
|
83680
|
-
currency: currency,
|
|
83681
|
-
customStyle: customStyle,
|
|
83682
|
-
EquivalentAmount: KnetEquivalentAmount !== null ? String(KnetEquivalentAmount) : undefined,
|
|
83683
|
-
KnetCurrency: KnetCurrency,
|
|
83684
|
-
disablePay: disablePay
|
|
83685
|
-
});
|
|
83686
|
-
}
|
|
83687
|
-
/* harmony default export */ const components_Payments_Knet = (Knet_KnetElement);
|
|
83688
|
-
;// ../../apps/elements/src/services/knetApplePayServices.ts
|
|
83689
|
-
|
|
83690
|
-
const knetApplePayServices_validatemerchant = async (appleURL, integrationId) => {
|
|
83691
|
-
return lib_axios.post(`/api/auth/merchant/validate`, {
|
|
83692
|
-
appleURL,
|
|
83693
|
-
integrationId
|
|
83694
|
-
}).then(res => res.data.api_response).catch(err => err == null ? void 0 : err.response);
|
|
83695
|
-
};
|
|
83696
|
-
const knetApplePayServices_knetApplePayPayment = async (applePaytoken, paymentToken, clientData) => {
|
|
83697
|
-
var _clientData$name$trim, _clientData$name$trim2, _clientData$name$trim3, _clientData$name$trim4;
|
|
83698
|
-
return lib_axios.post(`/api/acceptance/payments/pay`, Object.assign({
|
|
83699
|
-
payment_token: paymentToken,
|
|
83700
|
-
api_source: "PIXEL",
|
|
83701
|
-
source: {
|
|
83702
|
-
identifier: applePaytoken,
|
|
83703
|
-
subtype: 'KNET_APPLE_PAY'
|
|
83704
|
-
}
|
|
83705
|
-
}, clientData && {
|
|
83706
|
-
billing: {
|
|
83707
|
-
apartment: 'NA',
|
|
83708
|
-
floor: 'NA',
|
|
83709
|
-
first_name: (_clientData$name$trim = clientData.name.trim().split(' ')) != null && _clientData$name$trim[0] ? (_clientData$name$trim2 = clientData.name.trim().split(' ')) == null ? void 0 : _clientData$name$trim2[0] : 'NA',
|
|
83710
|
-
last_name: (_clientData$name$trim3 = clientData.name.trim().split(' ')) != null && _clientData$name$trim3[clientData.name.trim().split(' ').length - 1] ? (_clientData$name$trim4 = clientData.name.trim().split(' ')) == null ? void 0 : _clientData$name$trim4[clientData.name.trim().split(' ').length - 1] : 'NA',
|
|
83711
|
-
street: 'NA',
|
|
83712
|
-
building: 'NA',
|
|
83713
|
-
phone_number: clientData.phone,
|
|
83714
|
-
shipping_method: 'NA',
|
|
83715
|
-
city: 'NA',
|
|
83716
|
-
country: 'NA',
|
|
83717
|
-
state: 'NA',
|
|
83718
|
-
email: clientData.email,
|
|
83719
|
-
postal_code: 'NA'
|
|
83720
|
-
}
|
|
83721
|
-
})).then(res => res).catch(err => err == null ? void 0 : err.response);
|
|
83722
|
-
};
|
|
83723
|
-
;// ../../apps/elements/src/components/Payments/KnetApplePay/index.tsx
|
|
83724
|
-
|
|
83725
|
-
const Payments_KnetApplePay_excluded = ["payment", "customStyle", "onBeforePaymentComplete", "onAfterPaymentComplete", "onPaymentCancel", "isLoading", "country", "paymentMethodsCount", "onPaymentStart", "onPaymentEnd"];
|
|
83726
|
-
|
|
83727
|
-
|
|
83728
|
-
|
|
83729
|
-
|
|
83730
|
-
function KnetApplePay_KnetApplePayElement(_ref) {
|
|
83731
|
-
var _amount$toString;
|
|
83732
|
-
let {
|
|
83733
|
-
payment,
|
|
83734
|
-
customStyle,
|
|
83735
|
-
onBeforePaymentComplete,
|
|
83736
|
-
onAfterPaymentComplete,
|
|
83737
|
-
onPaymentCancel,
|
|
83738
|
-
isLoading,
|
|
83739
|
-
country,
|
|
83740
|
-
paymentMethodsCount,
|
|
83741
|
-
onPaymentStart,
|
|
83742
|
-
onPaymentEnd
|
|
83743
|
-
} = _ref,
|
|
83744
|
-
restProps = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(_ref, Payments_KnetApplePay_excluded);
|
|
83745
|
-
const {
|
|
83746
|
-
amount,
|
|
83747
|
-
currency,
|
|
83748
|
-
KnetEquivalentAmountCents,
|
|
83749
|
-
KnetCurrency,
|
|
83750
|
-
merchantName,
|
|
83751
|
-
KnetMinTransactionAmount
|
|
83752
|
-
} = payment;
|
|
83753
|
-
const applePay = payment;
|
|
83754
|
-
let KnetEquivalentAmount = null;
|
|
83755
|
-
if (KnetEquivalentAmountCents) {
|
|
83756
|
-
KnetEquivalentAmount = CURRENCIES_WITH_THOUSAND_DIVISOR.includes(KnetCurrency) ? KnetEquivalentAmountCents / 1000 : KnetEquivalentAmountCents / 100;
|
|
83757
|
-
}
|
|
83758
|
-
const handleSubmit = (status, resData) => {
|
|
83759
|
-
window.location.href = resData.redirection_url;
|
|
83760
|
-
};
|
|
83761
|
-
return /*#__PURE__*/(0,jsx_runtime.jsx)(KnetApplePay, {
|
|
83762
|
-
country: country,
|
|
83763
|
-
paymentMethodsCount: paymentMethodsCount,
|
|
83764
|
-
countryCode: currency == null ? void 0 : currency.slice(0, 2),
|
|
83765
|
-
currency: currency,
|
|
83766
|
-
amount: (_amount$toString = amount.toString()) == null ? void 0 : _amount$toString.replace(/,/g, ''),
|
|
83767
|
-
merchantName: merchantName,
|
|
83768
|
-
paymentToken: (applePay == null ? void 0 : applePay.token) || '',
|
|
83769
|
-
integrationId: (applePay == null ? void 0 : applePay.id) || '',
|
|
83770
|
-
validatemerchant: knetApplePayServices_validatemerchant,
|
|
83771
|
-
knetApplePayPayment: knetApplePayServices_knetApplePayPayment,
|
|
83772
|
-
onSubmit: handleSubmit,
|
|
83773
|
-
onBeforePaymentComplete: data => {
|
|
83774
|
-
onPaymentStart == null || onPaymentStart(payment.type);
|
|
83775
|
-
return onBeforePaymentComplete == null ? void 0 : onBeforePaymentComplete(data);
|
|
83776
|
-
},
|
|
83777
|
-
onAfterPaymentComplete: onAfterPaymentComplete,
|
|
83778
|
-
onPaymentCancel: () => {
|
|
83779
|
-
onPaymentEnd == null || onPaymentEnd();
|
|
83780
|
-
onPaymentCancel == null || onPaymentCancel();
|
|
83781
|
-
},
|
|
83782
|
-
customStyle: customStyle,
|
|
83783
|
-
isLoading: isLoading,
|
|
83784
|
-
paymentName: payment.name,
|
|
83785
|
-
EquivalentAmount: KnetEquivalentAmount !== null ? String(KnetEquivalentAmount) : undefined,
|
|
83786
|
-
KnetCurrency: KnetCurrency,
|
|
83787
|
-
minAmount: KnetMinTransactionAmount
|
|
83788
|
-
});
|
|
83789
|
-
}
|
|
83790
|
-
/* harmony default export */ const components_Payments_KnetApplePay = (KnetApplePay_KnetApplePayElement);
|
|
83791
|
-
;// ../../apps/elements/src/utils/renderSelectedPaymentMethod.tsx
|
|
83792
|
-
|
|
83793
|
-
|
|
83794
|
-
|
|
83795
|
-
|
|
83796
|
-
const renderSelectedPaymentMethod_renderSelectedPaymentMethod = (selectedPaymentMethod, restProps = {}) => {
|
|
83797
|
-
if (selectedPaymentMethod) {
|
|
83798
|
-
switch (selectedPaymentMethod.type.toUpperCase()) {
|
|
83799
|
-
case 'CARD':
|
|
83800
|
-
case 'CARD-AUTH':
|
|
83801
|
-
return /*#__PURE__*/(0,jsx_runtime.jsx)(components_Payments_Card, Object.assign({}, restProps, {
|
|
83802
|
-
payment: selectedPaymentMethod
|
|
83803
|
-
}));
|
|
83804
|
-
case 'KNET':
|
|
83805
|
-
return /*#__PURE__*/(0,jsx_runtime.jsx)(components_Payments_Knet, Object.assign({}, restProps, {
|
|
83806
|
-
payment: selectedPaymentMethod
|
|
83807
|
-
}));
|
|
83808
|
-
case 'KNET-APPLE-PAY':
|
|
83809
|
-
return /*#__PURE__*/(0,jsx_runtime.jsx)(components_Payments_KnetApplePay, Object.assign({}, restProps, {
|
|
83810
|
-
payment: selectedPaymentMethod
|
|
83811
|
-
}));
|
|
83812
|
-
}
|
|
83813
|
-
}
|
|
83814
|
-
return;
|
|
83815
|
-
};
|
|
83816
|
-
;// ./src/components/Payments/List/index.tsx
|
|
83817
|
-
|
|
83818
|
-
|
|
83819
|
-
|
|
83820
|
-
|
|
83821
|
-
|
|
83822
|
-
|
|
83823
|
-
|
|
83824
|
-
|
|
83825
|
-
|
|
83826
|
-
|
|
83827
|
-
|
|
83828
|
-
|
|
83829
|
-
|
|
83830
|
-
|
|
83831
|
-
|
|
83832
|
-
const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
83833
|
-
var _customStyle$containe;
|
|
83834
|
-
const {
|
|
83835
|
-
payments,
|
|
83836
|
-
customStyle,
|
|
83837
|
-
baseUrl,
|
|
83838
|
-
savedCards,
|
|
83839
|
-
forceSaveCard,
|
|
83840
|
-
showSaveCard,
|
|
83841
|
-
disablePay,
|
|
83842
|
-
onBeforePaymentComplete,
|
|
83843
|
-
onAfterPaymentComplete,
|
|
83844
|
-
onPaymentCancel,
|
|
83845
|
-
onCardValidationChanged,
|
|
83846
|
-
showPaymobLogo,
|
|
83847
|
-
hideCardHolderName,
|
|
83848
|
-
publicKey,
|
|
83849
|
-
clientSecret,
|
|
83850
|
-
selectedPaymentMethods,
|
|
83851
|
-
integrationType,
|
|
83852
|
-
discounts,
|
|
83853
|
-
viewMode
|
|
83854
|
-
} = props;
|
|
83855
|
-
const {
|
|
83856
|
-
t
|
|
83857
|
-
} = useTranslation_useTranslation('flash', {
|
|
83858
|
-
keyPrefix: 'paymentsList'
|
|
83859
|
-
});
|
|
83860
|
-
const [paymentList, setPaymentList] = (0,react.useState)(payments);
|
|
83861
|
-
const [savedCardsList, setSavedCardsList] = (0,react.useState)(savedCards);
|
|
83862
|
-
const [errorMessage, setErrorMessage] = (0,react.useState)('');
|
|
83863
|
-
const [isLoading, setIsLoading] = (0,react.useState)(false);
|
|
83864
|
-
const [isPaymentInProgress, setIsPaymentInProgress] = (0,react.useState)(null);
|
|
83865
|
-
const country = getCountryByKeys(publicKey, clientSecret);
|
|
83866
|
-
const cardRef = (0,react.useRef)(null);
|
|
83867
|
-
(0,react.useImperativeHandle)(ref, () => ({
|
|
83868
|
-
getData: async () => {
|
|
83869
|
-
setIsLoading(true);
|
|
83870
|
-
const {
|
|
83871
|
-
res,
|
|
83872
|
-
paymentList,
|
|
83873
|
-
savedCards
|
|
83874
|
-
} = await fetchPayments(publicKey, clientSecret, selectedPaymentMethods);
|
|
83875
|
-
setIsLoading(false);
|
|
83876
|
-
if (res.status === 200) {
|
|
83877
|
-
setPaymentList(paymentList);
|
|
83878
|
-
setSavedCardsList(savedCards);
|
|
82601
|
+
const [isLoading, setIsLoading] = (0,react.useState)(false);
|
|
82602
|
+
const country = getCountryByKeys(publicKey, clientSecret);
|
|
82603
|
+
const cardRef = (0,react.useRef)(null);
|
|
82604
|
+
(0,react.useImperativeHandle)(ref, () => ({
|
|
82605
|
+
getData: async () => {
|
|
82606
|
+
setIsLoading(true);
|
|
82607
|
+
const {
|
|
82608
|
+
res,
|
|
82609
|
+
paymentList,
|
|
82610
|
+
savedCards
|
|
82611
|
+
} = await fetchPayments(publicKey, clientSecret, selectedPaymentMethods);
|
|
82612
|
+
setIsLoading(false);
|
|
82613
|
+
if (res.status === 200) {
|
|
82614
|
+
setPaymentList(paymentList);
|
|
82615
|
+
setSavedCardsList(savedCards);
|
|
83879
82616
|
}
|
|
83880
82617
|
return res;
|
|
83881
82618
|
},
|
|
@@ -83887,12 +82624,6 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
|
83887
82624
|
const handleOnBeforePaymentComplete = async paymentMethod => {
|
|
83888
82625
|
return await onBeforePaymentComplete(paymentMethod);
|
|
83889
82626
|
};
|
|
83890
|
-
const handlePaymentStart = paymentMethodType => {
|
|
83891
|
-
setIsPaymentInProgress(paymentMethodType);
|
|
83892
|
-
};
|
|
83893
|
-
const handlePaymentEnd = () => {
|
|
83894
|
-
setIsPaymentInProgress(null);
|
|
83895
|
-
};
|
|
83896
82627
|
const getFilteredPaymentList = () => {
|
|
83897
82628
|
return paymentList.filter(method => {
|
|
83898
82629
|
if (method.name === 'knet-apple-pay' && !isKnetApplePaySupported()) {
|
|
@@ -84000,7 +82731,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
|
84000
82731
|
})]
|
|
84001
82732
|
}), paymentMethods.length >= 1 && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
84002
82733
|
className: list_module['payments-list'],
|
|
84003
|
-
children: paymentMethods.length === 1 ?
|
|
82734
|
+
children: paymentMethods.length === 1 ? renderSelectedPaymentMethod(paymentMethods[0], {
|
|
84004
82735
|
customStyle,
|
|
84005
82736
|
paymentMethodsCount: paymentMethods.length,
|
|
84006
82737
|
baseUrl,
|
|
@@ -84018,10 +82749,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
|
84018
82749
|
integrationType,
|
|
84019
82750
|
publicKey,
|
|
84020
82751
|
ref: cardRef,
|
|
84021
|
-
discounts: discounts == null ? void 0 : discounts.cards
|
|
84022
|
-
isPaymentInProgress,
|
|
84023
|
-
onPaymentStart: handlePaymentStart,
|
|
84024
|
-
onPaymentEnd: handlePaymentEnd
|
|
82752
|
+
discounts: discounts == null ? void 0 : discounts.cards
|
|
84025
82753
|
}) : /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
|
|
84026
82754
|
children: viewMode === 'list' ? /*#__PURE__*/(0,jsx_runtime.jsx)(ListView, {
|
|
84027
82755
|
paymentMethods: paymentMethods,
|
|
@@ -84041,10 +82769,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
|
84041
82769
|
integrationType,
|
|
84042
82770
|
publicKey,
|
|
84043
82771
|
ref: cardRef,
|
|
84044
|
-
discounts: discounts == null ? void 0 : discounts.cards
|
|
84045
|
-
isPaymentInProgress,
|
|
84046
|
-
onPaymentStart: handlePaymentStart,
|
|
84047
|
-
onPaymentEnd: handlePaymentEnd
|
|
82772
|
+
discounts: discounts == null ? void 0 : discounts.cards
|
|
84048
82773
|
}) : /*#__PURE__*/(0,jsx_runtime.jsx)(List_TabView, {
|
|
84049
82774
|
paymentMethods: paymentMethods,
|
|
84050
82775
|
customStyle,
|
|
@@ -84063,10 +82788,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
|
|
|
84063
82788
|
integrationType,
|
|
84064
82789
|
publicKey,
|
|
84065
82790
|
ref: cardRef,
|
|
84066
|
-
discounts: discounts == null ? void 0 : discounts.cards
|
|
84067
|
-
isPaymentInProgress,
|
|
84068
|
-
onPaymentStart: handlePaymentStart,
|
|
84069
|
-
onPaymentEnd: handlePaymentEnd
|
|
82791
|
+
discounts: discounts == null ? void 0 : discounts.cards
|
|
84070
82792
|
})
|
|
84071
82793
|
})
|
|
84072
82794
|
})]
|