@fractalpay/fractalpay-next-dev 0.0.68 → 0.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -22
- package/dist/index.mjs +14 -14
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ii=Object.defineProperty,ai=Object.defineProperties;var oi=Object.getOwnPropertyDescriptors;var Cn=Object.getOwnPropertySymbols;var jn=Object.prototype.hasOwnProperty,Vn=Object.prototype.propertyIsEnumerable;var Hn=(e,h,q)=>h in e?ii(e,h,{enumerable:!0,configurable:!0,writable:!0,value:q}):e[h]=q,P=(e,h)=>{for(var q in h||(h={}))jn.call(h,q)&&Hn(e,q,h[q]);if(Cn)for(var q of Cn(h))Vn.call(h,q)&&Hn(e,q,h[q]);return e},I=(e,h)=>ai(e,oi(h));var wn=(e,h)=>{var q={};for(var Z in e)jn.call(e,Z)&&h.indexOf(Z)<0&&(q[Z]=e[Z]);if(e!=null&&Cn)for(var Z of Cn(e))h.indexOf(Z)<0&&Vn.call(e,Z)&&(q[Z]=e[Z]);return q};var ri=(e,h)=>()=>(h||e((h={exports:{}}).exports,h),h.exports);var On=ri((ia,mi)=>{mi.exports={name:"@fractalpay/fractalpay-next-dev",version:"0.0.69",private:!1,scripts:{dev:"next dev -p 4001",build:"next build",start:"next start",lint:"next lint",bundle:"tsup src/app/index.ts"},dependencies:{"@types/yup":"^0.29.14",axios:"^1.8.1",bootstrap:"^5.3.3","credit-card-type":"^10.0.1",formik:"^2.4.6","node-forge":"^1.3.1","react-bootstrap":"^2.10.5","react-bs-datatable":"^3.15.0","react-datepicker":"^7.5.0","react-icons":"^5.5.0","react-number-format":"^5.4.3","react-toastify":"^10.0.6","socket.io-client":"^4.8.1","styled-components":"^6.1.15",sweetalert2:"^11.22.0",yup:"^1.6.1"},peerdependencies:{next:"15.0.3",react:">=18.0.0 <20.0.0","react-dom":">=18.0.0 <20.0.0"},devDependencies:{"@types/estree":"^1.0.8","@types/node":"^20","@types/node-forge":"^1.3.11","@types/react":"^18","@types/react-dom":"^18",autoprefixer:"^10.4.20","credit-card-type":"^10.0.1",eslint:"^8","eslint-config-next":"15.0.3",next:"^15.0.3",react:"^18.3.1","react-bs-datatable":"^3.15.0","react-datepicker":"^7.5.0","react-dom":"^18.3.1","react-toastify":"^10.0.6",tsup:"^8.4.0",typescript:"^5"},author:"Mukul",license:"MIT",keywords:["nextjs","next","typescript","tailwindcss"],main:"dist/index.js",publishConfig:{access:"public"}}});import"bootstrap/dist/js/bootstrap.bundle.min.js";import _,{useState as Rt,useEffect as Zn}from"react";import Dt from"react";import si from"react";var li=e=>si.createElement("style",null,`
|
|
2
2
|
|
|
3
3
|
.loader {
|
|
4
4
|
position: fixed; /* Fixed position to cover the viewport */
|
|
@@ -81,7 +81,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
`),
|
|
84
|
+
`),Kn=li;var di=e=>Dt.createElement(Dt.Fragment,null,Dt.createElement(Kn,null),(e==null?void 0:e.loading)&&Dt.createElement("div",{className:"loader"},Dt.createElement("div",{className:"lds-ellipsis"},Dt.createElement("div",null),Dt.createElement("div",null),Dt.createElement("div",null),Dt.createElement("div",null)))),kt=di;var{name:dn}=On();console.log(dn,"dgijiisdfhg");var te="https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/";dn==="@fractalpay/fractalpay-next-dev"?(Ce="https://dev-sky-node.fractalpay.com/",_e="https://dev-widget.fractalpay.com/",gt="https://api-dev.merchant-trends.com/"):dn==="@fractalpay/fractalpay-next-test"?(Ce="https://testapi.fractalpay.com/",_e="https://staging-widget.fractalpay.com/",gt="https://api-dev.merchant-trends.com/"):dn==="@fractalpay/fractalpay-next-testprod"?(Ce="https://sky-node-prod.fractalpay.com/",_e="https://widget-prod.fractalpay.com/",gt="https://api.merchant-trends.com/"):dn==="@fractalpay/fractalpay-next"?(Ce="https://api.fractalpay.com/",_e="https://widget.fractalpay.com/",gt="https://api.merchant-trends.com/"):(_e="http://localhost:8082/",Ce="http://localhost:8081/",gt="https://api-dev.merchant-trends.com/");var Ce,_e,gt;var Xe={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 mn from"react";import ci from"react";var pi=e=>ci.createElement("style",null,`
|
|
85
85
|
.fractal-input::placeholder {
|
|
86
86
|
color: #35254D;
|
|
87
87
|
opacity: 1;
|
|
@@ -334,7 +334,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
334
334
|
padding: 0px !important;
|
|
335
335
|
border-radius: 12px !important;
|
|
336
336
|
}
|
|
337
|
-
`),
|
|
337
|
+
`),En=pi;var ui=({open:e,onClose:h,children:q,maxWidth:Z})=>e?mn.createElement(mn.Fragment,null,mn.createElement(En,null),mn.createElement("div",{className:"fractal-popup"},mn.createElement("div",{className:"fractal-popup-content request-payment-popup-container",style:{maxWidth:`${Z!=null?Z:"auto"}`}},q))):null,$t=ui;import hi from"axios";import{PatternFormat as yi}from"react-number-format";import gi from"react";var fi=e=>gi.createElement("style",null,`
|
|
338
338
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
339
339
|
body {
|
|
340
340
|
font-family: 'Inter', sans-serif !important;
|
|
@@ -595,7 +595,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
595
595
|
font-style: normal;
|
|
596
596
|
font-weight: 500;
|
|
597
597
|
}
|
|
598
|
-
`),wn=gi;function yi(e){let h=e.merchantPublicKey,$=e==null?void 0:e.discount,Z=e==null?void 0:e.tax,j=e==null?void 0:e.surcharge,[qe,q]=Qt(!1),[We,ke]=Qt(!1),[Y,c]=Qt({}),[G,v]=Qt(null),[y,o]=Qt({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),[he,x]=Qt(void 0),[ye,f]=Qt(""),[Ue,W]=Qt(!1),[xe,dt]=Qt(null),Je=d=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(d),yt=/[+-]?([0-9]*[.])?[0-9]+/,b=d=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d),we=d=>/^[A-Za-z\s]*$/.test(d),Q=(d,X)=>{let L=(parseFloat(X)||0)/100,Me=d/(1+L);return Math.round(Me*100)/100};En(()=>{if(e!=null&&e.pass_fee){let d=Q(e==null?void 0:e.amount,e==null?void 0:e.surcharge);x(d)}},[e==null?void 0:e.pass_fee]);let C=()=>{q(!1),c({})},p=()=>q(!0),ce=()=>{console.log(xe,"apiresponse"),_(xe),W(!1)};function le(){o({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),f("")}function _(d){let X={type:"preview.compiledcheck",other:A(S({},d),{status:!0})};window.parent.postMessage(X,"*")}let u=async()=>{if(!(Object.keys(Y).length>0)){if(c({}),!(y!=null&&y.email)&&G&&!Je(G)){c(d=>A(S({},d),{phone:Qe.phonenumbervalid}));return}if(F())try{ke(!0);let d={fractalpayPublicKey:h,amount:ye,phone_number:G,order_id:y.order_id,action:"request",name:y.name,email:y.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:$,surcharge:j,tax:Z,require_3ds:e==null?void 0:e.require_3ds,pass_fee:e==null?void 0:e.pass_fee},X=await fi.post(`${Fe}create-widget-order`,d);(X==null?void 0:X.status)===200&&(W(!0),q(!1),le(),dt(X==null?void 0:X.data)),ke(!1)}catch(d){console.log(d),ke(!1)}}},J=Fe+"images/logo-img.png",H=d=>{let{value:X}=d.target,L=d.target.dataset.token;if(o(A(S({},y),{[L]:X})),L==="name"&&!we(X)){c(O=>A(S({},O),{[L]:Qe.onlylettersallowed}));return}let Me=Y;L==="email"&&!G&&(delete Me.phone,c(Me)),X&&(delete Me[L],c(Me)),L==="email"&&!X&&(delete Me[L],c(Me))},g=d=>{let{value:X}=d;if(Number(X)>0){let L=Y;delete L.amount,c(L)}f(X)},F=()=>{let d={};return ye||(d.amount=Qe.amountrequired),y.email&&!b(y==null?void 0:y.email)&&(d.email=Qe.invalidemail),!G&&!(y!=null&&y.email)&&(d.phone=Qe.phoneoremailrequired),!G&&!(y!=null&&y.email)&&(d.email=Qe.phoneoremailrequired),!G&&y.email&&!b(y==null?void 0:y.email)&&(d.email=Qe.invalidemail),e.from==="merchant"&&!y.order_id&&(d.order_id=Qe.orderidrequired),c(d),Object.keys(d).length===0};En(()=>{e&&(o(d=>A(S({},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:""})),f(e.amount?e.amount:""),v(e.phone?`${e.phone}`:null))},[e]);let m=d=>{let X=d==null?void 0:d.value;if(X&&(X==null?void 0:X.length)>0&&(X==null?void 0:X.length)!==10){c(Me=>A(S({},Me),{phone:Qe.phonenumberlength})),v(X);return}else v(X);let L=Y;delete L.phone,X&&!(y!=null&&y.email)&&delete L.email,c(L)};function K(d){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(d))}return k.createElement(k.Fragment,null,k.createElement(wn,null),k.createElement(St,{loading:We}),k.createElement(k.Fragment,null,k.createElement("button",{className:"paymentBtn",onClick:p},"Request Payment"),k.createElement(Tt,{open:qe,onClose:()=>q(!1),maxWidth:"500px"},k.createElement("div",{style:{maxWidth:"500px"}},k.createElement("div",{className:"request-payment-amount-detail frac-form"},k.createElement("p",{className:"request-payment-merchantname"},"Pay ",e==null?void 0:e.webname),k.createElement("p",{className:"request-payment-amount"},K(e==null?void 0:e.amount)),he&&he>0&&k.createElement("div",{className:"frac-req-cash-discount"},k.createElement("div",{className:"frac-cashlabel"},"Cash Discount :"),k.createElement("div",null,"$",he.toFixed(2))),(e==null?void 0:e.from)==="merchant"&&k.createElement("p",{className:"request-payment-orderid"},y==null?void 0:y.order_id),k.createElement("span",{className:"request-payment-close-popup",onClick:C},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},k.createElement("g",{clipPath:"url(#clip0_12425_52336)"},k.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"})),k.createElement("defs",null,k.createElement("clipPath",{id:"clip0_12425_52336"},k.createElement("rect",{width:"16",height:"16",fill:"white"})))))),k.createElement("form",{className:"request-payment-input-form"},k.createElement("div",{className:"request-payment-list-div"},k.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),k.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:H,value:y==null?void 0:y.name}),Y.name&&k.createElement("small",{className:"request-payment-error-msg"},Y.name)),k.createElement("div",{className:"request-payment-list-div"},k.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),k.createElement(hi,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:G,onValueChange:d=>{m(d)}}),Y.phone&&k.createElement("small",{className:"request-payment-error-msg"},Y.phone)),k.createElement("div",{className:"request-payment-list-div"},k.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),k.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:H,"data-token":"email",value:y==null?void 0:y.email}),Y.email&&k.createElement("small",{className:"request-payment-error-msg"},Y.email)),k.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:u,disabled:We},We?"Loading...":"Send Request"),k.createElement("div",{className:"request-payment-fractal-powerd-by"},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},k.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 ",k.createElement("span",null,"Fractal"),k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"}),k.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"})))))),k.createElement(Tt,{open:Ue,onClose:ce,maxWidth:"500px"},k.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},k.createElement("div",{className:"request-payment-success-container"},k.createElement("span",{className:"request-payment-close-popup",onClick:ce},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},k.createElement("g",{clipPath:"url(#clip0_12425_52336)"},k.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"})),k.createElement("defs",null,k.createElement("clipPath",{id:"clip0_12425_52336"},k.createElement("rect",{width:"16",height:"16",fill:"white"}))))),k.createElement("div",{className:"request-payment-success-tick-div"},k.createElement("div",{className:"request-payment-success-tick"},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},k.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"})))),k.createElement("h6",{className:"request-payment-success-text"},"The request ",k.createElement("br",null),"was sent"),k.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),k.createElement("div",{className:"request-payment-success-btn-div"},k.createElement("button",{onClick:ce,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import P,{useState as en,useEffect as xi}from"react";import bi from"axios";import{PatternFormat as vi}from"react-number-format";function Ci(e){let h=e.merchantPublicKey,$=e==null?void 0:e.discount,Z=e==null?void 0:e.tax,j=e==null?void 0:e.surcharge,[qe,q]=en(!1),[We,ke]=en(!1),[Y,c]=en({}),[G,v]=en(null),[y,o]=en({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),[he,x]=en(""),[ye,f]=en(!1),[Ue,W]=en(null),xe=F=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(F),dt=/[+-]?([0-9]*[.])?[0-9]+/,Je=F=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(F),yt=F=>/^[A-Za-z\s]*$/.test(F),b=()=>{q(!1),c({})},we=()=>q(!0),Q=()=>{console.log(Ue,"apiresponse"),p(Ue),f(!1)};function C(){o({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),x("")}function p(F){let m={type:"preview.compiledcheck",other:A(S({},F),{status:!0})};window.parent.postMessage(m,"*")}let ce=async()=>{if(!(Object.keys(Y).length>0)){if(c({}),!(y!=null&&y.email)&&G&&!xe(G)){c(F=>A(S({},F),{phone:Qe.phonenumbervalid}));return}if(J())try{ke(!0);let F={fractalpayPublicKey:h,amount:he,phone_number:G,order_id:y.order_id,action:"request",name:y.name,email:y.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:$,surcharge:j,tax:Z,require_3ds:e==null?void 0:e.require_3ds},m=await bi.post(`${Fe}send-request-pre-auth-payment`,F);(m==null?void 0:m.status)===200&&(f(!0),q(!1),C(),W(m==null?void 0:m.data)),ke(!1)}catch(F){console.log(F),ke(!1)}}},le=Fe+"images/logo-img.png",_=F=>{let{value:m}=F.target,K=F.target.dataset.token;if(o(A(S({},y),{[K]:m})),K==="name"&&!yt(m)){c(X=>A(S({},X),{[K]:Qe.onlylettersallowed}));return}let d=Y;K==="email"&&!G&&(delete d.phone,c(d)),m&&(delete d[K],c(d)),K==="email"&&!m&&(delete d[K],c(d))},u=F=>{let{value:m}=F;if(Number(m)>0){let K=Y;delete K.amount,c(K)}x(m)},J=()=>{let F={};return he||(F.amount=Qe.amountrequired),y.email&&!Je(y==null?void 0:y.email)&&(F.email=Qe.invalidemail),!G&&!(y!=null&&y.email)&&(F.phone=Qe.phoneoremailrequired),!G&&!(y!=null&&y.email)&&(F.email=Qe.phoneoremailrequired),!G&&y.email&&!Je(y==null?void 0:y.email)&&(F.email=Qe.invalidemail),e.from==="merchant"&&!y.order_id&&(F.order_id=Qe.orderidrequired),c(F),Object.keys(F).length===0};xi(()=>{e&&(o(F=>A(S({},F),{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:""})),x(e.amount?e.amount:""),v(e.phone?`${e.phone}`:null))},[e]);let H=F=>{let m=F==null?void 0:F.value;if(m&&(m==null?void 0:m.length)>0&&(m==null?void 0:m.length)!==10){c(d=>A(S({},d),{phone:Qe.phonenumberlength})),v(m);return}else v(m);let K=Y;delete K.phone,m&&!(y!=null&&y.email)&&delete K.email,c(K)};function g(F){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(F))}return P.createElement(P.Fragment,null,P.createElement(wn,null),P.createElement(St,{loading:We}),P.createElement(P.Fragment,null,P.createElement("button",{className:"paymentBtn",onClick:we},"Send Request"),P.createElement("div",{className:"frac-form"},P.createElement(Tt,{open:qe,onClose:()=>q(!1),maxWidth:"500px"},P.createElement("div",{className:"request-payment-amount-detail"},P.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),P.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",e==null?void 0:e.webname),P.createElement("p",{className:"request-payment-amount"},g(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&P.createElement("p",{className:"request-payment-orderid"},y==null?void 0:y.order_id),P.createElement("span",{className:"request-payment-close-popup",onClick:b},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},P.createElement("g",{clipPath:"url(#clip0_12425_52336)"},P.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"})),P.createElement("defs",null,P.createElement("clipPath",{id:"clip0_12425_52336"},P.createElement("rect",{width:"16",height:"16",fill:"white"})))))),P.createElement("form",{className:"request-payment-input-form"},P.createElement("div",{className:"request-payment-list-div"},P.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),P.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:_,value:y==null?void 0:y.name}),Y.name&&P.createElement("small",{className:"request-payment-error-msg"},Y.name)),P.createElement("div",{className:"request-payment-list-div"},P.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),P.createElement(vi,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:G,onValueChange:F=>{H(F)}}),Y.phone&&P.createElement("small",{className:"request-payment-error-msg"},Y.phone)),P.createElement("div",{className:"request-payment-list-div"},P.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),P.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:_,"data-token":"email",value:y==null?void 0:y.email}),Y.email&&P.createElement("small",{className:"request-payment-error-msg"},Y.email)),P.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:ce,disabled:We},We?"Loading...":"Send Request"),P.createElement("div",{className:"request-payment-fractal-powerd-by"},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},P.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 ",P.createElement("span",null,"Fractal"),P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}),P.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"}))))),P.createElement(Tt,{open:ye,onClose:Q,maxWidth:"500px"},P.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},P.createElement("div",{className:"request-payment-success-container"},P.createElement("span",{className:"request-payment-close-popup",onClick:Q},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},P.createElement("g",{clipPath:"url(#clip0_12425_52336)"},P.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"})),P.createElement("defs",null,P.createElement("clipPath",{id:"clip0_12425_52336"},P.createElement("rect",{width:"16",height:"16",fill:"white"}))))),P.createElement("div",{className:"request-payment-success-tick-div"},P.createElement("div",{className:"request-payment-success-tick"},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},P.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"})))),P.createElement("h6",{className:"request-payment-success-text"},"The request ",P.createElement("br",null),"was sent"),P.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),P.createElement("div",{className:"request-payment-success-btn-div"},P.createElement("button",{onClick:Q,className:"request-payment-success-btn2"},"Close"))))))))}import t,{useEffect as Gn,useState as Ve}from"react";import wi from"react";function mn(){let e="#000",h="#fff",$="#212529",Z="#dee2e6";return wi.createElement("style",null,`
|
|
598
|
+
`),Nn=fi;function xi(e){let h=e.merchantPublicKey,q=e==null?void 0:e.discount,Z=e==null?void 0:e.tax,H=e==null?void 0:e.surcharge,[Te,B]=Rt(!1),[Ee,Ne]=Rt(!1),[$,m]=Rt({}),[U,C]=Rt(null),[x,o]=Rt({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),[ye,b]=Rt(void 0),[xe,f]=Rt(""),[Ze,W]=Rt(!1),[be,lt]=Rt(null),Ue=l=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(l),ht=/[+-]?([0-9]*[.])?[0-9]+/,v=l=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l),we=l=>/^[A-Za-z\s]*$/.test(l),Q=(l,X)=>{let L=(parseFloat(X)||0)/100,Pe=l/(1+L);return Math.round(Pe*100)/100};Zn(()=>{if(e!=null&&e.pass_fee){let l=Q(e==null?void 0:e.amount,e==null?void 0:e.surcharge);b(l)}},[e==null?void 0:e.pass_fee]);let w=()=>{B(!1),m({})},p=()=>B(!0),pe=()=>{console.log(be,"apiresponse"),F(be),W(!1)};function de(){o({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),f("")}function F(l){let X={type:"preview.compiledcheck",other:I(P({},l),{status:!0})};window.parent.postMessage(X,"*")}let u=async()=>{if(!(Object.keys($).length>0)){if(m({}),!(x!=null&&x.email)&&U&&!Ue(U)){m(l=>I(P({},l),{phone:Xe.phonenumbervalid}));return}if(S())try{Ne(!0);let l={fractalpayPublicKey:h,amount:xe,phone_number:U,order_id:x.order_id,action:"request",name:x.name,email:x.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:q,surcharge:H,tax:Z,require_3ds:e==null?void 0:e.require_3ds,pass_fee:e==null?void 0:e.pass_fee},X=await hi.post(`${_e}create-widget-order`,l);(X==null?void 0:X.status)===200&&(W(!0),B(!1),de(),lt(X==null?void 0:X.data)),Ne(!1)}catch(l){console.log(l),Ne(!1)}}},G=_e+"images/logo-img.png",Y=l=>{let{value:X}=l.target,L=l.target.dataset.token;if(o(I(P({},x),{[L]:X})),L==="name"&&!we(X)){m(O=>I(P({},O),{[L]:Xe.onlylettersallowed}));return}let Pe=$;L==="email"&&!U&&(delete Pe.phone,m(Pe)),X&&(delete Pe[L],m(Pe)),L==="email"&&!X&&(delete Pe[L],m(Pe))},g=l=>{let{value:X}=l;if(Number(X)>0){let L=$;delete L.amount,m(L)}f(X)},S=()=>{let l={};return xe||(l.amount=Xe.amountrequired),x.email&&!v(x==null?void 0:x.email)&&(l.email=Xe.invalidemail),!U&&!(x!=null&&x.email)&&(l.phone=Xe.phoneoremailrequired),!U&&!(x!=null&&x.email)&&(l.email=Xe.phoneoremailrequired),!U&&x.email&&!v(x==null?void 0:x.email)&&(l.email=Xe.invalidemail),e.from==="merchant"&&!x.order_id&&(l.order_id=Xe.orderidrequired),m(l),Object.keys(l).length===0};Zn(()=>{e&&(o(l=>I(P({},l),{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:""})),f(e.amount?e.amount:""),C(e.phone?`${e.phone}`:null))},[e]);let d=l=>{let X=l==null?void 0:l.value;if(X&&(X==null?void 0:X.length)>0&&(X==null?void 0:X.length)!==10){m(Pe=>I(P({},Pe),{phone:Xe.phonenumberlength})),C(X);return}else C(X);let L=$;delete L.phone,X&&!(x!=null&&x.email)&&delete L.email,m(L)};function K(l){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(l))}return _.createElement(_.Fragment,null,_.createElement(Nn,null),_.createElement(kt,{loading:Ee}),_.createElement(_.Fragment,null,_.createElement("button",{className:"paymentBtn",onClick:p},"Request Payment"),_.createElement($t,{open:Te,onClose:()=>B(!1),maxWidth:"500px"},_.createElement("div",{style:{maxWidth:"500px"}},_.createElement("div",{className:"request-payment-amount-detail frac-form"},_.createElement("p",{className:"request-payment-merchantname"},"Pay ",e==null?void 0:e.webname),_.createElement("p",{className:"request-payment-amount"},K(e==null?void 0:e.amount)),ye&&ye>0&&_.createElement("div",{className:"frac-req-cash-discount"},_.createElement("div",{className:"frac-cashlabel"},"Cash Discount :"),_.createElement("div",null,"$",ye.toFixed(2))),(e==null?void 0:e.from)==="merchant"&&_.createElement("p",{className:"request-payment-orderid"},x==null?void 0:x.order_id),_.createElement("span",{className:"request-payment-close-popup",onClick:w},_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},_.createElement("g",{clipPath:"url(#clip0_12425_52336)"},_.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"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_12425_52336"},_.createElement("rect",{width:"16",height:"16",fill:"white"})))))),_.createElement("form",{className:"request-payment-input-form"},_.createElement("div",{className:"request-payment-list-div"},_.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),_.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:Y,value:x==null?void 0:x.name}),$.name&&_.createElement("small",{className:"request-payment-error-msg"},$.name)),_.createElement("div",{className:"request-payment-list-div"},_.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),_.createElement(yi,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:U,onValueChange:l=>{d(l)}}),$.phone&&_.createElement("small",{className:"request-payment-error-msg"},$.phone)),_.createElement("div",{className:"request-payment-list-div"},_.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),_.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:Y,"data-token":"email",value:x==null?void 0:x.email}),$.email&&_.createElement("small",{className:"request-payment-error-msg"},$.email)),_.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:u,disabled:Ee},Ee?"Loading...":"Send Request"),_.createElement("div",{className:"request-payment-fractal-powerd-by"},_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},_.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 ",_.createElement("span",null,"Fractal"),_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"}),_.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"})))))),_.createElement($t,{open:Ze,onClose:pe,maxWidth:"500px"},_.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},_.createElement("div",{className:"request-payment-success-container"},_.createElement("span",{className:"request-payment-close-popup",onClick:pe},_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},_.createElement("g",{clipPath:"url(#clip0_12425_52336)"},_.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"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_12425_52336"},_.createElement("rect",{width:"16",height:"16",fill:"white"}))))),_.createElement("div",{className:"request-payment-success-tick-div"},_.createElement("div",{className:"request-payment-success-tick"},_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},_.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"})))),_.createElement("h6",{className:"request-payment-success-text"},"The request ",_.createElement("br",null),"was sent"),_.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),_.createElement("div",{className:"request-payment-success-btn-div"},_.createElement("button",{onClick:pe,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import M,{useState as tn,useEffect as bi}from"react";import vi from"axios";import{PatternFormat as Ci}from"react-number-format";function wi(e){let h=e.merchantPublicKey,q=e==null?void 0:e.discount,Z=e==null?void 0:e.tax,H=e==null?void 0:e.surcharge,[Te,B]=tn(!1),[Ee,Ne]=tn(!1),[$,m]=tn({}),[U,C]=tn(null),[x,o]=tn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),[ye,b]=tn(""),[xe,f]=tn(!1),[Ze,W]=tn(null),be=S=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(S),lt=/[+-]?([0-9]*[.])?[0-9]+/,Ue=S=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(S),ht=S=>/^[A-Za-z\s]*$/.test(S),v=()=>{B(!1),m({})},we=()=>B(!0),Q=()=>{console.log(Ze,"apiresponse"),p(Ze),f(!1)};function w(){o({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),b("")}function p(S){let d={type:"preview.compiledcheck",other:I(P({},S),{status:!0})};window.parent.postMessage(d,"*")}let pe=async()=>{if(!(Object.keys($).length>0)){if(m({}),!(x!=null&&x.email)&&U&&!be(U)){m(S=>I(P({},S),{phone:Xe.phonenumbervalid}));return}if(G())try{Ne(!0);let S={fractalpayPublicKey:h,amount:ye,phone_number:U,order_id:x.order_id,action:"request",name:x.name,email:x.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:q,surcharge:H,tax:Z,require_3ds:e==null?void 0:e.require_3ds},d=await vi.post(`${_e}send-request-pre-auth-payment`,S);(d==null?void 0:d.status)===200&&(f(!0),B(!1),w(),W(d==null?void 0:d.data)),Ne(!1)}catch(S){console.log(S),Ne(!1)}}},de=_e+"images/logo-img.png",F=S=>{let{value:d}=S.target,K=S.target.dataset.token;if(o(I(P({},x),{[K]:d})),K==="name"&&!ht(d)){m(X=>I(P({},X),{[K]:Xe.onlylettersallowed}));return}let l=$;K==="email"&&!U&&(delete l.phone,m(l)),d&&(delete l[K],m(l)),K==="email"&&!d&&(delete l[K],m(l))},u=S=>{let{value:d}=S;if(Number(d)>0){let K=$;delete K.amount,m(K)}b(d)},G=()=>{let S={};return ye||(S.amount=Xe.amountrequired),x.email&&!Ue(x==null?void 0:x.email)&&(S.email=Xe.invalidemail),!U&&!(x!=null&&x.email)&&(S.phone=Xe.phoneoremailrequired),!U&&!(x!=null&&x.email)&&(S.email=Xe.phoneoremailrequired),!U&&x.email&&!Ue(x==null?void 0:x.email)&&(S.email=Xe.invalidemail),e.from==="merchant"&&!x.order_id&&(S.order_id=Xe.orderidrequired),m(S),Object.keys(S).length===0};bi(()=>{e&&(o(S=>I(P({},S),{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:""})),b(e.amount?e.amount:""),C(e.phone?`${e.phone}`:null))},[e]);let Y=S=>{let d=S==null?void 0:S.value;if(d&&(d==null?void 0:d.length)>0&&(d==null?void 0:d.length)!==10){m(l=>I(P({},l),{phone:Xe.phonenumberlength})),C(d);return}else C(d);let K=$;delete K.phone,d&&!(x!=null&&x.email)&&delete K.email,m(K)};function g(S){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(S))}return M.createElement(M.Fragment,null,M.createElement(Nn,null),M.createElement(kt,{loading:Ee}),M.createElement(M.Fragment,null,M.createElement("button",{className:"paymentBtn",onClick:we},"Send Request"),M.createElement("div",{className:"frac-form"},M.createElement($t,{open:Te,onClose:()=>B(!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"},g(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&M.createElement("p",{className:"request-payment-orderid"},x==null?void 0:x.order_id),M.createElement("span",{className:"request-payment-close-popup",onClick:v},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:F,value:x==null?void 0:x.name}),$.name&&M.createElement("small",{className:"request-payment-error-msg"},$.name)),M.createElement("div",{className:"request-payment-list-div"},M.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),M.createElement(Ci,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:U,onValueChange:S=>{Y(S)}}),$.phone&&M.createElement("small",{className:"request-payment-error-msg"},$.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:F,"data-token":"email",value:x==null?void 0:x.email}),$.email&&M.createElement("small",{className:"request-payment-error-msg"},$.email)),M.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:pe,disabled:Ee},Ee?"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($t,{open:xe,onClose:Q,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:Q},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:Q,className:"request-payment-success-btn2"},"Close"))))))))}import t,{useEffect as Jn,useState as je}from"react";import Ni from"react";function cn(){let e="#000",h="#fff",q="#212529",Z="#dee2e6";return Ni.createElement("style",null,`
|
|
599
599
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
600
600
|
body
|
|
601
601
|
{
|
|
@@ -824,7 +824,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
824
824
|
font-size: 1rem;
|
|
825
825
|
font-weight: 400;
|
|
826
826
|
line-height: 1.5;
|
|
827
|
-
color: ${
|
|
827
|
+
color: ${q};
|
|
828
828
|
-webkit-appearance: none;
|
|
829
829
|
-moz-appearance: none;
|
|
830
830
|
appearance: none;
|
|
@@ -1262,7 +1262,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
1262
1262
|
justify-content: space-between;
|
|
1263
1263
|
min-height: auto;
|
|
1264
1264
|
}
|
|
1265
|
-
`)}import
|
|
1265
|
+
`)}import rn from"axios";import Se from"react";import ki from"react";function Sn(){return ki.createElement("style",null,`
|
|
1266
1266
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
1267
1267
|
|
|
1268
1268
|
body{
|
|
@@ -1457,7 +1457,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
1457
1457
|
gap: 6px;
|
|
1458
1458
|
background-color: #161616;
|
|
1459
1459
|
color: #fff;
|
|
1460
|
-
}`)}function
|
|
1460
|
+
}`)}function nn(e,h,q){e.preventDefault();let H={type:"preview.compiledcheck",other:{msg:"Payment success!",status:h==="close",data:{tran_id:q,key:h}}};console.log("message:",H),window.parent.postMessage(H,"*")}function pn({onClose:e,tranId:h}){return Se.createElement(Se.Fragment,null,Se.createElement(Sn,null),Se.createElement("div",{className:"payment-msg-container"},Se.createElement("div",{className:"charge-payment-success-container"},Se.createElement("div",{className:"charge-payment-success-tick-div"},Se.createElement("div",{className:"charge-payment-success-tick"},Se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},Se.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"})))),Se.createElement("h6",{className:"charge-payment-success-text"},"Your charge",Se.createElement("br",null),"was successful"),Se.createElement("h6",{className:"charge-payment-success-subtext"},"We\u2019ve processed your charge"),Se.createElement("div",{className:"charge-success-payment-button-div"},Se.createElement("button",{className:"charge-success-btn1",onClick:q=>nn(q,"print",h)},Se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},Se.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"}),Se.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"),Se.createElement("button",{className:"charge-success-btn1",onClick:q=>nn(q,"share",h)},Se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},Se.createElement("g",{clipPath:"url(#clip0_12420_50683)"},Se.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"})),Se.createElement("defs",null,Se.createElement("clipPath",{id:"clip0_12420_50683"},Se.createElement("rect",{width:"16",height:"16",fill:"white",transform:"translate(0.5)"})))),"Send receipt"))),Se.createElement("div",{className:"charge-payment-success-btn-div"},Se.createElement("button",{className:"charge-payment-success-btn1",onClick:q=>nn(q,"tran",h)},"Go to Transactions"),Se.createElement("button",{className:"charge-payment-success-btn2",onClick:q=>{e(),nn(q,"close",h)}},"Close"))))}import gn from"sweetalert2";import{IoArrowBack as _n}from"react-icons/io5";import{useEffect as Wn}from"react";function jt(){return Wn(()=>{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 h=document.createElement("script");h.src=e,h.async=!0,h.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")},h.onerror=q=>{console.error("\u274C Failed to load Datacap script",q)},document.head.appendChild(h)}}},[]),Wn(()=>{let e="forge-cdn-script";if(!document.getElementById(e)){let h=document.createElement("script");h.src="https://cdn.jsdelivr.net/npm/node-forge@1.0.0/dist/forge.min.js",h.id=e,h.async=!0,document.head.appendChild(h)}return()=>{let h=document.getElementById(e);h&&document.head.removeChild(h)}},[]),null}import Bt from"react";import _i from"react";function Pn(){return _i.createElement("style",null,`
|
|
1461
1461
|
.card-error .logo-container {
|
|
1462
1462
|
display: flex;
|
|
1463
1463
|
justify-content: center;
|
|
@@ -1562,7 +1562,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
1562
1562
|
padding:10px 17px;
|
|
1563
1563
|
cursor:pointer;
|
|
1564
1564
|
}
|
|
1565
|
-
`)}var
|
|
1565
|
+
`)}var Fi=({onClose:e,error:h})=>Bt.createElement(Bt.Fragment,null,Bt.createElement(Pn,null),Bt.createElement("div",{className:"card-error"},Bt.createElement("div",{className:"payment-error-container"},Bt.createElement("div",{className:"error-icon"},Bt.createElement("div",{className:"circle"},Bt.createElement("i",{className:"fa fa-times","aria-hidden":"true"})),Bt.createElement("div",{className:"error-text"},Bt.createElement("div",{className:"payment-error-text"},h),Bt.createElement("div",{className:"thank-you-text"},"Try again later ")),Bt.createElement("div",{className:"error-btn-div"},Bt.createElement("button",{onClick:e},"OK")))))),Ut=Fi;import{io as Si}from"socket.io-client";var Pi=Si(_e,{transports:["websocket"],withCredentials:!1}),_t=Pi;var Mn=e=>{try{let h=JSON.parse(e);return typeof h=="object"&&h!==null}catch(h){return!1}},kn=[{value:"personal saving",label:"Personal Saving"},{value:"business saving",label:"Business Saving"},{value:"personal checking",label:"Personal Checking"},{value:"business checking",label:"Business Checking"}];function en(e){let h=Number(e);return isNaN(h)?`$${e}`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(h)}var Mi=te+"widget/mc-img.svg",Li=te+"widget/visa-img.svg",zi=te+"widget/ae-img.svg",Ii=te+"widget/discover-img.svg",un=te+"widget/card.svg",Ai=te+"widget/bank.svg",yo=te+"widget/Trash.svg",xo=te+"widget/secure-img.png",bo=te+"widget/pov-by.png",vo=te+"widget/pax.svg",Un=te+"widget/Bank _New.svg",Gn=e=>{switch(e==null?void 0:e.toLowerCase()){case"visa":return Li;case"mastercard":case"mc":case"m/c":return Mi;case"amex":case"american express":case"ae":return zi;case"discover":case"dcvr":return Ii;case"bank":return Ai;default:return un}};import Gt from"react";var Ln=e=>Gt.createElement(Gt.Fragment,null,Gt.createElement("div",{className:`frac-card-bank-radio ${e.activetab===e.value?"frac-active":""}`,onClick:()=>e.onChange(e.value),role:"radio"},Gt.createElement("div",{className:"frac-card-title-main"},Gt.createElement("img",{src:e.label.toLowerCase()==="card"?un:Un,className:"frac-payment-type-logo",alt:""}),Gt.createElement("div",{className:"frac-card-label"},Gt.createElement("div",{className:"frac-card-label-text"},e.label),Gt.createElement("div",{className:"frac-card-label-amount"},en(e.amount)))),Gt.createElement("div",null,Gt.createElement("input",{name:"paymenttype",checked:e.activetab===e.value,type:"radio",value:e.value,onChange:h=>{e.onChange(h.target.value)}}))));import Bi from"react";function zn({}){return Bi.createElement("style",null,`
|
|
1566
1566
|
.frac-card-bank-radio-main{
|
|
1567
1567
|
display: flex;
|
|
1568
1568
|
flex-direction: column;
|
|
@@ -1632,7 +1632,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
1632
1632
|
.frac-card-bank-radio.frac-active {
|
|
1633
1633
|
background: #F6F6F7;
|
|
1634
1634
|
}
|
|
1635
|
-
`)}import nt from"react";var zn=({listHeading:e="Card",ListItems:h,selectedCard:$,setSelectedCard:Z,paymentGateway:j,handleDeleteCard:qe,otherButtonAction:q,otherButtonLabel:We})=>{let ke=R+"widget/Trash.svg";return console.log($,"selectedCard another"),nt.createElement(nt.Fragment,null,nt.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}},e),nt.createElement("div",{className:"card-lint-div-in"},nt.createElement("div",{className:"card-list-div"},h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.map((Y,c)=>nt.createElement("div",{className:"card-list-single-div"},nt.createElement("div",{className:"card-number-radio"},nt.createElement("input",{disabled:j!=(Y==null?void 0:Y.payment_method_type)&&(Y==null?void 0:Y.card_type)!="Bank",type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:($==null?void 0:$.id)===(Y==null?void 0:Y.id),onChange:G=>Z(Y)}),nt.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",Y==null?void 0:Y.cardlastfourdigit),(Y==null?void 0:Y.card_type)!="Bank"&&nt.createElement("h6",{className:"card-expiry-date"},Y==null?void 0:Y.expmonth,"/",Y==null?void 0:Y.expyear)),nt.createElement("div",{className:"card-number-radio"},nt.createElement("span",{className:"visa-card"},nt.createElement("img",{src:Un(Y==null?void 0:Y.card_type),alt:""})),nt.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>qe(Y==null?void 0:Y.id)},nt.createElement("img",{src:ke,alt:""}))))))),nt.createElement("div",{className:"pay-with-other-card",onClick:q},We,nt.createElement("img",{src:pn,alt:""}))))};function Bi(e){var vt,Ct,wt,De,ue,gt,Nt,Kt,He,Ot,kt,Be,Ee,Gt,r,l,V,te;let[h,$]=Ve(!1),[Z,j]=Ve(!1),[qe,q]=Ve(""),[We,ke]=Ve(!1),[Y,c]=Ve(!1),[G,v]=Ve("card"),[y,o]=Ve("card"),[he,x]=Ve("form"),[ye,f]=Ve("form"),[Ue,W]=Ve(!0),[xe,dt]=Ve(!1),[Je,yt]=Ve(!1),b=e.merchantPublicKey,we=R+"widget/mc-img.svg",Q=R+"widget/visa-img.svg",C=R+"widget/ae-img.svg",p=R+"widget/discover-img.svg",ce=R+"widget/card.svg",le=R+"widget/Trash.svg",_=R+"widget/bank.svg",u=R+"widget/secure-img.png",J=R+"widget/pov-by.png",H=R+"widget/pax.svg",[g,F]=Ve(),[m,K]=Ve({}),[d,X]=Ve(),[L,Me]=Ve({}),[O,mt]=Ve([]),[Ke,Lt]=Ve([]),[$e,xt]=Ve(),[Oe,at]=Ve(),[_e,qt]=Ve(Number(e==null?void 0:e.amount));console.log($e,"selectedCard");let[E,ot]=Ve(),[Le,pe]=Ve(""),rt=()=>$(!0),zt=()=>$(!1),Vt=(s,i)=>{let N=(parseFloat(i)||0)/100,M=s/(1+N);return Math.round(M*100)/100};Gn(()=>{if(Y){debugger;let s=Vt(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);qt(s)}},[Y,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let w=()=>{c(!1),v("card"),q(""),ke(!1),pe(""),X({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),Me({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),F({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),K({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),yt(!1),dt(!1),xt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),at({}),qt(0),o("card"),W(!0),j(!1),$(!1)},z=()=>c(!0),oe=s=>{v(s)},re=(s,i)=>{let N=s;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(N)){(i===""||/^[0-9]+$/.test(i))&&(K(I=>A(S({},I),{[N]:""})),F(I=>A(S({},I),{[N]:i})));return}K(I=>A(S({},I),{[N]:""})),F(I=>A(S({},I),{[N]:i}))},ae=s=>{let N=s.target.value.replace(/\D/g,""),M="";/^3[47]/.test(N)?M=N.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(U,B,D,ne)=>[B,D,ne].filter(Boolean).join(" ")):M=N.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(U,B,D,ne,ee)=>[B,D,ne,ee].filter(Boolean).join(" ")),K(I=>A(S({},I),{cardNumber:""})),F(I=>A(S({},I),{cardNumber:M}))},ze=s=>{let{name:i,value:N}=s.target,M=["routingNumber","accountNumber","confirmAccountNumber"];if(i=="name"){/^[a-zA-Z\s]*$/.test(N)&&(Me(I=>A(S({},I),{[i]:""})),X(I=>A(S({},I),{[i]:N})));return}if(M.includes(i)){(N===""||/^[0-9]+$/.test(N))&&(Me(I=>A(S({},I),{[i]:""})),X(I=>A(S({},I),{[i]:N})));return}Me(I=>A(S({},I),{[i]:""})),X(I=>A(S({},I),{[i]:N}))},Ae=()=>{var I,U,B,D,ne,ee;let s={},i=g,N=parseInt((i==null?void 0:i.expiryMonth)||"",10),M=(i==null?void 0:i.expiryYear)||"";if((I=i==null?void 0:i.cardName)!=null&&I.trim()||(s.cardName="Card name is required"),(U=i==null?void 0:i.cardNumber)!=null&&U.trim()||(s.cardNumber="Card number is required"),(!((B=i==null?void 0:i.expiryMonth)!=null&&B.trim())||!((D=i==null?void 0:i.expiryYear)!=null&&D.trim())||isNaN(N)||N<1||N>12||M.length!==4)&&(s.expiryMonth="Invalid Expiration Date."),(ne=i==null?void 0:i.cvv)!=null&&ne.trim()||(s.cvv="CVV is required"),(ee=i==null?void 0:i.zipCode)!=null&&ee.trim()||(s.zipCode="ZIP code is required"),i!=null&&i.expiryMonth&&(i!=null&&i.expiryYear)&&i.expiryMonth.length<=2&&i.expiryYear.length===4){let se=parseInt(i.expiryMonth,10),Ne=parseInt(i.expiryYear,10),de=new Date,Re=de.getMonth()+1,_t=de.getFullYear();(Ne<_t||Ne===_t&&se<Re)&&(s.expiryMonth="Card is expired")}return K(s),Object.keys(s).length>0},be=()=>{var N,M,I,U,B,D,ne,ee;let s={},i=d;return(N=i==null?void 0:i.name)!=null&&N.trim()||(s.name="Name is required"),(M=i==null?void 0:i.accountNumber)!=null&&M.trim()||(s.accountNumber="Account number is required"),(I=i==null?void 0:i.accountNumber)!=null&&I.trim()&&((U=i==null?void 0:i.accountNumber)==null?void 0:U.trim())!==((B=i==null?void 0:i.confirmAccountNumber)==null?void 0:B.trim())&&(s.confirmAccountNumber="Account numbers must match"),(D=i==null?void 0:i.bankName)!=null&&D.trim()||(s.bankName="Bank name is required"),(ne=i==null?void 0:i.routingNumber)!=null&&ne.trim()||(s.routingNumber="Routing Number is required"),i!=null&&i.routingNumber&&((ee=i==null?void 0:i.routingNumber)==null?void 0:ee.length)!==9&&(s.routingNumber="Routing number must be 9 digits"),((i==null?void 0:i.accountType)==="business saving"||(i==null?void 0:i.accountType)==="business checking")&&(!(i!=null&&i.companyName)||(i==null?void 0:i.companyName)==="")&&(s.companyName="Company Name is required for business accounts"),Me(s),Object.keys(s).length>0},Ie=async s=>{var i,N,M,I,U,B,D,ne,ee,se,Ne,de,Re,_t,Bt,Ce;if(s.preventDefault(),G!=="ach"){if(Ae())return;{let $t=DatacapWebToken.validateCardNumber(g==null?void 0:g.cardNumber.replaceAll(" ","")),je=DatacapWebToken.validateExpirationDate(g==null?void 0:g.expiryMonth,g==null?void 0:g.expiryYear),Et=DatacapWebToken.validateCVV(g==null?void 0:g.cvv),Yt={};if($t||(Yt.cardNumber="Invalid card Number"),je||(Yt.expiryMonth="Invalid Expiration Date."),Et||(Yt.cvv="Invalid CVV"),K(Yt),$t&&Et&&je){j(!0);try{let et=A(S({},g),{amount:`${e.amount||0}`,fractalpayPublicKey:b,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,pass_fee:e==null?void 0:e.pass_fee}),tt=await on.post(`${Fe}create-widget-order`,et),lt=async function(Ge){if(Ge.Error)q(Ge.Error),j(!1);else{let Ze=g==null?void 0:g.cardName,Rt=g==null?void 0:g.zipCode;Ge.name=Ze,Ge.postal_code=Rt,Ge.isCardSave=`${xe}`,Ge.isCharge=!0,Ge.posSalesIdEncode=tt==null?void 0:tt.data.data.posSalesIdEncode,Pt.emit("sendMessage",Ge),Pt.on(tt==null?void 0:tt.data.data.posSalesIdEncode,Xe=>{if(Pn(Xe==null?void 0:Xe.data)){let Ft=JSON.parse(Xe.data);Ft!=null&&Ft.result?(F({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),dt(!1),pe(Ft==null?void 0:Ft.transactionId),ke(!0),j(!1)):(j(!1),q((Ft==null?void 0:Ft.message)||"Something went wrong."))}else q("Something went wrong.")})}};if((E==null?void 0:E.paymentGateway)===32){let Ge={method:"POST",redirect:"follow"};try{let Ze=await on.post(`${ve}api/v1/widget/generate-session`,Ge),Rt=Number(g==null?void 0:g.expiryYear)%100,Xe=g==null?void 0:g.cardNumber;Xe=Xe==null?void 0:Xe.replace(/\s+/g,"");let Ft=`${Xe}=${Rt}${g==null?void 0:g.expiryMonth} ${g==null?void 0:g.cvv}`,me=forge.pki.publicKeyFromPem((N=(i=Ze==null?void 0:Ze.data)==null?void 0:i.data)==null?void 0:N.publicKeyPem).encrypt(Ft,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),xn=forge.util.encode64(me),bn={"Content-Type":"application/json","x-app-session-key":(I=(M=Ze.data)==null?void 0:M.data)==null?void 0:I.session_key},It=JSON.stringify({enc_track2_data:`${xn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(B=(U=Ze==null?void 0:Ze.data)==null?void 0:U.data)==null?void 0:B.session_key}`});try{let Te=await on.post(`${ft}tokenizer/tokenize`,It,{headers:bn}),Rn=JSON.stringify(A(S({},(D=Te==null?void 0:Te.data)==null?void 0:D.data),{isSaveCardChecked:xe,name:g==null?void 0:g.cardName,postal_code:g==null?void 0:g.zipCode,customer_id:e==null?void 0:e.customerId})),ei=JSON.stringify({pre_sales_id:`${(ee=(ne=tt==null?void 0:tt.data)==null?void 0:ne.data)==null?void 0:ee.posSalesIdEncode}`,token:`${(se=Te==null?void 0:Te.data)==null?void 0:se.data.token}`,json_response:`${Rn}`}),ti={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:ei,redirect:"follow",isChargeviafractal:!0};Pt.emit("sendMessage",ti),Pt.on("chargeviafractalgateway",an=>{var $n;if(Pn(an==null?void 0:an.data)){let Jt=JSON.parse(an==null?void 0:an.data);Jt!=null&&Jt.result?(pe(($n=Jt==null?void 0:Jt.data)==null?void 0:$n.transactionId),ke(!0),j(!1)):(j(!1),q((Jt==null?void 0:Jt.message)||"Something went wrong."))}else q("Something went wrong.")})}catch(Te){j(!1),q(((de=(Ne=Te==null?void 0:Te.response)==null?void 0:Ne.data)==null?void 0:de.message)||(Te==null?void 0:Te.message)||"Something went wrong.")}}catch(Ze){j(!1),q(((_t=(Re=Ze==null?void 0:Ze.response)==null?void 0:Re.data)==null?void 0:_t.message)||(Ze==null?void 0:Ze.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(tt==null?void 0:tt.data.data.dctoken,"PaymentForm",lt)}catch(et){j(!1),q(((Ce=(Bt=et==null?void 0:et.response)==null?void 0:Bt.data)==null?void 0:Ce.message)||(et==null?void 0:et.message)||"Something went wrong.")}}}}else{if(be())return;{j(!0);let $t={fractalpayPublicKey:b,label:(d==null?void 0:d.name)||"John Doe",account_number:d==null?void 0:d.accountNumber,routing_number:d==null?void 0:d.routingNumber,bank_name:d==null?void 0:d.bankName,account_type:d==null?void 0:d.accountType,amount:String(_e||0),isSaveAch:Je,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,company_name:(d==null?void 0:d.companyName)||""};Pt.emit("sendMessage",$t),Pt.on("ach-incoming",je=>{var Et;(je==null?void 0:je.status)=="Failed"?typeof(je==null?void 0:je.message)=="object"?Object.values(je==null?void 0:je.message).forEach(Yt=>{q(Yt||"Something went wrong")}):q((je==null?void 0:je.message)||"Something went wrong"):(pe((Et=je==null?void 0:je.data)==null?void 0:Et.transaction_id),ke(!0),j(!1))})}}},Ye=async()=>{var s,i,N,M,I,U,B,D,ne,ee,se,Ne,de,Re,_t,Bt,Ce,Se,$t,je,Et,Yt,et,tt,lt,Ge,Ze,Rt,Xe,Ft;rt();try{let Zt={fractalpayPublicKey:b,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee},me=await on.post(`${Fe}get-payment-details`,Zt);if(ot((s=me==null?void 0:me.data)==null?void 0:s.data),(N=(i=me==null?void 0:me.data)==null?void 0:i.data)!=null&&N.paymentGateway||(w(),q("Something went wrong.")),(I=(M=me==null?void 0:me.data)==null?void 0:M.data)!=null&&I.card_list&&((D=(B=(U=me==null?void 0:me.data)==null?void 0:U.data)==null?void 0:B.card_list)==null?void 0:D.length)>0){let xn=(se=(ee=(ne=me==null?void 0:me.data)==null?void 0:ne.data)==null?void 0:ee.card_list)==null?void 0:se.filter(Te=>(Te==null?void 0:Te.card_type)=="Bank"),bn=(Re=(de=(Ne=me==null?void 0:me.data)==null?void 0:Ne.data)==null?void 0:de.card_list)==null?void 0:Re.filter(Te=>(Te==null?void 0:Te.card_type)!=="Bank");console.log(xn,"hohgohoo",bn),(O==null?void 0:O.length)>0&&x("list"),(Ke==null?void 0:Ke.length)>0&&f("list"),mt(bn),Lt(xn);let It=(Ce=(Bt=(_t=me==null?void 0:me.data)==null?void 0:_t.data)==null?void 0:Bt.card_list)==null?void 0:Ce.filter(Te=>(Te==null?void 0:Te.primary_card)==1);(It!=null&&It[0]&&((Se=It==null?void 0:It[0])==null?void 0:Se.payment_method_type)==((je=($t=me==null?void 0:me.data)==null?void 0:$t.data)==null?void 0:je.paymentGateway)||((Et=It==null?void 0:It[0])==null?void 0:Et.card_type)==="Bank")&&xt(It[0])}else v("card");(et=(Yt=me==null?void 0:me.data)==null?void 0:Yt.data)!=null&&et.paymentDeviceList&&((Ge=(lt=(tt=me==null?void 0:me.data)==null?void 0:tt.data)==null?void 0:lt.paymentDeviceList)==null?void 0:Ge.length)>0&&at((Rt=(Ze=me==null?void 0:me.data)==null?void 0:Ze.data)==null?void 0:Rt.paymentDeviceList[0]),zt()}catch(Zt){console.log(Zt),zt(),q(((Ft=(Xe=Zt==null?void 0:Zt.response)==null?void 0:Xe.data)==null?void 0:Ft.message)||(Zt==null?void 0:Zt.message)||"Something went wrong")}},ct=async()=>{let s=e==null?void 0:e.customerId,i=String(e==null?void 0:e.discount),N=String(e==null?void 0:e.surcharge),M=String(e==null?void 0:e.tax),I=e==null?void 0:e.merchantPublicKey,U=e==null?void 0:e.orderID,B=String(e==null?void 0:e.amount),D=$e==null?void 0:$e.id,ne=$e==null?void 0:$e.card_type;if(I&&U&&B&&_e)if(s)if(D){let se={amount:ne==="Bank"?_e:B,order_id:U,customer_id:s,card_id:D,fractalpayPublicKey:I,isCardSave:xe,discount:i,surcharge:N,tax:M},ee=se,{isCardSave:Ne}=ee,de=Cn(ee,["isCardSave"]),_t=Fe+(ne==="Bank"?"charge-ach":"charge-by-card"),Bt={"Content-Type":"application/json"};j(!0),Pt.emit("sendMessage",{url:_t,body:ne=="Bank"?de:se,isChargebycard:!0}),Pt.on("charge-by-card",Ce=>{var Se;(Ce==null?void 0:Ce.result)==!0||(Ce==null?void 0:Ce.status)==!0?(pe((Se=Ce.data)==null?void 0:Se.transaction_id),ke(!0),j(!1)):q((Ce==null?void 0:Ce.message)||"Something went wrong.")})}else q("Please Select A Card/ACH");else q("Please Select Customer");else q("Something went wrong.")},pt=async()=>{var I,U,B,D,ne,ee;let s=e==null?void 0:e.merchantPublicKey,i=e==null?void 0:e.orderID,N=String(e==null?void 0:e.amount),M=e==null?void 0:e.customerId;if(!(Oe!=null&&Oe.device_id)){q("Please Select A Payment Device");return}if(s&&i&&N){j(!0);let se={amount:N,fractalpayPublicKey:s,customer_order_id:i,device_id:Oe==null?void 0:Oe.device_id,customer_id:M||""};try{let Ne=await on.post(`${Fe}charge-with-reader`,se);((I=Ne==null?void 0:Ne.data)==null?void 0:I.result)==!0?(pe((B=(U=Ne==null?void 0:Ne.data)==null?void 0:U.data)==null?void 0:B.transaction_id),ke(!0),j(!1)):(q(((D=Ne==null?void 0:Ne.data)==null?void 0:D.message)||"Something went wrong."),j(!1))}catch(Ne){q(((ee=(ne=Ne==null?void 0:Ne.response)==null?void 0:ne.data)==null?void 0:ee.message)||"Something went wrong."),j(!1)}}else q("Something went wrong.")},st=()=>{y==="card"?ct():y==="reader"&&pt()};Gn(()=>{Y&&b&&Ye()},[b,Y]);let ut=async s=>{un.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){j(!0);try{let N={card_id:s,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},M=await on.post(`${Fe}delete-customer-card`,N);j(!1),Ye(),un.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(N){j(!1),un.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else i.dismiss===un.DismissReason.cancel&&un.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},bt=s=>{switch(s==null?void 0:s.toLowerCase()){case"visa":return Q;case"mastercard":case"mc":case"m/c":return we;case"amex":case"american express":case"ae":return C;case"discover":case"dcvr":return p;case"bank":return _;default:return s}};return console.log(he,"activeinCard","activeinBank",ye),t.createElement(t.Fragment,null,t.createElement(Ht,null),t.createElement(mn,null),t.createElement(Ln,null),t.createElement(t.Fragment,null,t.createElement("button",{className:"paymentBtn",onClick:z},"Pay"),t.createElement(Tt,{open:Y,onClose:w},qe&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(Wt,{error:qe,onClose:w})),We&&t.createElement(cn,{onClose:w,tranId:Le}),!qe&&!We&&t.createElement(t.Fragment,null,(h||Z)&&t.createElement(St,{loading:h||Z}),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:w},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:E==null?void 0:E.logo,id:"pay-logos"})),t.createElement("div",{className:"pay-container"},t.createElement("div",{className:"pay-header pay-conatiner-one frac-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:E==null?void 0:E.logo,id:"pay-logos"})),(O==null?void 0:O.length)>0&&G!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>v("cardList")}," ",t.createElement(kn,null)," Back")),t.createElement("div",{className:"amt-pay-con"},t.createElement("div",{className:"pay-amount-conatiner"},t.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),t.createElement("div",{className:"frac-card-bank-radio-main"},t.createElement(Mn,{label:"Card",amount:(vt=Number(e==null?void 0:e.amount))==null?void 0:vt.toFixed(2),value:"card",onChange:oe,activetab:G}),(E==null?void 0:E.isSkyFiAccount)&&t.createElement(Mn,{label:"Bank",amount:(Ct=Number(_e))==null?void 0:Ct.toFixed(2),value:"ach",onChange:oe,activetab:G})),_e&&_e>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,"Cash Discount Fee "),t.createElement("p",null,"$",_e.toFixed(2))):null)),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:u,alt:""}),t.createElement("img",{src:J,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!h&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},G!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(O==null?void 0:O.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>v("cardList")}," ",t.createElement(kn,null)," Back"),(E==null?void 0:E.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:s=>{oe("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:s=>{oe("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"},"$",(wt=Number(e==null?void 0:e.amount))==null?void 0:wt.toFixed(2))),G!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Q,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:we,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:C,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:p,width:35,alt:""})))),_e&&_e>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",_e))):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",E==null?void 0:E.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",y==="card"?"Cards/Banks":"Readers"," "),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"},"$",(De=Number(e==null?void 0:e.amount))==null?void 0:De.toFixed(2))),t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Q,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:we,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:C,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:p,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:G==="card"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(O==null?void 0:O.length)>0&&he==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>x("list")}," ",t.createElement(kn,null)),_e&&_e>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",_e))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),G!="ach"&&t.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},t.createElement("img",{src:Q,alt:"",width:33}),t.createElement("img",{src:we,width:33,alt:""}),t.createElement("img",{src:C,alt:"",width:33}),t.createElement("img",{src:p,width:33,alt:""}))),he==="list"?t.createElement(t.Fragment,null,t.createElement(zn,{listHeading:"Cards",paymentGateway:E==null?void 0:E.paymentGateway,ListItems:O,selectedCard:$e,setSelectedCard:xt,handleDeleteCard:ut,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{x("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:st},"$",(ue=Number(e==null?void 0:e.amount))==null?void 0:ue.toFixed(2)))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Ie},t.createElement("div",{className:"ach-scrl",style:{minHeight:E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)>0?"444px":E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)==0?"456px":(O==null?void 0:O.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:(g==null?void 0:g.cardName)||"",onChange:s=>{let i=s.target.value;/^[a-zA-Z\s]*$/.test(i)&&re("cardName",i)}}),(m==null?void 0:m.cardName)&&t.createElement("span",{className:"error-span"},m==null?void 0:m.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:(g==null?void 0:g.cardNumber)||"",onChange:s=>ae(s),"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:(g==null?void 0:g.expiryMonth)||"",onChange:s=>re("expiryMonth",s.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:(g==null?void 0:g.expiryYear)||"",onChange:s=>re("expiryYear",s.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:(g==null?void 0:g.cvv)||"",onChange:s=>re("cvv",s.target.value)})))),(m==null?void 0:m.cardNumber)&&t.createElement("span",{className:"error-span"},m==null?void 0:m.cardNumber),t.createElement("p",{style:{margin:"0"}},m!=null&&m.expiryMonth||m!=null&&m.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},m==null?void 0:m.expiryMonth):"",(m==null?void 0:m.cvv)&&t.createElement("span",{className:"error-span"},m==null?void 0:m.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:(gt=e==null?void 0:e.orderID)!=null?gt:"",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:(Nt=g==null?void 0:g.zipCode)!=null?Nt:"",onChange:s=>re("zipCode",s.target.value)}),(m==null?void 0:m.zipCode)&&t.createElement("span",{className:"error-span"},m==null?void 0:m.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:xe,onChange:s=>dt(s.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"}},(E==null?void 0:E.paymentDeviceList)&&((Kt=E==null?void 0:E.paymentDeviceList)==null?void 0:Kt.length)>0&&t.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>W(!Ue)},Ue?"Pay With Reader":"Pay With Card"),t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(He=Number(e==null?void 0:e.amount))==null?void 0:He.toFixed(2))))),t.createElement("div",{id:"ach",style:{display:G==="ach"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(Ke==null?void 0:Ke.length)>0&&ye==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>f("list")}," ",t.createElement(kn,null)),_e&&_e>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",_e))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),ye==="list"?t.createElement(t.Fragment,null,t.createElement(zn,{listHeading:"Banks",paymentGateway:E==null?void 0:E.paymentGateway,ListItems:Ke,selectedCard:$e,setSelectedCard:xt,handleDeleteCard:ut,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{f("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:st},"$",(Ot=Number(_e))==null?void 0:Ot.toFixed(2)))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Ie},t.createElement("div",{className:"ach-scrl",style:{minHeight:E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)>0?"444px":E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)==0?"436px":(O==null?void 0:O.length)>0?"462px":"520px",maxHeight:E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)>0?"444px":((O==null?void 0:O.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:(kt=d==null?void 0:d.name)!=null?kt:"",onChange:ze}),(L==null?void 0:L.name)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(Be=d==null?void 0:d.routingNumber)!=null?Be:"",onChange:ze}),(L==null?void 0:L.routingNumber)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(Ee=d==null?void 0:d.accountNumber)!=null?Ee:"",onChange:ze}),(L==null?void 0:L.accountNumber)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(Gt=d==null?void 0:d.confirmAccountNumber)!=null?Gt:"",onChange:ze}),(L==null?void 0:L.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(r=d==null?void 0:d.bankName)!=null?r:"",onChange:ze}),(L==null?void 0:L.bankName)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.bankName)),((d==null?void 0:d.accountType)==="business saving"||(d==null?void 0:d.accountType)==="business checking")&&t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"companyName"},"Company name"),t.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(l=d==null?void 0:d.companyName)!=null?l:"",onChange:ze}),(L==null?void 0:L.companyName)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.companyName)),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:(V=d==null?void 0:d.accountType)!=null?V:"",onChange:ze},t.createElement("option",{value:""},"Select account"),Nn.map(s=>t.createElement("option",{key:s.value,value:s.value},s.label)))),(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:Je,onChange:s=>yt(s.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),Je&&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"},"$",(te=Number(_e))==null?void 0:te.toFixed(2)))))))))))))))}import a,{useEffect as Jn,useState as Mt}from"react";import gn from"axios";import In from"sweetalert2";import{IoArrowBack as Xn}from"react-icons/io5";function Ti(e){var _e,qt,E,ot,Le,pe,rt,zt,Vt;let[h,$]=Mt(!1),[Z,j]=Mt(!1),[qe,q]=Mt(""),[We,ke]=Mt(!1),[Y,c]=Mt(!1),[G,v]=Mt("card"),[y,o]=Mt(!1),he=e.merchantPublicKey,x=R+"widget/mc-img.svg",ye=R+"widget/visa-img.svg",f=R+"widget/ae-img.svg",Ue=R+"widget/discover-img.svg",W=R+"widget/card.svg",xe=R+"widget/Trash.svg",dt=R+"widget/bank.svg",Je=R+"widget/secure-img.png",yt=R+"widget/pov-by.png",[b,we]=Mt(),[Q,C]=Mt({}),[p,ce]=Mt([]),[le,_]=Mt(),[u,J]=Mt(void 0),[H,g]=Mt(),[F,m]=Mt(""),K=(w,z)=>{let oe=(parseFloat(z)||0)/100,re=w/(1+oe);return Math.round(re*100)/100};Jn(()=>{if(e!=null&&e.pass_fee){let w=K(e==null?void 0:e.amount,e==null?void 0:e.surcharge);J(w)}},[e==null?void 0:e.pass_fee]);let d=()=>$(!0),X=()=>$(!1),L=()=>{c(!1),v("card"),j(!1),q(""),ke(!1),m(""),we({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),C({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),o(!1),_({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},Me=()=>c(!0),O=(w,z)=>{let oe=w;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(oe)){(z===""||/^[0-9]+$/.test(z))&&(C(ae=>A(S({},ae),{[oe]:""})),we(ae=>A(S({},ae),{[oe]:z})));return}C(ae=>A(S({},ae),{[oe]:""})),we(ae=>A(S({},ae),{[oe]:z}))},mt=w=>{let oe=w.target.value.replace(/\D/g,""),re="";/^3[47]/.test(oe)?re=oe.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(ze,Ae,be,Ie)=>[Ae,be,Ie].filter(Boolean).join(" ")):re=oe.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(ze,Ae,be,Ie,Ye)=>[Ae,be,Ie,Ye].filter(Boolean).join(" ")),C(ae=>A(S({},ae),{cardNumber:""})),we(ae=>A(S({},ae),{cardNumber:re}))},Ke=()=>{var ae,ze,Ae,be,Ie,Ye;let w={},z=b,oe=parseInt((z==null?void 0:z.expiryMonth)||"",10),re=(z==null?void 0:z.expiryYear)||"";if((ae=z==null?void 0:z.cardName)!=null&&ae.trim()||(w.cardName="Card name is required"),(ze=z==null?void 0:z.cardNumber)!=null&&ze.trim()||(w.cardNumber="Card number is required"),(!((Ae=z==null?void 0:z.expiryMonth)!=null&&Ae.trim())||!((be=z==null?void 0:z.expiryYear)!=null&&be.trim())||isNaN(oe)||oe<1||oe>12||re.length!==4)&&(w.expiryMonth="Invalid Expiration Date."),(Ie=z==null?void 0:z.cvv)!=null&&Ie.trim()||(w.cvv="CVV is required"),(Ye=z==null?void 0:z.zipCode)!=null&&Ye.trim()||(w.zipCode="ZIP code is required"),z!=null&&z.expiryMonth&&(z!=null&&z.expiryYear)&&z.expiryMonth.length<=2&&z.expiryYear.length===4){let ct=parseInt(z.expiryMonth,10),pt=parseInt(z.expiryYear,10),st=new Date,ut=st.getMonth()+1,bt=st.getFullYear();(pt<bt||pt===bt&&ct<ut)&&(w.expiryMonth="Card is expired")}return C(w),Object.keys(w).length>0},Lt=async w=>{var z,oe,re,ae,ze,Ae,be,Ie,Ye,ct,pt,st,ut,bt,vt,Ct,wt,De,ue;if(w.preventDefault(),G=="card"){if(Ke())return;{let Nt=DatacapWebToken.validateCardNumber(b==null?void 0:b.cardNumber.replaceAll(" ","")),Kt=DatacapWebToken.validateExpirationDate(b==null?void 0:b.expiryMonth,b==null?void 0:b.expiryYear),He=DatacapWebToken.validateCVV(b==null?void 0:b.cvv),Ot={};if(Nt||(Ot.cardNumber="Invalid card Number"),Kt||(Ot.expiryMonth="Invalid Expiration Date."),He||(Ot.cvv="Invalid CVV"),C(Ot),Nt&&He&&Kt){j(!0);try{let kt=async function(Be){if(Be.Error)q(Be.Error),j(!1);else{let Ee=b==null?void 0:b.cardName,Gt=b==null?void 0:b.zipCode;Be.name=Ee,Be.postal_code=Gt,Be.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,Be.amount=e==null?void 0:e.amount,Be.order_id=e==null?void 0:e.orderID,Be.preAuth_id="",Be.isCardSave=y,Be.customer_id=e==null?void 0:e.customerId,Be.link_token="",Be.gateway_id=H==null?void 0:H.paymentGateway,Be.discount=e==null?void 0:e.discount,Be.tax=e==null?void 0:e.tax,Be.surcharge=e==null?void 0:e.surcharge,Be.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let l={method:"POST",body:JSON.stringify(Be),redirect:"follow"};Pt.emit("sendMessage",A(S({},l),{isChargePreauth:!0})),Pt.on("charge-preauth",V=>{var te;console.log(V,"datdata"),(V==null?void 0:V.status)=="Failed"?(j(!1),q((V==null?void 0:V.message)||"Something went wrong. Please try again later.")):(ke(!0),m((te=V==null?void 0:V.data)==null?void 0:te.transaction_id),j(!1),we({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((H==null?void 0:H.paymentGateway)===32){let Be={method:"POST",redirect:"follow"};try{let Ee=await gn.post(`${ve}api/v1/widget/generate-session`,Be),Gt=Number(b==null?void 0:b.expiryYear)%100,r=b==null?void 0:b.cardNumber;r=r==null?void 0:r.replace(/\s+/g,"");let l=`${r}=${Gt}${b==null?void 0:b.expiryMonth} ${b==null?void 0:b.cvv}`,te=forge.pki.publicKeyFromPem((oe=(z=Ee==null?void 0:Ee.data)==null?void 0:z.data)==null?void 0:oe.publicKeyPem).encrypt(l,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),s=forge.util.encode64(te),i={"Content-Type":"application/json","x-app-session-key":(ae=(re=Ee.data)==null?void 0:re.data)==null?void 0:ae.session_key},N=JSON.stringify({enc_track2_data:`${s}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Ae=(ze=Ee==null?void 0:Ee.data)==null?void 0:ze.data)==null?void 0:Ae.session_key}`});try{let M=await gn.post(`${ft}tokenizer/tokenize`,N,{headers:i}),I=JSON.stringify(A(S({},(be=M==null?void 0:M.data)==null?void 0:be.data),{name:b==null?void 0:b.cardName,postal_code:b==null?void 0:b.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(Ye=(Ie=M==null?void 0:M.data)==null?void 0:Ie.data)==null?void 0:Ye.token}`,fractalpayPublicKey:he,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:y,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:b==null?void 0:b.expiryYear,ExpirationMonth:b==null?void 0:b.expiryMonth,CVV:b==null?void 0:b.cvv,Last4:(pt=(ct=M==null?void 0:M.data)==null?void 0:ct.data)==null?void 0:pt.last4,Brand:(ut=(st=M==null?void 0:M.data)==null?void 0:st.data)==null?void 0:ut.brand,gateway_id:H==null?void 0:H.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),B={method:"POST",headers:{"Content-Type":"application/json"},body:I,redirect:"follow"};Pt.emit("sendMessage",A(S({},B),{isFractalPreauth:!0})),Pt.on("fractal-charge-preauth",D=>{var ne;(D==null?void 0:D.status)=="Failed"?(j(!1),q((D==null?void 0:D.message)||"Something went wrong , Try again later")):(m((ne=D==null?void 0:D.data)==null?void 0:ne.transaction_id),ke(!0),j(!1))})}catch(M){console.log(M),j(!1),q(((vt=(bt=M==null?void 0:M.response)==null?void 0:bt.data)==null?void 0:vt.message)||(M==null?void 0:M.message)||"Something went wrong , Try again later")}}catch(Ee){j(!1),q(((wt=(Ct=Ee==null?void 0:Ee.response)==null?void 0:Ct.data)==null?void 0:wt.message)||(Ee==null?void 0:Ee.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(H==null?void 0:H.dctoken,"PaymentForm",kt)}catch(kt){j(!1),q(((ue=(De=kt==null?void 0:kt.response)==null?void 0:De.data)==null?void 0:ue.message)||(kt==null?void 0:kt.message)||"Something went wrong.")}}}}},$e=async()=>{var w,z,oe,re,ae,ze,Ae,be,Ie,Ye,ct,pt,st,ut,bt,vt,Ct,wt;d();try{let De={fractalpayPublicKey:he,customer_id:e==null?void 0:e.customerId,preauth:!0},ue=await gn.post(`${Fe}get-payment-details`,De);if(g((w=ue==null?void 0:ue.data)==null?void 0:w.data),(oe=(z=ue==null?void 0:ue.data)==null?void 0:z.data)!=null&&oe.paymentGateway||(L(),q("Something went wrong.")),(ae=(re=ue==null?void 0:ue.data)==null?void 0:re.data)!=null&&ae.card_list&&((be=(Ae=(ze=ue==null?void 0:ue.data)==null?void 0:ze.data)==null?void 0:Ae.card_list)==null?void 0:be.length)>0){ce((Ye=(Ie=ue==null?void 0:ue.data)==null?void 0:Ie.data)==null?void 0:Ye.card_list),v("cardList");let gt=(st=(pt=(ct=ue==null?void 0:ue.data)==null?void 0:ct.data)==null?void 0:pt.card_list)==null?void 0:st.filter(Nt=>(Nt==null?void 0:Nt.primary_card)==1);gt!=null&>[0]&&((ut=gt==null?void 0:gt[0])==null?void 0:ut.payment_method_type)==((vt=(bt=ue==null?void 0:ue.data)==null?void 0:bt.data)==null?void 0:vt.paymentGateway)&&_(gt[0])}else v("card");X()}catch(De){console.log(De),X(),q(((wt=(Ct=De==null?void 0:De.response)==null?void 0:Ct.data)==null?void 0:wt.message)||(De==null?void 0:De.message)||"Something went wrong")}},xt=async()=>{var ct,pt,st,ut,bt,vt,Ct;let w=e==null?void 0:e.customerId,z=e==null?void 0:e.discount,oe=e==null?void 0:e.surcharge,re=e==null?void 0:e.tax,ae=e==null?void 0:e.merchantPublicKey,ze=e==null?void 0:e.orderID,Ae=e==null?void 0:e.amount,be=le==null?void 0:le.id,Ie=le==null?void 0:le.card_type;if(ae&&ze&&Ae)if(w)if(be){let wt={amount:Ae,order_id:ze,customer_id:w,card_id:be,fractalpayPublicKey:ae,isCardSave:Ie!="Bank",discount:z,surcharge:oe,tax:re},Ye=wt,{isCardSave:De}=Ye,ue=Cn(Ye,["isCardSave"]),Nt=Fe+"authorize-by-card",Kt={"Content-Type":"application/json"};j(!0);try{let He=await gn.post(Nt,Ie=="Bank"?ue:wt,{headers:Kt});(ct=He==null?void 0:He.data)!=null&&ct.result&&(m((st=(pt=He==null?void 0:He.data)==null?void 0:pt.data)==null?void 0:st.transaction_id),ke(!0),j(!1))}catch(He){j(!1),console.log(He),q(((bt=(ut=He==null?void 0:He.response)==null?void 0:ut.data)==null?void 0:bt.message)||((Ct=(vt=He==null?void 0:He.response)==null?void 0:vt.data)==null?void 0:Ct.status)||"Something went erong")}}else q("Please Select A Card/ACH");else q("Please Select Customer");else q("Something went wrong.")};Jn(()=>{Y&&he&&$e()},[he,Y]);let Oe=async w=>{In.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 z=>{if(z.isConfirmed){j(!0);try{let oe={card_id:w,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},re=await gn.post(`${Fe}delete-customer-card`,oe);j(!1),$e(),In.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(oe){j(!1),In.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},at=w=>{switch(w==null?void 0:w.toLowerCase()){case"visa":return ye;case"mastercard":case"mc":case"m/c":return x;case"amex":case"american express":case"ae":return f;case"discover":case"dcvr":return Ue;case"bank":return dt;default:return w}};return a.createElement(a.Fragment,null,a.createElement(Ht,null),a.createElement(mn,null),a.createElement(a.Fragment,null,a.createElement("button",{className:"paymentBtn",onClick:Me},"PreAuth Payment"),a.createElement(Tt,{open:Y,onClose:L},qe&&a.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},a.createElement(Wt,{error:qe,onClose:L})),We&&a.createElement(cn,{onClose:L,tranId:F}),!qe&&!We&&a.createElement(a.Fragment,null,(h||Z)&&a.createElement(St,{loading:h||Z}),a.createElement("div",null,a.createElement("div",{className:"frac-card-payment-page frac-form"},a.createElement("div",{className:"parent-pay-container"},a.createElement("span",{className:"request-payment-close-popup",onClick:L},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12425_52336)"},a.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"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12425_52336"},a.createElement("rect",{width:"16",height:"16",fill:"white"}))))),a.createElement("div",{className:"pay-container"},a.createElement("div",{className:"pay-header pay-conatiner-one"},a.createElement("div",{className:"pay-conatiner-one-first"},a.createElement("div",{className:"pay-logo-container"},a.createElement("div",{className:"pay-main-logo"},a.createElement("img",{src:H==null?void 0:H.logo,id:"pay-logos"})),a.createElement("h1",{className:"pay-heading"},"Pay"),(p==null?void 0:p.length)>0&&G!=="cardList"&&a.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>v("cardList")}," ",a.createElement(Xn,null)," Back")),a.createElement("div",{className:"amt-pay-con"},a.createElement("div",{className:"pay-amount-conatiner"},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},"$",(_e=Number(e==null?void 0:e.amount))==null?void 0:_e.toFixed(2)),u&&u>0&&a.createElement("div",{style:{width:"80%"},className:"frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,"$",u.toFixed(2)))),G!="ach"&&a.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},a.createElement("img",{src:ye,alt:"",width:33}),a.createElement("img",{src:x,width:33,alt:""}),a.createElement("img",{src:f,alt:"",width:33}),a.createElement("img",{src:Ue,width:33,alt:""})))),a.createElement("div",{className:"pay-conatiner-one-last"},a.createElement("img",{src:Je,alt:""}),a.createElement("img",{src:yt,alt:""}),"Secure payments powered by Fractal"),a.createElement("div",null)),!h&&a.createElement("div",{className:"pay-tab pay-conatiner-two"},a.createElement("div",{className:"col-md-12"},a.createElement("div",{id:"payment-form-div"},G!=="cardList"?a.createElement("div",null,(p==null?void 0:p.length)>0&&a.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>v("cardList")}," ",a.createElement(Xn,null)," Back"),a.createElement("div",{className:""},a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},"$",(qt=Number(e==null?void 0:e.amount))==null?void 0:qt.toFixed(2))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:ye,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:x,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:f,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:Ue,width:35,alt:""})))),u&&u>0&&a.createElement("div",{className:"res-pay-con frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,"$",u)))):a.createElement("div",null,a.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",H==null?void 0:H.customer_name),a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},"$",(E=Number(e==null?void 0:e.amount))==null?void 0:E.toFixed(2))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:ye,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:x,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:f,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:Ue,width:35,alt:""})))),a.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),a.createElement("div",{style:{display:G==="cardList"?"block":"none"},className:"tabcontent"},a.createElement("div",{className:"card-lint-div-in"},a.createElement("div",{className:"card-list-div"},(H==null?void 0:H.card_list)&&((ot=H==null?void 0:H.card_list)==null?void 0:ot.length)>0&&((Le=H==null?void 0:H.card_list)==null?void 0:Le.map((w,z)=>a.createElement("div",{className:"card-list-single-div",key:z},a.createElement("div",{className:"card-number-radio"},a.createElement("input",{disabled:(H==null?void 0:H.paymentGateway)!=(w==null?void 0:w.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:le===w,onChange:oe=>_(w)}),a.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",w==null?void 0:w.cardlastfourdigit),a.createElement("h6",{className:"card-expiry-date"},w==null?void 0:w.expmonth,"/",w==null?void 0:w.expyear)),a.createElement("div",{className:"card-number-radio"},a.createElement("span",{className:"visa-card"},a.createElement("img",{src:at(w==null?void 0:w.card_type),alt:""})),a.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Oe(w==null?void 0:w.id)},a.createElement("img",{src:xe,alt:""}))))))),a.createElement("div",{className:"pay-with-other-card ",onClick:()=>v("card")},"Authorize With Other Card",a.createElement("img",{src:W,alt:""}))),a.createElement("div",{className:"form-group"},a.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:xt},"$",(pe=Number(e==null?void 0:e.amount))==null?void 0:pe.toFixed(2)))),a.createElement("div",{id:"card",style:{display:G==="card"?"block":"none"},className:"tabcontent"},a.createElement("form",{id:"PaymentForm",onSubmit:Lt},a.createElement("div",{className:"ach-scrl",style:{minHeight:(p==null?void 0:p.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),a.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(b==null?void 0:b.cardName)||"",onChange:w=>{let z=w.target.value;/^[a-zA-Z\s]*$/.test(z)&&O("cardName",z)}}),(Q==null?void 0:Q.cardName)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.cardName)),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"cardNumber"},"Card Number"),a.createElement("div",{className:"toggle-num-wrapper"},a.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(b==null?void 0:b.cardNumber)||"",onChange:w=>mt(w),"data-token":"card_number"}),a.createElement("div",{className:"card-crdi card-expiry-new"},a.createElement("div",{className:"exp-date-year-container"},a.createElement("div",{className:"exp-date form-group"},a.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(b==null?void 0:b.expiryMonth)||"",onChange:w=>O("expiryMonth",w.target.value)})),a.createElement("div",{className:"exp-year form-group"},a.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(b==null?void 0:b.expiryYear)||"",onChange:w=>O("expiryYear",w.target.value)})),a.createElement("div",{className:"security-digit form-group"},a.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(b==null?void 0:b.cvv)||"",onChange:w=>O("cvv",w.target.value)})))),(Q==null?void 0:Q.cardNumber)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.cardNumber),a.createElement("p",{style:{margin:"0"}},Q!=null&&Q.expiryMonth||Q!=null&&Q.expiryYear?a.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},Q==null?void 0:Q.expiryMonth):"",(Q==null?void 0:Q.cvv)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.cvv)))),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(rt=b==null?void 0:b.orderId)!=null?rt:"OID123456",onChange:w=>O("orderId",w.target.value),style:{background:"#F6F6F7",color:"#727272"}})),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"zip"},"ZIP"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(zt=b==null?void 0:b.zipCode)!=null?zt:"",onChange:w=>O("zipCode",w.target.value)}),(Q==null?void 0:Q.zipCode)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.zipCode)),(e==null?void 0:e.customerId)&&a.createElement("div",{className:"form-group"},a.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},a.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:y,onChange:w=>o(w.target.checked)}),a.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),a.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12420_50192)"},a.createElement("rect",{width:"20",height:"20",fill:"white"}),a.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),a.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"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12420_50192"},a.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),a.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},a.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(Vt=Number(e==null?void 0:e.amount))==null?void 0:Vt.toFixed(2))))))))))))))))}import ie,{useEffect as Hi,useRef as fn,useState as nn}from"react";import ji from"sweetalert2";import rn from"axios";import qi from"react";function An(){let e="#000",h="#fff",$="#212529",Z="#dee2e6";return qi.createElement("style",null,`
|
|
1635
|
+
`)}import Re from"react";var In=({listHeading:e="Card",ListItems:h,selectedCard:q,setSelectedCard:Z,paymentGateway:H,handleDeleteCard:Te,otherButtonAction:B,otherButtonLabel:Ee})=>{let Ne=te+"widget/Trash.svg";return console.log(q,"selectedCard another"),Re.createElement(Re.Fragment,null,Re.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}},e),Re.createElement("div",{className:"card-lint-div-in"},Re.createElement("div",{className:"card-list-div"},h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.map(($,m)=>Re.createElement("div",{className:"card-list-single-div"},Re.createElement("div",{className:"card-number-radio"},Re.createElement("input",{disabled:H!=($==null?void 0:$.payment_method_type)&&($==null?void 0:$.card_type)!="Bank",type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:(q==null?void 0:q.id)===($==null?void 0:$.id),onChange:U=>Z($)}),Re.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",$==null?void 0:$.cardlastfourdigit),($==null?void 0:$.card_type)!="Bank"&&Re.createElement("h6",{className:"card-expiry-date"},$==null?void 0:$.expmonth,"/",$==null?void 0:$.expyear)),Re.createElement("div",{className:"card-number-radio"},Re.createElement("span",{className:"visa-card"},Re.createElement("img",{src:Gn($==null?void 0:$.card_type),alt:""})),Re.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Te($==null?void 0:$.id)},Re.createElement("img",{src:Ne,alt:""}))))))),Re.createElement("div",{className:"pay-with-other-card",onClick:B},Ee,Re.createElement("img",{src:un,alt:""}))))};function Ti(e){var bt,vt,Qe,ge,ut,Ct,Ot,Ye,Et,wt,Ae,Oe,Jt,r,s,j,ie,V;let[h,q]=je(!1),[Z,H]=je(!1),[Te,B]=je(""),[Ee,Ne]=je(!1),[$,m]=je(!1),[U,C]=je("card"),[x,o]=je("card"),[ye,b]=je("form"),[xe,f]=je("form"),[Ze,W]=je(!0),[be,lt]=je(!1),[Ue,ht]=je(!1),v=e.merchantPublicKey,we=te+"widget/mc-img.svg",Q=te+"widget/visa-img.svg",w=te+"widget/ae-img.svg",p=te+"widget/discover-img.svg",pe=te+"widget/card.svg",de=te+"widget/Trash.svg",F=te+"widget/bank.svg",u=te+"widget/secure-img.png",G=te+"widget/pov-by.png",Y=te+"widget/pax.svg",[g,S]=je(),[d,K]=je({}),[l,X]=je(),[L,Pe]=je({}),[O,dt]=je([]),[Ve,St]=je([]),[qe,yt]=je(),[Ke,tt]=je(),[ke,Yt]=je(Number(e==null?void 0:e.amount));console.log(qe,"selectedCard");let[E,nt]=je(),[Me,ue]=je(""),it=()=>q(!0),Pt=()=>q(!1),Kt=(c,i)=>{let y=(parseFloat(i)||0)/100,J=c/(1+y);return Math.round(J*100)/100};Jn(()=>{if($){let c=Kt(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);Yt(c)}},[$,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let N=()=>{m(!1),C("card"),B(""),Ne(!1),ue(""),X({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),Pe({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),S({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),K({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),ht(!1),lt(!1),yt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),tt({}),Yt(0),o("card"),W(!0),H(!1),q(!1)},z=()=>m(!0),se=c=>{C(c)},le=(c,i)=>{let y=c;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(y)){(i===""||/^[0-9]+$/.test(i))&&(K(k=>I(P({},k),{[y]:""})),S(k=>I(P({},k),{[y]:i})));return}K(k=>I(P({},k),{[y]:""})),S(k=>I(P({},k),{[y]:i}))},re=c=>{let y=c.target.value.replace(/\D/g,""),J="";/^3[47]/.test(y)?J=y.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(T,D,ae,ee)=>[D,ae,ee].filter(Boolean).join(" ")):J=y.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(T,D,ae,ee,ne)=>[D,ae,ee,ne].filter(Boolean).join(" ")),K(k=>I(P({},k),{cardNumber:""})),S(k=>I(P({},k),{cardNumber:J}))},Le=c=>{let{name:i,value:y}=c.target,J=["routingNumber","accountNumber","confirmAccountNumber"];if(i=="name"){/^[a-zA-Z\s]*$/.test(y)&&(Pe(k=>I(P({},k),{[i]:""})),X(k=>I(P({},k),{[i]:y})));return}if(J.includes(i)){(y===""||/^[0-9]+$/.test(y))&&(Pe(k=>I(P({},k),{[i]:""})),X(k=>I(P({},k),{[i]:y})));return}Pe(k=>I(P({},k),{[i]:""})),X(k=>I(P({},k),{[i]:y}))},Ie=()=>{var k,T,D,ae,ee,ne;let c={},i=g,y=parseInt((i==null?void 0:i.expiryMonth)||"",10),J=(i==null?void 0:i.expiryYear)||"";if((k=i==null?void 0:i.cardName)!=null&&k.trim()||(c.cardName="Card name is required"),(T=i==null?void 0:i.cardNumber)!=null&&T.trim()||(c.cardNumber="Card number is required"),(!((D=i==null?void 0:i.expiryMonth)!=null&&D.trim())||!((ae=i==null?void 0:i.expiryYear)!=null&&ae.trim())||isNaN(y)||y<1||y>12||J.length!==4)&&(c.expiryMonth="Invalid Expiration Date."),(ee=i==null?void 0:i.cvv)!=null&&ee.trim()||(c.cvv="CVV is required"),(ne=i==null?void 0:i.zipCode)!=null&&ne.trim()||(c.zipCode="ZIP code is required"),i!=null&&i.expiryMonth&&(i!=null&&i.expiryYear)&&i.expiryMonth.length<=2&&i.expiryYear.length===4){let De=parseInt(i.expiryMonth,10),R=parseInt(i.expiryYear,10),Ge=new Date,Tt=Ge.getMonth()+1,ot=Ge.getFullYear();(R<ot||R===ot&&De<Tt)&&(c.expiryMonth="Card is expired")}return K(c),Object.keys(c).length>0},ve=()=>{var y,J,k,T,D,ae,ee,ne;let c={},i=l;return(y=i==null?void 0:i.name)!=null&&y.trim()||(c.name="Name is required"),(J=i==null?void 0:i.accountNumber)!=null&&J.trim()||(c.accountNumber="Account number is required"),(k=i==null?void 0:i.accountNumber)!=null&&k.trim()&&((T=i==null?void 0:i.accountNumber)==null?void 0:T.trim())!==((D=i==null?void 0:i.confirmAccountNumber)==null?void 0:D.trim())&&(c.confirmAccountNumber="Account numbers must match"),(ae=i==null?void 0:i.bankName)!=null&&ae.trim()||(c.bankName="Bank name is required"),(ee=i==null?void 0:i.routingNumber)!=null&&ee.trim()||(c.routingNumber="Routing Number is required"),i!=null&&i.routingNumber&&((ne=i==null?void 0:i.routingNumber)==null?void 0:ne.length)!==9&&(c.routingNumber="Routing number must be 9 digits"),((i==null?void 0:i.accountType)==="business saving"||(i==null?void 0:i.accountType)==="business checking")&&(!(i!=null&&i.companyName)||(i==null?void 0:i.companyName)==="")&&(c.companyName="Company Name is required for business accounts"),Pe(c),Object.keys(c).length>0},ze=async c=>{var i,y,J,k,T,D,ae,ee,ne,De,R,Ge,Tt,ot,Je,me;if(c.preventDefault(),U!=="ach"){if(Ie())return;{let Xt=DatacapWebToken.validateCardNumber(g==null?void 0:g.cardNumber.replaceAll(" ","")),He=DatacapWebToken.validateExpirationDate(g==null?void 0:g.expiryMonth,g==null?void 0:g.expiryYear),Zt=DatacapWebToken.validateCVV(g==null?void 0:g.cvv),rt={};if(Xt||(rt.cardNumber="Invalid card Number"),He||(rt.expiryMonth="Invalid Expiration Date."),Zt||(rt.cvv="Invalid CVV"),K(rt),Xt&&Zt&&He){H(!0);try{let Lt=I(P({},g),{amount:`${e.amount||0}`,fractalpayPublicKey:v,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,pass_fee:e==null?void 0:e.pass_fee}),Fe=await rn.post(`${_e}create-widget-order`,Lt),qt=async function(st){if(st.Error)B(st.Error),H(!1);else{let We=g==null?void 0:g.cardName,zt=g==null?void 0:g.zipCode;st.name=We,st.postal_code=zt,st.isCardSave=`${be}`,st.isCharge=!0,st.posSalesIdEncode=Fe==null?void 0:Fe.data.data.posSalesIdEncode,_t.emit("sendMessage",st),_t.on(Fe==null?void 0:Fe.data.data.posSalesIdEncode,It=>{if(Mn(It==null?void 0:It.data)){let Nt=JSON.parse(It.data);Nt!=null&&Nt.result?(S({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),lt(!1),ue(Nt==null?void 0:Nt.transactionId),Ne(!0),H(!1)):(H(!1),B((Nt==null?void 0:Nt.message)||"Something went wrong."))}else B("Something went wrong.")})}};if((E==null?void 0:E.paymentGateway)===32){let st={method:"POST",redirect:"follow"};try{let We=await rn.post(`${Ce}api/v1/widget/generate-session`,st),zt=Number(g==null?void 0:g.expiryYear)%100,It=g==null?void 0:g.cardNumber;It=It==null?void 0:It.replace(/\s+/g,"");let Nt=`${It}=${zt}${g==null?void 0:g.expiryMonth} ${g==null?void 0:g.cvv}`,ce=forge.pki.publicKeyFromPem((y=(i=We==null?void 0:We.data)==null?void 0:i.data)==null?void 0:y.publicKeyPem).encrypt(Nt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),bn=forge.util.encode64(ce),vn={"Content-Type":"application/json","x-app-session-key":(k=(J=We.data)==null?void 0:J.data)==null?void 0:k.session_key},At=JSON.stringify({enc_track2_data:`${bn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(D=(T=We==null?void 0:We.data)==null?void 0:T.data)==null?void 0:D.session_key}`});try{let Be=await rn.post(`${gt}tokenizer/tokenize`,At,{headers:vn}),ei=JSON.stringify(I(P({},(ae=Be==null?void 0:Be.data)==null?void 0:ae.data),{isSaveCardChecked:be,name:g==null?void 0:g.cardName,postal_code:g==null?void 0:g.zipCode,customer_id:e==null?void 0:e.customerId})),ti=JSON.stringify({pre_sales_id:`${(ne=(ee=Fe==null?void 0:Fe.data)==null?void 0:ee.data)==null?void 0:ne.posSalesIdEncode}`,token:`${(De=Be==null?void 0:Be.data)==null?void 0:De.data.token}`,json_response:`${ei}`}),ni={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:ti,redirect:"follow",isChargeviafractal:!0};_t.emit("sendMessage",ni),_t.on("chargeviafractalgateway",on=>{var Yn;if(Mn(on==null?void 0:on.data)){let Qt=JSON.parse(on==null?void 0:on.data);Qt!=null&&Qt.result?(ue((Yn=Qt==null?void 0:Qt.data)==null?void 0:Yn.transactionId),Ne(!0),H(!1)):(H(!1),B((Qt==null?void 0:Qt.message)||"Something went wrong."))}else B("Something went wrong.")})}catch(Be){H(!1),B(((Ge=(R=Be==null?void 0:Be.response)==null?void 0:R.data)==null?void 0:Ge.message)||(Be==null?void 0:Be.message)||"Something went wrong.")}}catch(We){H(!1),B(((ot=(Tt=We==null?void 0:We.response)==null?void 0:Tt.data)==null?void 0:ot.message)||(We==null?void 0:We.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(Fe==null?void 0:Fe.data.data.dctoken,"PaymentForm",qt)}catch(Lt){H(!1),B(((me=(Je=Lt==null?void 0:Lt.response)==null?void 0:Je.data)==null?void 0:me.message)||(Lt==null?void 0:Lt.message)||"Something went wrong.")}}}}else{if(ve())return;{H(!0);let Xt={fractalpayPublicKey:v,label:(l==null?void 0:l.name)||"John Doe",account_number:l==null?void 0:l.accountNumber,routing_number:l==null?void 0:l.routingNumber,bank_name:l==null?void 0:l.bankName,account_type:l==null?void 0:l.accountType,amount:String(ke||0),isSaveAch:Ue,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,company_name:(l==null?void 0:l.companyName)||""};_t.emit("sendMessage",Xt),_t.on("ach-incoming",He=>{var Zt;(He==null?void 0:He.status)=="Failed"?typeof(He==null?void 0:He.message)=="object"?Object.values(He==null?void 0:He.message).forEach(rt=>{B(rt||"Something went wrong")}):B((He==null?void 0:He.message)||"Something went wrong"):(ue((Zt=He==null?void 0:He.data)==null?void 0:Zt.transaction_id),Ne(!0),H(!1))})}}},$e=async()=>{var c,i,y,J,k,T,D,ae,ee,ne,De,R,Ge,Tt,ot,Je,me,Ht,Xt,He,Zt,rt,Lt,Fe,qt,st,We,zt,It,Nt;it();try{let Wt={fractalpayPublicKey:v,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee},ce=await rn.post(`${_e}get-payment-details`,Wt);if(nt((c=ce==null?void 0:ce.data)==null?void 0:c.data),(y=(i=ce==null?void 0:ce.data)==null?void 0:i.data)!=null&&y.paymentGateway||(N(),B("Something went wrong.")),(k=(J=ce==null?void 0:ce.data)==null?void 0:J.data)!=null&&k.card_list&&((ae=(D=(T=ce==null?void 0:ce.data)==null?void 0:T.data)==null?void 0:D.card_list)==null?void 0:ae.length)>0){let bn=(De=(ne=(ee=ce==null?void 0:ce.data)==null?void 0:ee.data)==null?void 0:ne.card_list)==null?void 0:De.filter(Be=>(Be==null?void 0:Be.card_type)=="Bank"),vn=(Tt=(Ge=(R=ce==null?void 0:ce.data)==null?void 0:R.data)==null?void 0:Ge.card_list)==null?void 0:Tt.filter(Be=>(Be==null?void 0:Be.card_type)!=="Bank");console.log(bn,"hohgohoo",vn),(O==null?void 0:O.length)>0&&b("list"),(Ve==null?void 0:Ve.length)>0&&f("list"),dt(vn),St(bn);let At=(me=(Je=(ot=ce==null?void 0:ce.data)==null?void 0:ot.data)==null?void 0:Je.card_list)==null?void 0:me.filter(Be=>(Be==null?void 0:Be.primary_card)==1);(At!=null&&At[0]&&((Ht=At==null?void 0:At[0])==null?void 0:Ht.payment_method_type)==((He=(Xt=ce==null?void 0:ce.data)==null?void 0:Xt.data)==null?void 0:He.paymentGateway)||((Zt=At==null?void 0:At[0])==null?void 0:Zt.card_type)==="Bank")&&yt(At[0])}else C("card");(Lt=(rt=ce==null?void 0:ce.data)==null?void 0:rt.data)!=null&&Lt.paymentDeviceList&&((st=(qt=(Fe=ce==null?void 0:ce.data)==null?void 0:Fe.data)==null?void 0:qt.paymentDeviceList)==null?void 0:st.length)>0&&tt((zt=(We=ce==null?void 0:ce.data)==null?void 0:We.data)==null?void 0:zt.paymentDeviceList[0]),Pt()}catch(Wt){console.log(Wt),Pt(),B(((Nt=(It=Wt==null?void 0:Wt.response)==null?void 0:It.data)==null?void 0:Nt.message)||(Wt==null?void 0:Wt.message)||"Something went wrong")}},mt=async()=>{let c=e==null?void 0:e.customerId,i=String(e==null?void 0:e.discount),y=String(e==null?void 0:e.surcharge),J=String(e==null?void 0:e.tax),k=e==null?void 0:e.merchantPublicKey,T=e==null?void 0:e.orderID,D=String(e==null?void 0:e.amount),ae=qe==null?void 0:qe.id,ee=qe==null?void 0:qe.card_type;if(k&&T&&D&&ke)if(c)if(ae){let De={amount:ee==="Bank"?ke:D,order_id:T,customer_id:c,card_id:ae,fractalpayPublicKey:k,isCardSave:be,discount:i,surcharge:y,tax:J},ne=De,{isCardSave:R}=ne,Ge=wn(ne,["isCardSave"]),ot=_e+(ee==="Bank"?"charge-ach":"charge-by-card"),Je={"Content-Type":"application/json"};H(!0),_t.emit("sendMessage",{url:ot,body:ee=="Bank"?Ge:De,isChargebycard:!0}),_t.on("charge-by-card",me=>{var Ht;(me==null?void 0:me.result)==!0||(me==null?void 0:me.status)==!0?(ue((Ht=me.data)==null?void 0:Ht.transaction_id),Ne(!0),H(!1)):B((me==null?void 0:me.message)||"Something went wrong.")})}else B("Please Select A Card/ACH");else B("Please Select Customer");else B("Something went wrong.")},ct=async()=>{var k,T,D,ae,ee,ne;let c=e==null?void 0:e.merchantPublicKey,i=e==null?void 0:e.orderID,y=String(e==null?void 0:e.amount),J=e==null?void 0:e.customerId;if(!(Ke!=null&&Ke.device_id)){B("Please Select A Payment Device");return}if(c&&i&&y){H(!0);let De={amount:y,fractalpayPublicKey:c,customer_order_id:i,device_id:Ke==null?void 0:Ke.device_id,customer_id:J||""};try{let R=await rn.post(`${_e}charge-with-reader`,De);((k=R==null?void 0:R.data)==null?void 0:k.result)==!0?(ue((D=(T=R==null?void 0:R.data)==null?void 0:T.data)==null?void 0:D.transaction_id),Ne(!0),H(!1)):(B(((ae=R==null?void 0:R.data)==null?void 0:ae.message)||"Something went wrong."),H(!1))}catch(R){B(((ne=(ee=R==null?void 0:R.response)==null?void 0:ee.data)==null?void 0:ne.message)||"Something went wrong."),H(!1)}}else B("Something went wrong.")},at=()=>{x==="card"?mt():x==="reader"&&ct()};Jn(()=>{$&&v&&$e()},[v,$]);let pt=async c=>{gn.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){H(!0);try{let y={card_id:c,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},J=await rn.post(`${_e}delete-customer-card`,y);H(!1),$e(),gn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(y){H(!1),gn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else i.dismiss===gn.DismissReason.cancel&&gn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},xt=c=>{switch(c==null?void 0:c.toLowerCase()){case"visa":return Q;case"mastercard":case"mc":case"m/c":return we;case"amex":case"american express":case"ae":return w;case"discover":case"dcvr":return p;case"bank":return F;default:return c}},Mt=()=>{let c=ke||0;return(Number(e.amount)-c).toFixed(0)};return console.log(ye,"activeinCard","activeinBank",xe),t.createElement(t.Fragment,null,t.createElement(jt,null),t.createElement(cn,null),t.createElement(zn,null),t.createElement(t.Fragment,null,t.createElement("button",{className:"paymentBtn",onClick:z},"Pay"),t.createElement($t,{open:$,onClose:N},Te&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(Ut,{error:Te,onClose:N})),Ee&&t.createElement(pn,{onClose:N,tranId:Me}),!Te&&!Ee&&t.createElement(t.Fragment,null,(h||Z)&&t.createElement(kt,{loading:h||Z}),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:N},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:E==null?void 0:E.logo,id:"pay-logos"})),t.createElement("div",{className:"pay-container"},t.createElement("div",{className:"pay-header pay-conatiner-one frac-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:E==null?void 0:E.logo,id:"pay-logos"})),(O==null?void 0:O.length)>0&&U!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>C("cardList")}," ",t.createElement(_n,null)," Back")),t.createElement("div",{className:"amt-pay-con"},t.createElement("div",{className:"pay-amount-conatiner"},t.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),t.createElement("div",{className:"frac-card-bank-radio-main"},t.createElement(Ln,{label:"Card",amount:(bt=Number(e==null?void 0:e.amount))==null?void 0:bt.toFixed(2),value:"card",onChange:se,activetab:U}),(E==null?void 0:E.isSkyFiAccount)&&t.createElement(Ln,{label:"Bank",amount:(vt=Number(ke))==null?void 0:vt.toFixed(2),value:"ach",onChange:se,activetab:U})),ke&&ke>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,U==="card"?"Cash Discount Fee":"Cash Discount Savings"," "),t.createElement("p",null,"$",(Number(e.amount)-ke).toFixed(2))):null)),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:u,alt:""}),t.createElement("img",{src:G,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!h&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},U!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(O==null?void 0:O.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>C("cardList")}," ",t.createElement(_n,null)," Back"),(E==null?void 0:E.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:c=>{se("card")},style:{border:U==="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:c=>{se("ach")},style:{border:U==="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"},"$",(Qe=Number(e==null?void 0:e.amount))==null?void 0:Qe.toFixed(2))),U!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Q,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:we,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:w,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:p,width:35,alt:""})))),ke&&ke>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",ke))):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",E==null?void 0:E.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",x==="card"?"Cards/Banks":"Readers"," "),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"},"$",(ge=Number(e==null?void 0:e.amount))==null?void 0:ge.toFixed(2))),t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Q,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:we,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:w,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:p,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:U==="card"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(O==null?void 0:O.length)>0&&ye==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>b("list")}," ",t.createElement(_n,null)),ke&&ke>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",ke))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),U!="ach"&&t.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},t.createElement("img",{src:Q,alt:"",width:33}),t.createElement("img",{src:we,width:33,alt:""}),t.createElement("img",{src:w,alt:"",width:33}),t.createElement("img",{src:p,width:33,alt:""}))),ye==="list"?t.createElement(t.Fragment,null,t.createElement(In,{listHeading:"Cards",paymentGateway:E==null?void 0:E.paymentGateway,ListItems:O,selectedCard:qe,setSelectedCard:yt,handleDeleteCard:pt,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{b("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:at},"$",(ut=Number(e==null?void 0:e.amount))==null?void 0:ut.toFixed(2)))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:ze},t.createElement("div",{className:"ach-scrl",style:{minHeight:E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)>0?"444px":E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)==0?"456px":(O==null?void 0:O.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:(g==null?void 0:g.cardName)||"",onChange:c=>{let i=c.target.value;/^[a-zA-Z\s]*$/.test(i)&&le("cardName",i)}}),(d==null?void 0:d.cardName)&&t.createElement("span",{className:"error-span"},d==null?void 0:d.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:(g==null?void 0:g.cardNumber)||"",onChange:c=>re(c),"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:(g==null?void 0:g.expiryMonth)||"",onChange:c=>le("expiryMonth",c.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:(g==null?void 0:g.expiryYear)||"",onChange:c=>le("expiryYear",c.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:(g==null?void 0:g.cvv)||"",onChange:c=>le("cvv",c.target.value)})))),(d==null?void 0:d.cardNumber)&&t.createElement("span",{className:"error-span"},d==null?void 0:d.cardNumber),t.createElement("p",{style:{margin:"0"}},d!=null&&d.expiryMonth||d!=null&&d.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},d==null?void 0:d.expiryMonth):"",(d==null?void 0:d.cvv)&&t.createElement("span",{className:"error-span"},d==null?void 0:d.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:(Ct=e==null?void 0:e.orderID)!=null?Ct:"",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:(Ot=g==null?void 0:g.zipCode)!=null?Ot:"",onChange:c=>le("zipCode",c.target.value)}),(d==null?void 0:d.zipCode)&&t.createElement("span",{className:"error-span"},d==null?void 0:d.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:be,onChange:c=>lt(c.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"}},(E==null?void 0:E.paymentDeviceList)&&((Ye=E==null?void 0:E.paymentDeviceList)==null?void 0:Ye.length)>0&&t.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>W(!Ze)},Ze?"Pay With Reader":"Pay With Card"),t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(Et=Number(e==null?void 0:e.amount))==null?void 0:Et.toFixed(2))))),t.createElement("div",{id:"ach",style:{display:U==="ach"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(Ve==null?void 0:Ve.length)>0&&xe==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>f("list")}," ",t.createElement(_n,null)),ke&&ke>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),t.createElement("div",null,"$",Mt()))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),xe==="list"?t.createElement(t.Fragment,null,t.createElement(In,{listHeading:"Banks",paymentGateway:E==null?void 0:E.paymentGateway,ListItems:Ve,selectedCard:qe,setSelectedCard:yt,handleDeleteCard:pt,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{f("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:at},"$",(wt=Number(ke))==null?void 0:wt.toFixed(2)))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:ze},t.createElement("div",{className:"ach-scrl",style:{minHeight:E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)>0?"444px":E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)==0?"436px":(O==null?void 0:O.length)>0?"462px":"520px",maxHeight:E!=null&&E.isSkyFiAccount&&(O==null?void 0:O.length)>0?"444px":((O==null?void 0:O.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:(Ae=l==null?void 0:l.name)!=null?Ae:"",onChange:Le}),(L==null?void 0:L.name)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(Oe=l==null?void 0:l.routingNumber)!=null?Oe:"",onChange:Le}),(L==null?void 0:L.routingNumber)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(Jt=l==null?void 0:l.accountNumber)!=null?Jt:"",onChange:Le}),(L==null?void 0:L.accountNumber)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(r=l==null?void 0:l.confirmAccountNumber)!=null?r:"",onChange:Le}),(L==null?void 0:L.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.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:(s=l==null?void 0:l.bankName)!=null?s:"",onChange:Le}),(L==null?void 0:L.bankName)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.bankName)),((l==null?void 0:l.accountType)==="business saving"||(l==null?void 0:l.accountType)==="business checking")&&t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"companyName"},"Company name"),t.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(j=l==null?void 0:l.companyName)!=null?j:"",onChange:Le}),(L==null?void 0:L.companyName)&&t.createElement("span",{className:"error-span"},L==null?void 0:L.companyName)),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:(ie=l==null?void 0:l.accountType)!=null?ie:"",onChange:Le},t.createElement("option",{value:""},"Select account"),kn.map(c=>t.createElement("option",{key:c.value,value:c.value},c.label)))),(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:Ue,onChange:c=>ht(c.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),Ue&&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"},"$",(V=Number(ke))==null?void 0:V.toFixed(2)))))))))))))))}import a,{useEffect as Xn,useState as Ft}from"react";import fn from"axios";import An from"sweetalert2";import{IoArrowBack as Qn}from"react-icons/io5";function qi(e){var ke,Yt,E,nt,Me,ue,it,Pt,Kt;let[h,q]=Ft(!1),[Z,H]=Ft(!1),[Te,B]=Ft(""),[Ee,Ne]=Ft(!1),[$,m]=Ft(!1),[U,C]=Ft("card"),[x,o]=Ft(!1),ye=e.merchantPublicKey,b=te+"widget/mc-img.svg",xe=te+"widget/visa-img.svg",f=te+"widget/ae-img.svg",Ze=te+"widget/discover-img.svg",W=te+"widget/card.svg",be=te+"widget/Trash.svg",lt=te+"widget/bank.svg",Ue=te+"widget/secure-img.png",ht=te+"widget/pov-by.png",[v,we]=Ft(),[Q,w]=Ft({}),[p,pe]=Ft([]),[de,F]=Ft(),[u,G]=Ft(void 0),[Y,g]=Ft(),[S,d]=Ft(""),K=(N,z)=>{let se=(parseFloat(z)||0)/100,le=N/(1+se);return Math.round(le*100)/100};Xn(()=>{if(e!=null&&e.pass_fee){let N=K(e==null?void 0:e.amount,e==null?void 0:e.surcharge);G(N)}},[e==null?void 0:e.pass_fee]);let l=()=>q(!0),X=()=>q(!1),L=()=>{m(!1),C("card"),H(!1),B(""),Ne(!1),d(""),we({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),w({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),o(!1),F({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},Pe=()=>m(!0),O=(N,z)=>{let se=N;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(se)){(z===""||/^[0-9]+$/.test(z))&&(w(re=>I(P({},re),{[se]:""})),we(re=>I(P({},re),{[se]:z})));return}w(re=>I(P({},re),{[se]:""})),we(re=>I(P({},re),{[se]:z}))},dt=N=>{let se=N.target.value.replace(/\D/g,""),le="";/^3[47]/.test(se)?le=se.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Le,Ie,ve,ze)=>[Ie,ve,ze].filter(Boolean).join(" ")):le=se.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Le,Ie,ve,ze,$e)=>[Ie,ve,ze,$e].filter(Boolean).join(" ")),w(re=>I(P({},re),{cardNumber:""})),we(re=>I(P({},re),{cardNumber:le}))},Ve=()=>{var re,Le,Ie,ve,ze,$e;let N={},z=v,se=parseInt((z==null?void 0:z.expiryMonth)||"",10),le=(z==null?void 0:z.expiryYear)||"";if((re=z==null?void 0:z.cardName)!=null&&re.trim()||(N.cardName="Card name is required"),(Le=z==null?void 0:z.cardNumber)!=null&&Le.trim()||(N.cardNumber="Card number is required"),(!((Ie=z==null?void 0:z.expiryMonth)!=null&&Ie.trim())||!((ve=z==null?void 0:z.expiryYear)!=null&&ve.trim())||isNaN(se)||se<1||se>12||le.length!==4)&&(N.expiryMonth="Invalid Expiration Date."),(ze=z==null?void 0:z.cvv)!=null&&ze.trim()||(N.cvv="CVV is required"),($e=z==null?void 0:z.zipCode)!=null&&$e.trim()||(N.zipCode="ZIP code is required"),z!=null&&z.expiryMonth&&(z!=null&&z.expiryYear)&&z.expiryMonth.length<=2&&z.expiryYear.length===4){let mt=parseInt(z.expiryMonth,10),ct=parseInt(z.expiryYear,10),at=new Date,pt=at.getMonth()+1,xt=at.getFullYear();(ct<xt||ct===xt&&mt<pt)&&(N.expiryMonth="Card is expired")}return w(N),Object.keys(N).length>0},St=async N=>{var z,se,le,re,Le,Ie,ve,ze,$e,mt,ct,at,pt,xt,Mt,bt,vt,Qe,ge;if(N.preventDefault(),U=="card"){if(Ve())return;{let Ct=DatacapWebToken.validateCardNumber(v==null?void 0:v.cardNumber.replaceAll(" ","")),Ot=DatacapWebToken.validateExpirationDate(v==null?void 0:v.expiryMonth,v==null?void 0:v.expiryYear),Ye=DatacapWebToken.validateCVV(v==null?void 0:v.cvv),Et={};if(Ct||(Et.cardNumber="Invalid card Number"),Ot||(Et.expiryMonth="Invalid Expiration Date."),Ye||(Et.cvv="Invalid CVV"),w(Et),Ct&&Ye&&Ot){H(!0);try{let wt=async function(Ae){if(Ae.Error)B(Ae.Error),H(!1);else{let Oe=v==null?void 0:v.cardName,Jt=v==null?void 0:v.zipCode;Ae.name=Oe,Ae.postal_code=Jt,Ae.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,Ae.amount=e==null?void 0:e.amount,Ae.order_id=e==null?void 0:e.orderID,Ae.preAuth_id="",Ae.isCardSave=x,Ae.customer_id=e==null?void 0:e.customerId,Ae.link_token="",Ae.gateway_id=Y==null?void 0:Y.paymentGateway,Ae.discount=e==null?void 0:e.discount,Ae.tax=e==null?void 0:e.tax,Ae.surcharge=e==null?void 0:e.surcharge,Ae.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let s={method:"POST",body:JSON.stringify(Ae),redirect:"follow"};_t.emit("sendMessage",I(P({},s),{isChargePreauth:!0})),_t.on("charge-preauth",j=>{var ie;console.log(j,"datdata"),(j==null?void 0:j.status)=="Failed"?(H(!1),B((j==null?void 0:j.message)||"Something went wrong. Please try again later.")):(Ne(!0),d((ie=j==null?void 0:j.data)==null?void 0:ie.transaction_id),H(!1),we({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((Y==null?void 0:Y.paymentGateway)===32){let Ae={method:"POST",redirect:"follow"};try{let Oe=await fn.post(`${Ce}api/v1/widget/generate-session`,Ae),Jt=Number(v==null?void 0:v.expiryYear)%100,r=v==null?void 0:v.cardNumber;r=r==null?void 0:r.replace(/\s+/g,"");let s=`${r}=${Jt}${v==null?void 0:v.expiryMonth} ${v==null?void 0:v.cvv}`,ie=forge.pki.publicKeyFromPem((se=(z=Oe==null?void 0:Oe.data)==null?void 0:z.data)==null?void 0:se.publicKeyPem).encrypt(s,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),V=forge.util.encode64(ie),c={"Content-Type":"application/json","x-app-session-key":(re=(le=Oe.data)==null?void 0:le.data)==null?void 0:re.session_key},i=JSON.stringify({enc_track2_data:`${V}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Ie=(Le=Oe==null?void 0:Oe.data)==null?void 0:Le.data)==null?void 0:Ie.session_key}`});try{let y=await fn.post(`${gt}tokenizer/tokenize`,i,{headers:c}),J=JSON.stringify(I(P({},(ve=y==null?void 0:y.data)==null?void 0:ve.data),{name:v==null?void 0:v.cardName,postal_code:v==null?void 0:v.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${($e=(ze=y==null?void 0:y.data)==null?void 0:ze.data)==null?void 0:$e.token}`,fractalpayPublicKey:ye,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:x,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:v==null?void 0:v.expiryYear,ExpirationMonth:v==null?void 0:v.expiryMonth,CVV:v==null?void 0:v.cvv,Last4:(ct=(mt=y==null?void 0:y.data)==null?void 0:mt.data)==null?void 0:ct.last4,Brand:(pt=(at=y==null?void 0:y.data)==null?void 0:at.data)==null?void 0:pt.brand,gateway_id:Y==null?void 0:Y.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),T={method:"POST",headers:{"Content-Type":"application/json"},body:J,redirect:"follow"};_t.emit("sendMessage",I(P({},T),{isFractalPreauth:!0})),_t.on("fractal-charge-preauth",D=>{var ae;(D==null?void 0:D.status)=="Failed"?(H(!1),B((D==null?void 0:D.message)||"Something went wrong , Try again later")):(d((ae=D==null?void 0:D.data)==null?void 0:ae.transaction_id),Ne(!0),H(!1))})}catch(y){console.log(y),H(!1),B(((Mt=(xt=y==null?void 0:y.response)==null?void 0:xt.data)==null?void 0:Mt.message)||(y==null?void 0:y.message)||"Something went wrong , Try again later")}}catch(Oe){H(!1),B(((vt=(bt=Oe==null?void 0:Oe.response)==null?void 0:bt.data)==null?void 0:vt.message)||(Oe==null?void 0:Oe.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(Y==null?void 0:Y.dctoken,"PaymentForm",wt)}catch(wt){H(!1),B(((ge=(Qe=wt==null?void 0:wt.response)==null?void 0:Qe.data)==null?void 0:ge.message)||(wt==null?void 0:wt.message)||"Something went wrong.")}}}}},qe=async()=>{var N,z,se,le,re,Le,Ie,ve,ze,$e,mt,ct,at,pt,xt,Mt,bt,vt;l();try{let Qe={fractalpayPublicKey:ye,customer_id:e==null?void 0:e.customerId,preauth:!0},ge=await fn.post(`${_e}get-payment-details`,Qe);if(g((N=ge==null?void 0:ge.data)==null?void 0:N.data),(se=(z=ge==null?void 0:ge.data)==null?void 0:z.data)!=null&&se.paymentGateway||(L(),B("Something went wrong.")),(re=(le=ge==null?void 0:ge.data)==null?void 0:le.data)!=null&&re.card_list&&((ve=(Ie=(Le=ge==null?void 0:ge.data)==null?void 0:Le.data)==null?void 0:Ie.card_list)==null?void 0:ve.length)>0){pe(($e=(ze=ge==null?void 0:ge.data)==null?void 0:ze.data)==null?void 0:$e.card_list),C("cardList");let ut=(at=(ct=(mt=ge==null?void 0:ge.data)==null?void 0:mt.data)==null?void 0:ct.card_list)==null?void 0:at.filter(Ct=>(Ct==null?void 0:Ct.primary_card)==1);ut!=null&&ut[0]&&((pt=ut==null?void 0:ut[0])==null?void 0:pt.payment_method_type)==((Mt=(xt=ge==null?void 0:ge.data)==null?void 0:xt.data)==null?void 0:Mt.paymentGateway)&&F(ut[0])}else C("card");X()}catch(Qe){console.log(Qe),X(),B(((vt=(bt=Qe==null?void 0:Qe.response)==null?void 0:bt.data)==null?void 0:vt.message)||(Qe==null?void 0:Qe.message)||"Something went wrong")}},yt=async()=>{var mt,ct,at,pt,xt,Mt,bt;let N=e==null?void 0:e.customerId,z=e==null?void 0:e.discount,se=e==null?void 0:e.surcharge,le=e==null?void 0:e.tax,re=e==null?void 0:e.merchantPublicKey,Le=e==null?void 0:e.orderID,Ie=e==null?void 0:e.amount,ve=de==null?void 0:de.id,ze=de==null?void 0:de.card_type;if(re&&Le&&Ie)if(N)if(ve){let vt={amount:Ie,order_id:Le,customer_id:N,card_id:ve,fractalpayPublicKey:re,isCardSave:ze!="Bank",discount:z,surcharge:se,tax:le},$e=vt,{isCardSave:Qe}=$e,ge=wn($e,["isCardSave"]),Ct=_e+"authorize-by-card",Ot={"Content-Type":"application/json"};H(!0);try{let Ye=await fn.post(Ct,ze=="Bank"?ge:vt,{headers:Ot});(mt=Ye==null?void 0:Ye.data)!=null&&mt.result&&(d((at=(ct=Ye==null?void 0:Ye.data)==null?void 0:ct.data)==null?void 0:at.transaction_id),Ne(!0),H(!1))}catch(Ye){H(!1),console.log(Ye),B(((xt=(pt=Ye==null?void 0:Ye.response)==null?void 0:pt.data)==null?void 0:xt.message)||((bt=(Mt=Ye==null?void 0:Ye.response)==null?void 0:Mt.data)==null?void 0:bt.status)||"Something went erong")}}else B("Please Select A Card/ACH");else B("Please Select Customer");else B("Something went wrong.")};Xn(()=>{$&&ye&&qe()},[ye,$]);let Ke=async N=>{An.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 z=>{if(z.isConfirmed){H(!0);try{let se={card_id:N,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},le=await fn.post(`${_e}delete-customer-card`,se);H(!1),qe(),An.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(se){H(!1),An.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},tt=N=>{switch(N==null?void 0:N.toLowerCase()){case"visa":return xe;case"mastercard":case"mc":case"m/c":return b;case"amex":case"american express":case"ae":return f;case"discover":case"dcvr":return Ze;case"bank":return lt;default:return N}};return a.createElement(a.Fragment,null,a.createElement(jt,null),a.createElement(cn,null),a.createElement(a.Fragment,null,a.createElement("button",{className:"paymentBtn",onClick:Pe},"PreAuth Payment"),a.createElement($t,{open:$,onClose:L},Te&&a.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},a.createElement(Ut,{error:Te,onClose:L})),Ee&&a.createElement(pn,{onClose:L,tranId:S}),!Te&&!Ee&&a.createElement(a.Fragment,null,(h||Z)&&a.createElement(kt,{loading:h||Z}),a.createElement("div",null,a.createElement("div",{className:"frac-card-payment-page frac-form"},a.createElement("div",{className:"parent-pay-container"},a.createElement("span",{className:"request-payment-close-popup",onClick:L},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12425_52336)"},a.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"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12425_52336"},a.createElement("rect",{width:"16",height:"16",fill:"white"}))))),a.createElement("div",{className:"pay-container"},a.createElement("div",{className:"pay-header pay-conatiner-one"},a.createElement("div",{className:"pay-conatiner-one-first"},a.createElement("div",{className:"pay-logo-container"},a.createElement("div",{className:"pay-main-logo"},a.createElement("img",{src:Y==null?void 0:Y.logo,id:"pay-logos"})),a.createElement("h1",{className:"pay-heading"},"Pay"),(p==null?void 0:p.length)>0&&U!=="cardList"&&a.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>C("cardList")}," ",a.createElement(Qn,null)," Back")),a.createElement("div",{className:"amt-pay-con"},a.createElement("div",{className:"pay-amount-conatiner"},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},"$",(ke=Number(e==null?void 0:e.amount))==null?void 0:ke.toFixed(2)),u&&u>0&&a.createElement("div",{style:{width:"80%"},className:"frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,"$",u.toFixed(2)))),U!="ach"&&a.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},a.createElement("img",{src:xe,alt:"",width:33}),a.createElement("img",{src:b,width:33,alt:""}),a.createElement("img",{src:f,alt:"",width:33}),a.createElement("img",{src:Ze,width:33,alt:""})))),a.createElement("div",{className:"pay-conatiner-one-last"},a.createElement("img",{src:Ue,alt:""}),a.createElement("img",{src:ht,alt:""}),"Secure payments powered by Fractal"),a.createElement("div",null)),!h&&a.createElement("div",{className:"pay-tab pay-conatiner-two"},a.createElement("div",{className:"col-md-12"},a.createElement("div",{id:"payment-form-div"},U!=="cardList"?a.createElement("div",null,(p==null?void 0:p.length)>0&&a.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>C("cardList")}," ",a.createElement(Qn,null)," Back"),a.createElement("div",{className:""},a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},"$",(Yt=Number(e==null?void 0:e.amount))==null?void 0:Yt.toFixed(2))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:xe,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:b,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:f,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:Ze,width:35,alt:""})))),u&&u>0&&a.createElement("div",{className:"res-pay-con frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,"$",u)))):a.createElement("div",null,a.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",Y==null?void 0:Y.customer_name),a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},"$",(E=Number(e==null?void 0:e.amount))==null?void 0:E.toFixed(2))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:xe,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:b,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:f,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:Ze,width:35,alt:""})))),a.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),a.createElement("div",{style:{display:U==="cardList"?"block":"none"},className:"tabcontent"},a.createElement("div",{className:"card-lint-div-in"},a.createElement("div",{className:"card-list-div"},(Y==null?void 0:Y.card_list)&&((nt=Y==null?void 0:Y.card_list)==null?void 0:nt.length)>0&&((Me=Y==null?void 0:Y.card_list)==null?void 0:Me.map((N,z)=>a.createElement("div",{className:"card-list-single-div",key:z},a.createElement("div",{className:"card-number-radio"},a.createElement("input",{disabled:(Y==null?void 0:Y.paymentGateway)!=(N==null?void 0:N.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:de===N,onChange:se=>F(N)}),a.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",N==null?void 0:N.cardlastfourdigit),a.createElement("h6",{className:"card-expiry-date"},N==null?void 0:N.expmonth,"/",N==null?void 0:N.expyear)),a.createElement("div",{className:"card-number-radio"},a.createElement("span",{className:"visa-card"},a.createElement("img",{src:tt(N==null?void 0:N.card_type),alt:""})),a.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Ke(N==null?void 0:N.id)},a.createElement("img",{src:be,alt:""}))))))),a.createElement("div",{className:"pay-with-other-card ",onClick:()=>C("card")},"Authorize With Other Card",a.createElement("img",{src:W,alt:""}))),a.createElement("div",{className:"form-group"},a.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:yt},"$",(ue=Number(e==null?void 0:e.amount))==null?void 0:ue.toFixed(2)))),a.createElement("div",{id:"card",style:{display:U==="card"?"block":"none"},className:"tabcontent"},a.createElement("form",{id:"PaymentForm",onSubmit:St},a.createElement("div",{className:"ach-scrl",style:{minHeight:(p==null?void 0:p.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),a.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(v==null?void 0:v.cardName)||"",onChange:N=>{let z=N.target.value;/^[a-zA-Z\s]*$/.test(z)&&O("cardName",z)}}),(Q==null?void 0:Q.cardName)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.cardName)),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"cardNumber"},"Card Number"),a.createElement("div",{className:"toggle-num-wrapper"},a.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(v==null?void 0:v.cardNumber)||"",onChange:N=>dt(N),"data-token":"card_number"}),a.createElement("div",{className:"card-crdi card-expiry-new"},a.createElement("div",{className:"exp-date-year-container"},a.createElement("div",{className:"exp-date form-group"},a.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(v==null?void 0:v.expiryMonth)||"",onChange:N=>O("expiryMonth",N.target.value)})),a.createElement("div",{className:"exp-year form-group"},a.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(v==null?void 0:v.expiryYear)||"",onChange:N=>O("expiryYear",N.target.value)})),a.createElement("div",{className:"security-digit form-group"},a.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(v==null?void 0:v.cvv)||"",onChange:N=>O("cvv",N.target.value)})))),(Q==null?void 0:Q.cardNumber)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.cardNumber),a.createElement("p",{style:{margin:"0"}},Q!=null&&Q.expiryMonth||Q!=null&&Q.expiryYear?a.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},Q==null?void 0:Q.expiryMonth):"",(Q==null?void 0:Q.cvv)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.cvv)))),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(it=v==null?void 0:v.orderId)!=null?it:"OID123456",onChange:N=>O("orderId",N.target.value),style:{background:"#F6F6F7",color:"#727272"}})),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"zip"},"ZIP"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Pt=v==null?void 0:v.zipCode)!=null?Pt:"",onChange:N=>O("zipCode",N.target.value)}),(Q==null?void 0:Q.zipCode)&&a.createElement("span",{className:"error-span"},Q==null?void 0:Q.zipCode)),(e==null?void 0:e.customerId)&&a.createElement("div",{className:"form-group"},a.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},a.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:x,onChange:N=>o(N.target.checked)}),a.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),a.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12420_50192)"},a.createElement("rect",{width:"20",height:"20",fill:"white"}),a.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),a.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"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12420_50192"},a.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),a.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},a.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(Kt=Number(e==null?void 0:e.amount))==null?void 0:Kt.toFixed(2))))))))))))))))}import oe,{useEffect as ji,useRef as hn,useState as an}from"react";import Vi from"sweetalert2";import sn from"axios";import $i from"react";function Bn(){let e="#000",h="#fff",q="#212529",Z="#dee2e6";return $i.createElement("style",null,`
|
|
1636
1636
|
.add-card {
|
|
1637
1637
|
max-width:380px;
|
|
1638
1638
|
padding: 0 20px
|
|
@@ -1891,7 +1891,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
1893
|
|
|
1894
|
-
`)}import
|
|
1894
|
+
`)}import Vt from"react";import Yi from"react";function Tn(){return Yi.createElement("style",null,`
|
|
1895
1895
|
.card-success .logo-container {
|
|
1896
1896
|
display: flex;
|
|
1897
1897
|
justify-content: center;
|
|
@@ -1979,7 +1979,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
1979
1979
|
color: #161616;
|
|
1980
1980
|
opacity: 0.5;
|
|
1981
1981
|
}
|
|
1982
|
-
`)}var Yi=({onClose:e})=>jt.createElement(jt.Fragment,null,jt.createElement(Bn,null),jt.createElement("div",{className:"card-success"},jt.createElement("div",{className:"payment-success-container"},jt.createElement("div",{className:"success-icon"},jt.createElement("div",{className:"circle"},jt.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),jt.createElement("div",{className:"success-text"},jt.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),jt.createElement("div",{className:"thank-you-text"},"Thank you ")))))),Qn=Yi;function Vi(e){var le;let[h,$]=nn(!1),[Z,j]=nn(!1),[qe,q]=nn(""),[We,ke]=nn(!1),Y=fn(null),c=fn(null),G=fn(null),v=fn(null),y=fn(null),[o,he]=nn(),[x,ye]=nn({}),[f,Ue]=nn(),W=()=>$(!0),xe=()=>$(!1),dt=_=>{ji.fire({icon:"error",text:_,customClass:{popup:"custom-z-index"}})},Je=()=>{ke(!1),j(!1),q(""),he({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},yt=()=>ke(!0),b=()=>{Je()},we=(_,u)=>{var g,F,m;let J=_,H=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(J,u==null?void 0:u.length,"dfih",J==="expiryMonth"&&(u==null?void 0:u.length)===2),J==="expiryMonth"&&(u==null?void 0:u.length)===2&&((g=G==null?void 0:G.current)==null||g.focus()),J==="expiryYear"&&(u==null?void 0:u.length)===4&&((F=v==null?void 0:v.current)==null||F.focus()),J==="cvv"&&(u==null?void 0:u.length)===3&&((m=y==null?void 0:y.current)==null||m.focus()),H.includes(J)){(u===""||/^[0-9]+$/.test(u))&&(ye(K=>A(S({},K),{[J]:""})),he(K=>A(S({},K),{[J]:u})));return}ye(K=>A(S({},K),{[J]:""})),console.log(u,J),he(K=>A(S({},K),{[J]:u}))},Q=_=>{var g;let J=_.target.value.replace(/\D/g,""),H="";/^3[47]/.test(J)?H=J.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(m,K,d,X)=>[K,d,X].filter(Boolean).join(" ")):H=J.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(m,K,d,X,L)=>[K,d,X,L].filter(Boolean).join(" ")),ye(F=>A(S({},F),{cardNumber:""})),he(F=>A(S({},F),{cardNumber:H})),console.log(J==null?void 0:J.length,"length"),(J==null?void 0:J.length)===16&&((g=c==null?void 0:c.current)==null||g.focus())},C=()=>{var g,F,m,K,d,X;let _={},u=o,J=parseInt((u==null?void 0:u.expiryMonth)||"",10),H=(u==null?void 0:u.expiryYear)||"";if((g=u==null?void 0:u.cardName)!=null&&g.trim()||(_.cardName="Card name is required"),(F=u==null?void 0:u.cardNumber)!=null&&F.trim()||(_.cardNumber="Card number is required"),(m=u==null?void 0:u.expiryMonth)!=null&&m.trim()?(Number(u==null?void 0:u.expiryMonth)>12||Number(u==null?void 0:u.expiryMonth)<1)&&(_.expiryMonth="Invalid Expiration Month."):_.expiryMonth="Expiration month is required",(K=u==null?void 0:u.expiryYear)!=null&&K.trim()?((d=u==null?void 0:u.expiryYear)==null?void 0:d.trim().length)!==4||Number(u==null?void 0:u.expiryYear)<2025?_.expiryYear="Invalid Expiration Year.":(isNaN(J)||J<1||J>12||H.length!==4)&&(_.expiryMonth="Invalid Expiration Date."):_.expiryYear="Expiration year is required",(X=u==null?void 0:u.cvv)!=null&&X.trim()||(_.cvv="CVC is required"),u!=null&&u.expiryMonth&&(u!=null&&u.expiryYear)&&u.expiryMonth.length<=2&&u.expiryYear.length===4){let L=parseInt(u.expiryMonth,10),Me=parseInt(u.expiryYear,10),O=new Date,mt=O.getMonth()+1,Ke=O.getFullYear();(Me<Ke||Me===Ke&&L<mt)&&(_.expiryMonth="Card is expired")}return ye(_),Object.keys(_).length>0},p=async()=>{var _,u,J;W();try{let H={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},g=await rn.post(`${Fe}get-payment-details`,H);console.log(g),Ue((_=g==null?void 0:g.data)==null?void 0:_.data),(J=(u=g==null?void 0:g.data)==null?void 0:u.data)!=null&&J.paymentGateway||(Je(),q("Something went wrong.")),xe()}catch(H){console.log(H),xe(),Je(),q("Something went wrong.")}};return Hi(()=>{e!=null&&e.merchantPublicKey&&p()},[e==null?void 0:e.merchantPublicKey]),ie.createElement(ie.Fragment,null,ie.createElement(Ht,null),ie.createElement(An,null),ie.createElement(St,{loading:h}),qe&&ie.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},ie.createElement(Wt,{error:qe,onClose:Je})),Z&&ie.createElement(Qn,{onClose:b}),!qe&&!Z&&ie.createElement(ie.Fragment,null,ie.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},ie.createElement("form",{id:"creditCardForm",onSubmit:async _=>{var J,H,g,F,m,K,d,X,L,Me,O,mt,Ke,Lt,$e,xt;_.preventDefault();let u=C();if(console.log(o),!u){let Oe=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),at=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),_e=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),qt={};if(Oe||(qt.cardNumber="Invalid card Number"),at||(qt.expiryMonth="Invalid Expiration Date."),_e||(qt.cvv="Invalid CVV"),ye(qt),Oe&&_e&&at){W();try{let E=async function(ot){var Le,pe,rt,zt,Vt;if(console.log(ot),ot.Error)console.log(ot==null?void 0:ot.Error),q(ot.Error),xe();else{let w={userId:e==null?void 0:e.customerId,cardName:o==null?void 0:o.cardName,zip:o==null?void 0:o.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:ot};try{let z=await rn.post(`${Fe}add-card`,w);console.log(z);let oe={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:o==null?void 0:o.cardNumber.replaceAll(" ",""),exp_month:o==null?void 0:o.expiryMonth,exp_year:(Le=o==null?void 0:o.expiryYear)==null?void 0:Le.slice(-2),cvv:o==null?void 0:o.cvv};try{let re=await rn.post(`${Fe}link-wallet`,oe);console.log(re),j(!0),xe(),he({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),tn(_,"close","")}catch(re){console.log(re),xe(),q(((rt=(pe=re==null?void 0:re.response)==null?void 0:pe.data)==null?void 0:rt.message)||(re==null?void 0:re.message)||"Something went wrong.")}}catch(z){console.log(z),xe(),q(((Vt=(zt=z==null?void 0:z.response)==null?void 0:zt.data)==null?void 0:Vt.message)||(z==null?void 0:z.message)||"Something went wrong.")}}};if((f==null?void 0:f.paymentGateway)===32){let ot={method:"POST",redirect:"follow"};try{let Le=await rn.post(`${ve}api/v1/widget/generate-session`,ot),pe=Number(o==null?void 0:o.expiryYear)%100,rt=o==null?void 0:o.cardNumber;rt=rt==null?void 0:rt.replace(/\s+/g,"");let zt=`${rt}=${pe}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,w=forge.pki.publicKeyFromPem((H=(J=Le==null?void 0:Le.data)==null?void 0:J.data)==null?void 0:H.publicKeyPem).encrypt(zt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),z=forge.util.encode64(w),oe={"Content-Type":"application/json","x-app-session-key":(F=(g=Le.data)==null?void 0:g.data)==null?void 0:F.session_key},re=JSON.stringify({enc_track2_data:`${z}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(K=(m=Le==null?void 0:Le.data)==null?void 0:m.data)==null?void 0:K.session_key}`});try{let ae=await rn.post(`${ft}tokenizer/tokenize`,re,{headers:oe}),ze=JSON.stringify(A(S({},(d=ae==null?void 0:ae.data)==null?void 0:d.data),{cvv:o==null?void 0:o.cvv,cardName:o==null?void 0:o.cardName,zip:o==null?void 0:o.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),Ae={"Content-Type":"application/json"};try{let be=await rn.post(`${Fe}add-card`,ze,{headers:Ae});console.log(be),(X=be==null?void 0:be.data)!=null&&X.result&&(j(!0),xe(),tn(_,"close",""))}catch(be){xe(),q(((Me=(L=be==null?void 0:be.response)==null?void 0:L.data)==null?void 0:Me.message)||(be==null?void 0:be.message)||"Something went wrong.")}}catch(ae){xe(),q(((mt=(O=ae==null?void 0:ae.response)==null?void 0:O.data)==null?void 0:mt.message)||(ae==null?void 0:ae.message)||"Something went wrong.")}}catch(Le){xe(),q(((Lt=(Ke=Le==null?void 0:Le.response)==null?void 0:Ke.data)==null?void 0:Lt.message)||(Le==null?void 0:Le.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(f==null?void 0:f.dctoken,"creditCardForm",E)}catch(E){xe(),q(((xt=($e=E==null?void 0:E.response)==null?void 0:$e.data)==null?void 0:xt.message)||(E==null?void 0:E.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},ie.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},ie.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},ie.createElement("label",{htmlFor:"cardNumber"},"Card Number"),ie.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(o==null?void 0:o.cardNumber)||"",onChange:_=>Q(_),ref:Y}),(x==null?void 0:x.cardNumber)&&ie.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},x==null?void 0:x.cardNumber),ie.createElement("br",null)),ie.createElement("div",{className:"card-dtl"},ie.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},ie.createElement("div",{className:"form-group",style:{marginTop:"0"}},ie.createElement("label",{htmlFor:"expMonth"},"MM"),ie.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:_=>we("expiryMonth",_.target.value),ref:c}),(x==null?void 0:x.expiryMonth)&&ie.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},x==null?void 0:x.expiryMonth)),ie.createElement("div",{className:"form-group",style:{marginTop:"0"}},ie.createElement("label",{htmlFor:"expYear"},"YYYY"),ie.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:_=>we("expiryYear",_.target.value),ref:G}),(x==null?void 0:x.expiryYear)&&ie.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},x==null?void 0:x.expiryYear)),ie.createElement("div",{className:"form-group",style:{marginTop:"0"}},ie.createElement("label",{htmlFor:"cvc"},"CVC"),ie.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(o==null?void 0:o.cvv)||"",onChange:_=>we("cvv",_.target.value),ref:v}),(x==null?void 0:x.cvv)&&ie.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},x==null?void 0:x.cvv)))),ie.createElement("div",{className:"form-group",style:{marginTop:"0"}},ie.createElement("label",{htmlFor:"cardholderName"},"Name on card"),ie.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(o==null?void 0:o.cardName)||"",onChange:_=>{let u=_.target.value;/^[a-zA-Z\s]*$/.test(u)&&we("cardName",u)},ref:y}),(x==null?void 0:x.cardName)&&ie.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},x==null?void 0:x.cardName)),ie.createElement("div",{className:"form-group",style:{marginTop:"0"}},ie.createElement("label",{htmlFor:"zipcode"},"Zip"),ie.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(le=o==null?void 0:o.zipCode)!=null?le:"",onChange:_=>we("zipCode",_.target.value)}),(x==null?void 0:x.zipCode)&&ie.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},x==null?void 0:x.zipCode))),ie.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import T,{useState as hn}from"react";import yn from"axios";var _n={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import Ki from"react";function Tn({}){return Ki.createElement("style",null,`
|
|
1982
|
+
`)}var Hi=({onClose:e})=>Vt.createElement(Vt.Fragment,null,Vt.createElement(Tn,null),Vt.createElement("div",{className:"card-success"},Vt.createElement("div",{className:"payment-success-container"},Vt.createElement("div",{className:"success-icon"},Vt.createElement("div",{className:"circle"},Vt.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),Vt.createElement("div",{className:"success-text"},Vt.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),Vt.createElement("div",{className:"thank-you-text"},"Thank you ")))))),Dn=Hi;function Ki(e){var de;let[h,q]=an(!1),[Z,H]=an(!1),[Te,B]=an(""),[Ee,Ne]=an(!1),$=hn(null),m=hn(null),U=hn(null),C=hn(null),x=hn(null),[o,ye]=an(),[b,xe]=an({}),[f,Ze]=an(),W=()=>q(!0),be=()=>q(!1),lt=F=>{Vi.fire({icon:"error",text:F,customClass:{popup:"custom-z-index"}})},Ue=()=>{Ne(!1),H(!1),B(""),ye({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},ht=()=>Ne(!0),v=()=>{Ue()},we=(F,u)=>{var g,S,d;let G=F,Y=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(G,u==null?void 0:u.length,"dfih",G==="expiryMonth"&&(u==null?void 0:u.length)===2),G==="expiryMonth"&&(u==null?void 0:u.length)===2&&((g=U==null?void 0:U.current)==null||g.focus()),G==="expiryYear"&&(u==null?void 0:u.length)===4&&((S=C==null?void 0:C.current)==null||S.focus()),G==="cvv"&&(u==null?void 0:u.length)===3&&((d=x==null?void 0:x.current)==null||d.focus()),Y.includes(G)){(u===""||/^[0-9]+$/.test(u))&&(xe(K=>I(P({},K),{[G]:""})),ye(K=>I(P({},K),{[G]:u})));return}xe(K=>I(P({},K),{[G]:""})),console.log(u,G),ye(K=>I(P({},K),{[G]:u}))},Q=F=>{var g;let G=F.target.value.replace(/\D/g,""),Y="";/^3[47]/.test(G)?Y=G.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(d,K,l,X)=>[K,l,X].filter(Boolean).join(" ")):Y=G.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(d,K,l,X,L)=>[K,l,X,L].filter(Boolean).join(" ")),xe(S=>I(P({},S),{cardNumber:""})),ye(S=>I(P({},S),{cardNumber:Y})),console.log(G==null?void 0:G.length,"length"),(G==null?void 0:G.length)===16&&((g=m==null?void 0:m.current)==null||g.focus())},w=()=>{var g,S,d,K,l,X;let F={},u=o,G=parseInt((u==null?void 0:u.expiryMonth)||"",10),Y=(u==null?void 0:u.expiryYear)||"";if((g=u==null?void 0:u.cardName)!=null&&g.trim()||(F.cardName="Card name is required"),(S=u==null?void 0:u.cardNumber)!=null&&S.trim()||(F.cardNumber="Card number is required"),(d=u==null?void 0:u.expiryMonth)!=null&&d.trim()?(Number(u==null?void 0:u.expiryMonth)>12||Number(u==null?void 0:u.expiryMonth)<1)&&(F.expiryMonth="Invalid Expiration Month."):F.expiryMonth="Expiration month is required",(K=u==null?void 0:u.expiryYear)!=null&&K.trim()?((l=u==null?void 0:u.expiryYear)==null?void 0:l.trim().length)!==4||Number(u==null?void 0:u.expiryYear)<2025?F.expiryYear="Invalid Expiration Year.":(isNaN(G)||G<1||G>12||Y.length!==4)&&(F.expiryMonth="Invalid Expiration Date."):F.expiryYear="Expiration year is required",(X=u==null?void 0:u.cvv)!=null&&X.trim()||(F.cvv="CVC is required"),u!=null&&u.expiryMonth&&(u!=null&&u.expiryYear)&&u.expiryMonth.length<=2&&u.expiryYear.length===4){let L=parseInt(u.expiryMonth,10),Pe=parseInt(u.expiryYear,10),O=new Date,dt=O.getMonth()+1,Ve=O.getFullYear();(Pe<Ve||Pe===Ve&&L<dt)&&(F.expiryMonth="Card is expired")}return xe(F),Object.keys(F).length>0},p=async()=>{var F,u,G;W();try{let Y={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},g=await sn.post(`${_e}get-payment-details`,Y);console.log(g),Ze((F=g==null?void 0:g.data)==null?void 0:F.data),(G=(u=g==null?void 0:g.data)==null?void 0:u.data)!=null&&G.paymentGateway||(Ue(),B("Something went wrong.")),be()}catch(Y){console.log(Y),be(),Ue(),B("Something went wrong.")}};return ji(()=>{e!=null&&e.merchantPublicKey&&p()},[e==null?void 0:e.merchantPublicKey]),oe.createElement(oe.Fragment,null,oe.createElement(jt,null),oe.createElement(Bn,null),oe.createElement(kt,{loading:h}),Te&&oe.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},oe.createElement(Ut,{error:Te,onClose:Ue})),Z&&oe.createElement(Dn,{onClose:v}),!Te&&!Z&&oe.createElement(oe.Fragment,null,oe.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},oe.createElement("form",{id:"creditCardForm",onSubmit:async F=>{var G,Y,g,S,d,K,l,X,L,Pe,O,dt,Ve,St,qe,yt;F.preventDefault();let u=w();if(console.log(o),!u){let Ke=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),tt=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),ke=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),Yt={};if(Ke||(Yt.cardNumber="Invalid card Number"),tt||(Yt.expiryMonth="Invalid Expiration Date."),ke||(Yt.cvv="Invalid CVV"),xe(Yt),Ke&&ke&&tt){W();try{let E=async function(nt){var Me,ue,it,Pt,Kt;if(console.log(nt),nt.Error)console.log(nt==null?void 0:nt.Error),B(nt.Error),be();else{let N={userId:e==null?void 0:e.customerId,cardName:o==null?void 0:o.cardName,zip:o==null?void 0:o.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:nt};try{let z=await sn.post(`${_e}add-card`,N);console.log(z);let se={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:o==null?void 0:o.cardNumber.replaceAll(" ",""),exp_month:o==null?void 0:o.expiryMonth,exp_year:(Me=o==null?void 0:o.expiryYear)==null?void 0:Me.slice(-2),cvv:o==null?void 0:o.cvv};try{let le=await sn.post(`${_e}link-wallet`,se);console.log(le),H(!0),be(),ye({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),nn(F,"close","")}catch(le){console.log(le),be(),B(((it=(ue=le==null?void 0:le.response)==null?void 0:ue.data)==null?void 0:it.message)||(le==null?void 0:le.message)||"Something went wrong.")}}catch(z){console.log(z),be(),B(((Kt=(Pt=z==null?void 0:z.response)==null?void 0:Pt.data)==null?void 0:Kt.message)||(z==null?void 0:z.message)||"Something went wrong.")}}};if((f==null?void 0:f.paymentGateway)===32){let nt={method:"POST",redirect:"follow"};try{let Me=await sn.post(`${Ce}api/v1/widget/generate-session`,nt),ue=Number(o==null?void 0:o.expiryYear)%100,it=o==null?void 0:o.cardNumber;it=it==null?void 0:it.replace(/\s+/g,"");let Pt=`${it}=${ue}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,N=forge.pki.publicKeyFromPem((Y=(G=Me==null?void 0:Me.data)==null?void 0:G.data)==null?void 0:Y.publicKeyPem).encrypt(Pt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),z=forge.util.encode64(N),se={"Content-Type":"application/json","x-app-session-key":(S=(g=Me.data)==null?void 0:g.data)==null?void 0:S.session_key},le=JSON.stringify({enc_track2_data:`${z}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(K=(d=Me==null?void 0:Me.data)==null?void 0:d.data)==null?void 0:K.session_key}`});try{let re=await sn.post(`${gt}tokenizer/tokenize`,le,{headers:se}),Le=JSON.stringify(I(P({},(l=re==null?void 0:re.data)==null?void 0:l.data),{cvv:o==null?void 0:o.cvv,cardName:o==null?void 0:o.cardName,zip:o==null?void 0:o.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),Ie={"Content-Type":"application/json"};try{let ve=await sn.post(`${_e}add-card`,Le,{headers:Ie});console.log(ve),(X=ve==null?void 0:ve.data)!=null&&X.result&&(H(!0),be(),nn(F,"close",""))}catch(ve){be(),B(((Pe=(L=ve==null?void 0:ve.response)==null?void 0:L.data)==null?void 0:Pe.message)||(ve==null?void 0:ve.message)||"Something went wrong.")}}catch(re){be(),B(((dt=(O=re==null?void 0:re.response)==null?void 0:O.data)==null?void 0:dt.message)||(re==null?void 0:re.message)||"Something went wrong.")}}catch(Me){be(),B(((St=(Ve=Me==null?void 0:Me.response)==null?void 0:Ve.data)==null?void 0:St.message)||(Me==null?void 0:Me.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(f==null?void 0:f.dctoken,"creditCardForm",E)}catch(E){be(),B(((yt=(qe=E==null?void 0:E.response)==null?void 0:qe.data)==null?void 0:yt.message)||(E==null?void 0:E.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},oe.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},oe.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},oe.createElement("label",{htmlFor:"cardNumber"},"Card Number"),oe.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(o==null?void 0:o.cardNumber)||"",onChange:F=>Q(F),ref:$}),(b==null?void 0:b.cardNumber)&&oe.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},b==null?void 0:b.cardNumber),oe.createElement("br",null)),oe.createElement("div",{className:"card-dtl"},oe.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},oe.createElement("div",{className:"form-group",style:{marginTop:"0"}},oe.createElement("label",{htmlFor:"expMonth"},"MM"),oe.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:F=>we("expiryMonth",F.target.value),ref:m}),(b==null?void 0:b.expiryMonth)&&oe.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},b==null?void 0:b.expiryMonth)),oe.createElement("div",{className:"form-group",style:{marginTop:"0"}},oe.createElement("label",{htmlFor:"expYear"},"YYYY"),oe.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:F=>we("expiryYear",F.target.value),ref:U}),(b==null?void 0:b.expiryYear)&&oe.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},b==null?void 0:b.expiryYear)),oe.createElement("div",{className:"form-group",style:{marginTop:"0"}},oe.createElement("label",{htmlFor:"cvc"},"CVC"),oe.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(o==null?void 0:o.cvv)||"",onChange:F=>we("cvv",F.target.value),ref:C}),(b==null?void 0:b.cvv)&&oe.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},b==null?void 0:b.cvv)))),oe.createElement("div",{className:"form-group",style:{marginTop:"0"}},oe.createElement("label",{htmlFor:"cardholderName"},"Name on card"),oe.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(o==null?void 0:o.cardName)||"",onChange:F=>{let u=F.target.value;/^[a-zA-Z\s]*$/.test(u)&&we("cardName",u)},ref:x}),(b==null?void 0:b.cardName)&&oe.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},b==null?void 0:b.cardName)),oe.createElement("div",{className:"form-group",style:{marginTop:"0"}},oe.createElement("label",{htmlFor:"zipcode"},"Zip"),oe.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(de=o==null?void 0:o.zipCode)!=null?de:"",onChange:F=>we("zipCode",F.target.value)}),(b==null?void 0:b.zipCode)&&oe.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},b==null?void 0:b.zipCode))),oe.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import A,{useState as yn}from"react";import xn from"axios";var Fn={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import Oi from"react";function qn({}){return Oi.createElement("style",null,`
|
|
1983
1983
|
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap");
|
|
1984
1984
|
|
|
1985
1985
|
.creditformbox {
|
|
@@ -2124,7 +2124,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
2124
2124
|
color:#ffffff !important;
|
|
2125
2125
|
}
|
|
2126
2126
|
|
|
2127
|
-
`)}function Oi({session_token:e,callback:h,isloading:$,onCancel:Z,showChecks:j,merchantName:qe}){var Q;let[q,We]=hn(!1),[ke,Y]=hn(!1),[c,G]=hn(),[v,y]=hn({}),[o,he]=hn(""),x=()=>We(!0),ye=()=>We(!1),f=()=>{var _,u,J,H,g,F,m,K;let C={},p=c,ce=parseInt((p==null?void 0:p.expiryMonth)||"",10),le=(p==null?void 0:p.expiryYear)||"";return(_=p==null?void 0:p.firstName)!=null&&_.trim()||(C.firstName="Please enter a first name."),(u=p==null?void 0:p.lastName)!=null&&u.trim()||(C.lastName="Please enter a last name."),(J=p==null?void 0:p.cardNumber)!=null&&J.trim()||(C.cardNumber="Please enter a card number."),(H=p==null?void 0:p.expiryMonth)!=null&&H.trim()?(Number(p==null?void 0:p.expiryMonth)>12||Number(p==null?void 0:p.expiryMonth)<1)&&(C.expiryMonth="Invalid Expiration Month."):C.expiryMonth="Please enter an expiry month.",(g=p==null?void 0:p.expiryYear)!=null&&g.trim()?((F=p==null?void 0:p.expiryYear)==null?void 0:F.trim().length)!==4||Number(p==null?void 0:p.expiryYear)<2025?C.expiryYear="Invalid Expiration Year.":(isNaN(ce)||ce<1||ce>12||le.length!==4)&&(C.expiryMonth="Invalid Expiration Date."):C.expiryYear="Please enter an expiry year.",(m=p==null?void 0:p.cvv)!=null&&m.trim()||(C.cvv="Please enter a CVV."),(K=p==null?void 0:p.zipCode)!=null&&K.trim()||(C.zipCode="Please enter a zip code."),j&&!(p!=null&&p.authHold)&&(C.authHold="You must authorize this before proceeding."),j&&!(p!=null&&p.authorise)&&(C.authorise="Please confirm your authorization to continue."),y(C),Object.keys(C).length>0},Ue=C=>{let ce=C.target.value.replace(/\D/g,""),le="";/^3[47]/.test(ce)?le=ce.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(u,J,H,g)=>[J,H,g].filter(Boolean).join(" ")):le=ce.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(u,J,H,g,F)=>[J,H,g,F].filter(Boolean).join(" ")),y(_=>A(S({},_),{cardNumber:""})),G(_=>A(S({},_),{cardNumber:le}))},W=(C,p)=>{let ce=C;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(ce)){(p===""||/^[0-9]+$/.test(p))&&(y(_=>A(S({},_),{[ce]:""})),G(_=>A(S({},_),{[ce]:p})));return}y(_=>A(S({},_),{[ce]:""})),G(_=>A(S({},_),{[ce]:p}))},xe=()=>{let C=DatacapWebToken.validateCardNumber(c==null?void 0:c.cardNumber.replaceAll(" ","")),p=DatacapWebToken.validateExpirationDate(c==null?void 0:c.expiryMonth,c==null?void 0:c.expiryYear),ce=DatacapWebToken.validateCVV(c==null?void 0:c.cvv),le={};return C||(le.cardNumber="Invalid card Number"),p||(le.expiryMonth="Invalid Expiration Date."),ce||(le.cvv="Invalid CVV"),y(le),C&&ce&&p},dt=async C=>{var p,ce;if(C.Error)he(C.Error),ye();else{let le={token:C.Token,resp:C},_=await yn.post(`${ve}api/v1/gateway/update/token/${e}`,le);if((_==null?void 0:_.status)==200){let u=S(S({Token:(ce=(p=_==null?void 0:_.data)==null?void 0:p.data)==null?void 0:ce.gateway_token,Brand:C.Brand,ExpirationMonth:C.ExpirationMonth,ExpirationYear:C.ExpirationYear,Last4:C.Last4,Bin:C.Bin,CVV:C.CVV,postalCode:c==null?void 0:c.zipCode},j&&{authHold:c==null?void 0:c.authHold}),j&&{authorise:c==null?void 0:c.authorise});ye(),h(u)}}},Je=async()=>{var C,p,ce,le,_,u,J,H,g,F;try{let m={method:"POST",redirect:"follow"},K=await yn.post(`${ve}api/v1/widget/generate-session`,m),d=Number(c==null?void 0:c.expiryYear)%100,L=`${(C=c==null?void 0:c.cardNumber)==null?void 0:C.replace(/\s+/g,"")}=${d}${c==null?void 0:c.expiryMonth} ${c==null?void 0:c.cvv}`,O=forge.pki.publicKeyFromPem((ce=(p=K==null?void 0:K.data)==null?void 0:p.data)==null?void 0:ce.publicKeyPem).encrypt(L,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),mt=forge.util.encode64(O),Ke={"Content-Type":"application/json","x-app-session-key":(_=(le=K.data)==null?void 0:le.data)==null?void 0:_.session_key},Lt=JSON.stringify({enc_track2_data:mt,algorithm:"RSAES_OAEP_SHA_1",session_key:(J=(u=K==null?void 0:K.data)==null?void 0:u.data)==null?void 0:J.session_key}),$e=await yn.post(`${ft}tokenizer/tokenize`,Lt,{headers:Ke});if(($e==null?void 0:$e.status)==200){let xt=(g=(H=$e==null?void 0:$e.data)==null?void 0:H.data)==null?void 0:g.token;try{let Oe=await yn.post(`${ve}api/v1/gateway/verify-and-save/${e}`,{token:xt});if((Oe==null?void 0:Oe.status)==200){let at=(F=Oe==null?void 0:Oe.data)==null?void 0:F.data,_e={Token:at.gateway_token,Brand:at.card_data.brand,ExpirationMonth:at.card_data.expire_mm,ExpirationYear:at.card_data.expire_yy,Last4:at.card_data.last4,Bin:at.card_data.bin,postalCode:c==null?void 0:c.zipCode};ye(),h(_e)}}catch(Oe){console.log(Oe,"error"),ye()}}}catch(m){console.log(m,"eroror")}},yt=async C=>{var le,_,u,J,H,g,F;if(C.preventDefault(),!(f()||!xe())){x();try{let m=await yn.get(`${ve}api/v1/gateway/token/${e}`);if((m==null?void 0:m.status)==200){let K=(_=(le=m==null?void 0:m.data)==null?void 0:le.data)==null?void 0:_.gateway_token;((J=(u=m==null?void 0:m.data)==null?void 0:u.data)==null?void 0:J.paymentGateway)==((H=_n)==null?void 0:H.FRACTALKEY)?await Je():DatacapWebToken.requestToken(K,"creditCardForm",dt)}}catch(m){ye(),he(((F=(g=m==null?void 0:m.response)==null?void 0:g.data)==null?void 0:F.message)||"Something went wrong!")}}},b=()=>{he("")},we=()=>{he(""),G({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1}),Z()};return T.createElement(T.Fragment,null,T.createElement(Ht,null),T.createElement(Tn,null),T.createElement(St,{loading:q||$}),o&&T.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},T.createElement(Wt,{error:o,onClose:b})),!o&&T.createElement("div",{className:"creditformbox"},T.createElement("form",{id:"creditCardForm",onSubmit:yt},T.createElement("div",{className:"name-row"},T.createElement("div",{className:"form-group"},T.createElement("label",null," First Name ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(c==null?void 0:c.firstName)||"",onChange:C=>{let p=C.target.value;/^[a-zA-Z\s]*$/.test(p)&&W("firstName",p)}}),(v==null?void 0:v.firstName)&&T.createElement("small",{className:"error"},v==null?void 0:v.firstName)),T.createElement("div",{className:"form-group"},T.createElement("label",null," Last Name ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(c==null?void 0:c.lastName)||"",onChange:C=>{let p=C.target.value;/^[a-zA-Z\s]*$/.test(p)&&W("lastName",p)}}),(v==null?void 0:v.lastName)&&T.createElement("small",{className:"error"},v==null?void 0:v.lastName))),T.createElement("div",{className:"form-pay-row"},T.createElement("div",{className:"form-group"},T.createElement("label",null," Card Number ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(c==null?void 0:c.cardNumber)||"",onChange:C=>Ue(C)}),(v==null?void 0:v.cardNumber)&&T.createElement("small",{className:"error"},v==null?void 0:v.cardNumber))),T.createElement("div",{className:"card-pay-row"},T.createElement("div",{className:"form-group"},T.createElement("label",null," Exp Month ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(c==null?void 0:c.expiryMonth)||"",onChange:C=>W("expiryMonth",C.target.value)}),(v==null?void 0:v.expiryMonth)&&T.createElement("small",{className:"error"},v==null?void 0:v.expiryMonth)),T.createElement("div",{className:"form-group"},T.createElement("label",null," Exp Year ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(c==null?void 0:c.expiryYear)||"",onChange:C=>W("expiryYear",C.target.value)}),(v==null?void 0:v.expiryYear)&&T.createElement("small",{className:"error"},v==null?void 0:v.expiryYear)),T.createElement("div",{className:"form-group"},T.createElement("label",null," CVV ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(c==null?void 0:c.cvv)||"",onChange:C=>W("cvv",C.target.value)}),(v==null?void 0:v.cvv)&&T.createElement("small",{className:"error"},v==null?void 0:v.cvv)),T.createElement("div",{className:"form-group"},T.createElement("label",null," Zip ",T.createElement("span",{className:"text-danger"},"*")),T.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(Q=c==null?void 0:c.zipCode)!=null?Q:"",onChange:C=>W("zipCode",C.target.value)}),(v==null?void 0:v.zipCode)&&T.createElement("small",{className:"error"},v==null?void 0:v.zipCode))),j&&T.createElement(T.Fragment,null,T.createElement("div",{className:"checks-row"},T.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(c!=null&&c.authHold),onChange:C=>W("authHold",C.target.checked)}),T.createElement("label",{htmlFor:"authHold",className:"form-check-label"},"To securely save your card on file, we will place a temporary authorization hold of $1.00. This is not a charge and will be released by your card issuer shortly after verification.")),(v==null?void 0:v.authHold)&&T.createElement("small",{className:"check-error"},v==null?void 0:v.authHold),T.createElement("div",{className:"checks-row "},T.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(c!=null&&c.authorise),onChange:C=>W("authorise",C.target.checked)}),T.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},ke?T.createElement(T.Fragment,null,T.createElement("span",null,"By providing your payment information, you authorize"," ",T.createElement("strong",null,qe),", a Sky Systemz merchant, to securely store your card on file for future payments. Your card information will be encrypted and stored in compliance with PCI-DSS (Payment Card Industry Data Security Standard) regulations using Sky Systemz\u2019s secure payment technology. This information will be used solely for transactions you authorize with"," ",T.createElement("strong",null,qe),". You may request the removal of your stored payment information at any time by contacting"," ",T.createElement("strong",null,qe)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",T.createElement("a",{href:"#",onClick:C=>{C.preventDefault(),Y(!1)}},"See less ..."))):T.createElement(T.Fragment,null,T.createElement("span",null,"By providing your payment information, you authorize ",qe,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),T.createElement("a",{href:"#",onClick:C=>{C.preventDefault(),Y(!0)}},"See more ...")))),(v==null?void 0:v.authorise)&&T.createElement("small",{className:"check-error"},v==null?void 0:v.authorise)),T.createElement("div",{className:"button-row"},T.createElement("button",{className:"cancelbtn",type:"button",onClick:we},"Cancel"),T.createElement("button",{className:"savebtn",type:"submit"},"Save")))))}import n,{useEffect as Zi,useState as it}from"react";import Ei from"react";function qn(){let e="#000",h="#fff",$="#212529",Z="#dee2e6";return Ei.createElement("style",null,`
|
|
2127
|
+
`)}function Ei({session_token:e,callback:h,isloading:q,onCancel:Z,showChecks:H,merchantName:Te}){var Q;let[B,Ee]=yn(!1),[Ne,$]=yn(!1),[m,U]=yn(),[C,x]=yn({}),[o,ye]=yn(""),b=()=>Ee(!0),xe=()=>Ee(!1),f=()=>{var F,u,G,Y,g,S,d,K;let w={},p=m,pe=parseInt((p==null?void 0:p.expiryMonth)||"",10),de=(p==null?void 0:p.expiryYear)||"";return(F=p==null?void 0:p.firstName)!=null&&F.trim()||(w.firstName="Please enter a first name."),(u=p==null?void 0:p.lastName)!=null&&u.trim()||(w.lastName="Please enter a last name."),(G=p==null?void 0:p.cardNumber)!=null&&G.trim()||(w.cardNumber="Please enter a card number."),(Y=p==null?void 0:p.expiryMonth)!=null&&Y.trim()?(Number(p==null?void 0:p.expiryMonth)>12||Number(p==null?void 0:p.expiryMonth)<1)&&(w.expiryMonth="Invalid Expiration Month."):w.expiryMonth="Please enter an expiry month.",(g=p==null?void 0:p.expiryYear)!=null&&g.trim()?((S=p==null?void 0:p.expiryYear)==null?void 0:S.trim().length)!==4||Number(p==null?void 0:p.expiryYear)<2025?w.expiryYear="Invalid Expiration Year.":(isNaN(pe)||pe<1||pe>12||de.length!==4)&&(w.expiryMonth="Invalid Expiration Date."):w.expiryYear="Please enter an expiry year.",(d=p==null?void 0:p.cvv)!=null&&d.trim()||(w.cvv="Please enter a CVV."),(K=p==null?void 0:p.zipCode)!=null&&K.trim()||(w.zipCode="Please enter a zip code."),H&&!(p!=null&&p.authHold)&&(w.authHold="You must authorize this before proceeding."),H&&!(p!=null&&p.authorise)&&(w.authorise="Please confirm your authorization to continue."),x(w),Object.keys(w).length>0},Ze=w=>{let pe=w.target.value.replace(/\D/g,""),de="";/^3[47]/.test(pe)?de=pe.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(u,G,Y,g)=>[G,Y,g].filter(Boolean).join(" ")):de=pe.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(u,G,Y,g,S)=>[G,Y,g,S].filter(Boolean).join(" ")),x(F=>I(P({},F),{cardNumber:""})),U(F=>I(P({},F),{cardNumber:de}))},W=(w,p)=>{let pe=w;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(pe)){(p===""||/^[0-9]+$/.test(p))&&(x(F=>I(P({},F),{[pe]:""})),U(F=>I(P({},F),{[pe]:p})));return}x(F=>I(P({},F),{[pe]:""})),U(F=>I(P({},F),{[pe]:p}))},be=()=>{let w=DatacapWebToken.validateCardNumber(m==null?void 0:m.cardNumber.replaceAll(" ","")),p=DatacapWebToken.validateExpirationDate(m==null?void 0:m.expiryMonth,m==null?void 0:m.expiryYear),pe=DatacapWebToken.validateCVV(m==null?void 0:m.cvv),de={};return w||(de.cardNumber="Invalid card Number"),p||(de.expiryMonth="Invalid Expiration Date."),pe||(de.cvv="Invalid CVV"),x(de),w&&pe&&p},lt=async w=>{var p,pe;if(w.Error)ye(w.Error),xe();else{let de={token:w.Token,resp:w},F=await xn.post(`${Ce}api/v1/gateway/update/token/${e}`,de);if((F==null?void 0:F.status)==200){let u=P(P({Token:(pe=(p=F==null?void 0:F.data)==null?void 0:p.data)==null?void 0:pe.gateway_token,Brand:w.Brand,ExpirationMonth:w.ExpirationMonth,ExpirationYear:w.ExpirationYear,Last4:w.Last4,Bin:w.Bin,CVV:w.CVV,postalCode:m==null?void 0:m.zipCode},H&&{authHold:m==null?void 0:m.authHold}),H&&{authorise:m==null?void 0:m.authorise});xe(),h(u)}}},Ue=async()=>{var w,p,pe,de,F,u,G,Y,g,S;try{let d={method:"POST",redirect:"follow"},K=await xn.post(`${Ce}api/v1/widget/generate-session`,d),l=Number(m==null?void 0:m.expiryYear)%100,L=`${(w=m==null?void 0:m.cardNumber)==null?void 0:w.replace(/\s+/g,"")}=${l}${m==null?void 0:m.expiryMonth} ${m==null?void 0:m.cvv}`,O=forge.pki.publicKeyFromPem((pe=(p=K==null?void 0:K.data)==null?void 0:p.data)==null?void 0:pe.publicKeyPem).encrypt(L,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),dt=forge.util.encode64(O),Ve={"Content-Type":"application/json","x-app-session-key":(F=(de=K.data)==null?void 0:de.data)==null?void 0:F.session_key},St=JSON.stringify({enc_track2_data:dt,algorithm:"RSAES_OAEP_SHA_1",session_key:(G=(u=K==null?void 0:K.data)==null?void 0:u.data)==null?void 0:G.session_key}),qe=await xn.post(`${gt}tokenizer/tokenize`,St,{headers:Ve});if((qe==null?void 0:qe.status)==200){let yt=(g=(Y=qe==null?void 0:qe.data)==null?void 0:Y.data)==null?void 0:g.token;try{let Ke=await xn.post(`${Ce}api/v1/gateway/verify-and-save/${e}`,{token:yt});if((Ke==null?void 0:Ke.status)==200){let tt=(S=Ke==null?void 0:Ke.data)==null?void 0:S.data,ke={Token:tt.gateway_token,Brand:tt.card_data.brand,ExpirationMonth:tt.card_data.expire_mm,ExpirationYear:tt.card_data.expire_yy,Last4:tt.card_data.last4,Bin:tt.card_data.bin,postalCode:m==null?void 0:m.zipCode};xe(),h(ke)}}catch(Ke){console.log(Ke,"error"),xe()}}}catch(d){console.log(d,"eroror")}},ht=async w=>{var de,F,u,G,Y,g,S;if(w.preventDefault(),!(f()||!be())){b();try{let d=await xn.get(`${Ce}api/v1/gateway/token/${e}`);if((d==null?void 0:d.status)==200){let K=(F=(de=d==null?void 0:d.data)==null?void 0:de.data)==null?void 0:F.gateway_token;((G=(u=d==null?void 0:d.data)==null?void 0:u.data)==null?void 0:G.paymentGateway)==((Y=Fn)==null?void 0:Y.FRACTALKEY)?await Ue():DatacapWebToken.requestToken(K,"creditCardForm",lt)}}catch(d){xe(),ye(((S=(g=d==null?void 0:d.response)==null?void 0:g.data)==null?void 0:S.message)||"Something went wrong!")}}},v=()=>{ye("")},we=()=>{ye(""),U({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1}),Z()};return A.createElement(A.Fragment,null,A.createElement(jt,null),A.createElement(qn,null),A.createElement(kt,{loading:B||q}),o&&A.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},A.createElement(Ut,{error:o,onClose:v})),!o&&A.createElement("div",{className:"creditformbox"},A.createElement("form",{id:"creditCardForm",onSubmit:ht},A.createElement("div",{className:"name-row"},A.createElement("div",{className:"form-group"},A.createElement("label",null," First Name ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(m==null?void 0:m.firstName)||"",onChange:w=>{let p=w.target.value;/^[a-zA-Z\s]*$/.test(p)&&W("firstName",p)}}),(C==null?void 0:C.firstName)&&A.createElement("small",{className:"error"},C==null?void 0:C.firstName)),A.createElement("div",{className:"form-group"},A.createElement("label",null," Last Name ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(m==null?void 0:m.lastName)||"",onChange:w=>{let p=w.target.value;/^[a-zA-Z\s]*$/.test(p)&&W("lastName",p)}}),(C==null?void 0:C.lastName)&&A.createElement("small",{className:"error"},C==null?void 0:C.lastName))),A.createElement("div",{className:"form-pay-row"},A.createElement("div",{className:"form-group"},A.createElement("label",null," Card Number ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(m==null?void 0:m.cardNumber)||"",onChange:w=>Ze(w)}),(C==null?void 0:C.cardNumber)&&A.createElement("small",{className:"error"},C==null?void 0:C.cardNumber))),A.createElement("div",{className:"card-pay-row"},A.createElement("div",{className:"form-group"},A.createElement("label",null," Exp Month ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(m==null?void 0:m.expiryMonth)||"",onChange:w=>W("expiryMonth",w.target.value)}),(C==null?void 0:C.expiryMonth)&&A.createElement("small",{className:"error"},C==null?void 0:C.expiryMonth)),A.createElement("div",{className:"form-group"},A.createElement("label",null," Exp Year ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(m==null?void 0:m.expiryYear)||"",onChange:w=>W("expiryYear",w.target.value)}),(C==null?void 0:C.expiryYear)&&A.createElement("small",{className:"error"},C==null?void 0:C.expiryYear)),A.createElement("div",{className:"form-group"},A.createElement("label",null," CVV ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(m==null?void 0:m.cvv)||"",onChange:w=>W("cvv",w.target.value)}),(C==null?void 0:C.cvv)&&A.createElement("small",{className:"error"},C==null?void 0:C.cvv)),A.createElement("div",{className:"form-group"},A.createElement("label",null," Zip ",A.createElement("span",{className:"text-danger"},"*")),A.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(Q=m==null?void 0:m.zipCode)!=null?Q:"",onChange:w=>W("zipCode",w.target.value)}),(C==null?void 0:C.zipCode)&&A.createElement("small",{className:"error"},C==null?void 0:C.zipCode))),H&&A.createElement(A.Fragment,null,A.createElement("div",{className:"checks-row"},A.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(m!=null&&m.authHold),onChange:w=>W("authHold",w.target.checked)}),A.createElement("label",{htmlFor:"authHold",className:"form-check-label"},"To securely save your card on file, we will place a temporary authorization hold of $1.00. This is not a charge and will be released by your card issuer shortly after verification.")),(C==null?void 0:C.authHold)&&A.createElement("small",{className:"check-error"},C==null?void 0:C.authHold),A.createElement("div",{className:"checks-row "},A.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(m!=null&&m.authorise),onChange:w=>W("authorise",w.target.checked)}),A.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},Ne?A.createElement(A.Fragment,null,A.createElement("span",null,"By providing your payment information, you authorize"," ",A.createElement("strong",null,Te),", a Sky Systemz merchant, to securely store your card on file for future payments. Your card information will be encrypted and stored in compliance with PCI-DSS (Payment Card Industry Data Security Standard) regulations using Sky Systemz\u2019s secure payment technology. This information will be used solely for transactions you authorize with"," ",A.createElement("strong",null,Te),". You may request the removal of your stored payment information at any time by contacting"," ",A.createElement("strong",null,Te)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",A.createElement("a",{href:"#",onClick:w=>{w.preventDefault(),$(!1)}},"See less ..."))):A.createElement(A.Fragment,null,A.createElement("span",null,"By providing your payment information, you authorize ",Te,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),A.createElement("a",{href:"#",onClick:w=>{w.preventDefault(),$(!0)}},"See more ...")))),(C==null?void 0:C.authorise)&&A.createElement("small",{className:"check-error"},C==null?void 0:C.authorise)),A.createElement("div",{className:"button-row"},A.createElement("button",{className:"cancelbtn",type:"button",onClick:we},"Cancel"),A.createElement("button",{className:"savebtn",type:"submit"},"Save")))))}import n,{useEffect as Wi,useState as et}from"react";import Zi from"react";function $n(){let e="#000",h="#fff",q="#212529",Z="#dee2e6";return Zi.createElement("style",null,`
|
|
2128
2128
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
2129
2129
|
body
|
|
2130
2130
|
{
|
|
@@ -2357,7 +2357,7 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
2357
2357
|
font-size: 1rem;
|
|
2358
2358
|
font-weight: 400;
|
|
2359
2359
|
line-height: 1.5;
|
|
2360
|
-
color: ${
|
|
2360
|
+
color: ${q};
|
|
2361
2361
|
-webkit-appearance: none;
|
|
2362
2362
|
-moz-appearance: none;
|
|
2363
2363
|
appearance: none;
|
|
@@ -2751,4 +2751,4 @@ var ni=Object.defineProperty,ii=Object.defineProperties;var ai=Object.getOwnProp
|
|
|
2751
2751
|
|
|
2752
2752
|
|
|
2753
2753
|
|
|
2754
|
-
`)}import ht from"axios";import{IoArrowBack as Dn}from"react-icons/io5";import sn from"sweetalert2";var Wi=({amount:e,submitBtnText:h="Pay",session_token:$,customerId:Z,callback:j,merchantName:qe="merchant",isPreAuth:q,surcharge:We="0",submitBtnClass:ke,submitBtnIcon:Y})=>{var vt,Ct,wt,De,ue,gt,Nt,Kt,He,Ot,kt,Be,Ee,Gt;let[c,G]=it("card"),[v,y]=it("card"),[o,he]=it(),[x,ye]=it({}),[f,Ue]=it(),[W,xe]=it({}),[dt,Je]=it(!1),[yt,b]=it(!1),[we,Q]=it(!1),[C,p]=it(""),[ce,le]=it(!1),[_,u]=it(""),[J,H]=it(!1),[g,F]=it(!1),[m,K]=it([]),[d,X]=it(),[L,Me]=it(),O=R+"widget/mc-img.svg",mt=R+"widget/visa-img.svg",Ke=R+"widget/ae-img.svg",Lt=R+"widget/discover-img.svg",$e=R+"widget/card.svg",xt=R+"widget/Trash.svg",Oe=R+"widget/bank.svg",at=R+"widget/secure-img.png",_e=R+"widget/pov-by.png",qt=R+"widget/pax.svg",E=R+"widget/cardicon.svg",ot=R+"widget/bankicon.svg",Le=()=>H(!0),pe=()=>H(!1),rt=async r=>{var l,V,te,s,i,N,M,I;console.log(r,"ndfkjhdskjfhds");try{let U={pass_fee_amount:We,Token:r==null?void 0:r.Token,amount:e,postal_code:r==null?void 0:r.postalCode},B=await ht.post(`${ve}api/v1/gateway/charge/${$}`,U);if((l=B==null?void 0:B.data)!=null&&l.result){let D={};if(we&&Z)try{let ee={postal_code:o==null?void 0:o.zipCode,customer_id:Z,gateway_token:(r==null?void 0:r.gateway_token)||(r==null?void 0:r.Token)},se=await ht.post(`${ve}api/v1/gateway/add-card/${$}`,ee);(V=se==null?void 0:se.data)!=null&&V.result&&(se=(te=se==null?void 0:se.data)==null?void 0:te.data)}catch(ee){console.log(ee,"error"),pe(),p(((i=(s=ee==null?void 0:ee.response)==null?void 0:s.data)==null?void 0:i.message)||"Something went wrong!")}let ne={cardDetails:S(S({},D),r),callback:A(S({},(N=B==null?void 0:B.data)==null?void 0:N.data),{name:o==null?void 0:o.cardName,isPreAuth:q})};we||delete ne.cardDetails,j(ne),pe(),Ye()}}catch(U){p(((I=(M=U==null?void 0:U.response)==null?void 0:M.data)==null?void 0:I.message)||"Something went wrong!"),pe()}},zt=async r=>{var l,V,te,s,i,N,M,I;try{let U={Token:r==null?void 0:r.Token,amount:e,postal_code:r==null?void 0:r.postalCode},B=await ht.post(`${ve}api/v1/gateway/preauth/${$}`,U);if((l=B==null?void 0:B.data)!=null&&l.result){let D={};if(we&&Z)try{let ee={postal_code:o==null?void 0:o.zipCode,customer_id:Z,gateway_token:r==null?void 0:r.gateway_token},se=await ht.post(`${ve}api/v1/gateway/add-card/${$}`,ee);(V=se==null?void 0:se.data)!=null&&V.result&&(se=(te=se==null?void 0:se.data)==null?void 0:te.data)}catch(ee){console.log(ee,"error"),pe(),p(((i=(s=ee==null?void 0:ee.response)==null?void 0:s.data)==null?void 0:i.message)||"Something went wrong!")}let ne={cardDetails:S(S({},D),r),callback:A(S({},(N=B==null?void 0:B.data)==null?void 0:N.data),{name:o==null?void 0:o.cardName,isPreAuth:q})};we||delete ne.cardDetails,j(ne),pe(),Ye()}}catch(U){p(((I=(M=U==null?void 0:U.response)==null?void 0:M.data)==null?void 0:I.message)||"Something went wrong!"),pe()}},Vt=async r=>{var l,V,te,s;if(r.Error)p(r.Error),pe();else{let i={token:r.Token,resp:r};try{let N=await ht.post(`${ve}api/v1/gateway/update/token/${$}`,i);if((N==null?void 0:N.status)==200){let M={Token:(V=(l=N==null?void 0:N.data)==null?void 0:l.data)==null?void 0:V.gateway_token,Brand:r.Brand,ExpirationMonth:r.ExpirationMonth,ExpirationYear:r.ExpirationYear,Last4:r.Last4,Bin:r.Bin,CVV:r.CVV,postalCode:o==null?void 0:o.zipCode},I;q?zt(M):rt(M)}}catch(N){console.log(N,"error"),pe(),p(((s=(te=N==null?void 0:N.response)==null?void 0:te.data)==null?void 0:s.message)||"Something went wrong!")}}},w=()=>b(!0),z=r=>{G(r)},oe=()=>{var V,te,s,i,N,M,I,U;let r={},l=f;return(V=l==null?void 0:l.name)!=null&&V.trim()||(r.name="Name is required"),(te=l==null?void 0:l.accountNumber)!=null&&te.trim()||(r.accountNumber="Account number is required"),(s=l==null?void 0:l.accountNumber)!=null&&s.trim()&&((i=l==null?void 0:l.accountNumber)==null?void 0:i.trim())!==((N=l==null?void 0:l.confirmAccountNumber)==null?void 0:N.trim())&&(r.confirmAccountNumber="Account numbers must match"),(M=l==null?void 0:l.bankName)!=null&&M.trim()||(r.bankName="Bank name is required"),(I=l==null?void 0:l.routingNumber)!=null&&I.trim()||(r.routingNumber="Routing Number is required"),l!=null&&l.routingNumber&&((U=l==null?void 0:l.routingNumber)==null?void 0:U.length)!==9&&(r.routingNumber="Routing number must be 9 digits"),((l==null?void 0:l.accountType)==="business saving"||(l==null?void 0:l.accountType)==="business checking")&&(!(l!=null&&l.companyName)||(l==null?void 0:l.companyName)==="")&&(r.companyName="Company Name is required for business accounts"),xe(r),Object.keys(r).length>0},re=async()=>{var r,l,V,te,s,i,N,M,I,U,B,D,ne,ee,se,Ne;try{let de={method:"POST",redirect:"follow"},Re=await ht.post(`${ve}api/v1/widget/generate-session`,de),_t=Number(o==null?void 0:o.expiryYear)%100,Ce=`${(r=o==null?void 0:o.cardNumber)==null?void 0:r.replace(/\s+/g,"")}=${_t}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,$t=forge.pki.publicKeyFromPem((V=(l=Re==null?void 0:Re.data)==null?void 0:l.data)==null?void 0:V.publicKeyPem).encrypt(Ce,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),je=forge.util.encode64($t),Et={"Content-Type":"application/json","x-app-session-key":(s=(te=Re.data)==null?void 0:te.data)==null?void 0:s.session_key},Yt=JSON.stringify({enc_track2_data:je,algorithm:"RSAES_OAEP_SHA_1",session_key:(N=(i=Re==null?void 0:Re.data)==null?void 0:i.data)==null?void 0:N.session_key}),et=await ht.post(`${ft}tokenizer/tokenize`,Yt,{headers:Et});if((et==null?void 0:et.status)==200){let tt=(I=(M=et==null?void 0:et.data)==null?void 0:M.data)==null?void 0:I.token;try{let lt=await ht.post(`${ve}api/v1/gateway/verify-and-save/${$}`,{token:tt});if((lt==null?void 0:lt.status)==200){let Ge=(U=lt==null?void 0:lt.data)==null?void 0:U.data,Ze={Token:Ge.gateway_token,Brand:Ge.card_data.brand,ExpirationMonth:Ge.card_data.expire_mm,ExpirationYear:Ge.card_data.expire_yy,Last4:Ge.card_data.last4,Bin:Ge.card_data.bin,postalCode:o==null?void 0:o.zipCode},Rt;if(we&&Z)try{let Xe={postal_code:o==null?void 0:o.zipCode,customer_id:Z,gateway_token:Ge.gateway_token};Rt=await ht.post(`${ve}api/v1/gateway/add-card/${$}`,Xe)}catch(Xe){console.log(Xe,"error"),pe(),p(((D=(B=Xe==null?void 0:Xe.response)==null?void 0:B.data)==null?void 0:D.message)||"Something went wrong!")}q?zt(Ze):rt(Ze)}}catch(lt){console.log(lt,"error"),p(((ee=(ne=lt==null?void 0:lt.response)==null?void 0:ne.data)==null?void 0:ee.message)||"Something went wrong!"),pe()}}}catch(de){pe(),console.log(de,"error"),p(((Ne=(se=de==null?void 0:de.response)==null?void 0:se.data)==null?void 0:Ne.message)||"Something went wrong!")}},ae=()=>{var s,i,N,M,I,U;let r={},l=o,V=parseInt((l==null?void 0:l.expiryMonth)||"",10),te=(l==null?void 0:l.expiryYear)||"";if((s=l==null?void 0:l.cardName)!=null&&s.trim()||(r.cardName="Card name is required"),(i=l==null?void 0:l.cardNumber)!=null&&i.trim()||(r.cardNumber="Card number is required"),(!((N=l==null?void 0:l.expiryMonth)!=null&&N.trim())||!((M=l==null?void 0:l.expiryYear)!=null&&M.trim())||isNaN(V)||V<1||V>12||te.length!==4)&&(r.expiryMonth="Invalid Expiration Date."),(I=l==null?void 0:l.cvv)!=null&&I.trim()||(r.cvv="CVV is required"),(U=l==null?void 0:l.zipCode)!=null&&U.trim()||(r.zipCode="ZIP code is required"),l!=null&&l.expiryMonth&&(l!=null&&l.expiryYear)&&l.expiryMonth.length<=2&&l.expiryYear.length===4){let B=parseInt(l.expiryMonth,10),D=parseInt(l.expiryYear,10),ne=new Date,ee=ne.getMonth()+1,se=ne.getFullYear();(D<se||D===se&&B<ee)&&(r.expiryMonth="Card is expired")}return ye(r),Object.keys(r).length>0},ze=async r=>{var l,V,te,s,i,N,M,I,U,B,D,ne,ee,se,Ne;if(r.preventDefault(),c!=="ach"){if(ae())return}else if(oe())return;try{Le();let de=await ht.get(`${ve}api/v1/gateway/token/${$}`);if((de==null?void 0:de.status)==200){let Re=(V=(l=de==null?void 0:de.data)==null?void 0:l.data)==null?void 0:V.gateway_token,_t=(s=(te=de==null?void 0:de.data)==null?void 0:te.data)==null?void 0:s.paymentGateway;if(c!=="ach")_t==((i=_n)==null?void 0:i.FRACTALKEY)?await re():DatacapWebToken.requestToken(Re,"PaymentForm",Vt);else{let Bt;try{let Ce=await ht.post(`${ve}api/v1/gateway/bank-charge/${$}`,{label:f==null?void 0:f.name,account_number:f==null?void 0:f.accountNumber,routing_number:f==null?void 0:f.routingNumber,bank_name:f==null?void 0:f.bankName,account_type:f==null?void 0:f.accountType,amount:e,customer_id:null,isSaveAch:!1,tax:"0.00",discount:"0.00",surcharge:"0.00",order_id:"",company_name:(f==null?void 0:f.companyName)||""});if((N=Ce==null?void 0:Ce.data)!=null&&N.result){if(dt&&Z)try{let Se=await ht.post(`${ve}api/v1/gateway/add-bank/${$}`,{name:f==null?void 0:f.name,account_number:f==null?void 0:f.accountNumber,routing_number:f==null?void 0:f.routingNumber,bank_name:f==null?void 0:f.bankName,account_type:f==null?void 0:f.accountType,customer_id:Z||"",company_name:(f==null?void 0:f.companyName)||""});Se.data.result&&(Bt={bankDetails:A(S({},(M=Se==null?void 0:Se.data)==null?void 0:M.data),{account_type:f==null?void 0:f.accountType})})}catch(Se){pe(),p(((U=(I=Se==null?void 0:Se.response)==null?void 0:I.data)==null?void 0:U.message)||"Something went wrong!")}Bt=A(S({},Bt),{callback:A(S({},(B=Ce==null?void 0:Ce.data)==null?void 0:B.data),{name:f==null?void 0:f.name,isPreAuth:q})}),j(Bt),Ye(),pe()}}catch(Ce){console.log(Ce,"errororor");let Se=(D=Ce==null?void 0:Ce.response)==null?void 0:D.data;typeof(Se==null?void 0:Se.message)=="object"?Object.values(Se==null?void 0:Se.message).forEach($t=>{p($t||"Something went wrong")}):p((Se==null?void 0:Se.message)||"Something went wrong"),pe()}}}}catch(de){pe(),j({error:((ee=(ne=de==null?void 0:de.response)==null?void 0:ne.data)==null?void 0:ee.message)||"Something went wrong!"}),p(((Ne=(se=de==null?void 0:de.response)==null?void 0:se.data)==null?void 0:Ne.message)||"Something went wrong!")}},Ae=(r,l)=>{let V=r;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(V)){(l===""||/^[0-9]+$/.test(l))&&(ye(s=>A(S({},s),{[V]:""})),he(s=>A(S({},s),{[V]:l})));return}ye(s=>A(S({},s),{[V]:""})),he(s=>A(S({},s),{[V]:l}))},be=r=>{let V=r.target.value.replace(/\D/g,""),te="";/^3[47]/.test(V)?te=V.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(i,N,M,I)=>[N,M,I].filter(Boolean).join(" ")):te=V.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(i,N,M,I,U)=>[N,M,I,U].filter(Boolean).join(" ")),ye(s=>A(S({},s),{cardNumber:""})),he(s=>A(S({},s),{cardNumber:te}))},Ie=r=>{let{name:l,value:V}=r.target,te=["routingNumber","accountNumber","confirmAccountNumber"];if(l=="name"){/^[a-zA-Z\s]*$/.test(V)&&(xe(s=>A(S({},s),{[l]:""})),Ue(s=>A(S({},s),{[l]:V})));return}if(te.includes(l)){(V===""||/^[0-9]+$/.test(V))&&(xe(s=>A(S({},s),{[l]:""})),Ue(s=>A(S({},s),{[l]:V})));return}xe(s=>A(S({},s),{[l]:""})),Ue(s=>A(S({},s),{[l]:V}))},Ye=()=>{b(!1),G("card"),p(""),le(!1),u(""),Ue({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),xe({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),he({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),ye({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Je(!1),Q(!1),K([])},ct=async()=>{var r,l,V,te,s,i,N,M,I;Le();try{let U={isPreAuth:q,customerId:Z},B=await ht.post(`${ve}api/v1/gateway/card-list/${$}`,U);if(console.log("paymentData",B),(l=(r=B==null?void 0:B.data)==null?void 0:r.data)!=null&&l.cardList&&((s=(te=(V=B==null?void 0:B.data)==null?void 0:V.data)==null?void 0:te.cardList)==null?void 0:s.length)>0){G("cardList");let D=(N=(i=B==null?void 0:B.data)==null?void 0:i.data)==null?void 0:N.cardList;K(D);let ne=D==null?void 0:D.find(ee=>(ee==null?void 0:ee.primary_card)==1);ne&&X(ne)}else G("card");pe()}catch(U){console.log(U),pe(),p(((I=(M=U==null?void 0:U.response)==null?void 0:M.data)==null?void 0:I.message)||(U==null?void 0:U.message)||"Something went wrong")}},pt=r=>{switch(r==null?void 0:r.toLowerCase()){case"visa":return mt;case"mastercard":case"mc":case"m/c":return O;case"amex":case"american express":case"ae":return Ke;case"discover":case"dcvr":return Lt;case"bank":return Oe;default:return r}},st=async r=>{sn.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 l=>{var V,te;if(l.isConfirmed){F(!0);try{let s={card_id:r,customer_id:Z},i=await ht.patch(`${ve}api/v1/gateway/delete-card/${$}`,s);(V=i==null?void 0:i.data)!=null&&V.result?(F(!1),ct(),sn.fire({icon:"success",title:"Deleted!",text:((te=i==null?void 0:i.data)==null?void 0:te.message)||"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})):(F(!1),sn.fire({icon:"error",title:"Failure!",text:"Card not deleted.",timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}}))}catch(s){F(!1),sn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else l.dismiss===sn.DismissReason.cancel&&sn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},ut=async()=>{var te,s,i,N;let r=Z,l=d==null?void 0:d.id,V=d==null?void 0:d.card_type;if(e)if(r)if(l){let M={amount:e,customer_id:r,card_id:l};q&&(M.isPreauth=!0);let I=ve+"api/v1/gateway/charge-by-saved-details/"+$,U={"Content-Type":"application/json"};try{Le();let B=await ht.post(I,M);console.log(B,"res"),(te=B==null?void 0:B.data)!=null&&te.result&&(j({callback:(s=B==null?void 0:B.data)==null?void 0:s.data}),pe(),Ye())}catch(B){console.log(B==null?void 0:B.response,"error by saved details"),pe(),p(((N=(i=B==null?void 0:B.response)==null?void 0:i.data)==null?void 0:N.message)||"Something went wrong!")}}else p("Please Select A Card/ACH");else p("Please Select Customer");else p("Something went wrong.")};Zi(()=>{Z&&yt&&ct()},[Z,yt]);let bt=()=>q?"Cards":"Cards/Bank";return n.createElement(n.Fragment,null,n.createElement("link",{href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}),n.createElement(Ht,null),n.createElement(qn,null),n.createElement("button",{className:ke||"paymentBtn",onClick:w},h,Y),n.createElement(Tt,{open:yt,onClose:Ye},C&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(Wt,{error:C,onClose:Ye})),!C&&n.createElement(n.Fragment,null,(J||g)&&n.createElement(St,{loading:J||g}),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:Ye},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-main-logo-res"}),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("h1",{className:"pay-heading"},"Pay"),(m==null?void 0:m.length)>0&&c!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>G("cardList")}," ",n.createElement(Dn,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"},Dt((vt=Number(e))==null?void 0:vt.toFixed(2)))),c!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},n.createElement("img",{src:mt,alt:"",width:33}),n.createElement("img",{src:O,width:33,alt:""}),n.createElement("img",{src:Ke,alt:"",width:33}),n.createElement("img",{src:Lt,width:33,alt:""})))),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:at,alt:""}),n.createElement("img",{src:_e,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},c!=="cardList"?n.createElement("div",null,(m==null?void 0:m.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>G("cardList")}," ",n.createElement(Dn,null)," Back"),!q&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks cardicon-img",onClick:r=>{z("card")},style:{border:c==="card"?"1px solid":"",display:"flex",justifyContent:"center",alignItems:"center"}},n.createElement("img",{className:"cardicon",src:E}),"Card"),n.createElement("button",{className:"tablinks bankicon-img",onClick:r=>{z("ach")},style:{border:c==="ach"?"1px solid":"",display:"flex",justifyContent:"center",alignItems:"center"}},n.createElement("img",{className:"bankicon",src:ot}),"Bank")),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"},Dt((Ct=Number(e))==null?void 0:Ct.toFixed(2)))),c!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:mt,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:O,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:Ke,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Lt,width:35,alt:""}))))):n.createElement("div",null,n.createElement("div",{className:"charge-customer-name-frac",style:{marginBottom:"16px !important"}}," Charge ",L==null?void 0:L.customer_name),n.createElement("div",{className:"card-ach-heading-frac",style:{marginBottom:"10px !important"}}," ",v==="card"?bt():"Readers"," "),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"},Dt((wt=Number(e))==null?void 0:wt.toFixed(2)))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:mt,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:O,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:Ke,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Lt,width:35,alt:""}))))),n.createElement("div",{id:"ach",style:{display:c==="cardList"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"card-lint-div-in"},n.createElement("div",{className:"card-list-div"},m&&(m==null?void 0:m.length)>0&&(m==null?void 0:m.map((r,l)=>n.createElement("div",{className:"card-list-single-div",key:l},n.createElement("div",{className:"card-number-radio"},n.createElement("input",{disabled:(L==null?void 0:L.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:d===r,onChange:V=>X(r)}),n.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",r==null?void 0:r.cardlastfourdigit),(r==null?void 0:r.card_type)!="Bank"&&n.createElement("h6",{className:"card-expiry-date"},r==null?void 0:r.expmonth,"/",r==null?void 0:r.expyear)),n.createElement("div",{className:"card-number-radio"},n.createElement("span",{className:"visa-card"},n.createElement("img",{src:pt(r==null?void 0:r.card_type),alt:""})),n.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>st(r==null?void 0:r.id)},n.createElement("img",{src:xt,alt:""}))))))),n.createElement("div",{className:"pay-with-other-card",onClick:()=>G("card")},"Pay With Other Card",n.createElement("img",{src:$e,alt:""}))),n.createElement("div",{className:"form-group-frac",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:ut},Dt((De=Number(e))==null?void 0:De.toFixed(2))))),n.createElement("div",{id:"ach",style:{display:c==="card"?"block":"none"},className:"tabcontent"},n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:ze},n.createElement("div",{className:"ach-scrl",style:{minHeight:"398px",maxHeight:"398px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group-frac"},n.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),n.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"John Doe",value:(o==null?void 0:o.cardName)||"",onChange:r=>{let l=r.target.value;/^[a-zA-Z\s]*$/.test(l)&&Ae("cardName",l)}}),(x==null?void 0:x.cardName)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.cardName)),n.createElement("div",{className:"form-group-frac"},n.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control-frac card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(o==null?void 0:o.cardNumber)||"",onChange:r=>be(r),"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-frac"},n.createElement("input",{"data-token":"exp_month",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:r=>Ae("expiryMonth",r.target.value)})),n.createElement("div",{className:"exp-year form-group-frac"},n.createElement("input",{"data-token":"exp_year",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:r=>Ae("expiryYear",r.target.value)})),n.createElement("div",{className:"security-digit form-group-frac"},n.createElement("input",{"data-token":"cvv",className:"form-control-frac card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(o==null?void 0:o.cvv)||"",onChange:r=>Ae("cvv",r.target.value)})))),(x==null?void 0:x.cardNumber)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.cardNumber),n.createElement("p",{style:{margin:"0"}},x!=null&&x.expiryMonth||x!=null&&x.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},x==null?void 0:x.expiryMonth):"",(x==null?void 0:x.cvv)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.cvv)))),n.createElement("div",{className:"form-group-frac"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"000000",value:(ue=o==null?void 0:o.zipCode)!=null?ue:"",onChange:r=>Ae("zipCode",r.target.value)}),(x==null?void 0:x.zipCode)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.zipCode)),Z&&n.createElement("div",{className:"form-group-frac"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:we,onChange:r=>Q(r.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-frac",style:{marginTop:"20px",padding:"0"}},n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Dt((gt=Number(e))==null?void 0:gt.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:c==="ach"?"block":"none"},className:"tabcontent"},n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:ze},n.createElement("div",{className:"ach-scrl",style:{minHeight:"358px",maxHeight:"378px"}},n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),n.createElement("input",{type:"text",id:"nameonaccount",className:"form-control-frac",maxLength:100,placeholder:"John Doe",name:"name",value:(Nt=f==null?void 0:f.name)!=null?Nt:"",onChange:Ie}),(W==null?void 0:W.name)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.name)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"routingnumber"},"Routing number"),n.createElement("input",{type:"text",id:"routingnumber",className:"form-control-frac",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(Kt=f==null?void 0:f.routingNumber)!=null?Kt:"",onChange:Ie}),(W==null?void 0:W.routingNumber)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.routingNumber)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"accountnumber"},"Account number"),n.createElement("input",{type:"text",id:"accountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(He=f==null?void 0:f.accountNumber)!=null?He:"",onChange:Ie}),(W==null?void 0:W.accountNumber)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.accountNumber)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),n.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Ot=f==null?void 0:f.confirmAccountNumber)!=null?Ot:"",onChange:Ie}),(W==null?void 0:W.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.confirmAccountNumber)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"bankname"},"Bank name"),n.createElement("input",{type:"text",id:"bankname",className:"form-control-frac",maxLength:100,placeholder:"My Bank",name:"bankName",value:(kt=f==null?void 0:f.bankName)!=null?kt:"",onChange:Ie}),(W==null?void 0:W.bankName)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.bankName)),((f==null?void 0:f.accountType)==="business saving"||(f==null?void 0:f.accountType)==="business checking")&&n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"companyName"},"Company name"),n.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(Be=f==null?void 0:f.companyName)!=null?Be:"",onChange:Ie}),(W==null?void 0:W.companyName)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.companyName)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"accounttype"},"Select account type"),n.createElement("select",{name:"accountType",id:"accounttype",className:"form-control-frac",value:(Ee=f==null?void 0:f.accountType)!=null?Ee:"",onChange:Ie},n.createElement("option",{value:""},"Select account"),Nn.map(r=>n.createElement("option",{key:r.value,value:r.value},r.label)))),Z&&n.createElement("div",{className:"form-group-frac mb-4 save-ach-div",style:{paddingTop:"5px"}},n.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:dt,onChange:r=>Je(r.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),dt&&n.createElement("div",{className:"form-group-frac mb-4 saveachtext"},n.createElement("p",null,"If checked, I agree for ",n.createElement("b",null,qe||"merchant")," to have my permission to charge this credit card for agreed upon purchases in the future."))),n.createElement("div",{className:"form-group-frac "},n.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Dt((Gt=Number(e))==null?void 0:Gt.toFixed(2)))))))))))))))};export{Vi as AddCard,Oi as CardOnFile,Bi as GetPaymentPage,Wi as PaymentWidget,Ti as PreAuthPayment,yi as RequestPayment,Ci as RequestPreAuthPayment};
|
|
2754
|
+
`)}import ft from"axios";import{IoArrowBack as Rn}from"react-icons/io5";import ln from"sweetalert2";var Ui=({amount:e,submitBtnText:h="Pay",session_token:q,customerId:Z,callback:H,merchantName:Te="merchant",isPreAuth:B,surcharge:Ee="0",submitBtnClass:Ne,submitBtnIcon:$})=>{var Mt,bt,vt,Qe,ge,ut,Ct,Ot,Ye,Et,wt,Ae,Oe,Jt;let[m,U]=et("card"),[C,x]=et("card"),[o,ye]=et(),[b,xe]=et({}),[f,Ze]=et(),[W,be]=et({}),[lt,Ue]=et(!1),[ht,v]=et(!1),[we,Q]=et(!1),[w,p]=et(""),[pe,de]=et(!1),[F,u]=et(""),[G,Y]=et(!1),[g,S]=et(!1),[d,K]=et([]),[l,X]=et(),[L,Pe]=et(),O=te+"widget/mc-img.svg",dt=te+"widget/visa-img.svg",Ve=te+"widget/ae-img.svg",St=te+"widget/discover-img.svg",qe=te+"widget/card.svg",yt=te+"widget/Trash.svg",Ke=te+"widget/bank.svg",tt=te+"widget/secure-img.png",ke=te+"widget/pov-by.png",Yt=te+"widget/pax.svg",E=te+"widget/cardicon.svg",nt=te+"widget/bankicon.svg",Me=()=>Y(!0),ue=()=>Y(!1),it=async r=>{var s,j,ie,V,c,i,y,J;console.log(r,"ndfkjhdskjfhds");try{let k={pass_fee_amount:Ee,Token:r==null?void 0:r.Token,amount:e,postal_code:r==null?void 0:r.postalCode},T=await ft.post(`${Ce}api/v1/gateway/charge/${q}`,k);if((s=T==null?void 0:T.data)!=null&&s.result){let D={};if(we&&Z)try{let ee={postal_code:o==null?void 0:o.zipCode,customer_id:Z,gateway_token:(r==null?void 0:r.gateway_token)||(r==null?void 0:r.Token)},ne=await ft.post(`${Ce}api/v1/gateway/add-card/${q}`,ee);(j=ne==null?void 0:ne.data)!=null&&j.result&&(ne=(ie=ne==null?void 0:ne.data)==null?void 0:ie.data)}catch(ee){console.log(ee,"error"),ue(),p(((c=(V=ee==null?void 0:ee.response)==null?void 0:V.data)==null?void 0:c.message)||"Something went wrong!")}let ae={cardDetails:P(P({},D),r),callback:I(P({},(i=T==null?void 0:T.data)==null?void 0:i.data),{name:o==null?void 0:o.cardName,isPreAuth:B})};we||delete ae.cardDetails,H(ae),ue(),$e()}}catch(k){p(((J=(y=k==null?void 0:k.response)==null?void 0:y.data)==null?void 0:J.message)||"Something went wrong!"),ue()}},Pt=async r=>{var s,j,ie,V,c,i,y,J;try{let k={Token:r==null?void 0:r.Token,amount:e,postal_code:r==null?void 0:r.postalCode},T=await ft.post(`${Ce}api/v1/gateway/preauth/${q}`,k);if((s=T==null?void 0:T.data)!=null&&s.result){let D={};if(we&&Z)try{let ee={postal_code:o==null?void 0:o.zipCode,customer_id:Z,gateway_token:r==null?void 0:r.gateway_token},ne=await ft.post(`${Ce}api/v1/gateway/add-card/${q}`,ee);(j=ne==null?void 0:ne.data)!=null&&j.result&&(ne=(ie=ne==null?void 0:ne.data)==null?void 0:ie.data)}catch(ee){console.log(ee,"error"),ue(),p(((c=(V=ee==null?void 0:ee.response)==null?void 0:V.data)==null?void 0:c.message)||"Something went wrong!")}let ae={cardDetails:P(P({},D),r),callback:I(P({},(i=T==null?void 0:T.data)==null?void 0:i.data),{name:o==null?void 0:o.cardName,isPreAuth:B})};we||delete ae.cardDetails,H(ae),ue(),$e()}}catch(k){p(((J=(y=k==null?void 0:k.response)==null?void 0:y.data)==null?void 0:J.message)||"Something went wrong!"),ue()}},Kt=async r=>{var s,j,ie,V;if(r.Error)p(r.Error),ue();else{let c={token:r.Token,resp:r};try{let i=await ft.post(`${Ce}api/v1/gateway/update/token/${q}`,c);if((i==null?void 0:i.status)==200){let y={Token:(j=(s=i==null?void 0:i.data)==null?void 0:s.data)==null?void 0:j.gateway_token,Brand:r.Brand,ExpirationMonth:r.ExpirationMonth,ExpirationYear:r.ExpirationYear,Last4:r.Last4,Bin:r.Bin,CVV:r.CVV,postalCode:o==null?void 0:o.zipCode},J;B?Pt(y):it(y)}}catch(i){console.log(i,"error"),ue(),p(((V=(ie=i==null?void 0:i.response)==null?void 0:ie.data)==null?void 0:V.message)||"Something went wrong!")}}},N=()=>v(!0),z=r=>{U(r)},se=()=>{var j,ie,V,c,i,y,J,k;let r={},s=f;return(j=s==null?void 0:s.name)!=null&&j.trim()||(r.name="Name is required"),(ie=s==null?void 0:s.accountNumber)!=null&&ie.trim()||(r.accountNumber="Account number is required"),(V=s==null?void 0:s.accountNumber)!=null&&V.trim()&&((c=s==null?void 0:s.accountNumber)==null?void 0:c.trim())!==((i=s==null?void 0:s.confirmAccountNumber)==null?void 0:i.trim())&&(r.confirmAccountNumber="Account numbers must match"),(y=s==null?void 0:s.bankName)!=null&&y.trim()||(r.bankName="Bank name is required"),(J=s==null?void 0:s.routingNumber)!=null&&J.trim()||(r.routingNumber="Routing Number is required"),s!=null&&s.routingNumber&&((k=s==null?void 0:s.routingNumber)==null?void 0:k.length)!==9&&(r.routingNumber="Routing number must be 9 digits"),((s==null?void 0:s.accountType)==="business saving"||(s==null?void 0:s.accountType)==="business checking")&&(!(s!=null&&s.companyName)||(s==null?void 0:s.companyName)==="")&&(r.companyName="Company Name is required for business accounts"),be(r),Object.keys(r).length>0},le=async()=>{var r,s,j,ie,V,c,i,y,J,k,T,D,ae,ee,ne,De;try{let R={method:"POST",redirect:"follow"},Ge=await ft.post(`${Ce}api/v1/widget/generate-session`,R),Tt=Number(o==null?void 0:o.expiryYear)%100,Je=`${(r=o==null?void 0:o.cardNumber)==null?void 0:r.replace(/\s+/g,"")}=${Tt}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,Ht=forge.pki.publicKeyFromPem((j=(s=Ge==null?void 0:Ge.data)==null?void 0:s.data)==null?void 0:j.publicKeyPem).encrypt(Je,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Xt=forge.util.encode64(Ht),He={"Content-Type":"application/json","x-app-session-key":(V=(ie=Ge.data)==null?void 0:ie.data)==null?void 0:V.session_key},Zt=JSON.stringify({enc_track2_data:Xt,algorithm:"RSAES_OAEP_SHA_1",session_key:(i=(c=Ge==null?void 0:Ge.data)==null?void 0:c.data)==null?void 0:i.session_key}),rt=await ft.post(`${gt}tokenizer/tokenize`,Zt,{headers:He});if((rt==null?void 0:rt.status)==200){let Lt=(J=(y=rt==null?void 0:rt.data)==null?void 0:y.data)==null?void 0:J.token;try{let Fe=await ft.post(`${Ce}api/v1/gateway/verify-and-save/${q}`,{token:Lt});if((Fe==null?void 0:Fe.status)==200){let qt=(k=Fe==null?void 0:Fe.data)==null?void 0:k.data,st={Token:qt.gateway_token,Brand:qt.card_data.brand,ExpirationMonth:qt.card_data.expire_mm,ExpirationYear:qt.card_data.expire_yy,Last4:qt.card_data.last4,Bin:qt.card_data.bin,postalCode:o==null?void 0:o.zipCode},We;if(we&&Z)try{let zt={postal_code:o==null?void 0:o.zipCode,customer_id:Z,gateway_token:qt.gateway_token};We=await ft.post(`${Ce}api/v1/gateway/add-card/${q}`,zt)}catch(zt){console.log(zt,"error"),ue(),p(((D=(T=zt==null?void 0:zt.response)==null?void 0:T.data)==null?void 0:D.message)||"Something went wrong!")}B?Pt(st):it(st)}}catch(Fe){console.log(Fe,"error"),p(((ee=(ae=Fe==null?void 0:Fe.response)==null?void 0:ae.data)==null?void 0:ee.message)||"Something went wrong!"),ue()}}}catch(R){ue(),console.log(R,"error"),p(((De=(ne=R==null?void 0:R.response)==null?void 0:ne.data)==null?void 0:De.message)||"Something went wrong!")}},re=()=>{var V,c,i,y,J,k;let r={},s=o,j=parseInt((s==null?void 0:s.expiryMonth)||"",10),ie=(s==null?void 0:s.expiryYear)||"";if((V=s==null?void 0:s.cardName)!=null&&V.trim()||(r.cardName="Card name is required"),(c=s==null?void 0:s.cardNumber)!=null&&c.trim()||(r.cardNumber="Card number is required"),(!((i=s==null?void 0:s.expiryMonth)!=null&&i.trim())||!((y=s==null?void 0:s.expiryYear)!=null&&y.trim())||isNaN(j)||j<1||j>12||ie.length!==4)&&(r.expiryMonth="Invalid Expiration Date."),(J=s==null?void 0:s.cvv)!=null&&J.trim()||(r.cvv="CVV is required"),(k=s==null?void 0:s.zipCode)!=null&&k.trim()||(r.zipCode="ZIP code is required"),s!=null&&s.expiryMonth&&(s!=null&&s.expiryYear)&&s.expiryMonth.length<=2&&s.expiryYear.length===4){let T=parseInt(s.expiryMonth,10),D=parseInt(s.expiryYear,10),ae=new Date,ee=ae.getMonth()+1,ne=ae.getFullYear();(D<ne||D===ne&&T<ee)&&(r.expiryMonth="Card is expired")}return xe(r),Object.keys(r).length>0},Le=async r=>{var s,j,ie,V,c,i,y,J,k,T,D,ae,ee,ne,De;if(r.preventDefault(),m!=="ach"){if(re())return}else if(se())return;try{Me();let R=await ft.get(`${Ce}api/v1/gateway/token/${q}`);if((R==null?void 0:R.status)==200){let Ge=(j=(s=R==null?void 0:R.data)==null?void 0:s.data)==null?void 0:j.gateway_token,Tt=(V=(ie=R==null?void 0:R.data)==null?void 0:ie.data)==null?void 0:V.paymentGateway;if(m!=="ach")Tt==((c=Fn)==null?void 0:c.FRACTALKEY)?await le():DatacapWebToken.requestToken(Ge,"PaymentForm",Kt);else{let ot;try{let Je=await ft.post(`${Ce}api/v1/gateway/bank-charge/${q}`,{label:f==null?void 0:f.name,account_number:f==null?void 0:f.accountNumber,routing_number:f==null?void 0:f.routingNumber,bank_name:f==null?void 0:f.bankName,account_type:f==null?void 0:f.accountType,amount:e,customer_id:null,isSaveAch:!1,tax:"0.00",discount:"0.00",surcharge:"0.00",order_id:"",company_name:(f==null?void 0:f.companyName)||""});if((i=Je==null?void 0:Je.data)!=null&&i.result){if(lt&&Z)try{let me=await ft.post(`${Ce}api/v1/gateway/add-bank/${q}`,{name:f==null?void 0:f.name,account_number:f==null?void 0:f.accountNumber,routing_number:f==null?void 0:f.routingNumber,bank_name:f==null?void 0:f.bankName,account_type:f==null?void 0:f.accountType,customer_id:Z||"",company_name:(f==null?void 0:f.companyName)||""});me.data.result&&(ot={bankDetails:I(P({},(y=me==null?void 0:me.data)==null?void 0:y.data),{account_type:f==null?void 0:f.accountType})})}catch(me){ue(),p(((k=(J=me==null?void 0:me.response)==null?void 0:J.data)==null?void 0:k.message)||"Something went wrong!")}ot=I(P({},ot),{callback:I(P({},(T=Je==null?void 0:Je.data)==null?void 0:T.data),{name:f==null?void 0:f.name,isPreAuth:B})}),H(ot),$e(),ue()}}catch(Je){console.log(Je,"errororor");let me=(D=Je==null?void 0:Je.response)==null?void 0:D.data;typeof(me==null?void 0:me.message)=="object"?Object.values(me==null?void 0:me.message).forEach(Ht=>{p(Ht||"Something went wrong")}):p((me==null?void 0:me.message)||"Something went wrong"),ue()}}}}catch(R){ue(),H({error:((ee=(ae=R==null?void 0:R.response)==null?void 0:ae.data)==null?void 0:ee.message)||"Something went wrong!"}),p(((De=(ne=R==null?void 0:R.response)==null?void 0:ne.data)==null?void 0:De.message)||"Something went wrong!")}},Ie=(r,s)=>{let j=r;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(j)){(s===""||/^[0-9]+$/.test(s))&&(xe(V=>I(P({},V),{[j]:""})),ye(V=>I(P({},V),{[j]:s})));return}xe(V=>I(P({},V),{[j]:""})),ye(V=>I(P({},V),{[j]:s}))},ve=r=>{let j=r.target.value.replace(/\D/g,""),ie="";/^3[47]/.test(j)?ie=j.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(c,i,y,J)=>[i,y,J].filter(Boolean).join(" ")):ie=j.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(c,i,y,J,k)=>[i,y,J,k].filter(Boolean).join(" ")),xe(V=>I(P({},V),{cardNumber:""})),ye(V=>I(P({},V),{cardNumber:ie}))},ze=r=>{let{name:s,value:j}=r.target,ie=["routingNumber","accountNumber","confirmAccountNumber"];if(s=="name"){/^[a-zA-Z\s]*$/.test(j)&&(be(V=>I(P({},V),{[s]:""})),Ze(V=>I(P({},V),{[s]:j})));return}if(ie.includes(s)){(j===""||/^[0-9]+$/.test(j))&&(be(V=>I(P({},V),{[s]:""})),Ze(V=>I(P({},V),{[s]:j})));return}be(V=>I(P({},V),{[s]:""})),Ze(V=>I(P({},V),{[s]:j}))},$e=()=>{v(!1),U("card"),p(""),de(!1),u(""),Ze({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),be({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),ye({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),xe({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Ue(!1),Q(!1),K([])},mt=async()=>{var r,s,j,ie,V,c,i,y,J;Me();try{let k={isPreAuth:B,customerId:Z},T=await ft.post(`${Ce}api/v1/gateway/card-list/${q}`,k);if(console.log("paymentData",T),(s=(r=T==null?void 0:T.data)==null?void 0:r.data)!=null&&s.cardList&&((V=(ie=(j=T==null?void 0:T.data)==null?void 0:j.data)==null?void 0:ie.cardList)==null?void 0:V.length)>0){U("cardList");let D=(i=(c=T==null?void 0:T.data)==null?void 0:c.data)==null?void 0:i.cardList;K(D);let ae=D==null?void 0:D.find(ee=>(ee==null?void 0:ee.primary_card)==1);ae&&X(ae)}else U("card");ue()}catch(k){console.log(k),ue(),p(((J=(y=k==null?void 0:k.response)==null?void 0:y.data)==null?void 0:J.message)||(k==null?void 0:k.message)||"Something went wrong")}},ct=r=>{switch(r==null?void 0:r.toLowerCase()){case"visa":return dt;case"mastercard":case"mc":case"m/c":return O;case"amex":case"american express":case"ae":return Ve;case"discover":case"dcvr":return St;case"bank":return Ke;default:return r}},at=async r=>{ln.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 s=>{var j,ie;if(s.isConfirmed){S(!0);try{let V={card_id:r,customer_id:Z},c=await ft.patch(`${Ce}api/v1/gateway/delete-card/${q}`,V);(j=c==null?void 0:c.data)!=null&&j.result?(S(!1),mt(),ln.fire({icon:"success",title:"Deleted!",text:((ie=c==null?void 0:c.data)==null?void 0:ie.message)||"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})):(S(!1),ln.fire({icon:"error",title:"Failure!",text:"Card not deleted.",timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}}))}catch(V){S(!1),ln.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else s.dismiss===ln.DismissReason.cancel&&ln.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},pt=async()=>{var ie,V,c,i;let r=Z,s=l==null?void 0:l.id,j=l==null?void 0:l.card_type;if(e)if(r)if(s){let y={amount:e,customer_id:r,card_id:s};B&&(y.isPreauth=!0);let J=Ce+"api/v1/gateway/charge-by-saved-details/"+q,k={"Content-Type":"application/json"};try{Me();let T=await ft.post(J,y);console.log(T,"res"),(ie=T==null?void 0:T.data)!=null&&ie.result&&(H({callback:(V=T==null?void 0:T.data)==null?void 0:V.data}),ue(),$e())}catch(T){console.log(T==null?void 0:T.response,"error by saved details"),ue(),p(((i=(c=T==null?void 0:T.response)==null?void 0:c.data)==null?void 0:i.message)||"Something went wrong!")}}else p("Please Select A Card/ACH");else p("Please Select Customer");else p("Something went wrong.")};Wi(()=>{Z&&ht&&mt()},[Z,ht]);let xt=()=>B?"Cards":"Cards/Bank";return n.createElement(n.Fragment,null,n.createElement("link",{href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}),n.createElement(jt,null),n.createElement($n,null),n.createElement("button",{className:Ne||"paymentBtn",onClick:N},h,$),n.createElement($t,{open:ht,onClose:$e},w&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(Ut,{error:w,onClose:$e})),!w&&n.createElement(n.Fragment,null,(G||g)&&n.createElement(kt,{loading:G||g}),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:$e},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-main-logo-res"}),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("h1",{className:"pay-heading"},"Pay"),(d==null?void 0:d.length)>0&&m!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>U("cardList")}," ",n.createElement(Rn,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"},en((Mt=Number(e))==null?void 0:Mt.toFixed(2)))),m!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},n.createElement("img",{src:dt,alt:"",width:33}),n.createElement("img",{src:O,width:33,alt:""}),n.createElement("img",{src:Ve,alt:"",width:33}),n.createElement("img",{src:St,width:33,alt:""})))),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:tt,alt:""}),n.createElement("img",{src:ke,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},m!=="cardList"?n.createElement("div",null,(d==null?void 0:d.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>U("cardList")}," ",n.createElement(Rn,null)," Back"),!B&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks cardicon-img",onClick:r=>{z("card")},style:{border:m==="card"?"1px solid":"",display:"flex",justifyContent:"center",alignItems:"center"}},n.createElement("img",{className:"cardicon",src:E}),"Card"),n.createElement("button",{className:"tablinks bankicon-img",onClick:r=>{z("ach")},style:{border:m==="ach"?"1px solid":"",display:"flex",justifyContent:"center",alignItems:"center"}},n.createElement("img",{className:"bankicon",src:nt}),"Bank")),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"},en((bt=Number(e))==null?void 0:bt.toFixed(2)))),m!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:dt,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:O,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:Ve,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:St,width:35,alt:""}))))):n.createElement("div",null,n.createElement("div",{className:"charge-customer-name-frac",style:{marginBottom:"16px !important"}}," Charge ",L==null?void 0:L.customer_name),n.createElement("div",{className:"card-ach-heading-frac",style:{marginBottom:"10px !important"}}," ",C==="card"?xt():"Readers"," "),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"},en((vt=Number(e))==null?void 0:vt.toFixed(2)))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:dt,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:O,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:Ve,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:St,width:35,alt:""}))))),n.createElement("div",{id:"ach",style:{display:m==="cardList"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"card-lint-div-in"},n.createElement("div",{className:"card-list-div"},d&&(d==null?void 0:d.length)>0&&(d==null?void 0:d.map((r,s)=>n.createElement("div",{className:"card-list-single-div",key:s},n.createElement("div",{className:"card-number-radio"},n.createElement("input",{disabled:(L==null?void 0:L.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:l===r,onChange:j=>X(r)}),n.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",r==null?void 0:r.cardlastfourdigit),(r==null?void 0:r.card_type)!="Bank"&&n.createElement("h6",{className:"card-expiry-date"},r==null?void 0:r.expmonth,"/",r==null?void 0:r.expyear)),n.createElement("div",{className:"card-number-radio"},n.createElement("span",{className:"visa-card"},n.createElement("img",{src:ct(r==null?void 0:r.card_type),alt:""})),n.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>at(r==null?void 0:r.id)},n.createElement("img",{src:yt,alt:""}))))))),n.createElement("div",{className:"pay-with-other-card",onClick:()=>U("card")},"Pay With Other Card",n.createElement("img",{src:qe,alt:""}))),n.createElement("div",{className:"form-group-frac",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:pt},en((Qe=Number(e))==null?void 0:Qe.toFixed(2))))),n.createElement("div",{id:"ach",style:{display:m==="card"?"block":"none"},className:"tabcontent"},n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Le},n.createElement("div",{className:"ach-scrl",style:{minHeight:"398px",maxHeight:"398px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group-frac"},n.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),n.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"John Doe",value:(o==null?void 0:o.cardName)||"",onChange:r=>{let s=r.target.value;/^[a-zA-Z\s]*$/.test(s)&&Ie("cardName",s)}}),(b==null?void 0:b.cardName)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.cardName)),n.createElement("div",{className:"form-group-frac"},n.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control-frac card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(o==null?void 0:o.cardNumber)||"",onChange:r=>ve(r),"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-frac"},n.createElement("input",{"data-token":"exp_month",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:r=>Ie("expiryMonth",r.target.value)})),n.createElement("div",{className:"exp-year form-group-frac"},n.createElement("input",{"data-token":"exp_year",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:r=>Ie("expiryYear",r.target.value)})),n.createElement("div",{className:"security-digit form-group-frac"},n.createElement("input",{"data-token":"cvv",className:"form-control-frac card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(o==null?void 0:o.cvv)||"",onChange:r=>Ie("cvv",r.target.value)})))),(b==null?void 0:b.cardNumber)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.cardNumber),n.createElement("p",{style:{margin:"0"}},b!=null&&b.expiryMonth||b!=null&&b.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},b==null?void 0:b.expiryMonth):"",(b==null?void 0:b.cvv)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.cvv)))),n.createElement("div",{className:"form-group-frac"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"000000",value:(ge=o==null?void 0:o.zipCode)!=null?ge:"",onChange:r=>Ie("zipCode",r.target.value)}),(b==null?void 0:b.zipCode)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.zipCode)),Z&&n.createElement("div",{className:"form-group-frac"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:we,onChange:r=>Q(r.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-frac",style:{marginTop:"20px",padding:"0"}},n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},en((ut=Number(e))==null?void 0:ut.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:m==="ach"?"block":"none"},className:"tabcontent"},n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Le},n.createElement("div",{className:"ach-scrl",style:{minHeight:"358px",maxHeight:"378px"}},n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),n.createElement("input",{type:"text",id:"nameonaccount",className:"form-control-frac",maxLength:100,placeholder:"John Doe",name:"name",value:(Ct=f==null?void 0:f.name)!=null?Ct:"",onChange:ze}),(W==null?void 0:W.name)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.name)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"routingnumber"},"Routing number"),n.createElement("input",{type:"text",id:"routingnumber",className:"form-control-frac",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(Ot=f==null?void 0:f.routingNumber)!=null?Ot:"",onChange:ze}),(W==null?void 0:W.routingNumber)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.routingNumber)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"accountnumber"},"Account number"),n.createElement("input",{type:"text",id:"accountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Ye=f==null?void 0:f.accountNumber)!=null?Ye:"",onChange:ze}),(W==null?void 0:W.accountNumber)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.accountNumber)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),n.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Et=f==null?void 0:f.confirmAccountNumber)!=null?Et:"",onChange:ze}),(W==null?void 0:W.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.confirmAccountNumber)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"bankname"},"Bank name"),n.createElement("input",{type:"text",id:"bankname",className:"form-control-frac",maxLength:100,placeholder:"My Bank",name:"bankName",value:(wt=f==null?void 0:f.bankName)!=null?wt:"",onChange:ze}),(W==null?void 0:W.bankName)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.bankName)),((f==null?void 0:f.accountType)==="business saving"||(f==null?void 0:f.accountType)==="business checking")&&n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"companyName"},"Company name"),n.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(Ae=f==null?void 0:f.companyName)!=null?Ae:"",onChange:ze}),(W==null?void 0:W.companyName)&&n.createElement("span",{className:"error-span"},W==null?void 0:W.companyName)),n.createElement("div",{className:"form-group-frac mb-4"},n.createElement("label",{htmlFor:"accounttype"},"Select account type"),n.createElement("select",{name:"accountType",id:"accounttype",className:"form-control-frac",value:(Oe=f==null?void 0:f.accountType)!=null?Oe:"",onChange:ze},n.createElement("option",{value:""},"Select account"),kn.map(r=>n.createElement("option",{key:r.value,value:r.value},r.label)))),Z&&n.createElement("div",{className:"form-group-frac mb-4 save-ach-div",style:{paddingTop:"5px"}},n.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:lt,onChange:r=>Ue(r.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),lt&&n.createElement("div",{className:"form-group-frac mb-4 saveachtext"},n.createElement("p",null,"If checked, I agree for ",n.createElement("b",null,Te||"merchant")," to have my permission to charge this credit card for agreed upon purchases in the future."))),n.createElement("div",{className:"form-group-frac "},n.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},en((Jt=Number(e))==null?void 0:Jt.toFixed(2)))))))))))))))};export{Ki as AddCard,Ei as CardOnFile,Ti as GetPaymentPage,Ui as PaymentWidget,qi as PreAuthPayment,xi as RequestPayment,wi as RequestPreAuthPayment};
|