@miden-npm/react 2.1.4 → 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 +438 -265
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +10 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +439 -266
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -705,6 +705,48 @@ async function authorizeCardPayment(environment, { merchantId, ...rest }, caller
|
|
|
705
705
|
} catch (error) {
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
+
async function validateCardPaymentOtp(environment, { merchantId, ...rest }, caller) {
|
|
709
|
+
try {
|
|
710
|
+
const baseUrl = getBaseUrl(environment, caller);
|
|
711
|
+
const apiKey = {
|
|
712
|
+
buzapay: "api/v1/checkout/card-payment/validate-otp",
|
|
713
|
+
miden: ""
|
|
714
|
+
};
|
|
715
|
+
const res = await fetch(`${baseUrl}/${apiKey[caller]}`, {
|
|
716
|
+
method: "POST",
|
|
717
|
+
headers: {
|
|
718
|
+
"Content-Type": "application/json",
|
|
719
|
+
Accept: "application/json",
|
|
720
|
+
merchantId,
|
|
721
|
+
uniqueKey: merchantId
|
|
722
|
+
},
|
|
723
|
+
body: JSON.stringify(rest)
|
|
724
|
+
});
|
|
725
|
+
return await res.json();
|
|
726
|
+
} catch (error) {
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
async function resendCardPaymentOtp(environment, { merchantId, ...rest }, caller) {
|
|
730
|
+
try {
|
|
731
|
+
const baseUrl = getBaseUrl(environment, caller);
|
|
732
|
+
const apiKey = {
|
|
733
|
+
buzapay: "api/v1/checkout/card-payment/resend-otp",
|
|
734
|
+
miden: ""
|
|
735
|
+
};
|
|
736
|
+
const res = await fetch(`${baseUrl}/${apiKey[caller]}`, {
|
|
737
|
+
method: "POST",
|
|
738
|
+
headers: {
|
|
739
|
+
"Content-Type": "application/json",
|
|
740
|
+
Accept: "application/json",
|
|
741
|
+
merchantId,
|
|
742
|
+
uniqueKey: merchantId
|
|
743
|
+
},
|
|
744
|
+
body: JSON.stringify(rest)
|
|
745
|
+
});
|
|
746
|
+
return await res.json();
|
|
747
|
+
} catch (error) {
|
|
748
|
+
}
|
|
749
|
+
}
|
|
708
750
|
async function getPaymentReferenceDetails(environment, paymentReference, caller) {
|
|
709
751
|
try {
|
|
710
752
|
const baseUrl = getBaseUrl(environment, caller);
|
|
@@ -2786,7 +2828,7 @@ var BasePhoneNumberInput = ({
|
|
|
2786
2828
|
};
|
|
2787
2829
|
|
|
2788
2830
|
// src/components/pay-by-card.tsx
|
|
2789
|
-
import toast from "react-hot-toast";
|
|
2831
|
+
import toast, { Toaster } from "react-hot-toast";
|
|
2790
2832
|
import { jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2791
2833
|
function PayByCard({
|
|
2792
2834
|
secretKey,
|
|
@@ -2799,6 +2841,8 @@ function PayByCard({
|
|
|
2799
2841
|
const [formIndex, setFormIndex] = useState4(0);
|
|
2800
2842
|
const [message, setMessage] = useState4("");
|
|
2801
2843
|
const [isMakingPayment, setIsMakingPayment] = useState4(false);
|
|
2844
|
+
const [isSendingOtp, setIsSendingOtp] = useState4(false);
|
|
2845
|
+
const [isValidatingOtp, setIsValidatingOtp] = useState4(false);
|
|
2802
2846
|
const [loading, setLoading] = useState4(false);
|
|
2803
2847
|
const [defaultCountryCode, setDefaultCountryCode] = useState4("");
|
|
2804
2848
|
const [cardType, setCardType] = useState4("");
|
|
@@ -2831,10 +2875,14 @@ function PayByCard({
|
|
|
2831
2875
|
cardPin: ""
|
|
2832
2876
|
// Only required for Verve cards
|
|
2833
2877
|
});
|
|
2878
|
+
const [otpForm, setOtpForm] = useState4({
|
|
2879
|
+
otp: ""
|
|
2880
|
+
});
|
|
2834
2881
|
const [billingErrors, setBillingErrors] = useState4(
|
|
2835
2882
|
{}
|
|
2836
2883
|
);
|
|
2837
2884
|
const [payErrors, setPayErrors] = useState4({});
|
|
2885
|
+
const [otpErrors, setOtpErrors] = useState4({});
|
|
2838
2886
|
const billingRules = {
|
|
2839
2887
|
address1: "required",
|
|
2840
2888
|
address2: "",
|
|
@@ -2851,9 +2899,12 @@ function PayByCard({
|
|
|
2851
2899
|
cardNo: "required|num_spaces",
|
|
2852
2900
|
expireDate: "required",
|
|
2853
2901
|
cvv: "required|numeric",
|
|
2854
|
-
cardPin: ""
|
|
2902
|
+
cardPin: cardType === "Verve" ? "required" : ""
|
|
2855
2903
|
// optional unless Verve
|
|
2856
2904
|
};
|
|
2905
|
+
const otpRules = {
|
|
2906
|
+
otp: "required"
|
|
2907
|
+
};
|
|
2857
2908
|
const formatAmountHandler = formatAmount(
|
|
2858
2909
|
paymentObject.amount,
|
|
2859
2910
|
paymentObject.currency
|
|
@@ -2875,6 +2926,9 @@ function PayByCard({
|
|
|
2875
2926
|
cvv: "CVV",
|
|
2876
2927
|
cardPin: "Card PIN"
|
|
2877
2928
|
};
|
|
2929
|
+
const otpLabels = {
|
|
2930
|
+
otp: "OTP"
|
|
2931
|
+
};
|
|
2878
2932
|
const [threeDSOpen, setThreeDSOpen] = useState4(false);
|
|
2879
2933
|
const [threeDSIframeSrc, setThreeDSIframeSrc] = useState4("");
|
|
2880
2934
|
const messageListenerRef = useRef2();
|
|
@@ -2921,6 +2975,28 @@ function PayByCard({
|
|
|
2921
2975
|
}
|
|
2922
2976
|
};
|
|
2923
2977
|
}, []);
|
|
2978
|
+
const resendOtp = async () => {
|
|
2979
|
+
setIsSendingOtp(true);
|
|
2980
|
+
try {
|
|
2981
|
+
const response = await resendCardPaymentOtp(
|
|
2982
|
+
environment,
|
|
2983
|
+
{
|
|
2984
|
+
merchantId: secretKey,
|
|
2985
|
+
transactionReference
|
|
2986
|
+
},
|
|
2987
|
+
caller ?? "buzapay"
|
|
2988
|
+
);
|
|
2989
|
+
if (response?.isSuccessful) {
|
|
2990
|
+
setIsSendingOtp(false);
|
|
2991
|
+
toast.success("OTP Sent Successfully.", toastConfig);
|
|
2992
|
+
}
|
|
2993
|
+
} catch (e) {
|
|
2994
|
+
setMessage(e?.message || "OTP Sending Failed");
|
|
2995
|
+
onError?.({ errorMessage: message });
|
|
2996
|
+
} finally {
|
|
2997
|
+
setIsSendingOtp(false);
|
|
2998
|
+
}
|
|
2999
|
+
};
|
|
2924
3000
|
const handleMidenProceed = async () => {
|
|
2925
3001
|
try {
|
|
2926
3002
|
setIsMakingPayment(true);
|
|
@@ -3042,6 +3118,11 @@ function PayByCard({
|
|
|
3042
3118
|
response = decryptPayload(environment, response.responseParam);
|
|
3043
3119
|
}
|
|
3044
3120
|
if (response?.isSuccessful) {
|
|
3121
|
+
if (response?.otpValidationRequired) {
|
|
3122
|
+
setIsMakingPayment(false);
|
|
3123
|
+
setFormIndex(2);
|
|
3124
|
+
return;
|
|
3125
|
+
}
|
|
3045
3126
|
if (caller === "miden") {
|
|
3046
3127
|
handleMidenCard(response);
|
|
3047
3128
|
return;
|
|
@@ -3104,11 +3185,11 @@ function PayByCard({
|
|
|
3104
3185
|
setIsMakingPayment(false);
|
|
3105
3186
|
return;
|
|
3106
3187
|
}
|
|
3107
|
-
if (response && response.
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
});
|
|
3188
|
+
if (response && !response.isSuccessful && caller === "miden") {
|
|
3189
|
+
onError?.({ errorMessage: response.responseMessage });
|
|
3190
|
+
}
|
|
3191
|
+
if (response && response.message && caller === "buzapay") {
|
|
3192
|
+
onError?.({ errorMessage: response.message });
|
|
3112
3193
|
}
|
|
3113
3194
|
setIsMakingPayment(false);
|
|
3114
3195
|
} catch (err) {
|
|
@@ -3133,6 +3214,37 @@ function PayByCard({
|
|
|
3133
3214
|
});
|
|
3134
3215
|
}
|
|
3135
3216
|
}
|
|
3217
|
+
if (formIndex === 2) {
|
|
3218
|
+
const errs = validateGroup(otpForm, otpRules, otpLabels);
|
|
3219
|
+
Object.assign(otpErrors, errs);
|
|
3220
|
+
if (Object.keys(errs).length > 0) return;
|
|
3221
|
+
setIsValidatingOtp(true);
|
|
3222
|
+
try {
|
|
3223
|
+
const response = await validateCardPaymentOtp(
|
|
3224
|
+
environment,
|
|
3225
|
+
{
|
|
3226
|
+
merchantId: secretKey,
|
|
3227
|
+
transactionReference,
|
|
3228
|
+
otp: otpForm.otp
|
|
3229
|
+
},
|
|
3230
|
+
caller ?? "buzapay"
|
|
3231
|
+
);
|
|
3232
|
+
if (response?.isSuccessful) {
|
|
3233
|
+
setIsValidatingOtp(false);
|
|
3234
|
+
onPaymentAuthorized?.({
|
|
3235
|
+
paymentId: transactionReference,
|
|
3236
|
+
paymentDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3237
|
+
paymentStatus: "authorized",
|
|
3238
|
+
message: response?.responseMessage
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
} catch (e) {
|
|
3242
|
+
setMessage(e?.message || "Validate OTP Failed");
|
|
3243
|
+
onError?.({ errorMessage: message });
|
|
3244
|
+
} finally {
|
|
3245
|
+
setIsValidatingOtp(false);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3136
3248
|
};
|
|
3137
3249
|
const generatePaymentLinkHandler = async () => {
|
|
3138
3250
|
if (!secretKey) {
|
|
@@ -3252,260 +3364,311 @@ function PayByCard({
|
|
|
3252
3364
|
className: "w-full h-full",
|
|
3253
3365
|
sandbox: "allow-forms allow-scripts allow-same-origin allow-top-navigation"
|
|
3254
3366
|
}
|
|
3255
|
-
) }) : /* @__PURE__ */ jsxs24("div", {
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
{
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
{
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
{
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
(
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
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
|
-
|
|
3367
|
+
) }) : /* @__PURE__ */ jsxs24("div", { children: [
|
|
3368
|
+
/* @__PURE__ */ jsx36(Toaster, {}),
|
|
3369
|
+
/* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-6", children: [
|
|
3370
|
+
formIndex === 0 && /* @__PURE__ */ jsxs24("div", { className: "grid grid-cols-2 gap-6 overflow-y-auto", children: [
|
|
3371
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3372
|
+
BaseInput,
|
|
3373
|
+
{
|
|
3374
|
+
label: "Address Line 1",
|
|
3375
|
+
required: true,
|
|
3376
|
+
value: billingForm.address1,
|
|
3377
|
+
onChange: (e) => {
|
|
3378
|
+
setBillingForm({ ...billingForm, address1: e });
|
|
3379
|
+
if (billingErrors.address1) {
|
|
3380
|
+
setBillingErrors((er) => ({ ...er, address1: "" }));
|
|
3381
|
+
}
|
|
3382
|
+
},
|
|
3383
|
+
validationError: billingErrors.address1 ?? ""
|
|
3384
|
+
}
|
|
3385
|
+
) }),
|
|
3386
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3387
|
+
BaseInput,
|
|
3388
|
+
{
|
|
3389
|
+
label: "Address Line 2",
|
|
3390
|
+
value: billingForm.address2,
|
|
3391
|
+
onChange: (e) => setBillingForm({ ...billingForm, address2: e }),
|
|
3392
|
+
validationError: billingErrors.address2 ?? ""
|
|
3393
|
+
}
|
|
3394
|
+
) }),
|
|
3395
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ jsx36(
|
|
3396
|
+
BaseSelect,
|
|
3397
|
+
{
|
|
3398
|
+
label: "Select Country",
|
|
3399
|
+
required: true,
|
|
3400
|
+
options: countries,
|
|
3401
|
+
loading: loadingCountries,
|
|
3402
|
+
value: billingForm.country,
|
|
3403
|
+
onChange: (e) => {
|
|
3404
|
+
setBillingForm({ ...billingForm, country: e, state: "" });
|
|
3405
|
+
getStates(e);
|
|
3406
|
+
const selectedCountry = COUNTRIES.filter(
|
|
3407
|
+
(c) => c.code.toLowerCase() === e.toLowerCase()
|
|
3408
|
+
)[0];
|
|
3409
|
+
if (selectedCountry) {
|
|
3410
|
+
setDefaultCountryCode(
|
|
3411
|
+
`${selectedCountry.phoneCode}-${selectedCountry.code}`
|
|
3412
|
+
);
|
|
3413
|
+
}
|
|
3414
|
+
if (billingErrors.country) {
|
|
3415
|
+
setBillingErrors((er) => ({ ...er, country: "" }));
|
|
3416
|
+
}
|
|
3417
|
+
},
|
|
3418
|
+
validationError: billingErrors.country ?? ""
|
|
3419
|
+
}
|
|
3420
|
+
) }),
|
|
3421
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ jsx36(
|
|
3422
|
+
BaseSelect,
|
|
3423
|
+
{
|
|
3424
|
+
label: "Select State",
|
|
3425
|
+
required: true,
|
|
3426
|
+
options: countryStates,
|
|
3427
|
+
loading: loadingStates,
|
|
3428
|
+
value: billingForm.state,
|
|
3429
|
+
onChange: (e) => {
|
|
3430
|
+
setBillingForm({ ...billingForm, state: e });
|
|
3431
|
+
if (billingErrors.state) {
|
|
3432
|
+
setBillingErrors((er) => ({ ...er, state: "" }));
|
|
3433
|
+
}
|
|
3434
|
+
},
|
|
3435
|
+
validationError: billingErrors.state ?? ""
|
|
3436
|
+
}
|
|
3437
|
+
) }),
|
|
3438
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ jsx36(
|
|
3439
|
+
BaseInput,
|
|
3440
|
+
{
|
|
3441
|
+
label: "City",
|
|
3442
|
+
required: true,
|
|
3443
|
+
value: billingForm.city,
|
|
3444
|
+
onChange: (e) => {
|
|
3445
|
+
setBillingForm({ ...billingForm, city: e });
|
|
3446
|
+
if (billingErrors.city) {
|
|
3447
|
+
setBillingErrors((er) => ({ ...er, city: "" }));
|
|
3448
|
+
}
|
|
3449
|
+
},
|
|
3450
|
+
validationError: billingErrors.city ?? ""
|
|
3451
|
+
}
|
|
3452
|
+
) }),
|
|
3453
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ jsx36(
|
|
3454
|
+
BaseInput,
|
|
3455
|
+
{
|
|
3456
|
+
label: "Postal Code",
|
|
3457
|
+
required: true,
|
|
3458
|
+
value: billingForm.postalCode,
|
|
3459
|
+
onChange: (e) => {
|
|
3460
|
+
setBillingForm({ ...billingForm, postalCode: e });
|
|
3461
|
+
if (billingErrors.postalCode) {
|
|
3462
|
+
setBillingErrors((er) => ({ ...er, postalCode: "" }));
|
|
3463
|
+
}
|
|
3464
|
+
},
|
|
3465
|
+
validationError: billingErrors.postalCode ?? ""
|
|
3466
|
+
}
|
|
3467
|
+
) }),
|
|
3468
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3469
|
+
BaseInput,
|
|
3470
|
+
{
|
|
3471
|
+
label: "Email",
|
|
3472
|
+
required: true,
|
|
3473
|
+
value: billingForm.emailAddress,
|
|
3474
|
+
onChange: (e) => {
|
|
3475
|
+
setBillingForm({ ...billingForm, emailAddress: e });
|
|
3476
|
+
if (billingErrors.emailAddress) {
|
|
3477
|
+
setBillingErrors((er) => ({ ...er, emailAddress: "" }));
|
|
3478
|
+
}
|
|
3479
|
+
},
|
|
3480
|
+
validationError: billingErrors.emailAddress ?? ""
|
|
3481
|
+
}
|
|
3482
|
+
) }),
|
|
3483
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3484
|
+
BasePhoneNumberInput,
|
|
3485
|
+
{
|
|
3486
|
+
label: "Phone Number",
|
|
3487
|
+
required: true,
|
|
3488
|
+
preventPaste: true,
|
|
3489
|
+
value: billingForm.phoneNumber,
|
|
3490
|
+
phoneCodeOptions,
|
|
3491
|
+
defaultCountryCode,
|
|
3492
|
+
onChange: (e) => {
|
|
3493
|
+
setBillingForm({ ...billingForm, phoneNumber: e });
|
|
3494
|
+
if (billingErrors.phoneNumber) {
|
|
3495
|
+
setBillingErrors((er) => ({ ...er, phoneNumber: "" }));
|
|
3496
|
+
}
|
|
3497
|
+
},
|
|
3498
|
+
onCodeChange: (e) => {
|
|
3499
|
+
setBillingForm({ ...billingForm, phoneNumberExt: e });
|
|
3500
|
+
if (billingErrors.phoneNumberExt) {
|
|
3501
|
+
setBillingErrors((er) => ({ ...er, phoneNumberExt: "" }));
|
|
3502
|
+
}
|
|
3503
|
+
},
|
|
3504
|
+
validationError: billingErrors.phoneNumber ?? ""
|
|
3505
|
+
}
|
|
3506
|
+
) })
|
|
3507
|
+
] }),
|
|
3508
|
+
formIndex === 1 && /* @__PURE__ */ jsxs24(
|
|
3509
|
+
"div",
|
|
3356
3510
|
{
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3511
|
+
className: "grid grid-cols-2 gap-6 overflow-y-auto",
|
|
3512
|
+
style: { maxHeight: 320 },
|
|
3513
|
+
children: [
|
|
3514
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3515
|
+
BaseInput,
|
|
3516
|
+
{
|
|
3517
|
+
label: "Card Name",
|
|
3518
|
+
required: true,
|
|
3519
|
+
value: payForm.customerName,
|
|
3520
|
+
onChange: (e) => {
|
|
3521
|
+
setPayForm({ ...payForm, customerName: e });
|
|
3522
|
+
if (payErrors.customerName) {
|
|
3523
|
+
setPayErrors((er) => ({ ...er, customerName: "" }));
|
|
3524
|
+
}
|
|
3525
|
+
},
|
|
3526
|
+
validationError: payErrors.customerName ?? ""
|
|
3527
|
+
}
|
|
3528
|
+
) }),
|
|
3529
|
+
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3530
|
+
BaseInput,
|
|
3531
|
+
{
|
|
3532
|
+
label: "Card Number",
|
|
3533
|
+
required: true,
|
|
3534
|
+
rules: ["numeric"],
|
|
3535
|
+
mask: "0000 0000 0000 0000 000",
|
|
3536
|
+
placeholder: "0000 0000 0000 0000",
|
|
3537
|
+
value: payForm.cardNo,
|
|
3538
|
+
preventPaste: true,
|
|
3539
|
+
onChange: (e) => {
|
|
3540
|
+
setPayForm({ ...payForm, cardNo: e });
|
|
3541
|
+
if (payErrors.cardNo)
|
|
3542
|
+
setPayErrors((er) => ({ ...er, cardNo: "" }));
|
|
3543
|
+
cardNumberInputHandler(e);
|
|
3544
|
+
},
|
|
3545
|
+
validationError: payErrors.cardNo ?? ""
|
|
3546
|
+
}
|
|
3547
|
+
) }),
|
|
3548
|
+
/* @__PURE__ */ jsx36(
|
|
3549
|
+
BaseInput,
|
|
3550
|
+
{
|
|
3551
|
+
label: "Expiry Date",
|
|
3552
|
+
required: true,
|
|
3553
|
+
value: payForm.expireDate,
|
|
3554
|
+
mask: "00/00",
|
|
3555
|
+
placeholder: "00/00",
|
|
3556
|
+
onChange: (e) => {
|
|
3557
|
+
setPayForm({ ...payForm, expireDate: e });
|
|
3558
|
+
if (payErrors.expireDate)
|
|
3559
|
+
setPayErrors((er) => ({ ...er, expireDate: "" }));
|
|
3560
|
+
},
|
|
3561
|
+
validationError: payErrors.expireDate ?? ""
|
|
3562
|
+
}
|
|
3563
|
+
),
|
|
3564
|
+
/* @__PURE__ */ jsx36(
|
|
3565
|
+
BaseInput,
|
|
3566
|
+
{
|
|
3567
|
+
label: "CVV",
|
|
3568
|
+
required: true,
|
|
3569
|
+
rules: ["numeric"],
|
|
3570
|
+
value: payForm.cvv,
|
|
3571
|
+
mask: "000",
|
|
3572
|
+
placeholder: "000",
|
|
3573
|
+
onChange: (e) => {
|
|
3574
|
+
setPayForm({ ...payForm, cvv: e });
|
|
3575
|
+
if (payErrors.cvv) setPayErrors((er) => ({ ...er, cvv: "" }));
|
|
3576
|
+
},
|
|
3577
|
+
validationError: payErrors.cvv ?? ""
|
|
3578
|
+
}
|
|
3579
|
+
),
|
|
3580
|
+
cardType === "Verve" && /* @__PURE__ */ jsx36(
|
|
3581
|
+
BaseInput,
|
|
3582
|
+
{
|
|
3583
|
+
label: "Card Pin",
|
|
3584
|
+
required: true,
|
|
3585
|
+
rules: ["numeric"],
|
|
3586
|
+
value: payForm.cardPin,
|
|
3587
|
+
mask: "0000",
|
|
3588
|
+
placeholder: "0000",
|
|
3589
|
+
onChange: (e) => {
|
|
3590
|
+
setPayForm({ ...payForm, cardPin: e });
|
|
3591
|
+
if (payErrors.cardPin)
|
|
3592
|
+
setPayErrors((er) => ({ ...er, cardPin: "" }));
|
|
3593
|
+
},
|
|
3594
|
+
validationError: payErrors.cardPin ?? ""
|
|
3595
|
+
}
|
|
3596
|
+
)
|
|
3597
|
+
]
|
|
3367
3598
|
}
|
|
3368
|
-
)
|
|
3369
|
-
|
|
3370
|
-
|
|
3599
|
+
),
|
|
3600
|
+
formIndex === 2 && /* @__PURE__ */ jsx36(
|
|
3601
|
+
"div",
|
|
3371
3602
|
{
|
|
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
|
-
|
|
3401
|
-
BaseInput,
|
|
3402
|
-
{
|
|
3403
|
-
label: "Card Name",
|
|
3404
|
-
required: true,
|
|
3405
|
-
value: payForm.customerName,
|
|
3406
|
-
onChange: (e) => {
|
|
3407
|
-
setPayForm({ ...payForm, customerName: e });
|
|
3408
|
-
if (payErrors.customerName) {
|
|
3409
|
-
setPayErrors((er) => ({ ...er, customerName: "" }));
|
|
3603
|
+
className: "grid grid-cols-2 gap-6 overflow-y-auto",
|
|
3604
|
+
style: { maxHeight: 320 },
|
|
3605
|
+
children: /* @__PURE__ */ jsxs24("div", { className: "col-span-2", children: [
|
|
3606
|
+
/* @__PURE__ */ jsx36(
|
|
3607
|
+
BaseInput,
|
|
3608
|
+
{
|
|
3609
|
+
label: "OTP",
|
|
3610
|
+
required: true,
|
|
3611
|
+
value: otpForm.otp,
|
|
3612
|
+
onChange: (e) => {
|
|
3613
|
+
setOtpForm({ ...otpForm, otp: e });
|
|
3614
|
+
if (otpErrors.otp) {
|
|
3615
|
+
setOtpErrors((er) => ({ ...er, otp: "" }));
|
|
3616
|
+
}
|
|
3617
|
+
},
|
|
3618
|
+
validationError: otpErrors.otp ?? ""
|
|
3619
|
+
}
|
|
3620
|
+
),
|
|
3621
|
+
/* @__PURE__ */ jsxs24("p", { className: "text-primary text-sm mt-2", children: [
|
|
3622
|
+
"Didn't get OTP?",
|
|
3623
|
+
/* @__PURE__ */ jsx36(
|
|
3624
|
+
"span",
|
|
3625
|
+
{
|
|
3626
|
+
className: isSendingOtp ? "ml-1" : "ml-1 underline cursor-pointer",
|
|
3627
|
+
onClick: () => {
|
|
3628
|
+
if (isSendingOtp) return;
|
|
3629
|
+
resendOtp();
|
|
3630
|
+
},
|
|
3631
|
+
children: isSendingOtp ? "Sending..." : "Resend OTP"
|
|
3410
3632
|
}
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
) }),
|
|
3415
|
-
/* @__PURE__ */ jsx36("div", { className: "col-span-2", children: /* @__PURE__ */ jsx36(
|
|
3416
|
-
BaseInput,
|
|
3417
|
-
{
|
|
3418
|
-
label: "Card Number",
|
|
3419
|
-
required: true,
|
|
3420
|
-
rules: ["numeric"],
|
|
3421
|
-
mask: "0000 0000 0000 0000",
|
|
3422
|
-
placeholder: "0000 0000 0000 0000",
|
|
3423
|
-
value: payForm.cardNo,
|
|
3424
|
-
preventPaste: false,
|
|
3425
|
-
onChange: (e) => {
|
|
3426
|
-
setPayForm({ ...payForm, cardNo: e });
|
|
3427
|
-
if (payErrors.cardNo)
|
|
3428
|
-
setPayErrors((er) => ({ ...er, cardNo: "" }));
|
|
3429
|
-
cardNumberInputHandler(e);
|
|
3430
|
-
},
|
|
3431
|
-
validationError: payErrors.cardNo ?? ""
|
|
3432
|
-
}
|
|
3433
|
-
) }),
|
|
3434
|
-
/* @__PURE__ */ jsx36(
|
|
3435
|
-
BaseInput,
|
|
3436
|
-
{
|
|
3437
|
-
label: "Expiry Date",
|
|
3438
|
-
required: true,
|
|
3439
|
-
value: payForm.expireDate,
|
|
3440
|
-
mask: "00/00",
|
|
3441
|
-
placeholder: "00/00",
|
|
3442
|
-
onChange: (e) => {
|
|
3443
|
-
setPayForm({ ...payForm, expireDate: e });
|
|
3444
|
-
if (payErrors.expireDate)
|
|
3445
|
-
setPayErrors((er) => ({ ...er, expireDate: "" }));
|
|
3446
|
-
},
|
|
3447
|
-
validationError: payErrors.expireDate ?? ""
|
|
3448
|
-
}
|
|
3449
|
-
),
|
|
3450
|
-
/* @__PURE__ */ jsx36(
|
|
3451
|
-
BaseInput,
|
|
3452
|
-
{
|
|
3453
|
-
label: "CVV",
|
|
3454
|
-
required: true,
|
|
3455
|
-
rules: ["numeric"],
|
|
3456
|
-
value: payForm.cvv,
|
|
3457
|
-
mask: "000",
|
|
3458
|
-
placeholder: "000",
|
|
3459
|
-
onChange: (e) => {
|
|
3460
|
-
setPayForm({ ...payForm, cvv: e });
|
|
3461
|
-
if (payErrors.cvv) setPayErrors((er) => ({ ...er, cvv: "" }));
|
|
3462
|
-
},
|
|
3463
|
-
validationError: payErrors.cvv ?? ""
|
|
3464
|
-
}
|
|
3465
|
-
),
|
|
3466
|
-
cardType === "Verve" && /* @__PURE__ */ jsx36(
|
|
3467
|
-
BaseInput,
|
|
3468
|
-
{
|
|
3469
|
-
label: "Card Pin",
|
|
3470
|
-
required: true,
|
|
3471
|
-
rules: ["numeric"],
|
|
3472
|
-
value: payForm.cardPin,
|
|
3473
|
-
mask: "0000",
|
|
3474
|
-
placeholder: "0000",
|
|
3475
|
-
onChange: (e) => {
|
|
3476
|
-
setPayForm({ ...payForm, cardPin: e });
|
|
3477
|
-
if (payErrors.cardPin)
|
|
3478
|
-
setPayErrors((er) => ({ ...er, cardPin: "" }));
|
|
3479
|
-
},
|
|
3480
|
-
validationError: payErrors.cardPin ?? ""
|
|
3481
|
-
}
|
|
3482
|
-
)
|
|
3483
|
-
]
|
|
3484
|
-
}
|
|
3485
|
-
),
|
|
3486
|
-
/* @__PURE__ */ jsxs24("div", { className: "flex items-center justify-between gap-4 mt-6", children: [
|
|
3487
|
-
formIndex > 0 && /* @__PURE__ */ jsx36(
|
|
3488
|
-
BaseButton,
|
|
3489
|
-
{
|
|
3490
|
-
label: "Previous",
|
|
3491
|
-
type: "secondary",
|
|
3492
|
-
customClass: "w-1/2",
|
|
3493
|
-
caller,
|
|
3494
|
-
onClick: goBack
|
|
3633
|
+
)
|
|
3634
|
+
] })
|
|
3635
|
+
] })
|
|
3495
3636
|
}
|
|
3496
3637
|
),
|
|
3497
|
-
/* @__PURE__ */
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3638
|
+
/* @__PURE__ */ jsxs24("div", { className: "flex items-center justify-between gap-4 mt-6", children: [
|
|
3639
|
+
formIndex > 0 && /* @__PURE__ */ jsx36(
|
|
3640
|
+
BaseButton,
|
|
3641
|
+
{
|
|
3642
|
+
label: "Previous",
|
|
3643
|
+
type: "secondary",
|
|
3644
|
+
customClass: "w-1/2",
|
|
3645
|
+
caller,
|
|
3646
|
+
onClick: goBack
|
|
3647
|
+
}
|
|
3648
|
+
),
|
|
3649
|
+
formIndex < 2 && /* @__PURE__ */ jsx36(
|
|
3650
|
+
BaseButton,
|
|
3651
|
+
{
|
|
3652
|
+
label: formIndex === 0 ? "Proceed" : `Pay ${formatAmountHandler}`,
|
|
3653
|
+
type: "primary",
|
|
3654
|
+
customClass: `${formIndex > 0 ? "w-1/2" : "w-full"}`,
|
|
3655
|
+
caller,
|
|
3656
|
+
loading: isMakingPayment,
|
|
3657
|
+
onClick: proceedHandler,
|
|
3658
|
+
disabled: isMakingPayment
|
|
3659
|
+
}
|
|
3660
|
+
),
|
|
3661
|
+
formIndex === 2 && /* @__PURE__ */ jsx36("div", { className: "w-1/2", children: /* @__PURE__ */ jsx36(
|
|
3662
|
+
BaseButton,
|
|
3663
|
+
{
|
|
3664
|
+
label: "Validate OTP",
|
|
3665
|
+
type: "primary",
|
|
3666
|
+
caller,
|
|
3667
|
+
loading: isValidatingOtp,
|
|
3668
|
+
onClick: proceedHandler
|
|
3669
|
+
}
|
|
3670
|
+
) })
|
|
3671
|
+
] })
|
|
3509
3672
|
] })
|
|
3510
3673
|
] });
|
|
3511
3674
|
}
|
|
@@ -3577,11 +3740,19 @@ var PayByTransfer = ({
|
|
|
3577
3740
|
caller
|
|
3578
3741
|
);
|
|
3579
3742
|
if (response?.isSuccessful) {
|
|
3580
|
-
setPaymentAccountDetails(
|
|
3743
|
+
setPaymentAccountDetails(
|
|
3744
|
+
caller === "buzapay" ? response.data : response
|
|
3745
|
+
);
|
|
3581
3746
|
startTimer();
|
|
3582
3747
|
setMessage("Virtual account generated successfully for payment.");
|
|
3583
|
-
setIsMakingPayment(
|
|
3748
|
+
setIsMakingPayment(false);
|
|
3584
3749
|
setFormIndex(1);
|
|
3750
|
+
} else {
|
|
3751
|
+
setIsMakingPayment(false);
|
|
3752
|
+
setMessage("Payment failed.");
|
|
3753
|
+
onError?.({
|
|
3754
|
+
errorMessage: "Payment failed."
|
|
3755
|
+
});
|
|
3585
3756
|
}
|
|
3586
3757
|
} catch (err) {
|
|
3587
3758
|
setIsMakingPayment(false);
|
|
@@ -3603,10 +3774,12 @@ var PayByTransfer = ({
|
|
|
3603
3774
|
caller
|
|
3604
3775
|
);
|
|
3605
3776
|
if (response?.isSuccessful) {
|
|
3606
|
-
setPaymentReferenceDetails(
|
|
3607
|
-
|
|
3777
|
+
setPaymentReferenceDetails(
|
|
3778
|
+
caller === "buzapay" ? response.data : response
|
|
3779
|
+
);
|
|
3780
|
+
const made = paymentReferenceDetails?.paymentStatus === "Payment Received";
|
|
3608
3781
|
setPaymentMade(made);
|
|
3609
|
-
const noServerStatus =
|
|
3782
|
+
const noServerStatus = paymentReferenceDetails?.finalTransactionStatus == null || paymentReferenceDetails?.paymentStatus == null;
|
|
3610
3783
|
if (noServerStatus) {
|
|
3611
3784
|
if (isConfirmCall) {
|
|
3612
3785
|
setMessage("Transaction not confirmed !!");
|
|
@@ -3615,7 +3788,7 @@ var PayByTransfer = ({
|
|
|
3615
3788
|
setPaymentReferenceStatus("pending");
|
|
3616
3789
|
onPaymentAuthorized?.({
|
|
3617
3790
|
paymentId: transactionReference,
|
|
3618
|
-
paymentDate:
|
|
3791
|
+
paymentDate: paymentReferenceDetails?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3619
3792
|
paymentStatus: "pending",
|
|
3620
3793
|
message
|
|
3621
3794
|
});
|
|
@@ -3623,18 +3796,18 @@ var PayByTransfer = ({
|
|
|
3623
3796
|
setPaymentReferenceStatus("confirmed");
|
|
3624
3797
|
onPaymentAuthorized?.({
|
|
3625
3798
|
paymentId: transactionReference,
|
|
3626
|
-
paymentDate:
|
|
3799
|
+
paymentDate: paymentReferenceDetails?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3627
3800
|
paymentStatus: "confirmed",
|
|
3628
3801
|
message
|
|
3629
3802
|
});
|
|
3630
3803
|
}
|
|
3631
|
-
} else if (
|
|
3804
|
+
} else if (paymentReferenceDetails?.finalTransactionStatus === "Success" || paymentReferenceDetails?.paymentStatus === "Received" || paymentReferenceDetails?.paymentStatus === "Payment Received") {
|
|
3632
3805
|
setPaymentReferenceStatus("confirmed");
|
|
3633
3806
|
setIsPaymentConfirmed(true);
|
|
3634
3807
|
setMessage("Transaction confirmed !!");
|
|
3635
3808
|
onPaymentAuthorized?.({
|
|
3636
3809
|
paymentId: transactionReference,
|
|
3637
|
-
paymentDate:
|
|
3810
|
+
paymentDate: paymentReferenceDetails?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3638
3811
|
paymentStatus: "confirmed",
|
|
3639
3812
|
message
|
|
3640
3813
|
});
|
|
@@ -3644,7 +3817,7 @@ var PayByTransfer = ({
|
|
|
3644
3817
|
setMessage(response.responseMessage || "");
|
|
3645
3818
|
onPaymentAuthorized?.({
|
|
3646
3819
|
paymentId: transactionReference,
|
|
3647
|
-
paymentDate:
|
|
3820
|
+
paymentDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3648
3821
|
paymentStatus: "used",
|
|
3649
3822
|
message
|
|
3650
3823
|
});
|
|
@@ -3854,7 +4027,7 @@ var PayByTransfer = ({
|
|
|
3854
4027
|
"button",
|
|
3855
4028
|
{
|
|
3856
4029
|
type: "button",
|
|
3857
|
-
onClick:
|
|
4030
|
+
onClick: () => setFormIndex(0),
|
|
3858
4031
|
className: "text-heading-text text-body-2xs font-medium text-center py-2 cursor-pointer",
|
|
3859
4032
|
children: "Cancel Payment"
|
|
3860
4033
|
}
|