@miden-npm/react 2.1.5 → 2.1.6
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/dist/index.cjs +413 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +10 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +414 -251
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -750,6 +750,48 @@ async function authorizeCardPayment(environment, { merchantId, ...rest }, caller
|
|
|
750
750
|
} catch (error) {
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
|
+
async function validateCardPaymentOtp(environment, { merchantId, ...rest }, caller) {
|
|
754
|
+
try {
|
|
755
|
+
const baseUrl = getBaseUrl(environment, caller);
|
|
756
|
+
const apiKey = {
|
|
757
|
+
buzapay: "api/v1/checkout/card-payment/validate-otp",
|
|
758
|
+
miden: ""
|
|
759
|
+
};
|
|
760
|
+
const res = await fetch(`${baseUrl}/${apiKey[caller]}`, {
|
|
761
|
+
method: "POST",
|
|
762
|
+
headers: {
|
|
763
|
+
"Content-Type": "application/json",
|
|
764
|
+
Accept: "application/json",
|
|
765
|
+
merchantId,
|
|
766
|
+
uniqueKey: merchantId
|
|
767
|
+
},
|
|
768
|
+
body: JSON.stringify(rest)
|
|
769
|
+
});
|
|
770
|
+
return await res.json();
|
|
771
|
+
} catch (error) {
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
async function resendCardPaymentOtp(environment, { merchantId, ...rest }, caller) {
|
|
775
|
+
try {
|
|
776
|
+
const baseUrl = getBaseUrl(environment, caller);
|
|
777
|
+
const apiKey = {
|
|
778
|
+
buzapay: "api/v1/checkout/card-payment/resend-otp",
|
|
779
|
+
miden: ""
|
|
780
|
+
};
|
|
781
|
+
const res = await fetch(`${baseUrl}/${apiKey[caller]}`, {
|
|
782
|
+
method: "POST",
|
|
783
|
+
headers: {
|
|
784
|
+
"Content-Type": "application/json",
|
|
785
|
+
Accept: "application/json",
|
|
786
|
+
merchantId,
|
|
787
|
+
uniqueKey: merchantId
|
|
788
|
+
},
|
|
789
|
+
body: JSON.stringify(rest)
|
|
790
|
+
});
|
|
791
|
+
return await res.json();
|
|
792
|
+
} catch (error) {
|
|
793
|
+
}
|
|
794
|
+
}
|
|
753
795
|
async function getPaymentReferenceDetails(environment, paymentReference, caller) {
|
|
754
796
|
try {
|
|
755
797
|
const baseUrl = getBaseUrl(environment, caller);
|
|
@@ -2844,6 +2886,8 @@ function PayByCard({
|
|
|
2844
2886
|
const [formIndex, setFormIndex] = (0, import_react10.useState)(0);
|
|
2845
2887
|
const [message, setMessage] = (0, import_react10.useState)("");
|
|
2846
2888
|
const [isMakingPayment, setIsMakingPayment] = (0, import_react10.useState)(false);
|
|
2889
|
+
const [isSendingOtp, setIsSendingOtp] = (0, import_react10.useState)(false);
|
|
2890
|
+
const [isValidatingOtp, setIsValidatingOtp] = (0, import_react10.useState)(false);
|
|
2847
2891
|
const [loading, setLoading] = (0, import_react10.useState)(false);
|
|
2848
2892
|
const [defaultCountryCode, setDefaultCountryCode] = (0, import_react10.useState)("");
|
|
2849
2893
|
const [cardType, setCardType] = (0, import_react10.useState)("");
|
|
@@ -2876,10 +2920,14 @@ function PayByCard({
|
|
|
2876
2920
|
cardPin: ""
|
|
2877
2921
|
// Only required for Verve cards
|
|
2878
2922
|
});
|
|
2923
|
+
const [otpForm, setOtpForm] = (0, import_react10.useState)({
|
|
2924
|
+
otp: ""
|
|
2925
|
+
});
|
|
2879
2926
|
const [billingErrors, setBillingErrors] = (0, import_react10.useState)(
|
|
2880
2927
|
{}
|
|
2881
2928
|
);
|
|
2882
2929
|
const [payErrors, setPayErrors] = (0, import_react10.useState)({});
|
|
2930
|
+
const [otpErrors, setOtpErrors] = (0, import_react10.useState)({});
|
|
2883
2931
|
const billingRules = {
|
|
2884
2932
|
address1: "required",
|
|
2885
2933
|
address2: "",
|
|
@@ -2899,6 +2947,9 @@ function PayByCard({
|
|
|
2899
2947
|
cardPin: cardType === "Verve" ? "required" : ""
|
|
2900
2948
|
// optional unless Verve
|
|
2901
2949
|
};
|
|
2950
|
+
const otpRules = {
|
|
2951
|
+
otp: "required"
|
|
2952
|
+
};
|
|
2902
2953
|
const formatAmountHandler = formatAmount(
|
|
2903
2954
|
paymentObject.amount,
|
|
2904
2955
|
paymentObject.currency
|
|
@@ -2920,6 +2971,9 @@ function PayByCard({
|
|
|
2920
2971
|
cvv: "CVV",
|
|
2921
2972
|
cardPin: "Card PIN"
|
|
2922
2973
|
};
|
|
2974
|
+
const otpLabels = {
|
|
2975
|
+
otp: "OTP"
|
|
2976
|
+
};
|
|
2923
2977
|
const [threeDSOpen, setThreeDSOpen] = (0, import_react10.useState)(false);
|
|
2924
2978
|
const [threeDSIframeSrc, setThreeDSIframeSrc] = (0, import_react10.useState)("");
|
|
2925
2979
|
const messageListenerRef = (0, import_react10.useRef)();
|
|
@@ -2966,6 +3020,28 @@ function PayByCard({
|
|
|
2966
3020
|
}
|
|
2967
3021
|
};
|
|
2968
3022
|
}, []);
|
|
3023
|
+
const resendOtp = async () => {
|
|
3024
|
+
setIsSendingOtp(true);
|
|
3025
|
+
try {
|
|
3026
|
+
const response = await resendCardPaymentOtp(
|
|
3027
|
+
environment,
|
|
3028
|
+
{
|
|
3029
|
+
merchantId: secretKey,
|
|
3030
|
+
transactionReference
|
|
3031
|
+
},
|
|
3032
|
+
caller ?? "buzapay"
|
|
3033
|
+
);
|
|
3034
|
+
if (response?.isSuccessful) {
|
|
3035
|
+
setIsSendingOtp(false);
|
|
3036
|
+
import_react_hot_toast.default.success("OTP Sent Successfully.", toastConfig);
|
|
3037
|
+
}
|
|
3038
|
+
} catch (e) {
|
|
3039
|
+
setMessage(e?.message || "OTP Sending Failed");
|
|
3040
|
+
onError?.({ errorMessage: message });
|
|
3041
|
+
} finally {
|
|
3042
|
+
setIsSendingOtp(false);
|
|
3043
|
+
}
|
|
3044
|
+
};
|
|
2969
3045
|
const handleMidenProceed = async () => {
|
|
2970
3046
|
try {
|
|
2971
3047
|
setIsMakingPayment(true);
|
|
@@ -3087,6 +3163,11 @@ function PayByCard({
|
|
|
3087
3163
|
response = decryptPayload(environment, response.responseParam);
|
|
3088
3164
|
}
|
|
3089
3165
|
if (response?.isSuccessful) {
|
|
3166
|
+
if (response?.otpValidationRequired) {
|
|
3167
|
+
setIsMakingPayment(false);
|
|
3168
|
+
setFormIndex(2);
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3090
3171
|
if (caller === "miden") {
|
|
3091
3172
|
handleMidenCard(response);
|
|
3092
3173
|
return;
|
|
@@ -3178,6 +3259,37 @@ function PayByCard({
|
|
|
3178
3259
|
});
|
|
3179
3260
|
}
|
|
3180
3261
|
}
|
|
3262
|
+
if (formIndex === 2) {
|
|
3263
|
+
const errs = validateGroup(otpForm, otpRules, otpLabels);
|
|
3264
|
+
Object.assign(otpErrors, errs);
|
|
3265
|
+
if (Object.keys(errs).length > 0) return;
|
|
3266
|
+
setIsValidatingOtp(true);
|
|
3267
|
+
try {
|
|
3268
|
+
const response = await validateCardPaymentOtp(
|
|
3269
|
+
environment,
|
|
3270
|
+
{
|
|
3271
|
+
merchantId: secretKey,
|
|
3272
|
+
transactionReference,
|
|
3273
|
+
otp: otpForm.otp
|
|
3274
|
+
},
|
|
3275
|
+
caller ?? "buzapay"
|
|
3276
|
+
);
|
|
3277
|
+
if (response?.isSuccessful) {
|
|
3278
|
+
setIsValidatingOtp(false);
|
|
3279
|
+
onPaymentAuthorized?.({
|
|
3280
|
+
paymentId: transactionReference,
|
|
3281
|
+
paymentDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3282
|
+
paymentStatus: "authorized",
|
|
3283
|
+
message: response?.responseMessage
|
|
3284
|
+
});
|
|
3285
|
+
}
|
|
3286
|
+
} catch (e) {
|
|
3287
|
+
setMessage(e?.message || "Validate OTP Failed");
|
|
3288
|
+
onError?.({ errorMessage: message });
|
|
3289
|
+
} finally {
|
|
3290
|
+
setIsValidatingOtp(false);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3181
3293
|
};
|
|
3182
3294
|
const generatePaymentLinkHandler = async () => {
|
|
3183
3295
|
if (!secretKey) {
|
|
@@ -3297,260 +3409,311 @@ function PayByCard({
|
|
|
3297
3409
|
className: "w-full h-full",
|
|
3298
3410
|
sandbox: "allow-forms allow-scripts allow-same-origin allow-top-navigation"
|
|
3299
3411
|
}
|
|
3300
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", {
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
{
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
{
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
{
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
(
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
{
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
{
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
{
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3412
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
|
3413
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react_hot_toast.Toaster, {}),
|
|
3414
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
3415
|
+
formIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "grid grid-cols-2 gap-6 overflow-y-auto", children: [
|
|
3416
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3417
|
+
BaseInput,
|
|
3418
|
+
{
|
|
3419
|
+
label: "Address Line 1",
|
|
3420
|
+
required: true,
|
|
3421
|
+
value: billingForm.address1,
|
|
3422
|
+
onChange: (e) => {
|
|
3423
|
+
setBillingForm({ ...billingForm, address1: e });
|
|
3424
|
+
if (billingErrors.address1) {
|
|
3425
|
+
setBillingErrors((er) => ({ ...er, address1: "" }));
|
|
3426
|
+
}
|
|
3427
|
+
},
|
|
3428
|
+
validationError: billingErrors.address1 ?? ""
|
|
3429
|
+
}
|
|
3430
|
+
) }),
|
|
3431
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3432
|
+
BaseInput,
|
|
3433
|
+
{
|
|
3434
|
+
label: "Address Line 2",
|
|
3435
|
+
value: billingForm.address2,
|
|
3436
|
+
onChange: (e) => setBillingForm({ ...billingForm, address2: e }),
|
|
3437
|
+
validationError: billingErrors.address2 ?? ""
|
|
3438
|
+
}
|
|
3439
|
+
) }),
|
|
3440
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3441
|
+
BaseSelect,
|
|
3442
|
+
{
|
|
3443
|
+
label: "Select Country",
|
|
3444
|
+
required: true,
|
|
3445
|
+
options: countries,
|
|
3446
|
+
loading: loadingCountries,
|
|
3447
|
+
value: billingForm.country,
|
|
3448
|
+
onChange: (e) => {
|
|
3449
|
+
setBillingForm({ ...billingForm, country: e, state: "" });
|
|
3450
|
+
getStates(e);
|
|
3451
|
+
const selectedCountry = COUNTRIES.filter(
|
|
3452
|
+
(c) => c.code.toLowerCase() === e.toLowerCase()
|
|
3453
|
+
)[0];
|
|
3454
|
+
if (selectedCountry) {
|
|
3455
|
+
setDefaultCountryCode(
|
|
3456
|
+
`${selectedCountry.phoneCode}-${selectedCountry.code}`
|
|
3457
|
+
);
|
|
3458
|
+
}
|
|
3459
|
+
if (billingErrors.country) {
|
|
3460
|
+
setBillingErrors((er) => ({ ...er, country: "" }));
|
|
3461
|
+
}
|
|
3462
|
+
},
|
|
3463
|
+
validationError: billingErrors.country ?? ""
|
|
3464
|
+
}
|
|
3465
|
+
) }),
|
|
3466
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3467
|
+
BaseSelect,
|
|
3468
|
+
{
|
|
3469
|
+
label: "Select State",
|
|
3470
|
+
required: true,
|
|
3471
|
+
options: countryStates,
|
|
3472
|
+
loading: loadingStates,
|
|
3473
|
+
value: billingForm.state,
|
|
3474
|
+
onChange: (e) => {
|
|
3475
|
+
setBillingForm({ ...billingForm, state: e });
|
|
3476
|
+
if (billingErrors.state) {
|
|
3477
|
+
setBillingErrors((er) => ({ ...er, state: "" }));
|
|
3478
|
+
}
|
|
3479
|
+
},
|
|
3480
|
+
validationError: billingErrors.state ?? ""
|
|
3481
|
+
}
|
|
3482
|
+
) }),
|
|
3483
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3484
|
+
BaseInput,
|
|
3485
|
+
{
|
|
3486
|
+
label: "City",
|
|
3487
|
+
required: true,
|
|
3488
|
+
value: billingForm.city,
|
|
3489
|
+
onChange: (e) => {
|
|
3490
|
+
setBillingForm({ ...billingForm, city: e });
|
|
3491
|
+
if (billingErrors.city) {
|
|
3492
|
+
setBillingErrors((er) => ({ ...er, city: "" }));
|
|
3493
|
+
}
|
|
3494
|
+
},
|
|
3495
|
+
validationError: billingErrors.city ?? ""
|
|
3496
|
+
}
|
|
3497
|
+
) }),
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3499
|
+
BaseInput,
|
|
3500
|
+
{
|
|
3501
|
+
label: "Postal Code",
|
|
3502
|
+
required: true,
|
|
3503
|
+
value: billingForm.postalCode,
|
|
3504
|
+
onChange: (e) => {
|
|
3505
|
+
setBillingForm({ ...billingForm, postalCode: e });
|
|
3506
|
+
if (billingErrors.postalCode) {
|
|
3507
|
+
setBillingErrors((er) => ({ ...er, postalCode: "" }));
|
|
3508
|
+
}
|
|
3509
|
+
},
|
|
3510
|
+
validationError: billingErrors.postalCode ?? ""
|
|
3511
|
+
}
|
|
3512
|
+
) }),
|
|
3513
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3514
|
+
BaseInput,
|
|
3515
|
+
{
|
|
3516
|
+
label: "Email",
|
|
3517
|
+
required: true,
|
|
3518
|
+
value: billingForm.emailAddress,
|
|
3519
|
+
onChange: (e) => {
|
|
3520
|
+
setBillingForm({ ...billingForm, emailAddress: e });
|
|
3521
|
+
if (billingErrors.emailAddress) {
|
|
3522
|
+
setBillingErrors((er) => ({ ...er, emailAddress: "" }));
|
|
3523
|
+
}
|
|
3524
|
+
},
|
|
3525
|
+
validationError: billingErrors.emailAddress ?? ""
|
|
3526
|
+
}
|
|
3527
|
+
) }),
|
|
3528
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3529
|
+
BasePhoneNumberInput,
|
|
3530
|
+
{
|
|
3531
|
+
label: "Phone Number",
|
|
3532
|
+
required: true,
|
|
3533
|
+
preventPaste: true,
|
|
3534
|
+
value: billingForm.phoneNumber,
|
|
3535
|
+
phoneCodeOptions,
|
|
3536
|
+
defaultCountryCode,
|
|
3537
|
+
onChange: (e) => {
|
|
3538
|
+
setBillingForm({ ...billingForm, phoneNumber: e });
|
|
3539
|
+
if (billingErrors.phoneNumber) {
|
|
3540
|
+
setBillingErrors((er) => ({ ...er, phoneNumber: "" }));
|
|
3541
|
+
}
|
|
3542
|
+
},
|
|
3543
|
+
onCodeChange: (e) => {
|
|
3544
|
+
setBillingForm({ ...billingForm, phoneNumberExt: e });
|
|
3545
|
+
if (billingErrors.phoneNumberExt) {
|
|
3546
|
+
setBillingErrors((er) => ({ ...er, phoneNumberExt: "" }));
|
|
3547
|
+
}
|
|
3548
|
+
},
|
|
3549
|
+
validationError: billingErrors.phoneNumber ?? ""
|
|
3550
|
+
}
|
|
3551
|
+
) })
|
|
3552
|
+
] }),
|
|
3553
|
+
formIndex === 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3554
|
+
"div",
|
|
3401
3555
|
{
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3556
|
+
className: "grid grid-cols-2 gap-6 overflow-y-auto",
|
|
3557
|
+
style: { maxHeight: 320 },
|
|
3558
|
+
children: [
|
|
3559
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3560
|
+
BaseInput,
|
|
3561
|
+
{
|
|
3562
|
+
label: "Card Name",
|
|
3563
|
+
required: true,
|
|
3564
|
+
value: payForm.customerName,
|
|
3565
|
+
onChange: (e) => {
|
|
3566
|
+
setPayForm({ ...payForm, customerName: e });
|
|
3567
|
+
if (payErrors.customerName) {
|
|
3568
|
+
setPayErrors((er) => ({ ...er, customerName: "" }));
|
|
3569
|
+
}
|
|
3570
|
+
},
|
|
3571
|
+
validationError: payErrors.customerName ?? ""
|
|
3572
|
+
}
|
|
3573
|
+
) }),
|
|
3574
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3575
|
+
BaseInput,
|
|
3576
|
+
{
|
|
3577
|
+
label: "Card Number",
|
|
3578
|
+
required: true,
|
|
3579
|
+
rules: ["numeric"],
|
|
3580
|
+
mask: "0000 0000 0000 0000 000",
|
|
3581
|
+
placeholder: "0000 0000 0000 0000",
|
|
3582
|
+
value: payForm.cardNo,
|
|
3583
|
+
preventPaste: true,
|
|
3584
|
+
onChange: (e) => {
|
|
3585
|
+
setPayForm({ ...payForm, cardNo: e });
|
|
3586
|
+
if (payErrors.cardNo)
|
|
3587
|
+
setPayErrors((er) => ({ ...er, cardNo: "" }));
|
|
3588
|
+
cardNumberInputHandler(e);
|
|
3589
|
+
},
|
|
3590
|
+
validationError: payErrors.cardNo ?? ""
|
|
3591
|
+
}
|
|
3592
|
+
) }),
|
|
3593
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3594
|
+
BaseInput,
|
|
3595
|
+
{
|
|
3596
|
+
label: "Expiry Date",
|
|
3597
|
+
required: true,
|
|
3598
|
+
value: payForm.expireDate,
|
|
3599
|
+
mask: "00/00",
|
|
3600
|
+
placeholder: "00/00",
|
|
3601
|
+
onChange: (e) => {
|
|
3602
|
+
setPayForm({ ...payForm, expireDate: e });
|
|
3603
|
+
if (payErrors.expireDate)
|
|
3604
|
+
setPayErrors((er) => ({ ...er, expireDate: "" }));
|
|
3605
|
+
},
|
|
3606
|
+
validationError: payErrors.expireDate ?? ""
|
|
3607
|
+
}
|
|
3608
|
+
),
|
|
3609
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3610
|
+
BaseInput,
|
|
3611
|
+
{
|
|
3612
|
+
label: "CVV",
|
|
3613
|
+
required: true,
|
|
3614
|
+
rules: ["numeric"],
|
|
3615
|
+
value: payForm.cvv,
|
|
3616
|
+
mask: "000",
|
|
3617
|
+
placeholder: "000",
|
|
3618
|
+
onChange: (e) => {
|
|
3619
|
+
setPayForm({ ...payForm, cvv: e });
|
|
3620
|
+
if (payErrors.cvv) setPayErrors((er) => ({ ...er, cvv: "" }));
|
|
3621
|
+
},
|
|
3622
|
+
validationError: payErrors.cvv ?? ""
|
|
3623
|
+
}
|
|
3624
|
+
),
|
|
3625
|
+
cardType === "Verve" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3626
|
+
BaseInput,
|
|
3627
|
+
{
|
|
3628
|
+
label: "Card Pin",
|
|
3629
|
+
required: true,
|
|
3630
|
+
rules: ["numeric"],
|
|
3631
|
+
value: payForm.cardPin,
|
|
3632
|
+
mask: "0000",
|
|
3633
|
+
placeholder: "0000",
|
|
3634
|
+
onChange: (e) => {
|
|
3635
|
+
setPayForm({ ...payForm, cardPin: e });
|
|
3636
|
+
if (payErrors.cardPin)
|
|
3637
|
+
setPayErrors((er) => ({ ...er, cardPin: "" }));
|
|
3638
|
+
},
|
|
3639
|
+
validationError: payErrors.cardPin ?? ""
|
|
3640
|
+
}
|
|
3641
|
+
)
|
|
3642
|
+
]
|
|
3412
3643
|
}
|
|
3413
|
-
)
|
|
3414
|
-
|
|
3415
|
-
|
|
3644
|
+
),
|
|
3645
|
+
formIndex === 2 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3646
|
+
"div",
|
|
3416
3647
|
{
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
BaseInput,
|
|
3447
|
-
{
|
|
3448
|
-
label: "Card Name",
|
|
3449
|
-
required: true,
|
|
3450
|
-
value: payForm.customerName,
|
|
3451
|
-
onChange: (e) => {
|
|
3452
|
-
setPayForm({ ...payForm, customerName: e });
|
|
3453
|
-
if (payErrors.customerName) {
|
|
3454
|
-
setPayErrors((er) => ({ ...er, customerName: "" }));
|
|
3648
|
+
className: "grid grid-cols-2 gap-6 overflow-y-auto",
|
|
3649
|
+
style: { maxHeight: 320 },
|
|
3650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "col-span-2", children: [
|
|
3651
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3652
|
+
BaseInput,
|
|
3653
|
+
{
|
|
3654
|
+
label: "OTP",
|
|
3655
|
+
required: true,
|
|
3656
|
+
value: otpForm.otp,
|
|
3657
|
+
onChange: (e) => {
|
|
3658
|
+
setOtpForm({ ...otpForm, otp: e });
|
|
3659
|
+
if (otpErrors.otp) {
|
|
3660
|
+
setOtpErrors((er) => ({ ...er, otp: "" }));
|
|
3661
|
+
}
|
|
3662
|
+
},
|
|
3663
|
+
validationError: otpErrors.otp ?? ""
|
|
3664
|
+
}
|
|
3665
|
+
),
|
|
3666
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "text-primary text-sm mt-2", children: [
|
|
3667
|
+
"Didn't get OTP?",
|
|
3668
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3669
|
+
"span",
|
|
3670
|
+
{
|
|
3671
|
+
className: isSendingOtp ? "ml-1" : "ml-1 underline cursor-pointer",
|
|
3672
|
+
onClick: () => {
|
|
3673
|
+
if (isSendingOtp) return;
|
|
3674
|
+
resendOtp();
|
|
3675
|
+
},
|
|
3676
|
+
children: isSendingOtp ? "Sending..." : "Resend OTP"
|
|
3455
3677
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
) }),
|
|
3460
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3461
|
-
BaseInput,
|
|
3462
|
-
{
|
|
3463
|
-
label: "Card Number",
|
|
3464
|
-
required: true,
|
|
3465
|
-
rules: ["numeric"],
|
|
3466
|
-
mask: "0000 0000 0000 0000 000",
|
|
3467
|
-
placeholder: "0000 0000 0000 0000",
|
|
3468
|
-
value: payForm.cardNo,
|
|
3469
|
-
preventPaste: true,
|
|
3470
|
-
onChange: (e) => {
|
|
3471
|
-
setPayForm({ ...payForm, cardNo: e });
|
|
3472
|
-
if (payErrors.cardNo)
|
|
3473
|
-
setPayErrors((er) => ({ ...er, cardNo: "" }));
|
|
3474
|
-
cardNumberInputHandler(e);
|
|
3475
|
-
},
|
|
3476
|
-
validationError: payErrors.cardNo ?? ""
|
|
3477
|
-
}
|
|
3478
|
-
) }),
|
|
3479
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3480
|
-
BaseInput,
|
|
3481
|
-
{
|
|
3482
|
-
label: "Expiry Date",
|
|
3483
|
-
required: true,
|
|
3484
|
-
value: payForm.expireDate,
|
|
3485
|
-
mask: "00/00",
|
|
3486
|
-
placeholder: "00/00",
|
|
3487
|
-
onChange: (e) => {
|
|
3488
|
-
setPayForm({ ...payForm, expireDate: e });
|
|
3489
|
-
if (payErrors.expireDate)
|
|
3490
|
-
setPayErrors((er) => ({ ...er, expireDate: "" }));
|
|
3491
|
-
},
|
|
3492
|
-
validationError: payErrors.expireDate ?? ""
|
|
3493
|
-
}
|
|
3494
|
-
),
|
|
3495
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3496
|
-
BaseInput,
|
|
3497
|
-
{
|
|
3498
|
-
label: "CVV",
|
|
3499
|
-
required: true,
|
|
3500
|
-
rules: ["numeric"],
|
|
3501
|
-
value: payForm.cvv,
|
|
3502
|
-
mask: "000",
|
|
3503
|
-
placeholder: "000",
|
|
3504
|
-
onChange: (e) => {
|
|
3505
|
-
setPayForm({ ...payForm, cvv: e });
|
|
3506
|
-
if (payErrors.cvv) setPayErrors((er) => ({ ...er, cvv: "" }));
|
|
3507
|
-
},
|
|
3508
|
-
validationError: payErrors.cvv ?? ""
|
|
3509
|
-
}
|
|
3510
|
-
),
|
|
3511
|
-
cardType === "Verve" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3512
|
-
BaseInput,
|
|
3513
|
-
{
|
|
3514
|
-
label: "Card Pin",
|
|
3515
|
-
required: true,
|
|
3516
|
-
rules: ["numeric"],
|
|
3517
|
-
value: payForm.cardPin,
|
|
3518
|
-
mask: "0000",
|
|
3519
|
-
placeholder: "0000",
|
|
3520
|
-
onChange: (e) => {
|
|
3521
|
-
setPayForm({ ...payForm, cardPin: e });
|
|
3522
|
-
if (payErrors.cardPin)
|
|
3523
|
-
setPayErrors((er) => ({ ...er, cardPin: "" }));
|
|
3524
|
-
},
|
|
3525
|
-
validationError: payErrors.cardPin ?? ""
|
|
3526
|
-
}
|
|
3527
|
-
)
|
|
3528
|
-
]
|
|
3529
|
-
}
|
|
3530
|
-
),
|
|
3531
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center justify-between gap-4 mt-6", children: [
|
|
3532
|
-
formIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3533
|
-
BaseButton,
|
|
3534
|
-
{
|
|
3535
|
-
label: "Previous",
|
|
3536
|
-
type: "secondary",
|
|
3537
|
-
customClass: "w-1/2",
|
|
3538
|
-
caller,
|
|
3539
|
-
onClick: goBack
|
|
3678
|
+
)
|
|
3679
|
+
] })
|
|
3680
|
+
] })
|
|
3540
3681
|
}
|
|
3541
3682
|
),
|
|
3542
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3683
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center justify-between gap-4 mt-6", children: [
|
|
3684
|
+
formIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3685
|
+
BaseButton,
|
|
3686
|
+
{
|
|
3687
|
+
label: "Previous",
|
|
3688
|
+
type: "secondary",
|
|
3689
|
+
customClass: "w-1/2",
|
|
3690
|
+
caller,
|
|
3691
|
+
onClick: goBack
|
|
3692
|
+
}
|
|
3693
|
+
),
|
|
3694
|
+
formIndex < 2 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3695
|
+
BaseButton,
|
|
3696
|
+
{
|
|
3697
|
+
label: formIndex === 0 ? "Proceed" : `Pay ${formatAmountHandler}`,
|
|
3698
|
+
type: "primary",
|
|
3699
|
+
customClass: `${formIndex > 0 ? "w-1/2" : "w-full"}`,
|
|
3700
|
+
caller,
|
|
3701
|
+
loading: isMakingPayment,
|
|
3702
|
+
onClick: proceedHandler,
|
|
3703
|
+
disabled: isMakingPayment
|
|
3704
|
+
}
|
|
3705
|
+
),
|
|
3706
|
+
formIndex === 2 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "w-1/2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3707
|
+
BaseButton,
|
|
3708
|
+
{
|
|
3709
|
+
label: "Validate OTP",
|
|
3710
|
+
type: "primary",
|
|
3711
|
+
caller,
|
|
3712
|
+
loading: isValidatingOtp,
|
|
3713
|
+
onClick: proceedHandler
|
|
3714
|
+
}
|
|
3715
|
+
) })
|
|
3716
|
+
] })
|
|
3554
3717
|
] })
|
|
3555
3718
|
] });
|
|
3556
3719
|
}
|
|
@@ -3622,7 +3785,7 @@ var PayByTransfer = ({
|
|
|
3622
3785
|
);
|
|
3623
3786
|
startTimer();
|
|
3624
3787
|
setMessage("Virtual account generated successfully for payment.");
|
|
3625
|
-
setIsMakingPayment(
|
|
3788
|
+
setIsMakingPayment(false);
|
|
3626
3789
|
setFormIndex(1);
|
|
3627
3790
|
} else {
|
|
3628
3791
|
setIsMakingPayment(false);
|
|
@@ -3904,7 +4067,7 @@ var PayByTransfer = ({
|
|
|
3904
4067
|
"button",
|
|
3905
4068
|
{
|
|
3906
4069
|
type: "button",
|
|
3907
|
-
onClick:
|
|
4070
|
+
onClick: () => setFormIndex(0),
|
|
3908
4071
|
className: "text-heading-text text-body-2xs font-medium text-center py-2 cursor-pointer",
|
|
3909
4072
|
children: "Cancel Payment"
|
|
3910
4073
|
}
|