@pinerohit11/testwidget 0.1.57 → 0.1.58
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +463 -34
- package/dist/index.mjs +456 -30
- package/global.d.ts +2 -8
- package/next.config.ts +7 -12
- package/package.json +8 -10
package/dist/index.mjs
CHANGED
@@ -18,9 +18,6 @@ var __spreadValues = (a, b) => {
|
|
18
18
|
};
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
20
|
|
21
|
-
// src/app/index.ts
|
22
|
-
import "bootstrap/dist/js/bootstrap.bundle.min.js";
|
23
|
-
|
24
21
|
// src/app/components/RequestPayment/RequestPayment.tsx
|
25
22
|
import React4, { useState, useEffect } from "react";
|
26
23
|
|
@@ -29,7 +26,7 @@ import React2 from "react";
|
|
29
26
|
|
30
27
|
// src/app/components/Loader/LoaderStyle.tsx
|
31
28
|
import React from "react";
|
32
|
-
var LoaderStyle = () => {
|
29
|
+
var LoaderStyle = (props) => {
|
33
30
|
return /* @__PURE__ */ React.createElement("style", null, `
|
34
31
|
.loader {
|
35
32
|
position: fixed;
|
@@ -158,7 +155,7 @@ import { Button, Form, Modal } from "react-bootstrap";
|
|
158
155
|
|
159
156
|
// src/app/components/RequestPayment/RequestPaymentstyles.tsx
|
160
157
|
import React3 from "react";
|
161
|
-
var RequestPaymentstyles = () => {
|
158
|
+
var RequestPaymentstyles = (props) => {
|
162
159
|
return /* @__PURE__ */ React3.createElement("style", null, `
|
163
160
|
.paymentBtn {
|
164
161
|
background-color: black;
|
@@ -1029,6 +1026,7 @@ function RequestPayment(props) {
|
|
1029
1026
|
});
|
1030
1027
|
const [showConfirmationModal, setShowConfirmationModal] = useState(false);
|
1031
1028
|
const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
|
1029
|
+
const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
|
1032
1030
|
const positiveAmountRegex = /^[+]?\d+(\.\d+)?$/;
|
1033
1031
|
const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
1034
1032
|
const isAlpha = (value) => /^[A-Za-z\s]*$/.test(value);
|
@@ -1050,7 +1048,7 @@ function RequestPayment(props) {
|
|
1050
1048
|
});
|
1051
1049
|
};
|
1052
1050
|
const handleSubmit = (event) => {
|
1053
|
-
|
1051
|
+
let message = {
|
1054
1052
|
type: "preview.compiledcheck",
|
1055
1053
|
other: __spreadProps(__spreadValues({}, event), { status: true })
|
1056
1054
|
};
|
@@ -1103,6 +1101,7 @@ function RequestPayment(props) {
|
|
1103
1101
|
setLoading(false);
|
1104
1102
|
}
|
1105
1103
|
};
|
1104
|
+
const validateAmount = (amount) => amoutRegex.test(amount);
|
1106
1105
|
const PositiveAmount = (amount) => positiveAmountRegex.test(amount);
|
1107
1106
|
const handleChange = (e) => {
|
1108
1107
|
const { value } = e.target;
|
@@ -1157,7 +1156,7 @@ function RequestPayment(props) {
|
|
1157
1156
|
}
|
1158
1157
|
};
|
1159
1158
|
const validateForm = () => {
|
1160
|
-
|
1159
|
+
let newErrors = {};
|
1161
1160
|
if (!requestDetails.name) newErrors.name = ErrorText.namerequired;
|
1162
1161
|
if (!requestDetails.amount) newErrors.amount = ErrorText.amountrequired;
|
1163
1162
|
if (!requestDetails.phone_number && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.phone_number = ErrorText.phoneoremailrequired;
|
@@ -1340,6 +1339,7 @@ function RequestPaymentAllInput({ fractalpayClientKey }) {
|
|
1340
1339
|
const [errorMessageorderid, setErrorMessageorderid] = useState2("");
|
1341
1340
|
const [submitClicked, setSubmitClicked] = useState2(false);
|
1342
1341
|
const handleClose = () => setShow(false);
|
1342
|
+
const handleShow = () => setShow(true);
|
1343
1343
|
const sendRequestPayment = () => {
|
1344
1344
|
if (!phoneNumber) {
|
1345
1345
|
setErrorMessagephone(ErrorText.phonenumberrequired);
|
@@ -1371,7 +1371,7 @@ function RequestPaymentAllInput({ fractalpayClientKey }) {
|
|
1371
1371
|
setErrorMessageorderid("");
|
1372
1372
|
setSubmitClicked(true);
|
1373
1373
|
setIsLoading(true);
|
1374
|
-
|
1374
|
+
let formData = {
|
1375
1375
|
fractalpayPublicKey: fractalpayClientKey,
|
1376
1376
|
amount,
|
1377
1377
|
phone_number: phoneNumber,
|
@@ -1542,6 +1542,7 @@ function RequestPaymentDynamic({ fractalpayClientKey, amount, phone_number, orde
|
|
1542
1542
|
const [isLoading, setIsLoading] = useState3(false);
|
1543
1543
|
const [show, setShow] = useState3(false);
|
1544
1544
|
const handleClose = () => setShow(false);
|
1545
|
+
const handleShow = () => setShow(true);
|
1545
1546
|
const sendRequestPayment = () => {
|
1546
1547
|
setIsLoading(true);
|
1547
1548
|
const formData = {
|
@@ -1616,10 +1617,11 @@ function RequestPaymentonClick(props) {
|
|
1616
1617
|
const [isLoading, setIsLoading] = useState4(false);
|
1617
1618
|
const [show, setShow] = useState4(false);
|
1618
1619
|
const handleClose = () => setShow(false);
|
1620
|
+
const handleShow = () => setShow(true);
|
1619
1621
|
const { fractalpayClientKey, amount, phone_number, orderID, onSuccess, onError } = props;
|
1620
1622
|
const sendRequestPayment = () => {
|
1621
1623
|
setIsLoading(true);
|
1622
|
-
|
1624
|
+
let formData = {
|
1623
1625
|
fractalpayPublicKey: fractalpayClientKey,
|
1624
1626
|
amount,
|
1625
1627
|
phone_number,
|
@@ -1707,6 +1709,7 @@ function RqstPaymntInputField({ fractalpayClientKey, amount, orderID }) {
|
|
1707
1709
|
const [errorMessage, setErrorMessage] = useState5("");
|
1708
1710
|
const [submitClicked, setSubmitClicked] = useState5(false);
|
1709
1711
|
const handleClose = () => setShow(false);
|
1712
|
+
const handleShow = () => setShow(true);
|
1710
1713
|
const sendRequestPayment = () => {
|
1711
1714
|
if (!phoneNumber) {
|
1712
1715
|
setErrorMessage(ErrorText.phonenumberrequired);
|
@@ -1721,7 +1724,7 @@ function RqstPaymntInputField({ fractalpayClientKey, amount, orderID }) {
|
|
1721
1724
|
setErrorMessage("");
|
1722
1725
|
setSubmitClicked(true);
|
1723
1726
|
setIsLoading(true);
|
1724
|
-
|
1727
|
+
let formData = {
|
1725
1728
|
fractalpayPublicKey: fractalpayClientKey,
|
1726
1729
|
amount,
|
1727
1730
|
phone_number: phoneNumber,
|
@@ -2772,7 +2775,7 @@ function Payment() {
|
|
2772
2775
|
});
|
2773
2776
|
const [isValid, setIsValid] = useState6(false);
|
2774
2777
|
const [isValidMonth, setIsValidMonth] = useState6(false);
|
2775
|
-
|
2778
|
+
const [data, setData] = useState6(null);
|
2776
2779
|
const handlePaymentClick = async () => {
|
2777
2780
|
try {
|
2778
2781
|
const response = await fetch(`${baseUrl}generate-session`, {
|
@@ -2785,14 +2788,14 @@ function Payment() {
|
|
2785
2788
|
if (!response.ok) {
|
2786
2789
|
throw new Error("Network response was not ok");
|
2787
2790
|
}
|
2788
|
-
const
|
2789
|
-
if (
|
2791
|
+
const data2 = await response.json();
|
2792
|
+
if (data2 && data2.result === true) {
|
2790
2793
|
setState((prev) => {
|
2791
2794
|
var _a2, _b;
|
2792
2795
|
return __spreadProps(__spreadValues({}, prev), {
|
2793
2796
|
show: true,
|
2794
|
-
publicKey: (_a2 =
|
2795
|
-
sessionKey: (_b =
|
2797
|
+
publicKey: (_a2 = data2 == null ? void 0 : data2.data) == null ? void 0 : _a2.publicKeyPem,
|
2798
|
+
sessionKey: (_b = data2 == null ? void 0 : data2.data) == null ? void 0 : _b.session_key
|
2796
2799
|
});
|
2797
2800
|
});
|
2798
2801
|
}
|
@@ -2862,7 +2865,7 @@ function Payment() {
|
|
2862
2865
|
};
|
2863
2866
|
const handleMonthChange = (e) => {
|
2864
2867
|
setIsValid(false);
|
2865
|
-
|
2868
|
+
let value = e.target.value;
|
2866
2869
|
if (/^\d{0,2}$/.test(value) && (value === "" || parseInt(value, 10) >= 1 && parseInt(value, 10) <= 12)) {
|
2867
2870
|
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
2868
2871
|
month: value
|
@@ -2875,7 +2878,7 @@ function Payment() {
|
|
2875
2878
|
const handleYearChange = (e) => {
|
2876
2879
|
setIsValid(false);
|
2877
2880
|
setIsValidMonth(false);
|
2878
|
-
|
2881
|
+
let value = e.target.value;
|
2879
2882
|
if (/^\d{0,2}$/.test(value) && (value === "" || parseInt(value, 10) >= 0 && parseInt(value, 10) <= 99)) {
|
2880
2883
|
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
2881
2884
|
year: value
|
@@ -2885,7 +2888,7 @@ function Payment() {
|
|
2885
2888
|
const handleCVVChange = (e) => {
|
2886
2889
|
setIsValid(false);
|
2887
2890
|
setIsValidMonth(false);
|
2888
|
-
|
2891
|
+
let value = e.target.value;
|
2889
2892
|
if (/^\d{0,4}$/.test(value)) {
|
2890
2893
|
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
2891
2894
|
cvv: value
|
@@ -2895,7 +2898,7 @@ function Payment() {
|
|
2895
2898
|
const handleZIP = (e) => {
|
2896
2899
|
setIsValid(false);
|
2897
2900
|
setIsValidMonth(false);
|
2898
|
-
|
2901
|
+
let value = e.target.value;
|
2899
2902
|
if (/^\d{0,7}$/.test(value)) {
|
2900
2903
|
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
2901
2904
|
zip: value
|
@@ -2909,8 +2912,7 @@ function Payment() {
|
|
2909
2912
|
value = value.replace(/[^0-9.]/g, "");
|
2910
2913
|
let parts = value.split(".");
|
2911
2914
|
if (parts.length > 2) {
|
2912
|
-
|
2913
|
-
parts = [p1, parts.join(".")];
|
2915
|
+
parts = [parts.shift(), parts.join(".")];
|
2914
2916
|
value = parts.join("");
|
2915
2917
|
}
|
2916
2918
|
if (parts.length === 2 && parts[1].length > 2) {
|
@@ -2928,6 +2930,15 @@ function Payment() {
|
|
2928
2930
|
}));
|
2929
2931
|
}
|
2930
2932
|
};
|
2933
|
+
function amountFormat(amt) {
|
2934
|
+
if (amt) {
|
2935
|
+
return `${parseFloat(amt).toLocaleString("en-US", {
|
2936
|
+
minimumFractionDigits: 2,
|
2937
|
+
maximumFractionDigits: 2
|
2938
|
+
})}`;
|
2939
|
+
}
|
2940
|
+
return "";
|
2941
|
+
}
|
2931
2942
|
return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(Paymentstyles, null), /* @__PURE__ */ React10.createElement("div", { className: "" }, /* @__PURE__ */ React10.createElement(
|
2932
2943
|
"button",
|
2933
2944
|
{
|
@@ -3374,6 +3385,7 @@ function CompletedTransactions(props) {
|
|
3374
3385
|
selectsEnd: true,
|
3375
3386
|
startDate,
|
3376
3387
|
endDate,
|
3388
|
+
minDate: startDate,
|
3377
3389
|
placeholderText: "End Date"
|
3378
3390
|
}
|
3379
3391
|
)), /* @__PURE__ */ React12.createElement("button", { className: "export-btn1", onClick: handleExport }, "Export")), /* @__PURE__ */ React12.createElement(
|
@@ -3394,22 +3406,420 @@ function CompletedTransactions(props) {
|
|
3394
3406
|
))));
|
3395
3407
|
}
|
3396
3408
|
|
3397
|
-
// src/app/components/Payment/
|
3398
|
-
import
|
3409
|
+
// src/app/components/Payment/TockenizPay.tsx
|
3410
|
+
import React13, { useState as useState9 } from "react";
|
3399
3411
|
import { Modal as Modal7 } from "react-bootstrap";
|
3412
|
+
import { toast as toast5, ToastContainer as ToastContainer3 } from "react-toastify";
|
3413
|
+
import forge2 from "node-forge";
|
3414
|
+
import creditCardType from "credit-card-type";
|
3415
|
+
function TockenizPay() {
|
3416
|
+
const [state, setState] = useState9({
|
3417
|
+
show: false,
|
3418
|
+
publicKey: "",
|
3419
|
+
sessionKey: "",
|
3420
|
+
cardNumber: "",
|
3421
|
+
year: "",
|
3422
|
+
month: "",
|
3423
|
+
cvv: "",
|
3424
|
+
zip: "",
|
3425
|
+
amount: ""
|
3426
|
+
});
|
3427
|
+
const [cardTypeDetail, setCardTypeDetail] = useState9(null);
|
3428
|
+
const [isValid, setIsValid] = useState9(false);
|
3429
|
+
const [isValidMonth, setIsValidMonth] = useState9(false);
|
3430
|
+
const [data, setData] = useState9(null);
|
3431
|
+
const handlePaymentClick = async () => {
|
3432
|
+
try {
|
3433
|
+
const response = await fetch(`${baseUrl}/generate-session`, {
|
3434
|
+
method: "POST",
|
3435
|
+
headers: {
|
3436
|
+
"Content-Type": "application/json"
|
3437
|
+
},
|
3438
|
+
body: JSON.stringify({})
|
3439
|
+
});
|
3440
|
+
if (!response.ok) {
|
3441
|
+
throw new Error("Network response was not ok");
|
3442
|
+
}
|
3443
|
+
const data2 = await response.json();
|
3444
|
+
if (data2 && data2.result === true) {
|
3445
|
+
setState((prev) => {
|
3446
|
+
var _a, _b;
|
3447
|
+
return __spreadProps(__spreadValues({}, prev), {
|
3448
|
+
show: true,
|
3449
|
+
publicKey: (_a = data2 == null ? void 0 : data2.data) == null ? void 0 : _a.publicKeyPem,
|
3450
|
+
sessionKey: (_b = data2 == null ? void 0 : data2.data) == null ? void 0 : _b.session_key
|
3451
|
+
});
|
3452
|
+
});
|
3453
|
+
}
|
3454
|
+
} catch (error) {
|
3455
|
+
console.log(error);
|
3456
|
+
}
|
3457
|
+
};
|
3458
|
+
const handleSubmitPay = async () => {
|
3459
|
+
var _a, _b, _c;
|
3460
|
+
let track2_data = `${(_a = state == null ? void 0 : state.cardNumber) == null ? void 0 : _a.replaceAll(" ", "")}=${state.year}${((_b = state == null ? void 0 : state.month) == null ? void 0 : _b.length) > 1 ? state == null ? void 0 : state.month : "0" + (state == null ? void 0 : state.month)} ${state.cvv}`;
|
3461
|
+
const publicKey = forge2.pki.publicKeyFromPem(state.publicKey);
|
3462
|
+
const encrypted = publicKey.encrypt(track2_data, "RSA-OAEP", {
|
3463
|
+
md: forge2.md.sha1.create(),
|
3464
|
+
mgf1: {
|
3465
|
+
md: forge2.md.sha1.create()
|
3466
|
+
}
|
3467
|
+
});
|
3468
|
+
const encryptedBase64 = forge2.util.encode64(encrypted);
|
3469
|
+
console.log(encryptedBase64);
|
3470
|
+
const requestBody = {
|
3471
|
+
enc_track2_data: encryptedBase64,
|
3472
|
+
session_key: state.sessionKey,
|
3473
|
+
algorithm: "RSAES_OAEP_SHA_1"
|
3474
|
+
};
|
3475
|
+
try {
|
3476
|
+
const response = await fetch(
|
3477
|
+
"https://m1ao5pku8b.execute-api.us-east-2.amazonaws.com/prod/tokenizer/tokenize",
|
3478
|
+
{
|
3479
|
+
method: "POST",
|
3480
|
+
headers: {
|
3481
|
+
"x-app-session-key": state == null ? void 0 : state.sessionKey,
|
3482
|
+
"Content-Type": "application/json"
|
3483
|
+
},
|
3484
|
+
body: JSON.stringify(requestBody)
|
3485
|
+
}
|
3486
|
+
);
|
3487
|
+
if (!response.ok) {
|
3488
|
+
const errorData = await response.json();
|
3489
|
+
throw new Error(((_c = errorData == null ? void 0 : errorData.data) == null ? void 0 : _c.message) || "Request failed");
|
3490
|
+
}
|
3491
|
+
const responseData = await response.json();
|
3492
|
+
toast5.success("Payment Successful");
|
3493
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3494
|
+
show: false,
|
3495
|
+
publicKey: "",
|
3496
|
+
sessionKey: "",
|
3497
|
+
cardNumber: "",
|
3498
|
+
year: "",
|
3499
|
+
month: "",
|
3500
|
+
cvv: "",
|
3501
|
+
zip: "",
|
3502
|
+
amount: ""
|
3503
|
+
}));
|
3504
|
+
console.log("response", responseData);
|
3505
|
+
} catch (error) {
|
3506
|
+
toast5.error((error == null ? void 0 : error.message) || "An error occurred");
|
3507
|
+
console.error("Error:", error);
|
3508
|
+
}
|
3509
|
+
};
|
3510
|
+
const formatCreditCardNumber = (cardNumber, cardType) => {
|
3511
|
+
const cleanNumber = cardNumber.replace(/\D+/g, "");
|
3512
|
+
let formattedValue;
|
3513
|
+
switch (cardType) {
|
3514
|
+
case "visa":
|
3515
|
+
case "mastercard":
|
3516
|
+
case "Discover":
|
3517
|
+
case "JCB":
|
3518
|
+
formattedValue = cleanNumber.replace(/(.{4})/g, "$1 ").trim();
|
3519
|
+
break;
|
3520
|
+
case "american-express":
|
3521
|
+
formattedValue = cleanNumber.replace(/(\d{4})(\d{6})(\d{5})/, "$1 $2 $3");
|
3522
|
+
break;
|
3523
|
+
case "diners-club":
|
3524
|
+
formattedValue = cleanNumber.replace(/(\d{4})(\d{6})(\d{4})/, "$1 $2 $3");
|
3525
|
+
break;
|
3526
|
+
case "maestro":
|
3527
|
+
formattedValue = cleanNumber.length <= 19 ? cleanNumber.replace(/(.{4})/g, "$1 ").trim() : cleanNumber;
|
3528
|
+
break;
|
3529
|
+
default:
|
3530
|
+
formattedValue = cleanNumber;
|
3531
|
+
}
|
3532
|
+
return formattedValue;
|
3533
|
+
};
|
3534
|
+
const handleCardNumberChange = (e) => {
|
3535
|
+
e.preventDefault();
|
3536
|
+
e.stopPropagation();
|
3537
|
+
const { value } = e.target;
|
3538
|
+
let cardtyp = creditCardType(value)[0];
|
3539
|
+
const formattedValue = formatCreditCardNumber(value, cardtyp == null ? void 0 : cardtyp.type);
|
3540
|
+
setCardTypeDetail(creditCardType(value)[0]);
|
3541
|
+
console.log(formattedValue);
|
3542
|
+
if (value.match(/[a-zA-Z]/)) {
|
3543
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3544
|
+
cardNumber: formattedValue,
|
3545
|
+
error: "Invalid input. Please enter only numbers."
|
3546
|
+
}));
|
3547
|
+
} else {
|
3548
|
+
handleCardNumLength("");
|
3549
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3550
|
+
cardNumber: formattedValue,
|
3551
|
+
error: null
|
3552
|
+
}));
|
3553
|
+
}
|
3554
|
+
};
|
3555
|
+
function handleCardNumLength(cardType) {
|
3556
|
+
const cardLengths = {
|
3557
|
+
"Visa": 16,
|
3558
|
+
"MasterCard": 16,
|
3559
|
+
"AmericanExpress": 15,
|
3560
|
+
"Discover": 16,
|
3561
|
+
"DinersClub": 14,
|
3562
|
+
"JCB": 16
|
3563
|
+
};
|
3564
|
+
return cardLengths[cardType] || "Unknown card type";
|
3565
|
+
}
|
3566
|
+
const handleMonthChange = (e) => {
|
3567
|
+
setIsValid(false);
|
3568
|
+
let value = e.target.value;
|
3569
|
+
if (/^\d{0,2}$/.test(value) && (value === "" || parseInt(value, 10) >= 1 && parseInt(value, 10) <= 12)) {
|
3570
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3571
|
+
month: value
|
3572
|
+
}));
|
3573
|
+
setIsValidMonth(false);
|
3574
|
+
} else {
|
3575
|
+
setIsValidMonth(true);
|
3576
|
+
}
|
3577
|
+
};
|
3578
|
+
const handleYearChange = (e) => {
|
3579
|
+
setIsValid(false);
|
3580
|
+
setIsValidMonth(false);
|
3581
|
+
let value = e.target.value;
|
3582
|
+
if (/^\d{0,2}$/.test(value) && (value === "" || parseInt(value, 10) >= 0 && parseInt(value, 10) <= 99)) {
|
3583
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3584
|
+
year: value
|
3585
|
+
}));
|
3586
|
+
}
|
3587
|
+
};
|
3588
|
+
const handleCVVChange = (e) => {
|
3589
|
+
setIsValid(false);
|
3590
|
+
setIsValidMonth(false);
|
3591
|
+
let value = e.target.value;
|
3592
|
+
if (/^\d{0,4}$/.test(value)) {
|
3593
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3594
|
+
cvv: value
|
3595
|
+
}));
|
3596
|
+
}
|
3597
|
+
};
|
3598
|
+
const handleZIP = (e) => {
|
3599
|
+
setIsValid(false);
|
3600
|
+
setIsValidMonth(false);
|
3601
|
+
let value = e.target.value;
|
3602
|
+
if (/^\d{0,7}$/.test(value)) {
|
3603
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3604
|
+
zip: value
|
3605
|
+
}));
|
3606
|
+
}
|
3607
|
+
};
|
3608
|
+
const handleAmount = (e) => {
|
3609
|
+
setIsValid(false);
|
3610
|
+
setIsValidMonth(false);
|
3611
|
+
let value = e.target.value;
|
3612
|
+
value = value.replace(/[^0-9.]/g, "");
|
3613
|
+
let parts = value.split(".");
|
3614
|
+
if (parts.length > 2) {
|
3615
|
+
parts = [parts.shift(), parts.join(".")];
|
3616
|
+
value = parts.join("");
|
3617
|
+
}
|
3618
|
+
if (parts.length === 2 && parts[1].length > 2) {
|
3619
|
+
value = `${parts[0]}.${parts[1].slice(0, 2)}`;
|
3620
|
+
}
|
3621
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3622
|
+
amount: value
|
3623
|
+
}));
|
3624
|
+
};
|
3625
|
+
const handleAmountBlur = () => {
|
3626
|
+
const value = state.amount;
|
3627
|
+
if (value && !value.includes(".")) {
|
3628
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3629
|
+
amount: `${value}.00`
|
3630
|
+
}));
|
3631
|
+
}
|
3632
|
+
};
|
3633
|
+
function amountFormat(amt) {
|
3634
|
+
if (amt) {
|
3635
|
+
return `${parseFloat(amt).toLocaleString("en-US", {
|
3636
|
+
minimumFractionDigits: 2,
|
3637
|
+
maximumFractionDigits: 2
|
3638
|
+
})}`;
|
3639
|
+
}
|
3640
|
+
return "";
|
3641
|
+
}
|
3642
|
+
return /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement(ToastContainer3, null), /* @__PURE__ */ React13.createElement(
|
3643
|
+
"button",
|
3644
|
+
{
|
3645
|
+
className: "export-btn mt-4",
|
3646
|
+
style: { width: "100px" },
|
3647
|
+
onClick: () => handlePaymentClick()
|
3648
|
+
},
|
3649
|
+
"TokenizePay"
|
3650
|
+
), /* @__PURE__ */ React13.createElement(
|
3651
|
+
Modal7,
|
3652
|
+
{
|
3653
|
+
show: state.show,
|
3654
|
+
onHide: () => setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3655
|
+
show: false
|
3656
|
+
})),
|
3657
|
+
centered: true
|
3658
|
+
},
|
3659
|
+
/* @__PURE__ */ React13.createElement(Modal7.Header, { closeButton: true }),
|
3660
|
+
/* @__PURE__ */ React13.createElement(Modal7.Body, null, /* @__PURE__ */ React13.createElement("div", { className: "payment-popup" }, /* @__PURE__ */ React13.createElement("div", { className: "row" }, /* @__PURE__ */ React13.createElement("div", { className: "" }, /* @__PURE__ */ React13.createElement("div", { id: "Checkout", className: "inline" }, /* @__PURE__ */ React13.createElement("div", { className: "header" }, /* @__PURE__ */ React13.createElement("h1", null, "Pay")), /* @__PURE__ */ React13.createElement("form", { id: "PaymentForm", className: "payment-form" }, /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement("label", null, "Name on card"), /* @__PURE__ */ React13.createElement(
|
3661
|
+
"input",
|
3662
|
+
{
|
3663
|
+
id: "NameOnCard",
|
3664
|
+
className: "form-control required",
|
3665
|
+
type: "text",
|
3666
|
+
maxLength: 100,
|
3667
|
+
placeholder: "Name"
|
3668
|
+
}
|
3669
|
+
), /* @__PURE__ */ React13.createElement(
|
3670
|
+
"span",
|
3671
|
+
{
|
3672
|
+
id: "NameOnCard-error",
|
3673
|
+
style: { color: "red", display: "none" }
|
3674
|
+
}
|
3675
|
+
)), /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement(
|
3676
|
+
"input",
|
3677
|
+
{
|
3678
|
+
"data-token": "card_number",
|
3679
|
+
className: "null card-image form-control required",
|
3680
|
+
type: "text",
|
3681
|
+
maxLength: 19,
|
3682
|
+
value: state.cardNumber,
|
3683
|
+
placeholder: "0000 0000 0000 0000",
|
3684
|
+
onChange: handleCardNumberChange
|
3685
|
+
}
|
3686
|
+
), state.error && /* @__PURE__ */ React13.createElement("div", { style: { color: "red" } }, state.error)), /* @__PURE__ */ React13.createElement("div", { className: "expiry-date-group form-group" }, /* @__PURE__ */ React13.createElement(
|
3687
|
+
"input",
|
3688
|
+
{
|
3689
|
+
"data-token": "exp_month",
|
3690
|
+
className: "form-control required",
|
3691
|
+
type: "text",
|
3692
|
+
placeholder: "MM",
|
3693
|
+
value: state.month,
|
3694
|
+
maxLength: 2,
|
3695
|
+
onChange: (e) => handleMonthChange(e)
|
3696
|
+
}
|
3697
|
+
), isValidMonth && /* @__PURE__ */ React13.createElement(
|
3698
|
+
"span",
|
3699
|
+
{
|
3700
|
+
id: "card_number-error",
|
3701
|
+
style: { color: "red", fontSize: "15px" }
|
3702
|
+
},
|
3703
|
+
"Please write month only 1 to 12"
|
3704
|
+
)), /* @__PURE__ */ React13.createElement("div", { className: "expiry-date-group form-group" }, /* @__PURE__ */ React13.createElement(
|
3705
|
+
"input",
|
3706
|
+
{
|
3707
|
+
"data-token": "exp_year",
|
3708
|
+
className: "form-control required",
|
3709
|
+
type: "text",
|
3710
|
+
placeholder: "YY",
|
3711
|
+
maxLength: 2,
|
3712
|
+
value: state.year,
|
3713
|
+
onChange: (e) => handleYearChange(e)
|
3714
|
+
}
|
3715
|
+
), state.yearError && /* @__PURE__ */ React13.createElement("span", { id: "exp_year-error", style: { color: "red" } }, state.yearError)), /* @__PURE__ */ React13.createElement("div", { className: "security-code-group form-group" }, /* @__PURE__ */ React13.createElement("div", { className: "input-container" }, /* @__PURE__ */ React13.createElement(
|
3716
|
+
"input",
|
3717
|
+
{
|
3718
|
+
"data-token": "cvv",
|
3719
|
+
className: "form-control required",
|
3720
|
+
type: "text",
|
3721
|
+
maxLength: 4,
|
3722
|
+
value: state.cvv,
|
3723
|
+
placeholder: "CVV",
|
3724
|
+
onChange: (e) => handleCVVChange(e)
|
3725
|
+
}
|
3726
|
+
), /* @__PURE__ */ React13.createElement("i", { id: "cvc", className: "fa fa-question-circle" }), state.cvvError && /* @__PURE__ */ React13.createElement("span", { id: "cvv-error", style: { color: "red" } }, state.cvvError)), /* @__PURE__ */ React13.createElement("div", { className: "cvc-preview-container two-card hide" }, /* @__PURE__ */ React13.createElement("div", { className: "amex-cvc-preview" }), /* @__PURE__ */ React13.createElement("div", { className: "visa-mc-dis-cvc-preview" }))), /* @__PURE__ */ React13.createElement("div", { className: "zip-code-group form-group" }, /* @__PURE__ */ React13.createElement("label", null, "Postal code"), /* @__PURE__ */ React13.createElement("div", { className: "input-container" }, /* @__PURE__ */ React13.createElement(
|
3727
|
+
"input",
|
3728
|
+
{
|
3729
|
+
id: "ZIPCode",
|
3730
|
+
className: "form-control required",
|
3731
|
+
name: "zip",
|
3732
|
+
type: "text",
|
3733
|
+
maxLength: 7,
|
3734
|
+
placeholder: "000000",
|
3735
|
+
value: state.zip,
|
3736
|
+
onChange: (e) => handleZIP(e)
|
3737
|
+
}
|
3738
|
+
), /* @__PURE__ */ React13.createElement(
|
3739
|
+
"a",
|
3740
|
+
{
|
3741
|
+
tabIndex: 0,
|
3742
|
+
role: "button",
|
3743
|
+
"data-toggle": "popover",
|
3744
|
+
"data-trigger": "focus",
|
3745
|
+
"data-placement": "left",
|
3746
|
+
"data-content": "Enter the ZIP/Postal code for your credit card billing address."
|
3747
|
+
},
|
3748
|
+
/* @__PURE__ */ React13.createElement("i", { className: "fa fa-question-circle" })
|
3749
|
+
), /* @__PURE__ */ React13.createElement(
|
3750
|
+
"span",
|
3751
|
+
{
|
3752
|
+
id: "ZIPCode-error",
|
3753
|
+
style: { color: "red", display: "none" }
|
3754
|
+
},
|
3755
|
+
"This field is required"
|
3756
|
+
))), /* @__PURE__ */ React13.createElement("div", { className: "form-group top-amnt" }, /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("label", null, "Payment amount"), /* @__PURE__ */ React13.createElement("div", { className: "amount-placeholder" }, /* @__PURE__ */ React13.createElement(
|
3757
|
+
"input",
|
3758
|
+
{
|
3759
|
+
id: "Amount",
|
3760
|
+
className: "form-control required",
|
3761
|
+
name: "amount",
|
3762
|
+
type: "text",
|
3763
|
+
placeholder: "",
|
3764
|
+
value: state.amount,
|
3765
|
+
onChange: (e) => handleAmount(e),
|
3766
|
+
onBlur: handleAmountBlur
|
3767
|
+
}
|
3768
|
+
))), /* @__PURE__ */ React13.createElement("div", { className: "card-row" }, /* @__PURE__ */ React13.createElement("span", { className: "visa" }), /* @__PURE__ */ React13.createElement("span", { className: "mastercard" }), /* @__PURE__ */ React13.createElement("span", { className: "amex" }), /* @__PURE__ */ React13.createElement("span", { className: "discover" }))), /* @__PURE__ */ React13.createElement(
|
3769
|
+
"button",
|
3770
|
+
{
|
3771
|
+
type: "button",
|
3772
|
+
id: "submitButton",
|
3773
|
+
onClick: () => handleSubmitPay(),
|
3774
|
+
className: "btn btn-block btn-success submit-button"
|
3775
|
+
},
|
3776
|
+
"Submit"
|
3777
|
+
)), /* @__PURE__ */ React13.createElement("div", { className: "powerd-by-part" }, /* @__PURE__ */ React13.createElement(
|
3778
|
+
"svg",
|
3779
|
+
{
|
3780
|
+
xmlns: "http://www.w3.org/2000/svg",
|
3781
|
+
width: "20",
|
3782
|
+
height: "20",
|
3783
|
+
viewBox: "0 0 26 26"
|
3784
|
+
},
|
3785
|
+
/* @__PURE__ */ React13.createElement(
|
3786
|
+
"path",
|
3787
|
+
{
|
3788
|
+
fill: "currentColor",
|
3789
|
+
d: "M23.633 5.028a1.074 1.074 0 0 0-.777-.366c-2.295-.06-5.199-2.514-7.119-3.477C14.551.592 13.768.201 13.18.098a1.225 1.225 0 0 0-.36.001c-.588.103-1.371.494-2.556 1.087c-1.92.962-4.824 3.416-7.119 3.476a1.08 1.08 0 0 0-.778.366a1.167 1.167 0 0 0-.291.834c.493 10.023 4.088 16.226 10.396 19.831c.164.093.346.141.527.141s.363-.048.528-.141c6.308-3.605 9.902-9.808 10.396-19.831a1.161 1.161 0 0 0-.29-.834zM18.617 8.97l-5.323 7.855c-.191.282-.491.469-.788.469c-.298 0-.629-.163-.838-.372l-3.752-3.753a.656.656 0 0 1 0-.926l.927-.929a.658.658 0 0 1 .926 0l2.44 2.44l4.239-6.257a.657.657 0 0 1 .91-.173l1.085.736a.657.657 0 0 1 .174.91z"
|
3790
|
+
}
|
3791
|
+
)
|
3792
|
+
), "Secure payments powered by Fractal", /* @__PURE__ */ React13.createElement(
|
3793
|
+
"img",
|
3794
|
+
{
|
3795
|
+
src: "https://ui.fractalpay.com/favicon.ico",
|
3796
|
+
alt: "Fractal logo",
|
3797
|
+
className: "powered-logo"
|
3798
|
+
}
|
3799
|
+
)))))))
|
3800
|
+
));
|
3801
|
+
}
|
3802
|
+
|
3803
|
+
// src/app/components/Payment/GetPaymentDynamic.tsx
|
3804
|
+
import React15, { useEffect as useEffect4, useState as useState10 } from "react";
|
3805
|
+
import { Modal as Modal8 } from "react-bootstrap";
|
3400
3806
|
|
3401
3807
|
// src/app/components/Loader/MyLoadingAnimation.tsx
|
3402
|
-
import
|
3808
|
+
import React14 from "react";
|
3403
3809
|
function MyLoadingAnimation() {
|
3404
|
-
return /* @__PURE__ */
|
3810
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(LoaderStyle_default, null), /* @__PURE__ */ React14.createElement("div", { className: "loading-animation" }, /* @__PURE__ */ React14.createElement("div", { className: "spinner" })));
|
3405
3811
|
}
|
3406
3812
|
|
3407
3813
|
// src/app/components/Payment/GetPaymentDynamic.tsx
|
3408
3814
|
function GetPaymentDynamic(props) {
|
3409
3815
|
const { amount, fractalpayClientKey, orderID } = props;
|
3410
|
-
const [loading, setLoading] =
|
3411
|
-
const [show, setShow] =
|
3412
|
-
const [iframeLoaded, setIframeLoaded] =
|
3816
|
+
const [loading, setLoading] = useState10(false);
|
3817
|
+
const [show, setShow] = useState10(false);
|
3818
|
+
const [iframeLoaded, setIframeLoaded] = useState10(false);
|
3819
|
+
const [phoneNumber, setPhoneNumber] = useState10("");
|
3820
|
+
const [errorMessage, setErrorMessage] = useState10("");
|
3821
|
+
const [submitClicked, setSubmitClicked] = useState10(false);
|
3822
|
+
const [isValidNumber, setIsValidNumber] = useState10(true);
|
3413
3823
|
const handleClose = () => {
|
3414
3824
|
setIframeLoaded(false);
|
3415
3825
|
setTimeout(() => {
|
@@ -3429,6 +3839,21 @@ function GetPaymentDynamic(props) {
|
|
3429
3839
|
console.error(ErrorText.fractalpayclientidrequired);
|
3430
3840
|
}
|
3431
3841
|
}, [fractalpayClientKey]);
|
3842
|
+
const handlePhoneNumberChange = (e) => {
|
3843
|
+
const number = e.target.value;
|
3844
|
+
const isValid = /^\d*$/.test(number);
|
3845
|
+
if (isValid) {
|
3846
|
+
setPhoneNumber(number);
|
3847
|
+
setIsValidNumber(number.length <= 10);
|
3848
|
+
if (number.length > 10) {
|
3849
|
+
setErrorMessage(ErrorText.phonenumbervalid);
|
3850
|
+
} else {
|
3851
|
+
setErrorMessage("");
|
3852
|
+
}
|
3853
|
+
} else {
|
3854
|
+
setErrorMessage(ErrorText.phonenumbervalidnumberonly);
|
3855
|
+
}
|
3856
|
+
};
|
3432
3857
|
const handleLoad = () => {
|
3433
3858
|
setLoading(false);
|
3434
3859
|
};
|
@@ -3447,7 +3872,7 @@ function GetPaymentDynamic(props) {
|
|
3447
3872
|
window.removeEventListener("message", messageListener);
|
3448
3873
|
};
|
3449
3874
|
}, []);
|
3450
|
-
return /* @__PURE__ */
|
3875
|
+
return /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement("button", { className: "paymentBtn", onClick: handleShow }, "Pay"), /* @__PURE__ */ React15.createElement(Modal8, { show: show && iframeLoaded, id: "modal-pay", className: "modal-lg", onHide: handleClose }, /* @__PURE__ */ React15.createElement(Modal8.Header, { closeButton: true }), /* @__PURE__ */ React15.createElement(Modal8.Body, null, loading && /* @__PURE__ */ React15.createElement(MyLoadingAnimation, null), /* @__PURE__ */ React15.createElement(
|
3451
3876
|
"iframe",
|
3452
3877
|
{
|
3453
3878
|
src: `${baseUrl}widget-form/${amount}?fractalpay_public_key=${fractalpayClientKey}&order_id=${orderID}`,
|
@@ -3466,5 +3891,6 @@ export {
|
|
3466
3891
|
RequestPaymentAllInput,
|
3467
3892
|
RequestPaymentDynamic,
|
3468
3893
|
RequestPaymentonClick,
|
3469
|
-
RqstPaymntInputField
|
3894
|
+
RqstPaymntInputField,
|
3895
|
+
TockenizPay
|
3470
3896
|
};
|