@fractalpay/fractalpay-next-dev 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. package/dist/index.js +16 -2544
  2. package/dist/index.mjs +16 -2506
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,46 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
-
33
- // src/app/components/RequestPayment/RequestPayment.tsx
34
- import "bootstrap/dist/js/bootstrap.bundle.min.js";
35
- import React6, { useState, useEffect } from "react";
36
-
37
- // src/app/components/Loader/Loader.tsx
38
- import React2 from "react";
39
-
40
- // src/app/components/Loader/LoaderStyle.tsx
41
- import React from "react";
42
- var LoaderStyle = (props) => {
43
- return /* @__PURE__ */ React.createElement("style", null, `
1
+ var Qt=Object.defineProperty,Xt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var Nt=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable;var At=(e,y,P)=>y in e?Qt(e,y,{enumerable:!0,configurable:!0,writable:!0,value:P}):e[y]=P,F=(e,y)=>{for(var P in y||(y={}))Bt.call(y,P)&&At(e,P,y[P]);if(Nt)for(var P of Nt(y))Tt.call(y,P)&&At(e,P,y[P]);return e},L=(e,y)=>Xt(e,Dt(y));var kt=(e,y)=>{var P={};for(var $ in e)Bt.call(e,$)&&y.indexOf($)<0&&(P[$]=e[$]);if(e!=null&&Nt)for(var $ of Nt(e))y.indexOf($)<0&&Tt.call(e,$)&&(P[$]=e[$]);return P};import"bootstrap/dist/js/bootstrap.bundle.min.js";import c,{useState as it,useEffect as ln}from"react";import et from"react";import Rt from"react";var en=e=>Rt.createElement("style",null,`
44
2
 
45
3
  .loader {
46
4
  position: fixed; /* Fixed position to cover the viewport */
@@ -122,54 +80,7 @@ var LoaderStyle = (props) => {
122
80
  }
123
81
  }
124
82
 
125
- `);
126
- };
127
- var LoaderStyle_default = LoaderStyle;
128
-
129
- // src/app/components/Loader/Loader.tsx
130
- var Loader = (props) => {
131
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(LoaderStyle_default, null), (props == null ? void 0 : props.loading) && /* @__PURE__ */ React2.createElement("div", { className: "loader" }, /* @__PURE__ */ React2.createElement("div", { className: "lds-ellipsis" }, /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("div", null))));
132
- };
133
- var Loader_default = Loader;
134
-
135
- // src/app/components/baseurl.ts
136
- var fractalGatewayUrl = "https://api-dev.merchant-trends.com/";
137
- var masterBaseUrl = "https://dev-sky-node.fractalpay.com/";
138
- var baseUrl = "https://dev-widget.fractalpay.com/";
139
-
140
- // src/app/components/Errortext.ts
141
- var ErrorText = {
142
- namerequired: "Full Name is required",
143
- amountrequired: "Amount is required",
144
- amountpositive: "Amount should be positive",
145
- amountzero: "Amount should not be zero",
146
- amountenter: "Please enter an amount",
147
- amountvalid: "Please enter a valid amount",
148
- phoneoremailrequired: "Phone or Email is required",
149
- invalidemail: "Please enter a valid email",
150
- invalidemailformat: "Invalid email format",
151
- onlylettersallowed: "Only letters are allowed",
152
- phonenumberlength: "Phone number should be 10 digits",
153
- phonenumberrequired: "Please enter a phone number",
154
- // phonenumbervalid:'Please enter a valid 10-digit phone number',
155
- phonenumbervalid: "Please enter a valid phone number",
156
- phonenumbervalidnumberonly: "Please enter a valid phone number (numbers only)",
157
- orderidenter: "Please enter an order ID",
158
- orderidrequired: "Order ID is required",
159
- networkresponseerror: "Network response was not ok",
160
- anerroroccured: "An error occurred. Please try again.",
161
- montherror: "Please write month only 1 to 12",
162
- fieldrequired: "This field is required",
163
- fractalpayclientidrequired: "Fractalpay client key is missing or empty."
164
- };
165
-
166
- // src/app/components/CustomModal/CustomModal2.tsx
167
- import React4 from "react";
168
-
169
- // src/app/components/CustomModal/CustomModal2styles.tsx
170
- import React3 from "react";
171
- var CustomModal2styles = (props) => {
172
- return /* @__PURE__ */ React3.createElement("style", null, `
83
+ `),jt=en;var tn=e=>et.createElement(et.Fragment,null,et.createElement(jt,null),(e==null?void 0:e.loading)&&et.createElement("div",{className:"loader"},et.createElement("div",{className:"lds-ellipsis"},et.createElement("div",null),et.createElement("div",null),et.createElement("div",null),et.createElement("div",null)))),Qe=tn;var ut="https://api-dev.merchant-trends.com/",pt="https://dev-sky-node.fractalpay.com/",ce="https://dev-widget.fractalpay.com/";var fe={namerequired:"Full Name is required",amountrequired:"Amount is required",amountpositive:"Amount should be positive",amountzero:"Amount should not be zero",amountenter:"Please enter an amount",amountvalid:"Please enter a valid amount",phoneoremailrequired:"Phone or Email is required",invalidemail:"Please enter a valid email",invalidemailformat:"Invalid email format",onlylettersallowed:"Only letters are allowed",phonenumberlength:"Phone number should be 10 digits",phonenumberrequired:"Please enter a phone number",phonenumbervalid:"Please enter a valid phone number",phonenumbervalidnumberonly:"Please enter a valid phone number (numbers only)",orderidenter:"Please enter an order ID",orderidrequired:"Order ID is required",networkresponseerror:"Network response was not ok",anerroroccured:"An error occurred. Please try again.",montherror:"Please write month only 1 to 12",fieldrequired:"This field is required",fractalpayclientidrequired:"Fractalpay client key is missing or empty."};import yt from"react";import nn from"react";var an=e=>nn.createElement("style",null,`
173
84
  .fractal-input::placeholder {
174
85
  color: #35254D;
175
86
  opacity: 1;
@@ -422,30 +333,7 @@ var CustomModal2styles = (props) => {
422
333
  padding: 0px !important;
423
334
  border-radius: 12px !important;
424
335
  }
425
- `);
426
- };
427
- var CustomModal2styles_default = CustomModal2styles;
428
-
429
- // src/app/components/CustomModal/CustomModal2.tsx
430
- var CustomModal2 = ({
431
- open,
432
- onClose,
433
- children,
434
- maxWidth
435
- }) => {
436
- if (!open) return null;
437
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(CustomModal2styles_default, null), /* @__PURE__ */ React4.createElement("div", { className: "fractal-popup" }, /* @__PURE__ */ React4.createElement("div", { className: "fractal-popup-content request-payment-popup-container", style: { maxWidth: `${maxWidth != null ? maxWidth : "auto"}` } }, children)));
438
- };
439
- var CustomModal2_default = CustomModal2;
440
-
441
- // src/app/components/RequestPayment/RequestPayment.tsx
442
- import axios from "axios";
443
- import { PatternFormat } from "react-number-format";
444
-
445
- // src/app/components/RequestPayment/RequestPaymentstyles.tsx
446
- import React5 from "react";
447
- var RequestPaymentstyles = (props) => {
448
- return /* @__PURE__ */ React5.createElement("style", null, `
336
+ `),Yt=an;var on=({open:e,onClose:y,children:P,maxWidth:$})=>e?yt.createElement(yt.Fragment,null,yt.createElement(Yt,null),yt.createElement("div",{className:"fractal-popup"},yt.createElement("div",{className:"fractal-popup-content request-payment-popup-container",style:{maxWidth:`${$!=null?$:"auto"}`}},P))):null,Xe=on;import dn from"axios";import{PatternFormat as mn}from"react-number-format";import rn from"react";var sn=e=>rn.createElement("style",null,`
449
337
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
450
338
  body {
451
339
  font-family: 'Inter', sans-serif !important;
@@ -686,496 +574,7 @@ var RequestPaymentstyles = (props) => {
686
574
 
687
575
  font-size: 12px;
688
576
  }
689
- `);
690
- };
691
- var RequestPaymentstyles_default = RequestPaymentstyles;
692
-
693
- // src/app/components/RequestPayment/RequestPayment.tsx
694
- function RequestPayment(props) {
695
- const fractalpayClientKey = props.fractalpayClientKey;
696
- const discount = props == null ? void 0 : props.discount;
697
- const tax = props == null ? void 0 : props.tax;
698
- const surcharge = props == null ? void 0 : props.surcharge;
699
- const [show, setShow] = useState(false);
700
- const [loading, setLoading] = useState(false);
701
- const [errors, setErrors] = useState({});
702
- const [phone, setPhone] = useState(null);
703
- const [requestDetails, setRequestDetails] = useState({
704
- email: "",
705
- phone_number: "",
706
- order_id: "",
707
- name: "",
708
- fractalpayPublicKey: fractalpayClientKey
709
- });
710
- const [amount, setAmount] = useState("");
711
- const [showConfirmationModal, setShowConfirmationModal] = useState(false);
712
- const [apiResponse, setApiResponse] = useState(null);
713
- const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
714
- const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
715
- const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
716
- const isAlpha = (value) => /^[A-Za-z\s]*$/.test(value);
717
- const handleClose = () => {
718
- setShow(false);
719
- setErrors({});
720
- };
721
- const handleShow = () => setShow(true);
722
- const handleCloseConfirmationModal = () => {
723
- console.log(apiResponse, "apiresponse");
724
- handleSubmit(apiResponse);
725
- setShowConfirmationModal(false);
726
- };
727
- function emptyFields() {
728
- setRequestDetails({
729
- email: "",
730
- phone_number: "",
731
- order_id: "",
732
- name: "",
733
- fractalpayPublicKey: fractalpayClientKey
734
- });
735
- setAmount("");
736
- }
737
- function handleSubmit(event) {
738
- let message = {
739
- type: "preview.compiledcheck",
740
- other: __spreadProps(__spreadValues({}, event), { status: true })
741
- };
742
- window.parent.postMessage(message, "*");
743
- }
744
- const sendRequestPayment = async () => {
745
- if (Object.keys(errors).length > 0) {
746
- return;
747
- }
748
- setErrors({});
749
- if (!(requestDetails == null ? void 0 : requestDetails.email) && phone && !phoneNumberRegex(phone)) {
750
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
751
- phone: ErrorText.phonenumbervalid
752
- }));
753
- return;
754
- }
755
- if (!validateForm()) {
756
- return;
757
- }
758
- try {
759
- setLoading(true);
760
- const formData = {
761
- fractalpayPublicKey: fractalpayClientKey,
762
- amount,
763
- phone_number: phone,
764
- order_id: requestDetails.order_id,
765
- action: "request",
766
- name: requestDetails.name,
767
- email: requestDetails.email,
768
- customer_id: (props == null ? void 0 : props.customerId) ? props == null ? void 0 : props.customerId : "",
769
- discount,
770
- surcharge,
771
- tax,
772
- require_3ds: props == null ? void 0 : props.require_3ds
773
- };
774
- let response = await axios.post(`${baseUrl}create-widget-order`, formData);
775
- if ((response == null ? void 0 : response.status) === 200) {
776
- setShowConfirmationModal(true);
777
- setShow(false);
778
- emptyFields();
779
- setApiResponse(response == null ? void 0 : response.data);
780
- }
781
- setLoading(false);
782
- } catch (error) {
783
- console.log(error);
784
- setLoading(false);
785
- }
786
- };
787
- let favicon_logo = baseUrl + "images/logo-img.png";
788
- const handleChange = (e) => {
789
- const { value } = e.target;
790
- const token = e.target.dataset.token;
791
- setRequestDetails(__spreadProps(__spreadValues({}, requestDetails), { [token]: value }));
792
- if (token === "name" && !isAlpha(value)) {
793
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
794
- [token]: ErrorText.onlylettersallowed
795
- }));
796
- return;
797
- }
798
- let errorobj = errors;
799
- if (token === "email" && !phone) {
800
- delete errorobj.phone;
801
- setErrors(errorobj);
802
- }
803
- if (value) {
804
- delete errorobj[token];
805
- setErrors(errorobj);
806
- }
807
- if (token === "email" && !value) {
808
- delete errorobj[token];
809
- setErrors(errorobj);
810
- }
811
- };
812
- const handleAmountChange = (data) => {
813
- const { value } = data;
814
- if (Number(value) > 0) {
815
- let errorobj = errors;
816
- delete errorobj.amount;
817
- setErrors(errorobj);
818
- }
819
- setAmount(value);
820
- };
821
- const validateForm = () => {
822
- let newErrors = {};
823
- if (!amount) newErrors.amount = ErrorText.amountrequired;
824
- if (requestDetails.email && !isValidEmail(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.invalidemail;
825
- if (!phone && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.phone = ErrorText.phoneoremailrequired;
826
- if (!phone && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.phoneoremailrequired;
827
- if (!phone && requestDetails.email && !isValidEmail(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.invalidemail;
828
- if (props.from === "merchant" && !requestDetails.order_id) newErrors.order_id = ErrorText.orderidrequired;
829
- setErrors(newErrors);
830
- return Object.keys(newErrors).length === 0;
831
- };
832
- useEffect(() => {
833
- if (props) {
834
- setRequestDetails((prev) => __spreadProps(__spreadValues({}, prev), {
835
- order_id: props.orderID ? props.orderID : "",
836
- name: (props == null ? void 0 : props.name) ? props == null ? void 0 : props.name : "",
837
- email: (props == null ? void 0 : props.email) ? props == null ? void 0 : props.email : ""
838
- }));
839
- setAmount(props.amount ? props.amount : "");
840
- setPhone(props.phone ? `${props.phone}` : null);
841
- }
842
- }, [props]);
843
- const handlePhoneChange = (e) => {
844
- let value = e == null ? void 0 : e.value;
845
- if (value && (value == null ? void 0 : value.length) > 0 && (value == null ? void 0 : value.length) !== 10) {
846
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
847
- phone: ErrorText.phonenumberlength
848
- }));
849
- setPhone(value);
850
- return;
851
- } else {
852
- setPhone(value);
853
- }
854
- let errorobj = errors;
855
- delete errorobj.phone;
856
- if (value && !(requestDetails == null ? void 0 : requestDetails.email)) {
857
- delete errorobj.email;
858
- }
859
- setErrors(errorobj);
860
- };
861
- function formatAmount(amount2) {
862
- return new Intl.NumberFormat("en-US", {
863
- style: "currency",
864
- currency: "USD",
865
- minimumFractionDigits: 2,
866
- maximumFractionDigits: 2
867
- }).format(Number(amount2));
868
- }
869
- return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(RequestPaymentstyles_default, null), /* @__PURE__ */ React6.createElement(Loader_default, { loading }), /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("button", { className: "paymentBtn", onClick: handleShow }, "Request Payment"), /* @__PURE__ */ React6.createElement(
870
- CustomModal2_default,
871
- {
872
- open: show,
873
- onClose: () => setShow(false),
874
- maxWidth: "500px"
875
- },
876
- /* @__PURE__ */ React6.createElement("div", { style: { maxWidth: "500px" } }, /* @__PURE__ */ React6.createElement("div", { className: "request-payment-amount-detail frac-form" }, /* @__PURE__ */ React6.createElement("p", { className: "request-payment-merchantname" }, "Pay ", props == null ? void 0 : props.webname), /* @__PURE__ */ React6.createElement("p", { className: "request-payment-amount" }, formatAmount(props == null ? void 0 : props.amount)), (props == null ? void 0 : props.from) === "merchant" && /* @__PURE__ */ React6.createElement("p", { className: "request-payment-orderid" }, requestDetails == null ? void 0 : requestDetails.order_id), /* @__PURE__ */ React6.createElement("span", { className: "request-payment-close-popup", onClick: handleClose }, /* @__PURE__ */ React6.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React6.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React6.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React6.createElement("defs", null, /* @__PURE__ */ React6.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React6.createElement("rect", { width: "16", height: "16", fill: "white" })))))), /* @__PURE__ */ React6.createElement("form", { className: "request-payment-input-form" }, /* @__PURE__ */ React6.createElement("div", { className: "request-payment-list-div" }, /* @__PURE__ */ React6.createElement("label", { htmlFor: "exampleFormControlInput2", className: "request-payment-input-label" }, "FULL NAME"), /* @__PURE__ */ React6.createElement(
877
- "input",
878
- {
879
- className: "request-payment-input-box",
880
- type: "text",
881
- placeholder: "Full Name",
882
- "data-token": "name",
883
- onChange: handleChange,
884
- value: requestDetails == null ? void 0 : requestDetails.name
885
- }
886
- ), errors.name && /* @__PURE__ */ React6.createElement("small", { className: "request-payment-error-msg" }, errors.name)), /* @__PURE__ */ React6.createElement("div", { className: "request-payment-list-div" }, /* @__PURE__ */ React6.createElement("label", { htmlFor: "requestPhoneNumber", className: "request-payment-input-label" }, "Phone Number"), /* @__PURE__ */ React6.createElement(
887
- PatternFormat,
888
- {
889
- className: "request-payment-input-box",
890
- placeholder: "Mobile number",
891
- format: "+1 (###) ###-####",
892
- value: phone,
893
- onValueChange: (e) => {
894
- handlePhoneChange(e);
895
- }
896
- }
897
- ), errors.phone && /* @__PURE__ */ React6.createElement("small", { className: "request-payment-error-msg" }, errors.phone)), /* @__PURE__ */ React6.createElement("div", { className: "request-payment-list-div" }, /* @__PURE__ */ React6.createElement("label", { htmlFor: "exampleFormControlInput2", className: "request-payment-input-label" }, "EMAIL"), /* @__PURE__ */ React6.createElement(
898
- "input",
899
- {
900
- className: "request-payment-input-box",
901
- type: "text",
902
- placeholder: "Email",
903
- onChange: handleChange,
904
- "data-token": "email",
905
- value: requestDetails == null ? void 0 : requestDetails.email
906
- }
907
- ), errors.email && /* @__PURE__ */ React6.createElement("small", { className: "request-payment-error-msg" }, errors.email)), /* @__PURE__ */ React6.createElement(
908
- "button",
909
- {
910
- type: "button",
911
- className: "request-payment-submit-button",
912
- onClick: sendRequestPayment,
913
- disabled: loading
914
- },
915
- loading ? "Loading..." : "Send Request"
916
- ), /* @__PURE__ */ React6.createElement("div", { className: "request-payment-fractal-powerd-by" }, /* @__PURE__ */ React6.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "17", height: "16", viewBox: "0 0 17 16", fill: "none" }, /* @__PURE__ */ React6.createElement("path", { d: "M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z", fill: "#727272" })), "Secure payments powered by ", /* @__PURE__ */ React6.createElement("span", null, "Fractal"), /* @__PURE__ */ React6.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", fill: "none" }, /* @__PURE__ */ React6.createElement("path", { d: "M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z", fill: "#61C699" }), /* @__PURE__ */ React6.createElement("path", { d: "M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z", fill: "#61C699" })))))
917
- ), /* @__PURE__ */ React6.createElement(
918
- CustomModal2_default,
919
- {
920
- open: showConfirmationModal,
921
- onClose: handleCloseConfirmationModal,
922
- maxWidth: "500px"
923
- },
924
- /* @__PURE__ */ React6.createElement("div", { className: "fractal-popup-content", style: { padding: "0px", maxWidth: "500px" } }, /* @__PURE__ */ React6.createElement("div", { className: "request-payment-success-container" }, /* @__PURE__ */ React6.createElement("span", { className: "request-payment-close-popup", onClick: handleCloseConfirmationModal }, /* @__PURE__ */ React6.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React6.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React6.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React6.createElement("defs", null, /* @__PURE__ */ React6.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React6.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ React6.createElement("div", { className: "request-payment-success-tick-div" }, /* @__PURE__ */ React6.createElement("div", { className: "request-payment-success-tick" }, /* @__PURE__ */ React6.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React6.createElement("path", { d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z", fill: "#61C699" })))), /* @__PURE__ */ React6.createElement("h6", { className: "request-payment-success-text" }, "The request ", /* @__PURE__ */ React6.createElement("br", null), "was sent"), /* @__PURE__ */ React6.createElement("h6", { className: "request-payment-success-subtext" }, "Please wait for the customer to pay"), /* @__PURE__ */ React6.createElement("div", { className: "request-payment-success-btn-div" }, /* @__PURE__ */ React6.createElement("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2" }, "Close"))))
925
- )));
926
- }
927
-
928
- // src/app/components/RequestPayment/RequestPreAuthPayment.tsx
929
- import "bootstrap/dist/js/bootstrap.bundle.min.js";
930
- import React7, { useState as useState2, useEffect as useEffect2 } from "react";
931
- import axios2 from "axios";
932
- import { PatternFormat as PatternFormat2 } from "react-number-format";
933
- function RequestPreAuthPayment(props) {
934
- const fractalpayClientKey = props.fractalpayClientKey;
935
- const discount = props == null ? void 0 : props.discount;
936
- const tax = props == null ? void 0 : props.tax;
937
- const surcharge = props == null ? void 0 : props.surcharge;
938
- const [show, setShow] = useState2(false);
939
- const [loading, setLoading] = useState2(false);
940
- const [errors, setErrors] = useState2({});
941
- const [phone, setPhone] = useState2(null);
942
- const [requestDetails, setRequestDetails] = useState2({
943
- email: "",
944
- phone_number: "",
945
- order_id: "",
946
- name: "",
947
- fractalpayPublicKey: fractalpayClientKey
948
- });
949
- const [amount, setAmount] = useState2("");
950
- const [showConfirmationModal, setShowConfirmationModal] = useState2(false);
951
- const [apiResponse, setApiResponse] = useState2(null);
952
- const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
953
- const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
954
- const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
955
- const isAlpha = (value) => /^[A-Za-z\s]*$/.test(value);
956
- const handleClose = () => {
957
- setShow(false);
958
- setErrors({});
959
- };
960
- const handleShow = () => setShow(true);
961
- const handleCloseConfirmationModal = () => {
962
- console.log(apiResponse, "apiresponse");
963
- handleSubmit(apiResponse);
964
- setShowConfirmationModal(false);
965
- };
966
- function emptyFields() {
967
- setRequestDetails({
968
- email: "",
969
- phone_number: "",
970
- order_id: "",
971
- name: "",
972
- fractalpayPublicKey: fractalpayClientKey
973
- });
974
- setAmount("");
975
- }
976
- function handleSubmit(event) {
977
- let message = {
978
- type: "preview.compiledcheck",
979
- other: __spreadProps(__spreadValues({}, event), { status: true })
980
- };
981
- window.parent.postMessage(message, "*");
982
- }
983
- const sendRequestPayment = async () => {
984
- if (Object.keys(errors).length > 0) {
985
- return;
986
- }
987
- setErrors({});
988
- if (!(requestDetails == null ? void 0 : requestDetails.email) && phone && !phoneNumberRegex(phone)) {
989
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
990
- phone: ErrorText.phonenumbervalid
991
- }));
992
- return;
993
- }
994
- if (!validateForm()) {
995
- return;
996
- }
997
- try {
998
- setLoading(true);
999
- const formData = {
1000
- fractalpayPublicKey: fractalpayClientKey,
1001
- amount,
1002
- phone_number: phone,
1003
- order_id: requestDetails.order_id,
1004
- action: "request",
1005
- name: requestDetails.name,
1006
- email: requestDetails.email,
1007
- customer_id: (props == null ? void 0 : props.customerId) ? props == null ? void 0 : props.customerId : "",
1008
- discount,
1009
- surcharge,
1010
- tax,
1011
- require_3ds: props == null ? void 0 : props.require_3ds
1012
- };
1013
- let response = await axios2.post(`${baseUrl}send-request-pre-auth-payment`, formData);
1014
- if ((response == null ? void 0 : response.status) === 200) {
1015
- setShowConfirmationModal(true);
1016
- setShow(false);
1017
- emptyFields();
1018
- setApiResponse(response == null ? void 0 : response.data);
1019
- }
1020
- setLoading(false);
1021
- } catch (error) {
1022
- console.log(error);
1023
- setLoading(false);
1024
- }
1025
- };
1026
- let favicon_logo = baseUrl + "images/logo-img.png";
1027
- const handleChange = (e) => {
1028
- const { value } = e.target;
1029
- const token = e.target.dataset.token;
1030
- setRequestDetails(__spreadProps(__spreadValues({}, requestDetails), { [token]: value }));
1031
- if (token === "name" && !isAlpha(value)) {
1032
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1033
- [token]: ErrorText.onlylettersallowed
1034
- }));
1035
- return;
1036
- }
1037
- let errorobj = errors;
1038
- if (token === "email" && !phone) {
1039
- delete errorobj.phone;
1040
- setErrors(errorobj);
1041
- }
1042
- if (value) {
1043
- delete errorobj[token];
1044
- setErrors(errorobj);
1045
- }
1046
- if (token === "email" && !value) {
1047
- delete errorobj[token];
1048
- setErrors(errorobj);
1049
- }
1050
- };
1051
- const handleAmountChange = (data) => {
1052
- const { value } = data;
1053
- if (Number(value) > 0) {
1054
- let errorobj = errors;
1055
- delete errorobj.amount;
1056
- setErrors(errorobj);
1057
- }
1058
- setAmount(value);
1059
- };
1060
- const validateForm = () => {
1061
- let newErrors = {};
1062
- if (!amount) newErrors.amount = ErrorText.amountrequired;
1063
- if (requestDetails.email && !isValidEmail(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.invalidemail;
1064
- if (!phone && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.phone = ErrorText.phoneoremailrequired;
1065
- if (!phone && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.phoneoremailrequired;
1066
- if (!phone && requestDetails.email && !isValidEmail(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.invalidemail;
1067
- if (props.from === "merchant" && !requestDetails.order_id) newErrors.order_id = ErrorText.orderidrequired;
1068
- setErrors(newErrors);
1069
- return Object.keys(newErrors).length === 0;
1070
- };
1071
- useEffect2(() => {
1072
- if (props) {
1073
- setRequestDetails((prev) => __spreadProps(__spreadValues({}, prev), {
1074
- order_id: props.orderID ? props.orderID : "",
1075
- name: (props == null ? void 0 : props.name) ? props == null ? void 0 : props.name : "",
1076
- email: (props == null ? void 0 : props.email) ? props == null ? void 0 : props.email : ""
1077
- }));
1078
- setAmount(props.amount ? props.amount : "");
1079
- setPhone(props.phone ? `${props.phone}` : null);
1080
- }
1081
- }, [props]);
1082
- const handlePhoneChange = (e) => {
1083
- let value = e == null ? void 0 : e.value;
1084
- if (value && (value == null ? void 0 : value.length) > 0 && (value == null ? void 0 : value.length) !== 10) {
1085
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1086
- phone: ErrorText.phonenumberlength
1087
- }));
1088
- setPhone(value);
1089
- return;
1090
- } else {
1091
- setPhone(value);
1092
- }
1093
- let errorobj = errors;
1094
- delete errorobj.phone;
1095
- if (value && !(requestDetails == null ? void 0 : requestDetails.email)) {
1096
- delete errorobj.email;
1097
- }
1098
- setErrors(errorobj);
1099
- };
1100
- function formatAmount(amount2) {
1101
- return new Intl.NumberFormat("en-US", {
1102
- style: "currency",
1103
- currency: "USD",
1104
- minimumFractionDigits: 2,
1105
- maximumFractionDigits: 2
1106
- }).format(Number(amount2));
1107
- }
1108
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(RequestPaymentstyles_default, null), /* @__PURE__ */ React7.createElement(Loader_default, { loading }), /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("button", { className: "paymentBtn", onClick: handleShow }, "Send Request"), /* @__PURE__ */ React7.createElement("div", { className: "frac-form" }, /* @__PURE__ */ React7.createElement(
1109
- CustomModal2_default,
1110
- {
1111
- open: show,
1112
- onClose: () => setShow(false),
1113
- maxWidth: "500px"
1114
- },
1115
- /* @__PURE__ */ React7.createElement("div", { className: "request-payment-amount-detail" }, /* @__PURE__ */ React7.createElement("p", { className: "request-payment-merchantname" }, "Authorization Request"), /* @__PURE__ */ React7.createElement("p", { className: "request-payment-pre-auth-merchantname" }, "Pay ", props == null ? void 0 : props.webname), /* @__PURE__ */ React7.createElement("p", { className: "request-payment-amount" }, formatAmount(props == null ? void 0 : props.amount)), (props == null ? void 0 : props.from) === "merchant" && /* @__PURE__ */ React7.createElement("p", { className: "request-payment-orderid" }, requestDetails == null ? void 0 : requestDetails.order_id), /* @__PURE__ */ React7.createElement("span", { className: "request-payment-close-popup", onClick: handleClose }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React7.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React7.createElement("defs", null, /* @__PURE__ */ React7.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React7.createElement("rect", { width: "16", height: "16", fill: "white" })))))),
1116
- /* @__PURE__ */ React7.createElement("form", { className: "request-payment-input-form" }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-list-div" }, /* @__PURE__ */ React7.createElement("label", { htmlFor: "exampleFormControlInput2", className: "request-payment-input-label" }, "FULL NAME"), /* @__PURE__ */ React7.createElement(
1117
- "input",
1118
- {
1119
- className: "request-payment-input-box",
1120
- type: "text",
1121
- placeholder: "Full Name",
1122
- "data-token": "name",
1123
- onChange: handleChange,
1124
- value: requestDetails == null ? void 0 : requestDetails.name
1125
- }
1126
- ), errors.name && /* @__PURE__ */ React7.createElement("small", { className: "request-payment-error-msg" }, errors.name)), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-list-div" }, /* @__PURE__ */ React7.createElement("label", { htmlFor: "requestPhoneNumber", className: "request-payment-input-label" }, "Phone Number"), /* @__PURE__ */ React7.createElement(
1127
- PatternFormat2,
1128
- {
1129
- className: "request-payment-input-box",
1130
- placeholder: "Mobile number",
1131
- format: "+1 (###) ###-####",
1132
- value: phone,
1133
- onValueChange: (e) => {
1134
- handlePhoneChange(e);
1135
- }
1136
- }
1137
- ), errors.phone && /* @__PURE__ */ React7.createElement("small", { className: "request-payment-error-msg" }, errors.phone)), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-list-div" }, /* @__PURE__ */ React7.createElement("label", { htmlFor: "exampleFormControlInput2", className: "request-payment-input-label" }, "EMAIL"), /* @__PURE__ */ React7.createElement(
1138
- "input",
1139
- {
1140
- className: "request-payment-input-box",
1141
- type: "text",
1142
- placeholder: "Email",
1143
- onChange: handleChange,
1144
- "data-token": "email",
1145
- value: requestDetails == null ? void 0 : requestDetails.email
1146
- }
1147
- ), errors.email && /* @__PURE__ */ React7.createElement("small", { className: "request-payment-error-msg" }, errors.email)), /* @__PURE__ */ React7.createElement(
1148
- "button",
1149
- {
1150
- type: "button",
1151
- className: "request-payment-submit-button",
1152
- onClick: sendRequestPayment,
1153
- disabled: loading
1154
- },
1155
- loading ? "Loading..." : "Send Request"
1156
- ), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-fractal-powerd-by" }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "17", height: "16", viewBox: "0 0 17 16", fill: "none" }, /* @__PURE__ */ React7.createElement("path", { d: "M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z", fill: "#727272" })), "Secure payments powered by ", /* @__PURE__ */ React7.createElement("span", null, "Fractal"), /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", fill: "none" }, /* @__PURE__ */ React7.createElement("path", { d: "M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z", fill: "#61C699" }), /* @__PURE__ */ React7.createElement("path", { d: "M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z", fill: "#61C699" }))))
1157
- ), /* @__PURE__ */ React7.createElement(
1158
- CustomModal2_default,
1159
- {
1160
- open: showConfirmationModal,
1161
- onClose: handleCloseConfirmationModal,
1162
- maxWidth: "500px"
1163
- },
1164
- /* @__PURE__ */ React7.createElement("div", { className: "fractal-popup-content", style: { padding: "0px", maxWidth: "500px" } }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-container" }, /* @__PURE__ */ React7.createElement("span", { className: "request-payment-close-popup", onClick: handleCloseConfirmationModal }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React7.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React7.createElement("defs", null, /* @__PURE__ */ React7.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React7.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-tick-div" }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-tick" }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("path", { d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z", fill: "#61C699" })))), /* @__PURE__ */ React7.createElement("h6", { className: "request-payment-success-text" }, "The request ", /* @__PURE__ */ React7.createElement("br", null), "was sent"), /* @__PURE__ */ React7.createElement("h6", { className: "request-payment-success-subtext" }, "Please wait for the customer to pay"), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-btn-div" }, /* @__PURE__ */ React7.createElement("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2" }, "Close"))))
1165
- ))));
1166
- }
1167
-
1168
- // src/app/components/Charge/GetPaymentPage.tsx
1169
- import React13, { useEffect as useEffect4, useState as useState3 } from "react";
1170
-
1171
- // src/app/components/Charge/Chargewidgetstyles.tsx
1172
- import React8 from "react";
1173
- function Chargewidgetstyles() {
1174
- const primarycolor = "#000";
1175
- const primarybgcolor = "#fff";
1176
- const primarybodycolor = "#212529";
1177
- const primarybordercolor = "#dee2e6";
1178
- return /* @__PURE__ */ React8.createElement("style", null, `
577
+ `),_t=sn;function cn(e){let y=e.fractalpayClientKey,P=e==null?void 0:e.discount,$=e==null?void 0:e.tax,z=e==null?void 0:e.surcharge,[Be,v]=it(!1),[je,ge]=it(!1),[a,Y]=it({}),[g,W]=it(null),[l,Le]=it({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:y}),[ke,s]=it(""),[Se,o]=it(!1),[he,N]=it(null),ve=d=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(d),S=/[+-]?([0-9]*[.])?[0-9]+/,Pe=d=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d),x=d=>/^[A-Za-z\s]*$/.test(d),Ke=()=>{v(!1),Y({})},A=()=>v(!0),C=()=>{console.log(he,"apiresponse"),Z(he),o(!1)};function u(){Le({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:y}),s("")}function Z(d){let h={type:"preview.compiledcheck",other:L(F({},d),{status:!0})};window.parent.postMessage(h,"*")}let b=async()=>{if(!(Object.keys(a).length>0)){if(Y({}),!(l!=null&&l.email)&&g&&!ve(g)){Y(d=>L(F({},d),{phone:fe.phonenumbervalid}));return}if(_e())try{ge(!0);let d={fractalpayPublicKey:y,amount:ke,phone_number:g,order_id:l.order_id,action:"request",name:l.name,email:l.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:P,surcharge:z,tax:$,require_3ds:e==null?void 0:e.require_3ds},h=await dn.post(`${ce}create-widget-order`,d);(h==null?void 0:h.status)===200&&(o(!0),v(!1),u(),N(h==null?void 0:h.data)),ge(!1)}catch(d){console.log(d),ge(!1)}}},H=ce+"images/logo-img.png",le=d=>{let{value:h}=d.target,I=d.target.dataset.token;if(Le(L(F({},l),{[I]:h})),I==="name"&&!x(h)){Y(xe=>L(F({},xe),{[I]:fe.onlylettersallowed}));return}let U=a;I==="email"&&!g&&(delete U.phone,Y(U)),h&&(delete U[I],Y(U)),I==="email"&&!h&&(delete U[I],Y(U))},ye=d=>{let{value:h}=d;if(Number(h)>0){let I=a;delete I.amount,Y(I)}s(h)},_e=()=>{let d={};return ke||(d.amount=fe.amountrequired),l.email&&!Pe(l==null?void 0:l.email)&&(d.email=fe.invalidemail),!g&&!(l!=null&&l.email)&&(d.phone=fe.phoneoremailrequired),!g&&!(l!=null&&l.email)&&(d.email=fe.phoneoremailrequired),!g&&l.email&&!Pe(l==null?void 0:l.email)&&(d.email=fe.invalidemail),e.from==="merchant"&&!l.order_id&&(d.order_id=fe.orderidrequired),Y(d),Object.keys(d).length===0};ln(()=>{e&&(Le(d=>L(F({},d),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),s(e.amount?e.amount:""),W(e.phone?`${e.phone}`:null))},[e]);let Ce=d=>{let h=d==null?void 0:d.value;if(h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.length)!==10){Y(U=>L(F({},U),{phone:fe.phonenumberlength})),W(h);return}else W(h);let I=a;delete I.phone,h&&!(l!=null&&l.email)&&delete I.email,Y(I)};function ue(d){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(d))}return c.createElement(c.Fragment,null,c.createElement(_t,null),c.createElement(Qe,{loading:je}),c.createElement(c.Fragment,null,c.createElement("button",{className:"paymentBtn",onClick:A},"Request Payment"),c.createElement(Xe,{open:Be,onClose:()=>v(!1),maxWidth:"500px"},c.createElement("div",{style:{maxWidth:"500px"}},c.createElement("div",{className:"request-payment-amount-detail frac-form"},c.createElement("p",{className:"request-payment-merchantname"},"Pay ",e==null?void 0:e.webname),c.createElement("p",{className:"request-payment-amount"},ue(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&c.createElement("p",{className:"request-payment-orderid"},l==null?void 0:l.order_id),c.createElement("span",{className:"request-payment-close-popup",onClick:Ke},c.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},c.createElement("g",{clipPath:"url(#clip0_12425_52336)"},c.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_12425_52336"},c.createElement("rect",{width:"16",height:"16",fill:"white"})))))),c.createElement("form",{className:"request-payment-input-form"},c.createElement("div",{className:"request-payment-list-div"},c.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),c.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:le,value:l==null?void 0:l.name}),a.name&&c.createElement("small",{className:"request-payment-error-msg"},a.name)),c.createElement("div",{className:"request-payment-list-div"},c.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),c.createElement(mn,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:g,onValueChange:d=>{Ce(d)}}),a.phone&&c.createElement("small",{className:"request-payment-error-msg"},a.phone)),c.createElement("div",{className:"request-payment-list-div"},c.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),c.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:le,"data-token":"email",value:l==null?void 0:l.email}),a.email&&c.createElement("small",{className:"request-payment-error-msg"},a.email)),c.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:b,disabled:je},je?"Loading...":"Send Request"),c.createElement("div",{className:"request-payment-fractal-powerd-by"},c.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},c.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",c.createElement("span",null,"Fractal"),c.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},c.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),c.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),c.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),c.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),c.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),c.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),c.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),c.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),c.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),c.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),c.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),c.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),c.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),c.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),c.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),c.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),c.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),c.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"})))))),c.createElement(Xe,{open:Se,onClose:C,maxWidth:"500px"},c.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},c.createElement("div",{className:"request-payment-success-container"},c.createElement("span",{className:"request-payment-close-popup",onClick:C},c.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},c.createElement("g",{clipPath:"url(#clip0_12425_52336)"},c.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_12425_52336"},c.createElement("rect",{width:"16",height:"16",fill:"white"}))))),c.createElement("div",{className:"request-payment-success-tick-div"},c.createElement("div",{className:"request-payment-success-tick"},c.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},c.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),c.createElement("h6",{className:"request-payment-success-text"},"The request ",c.createElement("br",null),"was sent"),c.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),c.createElement("div",{className:"request-payment-success-btn-div"},c.createElement("button",{onClick:C,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import m,{useState as at,useEffect as gn}from"react";import un from"axios";import{PatternFormat as pn}from"react-number-format";function fn(e){let y=e.fractalpayClientKey,P=e==null?void 0:e.discount,$=e==null?void 0:e.tax,z=e==null?void 0:e.surcharge,[Be,v]=at(!1),[je,ge]=at(!1),[a,Y]=at({}),[g,W]=at(null),[l,Le]=at({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:y}),[ke,s]=at(""),[Se,o]=at(!1),[he,N]=at(null),ve=d=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(d),S=/[+-]?([0-9]*[.])?[0-9]+/,Pe=d=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d),x=d=>/^[A-Za-z\s]*$/.test(d),Ke=()=>{v(!1),Y({})},A=()=>v(!0),C=()=>{console.log(he,"apiresponse"),Z(he),o(!1)};function u(){Le({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:y}),s("")}function Z(d){let h={type:"preview.compiledcheck",other:L(F({},d),{status:!0})};window.parent.postMessage(h,"*")}let b=async()=>{if(!(Object.keys(a).length>0)){if(Y({}),!(l!=null&&l.email)&&g&&!ve(g)){Y(d=>L(F({},d),{phone:fe.phonenumbervalid}));return}if(_e())try{ge(!0);let d={fractalpayPublicKey:y,amount:ke,phone_number:g,order_id:l.order_id,action:"request",name:l.name,email:l.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:P,surcharge:z,tax:$,require_3ds:e==null?void 0:e.require_3ds},h=await un.post(`${ce}send-request-pre-auth-payment`,d);(h==null?void 0:h.status)===200&&(o(!0),v(!1),u(),N(h==null?void 0:h.data)),ge(!1)}catch(d){console.log(d),ge(!1)}}},H=ce+"images/logo-img.png",le=d=>{let{value:h}=d.target,I=d.target.dataset.token;if(Le(L(F({},l),{[I]:h})),I==="name"&&!x(h)){Y(xe=>L(F({},xe),{[I]:fe.onlylettersallowed}));return}let U=a;I==="email"&&!g&&(delete U.phone,Y(U)),h&&(delete U[I],Y(U)),I==="email"&&!h&&(delete U[I],Y(U))},ye=d=>{let{value:h}=d;if(Number(h)>0){let I=a;delete I.amount,Y(I)}s(h)},_e=()=>{let d={};return ke||(d.amount=fe.amountrequired),l.email&&!Pe(l==null?void 0:l.email)&&(d.email=fe.invalidemail),!g&&!(l!=null&&l.email)&&(d.phone=fe.phoneoremailrequired),!g&&!(l!=null&&l.email)&&(d.email=fe.phoneoremailrequired),!g&&l.email&&!Pe(l==null?void 0:l.email)&&(d.email=fe.invalidemail),e.from==="merchant"&&!l.order_id&&(d.order_id=fe.orderidrequired),Y(d),Object.keys(d).length===0};gn(()=>{e&&(Le(d=>L(F({},d),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),s(e.amount?e.amount:""),W(e.phone?`${e.phone}`:null))},[e]);let Ce=d=>{let h=d==null?void 0:d.value;if(h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.length)!==10){Y(U=>L(F({},U),{phone:fe.phonenumberlength})),W(h);return}else W(h);let I=a;delete I.phone,h&&!(l!=null&&l.email)&&delete I.email,Y(I)};function ue(d){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(d))}return m.createElement(m.Fragment,null,m.createElement(_t,null),m.createElement(Qe,{loading:je}),m.createElement(m.Fragment,null,m.createElement("button",{className:"paymentBtn",onClick:A},"Send Request"),m.createElement("div",{className:"frac-form"},m.createElement(Xe,{open:Be,onClose:()=>v(!1),maxWidth:"500px"},m.createElement("div",{className:"request-payment-amount-detail"},m.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),m.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",e==null?void 0:e.webname),m.createElement("p",{className:"request-payment-amount"},ue(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&m.createElement("p",{className:"request-payment-orderid"},l==null?void 0:l.order_id),m.createElement("span",{className:"request-payment-close-popup",onClick:Ke},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},m.createElement("g",{clipPath:"url(#clip0_12425_52336)"},m.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),m.createElement("defs",null,m.createElement("clipPath",{id:"clip0_12425_52336"},m.createElement("rect",{width:"16",height:"16",fill:"white"})))))),m.createElement("form",{className:"request-payment-input-form"},m.createElement("div",{className:"request-payment-list-div"},m.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),m.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:le,value:l==null?void 0:l.name}),a.name&&m.createElement("small",{className:"request-payment-error-msg"},a.name)),m.createElement("div",{className:"request-payment-list-div"},m.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),m.createElement(pn,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:g,onValueChange:d=>{Ce(d)}}),a.phone&&m.createElement("small",{className:"request-payment-error-msg"},a.phone)),m.createElement("div",{className:"request-payment-list-div"},m.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),m.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:le,"data-token":"email",value:l==null?void 0:l.email}),a.email&&m.createElement("small",{className:"request-payment-error-msg"},a.email)),m.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:b,disabled:je},je?"Loading...":"Send Request"),m.createElement("div",{className:"request-payment-fractal-powerd-by"},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},m.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",m.createElement("span",null,"Fractal"),m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},m.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),m.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),m.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),m.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),m.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),m.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),m.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),m.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),m.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),m.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),m.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),m.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),m.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),m.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),m.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),m.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),m.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),m.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"}))))),m.createElement(Xe,{open:Se,onClose:C,maxWidth:"500px"},m.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},m.createElement("div",{className:"request-payment-success-container"},m.createElement("span",{className:"request-payment-close-popup",onClick:C},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},m.createElement("g",{clipPath:"url(#clip0_12425_52336)"},m.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),m.createElement("defs",null,m.createElement("clipPath",{id:"clip0_12425_52336"},m.createElement("rect",{width:"16",height:"16",fill:"white"}))))),m.createElement("div",{className:"request-payment-success-tick-div"},m.createElement("div",{className:"request-payment-success-tick"},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},m.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),m.createElement("h6",{className:"request-payment-success-text"},"The request ",m.createElement("br",null),"was sent"),m.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),m.createElement("div",{className:"request-payment-success-btn-div"},m.createElement("button",{onClick:C,className:"request-payment-success-btn2"},"Close"))))))))}import t,{useEffect as wn,useState as Ae}from"react";import hn from"react";function xt(){let e="#000",y="#fff",P="#212529",$="#dee2e6";return hn.createElement("style",null,`
1179
578
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
1180
579
  body
1181
580
  {
@@ -1297,7 +696,7 @@ function Chargewidgetstyles() {
1297
696
  border-radius: 5px;
1298
697
  box-shadow: inherit;
1299
698
  outline: none;
1300
- color: ${primarycolor};
699
+ color: ${e};
1301
700
  }
1302
701
 
1303
702
  /* Change background color of buttons on hover */
@@ -1404,13 +803,13 @@ function Chargewidgetstyles() {
1404
803
  font-size: 1rem;
1405
804
  font-weight: 400;
1406
805
  line-height: 1.5;
1407
- color: ${primarybodycolor};
806
+ color: ${P};
1408
807
  -webkit-appearance: none;
1409
808
  -moz-appearance: none;
1410
809
  appearance: none;
1411
- background-color: ${primarybgcolor};
810
+ background-color: ${y};
1412
811
  background-clip: padding-box;
1413
- border: 1px solid ${primarybordercolor};
812
+ border: 1px solid ${$};
1414
813
  border-radius: 0.375rem;
1415
814
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
1416
815
  }
@@ -1428,7 +827,7 @@ function Chargewidgetstyles() {
1428
827
  }
1429
828
  .card-crdi {
1430
829
  display: flex;
1431
- border: 1px solid ${primarybordercolor};
830
+ border: 1px solid ${$};
1432
831
  border-radius: 0.375rem;
1433
832
  }
1434
833
  .card-expiry-new{
@@ -1454,7 +853,7 @@ function Chargewidgetstyles() {
1454
853
  border-top-right-radius: 0;
1455
854
  border-bottom-right-radius: 0;
1456
855
  border: 0;
1457
- border-right: 1px solid ${primarybordercolor};
856
+ border-right: 1px solid ${$};
1458
857
  }
1459
858
 
1460
859
 
@@ -1468,7 +867,7 @@ function Chargewidgetstyles() {
1468
867
  border-radius: 0;
1469
868
  border-top: 0;
1470
869
  border-bottom: 0;
1471
- border-right: 1px solid ${primarybordercolor};
870
+ border-right: 1px solid ${$};
1472
871
  }
1473
872
 
1474
873
  .exp-date input:focus {
@@ -1769,19 +1168,7 @@ function Chargewidgetstyles() {
1769
1168
 
1770
1169
 
1771
1170
 
1772
- `);
1773
- }
1774
-
1775
- // src/app/components/Charge/GetPaymentPage.tsx
1776
- import axios3 from "axios";
1777
-
1778
- // src/app/components/SuccessMessage/SuccessMsz.tsx
1779
- import React10 from "react";
1780
-
1781
- // src/app/components/SuccessMessage/SuccessMszStyle.tsx
1782
- import React9 from "react";
1783
- function SuccessMszStyle() {
1784
- return /* @__PURE__ */ React9.createElement("style", null, `
1171
+ `)}import vt from"axios";import J from"react";import yn from"react";function Ft(){return yn.createElement("style",null,`
1785
1172
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
1786
1173
 
1787
1174
  body{
@@ -1976,160 +1363,7 @@ function SuccessMszStyle() {
1976
1363
  gap: 6px;
1977
1364
  background-color: #161616;
1978
1365
  color: #fff;
1979
- }`);
1980
- }
1981
-
1982
- // src/app/components/SuccessMessage/HandleSubmit.tsx
1983
- function HandleSubmit(event, key, tranId) {
1984
- event.preventDefault();
1985
- const status = key === "close";
1986
- const message = {
1987
- type: "preview.compiledcheck",
1988
- other: {
1989
- msg: "Payment success!",
1990
- status,
1991
- data: {
1992
- tran_id: tranId,
1993
- key
1994
- }
1995
- }
1996
- };
1997
- console.log("message:", message);
1998
- window.parent.postMessage(message, "*");
1999
- }
2000
-
2001
- // src/app/components/SuccessMessage/SuccessMsz.tsx
2002
- function SuccessMsz({ onClose, tranId }) {
2003
- return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(SuccessMszStyle, null), /* @__PURE__ */ React10.createElement("div", { className: "payment-msg-container" }, /* @__PURE__ */ React10.createElement("div", { className: "charge-payment-success-container" }, /* @__PURE__ */ React10.createElement("div", { className: "charge-payment-success-tick-div" }, /* @__PURE__ */ React10.createElement("div", { className: "charge-payment-success-tick" }, /* @__PURE__ */ React10.createElement(
2004
- "svg",
2005
- {
2006
- xmlns: "http://www.w3.org/2000/svg",
2007
- width: "16",
2008
- height: "16",
2009
- viewBox: "0 0 16 16",
2010
- fill: "none"
2011
- },
2012
- /* @__PURE__ */ React10.createElement(
2013
- "path",
2014
- {
2015
- d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",
2016
- fill: "#61C699"
2017
- }
2018
- )
2019
- ))), /* @__PURE__ */ React10.createElement("h6", { className: "charge-payment-success-text" }, "Your charge", /* @__PURE__ */ React10.createElement("br", null), "was successful"), /* @__PURE__ */ React10.createElement("h6", { className: "charge-payment-success-subtext" }, "We\u2019ve processed your charge"), /* @__PURE__ */ React10.createElement("div", { className: "charge-success-payment-button-div" }, /* @__PURE__ */ React10.createElement("button", { className: "charge-success-btn1", onClick: (e) => HandleSubmit(e, "print", tranId) }, /* @__PURE__ */ React10.createElement(
2020
- "svg",
2021
- {
2022
- xmlns: "http://www.w3.org/2000/svg",
2023
- width: "17",
2024
- height: "16",
2025
- viewBox: "0 0 17 16",
2026
- fill: "none"
2027
- },
2028
- /* @__PURE__ */ React10.createElement(
2029
- "path",
2030
- {
2031
- d: "M15.7729 8.7272C15.58 8.7272 15.395 8.80383 15.2586 8.94022C15.1222 9.07661 15.0456 9.2616 15.0456 9.45448V12.5185C15.045 13.0559 14.8313 13.5711 14.4513 13.9511C14.0713 14.3311 13.5561 14.5449 13.0187 14.5454H3.98149C3.44409 14.5449 2.92887 14.3311 2.54887 13.9511C2.16887 13.5711 1.95514 13.0559 1.95456 12.5185V9.45448C1.95456 9.2616 1.87794 9.07661 1.74154 8.94022C1.60515 8.80383 1.42017 8.7272 1.22728 8.7272C1.03439 8.7272 0.849407 8.80383 0.713015 8.94022C0.576624 9.07661 0.5 9.2616 0.5 9.45448V12.5185C0.500963 13.4416 0.86807 14.3265 1.52077 14.9792C2.17346 15.6319 3.05844 15.999 3.98149 16H13.0187C13.9417 15.999 14.8267 15.6319 15.4794 14.9792C16.1321 14.3265 16.4992 13.4416 16.5002 12.5185V9.45448C16.5002 9.2616 16.4235 9.07661 16.2871 8.94022C16.1507 8.80383 15.9658 8.7272 15.7729 8.7272Z",
2032
- fill: "#161616"
2033
- }
2034
- ),
2035
- /* @__PURE__ */ React10.createElement(
2036
- "path",
2037
- {
2038
- d: "M4.65059 6.75861L7.7728 9.88082V0.72728C7.7728 0.534394 7.84942 0.349407 7.98581 0.213015C8.1222 0.0766239 8.30719 0 8.50008 0C8.69296 0 8.87795 0.0766239 9.01434 0.213015C9.15073 0.349407 9.22736 0.534394 9.22736 0.72728V9.88082L12.3496 6.75861C12.4867 6.62613 12.6704 6.55283 12.8611 6.55448C13.0518 6.55614 13.2342 6.63263 13.3691 6.76747C13.5039 6.90231 13.5804 7.08472 13.5821 7.27541C13.5837 7.46611 13.5104 7.64982 13.3779 7.78698L9.01427 12.1507C8.87788 12.287 8.69293 12.3636 8.50008 12.3636C8.30723 12.3636 8.12228 12.287 7.98589 12.1507L3.62221 7.78698C3.48973 7.64982 3.41643 7.46611 3.41808 7.27541C3.41974 7.08472 3.49623 6.90231 3.63107 6.76747C3.76592 6.63263 3.94833 6.55614 4.13902 6.55448C4.32971 6.55283 4.51342 6.62613 4.65059 6.75861Z",
2039
- fill: "#161616"
2040
- }
2041
- )
2042
- ), "Print receipt"), /* @__PURE__ */ React10.createElement("button", { className: "charge-success-btn1", onClick: (e) => HandleSubmit(e, "share", tranId) }, /* @__PURE__ */ React10.createElement(
2043
- "svg",
2044
- {
2045
- xmlns: "http://www.w3.org/2000/svg",
2046
- width: "17",
2047
- height: "16",
2048
- viewBox: "0 0 17 16",
2049
- fill: "none"
2050
- },
2051
- /* @__PURE__ */ React10.createElement("g", { clipPath: "url(#clip0_12420_50683)" }, /* @__PURE__ */ React10.createElement(
2052
- "path",
2053
- {
2054
- d: "M9.30194 4.78664V2.31152C9.30194 2.09629 9.3862 1.88988 9.53631 1.73768C9.68634 1.5855 9.8899 1.5 10.1021 1.5C10.312 1.50089 10.5132 1.58542 10.6622 1.73534L16.2633 7.41595C16.3383 7.49142 16.3978 7.58117 16.4385 7.68001C16.4791 7.77894 16.5 7.885 16.5 7.99212C16.5 8.09924 16.4791 8.20531 16.4385 8.30423C16.3978 8.40307 16.3383 8.49283 16.2633 8.5683L10.6622 14.2489C10.5499 14.3606 10.4076 14.4362 10.2531 14.4663C10.0987 14.4964 9.93887 14.4797 9.79372 14.4182C9.64857 14.3568 9.52455 14.2532 9.43701 14.1206C9.34955 13.9881 9.30258 13.8323 9.30194 13.6727V11.157H8.62181C7.35764 11.1379 6.10443 11.3981 4.94932 11.9193C3.79422 12.4406 2.76481 13.2107 1.93249 14.1759C1.83215 14.3113 1.6926 14.4115 1.53337 14.4624C1.37406 14.5134 1.20306 14.5125 1.04431 14.4599C0.882759 14.4046 0.742811 14.2984 0.644952 14.1568C0.547092 14.0152 0.496363 13.8456 0.500203 13.6727C0.500203 6.27171 6.96548 5.00575 9.30194 4.78664ZM8.62181 9.51777C9.15695 9.51607 9.69162 9.55129 10.2221 9.62327C10.4115 9.6524 10.5844 9.74954 10.7092 9.89699C10.834 10.0444 10.9025 10.2324 10.9023 10.4267V11.717L14.567 7.99212L10.9023 4.26727V5.55758C10.9023 5.77281 10.8179 5.97922 10.6679 6.13141C10.5178 6.28359 10.3143 6.36909 10.1021 6.36909C9.37396 6.36909 3.61282 6.5314 2.36457 11.5871C4.17637 10.2324 6.3708 9.50665 8.62181 9.51777Z",
2055
- fill: "#161616"
2056
- }
2057
- )),
2058
- /* @__PURE__ */ React10.createElement("defs", null, /* @__PURE__ */ React10.createElement("clipPath", { id: "clip0_12420_50683" }, /* @__PURE__ */ React10.createElement(
2059
- "rect",
2060
- {
2061
- width: "16",
2062
- height: "16",
2063
- fill: "white",
2064
- transform: "translate(0.5)"
2065
- }
2066
- )))
2067
- ), "Send receipt"))), /* @__PURE__ */ React10.createElement("div", { className: "charge-payment-success-btn-div" }, /* @__PURE__ */ React10.createElement("button", { className: "charge-payment-success-btn1", onClick: (e) => HandleSubmit(e, "tran", tranId) }, "Go to Transactions"), /* @__PURE__ */ React10.createElement("button", { className: "charge-payment-success-btn2", onClick: (e) => {
2068
- onClose();
2069
- HandleSubmit(e, "close", tranId);
2070
- } }, "Close"))));
2071
- }
2072
-
2073
- // src/app/components/Charge/GetPaymentPage.tsx
2074
- import Swal from "sweetalert2";
2075
- import { IoArrowBack } from "react-icons/io5";
2076
-
2077
- // src/app/components/Datascript.tsx
2078
- import { useEffect as useEffect3 } from "react";
2079
- function DataScript() {
2080
- useEffect3(() => {
2081
- const src = "https://token-cert.dcap.com/v1/client";
2082
- if (typeof window === "undefined") return;
2083
- if (window.DatacapWebToken) {
2084
- console.log("\u2705 Datacap already available");
2085
- return;
2086
- }
2087
- if (!document.querySelector(`script[src="${src}"]`)) {
2088
- const script = document.createElement("script");
2089
- script.src = src;
2090
- script.async = true;
2091
- script.onload = () => {
2092
- console.log("\u2705 Datacap script loaded");
2093
- if (window.DatacapWebToken) {
2094
- console.log("\u2705 DatacapWebToken is ready:", window.DatacapWebToken);
2095
- } else {
2096
- console.warn("\u26A0\uFE0F Script loaded, but DatacapWebToken not found");
2097
- }
2098
- };
2099
- script.onerror = (err) => {
2100
- console.error("\u274C Failed to load Datacap script", err);
2101
- };
2102
- document.head.appendChild(script);
2103
- } else {
2104
- console.log("\u2139\uFE0F Script already in DOM, waiting for Datacap...");
2105
- }
2106
- }, []);
2107
- useEffect3(() => {
2108
- const scriptId = "forge-cdn-script";
2109
- if (!document.getElementById(scriptId)) {
2110
- const forgeScript = document.createElement("script");
2111
- forgeScript.src = "https://cdn.jsdelivr.net/npm/node-forge@1.0.0/dist/forge.min.js";
2112
- forgeScript.id = scriptId;
2113
- forgeScript.async = true;
2114
- document.head.appendChild(forgeScript);
2115
- }
2116
- return () => {
2117
- const existingScript = document.getElementById(scriptId);
2118
- if (existingScript) {
2119
- document.head.removeChild(existingScript);
2120
- }
2121
- };
2122
- }, []);
2123
- return null;
2124
- }
2125
-
2126
- // src/app/components/ErrorCardMessage/ErrorCardMessage.tsx
2127
- import React12 from "react";
2128
-
2129
- // src/app/components/ErrorCardMessage/ErrorCardMessageStyle.tsx
2130
- import React11 from "react";
2131
- function ErrorCardMszStyle() {
2132
- return /* @__PURE__ */ React11.createElement("style", null, `
1366
+ }`)}function ot(e,y,P){e.preventDefault();let z={type:"preview.compiledcheck",other:{msg:"Payment success!",status:y==="close",data:{tran_id:P,key:y}}};console.log("message:",z),window.parent.postMessage(z,"*")}function bt({onClose:e,tranId:y}){return J.createElement(J.Fragment,null,J.createElement(Ft,null),J.createElement("div",{className:"payment-msg-container"},J.createElement("div",{className:"charge-payment-success-container"},J.createElement("div",{className:"charge-payment-success-tick-div"},J.createElement("div",{className:"charge-payment-success-tick"},J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},J.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),J.createElement("h6",{className:"charge-payment-success-text"},"Your charge",J.createElement("br",null),"was successful"),J.createElement("h6",{className:"charge-payment-success-subtext"},"We\u2019ve processed your charge"),J.createElement("div",{className:"charge-success-payment-button-div"},J.createElement("button",{className:"charge-success-btn1",onClick:P=>ot(P,"print",y)},J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},J.createElement("path",{d:"M15.7729 8.7272C15.58 8.7272 15.395 8.80383 15.2586 8.94022C15.1222 9.07661 15.0456 9.2616 15.0456 9.45448V12.5185C15.045 13.0559 14.8313 13.5711 14.4513 13.9511C14.0713 14.3311 13.5561 14.5449 13.0187 14.5454H3.98149C3.44409 14.5449 2.92887 14.3311 2.54887 13.9511C2.16887 13.5711 1.95514 13.0559 1.95456 12.5185V9.45448C1.95456 9.2616 1.87794 9.07661 1.74154 8.94022C1.60515 8.80383 1.42017 8.7272 1.22728 8.7272C1.03439 8.7272 0.849407 8.80383 0.713015 8.94022C0.576624 9.07661 0.5 9.2616 0.5 9.45448V12.5185C0.500963 13.4416 0.86807 14.3265 1.52077 14.9792C2.17346 15.6319 3.05844 15.999 3.98149 16H13.0187C13.9417 15.999 14.8267 15.6319 15.4794 14.9792C16.1321 14.3265 16.4992 13.4416 16.5002 12.5185V9.45448C16.5002 9.2616 16.4235 9.07661 16.2871 8.94022C16.1507 8.80383 15.9658 8.7272 15.7729 8.7272Z",fill:"#161616"}),J.createElement("path",{d:"M4.65059 6.75861L7.7728 9.88082V0.72728C7.7728 0.534394 7.84942 0.349407 7.98581 0.213015C8.1222 0.0766239 8.30719 0 8.50008 0C8.69296 0 8.87795 0.0766239 9.01434 0.213015C9.15073 0.349407 9.22736 0.534394 9.22736 0.72728V9.88082L12.3496 6.75861C12.4867 6.62613 12.6704 6.55283 12.8611 6.55448C13.0518 6.55614 13.2342 6.63263 13.3691 6.76747C13.5039 6.90231 13.5804 7.08472 13.5821 7.27541C13.5837 7.46611 13.5104 7.64982 13.3779 7.78698L9.01427 12.1507C8.87788 12.287 8.69293 12.3636 8.50008 12.3636C8.30723 12.3636 8.12228 12.287 7.98589 12.1507L3.62221 7.78698C3.48973 7.64982 3.41643 7.46611 3.41808 7.27541C3.41974 7.08472 3.49623 6.90231 3.63107 6.76747C3.76592 6.63263 3.94833 6.55614 4.13902 6.55448C4.32971 6.55283 4.51342 6.62613 4.65059 6.75861Z",fill:"#161616"})),"Print receipt"),J.createElement("button",{className:"charge-success-btn1",onClick:P=>ot(P,"share",y)},J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},J.createElement("g",{clipPath:"url(#clip0_12420_50683)"},J.createElement("path",{d:"M9.30194 4.78664V2.31152C9.30194 2.09629 9.3862 1.88988 9.53631 1.73768C9.68634 1.5855 9.8899 1.5 10.1021 1.5C10.312 1.50089 10.5132 1.58542 10.6622 1.73534L16.2633 7.41595C16.3383 7.49142 16.3978 7.58117 16.4385 7.68001C16.4791 7.77894 16.5 7.885 16.5 7.99212C16.5 8.09924 16.4791 8.20531 16.4385 8.30423C16.3978 8.40307 16.3383 8.49283 16.2633 8.5683L10.6622 14.2489C10.5499 14.3606 10.4076 14.4362 10.2531 14.4663C10.0987 14.4964 9.93887 14.4797 9.79372 14.4182C9.64857 14.3568 9.52455 14.2532 9.43701 14.1206C9.34955 13.9881 9.30258 13.8323 9.30194 13.6727V11.157H8.62181C7.35764 11.1379 6.10443 11.3981 4.94932 11.9193C3.79422 12.4406 2.76481 13.2107 1.93249 14.1759C1.83215 14.3113 1.6926 14.4115 1.53337 14.4624C1.37406 14.5134 1.20306 14.5125 1.04431 14.4599C0.882759 14.4046 0.742811 14.2984 0.644952 14.1568C0.547092 14.0152 0.496363 13.8456 0.500203 13.6727C0.500203 6.27171 6.96548 5.00575 9.30194 4.78664ZM8.62181 9.51777C9.15695 9.51607 9.69162 9.55129 10.2221 9.62327C10.4115 9.6524 10.5844 9.74954 10.7092 9.89699C10.834 10.0444 10.9025 10.2324 10.9023 10.4267V11.717L14.567 7.99212L10.9023 4.26727V5.55758C10.9023 5.77281 10.8179 5.97922 10.6679 6.13141C10.5178 6.28359 10.3143 6.36909 10.1021 6.36909C9.37396 6.36909 3.61282 6.5314 2.36457 11.5871C4.17637 10.2324 6.3708 9.50665 8.62181 9.51777Z",fill:"#161616"})),J.createElement("defs",null,J.createElement("clipPath",{id:"clip0_12420_50683"},J.createElement("rect",{width:"16",height:"16",fill:"white",transform:"translate(0.5)"})))),"Send receipt"))),J.createElement("div",{className:"charge-payment-success-btn-div"},J.createElement("button",{className:"charge-payment-success-btn1",onClick:P=>ot(P,"tran",y)},"Go to Transactions"),J.createElement("button",{className:"charge-payment-success-btn2",onClick:P=>{e(),ot(P,"close",y)}},"Close"))))}import Ct from"sweetalert2";import{IoArrowBack as Ht}from"react-icons/io5";import{useEffect as $t}from"react";function ct(){return $t(()=>{let e="https://token-cert.dcap.com/v1/client";if(typeof window!="undefined"){if(window.DatacapWebToken){console.log("\u2705 Datacap already available");return}if(document.querySelector(`script[src="${e}"]`))console.log("\u2139\uFE0F Script already in DOM, waiting for Datacap...");else{let y=document.createElement("script");y.src=e,y.async=!0,y.onload=()=>{console.log("\u2705 Datacap script loaded"),window.DatacapWebToken?console.log("\u2705 DatacapWebToken is ready:",window.DatacapWebToken):console.warn("\u26A0\uFE0F Script loaded, but DatacapWebToken not found")},y.onerror=P=>{console.error("\u274C Failed to load Datacap script",P)},document.head.appendChild(y)}}},[]),$t(()=>{let e="forge-cdn-script";if(!document.getElementById(e)){let y=document.createElement("script");y.src="https://cdn.jsdelivr.net/npm/node-forge@1.0.0/dist/forge.min.js",y.id=e,y.async=!0,document.head.appendChild(y)}return()=>{let y=document.getElementById(e);y&&document.head.removeChild(y)}},[]),null}import Ze from"react";import xn from"react";function Lt(){return xn.createElement("style",null,`
2133
1367
  .card-error .logo-container {
2134
1368
  display: flex;
2135
1369
  justify-content: center;
@@ -2234,1324 +1468,7 @@ function ErrorCardMszStyle() {
2234
1468
  padding:10px 17px;
2235
1469
  cursor:pointer;
2236
1470
  }
2237
- `);
2238
- }
2239
-
2240
- // src/app/components/ErrorCardMessage/ErrorCardMessage.tsx
2241
- var ErrorCardMessage = ({ onClose, error }) => {
2242
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(ErrorCardMszStyle, null), /* @__PURE__ */ React12.createElement("div", { className: "card-error" }, /* @__PURE__ */ React12.createElement("div", { className: "payment-error-container" }, /* @__PURE__ */ React12.createElement("div", { className: "error-icon" }, /* @__PURE__ */ React12.createElement("div", { className: "circle" }, /* @__PURE__ */ React12.createElement("i", { className: "fa fa-times", "aria-hidden": "true" })), /* @__PURE__ */ React12.createElement("div", { className: "error-text" }, /* @__PURE__ */ React12.createElement("div", { className: "payment-error-text" }, error), /* @__PURE__ */ React12.createElement("div", { className: "thank-you-text" }, "Try again later ")), /* @__PURE__ */ React12.createElement("div", { className: "error-btn-div" }, /* @__PURE__ */ React12.createElement("button", { onClick: onClose }, "OK"))))));
2243
- };
2244
- var ErrorCardMessage_default = ErrorCardMessage;
2245
-
2246
- // src/app/components/socketClient.js
2247
- import { io } from "socket.io-client";
2248
- var socket = io(baseUrl, {
2249
- transports: ["websocket"],
2250
- // Optional: force WebSocket
2251
- withCredentials: false
2252
- });
2253
- var socketClient_default = socket;
2254
-
2255
- // src/app/utils/Common.js
2256
- var isValidJson = (jsonString) => {
2257
- try {
2258
- const parsed = JSON.parse(jsonString);
2259
- return typeof parsed === "object" && parsed !== null;
2260
- } catch (e) {
2261
- return false;
2262
- }
2263
- };
2264
-
2265
- // src/app/components/Charge/GetPaymentPage.tsx
2266
- function GetPaymentPage(props) {
2267
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2268
- const [loading, setLoading] = useState3(false);
2269
- const [loading2, setLoading2] = useState3(false);
2270
- const [error, setError] = useState3("");
2271
- const [success, setSuccess] = useState3(false);
2272
- const [show, setShow] = useState3(false);
2273
- const [activetab, setActive] = useState3("card");
2274
- const [saveCardInfo, setSaveCardInfo] = useState3(false);
2275
- const [saveACHinfo, setSaveACHinfo] = useState3(false);
2276
- const fractalpayClientKey = props.fractalpayClientKey;
2277
- const [cardData, setCardData] = useState3();
2278
- const [cardError, setCardError] = useState3({});
2279
- const [achData, setAchData] = useState3();
2280
- const [achError, setAchError] = useState3({});
2281
- const [cardList, setCardList] = useState3([]);
2282
- const [selectedCard, setSelectedCard] = useState3();
2283
- const [paymentData, setPaymentData] = useState3();
2284
- let [tranId, setTranId] = useState3("");
2285
- const showLoader = () => setLoading(true);
2286
- const hideLoader = () => setLoading(false);
2287
- const handleClose = () => {
2288
- setShow(false);
2289
- setActive("card");
2290
- setError("");
2291
- setSuccess(false);
2292
- setTranId("");
2293
- setAchData({
2294
- name: "",
2295
- routingNumber: "",
2296
- accountNumber: "",
2297
- confirmAccountNumber: "",
2298
- bankName: "",
2299
- accountType: ""
2300
- });
2301
- setAchError({
2302
- name: "",
2303
- routingNumber: "",
2304
- accountNumber: "",
2305
- confirmAccountNumber: "",
2306
- bankName: "",
2307
- accountType: ""
2308
- });
2309
- setCardData({
2310
- cardName: "",
2311
- cardNumber: "",
2312
- expiryMonth: "",
2313
- expiryYear: "",
2314
- cvv: "",
2315
- orderId: "",
2316
- zipCode: ""
2317
- });
2318
- setCardError({
2319
- cardName: "",
2320
- cardNumber: "",
2321
- expiryMonth: "",
2322
- expiryYear: "",
2323
- cvv: "",
2324
- orderId: "",
2325
- zipCode: ""
2326
- });
2327
- setSaveACHinfo(false);
2328
- setSaveCardInfo(false);
2329
- setSelectedCard({
2330
- card_type: "",
2331
- cardlastfourdigit: "",
2332
- expmonth: 1,
2333
- expyear: 2025,
2334
- primary_card: 0,
2335
- firstname: "",
2336
- id: "",
2337
- lastname: ""
2338
- });
2339
- };
2340
- const handleShow = () => setShow(true);
2341
- const handletabchange = (id) => {
2342
- setActive(id);
2343
- };
2344
- const handleCardChange = (field, value) => {
2345
- const name = field;
2346
- const numericFields = ["expiryMonth", "expiryYear", "zipCode", "cvv"];
2347
- if (numericFields.includes(name)) {
2348
- if (value === "" || /^[0-9]+$/.test(value)) {
2349
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
2350
- [name]: ""
2351
- }));
2352
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
2353
- [name]: value
2354
- }));
2355
- }
2356
- return;
2357
- }
2358
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
2359
- [name]: ""
2360
- }));
2361
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
2362
- [name]: value
2363
- }));
2364
- };
2365
- const handleCardNumberChange = (e) => {
2366
- const input = e.target;
2367
- const rawValue = input.value.replace(/\D/g, "");
2368
- let formatted = "";
2369
- if (/^3[47]/.test(rawValue)) {
2370
- const trimmed = rawValue.slice(0, 15);
2371
- formatted = trimmed.replace(
2372
- /^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,
2373
- (_, g1, g2, g3) => [g1, g2, g3].filter(Boolean).join(" ")
2374
- );
2375
- } else {
2376
- const trimmed = rawValue.slice(0, 16);
2377
- formatted = trimmed.replace(
2378
- /^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,
2379
- (_, g1, g2, g3, g4) => [g1, g2, g3, g4].filter(Boolean).join(" ")
2380
- );
2381
- }
2382
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
2383
- cardNumber: ""
2384
- }));
2385
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
2386
- cardNumber: formatted
2387
- }));
2388
- };
2389
- const handleChangeAch = (e) => {
2390
- const { name, value } = e.target;
2391
- const numericFields = ["routingNumber", "accountNumber", "confirmAccountNumber"];
2392
- if (name == "name") {
2393
- if (/^[a-zA-Z\s]*$/.test(value)) {
2394
- setAchError((prev) => __spreadProps(__spreadValues({}, prev), {
2395
- [name]: ""
2396
- }));
2397
- setAchData((prev) => __spreadProps(__spreadValues({}, prev), {
2398
- [name]: value
2399
- }));
2400
- }
2401
- return;
2402
- }
2403
- if (numericFields.includes(name)) {
2404
- if (value === "" || /^[0-9]+$/.test(value)) {
2405
- setAchError((prev) => __spreadProps(__spreadValues({}, prev), {
2406
- [name]: ""
2407
- }));
2408
- setAchData((prev) => __spreadProps(__spreadValues({}, prev), {
2409
- [name]: value
2410
- }));
2411
- }
2412
- return;
2413
- }
2414
- setAchError((prev) => __spreadProps(__spreadValues({}, prev), {
2415
- [name]: ""
2416
- }));
2417
- setAchData((prev) => __spreadProps(__spreadValues({}, prev), {
2418
- [name]: value
2419
- }));
2420
- };
2421
- const validateCardData = () => {
2422
- var _a2, _b2, _c2, _d2, _e2, _f2;
2423
- const errors = {};
2424
- const data = cardData;
2425
- const month = parseInt((data == null ? void 0 : data.expiryMonth) || "", 10);
2426
- const year = (data == null ? void 0 : data.expiryYear) || "";
2427
- if (!((_a2 = data == null ? void 0 : data.cardName) == null ? void 0 : _a2.trim())) errors.cardName = "Card name is required";
2428
- if (!((_b2 = data == null ? void 0 : data.cardNumber) == null ? void 0 : _b2.trim())) errors.cardNumber = "Card number is required";
2429
- if (!((_c2 = data == null ? void 0 : data.expiryMonth) == null ? void 0 : _c2.trim()) || !((_d2 = data == null ? void 0 : data.expiryYear) == null ? void 0 : _d2.trim())) {
2430
- errors.expiryMonth = "Invalid Expiration Date.";
2431
- } else if (isNaN(month) || month < 1 || month > 12 || year.length !== 4) {
2432
- errors.expiryMonth = "Invalid Expiration Date.";
2433
- }
2434
- if (!((_e2 = data == null ? void 0 : data.cvv) == null ? void 0 : _e2.trim())) errors.cvv = "CVV is required";
2435
- if (!((_f2 = data == null ? void 0 : data.zipCode) == null ? void 0 : _f2.trim())) errors.zipCode = "ZIP code is required";
2436
- if ((data == null ? void 0 : data.expiryMonth) && (data == null ? void 0 : data.expiryYear) && data.expiryMonth.length <= 2 && data.expiryYear.length === 4) {
2437
- const month2 = parseInt(data.expiryMonth, 10);
2438
- const year2 = parseInt(data.expiryYear, 10);
2439
- const now = /* @__PURE__ */ new Date();
2440
- const currentMonth = now.getMonth() + 1;
2441
- const currentYear = now.getFullYear();
2442
- if (year2 < currentYear || year2 === currentYear && month2 < currentMonth) {
2443
- errors.expiryMonth = "Card is expired";
2444
- }
2445
- }
2446
- setCardError(errors);
2447
- return Object.keys(errors).length > 0;
2448
- };
2449
- const validateAchData = () => {
2450
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
2451
- const errors = {};
2452
- const data = achData;
2453
- if (!((_a2 = data == null ? void 0 : data.name) == null ? void 0 : _a2.trim())) errors.name = "Name is required";
2454
- if (!((_b2 = data == null ? void 0 : data.accountNumber) == null ? void 0 : _b2.trim())) errors.accountNumber = "account number is required";
2455
- if (((_c2 = data == null ? void 0 : data.accountNumber) == null ? void 0 : _c2.trim()) && ((_d2 = data == null ? void 0 : data.accountNumber) == null ? void 0 : _d2.trim()) !== ((_e2 = data == null ? void 0 : data.confirmAccountNumber) == null ? void 0 : _e2.trim())) errors.confirmAccountNumber = "Account numbers must match";
2456
- if (!((_f2 = data == null ? void 0 : data.bankName) == null ? void 0 : _f2.trim())) errors.bankName = "Bank name is required";
2457
- if (!((_g2 = data == null ? void 0 : data.routingNumber) == null ? void 0 : _g2.trim())) errors.routingNumber = "Routing Number is required";
2458
- if ((data == null ? void 0 : data.routingNumber) && ((_h2 = data == null ? void 0 : data.routingNumber) == null ? void 0 : _h2.length) !== 9) errors.routingNumber = "Routing number must be 9 digits";
2459
- if (((_i2 = data == null ? void 0 : data.routingNumber) == null ? void 0 : _i2.length) == 9) {
2460
- let routingNumber = data == null ? void 0 : data.routingNumber;
2461
- const weights = [3, 7, 1];
2462
- let sum = 0;
2463
- for (let i = 0; i < routingNumber.length; i++) {
2464
- sum += parseInt(routingNumber[i], 10) * weights[i % 3];
2465
- }
2466
- if (sum % 10 !== 0) {
2467
- errors.routingNumber = "Invalid routing number";
2468
- }
2469
- }
2470
- setAchError(errors);
2471
- return Object.keys(errors).length > 0;
2472
- };
2473
- const submitFunc = async (e) => {
2474
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
2475
- e.preventDefault();
2476
- if (activetab !== "ach") {
2477
- const hasError = validateCardData();
2478
- if (hasError) return;
2479
- else {
2480
- let validCard = DatacapWebToken.validateCardNumber(cardData == null ? void 0 : cardData.cardNumber.replaceAll(" ", ""));
2481
- let validExpirationDate = DatacapWebToken.validateExpirationDate(cardData == null ? void 0 : cardData.expiryMonth, cardData == null ? void 0 : cardData.expiryYear);
2482
- let validCVV = DatacapWebToken.validateCVV(cardData == null ? void 0 : cardData.cvv);
2483
- let errors = {};
2484
- if (!validCard) errors.cardNumber = "Invalid card Number";
2485
- if (!validExpirationDate) errors.expiryMonth = "Invalid Expiration Date.";
2486
- if (!validCVV) errors.cvv = "Invalid CVV";
2487
- setCardError(errors);
2488
- if (validCard && validCVV && validExpirationDate) {
2489
- setLoading2(true);
2490
- try {
2491
- const formData = __spreadProps(__spreadValues({}, cardData), {
2492
- amount: `${props.amount || 0}`,
2493
- fractalpayPublicKey: fractalpayClientKey,
2494
- orderId: props == null ? void 0 : props.orderID,
2495
- customer_id: props == null ? void 0 : props.customerId,
2496
- discount: props == null ? void 0 : props.discount,
2497
- surcharge: props == null ? void 0 : props.surcharge,
2498
- tax: props == null ? void 0 : props.tax
2499
- });
2500
- const result = await axios3.post(`${baseUrl}create-widget-order`, formData);
2501
- let tokenCallback = async function(response) {
2502
- if (response.Error) {
2503
- setError(response.Error);
2504
- setLoading2(false);
2505
- } else {
2506
- let name = cardData == null ? void 0 : cardData.cardName;
2507
- let postal_code = cardData == null ? void 0 : cardData.zipCode;
2508
- response.name = name;
2509
- response.postal_code = postal_code;
2510
- response.isCardSave = `${saveCardInfo}`;
2511
- response.isCharge = true;
2512
- response.posSalesIdEncode = result == null ? void 0 : result.data.data.posSalesIdEncode;
2513
- console.log(response, "resppp");
2514
- console.log(result == null ? void 0 : result.data.data.posSalesIdEncode, "fkjdashgfuh");
2515
- socketClient_default.emit("sendMessage", response);
2516
- socketClient_default.on(result == null ? void 0 : result.data.data.posSalesIdEncode, (data) => {
2517
- console.log(data, "socket data");
2518
- if (isValidJson(data == null ? void 0 : data.data)) {
2519
- let apiResponse = JSON.parse(data.data);
2520
- console.log("return data : ", apiResponse);
2521
- if (apiResponse == null ? void 0 : apiResponse.result) {
2522
- setCardData({
2523
- cardName: "",
2524
- cardNumber: "",
2525
- expiryMonth: "",
2526
- expiryYear: "",
2527
- cvv: "",
2528
- orderId: "",
2529
- zipCode: ""
2530
- });
2531
- setSaveCardInfo(false);
2532
- setTranId(apiResponse == null ? void 0 : apiResponse.transactionId);
2533
- setSuccess(true);
2534
- setLoading2(false);
2535
- } else {
2536
- setLoading2(false);
2537
- setError((apiResponse == null ? void 0 : apiResponse.message) || "Something went wrong.");
2538
- }
2539
- } else {
2540
- setError("Something went wrong.");
2541
- }
2542
- });
2543
- }
2544
- };
2545
- if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
2546
- const requestOptions = {
2547
- method: "POST",
2548
- redirect: "follow"
2549
- };
2550
- try {
2551
- let sesionResult = await axios3.post(`${masterBaseUrl}api/v1/widget/generate-session`, requestOptions);
2552
- let expYear = Number(cardData == null ? void 0 : cardData.expiryYear) % 100;
2553
- let cardNumber = cardData == null ? void 0 : cardData.cardNumber;
2554
- cardNumber = cardNumber == null ? void 0 : cardNumber.replace(/\s+/g, "");
2555
- let track2_data = `${cardNumber}=${expYear}${cardData == null ? void 0 : cardData.expiryMonth} ${cardData == null ? void 0 : cardData.cvv}`;
2556
- const publicKey = forge.pki.publicKeyFromPem((_b2 = (_a2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.publicKeyPem);
2557
- const encrypted = publicKey.encrypt(track2_data, "RSA-OAEP", {
2558
- md: forge.md.sha1.create(),
2559
- mgf1: {
2560
- md: forge.md.sha1.create()
2561
- }
2562
- });
2563
- const encryptedBase64 = forge.util.encode64(encrypted);
2564
- const myHeaders = {
2565
- "Content-Type": "application/json",
2566
- "x-app-session-key": (_d2 = (_c2 = sesionResult.data) == null ? void 0 : _c2.data) == null ? void 0 : _d2.session_key
2567
- };
2568
- const raw = JSON.stringify({
2569
- "enc_track2_data": `${encryptedBase64}`,
2570
- "algorithm": "RSAES_OAEP_SHA_1",
2571
- session_key: `${(_f2 = (_e2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e2.data) == null ? void 0 : _f2.session_key}`
2572
- });
2573
- try {
2574
- const tokenizeData = await axios3.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
2575
- const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g2.data), {
2576
- isSaveCardChecked: saveCardInfo,
2577
- name: cardData == null ? void 0 : cardData.cardName,
2578
- postal_code: cardData == null ? void 0 : cardData.zipCode,
2579
- customer_id: props == null ? void 0 : props.customerId
2580
- }));
2581
- const reqData2 = JSON.stringify({
2582
- "pre_sales_id": `${(_i2 = (_h2 = result == null ? void 0 : result.data) == null ? void 0 : _h2.data) == null ? void 0 : _i2.posSalesIdEncode}`,
2583
- "token": `${(_j2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _j2.data.token}`,
2584
- "json_response": `${reqData}`
2585
- });
2586
- let myHeaders2 = JSON.stringify({
2587
- "Content-Type": "application/json"
2588
- });
2589
- const requestOptions2 = {
2590
- method: "POST",
2591
- headers: myHeaders2,
2592
- body: reqData2,
2593
- redirect: "follow",
2594
- isChargeviafractal: true
2595
- };
2596
- socketClient_default.emit("sendMessage", requestOptions2);
2597
- socketClient_default.on("chargeviafractalgateway", (data) => {
2598
- var _a3;
2599
- console.log(data, "socket data");
2600
- if (isValidJson(data == null ? void 0 : data.data)) {
2601
- let paymentRes = JSON.parse(data == null ? void 0 : data.data);
2602
- console.log(paymentRes, "dfuigdasuf");
2603
- if (paymentRes == null ? void 0 : paymentRes.result) {
2604
- setTranId((_a3 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _a3.transactionId);
2605
- setSuccess(true);
2606
- setLoading2(false);
2607
- } else {
2608
- setLoading2(false);
2609
- setError((paymentRes == null ? void 0 : paymentRes.message) || "Something went wrong.");
2610
- }
2611
- } else {
2612
- setError("Something went wrong.");
2613
- }
2614
- });
2615
- } catch (err) {
2616
- setLoading2(false);
2617
- setError(((_l2 = (_k2 = err == null ? void 0 : err.response) == null ? void 0 : _k2.data) == null ? void 0 : _l2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2618
- }
2619
- } catch (err) {
2620
- setLoading2(false);
2621
- setError(((_n2 = (_m2 = err == null ? void 0 : err.response) == null ? void 0 : _m2.data) == null ? void 0 : _n2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2622
- }
2623
- } else {
2624
- if (typeof DatacapWebToken !== "undefined") {
2625
- DatacapWebToken.requestToken(result == null ? void 0 : result.data.data.dctoken, "PaymentForm", tokenCallback);
2626
- }
2627
- }
2628
- } catch (err) {
2629
- setLoading2(false);
2630
- setError(((_p2 = (_o2 = err == null ? void 0 : err.response) == null ? void 0 : _o2.data) == null ? void 0 : _p2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2631
- }
2632
- }
2633
- }
2634
- } else {
2635
- const hasError = validateAchData();
2636
- if (hasError) return;
2637
- else {
2638
- setLoading2(true);
2639
- let dataForm = {
2640
- fractalpayPublicKey: fractalpayClientKey,
2641
- label: (achData == null ? void 0 : achData.name) || "John Doe",
2642
- account_number: achData == null ? void 0 : achData.accountNumber,
2643
- routing_number: achData == null ? void 0 : achData.routingNumber,
2644
- bank_name: achData == null ? void 0 : achData.bankName,
2645
- account_type: achData == null ? void 0 : achData.accountType,
2646
- amount: String(props.amount || 0),
2647
- isSaveAch: saveACHinfo,
2648
- customer_id: props == null ? void 0 : props.customerId,
2649
- order_id: props == null ? void 0 : props.orderID,
2650
- tax: props == null ? void 0 : props.tax,
2651
- discount: props == null ? void 0 : props.discount,
2652
- surcharge: props == null ? void 0 : props.surcharge,
2653
- isChargeACH: true
2654
- };
2655
- socketClient_default.emit("sendMessage", dataForm);
2656
- socketClient_default.on("ach-incoming", (data) => {
2657
- var _a3;
2658
- console.log(data, "sfhdwhf");
2659
- if ((data == null ? void 0 : data.status) == "Failed") {
2660
- if (typeof (data == null ? void 0 : data.message) == "object") {
2661
- Object.values(data == null ? void 0 : data.message).forEach((message) => {
2662
- setError(message || "Something went wrong");
2663
- });
2664
- } else {
2665
- setError((data == null ? void 0 : data.message) || "Something went wrong");
2666
- }
2667
- } else {
2668
- setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
2669
- setSuccess(true);
2670
- setLoading2(false);
2671
- }
2672
- });
2673
- }
2674
- }
2675
- };
2676
- const getPaymentDetails = async () => {
2677
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q, _r, _s;
2678
- showLoader();
2679
- try {
2680
- const data = {
2681
- fractalpayPublicKey: fractalpayClientKey,
2682
- "customer_id": props == null ? void 0 : props.customerId
2683
- };
2684
- let paymentData2 = await axios3.post(`${baseUrl}get-payment-details`, data);
2685
- setPaymentData((_a2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _a2.data);
2686
- if (!((_c2 = (_b2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _b2.data) == null ? void 0 : _c2.paymentGateway)) {
2687
- handleClose();
2688
- setError("Something went wrong.");
2689
- }
2690
- if (((_e2 = (_d2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _d2.data) == null ? void 0 : _e2.card_list) && ((_h2 = (_g2 = (_f2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _f2.data) == null ? void 0 : _g2.card_list) == null ? void 0 : _h2.length) > 0) {
2691
- setCardList((_j2 = (_i2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _i2.data) == null ? void 0 : _j2.card_list);
2692
- setActive("cardList");
2693
- let primary_card = (_m2 = (_l2 = (_k2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _k2.data) == null ? void 0 : _l2.card_list) == null ? void 0 : _m2.filter((card) => (card == null ? void 0 : card.primary_card) == 1);
2694
- if ((primary_card == null ? void 0 : primary_card[0]) && ((_n2 = primary_card == null ? void 0 : primary_card[0]) == null ? void 0 : _n2.payment_method_type) == ((_p2 = (_o2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _o2.data) == null ? void 0 : _p2.paymentGateway)) {
2695
- setSelectedCard(primary_card[0]);
2696
- } else if (((_q = primary_card == null ? void 0 : primary_card[0]) == null ? void 0 : _q.card_type) === "Bank") {
2697
- setSelectedCard(primary_card[0]);
2698
- }
2699
- } else {
2700
- setActive("card");
2701
- }
2702
- hideLoader();
2703
- } catch (err) {
2704
- console.log(err);
2705
- hideLoader();
2706
- setError(((_s = (_r = err == null ? void 0 : err.response) == null ? void 0 : _r.data) == null ? void 0 : _s.message) || (err == null ? void 0 : err.message) || "Something went wrong");
2707
- }
2708
- };
2709
- const handlechargeCustomer = async () => {
2710
- let customer_id = props == null ? void 0 : props.customerId;
2711
- let discount = String(props == null ? void 0 : props.discount);
2712
- let surcharge = String(props == null ? void 0 : props.surcharge);
2713
- let tax = String(props == null ? void 0 : props.tax);
2714
- let fractalpayPublicKey = props == null ? void 0 : props.fractalpayClientKey;
2715
- let order_id = props == null ? void 0 : props.orderID;
2716
- let amount = String(props == null ? void 0 : props.amount);
2717
- let card_id = selectedCard == null ? void 0 : selectedCard.id;
2718
- let card_type = selectedCard == null ? void 0 : selectedCard.card_type;
2719
- if (fractalpayPublicKey && order_id && amount) {
2720
- if (customer_id) {
2721
- if (card_id) {
2722
- let chargeobj = {
2723
- amount,
2724
- order_id,
2725
- customer_id,
2726
- card_id,
2727
- fractalpayPublicKey,
2728
- isCardSave: saveCardInfo,
2729
- discount,
2730
- surcharge,
2731
- tax
2732
- };
2733
- let _a2 = chargeobj, { isCardSave } = _a2, rest = __objRest(_a2, ["isCardSave"]);
2734
- let endpoint = card_type === "Bank" ? "charge-ach" : "charge-by-card";
2735
- let chargeurl = baseUrl + endpoint;
2736
- const headers = {
2737
- "Content-Type": "application/json"
2738
- };
2739
- setLoading2(true);
2740
- socketClient_default.emit("sendMessage", { url: chargeurl, body: card_type == "Bank" ? rest : chargeobj, isChargebycard: true });
2741
- socketClient_default.on("charge-by-card", (response) => {
2742
- var _a3;
2743
- console.log(response, "response");
2744
- if ((response == null ? void 0 : response.result) == true || (response == null ? void 0 : response.status) == true) {
2745
- setTranId((_a3 = response.data) == null ? void 0 : _a3.transaction_id);
2746
- setSuccess(true);
2747
- setLoading2(false);
2748
- } else {
2749
- setError((response == null ? void 0 : response.message) || "Something went wrong.");
2750
- }
2751
- });
2752
- } else {
2753
- setError("Please Select A Card/ACH");
2754
- }
2755
- } else {
2756
- setError("Please Select Customer");
2757
- }
2758
- } else {
2759
- setError("Something went wrong.");
2760
- }
2761
- };
2762
- useEffect4(() => {
2763
- if (show && fractalpayClientKey) {
2764
- getPaymentDetails();
2765
- }
2766
- }, [fractalpayClientKey, show]);
2767
- const handleDeleteCard = async (cardId) => {
2768
- Swal.fire({
2769
- icon: "warning",
2770
- text: "Do you want to delete the card?",
2771
- showCancelButton: true,
2772
- confirmButtonText: "Yes",
2773
- cancelButtonText: "No",
2774
- reverseButtons: true,
2775
- buttonsStyling: false,
2776
- customClass: {
2777
- confirmButton: "swal2-confirm btn btn-dark",
2778
- cancelButton: "swal2-cancel btn btn-dark",
2779
- popup: "custom-swal-popup",
2780
- icon: "custom-swal-icon"
2781
- }
2782
- }).then(async (result) => {
2783
- if (result.isConfirmed) {
2784
- setLoading2(true);
2785
- try {
2786
- let obj = {
2787
- card_id: cardId,
2788
- customer_id: props == null ? void 0 : props.customerId,
2789
- fractalpayPublicKey: props == null ? void 0 : props.fractalpayClientKey
2790
- };
2791
- const res = await axios3.post(`${baseUrl}delete-customer-card`, obj);
2792
- setLoading2(false);
2793
- getPaymentDetails();
2794
- Swal.fire({
2795
- icon: "success",
2796
- title: "Deleted!",
2797
- text: "Card deleted.",
2798
- confirmButtonText: "OK",
2799
- showConfirmButton: true,
2800
- timer: 1e3,
2801
- // auto-close after 1 second
2802
- timerProgressBar: true,
2803
- customClass: {
2804
- confirmButton: "btn btn-dark"
2805
- }
2806
- });
2807
- } catch (err) {
2808
- setLoading2(false);
2809
- Swal.fire({
2810
- icon: "error",
2811
- title: "Error!",
2812
- text: "Failed to delete the card.",
2813
- confirmButtonText: "OK",
2814
- customClass: {
2815
- confirmButton: "btn btn-dark"
2816
- }
2817
- });
2818
- }
2819
- } else if (result.dismiss === Swal.DismissReason.cancel) {
2820
- Swal.fire({
2821
- icon: "info",
2822
- text: "Card not deleted",
2823
- confirmButtonText: "OK",
2824
- buttonsStyling: false,
2825
- customClass: {
2826
- confirmButton: "btn btn-dark float-end",
2827
- actions: "swal2-actions-end"
2828
- }
2829
- });
2830
- }
2831
- });
2832
- };
2833
- return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(DataScript, null), /* @__PURE__ */ React13.createElement(Chargewidgetstyles, null), /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(
2834
- "button",
2835
- {
2836
- className: "paymentBtn",
2837
- onClick: handleShow
2838
- },
2839
- "Pay"
2840
- ), /* @__PURE__ */ React13.createElement(
2841
- CustomModal2_default,
2842
- {
2843
- open: show,
2844
- onClose: handleClose
2845
- },
2846
- error && /* @__PURE__ */ React13.createElement("div", { style: { maxHeight: "606px", minHeight: "60vh", padding: "40px" } }, /* @__PURE__ */ React13.createElement(ErrorCardMessage_default, { error, onClose: handleClose })),
2847
- success && /* @__PURE__ */ React13.createElement(SuccessMsz, { onClose: handleClose, tranId }),
2848
- !error && !success && /* @__PURE__ */ React13.createElement(React13.Fragment, null, (loading || loading2) && /* @__PURE__ */ React13.createElement(Loader_default, { loading: loading || loading2 }), /* @__PURE__ */ React13.createElement("div", { className: "frac-card-payment-page frac-form" }, /* @__PURE__ */ React13.createElement("div", { className: "parent-pay-container" }, /* @__PURE__ */ React13.createElement("span", { className: "request-payment-close-popup", onClick: handleClose }, /* @__PURE__ */ React13.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React13.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React13.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React13.createElement("defs", null, /* @__PURE__ */ React13.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React13.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ React13.createElement("div", { className: "pay-main-logo-res" }, /* @__PURE__ */ React13.createElement("img", { src: "https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/uploaded/merchant_logo/20250311131124_merchant_logo.png", id: "pay-logos" })), /* @__PURE__ */ React13.createElement("div", { className: "pay-container" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-header pay-conatiner-one" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-conatiner-one-first" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-logo-container" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-main-logo" }, /* @__PURE__ */ React13.createElement("img", { src: "https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/uploaded/merchant_logo/20250311131124_merchant_logo.png", id: "pay-logos" })), /* @__PURE__ */ React13.createElement("h1", { className: "pay-heading" }, "Pay"), (cardList == null ? void 0 : cardList.length) > 0 && activetab !== "cardList" && /* @__PURE__ */ React13.createElement("button", { className: "res-charge-payment-back-btn ", onClick: () => setActive("cardList") }, " ", /* @__PURE__ */ React13.createElement(IoArrowBack, null), " Back")), /* @__PURE__ */ React13.createElement("div", { className: "amt-pay-con" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-amount-conatiner" }, /* @__PURE__ */ React13.createElement("small", { className: "pay-payment-amount" }, "Payment Amount"), /* @__PURE__ */ React13.createElement("strong", { className: "pay-amount" }, "$", (_a = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _a.toFixed(2))), activetab != "ach" && /* @__PURE__ */ React13.createElement("div", { style: { display: "flex", gap: "8px", margin: "8px 0" } }, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/visa-img.svg", alt: "", width: 33 }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/mc-img.svg", width: 33, alt: "" }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/ae-img.svg", alt: "", width: 33 }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/discover-img.svg", width: 33, alt: "" })))), /* @__PURE__ */ React13.createElement("div", { className: "pay-conatiner-one-last" }, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/secure-img.png", alt: "" }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/pov-by.png", alt: "" }), "Secure payments powered by Fractal"), /* @__PURE__ */ React13.createElement("div", null)), /* @__PURE__ */ React13.createElement("div", { className: "pay-tab pay-conatiner-two" }, !loading && /* @__PURE__ */ React13.createElement("div", { className: "col-md-12" }, /* @__PURE__ */ React13.createElement("div", { id: "payment-form-div" }, activetab !== "cardList" ? /* @__PURE__ */ React13.createElement("div", null, (cardList == null ? void 0 : cardList.length) > 0 && /* @__PURE__ */ React13.createElement("button", { className: "charge-payment-back-btn ", onClick: () => setActive("cardList") }, " ", /* @__PURE__ */ React13.createElement(IoArrowBack, null), " Back"), (paymentData == null ? void 0 : paymentData.isSkyFiAccount) && /* @__PURE__ */ React13.createElement("div", { className: "tab" }, /* @__PURE__ */ React13.createElement("button", { className: "tablinks", onClick: (e) => {
2849
- handletabchange("card");
2850
- }, style: { border: activetab === "card" ? "1px solid" : "" } }, /* @__PURE__ */ React13.createElement("i", { className: "fas fa-credit-card me-2", style: { marginRight: "8px", fontSize: "15px" } }), "Card"), /* @__PURE__ */ React13.createElement("button", { className: "tablinks", onClick: (e) => {
2851
- handletabchange("ach");
2852
- }, style: { border: activetab === "ach" ? "1px solid" : "" } }, /* @__PURE__ */ React13.createElement("i", { className: "fas fa-university me-2", style: { marginRight: "8px", fontSize: "15px" } }), "Bank")), /* @__PURE__ */ React13.createElement("div", { className: "res-pay-con" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-amount-conatiner", style: { margin: 0 } }, /* @__PURE__ */ React13.createElement("small", { className: "pay-payment-amount" }, "Payment Amount"), /* @__PURE__ */ React13.createElement("strong", { className: "pay-amount" }, "$", (_b = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _b.toFixed(2))), activetab != "ach" && /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/visa-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/mc-img.svg", width: 35, alt: "" })), /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/ae-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/discover-img.svg", width: 35, alt: "" }))))) : /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("h6", { className: "charge-customer-name", style: { marginBottom: "16px !important" } }, " Charge ", paymentData == null ? void 0 : paymentData.customer_name), /* @__PURE__ */ React13.createElement("h6", { className: "card-ach-heading", style: { marginBottom: "10px !important" } }, " Cards/ACH"), /* @__PURE__ */ React13.createElement("div", { className: "res-pay-con" }, /* @__PURE__ */ React13.createElement("div", { className: "pay-amount-conatiner", style: { margin: 0 } }, /* @__PURE__ */ React13.createElement("small", { className: "pay-payment-amount" }, "Payment Amount"), /* @__PURE__ */ React13.createElement("strong", { className: "pay-amount" }, "$", (_c = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _c.toFixed(2))), /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/visa-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/mc-img.svg", width: 35, alt: "" })), /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/ae-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/discover-img.svg", width: 35, alt: "" }))))), /* @__PURE__ */ React13.createElement("div", { id: "ach", style: { display: activetab === "cardList" ? "block" : "none" }, className: "tabcontent" }, /* @__PURE__ */ React13.createElement("div", { className: "card-lint-div-in" }, /* @__PURE__ */ React13.createElement("div", { className: "card-list-div" }, (paymentData == null ? void 0 : paymentData.card_list) && ((_d = paymentData == null ? void 0 : paymentData.card_list) == null ? void 0 : _d.length) > 0 && ((_e = paymentData == null ? void 0 : paymentData.card_list) == null ? void 0 : _e.map((card, index) => /* @__PURE__ */ React13.createElement("div", { className: "card-list-single-div", key: index }, /* @__PURE__ */ React13.createElement("div", { className: "card-number-radio" }, /* @__PURE__ */ React13.createElement(
2853
- "input",
2854
- {
2855
- disabled: (paymentData == null ? void 0 : paymentData.paymentGateway) != (card == null ? void 0 : card.payment_method_type) && (card == null ? void 0 : card.card_type) != "Bank",
2856
- type: "radio",
2857
- className: "cardRadio",
2858
- name: "selected_card",
2859
- id: "",
2860
- checked: selectedCard === card,
2861
- onChange: (e) => setSelectedCard(card)
2862
- }
2863
- ), /* @__PURE__ */ React13.createElement("label", { htmlFor: "", className: "card-number-last-four" }, "**** ", card == null ? void 0 : card.cardlastfourdigit), (card == null ? void 0 : card.card_type) != "Bank" && /* @__PURE__ */ React13.createElement("h6", { className: "card-expiry-date" }, card == null ? void 0 : card.expmonth, "/", card == null ? void 0 : card.expyear)), /* @__PURE__ */ React13.createElement("div", { className: "card-number-radio" }, /* @__PURE__ */ React13.createElement("span", { className: "visa-card" }, /* @__PURE__ */ React13.createElement("img", { src: (card == null ? void 0 : card.card_type) != "Bank" ? "https://dev-widget.fractalpay.com/images/visa-img.svg" : "https://dev-widget.fractalpay.com/images/bank.svg", alt: "" })), /* @__PURE__ */ React13.createElement("span", { className: "visa-card", style: { cursor: "pointer" }, onClick: () => handleDeleteCard(card == null ? void 0 : card.id) }, /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/Trash.svg", alt: "" }))))))), /* @__PURE__ */ React13.createElement("div", { className: "pay-with-other-card ", onClick: () => setActive("card") }, "Pay With Other Card", /* @__PURE__ */ React13.createElement("img", { src: "https://dev-widget.fractalpay.com/images/card.svg", alt: "" }))), /* @__PURE__ */ React13.createElement("div", { className: "form-group", style: { padding: "0" } }, /* @__PURE__ */ React13.createElement("button", { className: "pay-button", style: { margin: "0px" }, type: "submit", onClick: handlechargeCustomer }, "$", (_f = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _f.toFixed(2)))), /* @__PURE__ */ React13.createElement("div", { id: "card", style: { display: activetab === "card" ? "block" : "none" }, className: "tabcontent" }, /* @__PURE__ */ React13.createElement("form", { id: "PaymentForm", style: { textAlign: "start" }, onSubmit: submitFunc }, /* @__PURE__ */ React13.createElement("div", { className: "ach-scrl", style: { minHeight: (paymentData == null ? void 0 : paymentData.isSkyFiAccount) && (cardList == null ? void 0 : cardList.length) > 0 ? "398px" : (paymentData == null ? void 0 : paymentData.isSkyFiAccount) && (cardList == null ? void 0 : cardList.length) == 0 ? "456px" : (cardList == null ? void 0 : cardList.length) > 0 ? "462px" : "520px", overflow: "auto", marginRight: "5px" } }, /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "cardHolderName" }, "NAME ON CARD "), /* @__PURE__ */ React13.createElement("input", { type: "text", className: "form-control", maxLength: 100, placeholder: "John Doe", value: (cardData == null ? void 0 : cardData.cardName) || "", onChange: (e) => {
2864
- const value = e.target.value;
2865
- if (/^[a-zA-Z\s]*$/.test(value)) {
2866
- handleCardChange("cardName", value);
2867
- }
2868
- } }), (cardError == null ? void 0 : cardError.cardName) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.cardName)), /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "cardNumber" }, "CARD NUMBER"), /* @__PURE__ */ React13.createElement("div", { className: "toggle-num-wrapper" }, /* @__PURE__ */ React13.createElement(
2869
- "input",
2870
- {
2871
- className: "form-control card-number-new",
2872
- type: "text",
2873
- maxLength: 19,
2874
- inputMode: "numeric",
2875
- placeholder: "0000 0000 0000 0000",
2876
- value: (cardData == null ? void 0 : cardData.cardNumber) || "",
2877
- onChange: (e) => handleCardNumberChange(e),
2878
- "data-token": "card_number"
2879
- }
2880
- ), /* @__PURE__ */ React13.createElement("div", { className: "card-crdi card-expiry-new" }, /* @__PURE__ */ React13.createElement("div", { className: "exp-date-year-container" }, /* @__PURE__ */ React13.createElement("div", { className: "exp-date form-group" }, /* @__PURE__ */ React13.createElement(
2881
- "input",
2882
- {
2883
- "data-token": "exp_month",
2884
- className: "form-control required card-cvv-in",
2885
- type: "text",
2886
- style: { maxHeight: "36px" },
2887
- placeholder: "MM",
2888
- maxLength: 2,
2889
- value: (cardData == null ? void 0 : cardData.expiryMonth) || "",
2890
- onChange: (e) => handleCardChange("expiryMonth", e.target.value)
2891
- }
2892
- )), /* @__PURE__ */ React13.createElement("div", { className: "exp-year form-group" }, /* @__PURE__ */ React13.createElement(
2893
- "input",
2894
- {
2895
- "data-token": "exp_year",
2896
- className: "form-control required card-cvv-in",
2897
- type: "text",
2898
- style: { maxHeight: "36px" },
2899
- placeholder: "YYYY",
2900
- maxLength: 4,
2901
- value: (cardData == null ? void 0 : cardData.expiryYear) || "",
2902
- onChange: (e) => handleCardChange("expiryYear", e.target.value)
2903
- }
2904
- )), /* @__PURE__ */ React13.createElement("div", { className: "security-digit form-group" }, /* @__PURE__ */ React13.createElement(
2905
- "input",
2906
- {
2907
- "data-token": "cvv",
2908
- className: "form-control card-cvv-in required",
2909
- type: "text",
2910
- style: { maxHeight: "36px" },
2911
- maxLength: 4,
2912
- placeholder: "CVC",
2913
- value: (cardData == null ? void 0 : cardData.cvv) || "",
2914
- onChange: (e) => handleCardChange("cvv", e.target.value)
2915
- }
2916
- )))), (cardError == null ? void 0 : cardError.cardNumber) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.cardNumber), /* @__PURE__ */ React13.createElement("p", { style: { margin: "0" } }, (cardError == null ? void 0 : cardError.expiryMonth) || (cardError == null ? void 0 : cardError.expiryYear) ? /* @__PURE__ */ React13.createElement("span", { className: "error-span", style: { paddingRight: "4px" } }, cardError == null ? void 0 : cardError.expiryMonth) : "", (cardError == null ? void 0 : cardError.cvv) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.cvv)))), /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "OrderId" }, "Order ID / Description"), /* @__PURE__ */ React13.createElement(
2917
- "input",
2918
- {
2919
- type: "text",
2920
- className: "form-control",
2921
- maxLength: 100,
2922
- placeholder: "OID123456",
2923
- disabled: true,
2924
- value: (_g = props == null ? void 0 : props.orderID) != null ? _g : "",
2925
- style: { background: "#F6F6F7", color: "#727272" }
2926
- }
2927
- )), /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "zip" }, "ZIP"), /* @__PURE__ */ React13.createElement("input", { type: "text", className: "form-control", maxLength: 100, placeholder: "000000", value: (_h = cardData == null ? void 0 : cardData.zipCode) != null ? _h : "", onChange: (e) => handleCardChange("zipCode", e.target.value) }), (cardError == null ? void 0 : cardError.zipCode) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.zipCode)), (props == null ? void 0 : props.customerId) && /* @__PURE__ */ React13.createElement("div", { className: "form-group" }, /* @__PURE__ */ React13.createElement("div", { style: { display: "flex", alignItems: "center", gap: "10px", paddingTop: "10px" } }, /* @__PURE__ */ React13.createElement(
2928
- "input",
2929
- {
2930
- type: "checkbox",
2931
- id: "save_card",
2932
- className: "toggle-checkbox",
2933
- checked: saveCardInfo,
2934
- onChange: (e) => setSaveCardInfo(e.target.checked)
2935
- }
2936
- ), /* @__PURE__ */ React13.createElement("label", { htmlFor: "save_card", className: "toggle-label" }), /* @__PURE__ */ React13.createElement("label", { htmlFor: "save_card" }, "Save card for future payments "), /* @__PURE__ */ React13.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, /* @__PURE__ */ React13.createElement("g", { clipPath: "url(#clip0_12420_50192)" }, /* @__PURE__ */ React13.createElement("rect", { width: "20", height: "20", fill: "white" }), /* @__PURE__ */ React13.createElement("circle", { cx: "10", cy: "10", r: "10", fill: "#E0DFE2" }), /* @__PURE__ */ React13.createElement("path", { d: "M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z", fill: "#161616" })), /* @__PURE__ */ React13.createElement("defs", null, /* @__PURE__ */ React13.createElement("clipPath", { id: "clip0_12420_50192" }, /* @__PURE__ */ React13.createElement("rect", { width: "20", height: "20", fill: "white" }))))))), /* @__PURE__ */ React13.createElement("div", { className: "form-group", style: { marginTop: "20px", padding: "0" } }, /* @__PURE__ */ React13.createElement("button", { type: "submit", style: { margin: 0 }, className: "pay-button" }, "$", (_i = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _i.toFixed(2))))), /* @__PURE__ */ React13.createElement("div", { id: "ach", style: { display: activetab === "ach" ? "block" : "none" }, className: "tabcontent" }, /* @__PURE__ */ React13.createElement("form", { id: "ACHPaymentForm", style: { textAlign: "start" }, onSubmit: submitFunc }, /* @__PURE__ */ React13.createElement("div", { className: "ach-scrl", style: {
2937
- minHeight: (paymentData == null ? void 0 : paymentData.isSkyFiAccount) && (cardList == null ? void 0 : cardList.length) > 0 ? "378px" : (paymentData == null ? void 0 : paymentData.isSkyFiAccount) && (cardList == null ? void 0 : cardList.length) == 0 ? "436px" : (cardList == null ? void 0 : cardList.length) > 0 ? "462px" : "520px",
2938
- maxHeight: (paymentData == null ? void 0 : paymentData.isSkyFiAccount) && (cardList == null ? void 0 : cardList.length) > 0 ? "358px" : (cardList == null ? void 0 : cardList.length) > 0 ? "380px" : "380px"
2939
- } }, /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "nameonaccount" }, "Name on account"), /* @__PURE__ */ React13.createElement("input", { type: "text", id: "nameonaccount", className: "form-control", maxLength: 100, placeholder: "John Doe", name: "name", value: (_j = achData == null ? void 0 : achData.name) != null ? _j : "", onChange: handleChangeAch }), (achError == null ? void 0 : achError.name) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, achError == null ? void 0 : achError.name)), /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "routingnumber" }, "Routing number"), /* @__PURE__ */ React13.createElement(
2940
- "input",
2941
- {
2942
- type: "text",
2943
- id: "routingnumber",
2944
- className: "form-control",
2945
- maxLength: 9,
2946
- placeholder: "000000000",
2947
- name: "routingNumber",
2948
- value: (_k = achData == null ? void 0 : achData.routingNumber) != null ? _k : "",
2949
- onChange: handleChangeAch
2950
- }
2951
- ), (achError == null ? void 0 : achError.routingNumber) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, achError == null ? void 0 : achError.routingNumber)), /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "accountnumber" }, "Account number"), /* @__PURE__ */ React13.createElement(
2952
- "input",
2953
- {
2954
- type: "text",
2955
- id: "accountnumber",
2956
- className: "form-control",
2957
- maxLength: 16,
2958
- placeholder: "0000000000",
2959
- name: "accountNumber",
2960
- value: (_l = achData == null ? void 0 : achData.accountNumber) != null ? _l : "",
2961
- onChange: handleChangeAch
2962
- }
2963
- ), (achError == null ? void 0 : achError.accountNumber) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, achError == null ? void 0 : achError.accountNumber)), /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "confirmaccountnumber" }, "Confirm account number"), /* @__PURE__ */ React13.createElement(
2964
- "input",
2965
- {
2966
- type: "text",
2967
- id: "confirmaccountnumber",
2968
- className: "form-control",
2969
- maxLength: 16,
2970
- placeholder: "0000000000",
2971
- name: "confirmAccountNumber",
2972
- value: (_m = achData == null ? void 0 : achData.confirmAccountNumber) != null ? _m : "",
2973
- onChange: handleChangeAch
2974
- }
2975
- ), (achError == null ? void 0 : achError.confirmAccountNumber) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, achError == null ? void 0 : achError.confirmAccountNumber)), /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "bankname" }, "Bank name"), /* @__PURE__ */ React13.createElement(
2976
- "input",
2977
- {
2978
- type: "text",
2979
- id: "bankname",
2980
- className: "form-control",
2981
- maxLength: 100,
2982
- placeholder: "My Bank",
2983
- name: "bankName",
2984
- value: (_n = achData == null ? void 0 : achData.bankName) != null ? _n : "",
2985
- onChange: handleChangeAch
2986
- }
2987
- ), (achError == null ? void 0 : achError.bankName) && /* @__PURE__ */ React13.createElement("span", { className: "error-span" }, achError == null ? void 0 : achError.bankName)), /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4" }, /* @__PURE__ */ React13.createElement("label", { htmlFor: "accounttype" }, "Select account type"), /* @__PURE__ */ React13.createElement("select", { name: "accountType", id: "accounttype", className: "form-control", value: (_o = achData == null ? void 0 : achData.accountType) != null ? _o : "", onChange: handleChangeAch }, /* @__PURE__ */ React13.createElement("option", { value: "" }, "Select account"), /* @__PURE__ */ React13.createElement("option", { value: "Personal Saving" }, "Personal Saving"), /* @__PURE__ */ React13.createElement("option", { value: "Business Saving" }, "Business Saving"), /* @__PURE__ */ React13.createElement("option", { value: "Personal Checking" }, "Personal Checking"), /* @__PURE__ */ React13.createElement("option", { value: "Business Checking" }, "Business Checking"))), (props == null ? void 0 : props.customerId) && /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4 save-ach-div", style: { paddingTop: "5px" } }, /* @__PURE__ */ React13.createElement("input", { type: "checkbox", id: "saveACH", className: "", maxLength: 100, placeholder: "My Bank", checked: saveACHinfo, onChange: (e) => setSaveACHinfo(e.target.checked) }), /* @__PURE__ */ React13.createElement("label", { htmlFor: "saveACH" }, "Save ACH")), saveACHinfo && /* @__PURE__ */ React13.createElement("div", { className: "form-group mb-4", style: { fontSize: "12px", color: "#727272" } }, /* @__PURE__ */ React13.createElement("p", null, "If checked, I agree for ", /* @__PURE__ */ React13.createElement("b", null, "ecommerce"), " to have my permission to charge this credit card for agreed upon purchases in the future."))), /* @__PURE__ */ React13.createElement("div", { className: "form-group " }, /* @__PURE__ */ React13.createElement("button", { className: "pay-button", style: { margin: "20px 0 0" }, type: "submit" }, "$", (_p = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _p.toFixed(2))))))))))))
2988
- )));
2989
- }
2990
-
2991
- // src/app/components/PreAuthCharge/PreAuthPaymentPage.tsx
2992
- import React14, { useEffect as useEffect5, useState as useState4 } from "react";
2993
- import axios4 from "axios";
2994
- import Swal2 from "sweetalert2";
2995
- import { IoArrowBack as IoArrowBack2 } from "react-icons/io5";
2996
- function PreAuthPayment(props) {
2997
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2998
- const [loading, setLoading] = useState4(false);
2999
- const [loading2, setLoading2] = useState4(false);
3000
- const [error, setError] = useState4("");
3001
- const [success, setSuccess] = useState4(false);
3002
- const [show, setShow] = useState4(false);
3003
- const [activetab, setActive] = useState4("card");
3004
- const [saveCardInfo, setSaveCardInfo] = useState4(false);
3005
- const fractalpayClientKey = props.fractalpayClientKey;
3006
- const [cardData, setCardData] = useState4();
3007
- const [cardError, setCardError] = useState4({});
3008
- const [cardList, setCardList] = useState4([]);
3009
- const [selectedCard, setSelectedCard] = useState4();
3010
- const [paymentData, setPaymentData] = useState4();
3011
- let [tranId, setTranId] = useState4("");
3012
- const showLoader = () => setLoading(true);
3013
- const hideLoader = () => setLoading(false);
3014
- const handleClose = () => {
3015
- setShow(false);
3016
- setActive("card");
3017
- setLoading2(false);
3018
- setError("");
3019
- setSuccess(false);
3020
- setTranId("");
3021
- setCardData({
3022
- cardName: "",
3023
- cardNumber: "",
3024
- expiryMonth: "",
3025
- expiryYear: "",
3026
- cvv: "",
3027
- orderId: "",
3028
- zipCode: ""
3029
- });
3030
- setCardError({
3031
- cardName: "",
3032
- cardNumber: "",
3033
- expiryMonth: "",
3034
- expiryYear: "",
3035
- cvv: "",
3036
- orderId: "",
3037
- zipCode: ""
3038
- });
3039
- setSaveCardInfo(false);
3040
- setSelectedCard({
3041
- card_type: "",
3042
- cardlastfourdigit: "",
3043
- expmonth: 1,
3044
- expyear: 2025,
3045
- primary_card: 0,
3046
- firstname: "",
3047
- id: "",
3048
- lastname: ""
3049
- });
3050
- };
3051
- const handleShow = () => setShow(true);
3052
- const handleCardChange = (field, value) => {
3053
- const name = field;
3054
- const numericFields = ["expiryMonth", "expiryYear", "zipCode", "cvv"];
3055
- if (numericFields.includes(name)) {
3056
- if (value === "" || /^[0-9]+$/.test(value)) {
3057
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
3058
- [name]: ""
3059
- }));
3060
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
3061
- [name]: value
3062
- }));
3063
- }
3064
- return;
3065
- }
3066
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
3067
- [name]: ""
3068
- }));
3069
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
3070
- [name]: value
3071
- }));
3072
- };
3073
- const handleCardNumberChange = (e) => {
3074
- const input = e.target;
3075
- const rawValue = input.value.replace(/\D/g, "");
3076
- let formatted = "";
3077
- if (/^3[47]/.test(rawValue)) {
3078
- const trimmed = rawValue.slice(0, 15);
3079
- formatted = trimmed.replace(
3080
- /^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,
3081
- (_, g1, g2, g3) => [g1, g2, g3].filter(Boolean).join(" ")
3082
- );
3083
- } else {
3084
- const trimmed = rawValue.slice(0, 16);
3085
- formatted = trimmed.replace(
3086
- /^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,
3087
- (_, g1, g2, g3, g4) => [g1, g2, g3, g4].filter(Boolean).join(" ")
3088
- );
3089
- }
3090
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
3091
- cardNumber: ""
3092
- }));
3093
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
3094
- cardNumber: formatted
3095
- }));
3096
- };
3097
- const validateCardData = () => {
3098
- var _a2, _b2, _c2, _d2, _e2, _f2;
3099
- const errors = {};
3100
- const data = cardData;
3101
- const month = parseInt((data == null ? void 0 : data.expiryMonth) || "", 10);
3102
- const year = (data == null ? void 0 : data.expiryYear) || "";
3103
- if (!((_a2 = data == null ? void 0 : data.cardName) == null ? void 0 : _a2.trim())) errors.cardName = "Card name is required";
3104
- if (!((_b2 = data == null ? void 0 : data.cardNumber) == null ? void 0 : _b2.trim())) errors.cardNumber = "Card number is required";
3105
- if (!((_c2 = data == null ? void 0 : data.expiryMonth) == null ? void 0 : _c2.trim()) || !((_d2 = data == null ? void 0 : data.expiryYear) == null ? void 0 : _d2.trim())) {
3106
- errors.expiryMonth = "Invalid Expiration Date.";
3107
- } else if (isNaN(month) || month < 1 || month > 12 || year.length !== 4) {
3108
- errors.expiryMonth = "Invalid Expiration Date.";
3109
- }
3110
- if (!((_e2 = data == null ? void 0 : data.cvv) == null ? void 0 : _e2.trim())) errors.cvv = "CVV is required";
3111
- if (!((_f2 = data == null ? void 0 : data.zipCode) == null ? void 0 : _f2.trim())) errors.zipCode = "ZIP code is required";
3112
- if ((data == null ? void 0 : data.expiryMonth) && (data == null ? void 0 : data.expiryYear) && data.expiryMonth.length <= 2 && data.expiryYear.length === 4) {
3113
- const month2 = parseInt(data.expiryMonth, 10);
3114
- const year2 = parseInt(data.expiryYear, 10);
3115
- const now = /* @__PURE__ */ new Date();
3116
- const currentMonth = now.getMonth() + 1;
3117
- const currentYear = now.getFullYear();
3118
- if (year2 < currentYear || year2 === currentYear && month2 < currentMonth) {
3119
- errors.expiryMonth = "Card is expired";
3120
- }
3121
- }
3122
- setCardError(errors);
3123
- return Object.keys(errors).length > 0;
3124
- };
3125
- const submitFunc = async (e) => {
3126
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3127
- e.preventDefault();
3128
- if (activetab == "card") {
3129
- const hasError = validateCardData();
3130
- if (hasError) return;
3131
- else {
3132
- let validCard = DatacapWebToken.validateCardNumber(cardData == null ? void 0 : cardData.cardNumber.replaceAll(" ", ""));
3133
- let validExpirationDate = DatacapWebToken.validateExpirationDate(cardData == null ? void 0 : cardData.expiryMonth, cardData == null ? void 0 : cardData.expiryYear);
3134
- let validCVV = DatacapWebToken.validateCVV(cardData == null ? void 0 : cardData.cvv);
3135
- let errors = {};
3136
- if (!validCard) errors.cardNumber = "Invalid card Number";
3137
- if (!validExpirationDate) errors.expiryMonth = "Invalid Expiration Date.";
3138
- if (!validCVV) errors.cvv = "Invalid CVV";
3139
- setCardError(errors);
3140
- if (validCard && validCVV && validExpirationDate) {
3141
- setLoading2(true);
3142
- try {
3143
- let tokenCallback = async function(response) {
3144
- if (response.Error) {
3145
- setError(response.Error);
3146
- setLoading2(false);
3147
- } else {
3148
- let name = cardData == null ? void 0 : cardData.cardName;
3149
- let postal_code = cardData == null ? void 0 : cardData.zipCode;
3150
- response.name = name;
3151
- response.postal_code = postal_code;
3152
- response.fractalpayPublicKey = props == null ? void 0 : props.fractalpayClientKey;
3153
- response.amount = props == null ? void 0 : props.amount;
3154
- response.order_id = props == null ? void 0 : props.orderID;
3155
- response.preAuth_id = "";
3156
- response.isCardSave = saveCardInfo;
3157
- response.customer_id = props == null ? void 0 : props.customerId;
3158
- response.link_token = "";
3159
- response.gateway_id = paymentData == null ? void 0 : paymentData.paymentGateway;
3160
- response.discount = props == null ? void 0 : props.discount;
3161
- response.tax = props == null ? void 0 : props.tax;
3162
- response.surcharge = props == null ? void 0 : props.surcharge;
3163
- const myHeaders = new Headers();
3164
- myHeaders.append("Content-Type", "application/json");
3165
- const requestOptions = {
3166
- method: "POST",
3167
- body: JSON.stringify(response),
3168
- redirect: "follow"
3169
- };
3170
- socketClient_default.emit("sendMessage", __spreadProps(__spreadValues({}, requestOptions), { "isChargePreauth": true }));
3171
- socketClient_default.on("charge-preauth", (data) => {
3172
- var _a3;
3173
- console.log(data, "datdata");
3174
- if ((data == null ? void 0 : data.status) == "Failed") {
3175
- setLoading2(false);
3176
- setError((data == null ? void 0 : data.message) || "Something went wrong. Please try again later.");
3177
- } else {
3178
- setSuccess(true);
3179
- setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
3180
- setLoading2(false);
3181
- setCardData({
3182
- cardName: "",
3183
- cardNumber: "",
3184
- expiryMonth: "",
3185
- expiryYear: "",
3186
- cvv: "",
3187
- orderId: "",
3188
- zipCode: ""
3189
- });
3190
- }
3191
- });
3192
- }
3193
- };
3194
- if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
3195
- const requestOptions = {
3196
- method: "POST",
3197
- redirect: "follow"
3198
- };
3199
- try {
3200
- let sesionResult = await axios4.post(`${masterBaseUrl}api/v1/widget/generate-session`, requestOptions);
3201
- let expYear = Number(cardData == null ? void 0 : cardData.expiryYear) % 100;
3202
- let cardNumber = cardData == null ? void 0 : cardData.cardNumber;
3203
- cardNumber = cardNumber == null ? void 0 : cardNumber.replace(/\s+/g, "");
3204
- let track2_data = `${cardNumber}=${expYear}${cardData == null ? void 0 : cardData.expiryMonth} ${cardData == null ? void 0 : cardData.cvv}`;
3205
- const publicKey = forge.pki.publicKeyFromPem((_b2 = (_a2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.publicKeyPem);
3206
- const encrypted = publicKey.encrypt(track2_data, "RSA-OAEP", {
3207
- md: forge.md.sha1.create(),
3208
- mgf1: {
3209
- md: forge.md.sha1.create()
3210
- }
3211
- });
3212
- const encryptedBase64 = forge.util.encode64(encrypted);
3213
- const myHeaders = {
3214
- "Content-Type": "application/json",
3215
- "x-app-session-key": (_d2 = (_c2 = sesionResult.data) == null ? void 0 : _c2.data) == null ? void 0 : _d2.session_key
3216
- };
3217
- const raw = JSON.stringify({
3218
- "enc_track2_data": `${encryptedBase64}`,
3219
- "algorithm": "RSAES_OAEP_SHA_1",
3220
- session_key: `${(_f2 = (_e2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e2.data) == null ? void 0 : _f2.session_key}`
3221
- });
3222
- try {
3223
- const tokenizeData = await axios4.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
3224
- const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g2.data), {
3225
- // isSaveCardChecked: saveCardInfo,
3226
- name: cardData == null ? void 0 : cardData.cardName,
3227
- postal_code: cardData == null ? void 0 : cardData.zipCode,
3228
- customer_id: props == null ? void 0 : props.customerId,
3229
- "amount": props == null ? void 0 : props.amount,
3230
- "Token": `${(_i2 = (_h2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _h2.data) == null ? void 0 : _i2.token}`,
3231
- "fractalpayPublicKey": fractalpayClientKey,
3232
- "order_id": props == null ? void 0 : props.orderID,
3233
- "preAuth_id": "",
3234
- "isCardSave": saveCardInfo,
3235
- "discount": props == null ? void 0 : props.discount,
3236
- "surcharge": props == null ? void 0 : props.surcharge,
3237
- "tax": props == null ? void 0 : props.tax,
3238
- "link_token": "",
3239
- "ExpirationYear": cardData == null ? void 0 : cardData.expiryYear,
3240
- "ExpirationMonth": cardData == null ? void 0 : cardData.expiryMonth,
3241
- "CVV": cardData == null ? void 0 : cardData.cvv,
3242
- "Last4": (_k = (_j = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _j.data) == null ? void 0 : _k.last4,
3243
- "Brand": (_m = (_l = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _l.data) == null ? void 0 : _m.brand,
3244
- "gateway_id": paymentData == null ? void 0 : paymentData.paymentGateway
3245
- }));
3246
- let myHeaders2 = {
3247
- "Content-Type": "application/json"
3248
- };
3249
- const requestOptions2 = {
3250
- method: "POST",
3251
- headers: myHeaders2,
3252
- body: reqData,
3253
- redirect: "follow"
3254
- };
3255
- socketClient_default.emit("sendMessage", __spreadProps(__spreadValues({}, requestOptions2), { "isFractalPreauth": true }));
3256
- socketClient_default.on("fractal-charge-preauth", (data) => {
3257
- var _a3;
3258
- if ((data == null ? void 0 : data.status) == "Failed") {
3259
- setLoading2(false);
3260
- setError((data == null ? void 0 : data.message) || "Something went wrong , Try again later");
3261
- } else {
3262
- setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
3263
- setSuccess(true);
3264
- setLoading2(false);
3265
- }
3266
- });
3267
- } catch (err) {
3268
- console.log(err);
3269
- setLoading2(false);
3270
- setError(((_o = (_n = err == null ? void 0 : err.response) == null ? void 0 : _n.data) == null ? void 0 : _o.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3271
- }
3272
- } catch (err) {
3273
- setLoading2(false);
3274
- setError(((_q = (_p = err == null ? void 0 : err.response) == null ? void 0 : _p.data) == null ? void 0 : _q.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3275
- }
3276
- } else {
3277
- DatacapWebToken.requestToken(paymentData == null ? void 0 : paymentData.dctoken, "PaymentForm", tokenCallback);
3278
- }
3279
- } catch (err) {
3280
- setLoading2(false);
3281
- setError(((_s = (_r = err == null ? void 0 : err.response) == null ? void 0 : _r.data) == null ? void 0 : _s.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
3282
- }
3283
- }
3284
- }
3285
- }
3286
- };
3287
- const getPaymentDetails = async () => {
3288
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3289
- showLoader();
3290
- try {
3291
- const data = {
3292
- fractalpayPublicKey: fractalpayClientKey,
3293
- "customer_id": props == null ? void 0 : props.customerId,
3294
- preauth: true
3295
- };
3296
- let paymentData2 = await axios4.post(`${baseUrl}get-payment-details`, data);
3297
- setPaymentData((_a2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _a2.data);
3298
- if (!((_c2 = (_b2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _b2.data) == null ? void 0 : _c2.paymentGateway)) {
3299
- handleClose();
3300
- setError("Something went wrong.");
3301
- }
3302
- if (((_e2 = (_d2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _d2.data) == null ? void 0 : _e2.card_list) && ((_h2 = (_g2 = (_f2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _f2.data) == null ? void 0 : _g2.card_list) == null ? void 0 : _h2.length) > 0) {
3303
- setCardList((_j = (_i2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _i2.data) == null ? void 0 : _j.card_list);
3304
- setActive("cardList");
3305
- let primary_card = (_m = (_l = (_k = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _k.data) == null ? void 0 : _l.card_list) == null ? void 0 : _m.filter((card) => (card == null ? void 0 : card.primary_card) == 1);
3306
- if ((primary_card == null ? void 0 : primary_card[0]) && ((_n = primary_card == null ? void 0 : primary_card[0]) == null ? void 0 : _n.payment_method_type) == ((_p = (_o = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _o.data) == null ? void 0 : _p.paymentGateway)) {
3307
- setSelectedCard(primary_card[0]);
3308
- }
3309
- } else {
3310
- setActive("card");
3311
- }
3312
- hideLoader();
3313
- } catch (err) {
3314
- console.log(err);
3315
- hideLoader();
3316
- setError(((_r = (_q = err == null ? void 0 : err.response) == null ? void 0 : _q.data) == null ? void 0 : _r.message) || (err == null ? void 0 : err.message) || "Something went wrong");
3317
- }
3318
- };
3319
- const handlechargeCustomer = async () => {
3320
- var _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3321
- let customer_id = props == null ? void 0 : props.customerId;
3322
- let discount = props == null ? void 0 : props.discount;
3323
- let surcharge = props == null ? void 0 : props.surcharge;
3324
- let tax = props == null ? void 0 : props.tax;
3325
- let fractalpayPublicKey = props == null ? void 0 : props.fractalpayClientKey;
3326
- let order_id = props == null ? void 0 : props.orderID;
3327
- let amount = props == null ? void 0 : props.amount;
3328
- let card_id = selectedCard == null ? void 0 : selectedCard.id;
3329
- let card_type = selectedCard == null ? void 0 : selectedCard.card_type;
3330
- if (fractalpayPublicKey && order_id && amount) {
3331
- if (customer_id) {
3332
- if (card_id) {
3333
- let chargeobj = {
3334
- amount,
3335
- order_id,
3336
- customer_id,
3337
- card_id,
3338
- fractalpayPublicKey,
3339
- isCardSave: card_type != "Bank",
3340
- discount,
3341
- surcharge,
3342
- tax
3343
- };
3344
- let _a2 = chargeobj, { isCardSave } = _a2, rest = __objRest(_a2, ["isCardSave"]);
3345
- let endpoint = card_type === "Bank" ? "charge-ach" : "charge-by-card";
3346
- let chargeurl = baseUrl + endpoint;
3347
- const headers = {
3348
- "Content-Type": "application/json"
3349
- };
3350
- setLoading2(true);
3351
- try {
3352
- let result = await axios4.post(chargeurl, card_type == "Bank" ? rest : chargeobj, { headers });
3353
- if ((_b2 = result == null ? void 0 : result.data) == null ? void 0 : _b2.result) {
3354
- setTranId((_d2 = (_c2 = result == null ? void 0 : result.data) == null ? void 0 : _c2.data) == null ? void 0 : _d2.transaction_id);
3355
- setSuccess(true);
3356
- setLoading2(false);
3357
- }
3358
- } catch (err) {
3359
- setLoading2(false);
3360
- console.log(err);
3361
- setError(((_f2 = (_e2 = err == null ? void 0 : err.response) == null ? void 0 : _e2.data) == null ? void 0 : _f2.message) || ((_h2 = (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.data) == null ? void 0 : _h2.status) || "Something went erong");
3362
- }
3363
- } else {
3364
- setError("Please Select A Card/ACH");
3365
- }
3366
- } else {
3367
- setError("Please Select Customer");
3368
- }
3369
- } else {
3370
- setError("Something went wrong.");
3371
- }
3372
- };
3373
- useEffect5(() => {
3374
- if (show && fractalpayClientKey) {
3375
- getPaymentDetails();
3376
- }
3377
- }, [fractalpayClientKey, show]);
3378
- const handleDeleteCard = async (cardId) => {
3379
- Swal2.fire({
3380
- icon: "warning",
3381
- text: "Do you want to delete the card?",
3382
- showCancelButton: true,
3383
- confirmButtonText: "Yes",
3384
- cancelButtonText: "No",
3385
- reverseButtons: true,
3386
- buttonsStyling: false,
3387
- customClass: {
3388
- confirmButton: "swal2-confirm btn btn-dark",
3389
- cancelButton: "swal2-cancel btn btn-dark",
3390
- popup: "custom-swal-popup",
3391
- icon: "custom-swal-icon"
3392
- }
3393
- }).then(async (result) => {
3394
- if (result.isConfirmed) {
3395
- setLoading2(true);
3396
- try {
3397
- let obj = {
3398
- card_id: cardId,
3399
- customer_id: props == null ? void 0 : props.customerId,
3400
- fractalpayPublicKey: props == null ? void 0 : props.fractalpayClientKey
3401
- };
3402
- const res = await axios4.post(`${baseUrl}delete-customer-card`, obj);
3403
- setLoading2(false);
3404
- getPaymentDetails();
3405
- Swal2.fire({
3406
- icon: "success",
3407
- title: "Deleted!",
3408
- text: "The card has been deleted.",
3409
- confirmButtonText: "OK",
3410
- customClass: {
3411
- confirmButton: "btn btn-dark"
3412
- }
3413
- });
3414
- } catch (err) {
3415
- setLoading2(false);
3416
- Swal2.fire({
3417
- icon: "error",
3418
- title: "Error!",
3419
- text: "Failed to delete the card.",
3420
- confirmButtonText: "OK",
3421
- customClass: {
3422
- confirmButton: "btn btn-dark"
3423
- }
3424
- });
3425
- }
3426
- }
3427
- });
3428
- };
3429
- return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(DataScript, null), /* @__PURE__ */ React14.createElement(Chargewidgetstyles, null), /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(
3430
- "button",
3431
- {
3432
- className: "paymentBtn",
3433
- onClick: handleShow
3434
- },
3435
- "Pre Auth Pay"
3436
- ), /* @__PURE__ */ React14.createElement(
3437
- CustomModal2_default,
3438
- {
3439
- open: show,
3440
- onClose: handleClose
3441
- },
3442
- error && /* @__PURE__ */ React14.createElement("div", { style: { maxHeight: "606px", minHeight: "60vh", padding: "40px" } }, /* @__PURE__ */ React14.createElement(ErrorCardMessage_default, { error, onClose: handleClose })),
3443
- success && /* @__PURE__ */ React14.createElement(SuccessMsz, { onClose: handleClose, tranId }),
3444
- !error && !success && /* @__PURE__ */ React14.createElement(React14.Fragment, null, (loading || loading2) && /* @__PURE__ */ React14.createElement(Loader_default, { loading: loading || loading2 }), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", { className: "frac-card-payment-page frac-form" }, /* @__PURE__ */ React14.createElement("div", { className: "parent-pay-container" }, /* @__PURE__ */ React14.createElement("span", { className: "request-payment-close-popup", onClick: handleClose }, /* @__PURE__ */ React14.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React14.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React14.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React14.createElement("defs", null, /* @__PURE__ */ React14.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React14.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ React14.createElement("div", { className: "pay-container" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-header pay-conatiner-one" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-conatiner-one-first" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-logo-container" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-main-logo" }, /* @__PURE__ */ React14.createElement("img", { src: "https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/uploaded/merchant_logo/20250311131124_merchant_logo.png", id: "pay-logos" })), /* @__PURE__ */ React14.createElement("h1", { className: "pay-heading" }, "Pay"), (cardList == null ? void 0 : cardList.length) > 0 && activetab !== "cardList" && /* @__PURE__ */ React14.createElement("button", { className: "res-charge-payment-back-btn ", onClick: () => setActive("cardList") }, " ", /* @__PURE__ */ React14.createElement(IoArrowBack2, null), " Back")), /* @__PURE__ */ React14.createElement("div", { className: "amt-pay-con" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-amount-conatiner" }, /* @__PURE__ */ React14.createElement("small", { className: "pay-payment-amount" }, "Payment Amount"), /* @__PURE__ */ React14.createElement("strong", { className: "pay-amount" }, "$", (_a = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _a.toFixed(2))), activetab != "ach" && /* @__PURE__ */ React14.createElement("div", { style: { display: "flex", gap: "8px", margin: "8px 0" } }, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/visa-img.svg", alt: "", width: 33 }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/mc-img.svg", width: 33, alt: "" }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/ae-img.svg", alt: "", width: 33 }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/discover-img.svg", width: 33, alt: "" })))), /* @__PURE__ */ React14.createElement("div", { className: "pay-conatiner-one-last" }, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/secure-img.png", alt: "" }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/pov-by.png", alt: "" }), "Secure payments powered by Fractal"), /* @__PURE__ */ React14.createElement("div", null)), !loading && /* @__PURE__ */ React14.createElement("div", { className: "pay-tab pay-conatiner-two" }, /* @__PURE__ */ React14.createElement("div", { className: "col-md-12" }, /* @__PURE__ */ React14.createElement("div", { id: "payment-form-div" }, activetab !== "cardList" ? /* @__PURE__ */ React14.createElement("div", null, (cardList == null ? void 0 : cardList.length) > 0 && /* @__PURE__ */ React14.createElement("button", { className: "charge-payment-back-btn ", onClick: () => setActive("cardList") }, " ", /* @__PURE__ */ React14.createElement(IoArrowBack2, null), " Back"), /* @__PURE__ */ React14.createElement("div", { className: "" }, /* @__PURE__ */ React14.createElement("div", { className: "res-pay-con" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-amount-conatiner", style: { margin: 0 } }, /* @__PURE__ */ React14.createElement("small", { className: "pay-payment-amount" }, "Payment Amount"), /* @__PURE__ */ React14.createElement("strong", { className: "pay-amount" }, "$", (_b = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _b.toFixed(2))), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/visa-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/mc-img.svg", width: 35, alt: "" })), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/ae-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/discover-img.svg", width: 35, alt: "" })))))) : /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("h6", { className: "charge-customer-name", style: { marginBottom: "16px !important" } }, " Charge ", paymentData == null ? void 0 : paymentData.customer_name), /* @__PURE__ */ React14.createElement("div", { className: "res-pay-con" }, /* @__PURE__ */ React14.createElement("div", { className: "pay-amount-conatiner", style: { margin: 0 } }, /* @__PURE__ */ React14.createElement("small", { className: "pay-payment-amount" }, "Payment Amount"), /* @__PURE__ */ React14.createElement("strong", { className: "pay-amount" }, "$", (_c = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _c.toFixed(2))), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/visa-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/mc-img.svg", width: 35, alt: "" })), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/ae-img.svg", alt: "", width: 35, style: { paddingRight: "5px" } }), /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/discover-img.svg", width: 35, alt: "" })))), /* @__PURE__ */ React14.createElement("h6", { className: "card-ach-heading", style: { marginBottom: "10px !important" } }, " Cards")), /* @__PURE__ */ React14.createElement("div", { style: { display: activetab === "cardList" ? "block" : "none" }, className: "tabcontent" }, /* @__PURE__ */ React14.createElement("div", { className: "card-lint-div-in" }, /* @__PURE__ */ React14.createElement("div", { className: "card-list-div" }, (paymentData == null ? void 0 : paymentData.card_list) && ((_d = paymentData == null ? void 0 : paymentData.card_list) == null ? void 0 : _d.length) > 0 && ((_e = paymentData == null ? void 0 : paymentData.card_list) == null ? void 0 : _e.map((card, index) => /* @__PURE__ */ React14.createElement("div", { className: "card-list-single-div", key: index }, /* @__PURE__ */ React14.createElement("div", { className: "card-number-radio" }, /* @__PURE__ */ React14.createElement(
3445
- "input",
3446
- {
3447
- disabled: (paymentData == null ? void 0 : paymentData.paymentGateway) != (card == null ? void 0 : card.payment_method_type),
3448
- type: "radio",
3449
- className: "cardRadio",
3450
- name: "selected_card",
3451
- id: "",
3452
- checked: selectedCard === card,
3453
- onChange: (e) => setSelectedCard(card)
3454
- }
3455
- ), /* @__PURE__ */ React14.createElement("label", { htmlFor: "", className: "card-number-last-four" }, "**** ", card == null ? void 0 : card.cardlastfourdigit), /* @__PURE__ */ React14.createElement("h6", { className: "card-expiry-date" }, card == null ? void 0 : card.expmonth, "/", card == null ? void 0 : card.expyear)), /* @__PURE__ */ React14.createElement("div", { className: "card-number-radio" }, /* @__PURE__ */ React14.createElement("span", { className: "visa-card" }, /* @__PURE__ */ React14.createElement("img", { src: (card == null ? void 0 : card.card_type) != "Bank" ? "https://dev-widget.fractalpay.com/images/visa-img.svg" : "https://dev-widget.fractalpay.com/images/bank.svg", alt: "" })), /* @__PURE__ */ React14.createElement("span", { className: "visa-card", style: { cursor: "pointer" }, onClick: () => handleDeleteCard(card == null ? void 0 : card.id) }, /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/Trash.svg", alt: "" }))))))), /* @__PURE__ */ React14.createElement("div", { className: "pay-with-other-card ", onClick: () => setActive("card") }, "Authorize With Other Card", /* @__PURE__ */ React14.createElement("img", { src: "https://dev-widget.fractalpay.com/images/card.svg", alt: "" }))), /* @__PURE__ */ React14.createElement("div", { className: "form-group" }, /* @__PURE__ */ React14.createElement("button", { className: "pay-button", style: { margin: "0px" }, type: "submit", onClick: handlechargeCustomer }, "$", (_f = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _f.toFixed(2)))), /* @__PURE__ */ React14.createElement("div", { id: "card", style: { display: activetab === "card" ? "block" : "none" }, className: "tabcontent" }, /* @__PURE__ */ React14.createElement("form", { id: "PaymentForm", onSubmit: submitFunc }, /* @__PURE__ */ React14.createElement("div", { className: "ach-scrl", style: { minHeight: (cardList == null ? void 0 : cardList.length) > 0 ? "462px" : "520px", overflow: "auto", marginRight: "5px" } }, /* @__PURE__ */ React14.createElement("div", { className: "form-group" }, /* @__PURE__ */ React14.createElement("label", { htmlFor: "cardHolderName" }, "Name on Card"), /* @__PURE__ */ React14.createElement(
3456
- "input",
3457
- {
3458
- type: "text",
3459
- className: "form-control",
3460
- placeholder: "John Doe",
3461
- value: (cardData == null ? void 0 : cardData.cardName) || "",
3462
- onChange: (e) => {
3463
- const value = e.target.value;
3464
- if (/^[a-zA-Z\s]*$/.test(value)) {
3465
- handleCardChange("cardName", value);
3466
- }
3467
- }
3468
- }
3469
- ), (cardError == null ? void 0 : cardError.cardName) && /* @__PURE__ */ React14.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.cardName)), /* @__PURE__ */ React14.createElement("div", { className: "form-group" }, /* @__PURE__ */ React14.createElement("label", { htmlFor: "cardNumber" }, "Card Number"), /* @__PURE__ */ React14.createElement("div", { className: "toggle-num-wrapper" }, /* @__PURE__ */ React14.createElement(
3470
- "input",
3471
- {
3472
- className: "form-control card-number-new",
3473
- type: "text",
3474
- maxLength: 19,
3475
- inputMode: "numeric",
3476
- placeholder: "0000 0000 0000 0000",
3477
- value: (cardData == null ? void 0 : cardData.cardNumber) || "",
3478
- onChange: (e) => handleCardNumberChange(e),
3479
- "data-token": "card_number"
3480
- }
3481
- ), /* @__PURE__ */ React14.createElement("div", { className: "card-crdi card-expiry-new" }, /* @__PURE__ */ React14.createElement("div", { className: "exp-date-year-container" }, /* @__PURE__ */ React14.createElement("div", { className: "exp-date form-group" }, /* @__PURE__ */ React14.createElement(
3482
- "input",
3483
- {
3484
- "data-token": "exp_month",
3485
- className: "form-control required card-cvv-in",
3486
- type: "text",
3487
- style: { maxHeight: "36px" },
3488
- placeholder: "MM",
3489
- maxLength: 2,
3490
- value: (cardData == null ? void 0 : cardData.expiryMonth) || "",
3491
- onChange: (e) => handleCardChange("expiryMonth", e.target.value)
3492
- }
3493
- )), /* @__PURE__ */ React14.createElement("div", { className: "exp-year form-group" }, /* @__PURE__ */ React14.createElement(
3494
- "input",
3495
- {
3496
- "data-token": "exp_year",
3497
- className: "form-control required card-cvv-in",
3498
- type: "text",
3499
- style: { maxHeight: "36px" },
3500
- placeholder: "YYYY",
3501
- maxLength: 4,
3502
- value: (cardData == null ? void 0 : cardData.expiryYear) || "",
3503
- onChange: (e) => handleCardChange("expiryYear", e.target.value)
3504
- }
3505
- )), /* @__PURE__ */ React14.createElement("div", { className: "security-digit form-group" }, /* @__PURE__ */ React14.createElement(
3506
- "input",
3507
- {
3508
- "data-token": "cvv",
3509
- className: "form-control required card-cvv-in",
3510
- type: "text",
3511
- style: { maxHeight: "36px" },
3512
- maxLength: 4,
3513
- placeholder: "CVC",
3514
- value: (cardData == null ? void 0 : cardData.cvv) || "",
3515
- onChange: (e) => handleCardChange("cvv", e.target.value)
3516
- }
3517
- )))), (cardError == null ? void 0 : cardError.cardNumber) && /* @__PURE__ */ React14.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.cardNumber), /* @__PURE__ */ React14.createElement("p", { style: { margin: "0" } }, (cardError == null ? void 0 : cardError.expiryMonth) || (cardError == null ? void 0 : cardError.expiryYear) ? /* @__PURE__ */ React14.createElement("span", { className: "error-span", style: { paddingRight: "4px" } }, cardError == null ? void 0 : cardError.expiryMonth) : "", (cardError == null ? void 0 : cardError.cvv) && /* @__PURE__ */ React14.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.cvv)))), /* @__PURE__ */ React14.createElement("div", { className: "form-group" }, /* @__PURE__ */ React14.createElement("label", { htmlFor: "OrderId" }, "Order ID / Description"), /* @__PURE__ */ React14.createElement(
3518
- "input",
3519
- {
3520
- type: "text",
3521
- className: "form-control",
3522
- maxLength: 100,
3523
- placeholder: "OID123456",
3524
- disabled: true,
3525
- value: (_g = cardData == null ? void 0 : cardData.orderId) != null ? _g : "OID123456",
3526
- onChange: (e) => handleCardChange("orderId", e.target.value),
3527
- style: { background: "#F6F6F7", color: "#727272" }
3528
- }
3529
- )), /* @__PURE__ */ React14.createElement("div", { className: "form-group" }, /* @__PURE__ */ React14.createElement("label", { htmlFor: "zip" }, "ZIP"), /* @__PURE__ */ React14.createElement("input", { type: "text", className: "form-control", maxLength: 100, placeholder: "000000", value: (_h = cardData == null ? void 0 : cardData.zipCode) != null ? _h : "", onChange: (e) => handleCardChange("zipCode", e.target.value) }), (cardError == null ? void 0 : cardError.zipCode) && /* @__PURE__ */ React14.createElement("span", { className: "error-span" }, cardError == null ? void 0 : cardError.zipCode)), (props == null ? void 0 : props.customerId) && /* @__PURE__ */ React14.createElement("div", { className: "form-group" }, /* @__PURE__ */ React14.createElement("div", { style: { display: "flex", alignItems: "center", gap: "10px", paddingTop: "10px" } }, /* @__PURE__ */ React14.createElement(
3530
- "input",
3531
- {
3532
- type: "checkbox",
3533
- id: "save_card",
3534
- className: "toggle-checkbox",
3535
- checked: saveCardInfo,
3536
- onChange: (e) => setSaveCardInfo(e.target.checked)
3537
- }
3538
- ), /* @__PURE__ */ React14.createElement("label", { htmlFor: "save_card", className: "toggle-label" }), /* @__PURE__ */ React14.createElement("label", { htmlFor: "save_card" }, "Save card for future payments "), /* @__PURE__ */ React14.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, /* @__PURE__ */ React14.createElement("g", { clipPath: "url(#clip0_12420_50192)" }, /* @__PURE__ */ React14.createElement("rect", { width: "20", height: "20", fill: "white" }), /* @__PURE__ */ React14.createElement("circle", { cx: "10", cy: "10", r: "10", fill: "#E0DFE2" }), /* @__PURE__ */ React14.createElement("path", { d: "M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z", fill: "#161616" })), /* @__PURE__ */ React14.createElement("defs", null, /* @__PURE__ */ React14.createElement("clipPath", { id: "clip0_12420_50192" }, /* @__PURE__ */ React14.createElement("rect", { width: "20", height: "20", fill: "white" }))))))), /* @__PURE__ */ React14.createElement("div", { className: "form-group", style: { marginTop: "20px", padding: 0 } }, /* @__PURE__ */ React14.createElement("button", { type: "submit", style: { margin: 0 }, className: "pay-button" }, "$", (_i = Number(props == null ? void 0 : props.amount)) == null ? void 0 : _i.toFixed(2)))))))))))))
3539
- )));
3540
- }
3541
-
3542
- // src/app/components/AddCard/AddCardEasyPay.tsx
3543
- import React18, { useEffect as useEffect6, useState as useState5 } from "react";
3544
- import Swal3 from "sweetalert2";
3545
- import axios5 from "axios";
3546
-
3547
- // src/app/components/AddCard/AddCardStyles.tsx
3548
- import React15 from "react";
3549
- function AddCardStyle() {
3550
- const primarycolor = "#000";
3551
- const primarybgcolor = "#fff";
3552
- const primarybodycolor = "#212529";
3553
- const primarybordercolor = "#dee2e6";
3554
- return /* @__PURE__ */ React15.createElement("style", null, `
1471
+ `)}var bn=({onClose:e,error:y})=>Ze.createElement(Ze.Fragment,null,Ze.createElement(Lt,null),Ze.createElement("div",{className:"card-error"},Ze.createElement("div",{className:"payment-error-container"},Ze.createElement("div",{className:"error-icon"},Ze.createElement("div",{className:"circle"},Ze.createElement("i",{className:"fa fa-times","aria-hidden":"true"})),Ze.createElement("div",{className:"error-text"},Ze.createElement("div",{className:"payment-error-text"},y),Ze.createElement("div",{className:"thank-you-text"},"Try again later ")),Ze.createElement("div",{className:"error-btn-div"},Ze.createElement("button",{onClick:e},"OK")))))),ft=bn;import{io as vn}from"socket.io-client";var Cn=vn(ce,{transports:["websocket"],withCredentials:!1}),$e=Cn;var St=e=>{try{let y=JSON.parse(e);return typeof y=="object"&&y!==null}catch(y){return!1}};function Nn(e){var p,f,B,T,V,X,ie,de,ae,G,Me,Q,D,Te,ze,oe;let[y,P]=Ae(!1),[$,z]=Ae(!1),[Be,v]=Ae(""),[je,ge]=Ae(!1),[a,Y]=Ae(!1),[g,W]=Ae("card"),[l,Le]=Ae(!1),[ke,s]=Ae(!1),Se=e.fractalpayClientKey,[o,he]=Ae(),[N,ve]=Ae({}),[S,Pe]=Ae(),[x,Ke]=Ae({}),[A,C]=Ae([]),[u,Z]=Ae(),[b,H]=Ae(),[le,ye]=Ae(""),_e=()=>P(!0),Ce=()=>P(!1),ue=()=>{Y(!1),W("card"),v(""),ge(!1),ye(""),Pe({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),Ke({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),he({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),ve({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),s(!1),Le(!1),Z({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},d=()=>Y(!0),h=r=>{W(r)},I=(r,i)=>{let k=r;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(k)){(i===""||/^[0-9]+$/.test(i))&&(ve(w=>L(F({},w),{[k]:""})),he(w=>L(F({},w),{[k]:i})));return}ve(w=>L(F({},w),{[k]:""})),he(w=>L(F({},w),{[k]:i}))},U=r=>{let k=r.target.value.replace(/\D/g,""),M="";/^3[47]/.test(k)?M=k.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(R,re,j,se)=>[re,j,se].filter(Boolean).join(" ")):M=k.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(R,re,j,se,ee)=>[re,j,se,ee].filter(Boolean).join(" ")),ve(w=>L(F({},w),{cardNumber:""})),he(w=>L(F({},w),{cardNumber:M}))},xe=r=>{let{name:i,value:k}=r.target,M=["routingNumber","accountNumber","confirmAccountNumber"];if(i=="name"){/^[a-zA-Z\s]*$/.test(k)&&(Ke(w=>L(F({},w),{[i]:""})),Pe(w=>L(F({},w),{[i]:k})));return}if(M.includes(i)){(k===""||/^[0-9]+$/.test(k))&&(Ke(w=>L(F({},w),{[i]:""})),Pe(w=>L(F({},w),{[i]:k})));return}Ke(w=>L(F({},w),{[i]:""})),Pe(w=>L(F({},w),{[i]:k}))},rt=()=>{var w,R,re,j,se,ee;let r={},i=o,k=parseInt((i==null?void 0:i.expiryMonth)||"",10),M=(i==null?void 0:i.expiryYear)||"";if((w=i==null?void 0:i.cardName)!=null&&w.trim()||(r.cardName="Card name is required"),(R=i==null?void 0:i.cardNumber)!=null&&R.trim()||(r.cardNumber="Card number is required"),(!((re=i==null?void 0:i.expiryMonth)!=null&&re.trim())||!((j=i==null?void 0:i.expiryYear)!=null&&j.trim())||isNaN(k)||k<1||k>12||M.length!==4)&&(r.expiryMonth="Invalid Expiration Date."),(se=i==null?void 0:i.cvv)!=null&&se.trim()||(r.cvv="CVV is required"),(ee=i==null?void 0:i.zipCode)!=null&&ee.trim()||(r.zipCode="ZIP code is required"),i!=null&&i.expiryMonth&&(i!=null&&i.expiryYear)&&i.expiryMonth.length<=2&&i.expiryYear.length===4){let E=parseInt(i.expiryMonth,10),O=parseInt(i.expiryYear,10),Ie=new Date,we=Ie.getMonth()+1,be=Ie.getFullYear();(O<be||O===be&&E<we)&&(r.expiryMonth="Card is expired")}return ve(r),Object.keys(r).length>0},st=()=>{var k,M,w,R,re,j,se,ee,E;let r={},i=S;if((k=i==null?void 0:i.name)!=null&&k.trim()||(r.name="Name is required"),(M=i==null?void 0:i.accountNumber)!=null&&M.trim()||(r.accountNumber="account number is required"),(w=i==null?void 0:i.accountNumber)!=null&&w.trim()&&((R=i==null?void 0:i.accountNumber)==null?void 0:R.trim())!==((re=i==null?void 0:i.confirmAccountNumber)==null?void 0:re.trim())&&(r.confirmAccountNumber="Account numbers must match"),(j=i==null?void 0:i.bankName)!=null&&j.trim()||(r.bankName="Bank name is required"),(se=i==null?void 0:i.routingNumber)!=null&&se.trim()||(r.routingNumber="Routing Number is required"),i!=null&&i.routingNumber&&((ee=i==null?void 0:i.routingNumber)==null?void 0:ee.length)!==9&&(r.routingNumber="Routing number must be 9 digits"),((E=i==null?void 0:i.routingNumber)==null?void 0:E.length)==9){let O=i==null?void 0:i.routingNumber,Ie=[3,7,1],we=0;for(let be=0;be<O.length;be++)we+=parseInt(O[be],10)*Ie[be%3];we%10!==0&&(r.routingNumber="Invalid routing number")}return Ke(r),Object.keys(r).length>0},tt=async r=>{var i,k,M,w,R,re,j,se,ee,E,O,Ie,we,be,Ne,me;if(r.preventDefault(),g!=="ach"){if(rt())return;{let Re=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),K=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),_=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),pe={};if(Re||(pe.cardNumber="Invalid card Number"),K||(pe.expiryMonth="Invalid Expiration Date."),_||(pe.cvv="Invalid CVV"),ve(pe),Re&&_&&K){z(!0);try{let He=L(F({},o),{amount:`${e.amount||0}`,fractalpayPublicKey:Se,orderId:e==null?void 0:e.orderID,customer_id:e==null?void 0:e.customerId,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax}),Fe=await vt.post(`${ce}create-widget-order`,He),We=async function(Ye){if(Ye.Error)v(Ye.Error),z(!1);else{let qe=o==null?void 0:o.cardName,Mt=o==null?void 0:o.zipCode;Ye.name=qe,Ye.postal_code=Mt,Ye.isCardSave=`${l}`,Ye.isCharge=!0,Ye.posSalesIdEncode=Fe==null?void 0:Fe.data.data.posSalesIdEncode,console.log(Ye,"resppp"),console.log(Fe==null?void 0:Fe.data.data.posSalesIdEncode,"fkjdashgfuh"),$e.emit("sendMessage",Ye),$e.on(Fe==null?void 0:Fe.data.data.posSalesIdEncode,Ge=>{if(console.log(Ge,"socket data"),St(Ge==null?void 0:Ge.data)){let Oe=JSON.parse(Ge.data);console.log("return data : ",Oe),Oe!=null&&Oe.result?(he({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Le(!1),ye(Oe==null?void 0:Oe.transactionId),ge(!0),z(!1)):(z(!1),v((Oe==null?void 0:Oe.message)||"Something went wrong."))}else v("Something went wrong.")})}};if((b==null?void 0:b.paymentGateway)===32){let Ye={method:"POST",redirect:"follow"};try{let qe=await vt.post(`${pt}api/v1/widget/generate-session`,Ye),Mt=Number(o==null?void 0:o.expiryYear)%100,Ge=o==null?void 0:o.cardNumber;Ge=Ge==null?void 0:Ge.replace(/\s+/g,"");let Oe=`${Ge}=${Mt}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,Et=forge.pki.publicKeyFromPem((k=(i=qe==null?void 0:qe.data)==null?void 0:i.data)==null?void 0:k.publicKeyPem).encrypt(Oe,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Kt=forge.util.encode64(Et),Ot={"Content-Type":"application/json","x-app-session-key":(w=(M=qe.data)==null?void 0:M.data)==null?void 0:w.session_key},Wt=JSON.stringify({enc_track2_data:`${Kt}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(re=(R=qe==null?void 0:qe.data)==null?void 0:R.data)==null?void 0:re.session_key}`});try{let Ve=await vt.post(`${ut}tokenizer/tokenize`,Wt,{headers:Ot}),Gt=JSON.stringify(L(F({},(j=Ve==null?void 0:Ve.data)==null?void 0:j.data),{isSaveCardChecked:l,name:o==null?void 0:o.cardName,postal_code:o==null?void 0:o.zipCode,customer_id:e==null?void 0:e.customerId})),Ut=JSON.stringify({pre_sales_id:`${(ee=(se=Fe==null?void 0:Fe.data)==null?void 0:se.data)==null?void 0:ee.posSalesIdEncode}`,token:`${(E=Ve==null?void 0:Ve.data)==null?void 0:E.data.token}`,json_response:`${Gt}`}),Jt={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:Ut,redirect:"follow",isChargeviafractal:!0};$e.emit("sendMessage",Jt),$e.on("chargeviafractalgateway",mt=>{var qt;if(console.log(mt,"socket data"),St(mt==null?void 0:mt.data)){let Je=JSON.parse(mt==null?void 0:mt.data);console.log(Je,"dfuigdasuf"),Je!=null&&Je.result?(ye((qt=Je==null?void 0:Je.data)==null?void 0:qt.transactionId),ge(!0),z(!1)):(z(!1),v((Je==null?void 0:Je.message)||"Something went wrong."))}else v("Something went wrong.")})}catch(Ve){z(!1),v(((Ie=(O=Ve==null?void 0:Ve.response)==null?void 0:O.data)==null?void 0:Ie.message)||(Ve==null?void 0:Ve.message)||"Something went wrong.")}}catch(qe){z(!1),v(((be=(we=qe==null?void 0:qe.response)==null?void 0:we.data)==null?void 0:be.message)||(qe==null?void 0:qe.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(Fe==null?void 0:Fe.data.data.dctoken,"PaymentForm",We)}catch(He){z(!1),v(((me=(Ne=He==null?void 0:He.response)==null?void 0:Ne.data)==null?void 0:me.message)||(He==null?void 0:He.message)||"Something went wrong.")}}}}else{if(st())return;{z(!0);let Re={fractalpayPublicKey:Se,label:(S==null?void 0:S.name)||"John Doe",account_number:S==null?void 0:S.accountNumber,routing_number:S==null?void 0:S.routingNumber,bank_name:S==null?void 0:S.bankName,account_type:S==null?void 0:S.accountType,amount:String(e.amount||0),isSaveAch:ke,customer_id:e==null?void 0:e.customerId,order_id:e==null?void 0:e.orderID,tax:e==null?void 0:e.tax,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,isChargeACH:!0};$e.emit("sendMessage",Re),$e.on("ach-incoming",K=>{var _;console.log(K,"sfhdwhf"),(K==null?void 0:K.status)=="Failed"?typeof(K==null?void 0:K.message)=="object"?Object.values(K==null?void 0:K.message).forEach(pe=>{v(pe||"Something went wrong")}):v((K==null?void 0:K.message)||"Something went wrong"):(ye((_=K==null?void 0:K.data)==null?void 0:_.transaction_id),ge(!0),z(!1))})}}},nt=async()=>{var r,i,k,M,w,R,re,j,se,ee,E,O,Ie,we,be,Ne,me,De,Re;_e();try{let K={fractalpayPublicKey:Se,customer_id:e==null?void 0:e.customerId},_=await vt.post(`${ce}get-payment-details`,K);if(H((r=_==null?void 0:_.data)==null?void 0:r.data),(k=(i=_==null?void 0:_.data)==null?void 0:i.data)!=null&&k.paymentGateway||(ue(),v("Something went wrong.")),(w=(M=_==null?void 0:_.data)==null?void 0:M.data)!=null&&w.card_list&&((j=(re=(R=_==null?void 0:_.data)==null?void 0:R.data)==null?void 0:re.card_list)==null?void 0:j.length)>0){C((ee=(se=_==null?void 0:_.data)==null?void 0:se.data)==null?void 0:ee.card_list),W("cardList");let pe=(Ie=(O=(E=_==null?void 0:_.data)==null?void 0:E.data)==null?void 0:O.card_list)==null?void 0:Ie.filter(He=>(He==null?void 0:He.primary_card)==1);(pe!=null&&pe[0]&&((we=pe==null?void 0:pe[0])==null?void 0:we.payment_method_type)==((Ne=(be=_==null?void 0:_.data)==null?void 0:be.data)==null?void 0:Ne.paymentGateway)||((me=pe==null?void 0:pe[0])==null?void 0:me.card_type)==="Bank")&&Z(pe[0])}else W("card");Ce()}catch(K){console.log(K),Ce(),v(((Re=(De=K==null?void 0:K.response)==null?void 0:De.data)==null?void 0:Re.message)||(K==null?void 0:K.message)||"Something went wrong")}},lt=async()=>{let r=e==null?void 0:e.customerId,i=String(e==null?void 0:e.discount),k=String(e==null?void 0:e.surcharge),M=String(e==null?void 0:e.tax),w=e==null?void 0:e.fractalpayClientKey,R=e==null?void 0:e.orderID,re=String(e==null?void 0:e.amount),j=u==null?void 0:u.id,se=u==null?void 0:u.card_type;if(w&&R&&re)if(r)if(j){let E={amount:re,order_id:R,customer_id:r,card_id:j,fractalpayPublicKey:w,isCardSave:l,discount:i,surcharge:k,tax:M},ee=E,{isCardSave:O}=ee,Ie=kt(ee,["isCardSave"]),be=ce+(se==="Bank"?"charge-ach":"charge-by-card"),Ne={"Content-Type":"application/json"};z(!0),$e.emit("sendMessage",{url:be,body:se=="Bank"?Ie:E,isChargebycard:!0}),$e.on("charge-by-card",me=>{var De;console.log(me,"response"),(me==null?void 0:me.result)==!0||(me==null?void 0:me.status)==!0?(ye((De=me.data)==null?void 0:De.transaction_id),ge(!0),z(!1)):v((me==null?void 0:me.message)||"Something went wrong.")})}else v("Please Select A Card/ACH");else v("Please Select Customer");else v("Something went wrong.")};wn(()=>{a&&Se&&nt()},[Se,a]);let dt=async r=>{Ct.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async i=>{if(i.isConfirmed){z(!0);try{let k={card_id:r,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.fractalpayClientKey},M=await vt.post(`${ce}delete-customer-card`,k);z(!1),nt(),Ct.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(k){z(!1),Ct.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else i.dismiss===Ct.DismissReason.cancel&&Ct.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})};return t.createElement(t.Fragment,null,t.createElement(ct,null),t.createElement(xt,null),t.createElement(t.Fragment,null,t.createElement("button",{className:"paymentBtn",onClick:d},"Pay"),t.createElement(Xe,{open:a,onClose:ue},Be&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(ft,{error:Be,onClose:ue})),je&&t.createElement(bt,{onClose:ue,tranId:le}),!Be&&!je&&t.createElement(t.Fragment,null,(y||$)&&t.createElement(Qe,{loading:y||$}),t.createElement("div",{className:"frac-card-payment-page frac-form"},t.createElement("div",{className:"parent-pay-container"},t.createElement("span",{className:"request-payment-close-popup",onClick:ue},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t.createElement("g",{clipPath:"url(#clip0_12425_52336)"},t.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_12425_52336"},t.createElement("rect",{width:"16",height:"16",fill:"white"}))))),t.createElement("div",{className:"pay-main-logo-res"},t.createElement("img",{src:"https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/uploaded/merchant_logo/20250311131124_merchant_logo.png",id:"pay-logos"})),t.createElement("div",{className:"pay-container"},t.createElement("div",{className:"pay-header pay-conatiner-one"},t.createElement("div",{className:"pay-conatiner-one-first"},t.createElement("div",{className:"pay-logo-container"},t.createElement("div",{className:"pay-main-logo"},t.createElement("img",{src:"https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/uploaded/merchant_logo/20250311131124_merchant_logo.png",id:"pay-logos"})),t.createElement("h1",{className:"pay-heading"},"Pay"),(A==null?void 0:A.length)>0&&g!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>W("cardList")}," ",t.createElement(Ht,null)," Back")),t.createElement("div",{className:"amt-pay-con"},t.createElement("div",{className:"pay-amount-conatiner"},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(p=Number(e==null?void 0:e.amount))==null?void 0:p.toFixed(2))),g!="ach"&&t.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/visa-img.svg",alt:"",width:33}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/mc-img.svg",width:33,alt:""}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/ae-img.svg",alt:"",width:33}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/discover-img.svg",width:33,alt:""})))),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/secure-img.png",alt:""}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/pov-by.png",alt:""}),"Secure payments powered by Fractal"),t.createElement("div",null)),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!y&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},g!=="cardList"?t.createElement("div",null,(A==null?void 0:A.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>W("cardList")}," ",t.createElement(Ht,null)," Back"),(b==null?void 0:b.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:r=>{h("card")},style:{border:g==="card"?"1px solid":""}},t.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),t.createElement("button",{className:"tablinks",onClick:r=>{h("ach")},style:{border:g==="ach"?"1px solid":""}},t.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(f=Number(e==null?void 0:e.amount))==null?void 0:f.toFixed(2))),g!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/visa-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/mc-img.svg",width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/ae-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/discover-img.svg",width:35,alt:""}))))):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",b==null?void 0:b.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards/ACH"),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(B=Number(e==null?void 0:e.amount))==null?void 0:B.toFixed(2))),t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/visa-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/mc-img.svg",width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/ae-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/discover-img.svg",width:35,alt:""}))))),t.createElement("div",{id:"ach",style:{display:g==="cardList"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"card-lint-div-in"},t.createElement("div",{className:"card-list-div"},(b==null?void 0:b.card_list)&&((T=b==null?void 0:b.card_list)==null?void 0:T.length)>0&&((V=b==null?void 0:b.card_list)==null?void 0:V.map((r,i)=>t.createElement("div",{className:"card-list-single-div",key:i},t.createElement("div",{className:"card-number-radio"},t.createElement("input",{disabled:(b==null?void 0:b.paymentGateway)!=(r==null?void 0:r.payment_method_type)&&(r==null?void 0:r.card_type)!="Bank",type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:u===r,onChange:k=>Z(r)}),t.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",r==null?void 0:r.cardlastfourdigit),(r==null?void 0:r.card_type)!="Bank"&&t.createElement("h6",{className:"card-expiry-date"},r==null?void 0:r.expmonth,"/",r==null?void 0:r.expyear)),t.createElement("div",{className:"card-number-radio"},t.createElement("span",{className:"visa-card"},t.createElement("img",{src:(r==null?void 0:r.card_type)!="Bank"?"https://dev-widget.fractalpay.com/images/visa-img.svg":"https://dev-widget.fractalpay.com/images/bank.svg",alt:""})),t.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>dt(r==null?void 0:r.id)},t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/Trash.svg",alt:""}))))))),t.createElement("div",{className:"pay-with-other-card ",onClick:()=>W("card")},"Pay With Other Card",t.createElement("img",{src:"https://dev-widget.fractalpay.com/images/card.svg",alt:""}))),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:lt},"$",(X=Number(e==null?void 0:e.amount))==null?void 0:X.toFixed(2)))),t.createElement("div",{id:"card",style:{display:g==="card"?"block":"none"},className:"tabcontent"},t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:tt},t.createElement("div",{className:"ach-scrl",style:{minHeight:b!=null&&b.isSkyFiAccount&&(A==null?void 0:A.length)>0?"398px":b!=null&&b.isSkyFiAccount&&(A==null?void 0:A.length)==0?"456px":(A==null?void 0:A.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(o==null?void 0:o.cardName)||"",onChange:r=>{let i=r.target.value;/^[a-zA-Z\s]*$/.test(i)&&I("cardName",i)}}),(N==null?void 0:N.cardName)&&t.createElement("span",{className:"error-span"},N==null?void 0:N.cardName)),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),t.createElement("div",{className:"toggle-num-wrapper"},t.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(o==null?void 0:o.cardNumber)||"",onChange:r=>U(r),"data-token":"card_number"}),t.createElement("div",{className:"card-crdi card-expiry-new"},t.createElement("div",{className:"exp-date-year-container"},t.createElement("div",{className:"exp-date form-group"},t.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:r=>I("expiryMonth",r.target.value)})),t.createElement("div",{className:"exp-year form-group"},t.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:r=>I("expiryYear",r.target.value)})),t.createElement("div",{className:"security-digit form-group"},t.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(o==null?void 0:o.cvv)||"",onChange:r=>I("cvv",r.target.value)})))),(N==null?void 0:N.cardNumber)&&t.createElement("span",{className:"error-span"},N==null?void 0:N.cardNumber),t.createElement("p",{style:{margin:"0"}},N!=null&&N.expiryMonth||N!=null&&N.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},N==null?void 0:N.expiryMonth):"",(N==null?void 0:N.cvv)&&t.createElement("span",{className:"error-span"},N==null?void 0:N.cvv)))),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(ie=e==null?void 0:e.orderID)!=null?ie:"",style:{background:"#F6F6F7",color:"#727272"}})),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"zip"},"ZIP"),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(de=o==null?void 0:o.zipCode)!=null?de:"",onChange:r=>I("zipCode",r.target.value)}),(N==null?void 0:N.zipCode)&&t.createElement("span",{className:"error-span"},N==null?void 0:N.zipCode)),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},t.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:l,onChange:r=>Le(r.target.checked)}),t.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),t.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},t.createElement("g",{clipPath:"url(#clip0_12420_50192)"},t.createElement("rect",{width:"20",height:"20",fill:"white"}),t.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),t.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_12420_50192"},t.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),t.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(ae=Number(e==null?void 0:e.amount))==null?void 0:ae.toFixed(2))))),t.createElement("div",{id:"ach",style:{display:g==="ach"?"block":"none"},className:"tabcontent"},t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:tt},t.createElement("div",{className:"ach-scrl",style:{minHeight:b!=null&&b.isSkyFiAccount&&(A==null?void 0:A.length)>0?"378px":b!=null&&b.isSkyFiAccount&&(A==null?void 0:A.length)==0?"436px":(A==null?void 0:A.length)>0?"462px":"520px",maxHeight:b!=null&&b.isSkyFiAccount&&(A==null?void 0:A.length)>0?"358px":((A==null?void 0:A.length)>0,"380px")}},t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),t.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(G=S==null?void 0:S.name)!=null?G:"",onChange:xe}),(x==null?void 0:x.name)&&t.createElement("span",{className:"error-span"},x==null?void 0:x.name)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"routingnumber"},"Routing number"),t.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(Me=S==null?void 0:S.routingNumber)!=null?Me:"",onChange:xe}),(x==null?void 0:x.routingNumber)&&t.createElement("span",{className:"error-span"},x==null?void 0:x.routingNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"accountnumber"},"Account number"),t.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Q=S==null?void 0:S.accountNumber)!=null?Q:"",onChange:xe}),(x==null?void 0:x.accountNumber)&&t.createElement("span",{className:"error-span"},x==null?void 0:x.accountNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),t.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(D=S==null?void 0:S.confirmAccountNumber)!=null?D:"",onChange:xe}),(x==null?void 0:x.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},x==null?void 0:x.confirmAccountNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"bankname"},"Bank name"),t.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(Te=S==null?void 0:S.bankName)!=null?Te:"",onChange:xe}),(x==null?void 0:x.bankName)&&t.createElement("span",{className:"error-span"},x==null?void 0:x.bankName)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"accounttype"},"Select account type"),t.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(ze=S==null?void 0:S.accountType)!=null?ze:"",onChange:xe},t.createElement("option",{value:""},"Select account"),t.createElement("option",{value:"Personal Saving"},"Personal Saving"),t.createElement("option",{value:"Business Saving"},"Business Saving"),t.createElement("option",{value:"Personal Checking"},"Personal Checking"),t.createElement("option",{value:"Business Checking"},"Business Checking"))),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},t.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:ke,onChange:r=>s(r.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),ke&&t.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},t.createElement("p",null,"If checked, I agree for ",t.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),t.createElement("div",{className:"form-group "},t.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},"$",(oe=Number(e==null?void 0:e.amount))==null?void 0:oe.toFixed(2)))))))))))))))}import n,{useEffect as kn,useState as Ee}from"react";import wt from"axios";import Pt from"sweetalert2";import{IoArrowBack as Vt}from"react-icons/io5";function _n(e){var I,U,xe,rt,st,tt,nt,lt,dt;let[y,P]=Ee(!1),[$,z]=Ee(!1),[Be,v]=Ee(""),[je,ge]=Ee(!1),[a,Y]=Ee(!1),[g,W]=Ee("card"),[l,Le]=Ee(!1),ke=e.fractalpayClientKey,[s,Se]=Ee(),[o,he]=Ee({}),[N,ve]=Ee([]),[S,Pe]=Ee(),[x,Ke]=Ee(),[A,C]=Ee(""),u=()=>P(!0),Z=()=>P(!1),b=()=>{Y(!1),W("card"),z(!1),v(""),ge(!1),C(""),Se({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),he({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Le(!1),Pe({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},H=()=>Y(!0),le=(p,f)=>{let B=p;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(B)){(f===""||/^[0-9]+$/.test(f))&&(he(V=>L(F({},V),{[B]:""})),Se(V=>L(F({},V),{[B]:f})));return}he(V=>L(F({},V),{[B]:""})),Se(V=>L(F({},V),{[B]:f}))},ye=p=>{let B=p.target.value.replace(/\D/g,""),T="";/^3[47]/.test(B)?T=B.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(X,ie,de,ae)=>[ie,de,ae].filter(Boolean).join(" ")):T=B.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(X,ie,de,ae,G)=>[ie,de,ae,G].filter(Boolean).join(" ")),he(V=>L(F({},V),{cardNumber:""})),Se(V=>L(F({},V),{cardNumber:T}))},_e=()=>{var V,X,ie,de,ae,G;let p={},f=s,B=parseInt((f==null?void 0:f.expiryMonth)||"",10),T=(f==null?void 0:f.expiryYear)||"";if((V=f==null?void 0:f.cardName)!=null&&V.trim()||(p.cardName="Card name is required"),(X=f==null?void 0:f.cardNumber)!=null&&X.trim()||(p.cardNumber="Card number is required"),(!((ie=f==null?void 0:f.expiryMonth)!=null&&ie.trim())||!((de=f==null?void 0:f.expiryYear)!=null&&de.trim())||isNaN(B)||B<1||B>12||T.length!==4)&&(p.expiryMonth="Invalid Expiration Date."),(ae=f==null?void 0:f.cvv)!=null&&ae.trim()||(p.cvv="CVV is required"),(G=f==null?void 0:f.zipCode)!=null&&G.trim()||(p.zipCode="ZIP code is required"),f!=null&&f.expiryMonth&&(f!=null&&f.expiryYear)&&f.expiryMonth.length<=2&&f.expiryYear.length===4){let Me=parseInt(f.expiryMonth,10),Q=parseInt(f.expiryYear,10),D=new Date,Te=D.getMonth()+1,ze=D.getFullYear();(Q<ze||Q===ze&&Me<Te)&&(p.expiryMonth="Card is expired")}return he(p),Object.keys(p).length>0},Ce=async p=>{var f,B,T,V,X,ie,de,ae,G,Me,Q,D,Te,ze,oe,r,i,k,M;if(p.preventDefault(),g=="card"){if(_e())return;{let R=DatacapWebToken.validateCardNumber(s==null?void 0:s.cardNumber.replaceAll(" ","")),re=DatacapWebToken.validateExpirationDate(s==null?void 0:s.expiryMonth,s==null?void 0:s.expiryYear),j=DatacapWebToken.validateCVV(s==null?void 0:s.cvv),se={};if(R||(se.cardNumber="Invalid card Number"),re||(se.expiryMonth="Invalid Expiration Date."),j||(se.cvv="Invalid CVV"),he(se),R&&j&&re){z(!0);try{let ee=async function(E){if(E.Error)v(E.Error),z(!1);else{let O=s==null?void 0:s.cardName,Ie=s==null?void 0:s.zipCode;E.name=O,E.postal_code=Ie,E.fractalpayPublicKey=e==null?void 0:e.fractalpayClientKey,E.amount=e==null?void 0:e.amount,E.order_id=e==null?void 0:e.orderID,E.preAuth_id="",E.isCardSave=l,E.customer_id=e==null?void 0:e.customerId,E.link_token="",E.gateway_id=x==null?void 0:x.paymentGateway,E.discount=e==null?void 0:e.discount,E.tax=e==null?void 0:e.tax,E.surcharge=e==null?void 0:e.surcharge,new Headers().append("Content-Type","application/json");let be={method:"POST",body:JSON.stringify(E),redirect:"follow"};$e.emit("sendMessage",L(F({},be),{isChargePreauth:!0})),$e.on("charge-preauth",Ne=>{var me;console.log(Ne,"datdata"),(Ne==null?void 0:Ne.status)=="Failed"?(z(!1),v((Ne==null?void 0:Ne.message)||"Something went wrong. Please try again later.")):(ge(!0),C((me=Ne==null?void 0:Ne.data)==null?void 0:me.transaction_id),z(!1),Se({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((x==null?void 0:x.paymentGateway)===32){let E={method:"POST",redirect:"follow"};try{let O=await wt.post(`${pt}api/v1/widget/generate-session`,E),Ie=Number(s==null?void 0:s.expiryYear)%100,we=s==null?void 0:s.cardNumber;we=we==null?void 0:we.replace(/\s+/g,"");let be=`${we}=${Ie}${s==null?void 0:s.expiryMonth} ${s==null?void 0:s.cvv}`,me=forge.pki.publicKeyFromPem((B=(f=O==null?void 0:O.data)==null?void 0:f.data)==null?void 0:B.publicKeyPem).encrypt(be,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),De=forge.util.encode64(me),Re={"Content-Type":"application/json","x-app-session-key":(V=(T=O.data)==null?void 0:T.data)==null?void 0:V.session_key},K=JSON.stringify({enc_track2_data:`${De}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(ie=(X=O==null?void 0:O.data)==null?void 0:X.data)==null?void 0:ie.session_key}`});try{let _=await wt.post(`${ut}tokenizer/tokenize`,K,{headers:Re}),pe=JSON.stringify(L(F({},(de=_==null?void 0:_.data)==null?void 0:de.data),{name:s==null?void 0:s.cardName,postal_code:s==null?void 0:s.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(G=(ae=_==null?void 0:_.data)==null?void 0:ae.data)==null?void 0:G.token}`,fractalpayPublicKey:ke,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:l,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:s==null?void 0:s.expiryYear,ExpirationMonth:s==null?void 0:s.expiryMonth,CVV:s==null?void 0:s.cvv,Last4:(Q=(Me=_==null?void 0:_.data)==null?void 0:Me.data)==null?void 0:Q.last4,Brand:(Te=(D=_==null?void 0:_.data)==null?void 0:D.data)==null?void 0:Te.brand,gateway_id:x==null?void 0:x.paymentGateway})),Fe={method:"POST",headers:{"Content-Type":"application/json"},body:pe,redirect:"follow"};$e.emit("sendMessage",L(F({},Fe),{isFractalPreauth:!0})),$e.on("fractal-charge-preauth",We=>{var Ye;(We==null?void 0:We.status)=="Failed"?(z(!1),v((We==null?void 0:We.message)||"Something went wrong , Try again later")):(C((Ye=We==null?void 0:We.data)==null?void 0:Ye.transaction_id),ge(!0),z(!1))})}catch(_){console.log(_),z(!1),v(((oe=(ze=_==null?void 0:_.response)==null?void 0:ze.data)==null?void 0:oe.message)||(_==null?void 0:_.message)||"Something went wrong , Try again later")}}catch(O){z(!1),v(((i=(r=O==null?void 0:O.response)==null?void 0:r.data)==null?void 0:i.message)||(O==null?void 0:O.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(x==null?void 0:x.dctoken,"PaymentForm",ee)}catch(ee){z(!1),v(((M=(k=ee==null?void 0:ee.response)==null?void 0:k.data)==null?void 0:M.message)||(ee==null?void 0:ee.message)||"Something went wrong.")}}}}},ue=async()=>{var p,f,B,T,V,X,ie,de,ae,G,Me,Q,D,Te,ze,oe,r,i;u();try{let k={fractalpayPublicKey:ke,customer_id:e==null?void 0:e.customerId,preauth:!0},M=await wt.post(`${ce}get-payment-details`,k);if(Ke((p=M==null?void 0:M.data)==null?void 0:p.data),(B=(f=M==null?void 0:M.data)==null?void 0:f.data)!=null&&B.paymentGateway||(b(),v("Something went wrong.")),(V=(T=M==null?void 0:M.data)==null?void 0:T.data)!=null&&V.card_list&&((de=(ie=(X=M==null?void 0:M.data)==null?void 0:X.data)==null?void 0:ie.card_list)==null?void 0:de.length)>0){ve((G=(ae=M==null?void 0:M.data)==null?void 0:ae.data)==null?void 0:G.card_list),W("cardList");let w=(D=(Q=(Me=M==null?void 0:M.data)==null?void 0:Me.data)==null?void 0:Q.card_list)==null?void 0:D.filter(R=>(R==null?void 0:R.primary_card)==1);w!=null&&w[0]&&((Te=w==null?void 0:w[0])==null?void 0:Te.payment_method_type)==((oe=(ze=M==null?void 0:M.data)==null?void 0:ze.data)==null?void 0:oe.paymentGateway)&&Pe(w[0])}else W("card");Z()}catch(k){console.log(k),Z(),v(((i=(r=k==null?void 0:k.response)==null?void 0:r.data)==null?void 0:i.message)||(k==null?void 0:k.message)||"Something went wrong")}},d=async()=>{var Me,Q,D,Te,ze,oe,r;let p=e==null?void 0:e.customerId,f=e==null?void 0:e.discount,B=e==null?void 0:e.surcharge,T=e==null?void 0:e.tax,V=e==null?void 0:e.fractalpayClientKey,X=e==null?void 0:e.orderID,ie=e==null?void 0:e.amount,de=S==null?void 0:S.id,ae=S==null?void 0:S.card_type;if(V&&X&&ie)if(p)if(de){let i={amount:ie,order_id:X,customer_id:p,card_id:de,fractalpayPublicKey:V,isCardSave:ae!="Bank",discount:f,surcharge:B,tax:T},G=i,{isCardSave:k}=G,M=kt(G,["isCardSave"]),R=ce+(ae==="Bank"?"charge-ach":"charge-by-card"),re={"Content-Type":"application/json"};z(!0);try{let j=await wt.post(R,ae=="Bank"?M:i,{headers:re});(Me=j==null?void 0:j.data)!=null&&Me.result&&(C((D=(Q=j==null?void 0:j.data)==null?void 0:Q.data)==null?void 0:D.transaction_id),ge(!0),z(!1))}catch(j){z(!1),console.log(j),v(((ze=(Te=j==null?void 0:j.response)==null?void 0:Te.data)==null?void 0:ze.message)||((r=(oe=j==null?void 0:j.response)==null?void 0:oe.data)==null?void 0:r.status)||"Something went erong")}}else v("Please Select A Card/ACH");else v("Please Select Customer");else v("Something went wrong.")};kn(()=>{a&&ke&&ue()},[ke,a]);let h=async p=>{Pt.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async f=>{if(f.isConfirmed){z(!0);try{let B={card_id:p,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.fractalpayClientKey},T=await wt.post(`${ce}delete-customer-card`,B);z(!1),ue(),Pt.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(B){z(!1),Pt.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})};return n.createElement(n.Fragment,null,n.createElement(ct,null),n.createElement(xt,null),n.createElement(n.Fragment,null,n.createElement("button",{className:"paymentBtn",onClick:H},"Pre Auth Pay"),n.createElement(Xe,{open:a,onClose:b},Be&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(ft,{error:Be,onClose:b})),je&&n.createElement(bt,{onClose:b,tranId:A}),!Be&&!je&&n.createElement(n.Fragment,null,(y||$)&&n.createElement(Qe,{loading:y||$}),n.createElement("div",null,n.createElement("div",{className:"frac-card-payment-page frac-form"},n.createElement("div",{className:"parent-pay-container"},n.createElement("span",{className:"request-payment-close-popup",onClick:b},n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12425_52336)"},n.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12425_52336"},n.createElement("rect",{width:"16",height:"16",fill:"white"}))))),n.createElement("div",{className:"pay-container"},n.createElement("div",{className:"pay-header pay-conatiner-one"},n.createElement("div",{className:"pay-conatiner-one-first"},n.createElement("div",{className:"pay-logo-container"},n.createElement("div",{className:"pay-main-logo"},n.createElement("img",{src:"https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/uploaded/merchant_logo/20250311131124_merchant_logo.png",id:"pay-logos"})),n.createElement("h1",{className:"pay-heading"},"Pay"),(N==null?void 0:N.length)>0&&g!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>W("cardList")}," ",n.createElement(Vt,null)," Back")),n.createElement("div",{className:"amt-pay-con"},n.createElement("div",{className:"pay-amount-conatiner"},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",(I=Number(e==null?void 0:e.amount))==null?void 0:I.toFixed(2))),g!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/visa-img.svg",alt:"",width:33}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/mc-img.svg",width:33,alt:""}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/ae-img.svg",alt:"",width:33}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/discover-img.svg",width:33,alt:""})))),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/secure-img.png",alt:""}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/pov-by.png",alt:""}),"Secure payments powered by Fractal"),n.createElement("div",null)),!y&&n.createElement("div",{className:"pay-tab pay-conatiner-two"},n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},g!=="cardList"?n.createElement("div",null,(N==null?void 0:N.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>W("cardList")}," ",n.createElement(Vt,null)," Back"),n.createElement("div",{className:""},n.createElement("div",{className:"res-pay-con"},n.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",(U=Number(e==null?void 0:e.amount))==null?void 0:U.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/visa-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/mc-img.svg",width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/ae-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/discover-img.svg",width:35,alt:""})))))):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",x==null?void 0:x.customer_name),n.createElement("div",{className:"res-pay-con"},n.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",(xe=Number(e==null?void 0:e.amount))==null?void 0:xe.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/visa-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/mc-img.svg",width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/ae-img.svg",alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/discover-img.svg",width:35,alt:""})))),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),n.createElement("div",{style:{display:g==="cardList"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"card-lint-div-in"},n.createElement("div",{className:"card-list-div"},(x==null?void 0:x.card_list)&&((rt=x==null?void 0:x.card_list)==null?void 0:rt.length)>0&&((st=x==null?void 0:x.card_list)==null?void 0:st.map((p,f)=>n.createElement("div",{className:"card-list-single-div",key:f},n.createElement("div",{className:"card-number-radio"},n.createElement("input",{disabled:(x==null?void 0:x.paymentGateway)!=(p==null?void 0:p.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:S===p,onChange:B=>Pe(p)}),n.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",p==null?void 0:p.cardlastfourdigit),n.createElement("h6",{className:"card-expiry-date"},p==null?void 0:p.expmonth,"/",p==null?void 0:p.expyear)),n.createElement("div",{className:"card-number-radio"},n.createElement("span",{className:"visa-card"},n.createElement("img",{src:(p==null?void 0:p.card_type)!="Bank"?"https://dev-widget.fractalpay.com/images/visa-img.svg":"https://dev-widget.fractalpay.com/images/bank.svg",alt:""})),n.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>h(p==null?void 0:p.id)},n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/Trash.svg",alt:""}))))))),n.createElement("div",{className:"pay-with-other-card ",onClick:()=>W("card")},"Authorize With Other Card",n.createElement("img",{src:"https://dev-widget.fractalpay.com/images/card.svg",alt:""}))),n.createElement("div",{className:"form-group"},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:d},"$",(tt=Number(e==null?void 0:e.amount))==null?void 0:tt.toFixed(2)))),n.createElement("div",{id:"card",style:{display:g==="card"?"block":"none"},className:"tabcontent"},n.createElement("form",{id:"PaymentForm",onSubmit:Ce},n.createElement("div",{className:"ach-scrl",style:{minHeight:(N==null?void 0:N.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),n.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(s==null?void 0:s.cardName)||"",onChange:p=>{let f=p.target.value;/^[a-zA-Z\s]*$/.test(f)&&le("cardName",f)}}),(o==null?void 0:o.cardName)&&n.createElement("span",{className:"error-span"},o==null?void 0:o.cardName)),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardNumber"},"Card Number"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(s==null?void 0:s.cardNumber)||"",onChange:p=>ye(p),"data-token":"card_number"}),n.createElement("div",{className:"card-crdi card-expiry-new"},n.createElement("div",{className:"exp-date-year-container"},n.createElement("div",{className:"exp-date form-group"},n.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(s==null?void 0:s.expiryMonth)||"",onChange:p=>le("expiryMonth",p.target.value)})),n.createElement("div",{className:"exp-year form-group"},n.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(s==null?void 0:s.expiryYear)||"",onChange:p=>le("expiryYear",p.target.value)})),n.createElement("div",{className:"security-digit form-group"},n.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(s==null?void 0:s.cvv)||"",onChange:p=>le("cvv",p.target.value)})))),(o==null?void 0:o.cardNumber)&&n.createElement("span",{className:"error-span"},o==null?void 0:o.cardNumber),n.createElement("p",{style:{margin:"0"}},o!=null&&o.expiryMonth||o!=null&&o.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},o==null?void 0:o.expiryMonth):"",(o==null?void 0:o.cvv)&&n.createElement("span",{className:"error-span"},o==null?void 0:o.cvv)))),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(nt=s==null?void 0:s.orderId)!=null?nt:"OID123456",onChange:p=>le("orderId",p.target.value),style:{background:"#F6F6F7",color:"#727272"}})),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(lt=s==null?void 0:s.zipCode)!=null?lt:"",onChange:p=>le("zipCode",p.target.value)}),(o==null?void 0:o.zipCode)&&n.createElement("span",{className:"error-span"},o==null?void 0:o.zipCode)),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:l,onChange:p=>Le(p.target.checked)}),n.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),n.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12420_50192)"},n.createElement("rect",{width:"20",height:"20",fill:"white"}),n.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),n.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12420_50192"},n.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),n.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(dt=Number(e==null?void 0:e.amount))==null?void 0:dt.toFixed(2))))))))))))))))}import q,{useEffect as Sn,useState as gt}from"react";import Pn from"sweetalert2";import ht from"axios";import Mn from"react";function zt(){let e="#000",y="#fff",P="#212529",$="#dee2e6";return Mn.createElement("style",null,`
3555
1472
  .add-card {
3556
1473
  max-width:380px;
3557
1474
  padding: 0 20px
@@ -3810,16 +1727,7 @@ function AddCardStyle() {
3810
1727
  }
3811
1728
  }
3812
1729
 
3813
- `);
3814
- }
3815
-
3816
- // src/app/components/SuccessCardMessage/SuccessCardMsz.tsx
3817
- import React17 from "react";
3818
-
3819
- // src/app/components/SuccessCardMessage/SuccessCardMszStyle.tsx
3820
- import React16 from "react";
3821
- function SuccessCardMszStyle() {
3822
- return /* @__PURE__ */ React16.createElement("style", null, `
1730
+ `)}import Ue from"react";import Fn from"react";function It(){return Fn.createElement("style",null,`
3823
1731
  .card-success .logo-container {
3824
1732
  display: flex;
3825
1733
  justify-content: center;
@@ -3907,402 +1815,4 @@ function SuccessCardMszStyle() {
3907
1815
  color: #161616;
3908
1816
  opacity: 0.5;
3909
1817
  }
3910
- `);
3911
- }
3912
-
3913
- // src/app/components/SuccessCardMessage/SuccessCardMsz.tsx
3914
- var SuccessCardMsz = ({ onClose }) => {
3915
- return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(SuccessCardMszStyle, null), /* @__PURE__ */ React17.createElement("div", { className: "card-success" }, /* @__PURE__ */ React17.createElement("div", { className: "payment-success-container" }, /* @__PURE__ */ React17.createElement("div", { className: "success-icon" }, /* @__PURE__ */ React17.createElement("div", { className: "circle" }, /* @__PURE__ */ React17.createElement("i", { className: "fa fa-check-circle", "aria-hidden": "true" })), /* @__PURE__ */ React17.createElement("div", { className: "success-text" }, /* @__PURE__ */ React17.createElement("div", { className: "payment-success-text" }, "Your card was added successfully."), /* @__PURE__ */ React17.createElement("div", { className: "thank-you-text" }, "Thank you "))))));
3916
- };
3917
- var SuccessCardMsz_default = SuccessCardMsz;
3918
-
3919
- // src/app/components/AddCard/AddCardEasyPay.tsx
3920
- function AddCardEasyPay(props) {
3921
- var _a;
3922
- const [loading, setLoading] = useState5(false);
3923
- const [success, setSuccess] = useState5(false);
3924
- const [error, setError] = useState5("");
3925
- const [show, setShow] = useState5(false);
3926
- const [cardData, setCardData] = useState5();
3927
- const [cardError, setCardError] = useState5({});
3928
- const [paymentData, setPaymentData] = useState5();
3929
- const showLoader = () => setLoading(true);
3930
- const hideLoader = () => setLoading(false);
3931
- const showError = (msz) => {
3932
- Swal3.fire({
3933
- icon: "error",
3934
- text: msz,
3935
- customClass: {
3936
- popup: "custom-z-index"
3937
- }
3938
- });
3939
- };
3940
- const handleClose = () => {
3941
- setShow(false);
3942
- setSuccess(false);
3943
- setError("");
3944
- setCardData({
3945
- cardName: "",
3946
- cardNumber: "",
3947
- expiryMonth: "",
3948
- expiryYear: "",
3949
- cvv: "",
3950
- orderId: "",
3951
- zipCode: ""
3952
- });
3953
- };
3954
- const handleShow = () => setShow(true);
3955
- const handleCloseSeccess = () => {
3956
- handleClose();
3957
- };
3958
- const handleCardChange = (field, value) => {
3959
- const name = field;
3960
- const numericFields = ["expiryMonth", "expiryYear", "zipCode", "cvv"];
3961
- if (numericFields.includes(name)) {
3962
- if (value === "" || /^[0-9]+$/.test(value)) {
3963
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
3964
- [name]: ""
3965
- }));
3966
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
3967
- [name]: value
3968
- }));
3969
- }
3970
- return;
3971
- }
3972
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
3973
- [name]: ""
3974
- }));
3975
- console.log(value, name);
3976
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
3977
- [name]: value
3978
- }));
3979
- };
3980
- const handleCardNumberChange = (e) => {
3981
- const input = e.target;
3982
- const rawValue = input.value.replace(/\D/g, "");
3983
- let formatted = "";
3984
- if (/^3[47]/.test(rawValue)) {
3985
- const trimmed = rawValue.slice(0, 15);
3986
- formatted = trimmed.replace(
3987
- /^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,
3988
- (_, g1, g2, g3) => [g1, g2, g3].filter(Boolean).join(" ")
3989
- );
3990
- } else {
3991
- const trimmed = rawValue.slice(0, 16);
3992
- formatted = trimmed.replace(
3993
- /^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,
3994
- (_, g1, g2, g3, g4) => [g1, g2, g3, g4].filter(Boolean).join(" ")
3995
- );
3996
- }
3997
- setCardError((prev) => __spreadProps(__spreadValues({}, prev), {
3998
- cardNumber: ""
3999
- }));
4000
- setCardData((prev) => __spreadProps(__spreadValues({}, prev), {
4001
- cardNumber: formatted
4002
- }));
4003
- };
4004
- const validateCardData = () => {
4005
- var _a2, _b, _c, _d, _e, _f;
4006
- const errors = {};
4007
- const data = cardData;
4008
- const month = parseInt((data == null ? void 0 : data.expiryMonth) || "", 10);
4009
- const year = (data == null ? void 0 : data.expiryYear) || "";
4010
- if (!((_a2 = data == null ? void 0 : data.cardName) == null ? void 0 : _a2.trim())) errors.cardName = "Card name is required";
4011
- if (!((_b = data == null ? void 0 : data.cardNumber) == null ? void 0 : _b.trim())) errors.cardNumber = "Card number is required";
4012
- if (!((_c = data == null ? void 0 : data.expiryMonth) == null ? void 0 : _c.trim())) {
4013
- errors.expiryMonth = "Expiration month is required";
4014
- } else if (Number(data == null ? void 0 : data.expiryMonth) > 12 || Number(data == null ? void 0 : data.expiryMonth) < 1) {
4015
- errors.expiryMonth = "Invalid Expiration Month.";
4016
- }
4017
- if (!((_d = data == null ? void 0 : data.expiryYear) == null ? void 0 : _d.trim())) {
4018
- errors.expiryYear = "Expiration year is required";
4019
- } else if (((_e = data == null ? void 0 : data.expiryYear) == null ? void 0 : _e.trim().length) !== 4 || Number(data == null ? void 0 : data.expiryYear) < 2025) {
4020
- errors.expiryYear = "Invalid Expiration Year.";
4021
- } else if (isNaN(month) || month < 1 || month > 12 || year.length !== 4) {
4022
- errors.expiryMonth = "Invalid Expiration Date.";
4023
- }
4024
- if (!((_f = data == null ? void 0 : data.cvv) == null ? void 0 : _f.trim())) errors.cvv = "CVC is required";
4025
- if ((data == null ? void 0 : data.expiryMonth) && (data == null ? void 0 : data.expiryYear) && data.expiryMonth.length <= 2 && data.expiryYear.length === 4) {
4026
- const month2 = parseInt(data.expiryMonth, 10);
4027
- const year2 = parseInt(data.expiryYear, 10);
4028
- const now = /* @__PURE__ */ new Date();
4029
- const currentMonth = now.getMonth() + 1;
4030
- const currentYear = now.getFullYear();
4031
- if (year2 < currentYear || year2 === currentYear && month2 < currentMonth) {
4032
- errors.expiryMonth = "Card is expired";
4033
- }
4034
- }
4035
- setCardError(errors);
4036
- return Object.keys(errors).length > 0;
4037
- };
4038
- const getPaymentDetails = async () => {
4039
- var _a2, _b, _c;
4040
- showLoader();
4041
- try {
4042
- const data = {
4043
- fractalpayPublicKey: props == null ? void 0 : props.fractalpayClientKey,
4044
- "customer_id": props == null ? void 0 : props.customerId,
4045
- addcard: true
4046
- };
4047
- let paymentData2 = await axios5.post(`${baseUrl}get-payment-details`, data);
4048
- console.log(paymentData2);
4049
- setPaymentData((_a2 = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _a2.data);
4050
- if (!((_c = (_b = paymentData2 == null ? void 0 : paymentData2.data) == null ? void 0 : _b.data) == null ? void 0 : _c.paymentGateway)) {
4051
- handleClose();
4052
- setError("Something went wrong.");
4053
- }
4054
- hideLoader();
4055
- } catch (err) {
4056
- console.log(err);
4057
- hideLoader();
4058
- handleClose();
4059
- setError("Something went wrong.");
4060
- }
4061
- };
4062
- useEffect6(() => {
4063
- if (props.fractalpayClientKey) {
4064
- getPaymentDetails();
4065
- }
4066
- }, [props == null ? void 0 : props.fractalpayClientKey]);
4067
- const addCardFunc = async (e) => {
4068
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
4069
- e.preventDefault();
4070
- const hasError = validateCardData();
4071
- console.log(cardData);
4072
- if (hasError) return;
4073
- else {
4074
- let validCard = DatacapWebToken.validateCardNumber(cardData == null ? void 0 : cardData.cardNumber.replaceAll(" ", ""));
4075
- let validExpirationDate = DatacapWebToken.validateExpirationDate(cardData == null ? void 0 : cardData.expiryMonth, cardData == null ? void 0 : cardData.expiryYear);
4076
- let validCVV = DatacapWebToken.validateCVV(cardData == null ? void 0 : cardData.cvv);
4077
- let errors = {};
4078
- if (!validCard) errors.cardNumber = "Invalid card Number";
4079
- if (!validExpirationDate) errors.expiryMonth = "Invalid Expiration Date.";
4080
- if (!validCVV) errors.cvv = "Invalid CVV";
4081
- setCardError(errors);
4082
- if (validCard && validCVV && validExpirationDate) {
4083
- showLoader();
4084
- try {
4085
- let getTokenCallback = async function(token) {
4086
- var _a3, _b2, _c2, _d2, _e2;
4087
- console.log(token);
4088
- if (token.Error) {
4089
- console.log(token == null ? void 0 : token.Error);
4090
- setError(token.Error);
4091
- hideLoader();
4092
- } else {
4093
- const reqData = {
4094
- userId: props == null ? void 0 : props.customerId,
4095
- cardName: cardData == null ? void 0 : cardData.cardName,
4096
- zip: cardData == null ? void 0 : cardData.zipCode,
4097
- fractalpayPublicKey: props == null ? void 0 : props.fractalpayClientKey,
4098
- token
4099
- };
4100
- try {
4101
- let apiResponse = await axios5.post(`${baseUrl}add-card`, reqData);
4102
- console.log(apiResponse);
4103
- let formData = {
4104
- fractalpayPublicKey: props == null ? void 0 : props.fractalpayClientKey,
4105
- wallet_id: "",
4106
- card_number: cardData == null ? void 0 : cardData.cardNumber.replaceAll(" ", ""),
4107
- exp_month: cardData == null ? void 0 : cardData.expiryMonth,
4108
- exp_year: (_a3 = cardData == null ? void 0 : cardData.expiryYear) == null ? void 0 : _a3.slice(-2),
4109
- cvv: cardData == null ? void 0 : cardData.cvv
4110
- };
4111
- try {
4112
- const result = await axios5.post(`${baseUrl}link-wallet`, formData);
4113
- console.log(result);
4114
- setSuccess(true);
4115
- hideLoader();
4116
- setCardData({
4117
- cardName: "",
4118
- cardNumber: "",
4119
- expiryMonth: "",
4120
- expiryYear: "",
4121
- cvv: "",
4122
- orderId: "",
4123
- zipCode: ""
4124
- });
4125
- HandleSubmit(e, "close", "");
4126
- } catch (err) {
4127
- console.log(err);
4128
- hideLoader();
4129
- setError(((_c2 = (_b2 = err == null ? void 0 : err.response) == null ? void 0 : _b2.data) == null ? void 0 : _c2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
4130
- }
4131
- } catch (err) {
4132
- console.log(err);
4133
- hideLoader();
4134
- setError(((_e2 = (_d2 = err == null ? void 0 : err.response) == null ? void 0 : _d2.data) == null ? void 0 : _e2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
4135
- }
4136
- }
4137
- };
4138
- if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
4139
- const requestOptions = {
4140
- method: "POST",
4141
- redirect: "follow"
4142
- };
4143
- try {
4144
- let sesionResult = await axios5.post(`${masterBaseUrl}api/v1/widget/generate-session`, requestOptions);
4145
- let expYear = Number(cardData == null ? void 0 : cardData.expiryYear) % 100;
4146
- let cardNumber = cardData == null ? void 0 : cardData.cardNumber;
4147
- cardNumber = cardNumber == null ? void 0 : cardNumber.replace(/\s+/g, "");
4148
- let track2_data = `${cardNumber}=${expYear}${cardData == null ? void 0 : cardData.expiryMonth} ${cardData == null ? void 0 : cardData.cvv}`;
4149
- const publicKey = forge.pki.publicKeyFromPem((_b = (_a2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.publicKeyPem);
4150
- const encrypted = publicKey.encrypt(track2_data, "RSA-OAEP", {
4151
- md: forge.md.sha1.create(),
4152
- mgf1: {
4153
- md: forge.md.sha1.create()
4154
- }
4155
- });
4156
- const encryptedBase64 = forge.util.encode64(encrypted);
4157
- const myHeaders = {
4158
- "Content-Type": "application/json",
4159
- "x-app-session-key": (_d = (_c = sesionResult.data) == null ? void 0 : _c.data) == null ? void 0 : _d.session_key
4160
- };
4161
- const raw = JSON.stringify({
4162
- "enc_track2_data": `${encryptedBase64}`,
4163
- "algorithm": "RSAES_OAEP_SHA_1",
4164
- session_key: `${(_f = (_e = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e.data) == null ? void 0 : _f.session_key}`
4165
- });
4166
- try {
4167
- const tokenizeData = await axios5.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
4168
- const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g.data), {
4169
- cvv: cardData == null ? void 0 : cardData.cvv,
4170
- cardName: cardData == null ? void 0 : cardData.cardName,
4171
- zip: cardData == null ? void 0 : cardData.zipCode,
4172
- userId: props == null ? void 0 : props.customerId,
4173
- fractalpayPublicKey: props == null ? void 0 : props.fractalpayClientKey
4174
- }));
4175
- let myHeaders2 = {
4176
- "Content-Type": "application/json"
4177
- };
4178
- try {
4179
- let addCardRes = await axios5.post(
4180
- `${baseUrl}add-card`,
4181
- reqData,
4182
- {
4183
- headers: myHeaders2
4184
- }
4185
- );
4186
- console.log(addCardRes);
4187
- if ((_h = addCardRes == null ? void 0 : addCardRes.data) == null ? void 0 : _h.result) {
4188
- setSuccess(true);
4189
- hideLoader();
4190
- HandleSubmit(e, "close", "");
4191
- }
4192
- } catch (err) {
4193
- hideLoader();
4194
- setError(((_j = (_i = err == null ? void 0 : err.response) == null ? void 0 : _i.data) == null ? void 0 : _j.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
4195
- }
4196
- } catch (err) {
4197
- hideLoader();
4198
- setError(((_l = (_k = err == null ? void 0 : err.response) == null ? void 0 : _k.data) == null ? void 0 : _l.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
4199
- }
4200
- } catch (err) {
4201
- hideLoader();
4202
- setError(((_n = (_m = err == null ? void 0 : err.response) == null ? void 0 : _m.data) == null ? void 0 : _n.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
4203
- }
4204
- } else {
4205
- if (typeof DatacapWebToken !== "undefined") {
4206
- DatacapWebToken.requestToken(paymentData == null ? void 0 : paymentData.dctoken, "creditCardForm", getTokenCallback);
4207
- }
4208
- }
4209
- } catch (err) {
4210
- hideLoader();
4211
- setError(((_p = (_o = err == null ? void 0 : err.response) == null ? void 0 : _o.data) == null ? void 0 : _p.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
4212
- }
4213
- }
4214
- }
4215
- };
4216
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(DataScript, null), /* @__PURE__ */ React18.createElement(AddCardStyle, null), /* @__PURE__ */ React18.createElement(Loader_default, { loading }), error && /* @__PURE__ */ React18.createElement("div", { style: { maxHeight: "606px", minHeight: "60vh", padding: "40px" } }, /* @__PURE__ */ React18.createElement(ErrorCardMessage_default, { error, onClose: handleClose })), success && /* @__PURE__ */ React18.createElement(SuccessCardMsz_default, { onClose: handleCloseSeccess }), !error && !success && /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
4217
- "div",
4218
- {
4219
- className: "container-creditcard add-card modal-content",
4220
- id: "add-credit-card-panel",
4221
- style: { margin: "auto" }
4222
- },
4223
- /* @__PURE__ */ React18.createElement("form", { id: "creditCardForm", onSubmit: addCardFunc, style: { padding: "0 10px" } }, /* @__PURE__ */ React18.createElement("div", { style: { maxHeight: "350px", minHeight: "0" }, className: "card-scrl" }, /* @__PURE__ */ React18.createElement("div", { className: "form-group", style: { marginTop: "0", marginBottom: "10px" } }, /* @__PURE__ */ React18.createElement("label", { htmlFor: "cardNumber" }, "Card Number"), /* @__PURE__ */ React18.createElement(
4224
- "input",
4225
- {
4226
- type: "text",
4227
- "data-token": "card_number",
4228
- placeholder: "Enter card number",
4229
- maxLength: 19,
4230
- inputMode: "numeric",
4231
- value: (cardData == null ? void 0 : cardData.cardNumber) || "",
4232
- onChange: (e) => handleCardNumberChange(e)
4233
- }
4234
- ), (cardError == null ? void 0 : cardError.cardNumber) && /* @__PURE__ */ React18.createElement("span", { className: "error-span", style: { color: "red", fontSize: "12px" } }, cardError == null ? void 0 : cardError.cardNumber), /* @__PURE__ */ React18.createElement("br", null)), /* @__PURE__ */ React18.createElement("div", { className: "card-dtl" }, /* @__PURE__ */ React18.createElement("div", { className: "exp-cvc-container", style: { margin: "0" } }, /* @__PURE__ */ React18.createElement("div", { className: "form-group", style: { marginTop: "0" } }, /* @__PURE__ */ React18.createElement("label", { htmlFor: "expMonth" }, "MM"), /* @__PURE__ */ React18.createElement(
4235
- "input",
4236
- {
4237
- "data-token": "exp_month",
4238
- className: "form-control required",
4239
- type: "text",
4240
- placeholder: "MM",
4241
- maxLength: 2,
4242
- value: (cardData == null ? void 0 : cardData.expiryMonth) || "",
4243
- onChange: (e) => handleCardChange("expiryMonth", e.target.value)
4244
- }
4245
- ), (cardError == null ? void 0 : cardError.expiryMonth) && /* @__PURE__ */ React18.createElement("span", { className: "error-span", style: { color: "red", fontSize: "12px" } }, cardError == null ? void 0 : cardError.expiryMonth)), /* @__PURE__ */ React18.createElement("div", { className: "form-group", style: { marginTop: "0" } }, /* @__PURE__ */ React18.createElement("label", { htmlFor: "expYear" }, "YYYY"), /* @__PURE__ */ React18.createElement(
4246
- "input",
4247
- {
4248
- "data-token": "exp_year",
4249
- className: "form-control required",
4250
- type: "text",
4251
- placeholder: "YYYY",
4252
- maxLength: 4,
4253
- value: (cardData == null ? void 0 : cardData.expiryYear) || "",
4254
- onChange: (e) => handleCardChange("expiryYear", e.target.value)
4255
- }
4256
- ), (cardError == null ? void 0 : cardError.expiryYear) && /* @__PURE__ */ React18.createElement("span", { className: "error-span", style: { color: "red", fontSize: "12px" } }, cardError == null ? void 0 : cardError.expiryYear)), /* @__PURE__ */ React18.createElement("div", { className: "form-group", style: { marginTop: "0" } }, /* @__PURE__ */ React18.createElement("label", { htmlFor: "cvc" }, "CVC"), /* @__PURE__ */ React18.createElement(
4257
- "input",
4258
- {
4259
- "data-token": "cvv",
4260
- className: "form-control required",
4261
- type: "text",
4262
- placeholder: "CVC",
4263
- maxLength: 4,
4264
- value: (cardData == null ? void 0 : cardData.cvv) || "",
4265
- onChange: (e) => handleCardChange("cvv", e.target.value)
4266
- }
4267
- ), (cardError == null ? void 0 : cardError.cvv) && /* @__PURE__ */ React18.createElement("span", { className: "error-span", style: { color: "red", fontSize: "12px" } }, cardError == null ? void 0 : cardError.cvv)))), /* @__PURE__ */ React18.createElement("div", { className: "form-group", style: { marginTop: "0" } }, /* @__PURE__ */ React18.createElement("label", { htmlFor: "cardholderName" }, "Name on card"), /* @__PURE__ */ React18.createElement(
4268
- "input",
4269
- {
4270
- type: "text",
4271
- id: "cardholderName",
4272
- name: "cardholderName",
4273
- placeholder: "Name on card required",
4274
- value: (cardData == null ? void 0 : cardData.cardName) || "",
4275
- onChange: (e) => {
4276
- const value = e.target.value;
4277
- if (/^[a-zA-Z\s]*$/.test(value)) {
4278
- handleCardChange("cardName", value);
4279
- }
4280
- }
4281
- }
4282
- ), (cardError == null ? void 0 : cardError.cardName) && /* @__PURE__ */ React18.createElement("span", { className: "error-span", style: { color: "red", fontSize: "12px" } }, cardError == null ? void 0 : cardError.cardName)), /* @__PURE__ */ React18.createElement("div", { className: "form-group", style: { marginTop: "0" } }, /* @__PURE__ */ React18.createElement("label", { htmlFor: "zipcode" }, "Zip"), /* @__PURE__ */ React18.createElement(
4283
- "input",
4284
- {
4285
- type: "text",
4286
- id: "",
4287
- name: "zipcode",
4288
- placeholder: "Zip",
4289
- value: (_a = cardData == null ? void 0 : cardData.zipCode) != null ? _a : "",
4290
- onChange: (e) => handleCardChange("zipCode", e.target.value)
4291
- }
4292
- ), (cardError == null ? void 0 : cardError.zipCode) && /* @__PURE__ */ React18.createElement("span", { className: "error-span", style: { color: "red", fontSize: "12px" } }, cardError == null ? void 0 : cardError.zipCode))), /* @__PURE__ */ React18.createElement(
4293
- "input",
4294
- {
4295
- type: "submit",
4296
- className: "idle-green-btn w-100",
4297
- defaultValue: "Submit"
4298
- }
4299
- ))
4300
- )));
4301
- }
4302
- export {
4303
- AddCardEasyPay as AddCard,
4304
- GetPaymentPage,
4305
- PreAuthPayment,
4306
- RequestPayment,
4307
- RequestPreAuthPayment
4308
- };
1818
+ `)}var Ln=({onClose:e})=>Ue.createElement(Ue.Fragment,null,Ue.createElement(It,null),Ue.createElement("div",{className:"card-success"},Ue.createElement("div",{className:"payment-success-container"},Ue.createElement("div",{className:"success-icon"},Ue.createElement("div",{className:"circle"},Ue.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),Ue.createElement("div",{className:"success-text"},Ue.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),Ue.createElement("div",{className:"thank-you-text"},"Thank you ")))))),Zt=Ln;function zn(e){var A;let[y,P]=gt(!1),[$,z]=gt(!1),[Be,v]=gt(""),[je,ge]=gt(!1),[a,Y]=gt(),[g,W]=gt({}),[l,Le]=gt(),ke=()=>P(!0),s=()=>P(!1),Se=C=>{Pn.fire({icon:"error",text:C,customClass:{popup:"custom-z-index"}})},o=()=>{ge(!1),z(!1),v(""),Y({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},he=()=>ge(!0),N=()=>{o()},ve=(C,u)=>{let Z=C;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(Z)){(u===""||/^[0-9]+$/.test(u))&&(W(H=>L(F({},H),{[Z]:""})),Y(H=>L(F({},H),{[Z]:u})));return}W(H=>L(F({},H),{[Z]:""})),console.log(u,Z),Y(H=>L(F({},H),{[Z]:u}))},S=C=>{let Z=C.target.value.replace(/\D/g,""),b="";/^3[47]/.test(Z)?b=Z.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(le,ye,_e,Ce)=>[ye,_e,Ce].filter(Boolean).join(" ")):b=Z.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(le,ye,_e,Ce,ue)=>[ye,_e,Ce,ue].filter(Boolean).join(" ")),W(H=>L(F({},H),{cardNumber:""})),Y(H=>L(F({},H),{cardNumber:b}))},Pe=()=>{var H,le,ye,_e,Ce,ue;let C={},u=a,Z=parseInt((u==null?void 0:u.expiryMonth)||"",10),b=(u==null?void 0:u.expiryYear)||"";if((H=u==null?void 0:u.cardName)!=null&&H.trim()||(C.cardName="Card name is required"),(le=u==null?void 0:u.cardNumber)!=null&&le.trim()||(C.cardNumber="Card number is required"),(ye=u==null?void 0:u.expiryMonth)!=null&&ye.trim()?(Number(u==null?void 0:u.expiryMonth)>12||Number(u==null?void 0:u.expiryMonth)<1)&&(C.expiryMonth="Invalid Expiration Month."):C.expiryMonth="Expiration month is required",(_e=u==null?void 0:u.expiryYear)!=null&&_e.trim()?((Ce=u==null?void 0:u.expiryYear)==null?void 0:Ce.trim().length)!==4||Number(u==null?void 0:u.expiryYear)<2025?C.expiryYear="Invalid Expiration Year.":(isNaN(Z)||Z<1||Z>12||b.length!==4)&&(C.expiryMonth="Invalid Expiration Date."):C.expiryYear="Expiration year is required",(ue=u==null?void 0:u.cvv)!=null&&ue.trim()||(C.cvv="CVC is required"),u!=null&&u.expiryMonth&&(u!=null&&u.expiryYear)&&u.expiryMonth.length<=2&&u.expiryYear.length===4){let d=parseInt(u.expiryMonth,10),h=parseInt(u.expiryYear,10),I=new Date,U=I.getMonth()+1,xe=I.getFullYear();(h<xe||h===xe&&d<U)&&(C.expiryMonth="Card is expired")}return W(C),Object.keys(C).length>0},x=async()=>{var C,u,Z;ke();try{let b={fractalpayPublicKey:e==null?void 0:e.fractalpayClientKey,customer_id:e==null?void 0:e.customerId,addcard:!0},H=await ht.post(`${ce}get-payment-details`,b);console.log(H),Le((C=H==null?void 0:H.data)==null?void 0:C.data),(Z=(u=H==null?void 0:H.data)==null?void 0:u.data)!=null&&Z.paymentGateway||(o(),v("Something went wrong.")),s()}catch(b){console.log(b),s(),o(),v("Something went wrong.")}};return Sn(()=>{e.fractalpayClientKey&&x()},[e==null?void 0:e.fractalpayClientKey]),q.createElement(q.Fragment,null,q.createElement(ct,null),q.createElement(zt,null),q.createElement(Qe,{loading:y}),Be&&q.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},q.createElement(ft,{error:Be,onClose:o})),$&&q.createElement(Zt,{onClose:N}),!Be&&!$&&q.createElement(q.Fragment,null,q.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},q.createElement("form",{id:"creditCardForm",onSubmit:async C=>{var Z,b,H,le,ye,_e,Ce,ue,d,h,I,U,xe,rt,st,tt;C.preventDefault();let u=Pe();if(console.log(a),!u){let nt=DatacapWebToken.validateCardNumber(a==null?void 0:a.cardNumber.replaceAll(" ","")),lt=DatacapWebToken.validateExpirationDate(a==null?void 0:a.expiryMonth,a==null?void 0:a.expiryYear),dt=DatacapWebToken.validateCVV(a==null?void 0:a.cvv),p={};if(nt||(p.cardNumber="Invalid card Number"),lt||(p.expiryMonth="Invalid Expiration Date."),dt||(p.cvv="Invalid CVV"),W(p),nt&&dt&&lt){ke();try{let f=async function(B){var T,V,X,ie,de;if(console.log(B),B.Error)console.log(B==null?void 0:B.Error),v(B.Error),s();else{let ae={userId:e==null?void 0:e.customerId,cardName:a==null?void 0:a.cardName,zip:a==null?void 0:a.zipCode,fractalpayPublicKey:e==null?void 0:e.fractalpayClientKey,token:B};try{let G=await ht.post(`${ce}add-card`,ae);console.log(G);let Me={fractalpayPublicKey:e==null?void 0:e.fractalpayClientKey,wallet_id:"",card_number:a==null?void 0:a.cardNumber.replaceAll(" ",""),exp_month:a==null?void 0:a.expiryMonth,exp_year:(T=a==null?void 0:a.expiryYear)==null?void 0:T.slice(-2),cvv:a==null?void 0:a.cvv};try{let Q=await ht.post(`${ce}link-wallet`,Me);console.log(Q),z(!0),s(),Y({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),ot(C,"close","")}catch(Q){console.log(Q),s(),v(((X=(V=Q==null?void 0:Q.response)==null?void 0:V.data)==null?void 0:X.message)||(Q==null?void 0:Q.message)||"Something went wrong.")}}catch(G){console.log(G),s(),v(((de=(ie=G==null?void 0:G.response)==null?void 0:ie.data)==null?void 0:de.message)||(G==null?void 0:G.message)||"Something went wrong.")}}};if((l==null?void 0:l.paymentGateway)===32){let B={method:"POST",redirect:"follow"};try{let T=await ht.post(`${pt}api/v1/widget/generate-session`,B),V=Number(a==null?void 0:a.expiryYear)%100,X=a==null?void 0:a.cardNumber;X=X==null?void 0:X.replace(/\s+/g,"");let ie=`${X}=${V}${a==null?void 0:a.expiryMonth} ${a==null?void 0:a.cvv}`,ae=forge.pki.publicKeyFromPem((b=(Z=T==null?void 0:T.data)==null?void 0:Z.data)==null?void 0:b.publicKeyPem).encrypt(ie,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),G=forge.util.encode64(ae),Me={"Content-Type":"application/json","x-app-session-key":(le=(H=T.data)==null?void 0:H.data)==null?void 0:le.session_key},Q=JSON.stringify({enc_track2_data:`${G}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(_e=(ye=T==null?void 0:T.data)==null?void 0:ye.data)==null?void 0:_e.session_key}`});try{let D=await ht.post(`${ut}tokenizer/tokenize`,Q,{headers:Me}),Te=JSON.stringify(L(F({},(Ce=D==null?void 0:D.data)==null?void 0:Ce.data),{cvv:a==null?void 0:a.cvv,cardName:a==null?void 0:a.cardName,zip:a==null?void 0:a.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.fractalpayClientKey})),ze={"Content-Type":"application/json"};try{let oe=await ht.post(`${ce}add-card`,Te,{headers:ze});console.log(oe),(ue=oe==null?void 0:oe.data)!=null&&ue.result&&(z(!0),s(),ot(C,"close",""))}catch(oe){s(),v(((h=(d=oe==null?void 0:oe.response)==null?void 0:d.data)==null?void 0:h.message)||(oe==null?void 0:oe.message)||"Something went wrong.")}}catch(D){s(),v(((U=(I=D==null?void 0:D.response)==null?void 0:I.data)==null?void 0:U.message)||(D==null?void 0:D.message)||"Something went wrong.")}}catch(T){s(),v(((rt=(xe=T==null?void 0:T.response)==null?void 0:xe.data)==null?void 0:rt.message)||(T==null?void 0:T.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(l==null?void 0:l.dctoken,"creditCardForm",f)}catch(f){s(),v(((tt=(st=f==null?void 0:f.response)==null?void 0:st.data)==null?void 0:tt.message)||(f==null?void 0:f.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},q.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},q.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},q.createElement("label",{htmlFor:"cardNumber"},"Card Number"),q.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(a==null?void 0:a.cardNumber)||"",onChange:C=>S(C)}),(g==null?void 0:g.cardNumber)&&q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},g==null?void 0:g.cardNumber),q.createElement("br",null)),q.createElement("div",{className:"card-dtl"},q.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},q.createElement("div",{className:"form-group",style:{marginTop:"0"}},q.createElement("label",{htmlFor:"expMonth"},"MM"),q.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(a==null?void 0:a.expiryMonth)||"",onChange:C=>ve("expiryMonth",C.target.value)}),(g==null?void 0:g.expiryMonth)&&q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},g==null?void 0:g.expiryMonth)),q.createElement("div",{className:"form-group",style:{marginTop:"0"}},q.createElement("label",{htmlFor:"expYear"},"YYYY"),q.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(a==null?void 0:a.expiryYear)||"",onChange:C=>ve("expiryYear",C.target.value)}),(g==null?void 0:g.expiryYear)&&q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},g==null?void 0:g.expiryYear)),q.createElement("div",{className:"form-group",style:{marginTop:"0"}},q.createElement("label",{htmlFor:"cvc"},"CVC"),q.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(a==null?void 0:a.cvv)||"",onChange:C=>ve("cvv",C.target.value)}),(g==null?void 0:g.cvv)&&q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},g==null?void 0:g.cvv)))),q.createElement("div",{className:"form-group",style:{marginTop:"0"}},q.createElement("label",{htmlFor:"cardholderName"},"Name on card"),q.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(a==null?void 0:a.cardName)||"",onChange:C=>{let u=C.target.value;/^[a-zA-Z\s]*$/.test(u)&&ve("cardName",u)}}),(g==null?void 0:g.cardName)&&q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},g==null?void 0:g.cardName)),q.createElement("div",{className:"form-group",style:{marginTop:"0"}},q.createElement("label",{htmlFor:"zipcode"},"Zip"),q.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(A=a==null?void 0:a.zipCode)!=null?A:"",onChange:C=>ve("zipCode",C.target.value)}),(g==null?void 0:g.zipCode)&&q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},g==null?void 0:g.zipCode))),q.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}export{zn as AddCard,Nn as GetPaymentPage,_n as PreAuthPayment,cn as RequestPayment,fn as RequestPreAuthPayment};