@fractalpay/fractalpay-next-dev 0.0.97 → 0.0.99

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var ui=Object.defineProperty,gi=Object.defineProperties;var pi=Object.getOwnPropertyDescriptors;var $n=Object.getOwnPropertySymbols;var Rn=Object.prototype.hasOwnProperty,ei=Object.prototype.propertyIsEnumerable;var Dn=(e,w,j)=>w in e?ui(e,w,{enumerable:!0,configurable:!0,writable:!0,value:j}):e[w]=j,_=(e,w)=>{for(var j in w||(w={}))Rn.call(w,j)&&Dn(e,j,w[j]);if($n)for(var j of $n(w))ei.call(w,j)&&Dn(e,j,w[j]);return e},M=(e,w)=>gi(e,pi(w));var vn=(e,w)=>{var j={};for(var Q in e)Rn.call(e,Q)&&w.indexOf(Q)<0&&(j[Q]=e[Q]);if(e!=null&&$n)for(var Q of $n(e))w.indexOf(Q)<0&&ei.call(e,Q)&&(j[Q]=e[Q]);return j};var fi=(e,w)=>()=>(w||e((w={exports:{}}).exports,w),w.exports);var ni=fi((pa,xi)=>{xi.exports={name:"@fractalpay/fractalpay-next-dev",version:"0.0.97",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 B,{useState as dn,useEffect as ai}from"react";import mn from"react";import hi from"react";var yi=e=>hi.createElement("style",null,`
1
+ var ui=Object.defineProperty,gi=Object.defineProperties;var pi=Object.getOwnPropertyDescriptors;var $n=Object.getOwnPropertySymbols;var Rn=Object.prototype.hasOwnProperty,ei=Object.prototype.propertyIsEnumerable;var Dn=(e,w,j)=>w in e?ui(e,w,{enumerable:!0,configurable:!0,writable:!0,value:j}):e[w]=j,_=(e,w)=>{for(var j in w||(w={}))Rn.call(w,j)&&Dn(e,j,w[j]);if($n)for(var j of $n(w))ei.call(w,j)&&Dn(e,j,w[j]);return e},M=(e,w)=>gi(e,pi(w));var vn=(e,w)=>{var j={};for(var Q in e)Rn.call(e,Q)&&w.indexOf(Q)<0&&(j[Q]=e[Q]);if(e!=null&&$n)for(var Q of $n(e))w.indexOf(Q)<0&&ei.call(e,Q)&&(j[Q]=e[Q]);return j};var fi=(e,w)=>()=>(w||e((w={exports:{}}).exports,w),w.exports);var ni=fi((pa,xi)=>{xi.exports={name:"@fractalpay/fractalpay-next-dev",version:"0.0.99",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 B,{useState as dn,useEffect as ai}from"react";import mn from"react";import hi from"react";var yi=e=>hi.createElement("style",null,`
2
2
 
3
3
  .loader {
4
4
  position: fixed; /* Fixed position to cover the viewport */
@@ -1669,7 +1669,7 @@ position:relative;
1669
1669
  .frac-card-bank-radio.frac-active {
1670
1670
  background: #F6F6F7;
1671
1671
  }
1672
- `)}import It from"react";var un=({listHeading:e="Card",ListItems:w,selectedCard:j,setSelectedCard:Q,paymentGateway:E,handleDeleteCard:Oe,otherButtonAction:V,otherButtonLabel:gt,headingClass:Ke})=>{let we=oe+"widget/Trash.svg";return console.log(j,"selectedCard another",w),It.createElement(It.Fragment,null,It.createElement("h6",{className:Ke||"card-ach-heading",style:{marginBottom:"10px !important"}},e),It.createElement("div",{className:"card-lint-div-in"},It.createElement("div",{className:"card-list-div"},w&&(w==null?void 0:w.length)>0&&(w==null?void 0:w.map((O,he)=>{let Fe=!1;return E&&(Fe=E!=(O==null?void 0:O.payment_method_type)&&(O==null?void 0:O.card_type)!="Bank"),It.createElement("div",{key:O==null?void 0:O.id,className:"card-list-single-div"},It.createElement("div",{className:"card-number-radio"},It.createElement("input",{disabled:Fe,type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:(j==null?void 0:j.id)===(O==null?void 0:O.id),onChange:a=>Q(O)}),It.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",O==null?void 0:O.cardlastfourdigit),(O==null?void 0:O.card_type)!="Bank"&&It.createElement("h6",{className:"card-expiry-date"},O==null?void 0:O.expmonth,"/",O==null?void 0:O.expyear)),It.createElement("div",{className:"card-number-radio"},It.createElement("span",{className:"visa-card"},It.createElement("img",{src:si(O==null?void 0:O.card_type),alt:""})),It.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Oe(O==null?void 0:O.id)},It.createElement("img",{src:we,alt:""}))))}))),It.createElement("div",{className:"pay-with-other-card",onClick:V},gt,It.createElement("img",{src:Mn,alt:""}))))};function Zi(e){var qt,Yt,vt,Te,St,ht,Rt,Ve,Ft,Pt,et,ot,en,Et,on,yt,Xt,rn;let[w,j]=dt(!1),[Q,E]=dt(!1),[Oe,V]=dt(""),[gt,Ke]=dt(!1),[we,O]=dt(!1),[he,Fe]=dt("card"),[a,N]=dt("card"),[b,ee]=dt("form"),[h,Me]=dt("form"),[se,je]=dt(!0),[C,Ze]=dt(!1),[G,pt]=dt(!1),S=e.merchantPublicKey,Ee=oe+"widget/mc-img.svg",te=oe+"widget/visa-img.svg",De=oe+"widget/ae-img.svg",ze=oe+"widget/discover-img.svg",Ct=oe+"widget/card.svg",z=oe+"widget/Trash.svg",l=oe+"widget/bank.svg",f=oe+"widget/secure-img.png",D=oe+"widget/pov-by.png",F=oe+"widget/pax.svg",[x,d]=dt(),[v,k]=dt({}),[c,u]=dt(),[P,K]=dt({}),[re,ue]=dt([]),[xt,Re]=dt([]),[nt,lt]=dt(),[ct,rt]=dt(),[Ae,xe]=dt(Number(e==null?void 0:e.amount));console.log(nt,"selectedCard");let[Z,Be]=dt(),[Je,$]=dt(""),Nt=()=>j(!0),Kt=()=>j(!1),wt=(I,p)=>{let J=(parseFloat(p)||0)/100,He=I/(1+J);return Math.round(He*100)/100};li(()=>{if(we){let I=wt(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);xe(I)}},[we,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let A=()=>{O(!1),Fe("card"),V(""),Ke(!1),$(""),u({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),K({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),d({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),k({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),pt(!1),Ze(!1),lt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),rt({}),xe(0),N("card"),je(!0),Me("form"),ee("form"),E(!1),j(!1),Re([]),ue([])},q=()=>O(!0),_e=I=>{Fe(I)},Se=(I,p)=>{let J=I;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(J)){(p===""||/^[0-9]+$/.test(p))&&(k(g=>M(_({},g),{[J]:""})),d(g=>M(_({},g),{[J]:p})));return}k(g=>M(_({},g),{[J]:""})),d(g=>M(_({},g),{[J]:p}))},ye=I=>{let J=I.target.value.replace(/\D/g,""),He="";/^3[47]/.test(J)?He=J.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(m,Y,fe,W)=>[Y,fe,W].filter(Boolean).join(" ")):He=J.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(m,Y,fe,W,Ne)=>[Y,fe,W,Ne].filter(Boolean).join(" ")),k(g=>M(_({},g),{cardNumber:""})),d(g=>M(_({},g),{cardNumber:He}))},Xe=I=>{let{name:p,value:J}=I.target,He=["routingNumber","accountNumber","confirmAccountNumber"];if(p=="name"){/^[a-zA-Z\s]*$/.test(J)&&(K(g=>M(_({},g),{[p]:""})),u(g=>M(_({},g),{[p]:J})));return}if(He.includes(p)){(J===""||/^[0-9]+$/.test(J))&&(K(g=>M(_({},g),{[p]:""})),u(g=>M(_({},g),{[p]:J})));return}K(g=>M(_({},g),{[p]:""})),u(g=>M(_({},g),{[p]:J}))},it=()=>{var g,m,Y,fe,W,Ne;let I={},p=x,J=parseInt((p==null?void 0:p.expiryMonth)||"",10),He=(p==null?void 0:p.expiryYear)||"";if((g=p==null?void 0:p.cardName)!=null&&g.trim()||(I.cardName="Card name is required"),(m=p==null?void 0:p.cardNumber)!=null&&m.trim()||(I.cardNumber="Card number is required"),(!((Y=p==null?void 0:p.expiryMonth)!=null&&Y.trim())||!((fe=p==null?void 0:p.expiryYear)!=null&&fe.trim())||isNaN(J)||J<1||J>12||He.length!==4)&&(I.expiryMonth="Invalid Expiration Date."),(W=p==null?void 0:p.cvv)!=null&&W.trim()||(I.cvv="CVV is required"),(Ne=p==null?void 0:p.zipCode)!=null&&Ne.trim()||(I.zipCode="ZIP code is required"),p!=null&&p.expiryMonth&&(p!=null&&p.expiryYear)&&p.expiryMonth.length<=2&&p.expiryYear.length===4){let Pe=parseInt(p.expiryMonth,10),i=parseInt(p.expiryYear,10),o=new Date,L=o.getMonth()+1,U=o.getFullYear();(i<U||i===U&&Pe<L)&&(I.expiryMonth="Card is expired")}return k(I),Object.keys(I).length>0},Le=()=>{var J,He,g,m,Y,fe,W,Ne;let I={},p=c;return(J=p==null?void 0:p.name)!=null&&J.trim()||(I.name="Name is required"),(He=p==null?void 0:p.accountNumber)!=null&&He.trim()||(I.accountNumber="Account number is required"),(g=p==null?void 0:p.accountNumber)!=null&&g.trim()&&((m=p==null?void 0:p.accountNumber)==null?void 0:m.trim())!==((Y=p==null?void 0:p.confirmAccountNumber)==null?void 0:Y.trim())&&(I.confirmAccountNumber="Account numbers must match"),(fe=p==null?void 0:p.bankName)!=null&&fe.trim()||(I.bankName="Bank name is required"),(W=p==null?void 0:p.routingNumber)!=null&&W.trim()||(I.routingNumber="Routing Number is required"),p!=null&&p.routingNumber&&((Ne=p==null?void 0:p.routingNumber)==null?void 0:Ne.length)!==9&&(I.routingNumber="Routing number must be 9 digits"),((p==null?void 0:p.accountType)==="business saving"||(p==null?void 0:p.accountType)==="business checking")&&(!(p!=null&&p.companyName)||(p==null?void 0:p.companyName)==="")&&(I.companyName="Company Name is required for business accounts"),K(I),Object.keys(I).length>0},at=async I=>{var p,J,He,g,m,Y,fe,W,Ne,Pe,i,o,L,U,y,R;if(I.preventDefault(),he!=="ach"){if(it())return;{let pe=DatacapWebToken.validateCardNumber(x==null?void 0:x.cardNumber.replaceAll(" ","")),ie=DatacapWebToken.validateExpirationDate(x==null?void 0:x.expiryMonth,x==null?void 0:x.expiryYear),de=DatacapWebToken.validateCVV(x==null?void 0:x.cvv),le={};if(pe||(le.cardNumber="Invalid card Number"),ie||(le.expiryMonth="Invalid Expiration Date."),de||(le.cvv="Invalid CVV"),k(le),pe&&de&&ie){E(!0);try{let ae=M(_({},x),{amount:`${e.amount||0}`,fractalpayPublicKey:S,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}),ce=await wn.post(`${$e}create-widget-order`,ae),me=async function(ve){if(ve.Error)V(ve.Error),E(!1);else{let Ce=x==null?void 0:x.cardName,X=x==null?void 0:x.zipCode;ve.name=Ce,ve.postal_code=X,ve.isCardSave=`${C}`,ve.isCharge=!0,ve.posSalesIdEncode=ce==null?void 0:ce.data.data.posSalesIdEncode,mt.emit("sendMessage",ve),mt.on(ce==null?void 0:ce.data.data.posSalesIdEncode,ge=>{if(Cn(ge==null?void 0:ge.data)){let We=JSON.parse(ge.data);We!=null&&We.result?(d({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Ze(!1),$(We==null?void 0:We.transactionId),Ke(!0),E(!1)):(E(!1),V((We==null?void 0:We.message)||"Something went wrong."))}else V("Something went wrong.")})}};if((Z==null?void 0:Z.paymentGateway)===32){let ve={method:"POST",redirect:"follow"};try{let Ce=await wn.post(`${Ie}api/v1/widget/generate-session`,ve),X=Number(x==null?void 0:x.expiryYear)%100,ge=x==null?void 0:x.cardNumber;ge=ge==null?void 0:ge.replace(/\s+/g,"");let We=`${ge}=${X}${x==null?void 0:x.expiryMonth} ${x==null?void 0:x.cvv}`,tt=forge.pki.publicKeyFromPem((J=(p=Ce==null?void 0:Ce.data)==null?void 0:p.data)==null?void 0:J.publicKeyPem).encrypt(We,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Ge=forge.util.encode64(tt),Mt={"Content-Type":"application/json","x-app-session-key":(g=(He=Ce.data)==null?void 0:He.data)==null?void 0:g.session_key},Sn=JSON.stringify({enc_track2_data:`${Ge}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Y=(m=Ce==null?void 0:Ce.data)==null?void 0:m.data)==null?void 0:Y.session_key}`});try{let Lt=await wn.post(`${At}tokenizer/tokenize`,Sn,{headers:Mt}),zt=JSON.stringify(M(_({},(fe=Lt==null?void 0:Lt.data)==null?void 0:fe.data),{isSaveCardChecked:C,name:x==null?void 0:x.cardName,postal_code:x==null?void 0:x.zipCode,customer_id:e==null?void 0:e.customerId})),sn=JSON.stringify({pre_sales_id:`${(Ne=(W=ce==null?void 0:ce.data)==null?void 0:W.data)==null?void 0:Ne.posSalesIdEncode}`,token:`${(Pe=Lt==null?void 0:Lt.data)==null?void 0:Pe.data.token}`,json_response:`${zt}`}),Wt={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:sn,redirect:"follow",isChargeviafractal:!0};mt.emit("sendMessage",Wt),mt.on("chargeviafractalgateway",Ht=>{var tn;if(Cn(Ht==null?void 0:Ht.data)){let Ut=JSON.parse(Ht==null?void 0:Ht.data);Ut!=null&&Ut.result?($((tn=Ut==null?void 0:Ut.data)==null?void 0:tn.transactionId),Ke(!0),E(!1)):(E(!1),V((Ut==null?void 0:Ut.message)||"Something went wrong."))}else V("Something went wrong.")})}catch(Lt){E(!1),V(((o=(i=Lt==null?void 0:Lt.response)==null?void 0:i.data)==null?void 0:o.message)||(Lt==null?void 0:Lt.message)||"Something went wrong.")}}catch(Ce){E(!1),V(((U=(L=Ce==null?void 0:Ce.response)==null?void 0:L.data)==null?void 0:U.message)||(Ce==null?void 0:Ce.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(ce==null?void 0:ce.data.data.dctoken,"PaymentForm",me)}catch(ae){E(!1),V(((R=(y=ae==null?void 0:ae.response)==null?void 0:y.data)==null?void 0:R.message)||(ae==null?void 0:ae.message)||"Something went wrong.")}}}}else{if(Le())return;{E(!0);let pe={fractalpayPublicKey:S,label:(c==null?void 0:c.name)||"John Doe",account_number:c==null?void 0:c.accountNumber,routing_number:c==null?void 0:c.routingNumber,bank_name:c==null?void 0:c.bankName,account_type:c==null?void 0:c.accountType,amount:String(Ae||0),isSaveAch:G,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:(c==null?void 0:c.companyName)||""};mt.emit("sendMessage",pe),mt.on("ach-incoming",ie=>{var de;(ie==null?void 0:ie.status)=="Failed"?typeof(ie==null?void 0:ie.message)=="object"?Object.values(ie==null?void 0:ie.message).forEach(le=>{V(le||"Something went wrong")}):V((ie==null?void 0:ie.message)||"Something went wrong"):($((de=ie==null?void 0:ie.data)==null?void 0:de.transaction_id),Ke(!0),E(!1))})}}},be=async()=>{var I,p,J,He,g,m,Y,fe,W,Ne,Pe,i,o,L,U,y,R,ne,pe,ie,de,le,ae;Nt();try{let ce={fractalpayPublicKey:S,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee},me=await wn.post(`${$e}get-payment-details`,ce);if(Be((I=me==null?void 0:me.data)==null?void 0:I.data),(J=(p=me==null?void 0:me.data)==null?void 0:p.data)!=null&&J.paymentGateway||(A(),V("Something went wrong.")),(g=(He=me==null?void 0:me.data)==null?void 0:He.data)!=null&&g.card_list&&((fe=(Y=(m=me==null?void 0:me.data)==null?void 0:m.data)==null?void 0:Y.card_list)==null?void 0:fe.length)>0){let ve=(Pe=(Ne=(W=me==null?void 0:me.data)==null?void 0:W.data)==null?void 0:Ne.card_list)==null?void 0:Pe.filter(X=>(X==null?void 0:X.card_type)=="Bank"),Ce=(L=(o=(i=me==null?void 0:me.data)==null?void 0:i.data)==null?void 0:o.card_list)==null?void 0:L.filter(X=>(X==null?void 0:X.card_type)!=="Bank");console.log(ve,"hohgohoo",Ce),(Ce==null?void 0:Ce.length)>0&&ee("list"),(ve==null?void 0:ve.length)>0&&Me("list"),ue(Ce),Re(ve)}else Fe("card");(y=(U=me==null?void 0:me.data)==null?void 0:U.data)!=null&&y.paymentDeviceList&&((pe=(ne=(R=me==null?void 0:me.data)==null?void 0:R.data)==null?void 0:ne.paymentDeviceList)==null?void 0:pe.length)>0&&rt((de=(ie=me==null?void 0:me.data)==null?void 0:ie.data)==null?void 0:de.paymentDeviceList[0]),Kt()}catch(ce){console.log(ce),Kt(),V(((ae=(le=ce==null?void 0:ce.response)==null?void 0:le.data)==null?void 0:ae.message)||(ce==null?void 0:ce.message)||"Something went wrong")}},Bt=async()=>{let I=e==null?void 0:e.customerId,p=String(e==null?void 0:e.discount),J=String(e==null?void 0:e.surcharge),He=String(e==null?void 0:e.tax),g=e==null?void 0:e.merchantPublicKey,m=e==null?void 0:e.orderID,Y=String(e==null?void 0:e.amount),fe=nt==null?void 0:nt.id,W=nt==null?void 0:nt.card_type;if(g&&m&&Y&&Ae)if(I)if(fe){let Pe={amount:W==="Bank"?Ae:Y,order_id:m,customer_id:I,card_id:fe,fractalpayPublicKey:g,isCardSave:C,discount:p,surcharge:J,tax:He},Ne=Pe,{isCardSave:i}=Ne,o=vn(Ne,["isCardSave"]),U=$e+(W==="Bank"?"charge-ach":"charge-by-card"),y={"Content-Type":"application/json"};E(!0),mt.emit("sendMessage",{url:U,body:W=="Bank"?o:Pe,isChargebycard:!0}),mt.on("charge-by-card",R=>{var ne;(R==null?void 0:R.result)==!0||(R==null?void 0:R.status)==!0?($((ne=R.data)==null?void 0:ne.transaction_id),Ke(!0),E(!1)):V((R==null?void 0:R.message)||"Something went wrong.")})}else V("Please Select A Card/ACH");else V("Please Select Customer");else V("Something went wrong.")},kt=async()=>{var g,m,Y,fe,W,Ne;let I=e==null?void 0:e.merchantPublicKey,p=e==null?void 0:e.orderID,J=String(e==null?void 0:e.amount),He=e==null?void 0:e.customerId;if(!(ct!=null&&ct.device_id)){V("Please Select A Payment Device");return}if(I&&p&&J){E(!0);let Pe={amount:J,fractalpayPublicKey:I,customer_order_id:p,device_id:ct==null?void 0:ct.device_id,customer_id:He||""};try{let i=await wn.post(`${$e}charge-with-reader`,Pe);((g=i==null?void 0:i.data)==null?void 0:g.result)==!0?($((Y=(m=i==null?void 0:i.data)==null?void 0:m.data)==null?void 0:Y.transaction_id),Ke(!0),E(!1)):(V(((fe=i==null?void 0:i.data)==null?void 0:fe.message)||"Something went wrong."),E(!1))}catch(i){V(((Ne=(W=i==null?void 0:i.response)==null?void 0:W.data)==null?void 0:Ne.message)||"Something went wrong."),E(!1)}}else V("Something went wrong.")},ft=()=>{a==="card"?Bt():a==="reader"&&kt()};li(()=>{we&&S&&be()},[S,we]);let _t=async I=>{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 p=>{if(p.isConfirmed){E(!0);try{let J={card_id:I,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},He=await wn.post(`${$e}delete-customer-card`,J);E(!1),be(),Ln.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(J){E(!1),Ln.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else p.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"}})})},Tt=I=>{switch(I==null?void 0:I.toLowerCase()){case"visa":return te;case"mastercard":case"mc":case"m/c":return Ee;case"amex":case"american express":case"ae":return De;case"discover":case"dcvr":return ze;case"bank":return l;default:return I}},Zt=()=>{let I=Ae||0;return(Number(e.amount)-I).toFixed(0)};return console.log(b,"activeinCard","activeinBank",h),n.createElement(n.Fragment,null,n.createElement(Qt,null),n.createElement(hn,null),n.createElement(bn,null),n.createElement(n.Fragment,null,n.createElement("button",{className:"paymentBtn",onClick:q},"Pay"),n.createElement(Gt,{open:we,onClose:A},Oe&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(nn,{error:Oe,onClose:A})),gt&&n.createElement(yn,{onClose:A,tranId:Je}),!Oe&&!gt&&n.createElement(n.Fragment,null,(w||Q)&&n.createElement(Vt,{loading:w||Q}),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:A},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("img",{src:Z==null?void 0:Z.logo,id:"pay-logos"})),n.createElement("div",{className:"pay-container"},n.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},n.createElement("div",{className:"pay-conatiner-one-first"},n.createElement("div",{className:"pay-logo-container"},n.createElement("div",{className:"pay-main-logo"},n.createElement("img",{src:Z==null?void 0:Z.logo,id:"pay-logos"})),(re==null?void 0:re.length)>0&&he!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",n.createElement(jn,null)," Back")),n.createElement("div",{className:"amt-pay-con"},n.createElement("div",{className:"pay-amount-conatiner"},n.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),n.createElement("div",{className:"frac-card-bank-radio-main"},n.createElement(cn,{label:"Card",amount:(qt=Number(e==null?void 0:e.amount))==null?void 0:qt.toFixed(2),value:"card",onChange:_e,activetab:he}),(Z==null?void 0:Z.isSkyFiAccount)&&n.createElement(cn,{label:"Bank",amount:(Yt=Number(Ae))==null?void 0:Yt.toFixed(2),value:"ach",onChange:_e,activetab:he})),Ae&&Ae>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,he==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,Ue((Number(e.amount)-Ae).toFixed(2)))):null)),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:f,alt:""}),n.createElement("img",{src:D,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},!w&&n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},he!=="cardList"?n.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(re==null?void 0:re.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",n.createElement(jn,null)," Back"),(Z==null?void 0:Z.isSkyFiAccount)&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks",onClick:I=>{_e("card")},style:{border:he==="card"?"1px solid":""}},n.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),n.createElement("button",{className:"tablinks",onClick:I=>{_e("ach")},style:{border:he==="ach"?"1px solid":""}},n.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"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"},"$",(vt=Number(e==null?void 0:e.amount))==null?void 0:vt.toFixed(2))),he!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:te,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Ee,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:De,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:ze,width:35,alt:""})))),Ae&&Ae>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",Ae))):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",Z==null?void 0:Z.customer_name),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",a==="card"?"Cards/Banks":"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"},"$",(Te=Number(e==null?void 0:e.amount))==null?void 0:Te.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:te,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Ee,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:De,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:ze,width:35,alt:""}))))),n.createElement("div",{id:"card",style:{display:he==="card"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(re==null?void 0:re.length)>0&&b==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ee("list")}," ",n.createElement(jn,null)),Ae&&Ae>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",Ae))),n.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),he!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},n.createElement("img",{src:te,alt:"",width:33}),n.createElement("img",{src:Ee,width:33,alt:""}),n.createElement("img",{src:De,alt:"",width:33}),n.createElement("img",{src:ze,width:33,alt:""}))),b==="list"?n.createElement(n.Fragment,null,n.createElement(un,{listHeading:"Cards",paymentGateway:Z==null?void 0:Z.paymentGateway,ListItems:re,selectedCard:nt,setSelectedCard:lt,handleDeleteCard:_t,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{ee("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:ft},Ue((St=Number(e==null?void 0:e.amount))==null?void 0:St.toFixed(2))))):n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:at},n.createElement("div",{className:"ach-scrl",style:{minHeight:Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)>0?"444px":Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)==0?"456px":(re==null?void 0:re.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(x==null?void 0:x.cardName)||"",onChange:I=>{let p=I.target.value;/^[a-zA-Z\s]*$/.test(p)&&Se("cardName",p)}}),(v==null?void 0:v.cardName)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.cardName)),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(x==null?void 0:x.cardNumber)||"",onChange:I=>ye(I),"data-token":"card_number"}),n.createElement("div",{className:"card-crdi card-expiry-new"},n.createElement("div",{className:"exp-date-year-container"},n.createElement("div",{className:"exp-date form-group"},n.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(x==null?void 0:x.expiryMonth)||"",onChange:I=>Se("expiryMonth",I.target.value)})),n.createElement("div",{className:"exp-year form-group"},n.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(x==null?void 0:x.expiryYear)||"",onChange:I=>Se("expiryYear",I.target.value)})),n.createElement("div",{className:"security-digit form-group"},n.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(x==null?void 0:x.cvv)||"",onChange:I=>Se("cvv",I.target.value)})))),(v==null?void 0:v.cardNumber)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.cardNumber),n.createElement("p",{style:{margin:"0"}},v!=null&&v.expiryMonth||v!=null&&v.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},v==null?void 0:v.expiryMonth):"",(v==null?void 0:v.cvv)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.cvv)))),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(ht=e==null?void 0:e.orderID)!=null?ht:"",style:{background:"#F6F6F7",color:"#727272"}})),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Rt=x==null?void 0:x.zipCode)!=null?Rt:"",onChange:I=>Se("zipCode",I.target.value)}),(v==null?void 0:v.zipCode)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.zipCode)),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:C,onChange:I=>Ze(I.target.checked)}),n.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),n.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12420_50192)"},n.createElement("rect",{width:"20",height:"20",fill:"white"}),n.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),n.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12420_50192"},n.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),n.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(Z==null?void 0:Z.paymentDeviceList)&&((Ve=Z==null?void 0:Z.paymentDeviceList)==null?void 0:Ve.length)>0&&n.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>je(!se)},se?"Pay With Reader":"Pay With Card"),n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((Ft=Number(e==null?void 0:e.amount))==null?void 0:Ft.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:he==="ach"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(xt==null?void 0:xt.length)>0&&h==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Me("list")}," ",n.createElement(jn,null)),Ae&&Ae>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),n.createElement("div",null,"$",Zt()))),n.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),h==="list"?n.createElement(n.Fragment,null,n.createElement(un,{listHeading:"Banks",paymentGateway:Z==null?void 0:Z.paymentGateway,ListItems:xt,selectedCard:nt,setSelectedCard:lt,handleDeleteCard:_t,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Me("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:ft},Ue((Pt=Number(Ae))==null?void 0:Pt.toFixed(2))))):n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:at},n.createElement("div",{className:"ach-scrl",style:{minHeight:Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)>0?"444px":Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)==0?"436px":(re==null?void 0:re.length)>0?"462px":"520px",maxHeight:Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)>0?"444px":((re==null?void 0:re.length)>0,"380px")}},n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),n.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(et=c==null?void 0:c.name)!=null?et:"",onChange:Xe}),(P==null?void 0:P.name)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.name)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"routingnumber"},"Routing number"),n.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(ot=c==null?void 0:c.routingNumber)!=null?ot:"",onChange:Xe}),(P==null?void 0:P.routingNumber)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.routingNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accountnumber"},"Account number"),n.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(en=c==null?void 0:c.accountNumber)!=null?en:"",onChange:Xe}),(P==null?void 0:P.accountNumber)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.accountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),n.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Et=c==null?void 0:c.confirmAccountNumber)!=null?Et:"",onChange:Xe}),(P==null?void 0:P.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.confirmAccountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"bankname"},"Bank name"),n.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(on=c==null?void 0:c.bankName)!=null?on:"",onChange:Xe}),(P==null?void 0:P.bankName)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.bankName)),((c==null?void 0:c.accountType)==="business saving"||(c==null?void 0:c.accountType)==="business checking")&&n.createElement("div",{className:"form-group 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:(yt=c==null?void 0:c.companyName)!=null?yt:"",onChange:Xe}),(P==null?void 0:P.companyName)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.companyName)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accounttype"},"Select account type"),n.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(Xt=c==null?void 0:c.accountType)!=null?Xt:"",onChange:Xe},n.createElement("option",{value:""},"Select account"),Nn.map(I=>n.createElement("option",{key:I.value,value:I.value},I.label)))),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},n.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:G,onChange:I=>pt(I.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),G&&n.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},n.createElement("p",null,"If checked, I agree for ",n.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),n.createElement("div",{className:"form-group "},n.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Ue((rn=Number(Ae))==null?void 0:rn.toFixed(2))))))))))))))))}import s,{useEffect as mi,useState as Jt}from"react";import zn from"axios";import En from"sweetalert2";import{IoArrowBack as di}from"react-icons/io5";function Ei(e){var Ae,xe,Z,Be,Je,$,Nt,Kt,wt;let[w,j]=Jt(!1),[Q,E]=Jt(!1),[Oe,V]=Jt(""),[gt,Ke]=Jt(!1),[we,O]=Jt(!1),[he,Fe]=Jt("card"),[a,N]=Jt(!1),b=e.merchantPublicKey,ee=oe+"widget/mc-img.svg",h=oe+"widget/visa-img.svg",Me=oe+"widget/ae-img.svg",se=oe+"widget/discover-img.svg",je=oe+"widget/card.svg",C=oe+"widget/Trash.svg",Ze=oe+"widget/bank.svg",G=oe+"widget/secure-img.png",pt=oe+"widget/pov-by.png",[S,Ee]=Jt(),[te,De]=Jt({}),[ze,Ct]=Jt([]),[z,l]=Jt(),[f,D]=Jt(void 0),[F,x]=Jt(),[d,v]=Jt(""),k=(A,q)=>{let _e=(parseFloat(q)||0)/100,Se=A/(1+_e);return Math.round(Se*100)/100};mi(()=>{if(e!=null&&e.pass_fee){let A=k(e==null?void 0:e.amount,e==null?void 0:e.surcharge);D(A)}},[e==null?void 0:e.pass_fee]);let c=()=>j(!0),u=()=>j(!1),P=()=>{O(!1),Fe("card"),E(!1),V(""),Ke(!1),v(""),Ee({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),De({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),N(!1),l({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},K=()=>O(!0),re=(A,q)=>{let _e=A;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(_e)){(q===""||/^[0-9]+$/.test(q))&&(De(ye=>M(_({},ye),{[_e]:""})),Ee(ye=>M(_({},ye),{[_e]:q})));return}De(ye=>M(_({},ye),{[_e]:""})),Ee(ye=>M(_({},ye),{[_e]:q}))},ue=A=>{let _e=A.target.value.replace(/\D/g,""),Se="";/^3[47]/.test(_e)?Se=_e.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Xe,it,Le,at)=>[it,Le,at].filter(Boolean).join(" ")):Se=_e.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Xe,it,Le,at,be)=>[it,Le,at,be].filter(Boolean).join(" ")),De(ye=>M(_({},ye),{cardNumber:""})),Ee(ye=>M(_({},ye),{cardNumber:Se}))},xt=()=>{var ye,Xe,it,Le,at,be;let A={},q=S,_e=parseInt((q==null?void 0:q.expiryMonth)||"",10),Se=(q==null?void 0:q.expiryYear)||"";if((ye=q==null?void 0:q.cardName)!=null&&ye.trim()||(A.cardName="Card name is required"),(Xe=q==null?void 0:q.cardNumber)!=null&&Xe.trim()||(A.cardNumber="Card number is required"),(!((it=q==null?void 0:q.expiryMonth)!=null&&it.trim())||!((Le=q==null?void 0:q.expiryYear)!=null&&Le.trim())||isNaN(_e)||_e<1||_e>12||Se.length!==4)&&(A.expiryMonth="Invalid Expiration Date."),(at=q==null?void 0:q.cvv)!=null&&at.trim()||(A.cvv="CVV is required"),(be=q==null?void 0:q.zipCode)!=null&&be.trim()||(A.zipCode="ZIP code is required"),q!=null&&q.expiryMonth&&(q!=null&&q.expiryYear)&&q.expiryMonth.length<=2&&q.expiryYear.length===4){let Bt=parseInt(q.expiryMonth,10),kt=parseInt(q.expiryYear,10),ft=new Date,_t=ft.getMonth()+1,Tt=ft.getFullYear();(kt<Tt||kt===Tt&&Bt<_t)&&(A.expiryMonth="Card is expired")}return De(A),Object.keys(A).length>0},Re=async A=>{var q,_e,Se,ye,Xe,it,Le,at,be,Bt,kt,ft,_t,Tt,Zt,qt,Yt,vt,Te;if(A.preventDefault(),he=="card"){if(xt())return;{let ht=DatacapWebToken.validateCardNumber(S==null?void 0:S.cardNumber.replaceAll(" ","")),Rt=DatacapWebToken.validateExpirationDate(S==null?void 0:S.expiryMonth,S==null?void 0:S.expiryYear),Ve=DatacapWebToken.validateCVV(S==null?void 0:S.cvv),Ft={};if(ht||(Ft.cardNumber="Invalid card Number"),Rt||(Ft.expiryMonth="Invalid Expiration Date."),Ve||(Ft.cvv="Invalid CVV"),De(Ft),ht&&Ve&&Rt){E(!0);try{let Pt=async function(et){if(et.Error)V(et.Error),E(!1);else{let ot=S==null?void 0:S.cardName,en=S==null?void 0:S.zipCode;et.name=ot,et.postal_code=en,et.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,et.amount=e==null?void 0:e.amount,et.order_id=e==null?void 0:e.orderID,et.preAuth_id="",et.isCardSave=a,et.customer_id=e==null?void 0:e.customerId,et.link_token="",et.gateway_id=F==null?void 0:F.paymentGateway,et.discount=e==null?void 0:e.discount,et.tax=e==null?void 0:e.tax,et.surcharge=e==null?void 0:e.surcharge,et.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let on={method:"POST",body:JSON.stringify(et),redirect:"follow"};mt.emit("sendMessage",M(_({},on),{isChargePreauth:!0})),mt.on("charge-preauth",yt=>{var Xt;console.log(yt,"datdata"),(yt==null?void 0:yt.status)=="Failed"?(E(!1),V((yt==null?void 0:yt.message)||"Something went wrong. Please try again later.")):(Ke(!0),v((Xt=yt==null?void 0:yt.data)==null?void 0:Xt.transaction_id),E(!1),Ee({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((F==null?void 0:F.paymentGateway)===32){let et={method:"POST",redirect:"follow"};try{let ot=await zn.post(`${Ie}api/v1/widget/generate-session`,et),en=Number(S==null?void 0:S.expiryYear)%100,Et=S==null?void 0:S.cardNumber;Et=Et==null?void 0:Et.replace(/\s+/g,"");let on=`${Et}=${en}${S==null?void 0:S.expiryMonth} ${S==null?void 0:S.cvv}`,Xt=forge.pki.publicKeyFromPem((_e=(q=ot==null?void 0:ot.data)==null?void 0:q.data)==null?void 0:_e.publicKeyPem).encrypt(on,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),rn=forge.util.encode64(Xt),I={"Content-Type":"application/json","x-app-session-key":(ye=(Se=ot.data)==null?void 0:Se.data)==null?void 0:ye.session_key},p=JSON.stringify({enc_track2_data:`${rn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(it=(Xe=ot==null?void 0:ot.data)==null?void 0:Xe.data)==null?void 0:it.session_key}`});try{let J=await zn.post(`${At}tokenizer/tokenize`,p,{headers:I}),He=JSON.stringify(M(_({},(Le=J==null?void 0:J.data)==null?void 0:Le.data),{name:S==null?void 0:S.cardName,postal_code:S==null?void 0:S.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(be=(at=J==null?void 0:J.data)==null?void 0:at.data)==null?void 0:be.token}`,fractalpayPublicKey:b,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:a,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:S==null?void 0:S.expiryYear,ExpirationMonth:S==null?void 0:S.expiryMonth,CVV:S==null?void 0:S.cvv,Last4:(kt=(Bt=J==null?void 0:J.data)==null?void 0:Bt.data)==null?void 0:kt.last4,Brand:(_t=(ft=J==null?void 0:J.data)==null?void 0:ft.data)==null?void 0:_t.brand,gateway_id:F==null?void 0:F.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),m={method:"POST",headers:{"Content-Type":"application/json"},body:He,redirect:"follow"};mt.emit("sendMessage",M(_({},m),{isFractalPreauth:!0})),mt.on("fractal-charge-preauth",Y=>{var fe;(Y==null?void 0:Y.status)=="Failed"?(E(!1),V((Y==null?void 0:Y.message)||"Something went wrong , Try again later")):(v((fe=Y==null?void 0:Y.data)==null?void 0:fe.transaction_id),Ke(!0),E(!1))})}catch(J){console.log(J),E(!1),V(((Zt=(Tt=J==null?void 0:J.response)==null?void 0:Tt.data)==null?void 0:Zt.message)||(J==null?void 0:J.message)||"Something went wrong , Try again later")}}catch(ot){E(!1),V(((Yt=(qt=ot==null?void 0:ot.response)==null?void 0:qt.data)==null?void 0:Yt.message)||(ot==null?void 0:ot.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(F==null?void 0:F.dctoken,"PaymentForm",Pt)}catch(Pt){E(!1),V(((Te=(vt=Pt==null?void 0:Pt.response)==null?void 0:vt.data)==null?void 0:Te.message)||(Pt==null?void 0:Pt.message)||"Something went wrong.")}}}}},nt=async()=>{var A,q,_e,Se,ye,Xe,it,Le,at,be,Bt,kt,ft,_t,Tt,Zt,qt,Yt;c();try{let vt={fractalpayPublicKey:b,customer_id:e==null?void 0:e.customerId,preauth:!0},Te=await zn.post(`${$e}get-payment-details`,vt);if(x((A=Te==null?void 0:Te.data)==null?void 0:A.data),(_e=(q=Te==null?void 0:Te.data)==null?void 0:q.data)!=null&&_e.paymentGateway||(P(),V("Something went wrong.")),(ye=(Se=Te==null?void 0:Te.data)==null?void 0:Se.data)!=null&&ye.card_list&&((Le=(it=(Xe=Te==null?void 0:Te.data)==null?void 0:Xe.data)==null?void 0:it.card_list)==null?void 0:Le.length)>0){Ct((be=(at=Te==null?void 0:Te.data)==null?void 0:at.data)==null?void 0:be.card_list),Fe("cardList");let St=(ft=(kt=(Bt=Te==null?void 0:Te.data)==null?void 0:Bt.data)==null?void 0:kt.card_list)==null?void 0:ft.filter(ht=>(ht==null?void 0:ht.primary_card)==1);St!=null&&St[0]&&((_t=St==null?void 0:St[0])==null?void 0:_t.payment_method_type)==((Zt=(Tt=Te==null?void 0:Te.data)==null?void 0:Tt.data)==null?void 0:Zt.paymentGateway)&&l(St[0])}else Fe("card");u()}catch(vt){console.log(vt),u(),V(((Yt=(qt=vt==null?void 0:vt.response)==null?void 0:qt.data)==null?void 0:Yt.message)||(vt==null?void 0:vt.message)||"Something went wrong")}},lt=async()=>{var Bt,kt,ft,_t,Tt,Zt,qt;let A=e==null?void 0:e.customerId,q=e==null?void 0:e.discount,_e=e==null?void 0:e.surcharge,Se=e==null?void 0:e.tax,ye=e==null?void 0:e.merchantPublicKey,Xe=e==null?void 0:e.orderID,it=e==null?void 0:e.amount,Le=z==null?void 0:z.id,at=z==null?void 0:z.card_type;if(ye&&Xe&&it)if(A)if(Le){let Yt={amount:it,order_id:Xe,customer_id:A,card_id:Le,fractalpayPublicKey:ye,isCardSave:at!="Bank",discount:q,surcharge:_e,tax:Se},be=Yt,{isCardSave:vt}=be,Te=vn(be,["isCardSave"]),ht=$e+"authorize-by-card",Rt={"Content-Type":"application/json"};E(!0);try{let Ve=await zn.post(ht,at=="Bank"?Te:Yt,{headers:Rt});(Bt=Ve==null?void 0:Ve.data)!=null&&Bt.result&&(v((ft=(kt=Ve==null?void 0:Ve.data)==null?void 0:kt.data)==null?void 0:ft.transaction_id),Ke(!0),E(!1))}catch(Ve){E(!1),console.log(Ve),V(((Tt=(_t=Ve==null?void 0:Ve.response)==null?void 0:_t.data)==null?void 0:Tt.message)||((qt=(Zt=Ve==null?void 0:Ve.response)==null?void 0:Zt.data)==null?void 0:qt.status)||"Something went erong")}}else V("Please Select A Card/ACH");else V("Please Select Customer");else V("Something went wrong.")};mi(()=>{we&&b&&nt()},[b,we]);let ct=async A=>{En.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 q=>{if(q.isConfirmed){E(!0);try{let _e={card_id:A,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},Se=await zn.post(`${$e}delete-customer-card`,_e);E(!1),nt(),En.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(_e){E(!1),En.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},rt=A=>{switch(A==null?void 0:A.toLowerCase()){case"visa":return h;case"mastercard":case"mc":case"m/c":return ee;case"amex":case"american express":case"ae":return Me;case"discover":case"dcvr":return se;case"bank":return Ze;default:return A}};return s.createElement(s.Fragment,null,s.createElement(Qt,null),s.createElement(hn,null),s.createElement(s.Fragment,null,s.createElement("button",{className:"paymentBtn",onClick:K},"PreAuth Payment"),s.createElement(Gt,{open:we,onClose:P},Oe&&s.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},s.createElement(nn,{error:Oe,onClose:P})),gt&&s.createElement(yn,{onClose:P,tranId:d}),!Oe&&!gt&&s.createElement(s.Fragment,null,(w||Q)&&s.createElement(Vt,{loading:w||Q}),s.createElement("div",null,s.createElement("div",{className:"frac-card-payment-page frac-form"},s.createElement("div",{className:"parent-pay-container"},s.createElement("span",{className:"request-payment-close-popup",onClick:P},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12425_52336)"},s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12425_52336"},s.createElement("rect",{width:"16",height:"16",fill:"white"}))))),s.createElement("div",{className:"pay-container"},s.createElement("div",{className:"pay-header pay-conatiner-one"},s.createElement("div",{className:"pay-conatiner-one-first"},s.createElement("div",{className:"pay-logo-container"},s.createElement("div",{className:"pay-main-logo"},s.createElement("img",{src:F==null?void 0:F.logo,id:"pay-logos"})),s.createElement("h1",{className:"pay-heading"},"Pay"),(ze==null?void 0:ze.length)>0&&he!=="cardList"&&s.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",s.createElement(di,null)," Back")),s.createElement("div",{className:"amt-pay-con"},s.createElement("div",{className:"pay-amount-conatiner"},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ue((Ae=Number(e==null?void 0:e.amount))==null?void 0:Ae.toFixed(2))),f&&f>0&&s.createElement("div",{style:{width:"80%"},className:"frac-cash-discount"},s.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),s.createElement("div",null,Ue(f.toFixed(2))))),he!="ach"&&s.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},s.createElement("img",{src:h,alt:"",width:33}),s.createElement("img",{src:ee,width:33,alt:""}),s.createElement("img",{src:Me,alt:"",width:33}),s.createElement("img",{src:se,width:33,alt:""})))),s.createElement("div",{className:"pay-conatiner-one-last"},s.createElement("img",{src:G,alt:""}),s.createElement("img",{src:pt,alt:""}),"Secure payments powered by Fractal"),s.createElement("div",null)),!w&&s.createElement("div",{className:"pay-tab pay-conatiner-two"},s.createElement("div",{className:"col-md-12"},s.createElement("div",{id:"payment-form-div"},he!=="cardList"?s.createElement("div",null,(ze==null?void 0:ze.length)>0&&s.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",s.createElement(di,null)," Back"),s.createElement("div",{className:""},s.createElement("div",{className:"res-pay-con"},s.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ue((xe=Number(e==null?void 0:e.amount))==null?void 0:xe.toFixed(2)))),s.createElement("div",null,s.createElement("div",null,s.createElement("img",{src:h,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:ee,width:35,alt:""})),s.createElement("div",null,s.createElement("img",{src:Me,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:se,width:35,alt:""})))),f&&f>0&&s.createElement("div",{className:"res-pay-con frac-cash-discount"},s.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),s.createElement("div",null,Ue(f.toFixed(2)))))):s.createElement("div",null,s.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",F==null?void 0:F.customer_name),s.createElement("div",{className:"res-pay-con"},s.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ue((Z=Number(e==null?void 0:e.amount))==null?void 0:Z.toFixed(2)))),s.createElement("div",null,s.createElement("div",null,s.createElement("img",{src:h,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:ee,width:35,alt:""})),s.createElement("div",null,s.createElement("img",{src:Me,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:se,width:35,alt:""})))),s.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),s.createElement("div",{style:{display:he==="cardList"?"block":"none"},className:"tabcontent"},s.createElement("div",{className:"card-lint-div-in"},s.createElement("div",{className:"card-list-div"},(F==null?void 0:F.card_list)&&((Be=F==null?void 0:F.card_list)==null?void 0:Be.length)>0&&((Je=F==null?void 0:F.card_list)==null?void 0:Je.map((A,q)=>s.createElement("div",{className:"card-list-single-div",key:q},s.createElement("div",{className:"card-number-radio"},s.createElement("input",{disabled:(F==null?void 0:F.paymentGateway)!=(A==null?void 0:A.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:z===A,onChange:_e=>l(A)}),s.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",A==null?void 0:A.cardlastfourdigit),s.createElement("h6",{className:"card-expiry-date"},A==null?void 0:A.expmonth,"/",A==null?void 0:A.expyear)),s.createElement("div",{className:"card-number-radio"},s.createElement("span",{className:"visa-card"},s.createElement("img",{src:rt(A==null?void 0:A.card_type),alt:""})),s.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>ct(A==null?void 0:A.id)},s.createElement("img",{src:C,alt:""}))))))),s.createElement("div",{className:"pay-with-other-card ",onClick:()=>Fe("card")},"Authorize With Other Card",s.createElement("img",{src:je,alt:""}))),s.createElement("div",{className:"form-group"},s.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:lt},Ue(($=Number(e==null?void 0:e.amount))==null?void 0:$.toFixed(2))))),s.createElement("div",{id:"card",style:{display:he==="card"?"block":"none"},className:"tabcontent"},s.createElement("form",{id:"PaymentForm",onSubmit:Re},s.createElement("div",{className:"ach-scrl",style:{minHeight:(ze==null?void 0:ze.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),s.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(S==null?void 0:S.cardName)||"",onChange:A=>{let q=A.target.value;/^[a-zA-Z\s]*$/.test(q)&&re("cardName",q)}}),(te==null?void 0:te.cardName)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.cardName)),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"cardNumber"},"Card Number"),s.createElement("div",{className:"toggle-num-wrapper"},s.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(S==null?void 0:S.cardNumber)||"",onChange:A=>ue(A),"data-token":"card_number"}),s.createElement("div",{className:"card-crdi card-expiry-new"},s.createElement("div",{className:"exp-date-year-container"},s.createElement("div",{className:"exp-date form-group"},s.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(S==null?void 0:S.expiryMonth)||"",onChange:A=>re("expiryMonth",A.target.value)})),s.createElement("div",{className:"exp-year form-group"},s.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(S==null?void 0:S.expiryYear)||"",onChange:A=>re("expiryYear",A.target.value)})),s.createElement("div",{className:"security-digit form-group"},s.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(S==null?void 0:S.cvv)||"",onChange:A=>re("cvv",A.target.value)})))),(te==null?void 0:te.cardNumber)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.cardNumber),s.createElement("p",{style:{margin:"0"}},te!=null&&te.expiryMonth||te!=null&&te.expiryYear?s.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},te==null?void 0:te.expiryMonth):"",(te==null?void 0:te.cvv)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.cvv)))),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),s.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(Nt=S==null?void 0:S.orderId)!=null?Nt:"OID123456",onChange:A=>re("orderId",A.target.value),style:{background:"#F6F6F7",color:"#727272"}})),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"zip"},"ZIP"),s.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Kt=S==null?void 0:S.zipCode)!=null?Kt:"",onChange:A=>re("zipCode",A.target.value)}),(te==null?void 0:te.zipCode)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.zipCode)),(e==null?void 0:e.customerId)&&s.createElement("div",{className:"form-group"},s.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},s.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:a,onChange:A=>N(A.target.checked)}),s.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),s.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),s.createElement("div",{className:"frac-tooltip-wrapper"},s.createElement("div",{className:"frac-tooltip-icon"},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12420_50192)"},s.createElement("rect",{width:"20",height:"20",fill:"white"}),s.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12420_50192"},s.createElement("rect",{width:"20",height:"20",fill:"white"}))))),s.createElement("div",{className:"frac-tooltip-text"},s.createElement("p",null,"If checked, I agree to give the ",s.createElement("b",null,(F==null?void 0:F.bname)||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),s.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},s.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((wt=Number(e==null?void 0:e.amount))==null?void 0:wt.toFixed(2)))))))))))))))))}import ke,{useEffect as Ji,useRef as An,useState as xn}from"react";import Xi from"sweetalert2";import kn from"axios";import Wi from"react";function Wn(){let e="#000",w="#fff",j="#212529",Q="#dee2e6";return Wi.createElement("style",null,`
1672
+ `)}import It from"react";var un=({listHeading:e="Card",ListItems:w,selectedCard:j,setSelectedCard:Q,paymentGateway:E,handleDeleteCard:Oe,otherButtonAction:V,otherButtonLabel:gt,headingClass:Ke})=>{let we=oe+"widget/Trash.svg";return console.log(j,"selectedCard another",w),It.createElement(It.Fragment,null,It.createElement("h6",{className:Ke||"card-ach-heading",style:{marginBottom:"10px !important"}},e),It.createElement("div",{className:"card-lint-div-in"},It.createElement("div",{className:"card-list-div"},w&&(w==null?void 0:w.length)>0&&(w==null?void 0:w.map((O,he)=>{let Fe=!1;return E&&(Fe=E!=(O==null?void 0:O.payment_method_type)&&(O==null?void 0:O.card_type)!="Bank"),It.createElement("div",{key:O==null?void 0:O.id,className:"card-list-single-div"},It.createElement("div",{className:"card-number-radio"},It.createElement("input",{disabled:Fe,type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:(j==null?void 0:j.id)===(O==null?void 0:O.id),onChange:a=>Q(O)}),It.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",O==null?void 0:O.cardlastfourdigit),(O==null?void 0:O.card_type)!="Bank"&&It.createElement("h6",{className:"card-expiry-date"},O==null?void 0:O.expmonth,"/",O==null?void 0:O.expyear)),It.createElement("div",{className:"card-number-radio"},It.createElement("span",{className:"visa-card"},It.createElement("img",{src:si(O==null?void 0:O.card_type),alt:""})),It.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Oe(O==null?void 0:O.id)},It.createElement("img",{src:we,alt:""}))))}))),It.createElement("div",{className:"pay-with-other-card",onClick:V},gt,It.createElement("img",{src:Mn,alt:""}))))};function Zi(e){var qt,Yt,vt,Te,St,ht,Rt,Ve,Ft,Pt,et,ot,en,Et,on,yt,Xt,rn;let[w,j]=dt(!1),[Q,E]=dt(!1),[Oe,V]=dt(""),[gt,Ke]=dt(!1),[we,O]=dt(!1),[he,Fe]=dt("card"),[a,N]=dt("card"),[b,ee]=dt("form"),[h,Me]=dt("form"),[se,je]=dt(!0),[C,Ze]=dt(!1),[G,pt]=dt(!1),S=e.merchantPublicKey,Ee=oe+"widget/mc-img.svg",te=oe+"widget/visa-img.svg",De=oe+"widget/ae-img.svg",ze=oe+"widget/discover-img.svg",Ct=oe+"widget/card.svg",z=oe+"widget/Trash.svg",l=oe+"widget/bank.svg",f=oe+"widget/secure-img.png",D=oe+"widget/pov-by.png",F=oe+"widget/pax.svg",[x,d]=dt(),[v,k]=dt({}),[c,u]=dt(),[P,K]=dt({}),[re,ue]=dt([]),[xt,Re]=dt([]),[nt,lt]=dt(),[ct,rt]=dt(),[Ae,xe]=dt(Number(e==null?void 0:e.amount));console.log(nt,"selectedCard");let[Z,Be]=dt(),[Ge,$]=dt(""),Nt=()=>j(!0),Kt=()=>j(!1),wt=(I,p)=>{let J=(parseFloat(p)||0)/100,He=I/(1+J);return Math.round(He*100)/100};li(()=>{if(we){let I=wt(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);xe(I)}},[we,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let A=()=>{O(!1),Fe("card"),V(""),Ke(!1),$(""),u({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),K({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),d({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),k({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),pt(!1),Ze(!1),lt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),rt({}),xe(0),N("card"),je(!0),Me("form"),ee("form"),E(!1),j(!1),Re([]),ue([])},q=()=>O(!0),_e=I=>{Fe(I)},Se=(I,p)=>{let J=I;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(J)){(p===""||/^[0-9]+$/.test(p))&&(k(g=>M(_({},g),{[J]:""})),d(g=>M(_({},g),{[J]:p})));return}k(g=>M(_({},g),{[J]:""})),d(g=>M(_({},g),{[J]:p}))},ye=I=>{let J=I.target.value.replace(/\D/g,""),He="";/^3[47]/.test(J)?He=J.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(m,Y,fe,W)=>[Y,fe,W].filter(Boolean).join(" ")):He=J.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(m,Y,fe,W,Ne)=>[Y,fe,W,Ne].filter(Boolean).join(" ")),k(g=>M(_({},g),{cardNumber:""})),d(g=>M(_({},g),{cardNumber:He}))},Xe=I=>{let{name:p,value:J}=I.target,He=["routingNumber","accountNumber","confirmAccountNumber"];if(p=="name"){/^[a-zA-Z\s]*$/.test(J)&&(K(g=>M(_({},g),{[p]:""})),u(g=>M(_({},g),{[p]:J})));return}if(He.includes(p)){(J===""||/^[0-9]+$/.test(J))&&(K(g=>M(_({},g),{[p]:""})),u(g=>M(_({},g),{[p]:J})));return}K(g=>M(_({},g),{[p]:""})),u(g=>M(_({},g),{[p]:J}))},it=()=>{var g,m,Y,fe,W,Ne;let I={},p=x,J=parseInt((p==null?void 0:p.expiryMonth)||"",10),He=(p==null?void 0:p.expiryYear)||"";if((g=p==null?void 0:p.cardName)!=null&&g.trim()||(I.cardName="Card name is required"),(m=p==null?void 0:p.cardNumber)!=null&&m.trim()||(I.cardNumber="Card number is required"),(!((Y=p==null?void 0:p.expiryMonth)!=null&&Y.trim())||!((fe=p==null?void 0:p.expiryYear)!=null&&fe.trim())||isNaN(J)||J<1||J>12||He.length!==4)&&(I.expiryMonth="Invalid Expiration Date."),(W=p==null?void 0:p.cvv)!=null&&W.trim()||(I.cvv="CVV is required"),(Ne=p==null?void 0:p.zipCode)!=null&&Ne.trim()||(I.zipCode="ZIP code is required"),p!=null&&p.expiryMonth&&(p!=null&&p.expiryYear)&&p.expiryMonth.length<=2&&p.expiryYear.length===4){let Pe=parseInt(p.expiryMonth,10),i=parseInt(p.expiryYear,10),o=new Date,L=o.getMonth()+1,U=o.getFullYear();(i<U||i===U&&Pe<L)&&(I.expiryMonth="Card is expired")}return k(I),Object.keys(I).length>0},Le=()=>{var J,He,g,m,Y,fe,W,Ne;let I={},p=c;return(J=p==null?void 0:p.name)!=null&&J.trim()||(I.name="Name is required"),(He=p==null?void 0:p.accountNumber)!=null&&He.trim()||(I.accountNumber="Account number is required"),(g=p==null?void 0:p.accountNumber)!=null&&g.trim()&&((m=p==null?void 0:p.accountNumber)==null?void 0:m.trim())!==((Y=p==null?void 0:p.confirmAccountNumber)==null?void 0:Y.trim())&&(I.confirmAccountNumber="Account numbers must match"),(fe=p==null?void 0:p.bankName)!=null&&fe.trim()||(I.bankName="Bank name is required"),(W=p==null?void 0:p.routingNumber)!=null&&W.trim()||(I.routingNumber="Routing Number is required"),p!=null&&p.routingNumber&&((Ne=p==null?void 0:p.routingNumber)==null?void 0:Ne.length)!==9&&(I.routingNumber="Routing number must be 9 digits"),((p==null?void 0:p.accountType)==="business saving"||(p==null?void 0:p.accountType)==="business checking")&&(!(p!=null&&p.companyName)||(p==null?void 0:p.companyName)==="")&&(I.companyName="Company Name is required for business accounts"),K(I),Object.keys(I).length>0},at=async I=>{var p,J,He,g,m,Y,fe,W,Ne,Pe,i,o,L,U,y,R;if(I.preventDefault(),he!=="ach"){if(it())return;{let pe=DatacapWebToken.validateCardNumber(x==null?void 0:x.cardNumber.replaceAll(" ","")),ie=DatacapWebToken.validateExpirationDate(x==null?void 0:x.expiryMonth,x==null?void 0:x.expiryYear),de=DatacapWebToken.validateCVV(x==null?void 0:x.cvv),le={};if(pe||(le.cardNumber="Invalid card Number"),ie||(le.expiryMonth="Invalid Expiration Date."),de||(le.cvv="Invalid CVV"),k(le),pe&&de&&ie){E(!0);try{let ae=M(_({},x),{amount:`${e.amount||0}`,fractalpayPublicKey:S,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}),ce=await wn.post(`${$e}create-widget-order`,ae),me=async function(ve){if(ve.Error)V(ve.Error),E(!1);else{let Ce=x==null?void 0:x.cardName,X=x==null?void 0:x.zipCode;ve.name=Ce,ve.postal_code=X,ve.isCardSave=`${C}`,ve.isCharge=!0,ve.posSalesIdEncode=ce==null?void 0:ce.data.data.posSalesIdEncode,mt.emit("sendMessage",ve),mt.on(ce==null?void 0:ce.data.data.posSalesIdEncode,ge=>{if(Cn(ge==null?void 0:ge.data)){let We=JSON.parse(ge.data);We!=null&&We.result?(d({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Ze(!1),$(We==null?void 0:We.transactionId),Ke(!0),E(!1)):(E(!1),V((We==null?void 0:We.message)||"Something went wrong."))}else V("Something went wrong.")})}};if((Z==null?void 0:Z.paymentGateway)===32){let ve={method:"POST",redirect:"follow"};try{let Ce=await wn.post(`${Ie}api/v1/widget/generate-session`,ve),X=Number(x==null?void 0:x.expiryYear)%100,ge=x==null?void 0:x.cardNumber;ge=ge==null?void 0:ge.replace(/\s+/g,"");let We=`${ge}=${X}${x==null?void 0:x.expiryMonth} ${x==null?void 0:x.cvv}`,tt=forge.pki.publicKeyFromPem((J=(p=Ce==null?void 0:Ce.data)==null?void 0:p.data)==null?void 0:J.publicKeyPem).encrypt(We,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Je=forge.util.encode64(tt),Mt={"Content-Type":"application/json","x-app-session-key":(g=(He=Ce.data)==null?void 0:He.data)==null?void 0:g.session_key},Sn=JSON.stringify({enc_track2_data:`${Je}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Y=(m=Ce==null?void 0:Ce.data)==null?void 0:m.data)==null?void 0:Y.session_key}`});try{let Lt=await wn.post(`${At}tokenizer/tokenize`,Sn,{headers:Mt}),zt=JSON.stringify(M(_({},(fe=Lt==null?void 0:Lt.data)==null?void 0:fe.data),{isSaveCardChecked:C,name:x==null?void 0:x.cardName,postal_code:x==null?void 0:x.zipCode,customer_id:e==null?void 0:e.customerId})),sn=JSON.stringify({pre_sales_id:`${(Ne=(W=ce==null?void 0:ce.data)==null?void 0:W.data)==null?void 0:Ne.posSalesIdEncode}`,token:`${(Pe=Lt==null?void 0:Lt.data)==null?void 0:Pe.data.token}`,json_response:`${zt}`}),Wt={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:sn,redirect:"follow",isChargeviafractal:!0};mt.emit("sendMessage",Wt),mt.on("chargeviafractalgateway",Ht=>{var tn;if(Cn(Ht==null?void 0:Ht.data)){let Ut=JSON.parse(Ht==null?void 0:Ht.data);Ut!=null&&Ut.result?($((tn=Ut==null?void 0:Ut.data)==null?void 0:tn.transactionId),Ke(!0),E(!1)):(E(!1),V((Ut==null?void 0:Ut.message)||"Something went wrong."))}else V("Something went wrong.")})}catch(Lt){E(!1),V(((o=(i=Lt==null?void 0:Lt.response)==null?void 0:i.data)==null?void 0:o.message)||(Lt==null?void 0:Lt.message)||"Something went wrong.")}}catch(Ce){E(!1),V(((U=(L=Ce==null?void 0:Ce.response)==null?void 0:L.data)==null?void 0:U.message)||(Ce==null?void 0:Ce.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(ce==null?void 0:ce.data.data.dctoken,"PaymentForm",me)}catch(ae){E(!1),V(((R=(y=ae==null?void 0:ae.response)==null?void 0:y.data)==null?void 0:R.message)||(ae==null?void 0:ae.message)||"Something went wrong.")}}}}else{if(Le())return;{E(!0);let pe={fractalpayPublicKey:S,label:(c==null?void 0:c.name)||"John Doe",account_number:c==null?void 0:c.accountNumber,routing_number:c==null?void 0:c.routingNumber,bank_name:c==null?void 0:c.bankName,account_type:c==null?void 0:c.accountType,amount:String(Ae||0),isSaveAch:G,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:(c==null?void 0:c.companyName)||""};mt.emit("sendMessage",pe),mt.on("ach-incoming",ie=>{var de;(ie==null?void 0:ie.status)=="Failed"?typeof(ie==null?void 0:ie.message)=="object"?Object.values(ie==null?void 0:ie.message).forEach(le=>{V(le||"Something went wrong")}):V((ie==null?void 0:ie.message)||"Something went wrong"):($((de=ie==null?void 0:ie.data)==null?void 0:de.transaction_id),Ke(!0),E(!1))})}}},be=async()=>{var I,p,J,He,g,m,Y,fe,W,Ne,Pe,i,o,L,U,y,R,ne,pe,ie,de,le,ae;Nt();try{let ce={fractalpayPublicKey:S,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee},me=await wn.post(`${$e}get-payment-details`,ce);if(Be((I=me==null?void 0:me.data)==null?void 0:I.data),(J=(p=me==null?void 0:me.data)==null?void 0:p.data)!=null&&J.paymentGateway||(A(),V("Something went wrong.")),(g=(He=me==null?void 0:me.data)==null?void 0:He.data)!=null&&g.card_list&&((fe=(Y=(m=me==null?void 0:me.data)==null?void 0:m.data)==null?void 0:Y.card_list)==null?void 0:fe.length)>0){let ve=(Pe=(Ne=(W=me==null?void 0:me.data)==null?void 0:W.data)==null?void 0:Ne.card_list)==null?void 0:Pe.filter(X=>(X==null?void 0:X.card_type)=="Bank"),Ce=(L=(o=(i=me==null?void 0:me.data)==null?void 0:i.data)==null?void 0:o.card_list)==null?void 0:L.filter(X=>(X==null?void 0:X.card_type)!=="Bank");console.log(ve,"hohgohoo",Ce),(Ce==null?void 0:Ce.length)>0&&ee("list"),(ve==null?void 0:ve.length)>0&&Me("list"),ue(Ce),Re(ve)}else Fe("card");(y=(U=me==null?void 0:me.data)==null?void 0:U.data)!=null&&y.paymentDeviceList&&((pe=(ne=(R=me==null?void 0:me.data)==null?void 0:R.data)==null?void 0:ne.paymentDeviceList)==null?void 0:pe.length)>0&&rt((de=(ie=me==null?void 0:me.data)==null?void 0:ie.data)==null?void 0:de.paymentDeviceList[0]),Kt()}catch(ce){console.log(ce),Kt(),V(((ae=(le=ce==null?void 0:ce.response)==null?void 0:le.data)==null?void 0:ae.message)||(ce==null?void 0:ce.message)||"Something went wrong")}},Bt=async()=>{let I=e==null?void 0:e.customerId,p=String(e==null?void 0:e.discount),J=String(e==null?void 0:e.surcharge),He=String(e==null?void 0:e.tax),g=e==null?void 0:e.merchantPublicKey,m=e==null?void 0:e.orderID,Y=String(e==null?void 0:e.amount),fe=nt==null?void 0:nt.id,W=nt==null?void 0:nt.card_type;if(g&&m&&Y&&Ae)if(I)if(fe){let Pe={amount:W==="Bank"?Ae:Y,order_id:m,customer_id:I,card_id:fe,fractalpayPublicKey:g,isCardSave:C,discount:p,surcharge:J,tax:He},Ne=Pe,{isCardSave:i}=Ne,o=vn(Ne,["isCardSave"]),U=$e+(W==="Bank"?"charge-ach":"charge-by-card"),y={"Content-Type":"application/json"};E(!0),mt.emit("sendMessage",{url:U,body:W=="Bank"?o:Pe,isChargebycard:!0}),mt.on("charge-by-card",R=>{var ne;(R==null?void 0:R.result)==!0||(R==null?void 0:R.status)==!0?($((ne=R.data)==null?void 0:ne.transaction_id),Ke(!0),E(!1)):V((R==null?void 0:R.message)||"Something went wrong.")})}else V("Please Select A Card/ACH");else V("Please Select Customer");else V("Something went wrong.")},kt=async()=>{var g,m,Y,fe,W,Ne;let I=e==null?void 0:e.merchantPublicKey,p=e==null?void 0:e.orderID,J=String(e==null?void 0:e.amount),He=e==null?void 0:e.customerId;if(!(ct!=null&&ct.device_id)){V("Please Select A Payment Device");return}if(I&&p&&J){E(!0);let Pe={amount:J,fractalpayPublicKey:I,customer_order_id:p,device_id:ct==null?void 0:ct.device_id,customer_id:He||""};try{let i=await wn.post(`${$e}charge-with-reader`,Pe);((g=i==null?void 0:i.data)==null?void 0:g.result)==!0?($((Y=(m=i==null?void 0:i.data)==null?void 0:m.data)==null?void 0:Y.transaction_id),Ke(!0),E(!1)):(V(((fe=i==null?void 0:i.data)==null?void 0:fe.message)||"Something went wrong."),E(!1))}catch(i){V(((Ne=(W=i==null?void 0:i.response)==null?void 0:W.data)==null?void 0:Ne.message)||"Something went wrong."),E(!1)}}else V("Something went wrong.")},ft=()=>{a==="card"?Bt():a==="reader"&&kt()};li(()=>{we&&S&&be()},[S,we]);let _t=async I=>{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 p=>{if(p.isConfirmed){E(!0);try{let J={card_id:I,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},He=await wn.post(`${$e}delete-customer-card`,J);E(!1),be(),Ln.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(J){E(!1),Ln.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else p.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"}})})},Tt=I=>{switch(I==null?void 0:I.toLowerCase()){case"visa":return te;case"mastercard":case"mc":case"m/c":return Ee;case"amex":case"american express":case"ae":return De;case"discover":case"dcvr":return ze;case"bank":return l;default:return I}},Zt=()=>{let I=Ae||0;return(Number(e.amount)-I).toFixed(0)};return console.log(b,"activeinCard","activeinBank",h),n.createElement(n.Fragment,null,n.createElement(Qt,null),n.createElement(hn,null),n.createElement(bn,null),n.createElement(n.Fragment,null,n.createElement("button",{className:"paymentBtn",onClick:q},"Pay"),n.createElement(Gt,{open:we,onClose:A},Oe&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(nn,{error:Oe,onClose:A})),gt&&n.createElement(yn,{onClose:A,tranId:Ge}),!Oe&&!gt&&n.createElement(n.Fragment,null,(w||Q)&&n.createElement(Vt,{loading:w||Q}),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:A},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("img",{src:Z==null?void 0:Z.logo,id:"pay-logos"})),n.createElement("div",{className:"pay-container"},n.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},n.createElement("div",{className:"pay-conatiner-one-first"},n.createElement("div",{className:"pay-logo-container"},n.createElement("div",{className:"pay-main-logo"},n.createElement("img",{src:Z==null?void 0:Z.logo,id:"pay-logos"})),(re==null?void 0:re.length)>0&&he!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",n.createElement(jn,null)," Back")),n.createElement("div",{className:"amt-pay-con"},n.createElement("div",{className:"pay-amount-conatiner"},n.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),n.createElement("div",{className:"frac-card-bank-radio-main"},n.createElement(cn,{label:"Card",amount:(qt=Number(e==null?void 0:e.amount))==null?void 0:qt.toFixed(2),value:"card",onChange:_e,activetab:he}),(Z==null?void 0:Z.isSkyFiAccount)&&n.createElement(cn,{label:"Bank",amount:(Yt=Number(Ae))==null?void 0:Yt.toFixed(2),value:"ach",onChange:_e,activetab:he})),Ae&&Ae>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,he==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,Ue((Number(e.amount)-Ae).toFixed(2)))):null)),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:f,alt:""}),n.createElement("img",{src:D,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},!w&&n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},he!=="cardList"?n.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(re==null?void 0:re.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",n.createElement(jn,null)," Back"),(Z==null?void 0:Z.isSkyFiAccount)&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks",onClick:I=>{_e("card")},style:{border:he==="card"?"1px solid":""}},n.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),n.createElement("button",{className:"tablinks",onClick:I=>{_e("ach")},style:{border:he==="ach"?"1px solid":""}},n.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"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"},"$",(vt=Number(e==null?void 0:e.amount))==null?void 0:vt.toFixed(2))),he!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:te,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Ee,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:De,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:ze,width:35,alt:""})))),Ae&&Ae>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",Ae))):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",Z==null?void 0:Z.customer_name),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",a==="card"?"Cards/Banks":"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"},"$",(Te=Number(e==null?void 0:e.amount))==null?void 0:Te.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:te,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Ee,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:De,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:ze,width:35,alt:""}))))),n.createElement("div",{id:"card",style:{display:he==="card"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(re==null?void 0:re.length)>0&&b==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ee("list")}," ",n.createElement(jn,null)),Ae&&Ae>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",Ae))),n.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),he!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},n.createElement("img",{src:te,alt:"",width:33}),n.createElement("img",{src:Ee,width:33,alt:""}),n.createElement("img",{src:De,alt:"",width:33}),n.createElement("img",{src:ze,width:33,alt:""}))),b==="list"?n.createElement(n.Fragment,null,n.createElement(un,{listHeading:"Cards",paymentGateway:Z==null?void 0:Z.paymentGateway,ListItems:re,selectedCard:nt,setSelectedCard:lt,handleDeleteCard:_t,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{ee("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:ft},Ue((St=Number(e==null?void 0:e.amount))==null?void 0:St.toFixed(2))))):n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:at},n.createElement("div",{className:"ach-scrl",style:{minHeight:Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)>0?"444px":Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)==0?"456px":(re==null?void 0:re.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(x==null?void 0:x.cardName)||"",onChange:I=>{let p=I.target.value;/^[a-zA-Z\s]*$/.test(p)&&Se("cardName",p)}}),(v==null?void 0:v.cardName)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.cardName)),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(x==null?void 0:x.cardNumber)||"",onChange:I=>ye(I),"data-token":"card_number"}),n.createElement("div",{className:"card-crdi card-expiry-new"},n.createElement("div",{className:"exp-date-year-container"},n.createElement("div",{className:"exp-date form-group"},n.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(x==null?void 0:x.expiryMonth)||"",onChange:I=>Se("expiryMonth",I.target.value)})),n.createElement("div",{className:"exp-year form-group"},n.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(x==null?void 0:x.expiryYear)||"",onChange:I=>Se("expiryYear",I.target.value)})),n.createElement("div",{className:"security-digit form-group"},n.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(x==null?void 0:x.cvv)||"",onChange:I=>Se("cvv",I.target.value)})))),(v==null?void 0:v.cardNumber)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.cardNumber),n.createElement("p",{style:{margin:"0"}},v!=null&&v.expiryMonth||v!=null&&v.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},v==null?void 0:v.expiryMonth):"",(v==null?void 0:v.cvv)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.cvv)))),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(ht=e==null?void 0:e.orderID)!=null?ht:"",style:{background:"#F6F6F7",color:"#727272"}})),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Rt=x==null?void 0:x.zipCode)!=null?Rt:"",onChange:I=>Se("zipCode",I.target.value)}),(v==null?void 0:v.zipCode)&&n.createElement("span",{className:"error-span"},v==null?void 0:v.zipCode)),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:C,onChange:I=>Ze(I.target.checked)}),n.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),n.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12420_50192)"},n.createElement("rect",{width:"20",height:"20",fill:"white"}),n.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),n.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12420_50192"},n.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),n.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(Z==null?void 0:Z.paymentDeviceList)&&((Ve=Z==null?void 0:Z.paymentDeviceList)==null?void 0:Ve.length)>0&&n.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>je(!se)},se?"Pay With Reader":"Pay With Card"),n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((Ft=Number(e==null?void 0:e.amount))==null?void 0:Ft.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:he==="ach"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(xt==null?void 0:xt.length)>0&&h==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Me("list")}," ",n.createElement(jn,null)),Ae&&Ae>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),n.createElement("div",null,"$",Zt()))),n.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),h==="list"?n.createElement(n.Fragment,null,n.createElement(un,{listHeading:"Banks",paymentGateway:Z==null?void 0:Z.paymentGateway,ListItems:xt,selectedCard:nt,setSelectedCard:lt,handleDeleteCard:_t,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Me("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:ft},Ue((Pt=Number(Ae))==null?void 0:Pt.toFixed(2))))):n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:at},n.createElement("div",{className:"ach-scrl",style:{minHeight:Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)>0?"444px":Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)==0?"436px":(re==null?void 0:re.length)>0?"462px":"520px",maxHeight:Z!=null&&Z.isSkyFiAccount&&(re==null?void 0:re.length)>0?"444px":((re==null?void 0:re.length)>0,"380px")}},n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),n.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(et=c==null?void 0:c.name)!=null?et:"",onChange:Xe}),(P==null?void 0:P.name)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.name)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"routingnumber"},"Routing number"),n.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(ot=c==null?void 0:c.routingNumber)!=null?ot:"",onChange:Xe}),(P==null?void 0:P.routingNumber)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.routingNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accountnumber"},"Account number"),n.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(en=c==null?void 0:c.accountNumber)!=null?en:"",onChange:Xe}),(P==null?void 0:P.accountNumber)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.accountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),n.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Et=c==null?void 0:c.confirmAccountNumber)!=null?Et:"",onChange:Xe}),(P==null?void 0:P.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.confirmAccountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"bankname"},"Bank name"),n.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(on=c==null?void 0:c.bankName)!=null?on:"",onChange:Xe}),(P==null?void 0:P.bankName)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.bankName)),((c==null?void 0:c.accountType)==="business saving"||(c==null?void 0:c.accountType)==="business checking")&&n.createElement("div",{className:"form-group 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:(yt=c==null?void 0:c.companyName)!=null?yt:"",onChange:Xe}),(P==null?void 0:P.companyName)&&n.createElement("span",{className:"error-span"},P==null?void 0:P.companyName)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accounttype"},"Select account type"),n.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(Xt=c==null?void 0:c.accountType)!=null?Xt:"",onChange:Xe},n.createElement("option",{value:""},"Select account"),Nn.map(I=>n.createElement("option",{key:I.value,value:I.value},I.label)))),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},n.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:G,onChange:I=>pt(I.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),G&&n.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},n.createElement("p",null,"If checked, I agree for ",n.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),n.createElement("div",{className:"form-group "},n.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Ue((rn=Number(Ae))==null?void 0:rn.toFixed(2))))))))))))))))}import s,{useEffect as mi,useState as Jt}from"react";import zn from"axios";import En from"sweetalert2";import{IoArrowBack as di}from"react-icons/io5";function Ei(e){var Ae,xe,Z,Be,Ge,$,Nt,Kt,wt;let[w,j]=Jt(!1),[Q,E]=Jt(!1),[Oe,V]=Jt(""),[gt,Ke]=Jt(!1),[we,O]=Jt(!1),[he,Fe]=Jt("card"),[a,N]=Jt(!1),b=e.merchantPublicKey,ee=oe+"widget/mc-img.svg",h=oe+"widget/visa-img.svg",Me=oe+"widget/ae-img.svg",se=oe+"widget/discover-img.svg",je=oe+"widget/card.svg",C=oe+"widget/Trash.svg",Ze=oe+"widget/bank.svg",G=oe+"widget/secure-img.png",pt=oe+"widget/pov-by.png",[S,Ee]=Jt(),[te,De]=Jt({}),[ze,Ct]=Jt([]),[z,l]=Jt(),[f,D]=Jt(void 0),[F,x]=Jt(),[d,v]=Jt(""),k=(A,q)=>{let _e=(parseFloat(q)||0)/100,Se=A/(1+_e);return Math.round(Se*100)/100};mi(()=>{if(e!=null&&e.pass_fee){let A=k(e==null?void 0:e.amount,e==null?void 0:e.surcharge);D(A)}},[e==null?void 0:e.pass_fee]);let c=()=>j(!0),u=()=>j(!1),P=()=>{O(!1),Fe("card"),E(!1),V(""),Ke(!1),v(""),Ee({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),De({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),N(!1),l({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},K=()=>O(!0),re=(A,q)=>{let _e=A;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(_e)){(q===""||/^[0-9]+$/.test(q))&&(De(ye=>M(_({},ye),{[_e]:""})),Ee(ye=>M(_({},ye),{[_e]:q})));return}De(ye=>M(_({},ye),{[_e]:""})),Ee(ye=>M(_({},ye),{[_e]:q}))},ue=A=>{let _e=A.target.value.replace(/\D/g,""),Se="";/^3[47]/.test(_e)?Se=_e.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Xe,it,Le,at)=>[it,Le,at].filter(Boolean).join(" ")):Se=_e.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Xe,it,Le,at,be)=>[it,Le,at,be].filter(Boolean).join(" ")),De(ye=>M(_({},ye),{cardNumber:""})),Ee(ye=>M(_({},ye),{cardNumber:Se}))},xt=()=>{var ye,Xe,it,Le,at,be;let A={},q=S,_e=parseInt((q==null?void 0:q.expiryMonth)||"",10),Se=(q==null?void 0:q.expiryYear)||"";if((ye=q==null?void 0:q.cardName)!=null&&ye.trim()||(A.cardName="Card name is required"),(Xe=q==null?void 0:q.cardNumber)!=null&&Xe.trim()||(A.cardNumber="Card number is required"),(!((it=q==null?void 0:q.expiryMonth)!=null&&it.trim())||!((Le=q==null?void 0:q.expiryYear)!=null&&Le.trim())||isNaN(_e)||_e<1||_e>12||Se.length!==4)&&(A.expiryMonth="Invalid Expiration Date."),(at=q==null?void 0:q.cvv)!=null&&at.trim()||(A.cvv="CVV is required"),(be=q==null?void 0:q.zipCode)!=null&&be.trim()||(A.zipCode="ZIP code is required"),q!=null&&q.expiryMonth&&(q!=null&&q.expiryYear)&&q.expiryMonth.length<=2&&q.expiryYear.length===4){let Bt=parseInt(q.expiryMonth,10),kt=parseInt(q.expiryYear,10),ft=new Date,_t=ft.getMonth()+1,Tt=ft.getFullYear();(kt<Tt||kt===Tt&&Bt<_t)&&(A.expiryMonth="Card is expired")}return De(A),Object.keys(A).length>0},Re=async A=>{var q,_e,Se,ye,Xe,it,Le,at,be,Bt,kt,ft,_t,Tt,Zt,qt,Yt,vt,Te;if(A.preventDefault(),he=="card"){if(xt())return;{let ht=DatacapWebToken.validateCardNumber(S==null?void 0:S.cardNumber.replaceAll(" ","")),Rt=DatacapWebToken.validateExpirationDate(S==null?void 0:S.expiryMonth,S==null?void 0:S.expiryYear),Ve=DatacapWebToken.validateCVV(S==null?void 0:S.cvv),Ft={};if(ht||(Ft.cardNumber="Invalid card Number"),Rt||(Ft.expiryMonth="Invalid Expiration Date."),Ve||(Ft.cvv="Invalid CVV"),De(Ft),ht&&Ve&&Rt){E(!0);try{let Pt=async function(et){if(et.Error)V(et.Error),E(!1);else{let ot=S==null?void 0:S.cardName,en=S==null?void 0:S.zipCode;et.name=ot,et.postal_code=en,et.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,et.amount=e==null?void 0:e.amount,et.order_id=e==null?void 0:e.orderID,et.preAuth_id="",et.isCardSave=a,et.customer_id=e==null?void 0:e.customerId,et.link_token="",et.gateway_id=F==null?void 0:F.paymentGateway,et.discount=e==null?void 0:e.discount,et.tax=e==null?void 0:e.tax,et.surcharge=e==null?void 0:e.surcharge,et.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let on={method:"POST",body:JSON.stringify(et),redirect:"follow"};mt.emit("sendMessage",M(_({},on),{isChargePreauth:!0})),mt.on("charge-preauth",yt=>{var Xt;console.log(yt,"datdata"),(yt==null?void 0:yt.status)=="Failed"?(E(!1),V((yt==null?void 0:yt.message)||"Something went wrong. Please try again later.")):(Ke(!0),v((Xt=yt==null?void 0:yt.data)==null?void 0:Xt.transaction_id),E(!1),Ee({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((F==null?void 0:F.paymentGateway)===32){let et={method:"POST",redirect:"follow"};try{let ot=await zn.post(`${Ie}api/v1/widget/generate-session`,et),en=Number(S==null?void 0:S.expiryYear)%100,Et=S==null?void 0:S.cardNumber;Et=Et==null?void 0:Et.replace(/\s+/g,"");let on=`${Et}=${en}${S==null?void 0:S.expiryMonth} ${S==null?void 0:S.cvv}`,Xt=forge.pki.publicKeyFromPem((_e=(q=ot==null?void 0:ot.data)==null?void 0:q.data)==null?void 0:_e.publicKeyPem).encrypt(on,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),rn=forge.util.encode64(Xt),I={"Content-Type":"application/json","x-app-session-key":(ye=(Se=ot.data)==null?void 0:Se.data)==null?void 0:ye.session_key},p=JSON.stringify({enc_track2_data:`${rn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(it=(Xe=ot==null?void 0:ot.data)==null?void 0:Xe.data)==null?void 0:it.session_key}`});try{let J=await zn.post(`${At}tokenizer/tokenize`,p,{headers:I}),He=JSON.stringify(M(_({},(Le=J==null?void 0:J.data)==null?void 0:Le.data),{name:S==null?void 0:S.cardName,postal_code:S==null?void 0:S.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(be=(at=J==null?void 0:J.data)==null?void 0:at.data)==null?void 0:be.token}`,fractalpayPublicKey:b,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:a,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:S==null?void 0:S.expiryYear,ExpirationMonth:S==null?void 0:S.expiryMonth,CVV:S==null?void 0:S.cvv,Last4:(kt=(Bt=J==null?void 0:J.data)==null?void 0:Bt.data)==null?void 0:kt.last4,Brand:(_t=(ft=J==null?void 0:J.data)==null?void 0:ft.data)==null?void 0:_t.brand,gateway_id:F==null?void 0:F.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),m={method:"POST",headers:{"Content-Type":"application/json"},body:He,redirect:"follow"};mt.emit("sendMessage",M(_({},m),{isFractalPreauth:!0})),mt.on("fractal-charge-preauth",Y=>{var fe;(Y==null?void 0:Y.status)=="Failed"?(E(!1),V((Y==null?void 0:Y.message)||"Something went wrong , Try again later")):(v((fe=Y==null?void 0:Y.data)==null?void 0:fe.transaction_id),Ke(!0),E(!1))})}catch(J){console.log(J),E(!1),V(((Zt=(Tt=J==null?void 0:J.response)==null?void 0:Tt.data)==null?void 0:Zt.message)||(J==null?void 0:J.message)||"Something went wrong , Try again later")}}catch(ot){E(!1),V(((Yt=(qt=ot==null?void 0:ot.response)==null?void 0:qt.data)==null?void 0:Yt.message)||(ot==null?void 0:ot.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(F==null?void 0:F.dctoken,"PaymentForm",Pt)}catch(Pt){E(!1),V(((Te=(vt=Pt==null?void 0:Pt.response)==null?void 0:vt.data)==null?void 0:Te.message)||(Pt==null?void 0:Pt.message)||"Something went wrong.")}}}}},nt=async()=>{var A,q,_e,Se,ye,Xe,it,Le,at,be,Bt,kt,ft,_t,Tt,Zt,qt,Yt;c();try{let vt={fractalpayPublicKey:b,customer_id:e==null?void 0:e.customerId,preauth:!0},Te=await zn.post(`${$e}get-payment-details`,vt);if(x((A=Te==null?void 0:Te.data)==null?void 0:A.data),(_e=(q=Te==null?void 0:Te.data)==null?void 0:q.data)!=null&&_e.paymentGateway||(P(),V("Something went wrong.")),(ye=(Se=Te==null?void 0:Te.data)==null?void 0:Se.data)!=null&&ye.card_list&&((Le=(it=(Xe=Te==null?void 0:Te.data)==null?void 0:Xe.data)==null?void 0:it.card_list)==null?void 0:Le.length)>0){Ct((be=(at=Te==null?void 0:Te.data)==null?void 0:at.data)==null?void 0:be.card_list),Fe("cardList");let St=(ft=(kt=(Bt=Te==null?void 0:Te.data)==null?void 0:Bt.data)==null?void 0:kt.card_list)==null?void 0:ft.filter(ht=>(ht==null?void 0:ht.primary_card)==1);St!=null&&St[0]&&((_t=St==null?void 0:St[0])==null?void 0:_t.payment_method_type)==((Zt=(Tt=Te==null?void 0:Te.data)==null?void 0:Tt.data)==null?void 0:Zt.paymentGateway)&&l(St[0])}else Fe("card");u()}catch(vt){console.log(vt),u(),V(((Yt=(qt=vt==null?void 0:vt.response)==null?void 0:qt.data)==null?void 0:Yt.message)||(vt==null?void 0:vt.message)||"Something went wrong")}},lt=async()=>{var Bt,kt,ft,_t,Tt,Zt,qt;let A=e==null?void 0:e.customerId,q=e==null?void 0:e.discount,_e=e==null?void 0:e.surcharge,Se=e==null?void 0:e.tax,ye=e==null?void 0:e.merchantPublicKey,Xe=e==null?void 0:e.orderID,it=e==null?void 0:e.amount,Le=z==null?void 0:z.id,at=z==null?void 0:z.card_type;if(ye&&Xe&&it)if(A)if(Le){let Yt={amount:it,order_id:Xe,customer_id:A,card_id:Le,fractalpayPublicKey:ye,isCardSave:at!="Bank",discount:q,surcharge:_e,tax:Se},be=Yt,{isCardSave:vt}=be,Te=vn(be,["isCardSave"]),ht=$e+"authorize-by-card",Rt={"Content-Type":"application/json"};E(!0);try{let Ve=await zn.post(ht,at=="Bank"?Te:Yt,{headers:Rt});(Bt=Ve==null?void 0:Ve.data)!=null&&Bt.result&&(v((ft=(kt=Ve==null?void 0:Ve.data)==null?void 0:kt.data)==null?void 0:ft.transaction_id),Ke(!0),E(!1))}catch(Ve){E(!1),console.log(Ve),V(((Tt=(_t=Ve==null?void 0:Ve.response)==null?void 0:_t.data)==null?void 0:Tt.message)||((qt=(Zt=Ve==null?void 0:Ve.response)==null?void 0:Zt.data)==null?void 0:qt.status)||"Something went erong")}}else V("Please Select A Card/ACH");else V("Please Select Customer");else V("Something went wrong.")};mi(()=>{we&&b&&nt()},[b,we]);let ct=async A=>{En.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 q=>{if(q.isConfirmed){E(!0);try{let _e={card_id:A,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},Se=await zn.post(`${$e}delete-customer-card`,_e);E(!1),nt(),En.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(_e){E(!1),En.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},rt=A=>{switch(A==null?void 0:A.toLowerCase()){case"visa":return h;case"mastercard":case"mc":case"m/c":return ee;case"amex":case"american express":case"ae":return Me;case"discover":case"dcvr":return se;case"bank":return Ze;default:return A}};return s.createElement(s.Fragment,null,s.createElement(Qt,null),s.createElement(hn,null),s.createElement(s.Fragment,null,s.createElement("button",{className:"paymentBtn",onClick:K},"PreAuth Payment"),s.createElement(Gt,{open:we,onClose:P},Oe&&s.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},s.createElement(nn,{error:Oe,onClose:P})),gt&&s.createElement(yn,{onClose:P,tranId:d}),!Oe&&!gt&&s.createElement(s.Fragment,null,(w||Q)&&s.createElement(Vt,{loading:w||Q}),s.createElement("div",null,s.createElement("div",{className:"frac-card-payment-page frac-form"},s.createElement("div",{className:"parent-pay-container"},s.createElement("span",{className:"request-payment-close-popup",onClick:P},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12425_52336)"},s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12425_52336"},s.createElement("rect",{width:"16",height:"16",fill:"white"}))))),s.createElement("div",{className:"pay-container"},s.createElement("div",{className:"pay-header pay-conatiner-one"},s.createElement("div",{className:"pay-conatiner-one-first"},s.createElement("div",{className:"pay-logo-container"},s.createElement("div",{className:"pay-main-logo"},s.createElement("img",{src:F==null?void 0:F.logo,id:"pay-logos"})),s.createElement("h1",{className:"pay-heading"},"Pay"),(ze==null?void 0:ze.length)>0&&he!=="cardList"&&s.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",s.createElement(di,null)," Back")),s.createElement("div",{className:"amt-pay-con"},s.createElement("div",{className:"pay-amount-conatiner"},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ue((Ae=Number(e==null?void 0:e.amount))==null?void 0:Ae.toFixed(2))),f&&f>0&&s.createElement("div",{style:{width:"80%"},className:"frac-cash-discount"},s.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),s.createElement("div",null,Ue(f.toFixed(2))))),he!="ach"&&s.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},s.createElement("img",{src:h,alt:"",width:33}),s.createElement("img",{src:ee,width:33,alt:""}),s.createElement("img",{src:Me,alt:"",width:33}),s.createElement("img",{src:se,width:33,alt:""})))),s.createElement("div",{className:"pay-conatiner-one-last"},s.createElement("img",{src:G,alt:""}),s.createElement("img",{src:pt,alt:""}),"Secure payments powered by Fractal"),s.createElement("div",null)),!w&&s.createElement("div",{className:"pay-tab pay-conatiner-two"},s.createElement("div",{className:"col-md-12"},s.createElement("div",{id:"payment-form-div"},he!=="cardList"?s.createElement("div",null,(ze==null?void 0:ze.length)>0&&s.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Fe("cardList")}," ",s.createElement(di,null)," Back"),s.createElement("div",{className:""},s.createElement("div",{className:"res-pay-con"},s.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ue((xe=Number(e==null?void 0:e.amount))==null?void 0:xe.toFixed(2)))),s.createElement("div",null,s.createElement("div",null,s.createElement("img",{src:h,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:ee,width:35,alt:""})),s.createElement("div",null,s.createElement("img",{src:Me,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:se,width:35,alt:""})))),f&&f>0&&s.createElement("div",{className:"res-pay-con frac-cash-discount"},s.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),s.createElement("div",null,Ue(f.toFixed(2)))))):s.createElement("div",null,s.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",F==null?void 0:F.customer_name),s.createElement("div",{className:"res-pay-con"},s.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ue((Z=Number(e==null?void 0:e.amount))==null?void 0:Z.toFixed(2)))),s.createElement("div",null,s.createElement("div",null,s.createElement("img",{src:h,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:ee,width:35,alt:""})),s.createElement("div",null,s.createElement("img",{src:Me,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:se,width:35,alt:""})))),s.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),s.createElement("div",{style:{display:he==="cardList"?"block":"none"},className:"tabcontent"},s.createElement("div",{className:"card-lint-div-in"},s.createElement("div",{className:"card-list-div"},(F==null?void 0:F.card_list)&&((Be=F==null?void 0:F.card_list)==null?void 0:Be.length)>0&&((Ge=F==null?void 0:F.card_list)==null?void 0:Ge.map((A,q)=>s.createElement("div",{className:"card-list-single-div",key:q},s.createElement("div",{className:"card-number-radio"},s.createElement("input",{disabled:(F==null?void 0:F.paymentGateway)!=(A==null?void 0:A.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:z===A,onChange:_e=>l(A)}),s.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",A==null?void 0:A.cardlastfourdigit),s.createElement("h6",{className:"card-expiry-date"},A==null?void 0:A.expmonth,"/",A==null?void 0:A.expyear)),s.createElement("div",{className:"card-number-radio"},s.createElement("span",{className:"visa-card"},s.createElement("img",{src:rt(A==null?void 0:A.card_type),alt:""})),s.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>ct(A==null?void 0:A.id)},s.createElement("img",{src:C,alt:""}))))))),s.createElement("div",{className:"pay-with-other-card ",onClick:()=>Fe("card")},"Authorize With Other Card",s.createElement("img",{src:je,alt:""}))),s.createElement("div",{className:"form-group"},s.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:lt},Ue(($=Number(e==null?void 0:e.amount))==null?void 0:$.toFixed(2))))),s.createElement("div",{id:"card",style:{display:he==="card"?"block":"none"},className:"tabcontent"},s.createElement("form",{id:"PaymentForm",onSubmit:Re},s.createElement("div",{className:"ach-scrl",style:{minHeight:(ze==null?void 0:ze.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),s.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(S==null?void 0:S.cardName)||"",onChange:A=>{let q=A.target.value;/^[a-zA-Z\s]*$/.test(q)&&re("cardName",q)}}),(te==null?void 0:te.cardName)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.cardName)),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"cardNumber"},"Card Number"),s.createElement("div",{className:"toggle-num-wrapper"},s.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(S==null?void 0:S.cardNumber)||"",onChange:A=>ue(A),"data-token":"card_number"}),s.createElement("div",{className:"card-crdi card-expiry-new"},s.createElement("div",{className:"exp-date-year-container"},s.createElement("div",{className:"exp-date form-group"},s.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(S==null?void 0:S.expiryMonth)||"",onChange:A=>re("expiryMonth",A.target.value)})),s.createElement("div",{className:"exp-year form-group"},s.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(S==null?void 0:S.expiryYear)||"",onChange:A=>re("expiryYear",A.target.value)})),s.createElement("div",{className:"security-digit form-group"},s.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(S==null?void 0:S.cvv)||"",onChange:A=>re("cvv",A.target.value)})))),(te==null?void 0:te.cardNumber)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.cardNumber),s.createElement("p",{style:{margin:"0"}},te!=null&&te.expiryMonth||te!=null&&te.expiryYear?s.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},te==null?void 0:te.expiryMonth):"",(te==null?void 0:te.cvv)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.cvv)))),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),s.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(Nt=S==null?void 0:S.orderId)!=null?Nt:"OID123456",onChange:A=>re("orderId",A.target.value),style:{background:"#F6F6F7",color:"#727272"}})),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"zip"},"ZIP"),s.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Kt=S==null?void 0:S.zipCode)!=null?Kt:"",onChange:A=>re("zipCode",A.target.value)}),(te==null?void 0:te.zipCode)&&s.createElement("span",{className:"error-span"},te==null?void 0:te.zipCode)),(e==null?void 0:e.customerId)&&s.createElement("div",{className:"form-group"},s.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},s.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:a,onChange:A=>N(A.target.checked)}),s.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),s.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),s.createElement("div",{className:"frac-tooltip-wrapper"},s.createElement("div",{className:"frac-tooltip-icon"},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12420_50192)"},s.createElement("rect",{width:"20",height:"20",fill:"white"}),s.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12420_50192"},s.createElement("rect",{width:"20",height:"20",fill:"white"}))))),s.createElement("div",{className:"frac-tooltip-text"},s.createElement("p",null,"If checked, I agree to give the ",s.createElement("b",null,(F==null?void 0:F.bname)||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),s.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},s.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((wt=Number(e==null?void 0:e.amount))==null?void 0:wt.toFixed(2)))))))))))))))))}import ke,{useEffect as Ji,useRef as An,useState as xn}from"react";import Xi from"sweetalert2";import kn from"axios";import Wi from"react";function Wn(){let e="#000",w="#fff",j="#212529",Q="#dee2e6";return Wi.createElement("style",null,`
1673
1673
  .add-card {
1674
1674
  max-width:380px;
1675
1675
  padding: 0 20px
@@ -2016,7 +2016,7 @@ position:relative;
2016
2016
  color: #161616;
2017
2017
  opacity: 0.5;
2018
2018
  }
2019
- `)}var Gi=({onClose:e})=>an.createElement(an.Fragment,null,an.createElement(Un,null),an.createElement("div",{className:"card-success"},an.createElement("div",{className:"payment-success-container"},an.createElement("div",{className:"success-icon"},an.createElement("div",{className:"circle"},an.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),an.createElement("div",{className:"success-text"},an.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),an.createElement("div",{className:"thank-you-text"},"Thank you ")))))),ci=Gi;function Qi(e){var z;let[w,j]=xn(!1),[Q,E]=xn(!1),[Oe,V]=xn(""),[gt,Ke]=xn(!1),we=An(null),O=An(null),he=An(null),Fe=An(null),a=An(null),[N,b]=xn(),[ee,h]=xn({}),[Me,se]=xn(),je=()=>j(!0),C=()=>j(!1),Ze=l=>{Xi.fire({icon:"error",text:l,customClass:{popup:"custom-z-index"}})},G=()=>{Ke(!1),E(!1),V(""),b({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},pt=()=>Ke(!0),S=()=>{G()},Ee=(l,f)=>{var x,d,v;let D=l,F=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(D,f==null?void 0:f.length,"dfih",D==="expiryMonth"&&(f==null?void 0:f.length)===2),D==="expiryMonth"&&(f==null?void 0:f.length)===2&&((x=he==null?void 0:he.current)==null||x.focus()),D==="expiryYear"&&(f==null?void 0:f.length)===4&&((d=Fe==null?void 0:Fe.current)==null||d.focus()),D==="cvv"&&(f==null?void 0:f.length)===3&&((v=a==null?void 0:a.current)==null||v.focus()),F.includes(D)){(f===""||/^[0-9]+$/.test(f))&&(h(k=>M(_({},k),{[D]:""})),b(k=>M(_({},k),{[D]:f})));return}h(k=>M(_({},k),{[D]:""})),console.log(f,D),b(k=>M(_({},k),{[D]:f}))},te=l=>{var x;let D=l.target.value.replace(/\D/g,""),F="";/^3[47]/.test(D)?F=D.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(v,k,c,u)=>[k,c,u].filter(Boolean).join(" ")):F=D.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(v,k,c,u,P)=>[k,c,u,P].filter(Boolean).join(" ")),h(d=>M(_({},d),{cardNumber:""})),b(d=>M(_({},d),{cardNumber:F})),console.log(D==null?void 0:D.length,"length"),(D==null?void 0:D.length)===16&&((x=O==null?void 0:O.current)==null||x.focus())},De=()=>{var x,d,v,k,c,u;let l={},f=N,D=parseInt((f==null?void 0:f.expiryMonth)||"",10),F=(f==null?void 0:f.expiryYear)||"";if((x=f==null?void 0:f.cardName)!=null&&x.trim()||(l.cardName="Card name is required"),(d=f==null?void 0:f.cardNumber)!=null&&d.trim()||(l.cardNumber="Card number is required"),(v=f==null?void 0:f.expiryMonth)!=null&&v.trim()?(Number(f==null?void 0:f.expiryMonth)>12||Number(f==null?void 0:f.expiryMonth)<1)&&(l.expiryMonth="Invalid Expiration Month."):l.expiryMonth="Expiration month is required",(k=f==null?void 0:f.expiryYear)!=null&&k.trim()?((c=f==null?void 0:f.expiryYear)==null?void 0:c.trim().length)!==4||Number(f==null?void 0:f.expiryYear)<2025?l.expiryYear="Invalid Expiration Year.":(isNaN(D)||D<1||D>12||F.length!==4)&&(l.expiryMonth="Invalid Expiration Date."):l.expiryYear="Expiration year is required",(u=f==null?void 0:f.cvv)!=null&&u.trim()||(l.cvv="CVC is required"),f!=null&&f.expiryMonth&&(f!=null&&f.expiryYear)&&f.expiryMonth.length<=2&&f.expiryYear.length===4){let P=parseInt(f.expiryMonth,10),K=parseInt(f.expiryYear,10),re=new Date,ue=re.getMonth()+1,xt=re.getFullYear();(K<xt||K===xt&&P<ue)&&(l.expiryMonth="Card is expired")}return h(l),Object.keys(l).length>0},ze=async()=>{var l,f,D;je();try{let F={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},x=await kn.post(`${$e}get-payment-details`,F);console.log(x),se((l=x==null?void 0:x.data)==null?void 0:l.data),(D=(f=x==null?void 0:x.data)==null?void 0:f.data)!=null&&D.paymentGateway||(G(),V("Something went wrong.")),C()}catch(F){console.log(F),C(),G(),V("Something went wrong.")}};return Ji(()=>{e!=null&&e.merchantPublicKey&&ze()},[e==null?void 0:e.merchantPublicKey]),ke.createElement(ke.Fragment,null,ke.createElement(Qt,null),ke.createElement(Wn,null),ke.createElement(Vt,{loading:w}),Oe&&ke.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},ke.createElement(nn,{error:Oe,onClose:G})),Q&&ke.createElement(ci,{onClose:S}),!Oe&&!Q&&ke.createElement(ke.Fragment,null,ke.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},ke.createElement("form",{id:"creditCardForm",onSubmit:async l=>{var D,F,x,d,v,k,c,u,P,K,re,ue,xt,Re,nt,lt;l.preventDefault();let f=De();if(console.log(N),!f){let ct=DatacapWebToken.validateCardNumber(N==null?void 0:N.cardNumber.replaceAll(" ","")),rt=DatacapWebToken.validateExpirationDate(N==null?void 0:N.expiryMonth,N==null?void 0:N.expiryYear),Ae=DatacapWebToken.validateCVV(N==null?void 0:N.cvv),xe={};if(ct||(xe.cardNumber="Invalid card Number"),rt||(xe.expiryMonth="Invalid Expiration Date."),Ae||(xe.cvv="Invalid CVV"),h(xe),ct&&Ae&&rt){je();try{let Z=async function(Be){var Je,$,Nt,Kt,wt;if(console.log(Be),Be.Error)console.log(Be==null?void 0:Be.Error),V(Be.Error),C();else{let A={userId:e==null?void 0:e.customerId,cardName:N==null?void 0:N.cardName,zip:N==null?void 0:N.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:Be};try{let q=await kn.post(`${$e}add-card`,A);console.log(q);let _e={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:N==null?void 0:N.cardNumber.replaceAll(" ",""),exp_month:N==null?void 0:N.expiryMonth,exp_year:(Je=N==null?void 0:N.expiryYear)==null?void 0:Je.slice(-2),cvv:N==null?void 0:N.cvv};try{let Se=await kn.post(`${$e}link-wallet`,_e);console.log(Se),E(!0),C(),b({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),pn(l,"close","")}catch(Se){console.log(Se),C(),V(((Nt=($=Se==null?void 0:Se.response)==null?void 0:$.data)==null?void 0:Nt.message)||(Se==null?void 0:Se.message)||"Something went wrong.")}}catch(q){console.log(q),C(),V(((wt=(Kt=q==null?void 0:q.response)==null?void 0:Kt.data)==null?void 0:wt.message)||(q==null?void 0:q.message)||"Something went wrong.")}}};if((Me==null?void 0:Me.paymentGateway)===32){let Be={method:"POST",redirect:"follow"};try{let Je=await kn.post(`${Ie}api/v1/widget/generate-session`,Be),$=Number(N==null?void 0:N.expiryYear)%100,Nt=N==null?void 0:N.cardNumber;Nt=Nt==null?void 0:Nt.replace(/\s+/g,"");let Kt=`${Nt}=${$}${N==null?void 0:N.expiryMonth} ${N==null?void 0:N.cvv}`,A=forge.pki.publicKeyFromPem((F=(D=Je==null?void 0:Je.data)==null?void 0:D.data)==null?void 0:F.publicKeyPem).encrypt(Kt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),q=forge.util.encode64(A),_e={"Content-Type":"application/json","x-app-session-key":(d=(x=Je.data)==null?void 0:x.data)==null?void 0:d.session_key},Se=JSON.stringify({enc_track2_data:`${q}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(k=(v=Je==null?void 0:Je.data)==null?void 0:v.data)==null?void 0:k.session_key}`});try{let ye=await kn.post(`${At}tokenizer/tokenize`,Se,{headers:_e}),Xe=JSON.stringify(M(_({},(c=ye==null?void 0:ye.data)==null?void 0:c.data),{cvv:N==null?void 0:N.cvv,cardName:N==null?void 0:N.cardName,zip:N==null?void 0:N.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),it={"Content-Type":"application/json"};try{let Le=await kn.post(`${$e}add-card`,Xe,{headers:it});console.log(Le),(u=Le==null?void 0:Le.data)!=null&&u.result&&(E(!0),C(),pn(l,"close",""))}catch(Le){C(),V(((K=(P=Le==null?void 0:Le.response)==null?void 0:P.data)==null?void 0:K.message)||(Le==null?void 0:Le.message)||"Something went wrong.")}}catch(ye){C(),V(((ue=(re=ye==null?void 0:ye.response)==null?void 0:re.data)==null?void 0:ue.message)||(ye==null?void 0:ye.message)||"Something went wrong.")}}catch(Je){C(),V(((Re=(xt=Je==null?void 0:Je.response)==null?void 0:xt.data)==null?void 0:Re.message)||(Je==null?void 0:Je.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(Me==null?void 0:Me.dctoken,"creditCardForm",Z)}catch(Z){C(),V(((lt=(nt=Z==null?void 0:Z.response)==null?void 0:nt.data)==null?void 0:lt.message)||(Z==null?void 0:Z.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},ke.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},ke.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},ke.createElement("label",{htmlFor:"cardNumber"},"Card Number"),ke.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(N==null?void 0:N.cardNumber)||"",onChange:l=>te(l),ref:we}),(ee==null?void 0:ee.cardNumber)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.cardNumber),ke.createElement("br",null)),ke.createElement("div",{className:"card-dtl"},ke.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"expMonth"},"MM"),ke.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(N==null?void 0:N.expiryMonth)||"",onChange:l=>Ee("expiryMonth",l.target.value),ref:O}),(ee==null?void 0:ee.expiryMonth)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.expiryMonth)),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"expYear"},"YYYY"),ke.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(N==null?void 0:N.expiryYear)||"",onChange:l=>Ee("expiryYear",l.target.value),ref:he}),(ee==null?void 0:ee.expiryYear)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.expiryYear)),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"cvc"},"CVC"),ke.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(N==null?void 0:N.cvv)||"",onChange:l=>Ee("cvv",l.target.value),ref:Fe}),(ee==null?void 0:ee.cvv)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.cvv)))),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"cardholderName"},"Name on card"),ke.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(N==null?void 0:N.cardName)||"",onChange:l=>{let f=l.target.value;/^[a-zA-Z\s]*$/.test(f)&&Ee("cardName",f)},ref:a}),(ee==null?void 0:ee.cardName)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.cardName)),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"zipcode"},"Zip"),ke.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(z=N==null?void 0:N.zipCode)!=null?z:"",onChange:l=>Ee("zipCode",l.target.value)}),(ee==null?void 0:ee.zipCode)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.zipCode))),ke.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import H,{useState as In}from"react";import Bn from"axios";var Vn={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import Di from"react";function Gn({}){return Di.createElement("style",null,`
2019
+ `)}var Gi=({onClose:e})=>an.createElement(an.Fragment,null,an.createElement(Un,null),an.createElement("div",{className:"card-success"},an.createElement("div",{className:"payment-success-container"},an.createElement("div",{className:"success-icon"},an.createElement("div",{className:"circle"},an.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),an.createElement("div",{className:"success-text"},an.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),an.createElement("div",{className:"thank-you-text"},"Thank you ")))))),ci=Gi;function Qi(e){var z;let[w,j]=xn(!1),[Q,E]=xn(!1),[Oe,V]=xn(""),[gt,Ke]=xn(!1),we=An(null),O=An(null),he=An(null),Fe=An(null),a=An(null),[N,b]=xn(),[ee,h]=xn({}),[Me,se]=xn(),je=()=>j(!0),C=()=>j(!1),Ze=l=>{Xi.fire({icon:"error",text:l,customClass:{popup:"custom-z-index"}})},G=()=>{Ke(!1),E(!1),V(""),b({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},pt=()=>Ke(!0),S=()=>{G()},Ee=(l,f)=>{var x,d,v;let D=l,F=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(D,f==null?void 0:f.length,"dfih",D==="expiryMonth"&&(f==null?void 0:f.length)===2),D==="expiryMonth"&&(f==null?void 0:f.length)===2&&((x=he==null?void 0:he.current)==null||x.focus()),D==="expiryYear"&&(f==null?void 0:f.length)===4&&((d=Fe==null?void 0:Fe.current)==null||d.focus()),D==="cvv"&&(f==null?void 0:f.length)===3&&((v=a==null?void 0:a.current)==null||v.focus()),F.includes(D)){(f===""||/^[0-9]+$/.test(f))&&(h(k=>M(_({},k),{[D]:""})),b(k=>M(_({},k),{[D]:f})));return}h(k=>M(_({},k),{[D]:""})),console.log(f,D),b(k=>M(_({},k),{[D]:f}))},te=l=>{var x;let D=l.target.value.replace(/\D/g,""),F="";/^3[47]/.test(D)?F=D.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(v,k,c,u)=>[k,c,u].filter(Boolean).join(" ")):F=D.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(v,k,c,u,P)=>[k,c,u,P].filter(Boolean).join(" ")),h(d=>M(_({},d),{cardNumber:""})),b(d=>M(_({},d),{cardNumber:F})),console.log(D==null?void 0:D.length,"length"),(D==null?void 0:D.length)===16&&((x=O==null?void 0:O.current)==null||x.focus())},De=()=>{var x,d,v,k,c,u;let l={},f=N,D=parseInt((f==null?void 0:f.expiryMonth)||"",10),F=(f==null?void 0:f.expiryYear)||"";if((x=f==null?void 0:f.cardName)!=null&&x.trim()||(l.cardName="Card name is required"),(d=f==null?void 0:f.cardNumber)!=null&&d.trim()||(l.cardNumber="Card number is required"),(v=f==null?void 0:f.expiryMonth)!=null&&v.trim()?(Number(f==null?void 0:f.expiryMonth)>12||Number(f==null?void 0:f.expiryMonth)<1)&&(l.expiryMonth="Invalid Expiration Month."):l.expiryMonth="Expiration month is required",(k=f==null?void 0:f.expiryYear)!=null&&k.trim()?((c=f==null?void 0:f.expiryYear)==null?void 0:c.trim().length)!==4||Number(f==null?void 0:f.expiryYear)<2025?l.expiryYear="Invalid Expiration Year.":(isNaN(D)||D<1||D>12||F.length!==4)&&(l.expiryMonth="Invalid Expiration Date."):l.expiryYear="Expiration year is required",(u=f==null?void 0:f.cvv)!=null&&u.trim()||(l.cvv="CVC is required"),f!=null&&f.expiryMonth&&(f!=null&&f.expiryYear)&&f.expiryMonth.length<=2&&f.expiryYear.length===4){let P=parseInt(f.expiryMonth,10),K=parseInt(f.expiryYear,10),re=new Date,ue=re.getMonth()+1,xt=re.getFullYear();(K<xt||K===xt&&P<ue)&&(l.expiryMonth="Card is expired")}return h(l),Object.keys(l).length>0},ze=async()=>{var l,f,D;je();try{let F={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},x=await kn.post(`${$e}get-payment-details`,F);console.log(x),se((l=x==null?void 0:x.data)==null?void 0:l.data),(D=(f=x==null?void 0:x.data)==null?void 0:f.data)!=null&&D.paymentGateway||(G(),V("Something went wrong.")),C()}catch(F){console.log(F),C(),G(),V("Something went wrong.")}};return Ji(()=>{e!=null&&e.merchantPublicKey&&ze()},[e==null?void 0:e.merchantPublicKey]),ke.createElement(ke.Fragment,null,ke.createElement(Qt,null),ke.createElement(Wn,null),ke.createElement(Vt,{loading:w}),Oe&&ke.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},ke.createElement(nn,{error:Oe,onClose:G})),Q&&ke.createElement(ci,{onClose:S}),!Oe&&!Q&&ke.createElement(ke.Fragment,null,ke.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},ke.createElement("form",{id:"creditCardForm",onSubmit:async l=>{var D,F,x,d,v,k,c,u,P,K,re,ue,xt,Re,nt,lt;l.preventDefault();let f=De();if(console.log(N),!f){let ct=DatacapWebToken.validateCardNumber(N==null?void 0:N.cardNumber.replaceAll(" ","")),rt=DatacapWebToken.validateExpirationDate(N==null?void 0:N.expiryMonth,N==null?void 0:N.expiryYear),Ae=DatacapWebToken.validateCVV(N==null?void 0:N.cvv),xe={};if(ct||(xe.cardNumber="Invalid card Number"),rt||(xe.expiryMonth="Invalid Expiration Date."),Ae||(xe.cvv="Invalid CVV"),h(xe),ct&&Ae&&rt){je();try{let Z=async function(Be){var Ge,$,Nt,Kt,wt;if(console.log(Be),Be.Error)console.log(Be==null?void 0:Be.Error),V(Be.Error),C();else{let A={userId:e==null?void 0:e.customerId,cardName:N==null?void 0:N.cardName,zip:N==null?void 0:N.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:Be};try{let q=await kn.post(`${$e}add-card`,A);console.log(q);let _e={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:N==null?void 0:N.cardNumber.replaceAll(" ",""),exp_month:N==null?void 0:N.expiryMonth,exp_year:(Ge=N==null?void 0:N.expiryYear)==null?void 0:Ge.slice(-2),cvv:N==null?void 0:N.cvv};try{let Se=await kn.post(`${$e}link-wallet`,_e);console.log(Se),E(!0),C(),b({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),pn(l,"close","")}catch(Se){console.log(Se),C(),V(((Nt=($=Se==null?void 0:Se.response)==null?void 0:$.data)==null?void 0:Nt.message)||(Se==null?void 0:Se.message)||"Something went wrong.")}}catch(q){console.log(q),C(),V(((wt=(Kt=q==null?void 0:q.response)==null?void 0:Kt.data)==null?void 0:wt.message)||(q==null?void 0:q.message)||"Something went wrong.")}}};if((Me==null?void 0:Me.paymentGateway)===32){let Be={method:"POST",redirect:"follow"};try{let Ge=await kn.post(`${Ie}api/v1/widget/generate-session`,Be),$=Number(N==null?void 0:N.expiryYear)%100,Nt=N==null?void 0:N.cardNumber;Nt=Nt==null?void 0:Nt.replace(/\s+/g,"");let Kt=`${Nt}=${$}${N==null?void 0:N.expiryMonth} ${N==null?void 0:N.cvv}`,A=forge.pki.publicKeyFromPem((F=(D=Ge==null?void 0:Ge.data)==null?void 0:D.data)==null?void 0:F.publicKeyPem).encrypt(Kt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),q=forge.util.encode64(A),_e={"Content-Type":"application/json","x-app-session-key":(d=(x=Ge.data)==null?void 0:x.data)==null?void 0:d.session_key},Se=JSON.stringify({enc_track2_data:`${q}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(k=(v=Ge==null?void 0:Ge.data)==null?void 0:v.data)==null?void 0:k.session_key}`});try{let ye=await kn.post(`${At}tokenizer/tokenize`,Se,{headers:_e}),Xe=JSON.stringify(M(_({},(c=ye==null?void 0:ye.data)==null?void 0:c.data),{cvv:N==null?void 0:N.cvv,cardName:N==null?void 0:N.cardName,zip:N==null?void 0:N.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),it={"Content-Type":"application/json"};try{let Le=await kn.post(`${$e}add-card`,Xe,{headers:it});console.log(Le),(u=Le==null?void 0:Le.data)!=null&&u.result&&(E(!0),C(),pn(l,"close",""))}catch(Le){C(),V(((K=(P=Le==null?void 0:Le.response)==null?void 0:P.data)==null?void 0:K.message)||(Le==null?void 0:Le.message)||"Something went wrong.")}}catch(ye){C(),V(((ue=(re=ye==null?void 0:ye.response)==null?void 0:re.data)==null?void 0:ue.message)||(ye==null?void 0:ye.message)||"Something went wrong.")}}catch(Ge){C(),V(((Re=(xt=Ge==null?void 0:Ge.response)==null?void 0:xt.data)==null?void 0:Re.message)||(Ge==null?void 0:Ge.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(Me==null?void 0:Me.dctoken,"creditCardForm",Z)}catch(Z){C(),V(((lt=(nt=Z==null?void 0:Z.response)==null?void 0:nt.data)==null?void 0:lt.message)||(Z==null?void 0:Z.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},ke.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},ke.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},ke.createElement("label",{htmlFor:"cardNumber"},"Card Number"),ke.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(N==null?void 0:N.cardNumber)||"",onChange:l=>te(l),ref:we}),(ee==null?void 0:ee.cardNumber)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.cardNumber),ke.createElement("br",null)),ke.createElement("div",{className:"card-dtl"},ke.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"expMonth"},"MM"),ke.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(N==null?void 0:N.expiryMonth)||"",onChange:l=>Ee("expiryMonth",l.target.value),ref:O}),(ee==null?void 0:ee.expiryMonth)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.expiryMonth)),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"expYear"},"YYYY"),ke.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(N==null?void 0:N.expiryYear)||"",onChange:l=>Ee("expiryYear",l.target.value),ref:he}),(ee==null?void 0:ee.expiryYear)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.expiryYear)),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"cvc"},"CVC"),ke.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(N==null?void 0:N.cvv)||"",onChange:l=>Ee("cvv",l.target.value),ref:Fe}),(ee==null?void 0:ee.cvv)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.cvv)))),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"cardholderName"},"Name on card"),ke.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(N==null?void 0:N.cardName)||"",onChange:l=>{let f=l.target.value;/^[a-zA-Z\s]*$/.test(f)&&Ee("cardName",f)},ref:a}),(ee==null?void 0:ee.cardName)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.cardName)),ke.createElement("div",{className:"form-group",style:{marginTop:"0"}},ke.createElement("label",{htmlFor:"zipcode"},"Zip"),ke.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(z=N==null?void 0:N.zipCode)!=null?z:"",onChange:l=>Ee("zipCode",l.target.value)}),(ee==null?void 0:ee.zipCode)&&ke.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},ee==null?void 0:ee.zipCode))),ke.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import H,{useState as In}from"react";import Bn from"axios";var Vn={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import Di from"react";function Gn({}){return Di.createElement("style",null,`
2020
2020
  @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap");
2021
2021
 
2022
2022
  .creditformbox {
@@ -2888,4 +2888,4 @@ position:relative;
2888
2888
 
2889
2889
 
2890
2890
 
2891
- `)}import Ot from"axios";import{IoArrowBack as Xn}from"react-icons/io5";import _n from"sweetalert2";var ia=({amount:e,submitBtnText:w="Pay",session_token:j,customerId:Q,callback:E,merchantName:Oe="merchant",isPreAuth:V,surcharge:gt="0",submitBtnClass:Ke,submitBtnIcon:we,isRequest:O,pass_fee:he,pass_fee_amount:Fe})=>{var yt,Xt,rn,I,p,J,He,g,m,Y,fe,W,Ne,Pe;let[a,N]=ut("card"),[b,ee]=ut("card"),[h,Me]=ut(),[se,je]=ut({}),[C,Ze]=ut(),[G,pt]=ut({}),[S,Ee]=ut(!1),[te,De]=ut(!1),[ze,Ct]=ut(!1),[z,l]=ut(""),[f,D]=ut(!1),[F,x]=ut(""),[d,v]=ut(!1),[k,c]=ut(!1),[u,P]=ut([]),[K,re]=ut([]),[ue,xt]=ut(),[Re,nt]=ut(Number(e)),[lt,ct]=ut("form"),[rt,Ae]=ut("form"),[xe,Z]=ut(!1),[Be,Je]=ut(0);console.log(Re,"cashDiscount");let $=oe+"widget/mc-img.svg",Nt=oe+"widget/visa-img.svg",Kt=oe+"widget/ae-img.svg",wt=oe+"widget/discover-img.svg",A=oe+"widget/card.svg",q=oe+"widget/Trash.svg",_e=oe+"widget/bank.svg",Se=oe+"widget/secure-img.png",ye=oe+"widget/pov-by.png",Xe=oe+"widget/pax.svg",it=oe+"widget/cardicon.svg",Le=oe+"widget/bankicon.svg",at=()=>v(!0),be=()=>v(!1),Bt=(i,o)=>{let L=(parseFloat(o)||0)/100,U=i/(1+L);return Math.round(U*100)/100},kt=async i=>{var o,L,U,y,R,ne,pe,ie,de;console.log(i,"ndfkjhdskjfhds");try{let le={pass_fee_amount:Number(e)-Re,pass_fee:he,Token:i==null?void 0:i.Token,amount:e,postal_code:i==null?void 0:i.postalCode},ae=await Ot.post(`${Ie}api/v1/gateway/charge/${j}`,le);if((o=ae==null?void 0:ae.data)!=null&&o.result){let ce;if(ze&&Q)try{let ve={postal_code:h==null?void 0:h.zipCode,customer_id:Q,gateway_token:(i==null?void 0:i.gateway_token)||(i==null?void 0:i.Token)};ce=await Ot.post(`${Ie}api/v1/gateway/add-card/${j}`,ve);debugger;console.log((L=ce==null?void 0:ce.data)==null?void 0:L.data,"addCard?.data?.data"),(U=ce==null?void 0:ce.data)!=null&&U.result&&(ce=(y=ce==null?void 0:ce.data)==null?void 0:y.data)}catch(ve){console.log(ve,"error"),be(),l(((ne=(R=ve==null?void 0:ve.response)==null?void 0:R.data)==null?void 0:ne.message)||"Something went wrong!")}let me={cardDetails:_(_({},ce),i),callback:M(_({},(pe=ae==null?void 0:ae.data)==null?void 0:pe.data),{name:h==null?void 0:h.cardName,isPreAuth:V})};ze||delete me.cardDetails,E(me),be(),Ft()}}catch(le){l(((de=(ie=le==null?void 0:le.response)==null?void 0:ie.data)==null?void 0:de.message)||"Something went wrong!"),be()}},ft=async i=>{var o,L,U,y,R,ne,pe,ie;try{let de={Token:i==null?void 0:i.Token,amount:e,postal_code:i==null?void 0:i.postalCode},le=await Ot.post(`${Ie}api/v1/gateway/preauth/${j}`,de);if((o=le==null?void 0:le.data)!=null&&o.result){let ae;if(ze&&Q)try{console.log(le,"preAuthResponse");let me={postal_code:h==null?void 0:h.zipCode,customer_id:Q,gateway_token:(i==null?void 0:i.Token)||(i==null?void 0:i.gateway_token)};ae=await Ot.post(`${Ie}api/v1/gateway/add-card/${j}`,me),(L=ae==null?void 0:ae.data)!=null&&L.result&&(ae=(U=ae==null?void 0:ae.data)==null?void 0:U.data)}catch(me){console.log(me,"error"),be(),l(((R=(y=me==null?void 0:me.response)==null?void 0:y.data)==null?void 0:R.message)||"Something went wrong!")}let ce={cardDetails:_(_({},ae),i),callback:M(_({},(ne=le==null?void 0:le.data)==null?void 0:ne.data),{name:h==null?void 0:h.cardName,isPreAuth:V})};ze||delete ce.cardDetails,E(ce),be(),Ft()}}catch(de){l(((ie=(pe=de==null?void 0:de.response)==null?void 0:pe.data)==null?void 0:ie.message)||"Something went wrong!"),be()}},_t=async i=>{var o,L,U,y;if(i.Error)l(i.Error),be();else{let R={token:i.Token,resp:i};try{let ne=await Ot.post(`${Ie}api/v1/gateway/update/token/${j}`,R);if((ne==null?void 0:ne.status)==200){let pe={Token:(L=(o=ne==null?void 0:ne.data)==null?void 0:o.data)==null?void 0:L.gateway_token,Brand:i.Brand,ExpirationMonth:i.ExpirationMonth,ExpirationYear:i.ExpirationYear,Last4:i.Last4,Bin:i.Bin,CVV:i.CVV,postalCode:h==null?void 0:h.zipCode},ie;V?ft(pe):kt(pe)}}catch(ne){console.log(ne,"error"),be(),l(((y=(U=ne==null?void 0:ne.response)==null?void 0:U.data)==null?void 0:y.message)||"Something went wrong!")}}},Tt=()=>De(!0),Zt=i=>{N(i)},qt=()=>{var L,U,y,R,ne,pe,ie,de;let i={},o=C;return(L=o==null?void 0:o.name)!=null&&L.trim()||(i.name="Name is required"),(U=o==null?void 0:o.accountNumber)!=null&&U.trim()||(i.accountNumber="Account number is required"),(y=o==null?void 0:o.accountNumber)!=null&&y.trim()&&((R=o==null?void 0:o.accountNumber)==null?void 0:R.trim())!==((ne=o==null?void 0:o.confirmAccountNumber)==null?void 0:ne.trim())&&(i.confirmAccountNumber="Account numbers must match"),(pe=o==null?void 0:o.bankName)!=null&&pe.trim()||(i.bankName="Bank name is required"),(ie=o==null?void 0:o.routingNumber)!=null&&ie.trim()||(i.routingNumber="Routing Number is required"),o!=null&&o.routingNumber&&((de=o==null?void 0:o.routingNumber)==null?void 0:de.length)!==9&&(i.routingNumber="Routing number must be 9 digits"),((o==null?void 0:o.accountType)==="business saving"||(o==null?void 0:o.accountType)==="business checking")&&(!(o!=null&&o.companyName)||(o==null?void 0:o.companyName)==="")&&(i.companyName="Company Name is required for business accounts"),pt(i),Object.keys(i).length>0},Yt=async()=>{var i,o,L,U,y,R,ne,pe,ie,de,le,ae,ce,me,ve,Ce;try{let X={method:"POST",redirect:"follow"},ge=await Ot.post(`${Ie}api/v1/widget/generate-session`,X),We=Number(h==null?void 0:h.expiryYear)%100,tt=`${(i=h==null?void 0:h.cardNumber)==null?void 0:i.replace(/\s+/g,"")}=${We}${h==null?void 0:h.expiryMonth} ${h==null?void 0:h.cvv}`,Mt=forge.pki.publicKeyFromPem((L=(o=ge==null?void 0:ge.data)==null?void 0:o.data)==null?void 0:L.publicKeyPem).encrypt(tt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Sn=forge.util.encode64(Mt),Lt={"Content-Type":"application/json","x-app-session-key":(y=(U=ge.data)==null?void 0:U.data)==null?void 0:y.session_key},zt=JSON.stringify({enc_track2_data:Sn,algorithm:"RSAES_OAEP_SHA_1",session_key:(ne=(R=ge==null?void 0:ge.data)==null?void 0:R.data)==null?void 0:ne.session_key}),sn=await Ot.post(`${At}tokenizer/tokenize`,zt,{headers:Lt});if((sn==null?void 0:sn.status)==200){let Yn=(ie=(pe=sn==null?void 0:sn.data)==null?void 0:pe.data)==null?void 0:ie.token;try{let Wt=await Ot.post(`${Ie}api/v1/gateway/verify-and-save/${j}`,{token:Yn});if((Wt==null?void 0:Wt.status)==200){let Ht=(de=Wt==null?void 0:Wt.data)==null?void 0:de.data,tn={Token:Ht.gateway_token,Brand:Ht.card_data.brand,ExpirationMonth:Ht.card_data.expire_mm,ExpirationYear:Ht.card_data.expire_yy,Last4:Ht.card_data.last4,Bin:Ht.card_data.bin,postalCode:h==null?void 0:h.zipCode},Ut;if(ze&&Q)try{let jt={postal_code:h==null?void 0:h.zipCode,customer_id:Q,gateway_token:Ht.gateway_token};Ut=await Ot.post(`${Ie}api/v1/gateway/add-card/${j}`,jt)}catch(jt){console.log(jt,"error"),be(),l(((ae=(le=jt==null?void 0:jt.response)==null?void 0:le.data)==null?void 0:ae.message)||"Something went wrong!")}V?ft(tn):kt(tn)}}catch(Wt){console.log(Wt,"error"),l(((me=(ce=Wt==null?void 0:Wt.response)==null?void 0:ce.data)==null?void 0:me.message)||"Something went wrong!"),be()}}}catch(X){be(),console.log(X,"error"),l(((Ce=(ve=X==null?void 0:X.response)==null?void 0:ve.data)==null?void 0:Ce.message)||"Something went wrong!")}},vt=()=>{var y,R,ne,pe,ie,de;let i={},o=h,L=parseInt((o==null?void 0:o.expiryMonth)||"",10),U=(o==null?void 0:o.expiryYear)||"";if((y=o==null?void 0:o.cardName)!=null&&y.trim()||(i.cardName="Card name is required"),(R=o==null?void 0:o.cardNumber)!=null&&R.trim()||(i.cardNumber="Card number is required"),(!((ne=o==null?void 0:o.expiryMonth)!=null&&ne.trim())||!((pe=o==null?void 0:o.expiryYear)!=null&&pe.trim())||isNaN(L)||L<1||L>12||U.length!==4)&&(i.expiryMonth="Invalid Expiration Date."),(ie=o==null?void 0:o.cvv)!=null&&ie.trim()||(i.cvv="CVV is required"),(de=o==null?void 0:o.zipCode)!=null&&de.trim()||(i.zipCode="ZIP code is required"),o!=null&&o.expiryMonth&&(o!=null&&o.expiryYear)&&o.expiryMonth.length<=2&&o.expiryYear.length===4){let le=parseInt(o.expiryMonth,10),ae=parseInt(o.expiryYear,10),ce=new Date,me=ce.getMonth()+1,ve=ce.getFullYear();(ae<ve||ae===ve&&le<me)&&(i.expiryMonth="Card is expired")}return je(i),Object.keys(i).length>0},Te=()=>{let i=DatacapWebToken.validateCardNumber(h==null?void 0:h.cardNumber.replaceAll(" ","")),o=DatacapWebToken.validateExpirationDate(h==null?void 0:h.expiryMonth,h==null?void 0:h.expiryYear),L=DatacapWebToken.validateCVV(h==null?void 0:h.cvv),U={};return i||(U.cardNumber="Invalid card Number"),o||(U.expiryMonth="Invalid Expiration Date."),L||(U.cvv="Invalid CVV"),je(U),i&&L&&o},St=async i=>{var o,L,U,y,R,ne,pe,ie,de,le,ae,ce,me,ve,Ce;if(i.preventDefault(),a!=="ach"){if(vt()||!Te())return}else if(qt())return;try{at();let X=await Ot.get(`${Ie}api/v1/gateway/token/${j}`);if((X==null?void 0:X.status)==200){let ge=(L=(o=X==null?void 0:X.data)==null?void 0:o.data)==null?void 0:L.gateway_token,We=(y=(U=X==null?void 0:X.data)==null?void 0:U.data)==null?void 0:y.paymentGateway;if(a!=="ach")We==((R=Vn)==null?void 0:R.FRACTALKEY)?await Yt():DatacapWebToken.requestToken(ge,"PaymentForm",_t);else{let $t;try{let tt=await Ot.post(`${Ie}api/v1/gateway/bank-charge/${j}`,{label:C==null?void 0:C.name,account_number:C==null?void 0:C.accountNumber,routing_number:C==null?void 0:C.routingNumber,bank_name:C==null?void 0:C.bankName,account_type:C==null?void 0:C.accountType,amount:`${Re}`,customer_id:null,isSaveAch:!1,tax:"0.00",discount:"0.00",surcharge:"0.00",order_id:"",company_name:(C==null?void 0:C.companyName)||""});if((ne=tt==null?void 0:tt.data)!=null&&ne.result){if(S&&Q)try{let Ge=await Ot.post(`${Ie}api/v1/gateway/add-bank/${j}`,{name:C==null?void 0:C.name,account_number:C==null?void 0:C.accountNumber,routing_number:C==null?void 0:C.routingNumber,bank_name:C==null?void 0:C.bankName,account_type:C==null?void 0:C.accountType,customer_id:Q||"",company_name:(C==null?void 0:C.companyName)||""});Ge.data.result&&($t={bankDetails:M(_({},(pe=Ge==null?void 0:Ge.data)==null?void 0:pe.data),{account_type:C==null?void 0:C.accountType})})}catch(Ge){be(),l(((de=(ie=Ge==null?void 0:Ge.response)==null?void 0:ie.data)==null?void 0:de.message)||"Something went wrong!")}$t=M(_({},$t),{callback:M(_({},(le=tt==null?void 0:tt.data)==null?void 0:le.data),{name:C==null?void 0:C.name,isPreAuth:V})}),E($t),Ft(),be()}}catch(tt){console.log(tt,"errororor");let Ge=(ae=tt==null?void 0:tt.response)==null?void 0:ae.data;typeof(Ge==null?void 0:Ge.message)=="object"?Object.values(Ge==null?void 0:Ge.message).forEach(Mt=>{l(Mt||"Something went wrong")}):l((Ge==null?void 0:Ge.message)||"Something went wrong"),be()}}}}catch(X){be(),E({error:((me=(ce=X==null?void 0:X.response)==null?void 0:ce.data)==null?void 0:me.message)||"Something went wrong!"}),l(((Ce=(ve=X==null?void 0:X.response)==null?void 0:ve.data)==null?void 0:Ce.message)||"Something went wrong!")}},ht=(i,o)=>{let L=i;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(L)){(o===""||/^[0-9]+$/.test(o))&&(je(y=>M(_({},y),{[L]:""})),Me(y=>M(_({},y),{[L]:o})));return}je(y=>M(_({},y),{[L]:""})),Me(y=>M(_({},y),{[L]:o}))},Rt=i=>{let L=i.target.value.replace(/\D/g,""),U="";/^3[47]/.test(L)?U=L.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(R,ne,pe,ie)=>[ne,pe,ie].filter(Boolean).join(" ")):U=L.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(R,ne,pe,ie,de)=>[ne,pe,ie,de].filter(Boolean).join(" ")),je(y=>M(_({},y),{cardNumber:""})),Me(y=>M(_({},y),{cardNumber:U}))},Ve=i=>{let{name:o,value:L}=i.target,U=["routingNumber","accountNumber","confirmAccountNumber"];if(o=="name"){/^[a-zA-Z\s]*$/.test(L)&&(pt(y=>M(_({},y),{[o]:""})),Ze(y=>M(_({},y),{[o]:L})));return}if(U.includes(o)){(L===""||/^[0-9]+$/.test(L))&&(pt(y=>M(_({},y),{[o]:""})),Ze(y=>M(_({},y),{[o]:L})));return}pt(y=>M(_({},y),{[o]:""})),Ze(y=>M(_({},y),{[o]:L}))},Ft=()=>{De(!1),N("card"),l(""),D(!1),x(""),Ze({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),pt({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),Me({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),je({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Ee(!1),Ct(!1),Ae("form"),ct("form"),Z(!1),Je(0),nt(0),P([])},Pt=async()=>{var i,o,L,U;at();try{let y={isPreAuth:V,customerId:Q},R=await Ot.post(`${Ie}api/v1/gateway/card-list/${j}`,y);console.log("cardListData",R);let ne=((o=(i=R==null?void 0:R.data)==null?void 0:i.data)==null?void 0:o.cardList)||[],pe=ne==null?void 0:ne.filter(de=>(de==null?void 0:de.card_type)=="Bank"),ie=ne==null?void 0:ne.filter(de=>(de==null?void 0:de.card_type)!=="Bank");ie&&(ie==null?void 0:ie.length)>0?(N("card"),ct("list"),P(ie)):N("card"),pe&&(pe==null?void 0:pe.length)>0&&(Ae("list"),re(pe)),be()}catch(y){console.log(y),be(),l(((U=(L=y==null?void 0:y.response)==null?void 0:L.data)==null?void 0:U.message)||(y==null?void 0:y.message)||"Something went wrong")}};console.log(K,"lists",u);let et=i=>{switch(i==null?void 0:i.toLowerCase()){case"visa":return Nt;case"mastercard":case"mc":case"m/c":return $;case"amex":case"american express":case"ae":return Kt;case"discover":case"dcvr":return wt;case"bank":return _e;default:return i}},ot=async i=>{_n.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 o=>{var L,U;if(o.isConfirmed){c(!0);try{let y={card_id:i,customer_id:Q},R=await Ot.patch(`${Ie}api/v1/gateway/delete-card/${j}`,y);(L=R==null?void 0:R.data)!=null&&L.result?(c(!1),Pt(),_n.fire({icon:"success",title:"Deleted!",text:((U=R==null?void 0:R.data)==null?void 0:U.message)||"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})):(c(!1),_n.fire({icon:"error",title:"Failure!",text:"Card not deleted.",timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}}))}catch(y){c(!1),_n.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else o.dismiss===_n.DismissReason.cancel&&_n.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},en=async()=>{var U,y,R,ne;let i=Q,o=ue==null?void 0:ue.id,L=ue==null?void 0:ue.card_type;if(e)if(i)if(o){let pe={amount:(L==null?void 0:L.toLowerCase())==="bank"?`${Re}`:e,customer_id:i,card_id:o,pass_fee_amount:Number(e)-Re};V&&(pe.isPreauth=!0),console.log(pe,"chargeobj");let ie=Ie+"api/v1/gateway/charge-by-saved-details/"+j,de={"Content-Type":"application/json"};try{at();let le=await Ot.post(ie,pe);console.log(le,"res"),(U=le==null?void 0:le.data)!=null&&U.result&&(E({callback:M(_({},(y=le==null?void 0:le.data)==null?void 0:y.data),{isPreAuth:V})}),be(),Ft())}catch(le){console.log(le==null?void 0:le.response,"error by saved details"),be(),l(((ne=(R=le==null?void 0:le.response)==null?void 0:R.data)==null?void 0:ne.message)||"Something went wrong!")}}else l("Please Select A Card/ACH");else l("Please Select Customer");else l("Something went wrong.")};console.log(te,e,Q);let Et=async()=>{var i,o,L,U;try{at();let y=await Ot.get(`${Ie}api/v1/gateway/get-payment-details/${j}`);console.log(y,"respinse"),(y==null?void 0:y.status)==200&&(Z((o=(i=y==null?void 0:y.data)==null?void 0:i.data)==null?void 0:o.isBankActive),Je(Number((U=(L=y==null?void 0:y.data)==null?void 0:L.data)==null?void 0:U.fee)||0),be())}catch(y){console.log(y,"error while getting payment details"),be()}};na(()=>{te&&Et()},[te]),ta(()=>{if(te&&Fe){let i=Number(e)-Number(Fe);i&&!isNaN(i)&&nt(i)}else if(te&&he&&Be){let i=Bt(e,Be);i&&!isNaN(i)&&nt(i)}else nt(Number(e));Q&&te&&!O&&Pt()},[Q,te,e,Be]);let on=()=>V?"Cards":"Cards/Bank";return console.log(xe,"scdgfhasgcf"),r.createElement(r.Fragment,null,r.createElement("link",{href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}),r.createElement(Qt,null),r.createElement(Jn,null),r.createElement(bn,null),r.createElement("button",{className:Ke||"paymentBtn",onClick:Tt},w,we),r.createElement(Gt,{open:te,onClose:Ft},z&&r.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},r.createElement(nn,{error:z,onClose:Ft})),!z&&r.createElement(r.Fragment,null,(d||k)&&r.createElement(Vt,{loading:d||k}),r.createElement("div",{className:"frac-card-payment-page frac-form frac-new-form"},r.createElement("div",{className:"parent-pay-container"},r.createElement("span",{className:"request-payment-close-popup",onClick:Ft},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},r.createElement("g",{clipPath:"url(#clip0_12425_52336)"},r.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"})),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_12425_52336"},r.createElement("rect",{width:"16",height:"16",fill:"white"}))))),r.createElement("div",{className:"pay-main-logo-res"}),r.createElement("div",{className:"pay-container"},r.createElement("div",{className:"pay-header pay-conatiner-one"},r.createElement("div",{className:"pay-conatiner-one-first"},r.createElement("div",{className:"pay-logo-container"},r.createElement("div",{className:"pay-main-logo"}),r.createElement("h1",{className:"pay-heading"},"Pay"),(u==null?void 0:u.length)>0&&a!=="cardList"&&r.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>N("cardList")}," ",r.createElement(Xn,null)," Back")),r.createElement("div",{className:"amt-pay-con"},r.createElement("div",{className:"pay-amount-conatiner"},r.createElement("small",{className:"pay-payment-amount"},"Select payment type"),r.createElement("div",{className:"frac-card-bank-radio-main"},r.createElement(cn,{label:"Card",amount:(yt=Number(e))==null?void 0:yt.toFixed(2),value:"card",onChange:Zt,activetab:a}),!V&&xe&&r.createElement(cn,{label:"Bank",amount:(Xt=Number(Re))==null?void 0:Xt.toFixed(2),value:"ach",onChange:Zt,activetab:a})),he&&Re&&Number(e)-Number(Re)>0?r.createElement("div",{className:"frac-cash-discount-fee"},r.createElement("small",null,a==="card"?"Cash Discount":"Cash Discount Savings"," "),r.createElement("p",null,Ue((Number(e)-Number(Re)).toFixed(2)))):null))),r.createElement("div",{className:"pay-conatiner-one-last"},r.createElement("img",{src:Se,alt:""}),r.createElement("img",{src:ye,alt:""}),"Secure payments powered by Fractal")),r.createElement("div",{className:"pay-tab pay-conatiner-two"},r.createElement("div",{className:"col-md-12"},r.createElement("div",{id:"payment-form-div"},r.createElement("div",{id:"ach",style:{display:a==="card"?"block":"none"},className:"tabcontent"},r.createElement("div",{className:"frac-heading-card-wrap"},r.createElement("div",{className:"frac-backarrow"},(u==null?void 0:u.length)>0&&lt==="form"&&r.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ct("list")}," ",r.createElement(Xn,null))),r.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),r.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},r.createElement("img",{src:Nt,alt:"",width:33}),r.createElement("img",{src:$,width:33,alt:""}),r.createElement("img",{src:Kt,alt:"",width:33}),r.createElement("img",{src:wt,width:33,alt:""})),lt==="list"&&(u==null?void 0:u.length)>0?r.createElement(r.Fragment,null,r.createElement(un,{headingClass:"card-ach-heading-frac",listHeading:"Card",ListItems:u,selectedCard:ue,setSelectedCard:xt,handleDeleteCard:ot,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{ct("form")}}),r.createElement("div",{className:"form-group-frac",style:{padding:"0"}},r.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:en},Ue((rn=Number(e))==null?void 0:rn.toFixed(2))))):r.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:St},r.createElement("div",{className:"ach-scrl",style:{minHeight:"398px",maxHeight:"398px",overflow:"auto",marginRight:"5px"}},r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),r.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"John Doe",value:(h==null?void 0:h.cardName)||"",onChange:i=>{let o=i.target.value;/^[a-zA-Z\s]*$/.test(o)&&ht("cardName",o)}}),(se==null?void 0:se.cardName)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.cardName)),r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),r.createElement("div",{className:"toggle-num-wrapper"},r.createElement("input",{className:"form-control-frac card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(h==null?void 0:h.cardNumber)||"",onChange:i=>Rt(i),"data-token":"card_number"}),r.createElement("div",{className:"card-crdi card-expiry-new"},r.createElement("div",{className:"exp-date-year-container"},r.createElement("div",{className:"exp-date form-group-frac"},r.createElement("input",{"data-token":"exp_month",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(h==null?void 0:h.expiryMonth)||"",onChange:i=>ht("expiryMonth",i.target.value)})),r.createElement("div",{className:"exp-year form-group-frac"},r.createElement("input",{"data-token":"exp_year",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(h==null?void 0:h.expiryYear)||"",onChange:i=>ht("expiryYear",i.target.value)})),r.createElement("div",{className:"security-digit form-group-frac"},r.createElement("input",{"data-token":"cvv",className:"form-control-frac card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(h==null?void 0:h.cvv)||"",onChange:i=>ht("cvv",i.target.value)})))),(se==null?void 0:se.cardNumber)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.cardNumber),r.createElement("p",{style:{margin:"0"}},se!=null&&se.expiryMonth||se!=null&&se.expiryYear?r.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},se==null?void 0:se.expiryMonth):"",(se==null?void 0:se.cvv)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.cvv)))),r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"zip"},"ZIP"),r.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"000000",value:(I=h==null?void 0:h.zipCode)!=null?I:"",onChange:i=>ht("zipCode",i.target.value)}),(se==null?void 0:se.zipCode)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.zipCode)),Q&&r.createElement("div",{className:"form-group-frac"},r.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},r.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:ze,onChange:i=>Ct(i.target.checked)}),r.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),r.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),r.createElement("div",{className:"frac-tooltip-wrapper"},r.createElement("div",{className:"frac-tooltip-icon"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},r.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),r.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"}))),r.createElement("div",{className:"frac-tooltip-text"},r.createElement("p",null,"If checked, I agree to give the ",r.createElement("b",null,Oe||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),r.createElement("div",{className:"form-group-frac",style:{marginTop:"20px",padding:"0"}},r.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((p=Number(e))==null?void 0:p.toFixed(2)))))),r.createElement("div",{id:"ach",style:{display:a==="ach"?"block":"none"},className:"tabcontent"},r.createElement(r.Fragment,null,r.createElement("div",{className:"frac-heading-card-wrap"},r.createElement("div",{className:"frac-backarrow"},(K==null?void 0:K.length)>0&&rt==="form"&&r.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ae("list")}," ",r.createElement(Xn,null))),r.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment")),rt==="list"&&(K==null?void 0:K.length)>0?r.createElement(r.Fragment,null,r.createElement(un,{headingClass:"card-ach-heading-frac",listHeading:"Banks",ListItems:K,selectedCard:ue,setSelectedCard:xt,handleDeleteCard:ot,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Ae("form")}}),r.createElement("div",{className:"form-group-frac",style:{padding:"0"}},r.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:en},Ue((J=Number(Re))==null?void 0:J.toFixed(2))))):r.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:St},r.createElement("div",{className:"ach-scrl",style:{minHeight:"444px",maxHeight:"444px"}},r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),r.createElement("input",{type:"text",id:"nameonaccount",className:"form-control-frac",maxLength:100,placeholder:"John Doe",name:"name",value:(He=C==null?void 0:C.name)!=null?He:"",onChange:Ve}),(G==null?void 0:G.name)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.name)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"routingnumber"},"Routing number"),r.createElement("input",{type:"text",id:"routingnumber",className:"form-control-frac",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(g=C==null?void 0:C.routingNumber)!=null?g:"",onChange:Ve}),(G==null?void 0:G.routingNumber)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.routingNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"accountnumber"},"Account number"),r.createElement("input",{type:"text",id:"accountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(m=C==null?void 0:C.accountNumber)!=null?m:"",onChange:Ve}),(G==null?void 0:G.accountNumber)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.accountNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),r.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Y=C==null?void 0:C.confirmAccountNumber)!=null?Y:"",onChange:Ve}),(G==null?void 0:G.confirmAccountNumber)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.confirmAccountNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"bankname"},"Bank name"),r.createElement("input",{type:"text",id:"bankname",className:"form-control-frac",maxLength:100,placeholder:"My Bank",name:"bankName",value:(fe=C==null?void 0:C.bankName)!=null?fe:"",onChange:Ve}),(G==null?void 0:G.bankName)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.bankName)),((C==null?void 0:C.accountType)==="business saving"||(C==null?void 0:C.accountType)==="business checking")&&r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"companyName"},"Company name"),r.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(W=C==null?void 0:C.companyName)!=null?W:"",onChange:Ve}),(G==null?void 0:G.companyName)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.companyName)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"accounttype"},"Select account type"),r.createElement("select",{name:"accountType",id:"accounttype",className:"form-control-frac",value:(Ne=C==null?void 0:C.accountType)!=null?Ne:"",onChange:Ve},r.createElement("option",{value:""},"Select account"),Nn.map(i=>r.createElement("option",{key:i.value,value:i.value},i.label)))),Q&&r.createElement("div",{className:"form-group-frac mb-4 save-ach-div",style:{paddingTop:"5px"}},r.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:S,onChange:i=>Ee(i.target.checked)}),r.createElement("label",{className:"saveachlabel",htmlFor:"saveACH"},"Save ACH")),S&&r.createElement("div",{className:"form-group-frac mb-4 saveachtext"},r.createElement("p",null,"If checked, I agree to give the ",r.createElement("b",null,Oe||"merchant")," permission to charge this bank account for agreed-upon purchases in the future."))),r.createElement("div",{className:"form-group-frac "},r.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Ue((Pe=Number(Re))==null?void 0:Pe.toFixed(2))))))))))))))))};import t,{useEffect as Qn,useRef as aa,useState as st}from"react";import Tn from"axios";import qn from"sweetalert2";import{IoArrowBack as On}from"react-icons/io5";function oa(e){var St,ht,Rt,Ve,Ft,Pt,et,ot,en,Et,on,yt,Xt,rn,I,p,J,He;let w=aa(null);Qn(()=>{e.onTriggerPay&&e.onTriggerPay(()=>{Xe()})},[e]);let j=oe+"widget/mc-img.svg",Q=oe+"widget/visa-img.svg",E=oe+"widget/ae-img.svg",Oe=oe+"widget/discover-img.svg",V=oe+"widget/card.svg",gt=oe+"widget/Trash.svg",Ke=oe+"widget/bank.svg",we=oe+"widget/secure-img.png",O=oe+"widget/pov-by.png",he=oe+"widget/pax.svg",[Fe,a]=st(!1),[N,b]=st(!1),[ee,h]=st(""),[Me,se]=st(!1),[je,C]=st(!1),[Ze,G]=st("card"),[pt,S]=st("card"),[Ee,te]=st("form"),[De,ze]=st("form"),[Ct,z]=st(!0),[l,f]=st(!1),[D,F]=st(!1),x=e.merchantPublicKey,[d,v]=st(),[k,c]=st({}),[u,P]=st(),[K,re]=st({}),[ue,xt]=st([]),[Re,nt]=st([]),[lt,ct]=st(),[rt,Ae]=st(),[xe,Z]=st(Number(e==null?void 0:e.amount)),[Be,Je]=st(Number(e==null?void 0:e.amount));console.log(lt,"selectedCard");let[$,Nt]=st(),[Kt,wt]=st(""),A=()=>a(!0),q=()=>a(!1),_e=(g,m)=>{let Y=(parseFloat(m)||0)/100;return g-g*Y},Se=(g,m)=>{debugger;let Y=(Number(m)||0)/100;return+g+ +(g*Y)};Qn(()=>{if(je){let g=Se(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);Je(g),Z(Number(e==null?void 0:e.amount))}},[je,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let ye=()=>{C(!1),G("card"),h(""),se(!1),wt(""),P({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),re({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),v({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),c({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),F(!1),f(!1),ct({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),Ae({}),Z(0),S("card"),z(!0),ze("form"),te("form"),b(!1),a(!1),nt([]),xt([])},Xe=()=>C(!0),it=g=>{G(g)},Le=(g,m)=>{let Y=g;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(Y)){(m===""||/^[0-9]+$/.test(m))&&(c(W=>M(_({},W),{[Y]:""})),v(W=>M(_({},W),{[Y]:m})));return}c(W=>M(_({},W),{[Y]:""})),v(W=>M(_({},W),{[Y]:m}))},at=g=>{let Y=g.target.value.replace(/\D/g,""),fe="";/^3[47]/.test(Y)?fe=Y.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Ne,Pe,i,o)=>[Pe,i,o].filter(Boolean).join(" ")):fe=Y.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Ne,Pe,i,o,L)=>[Pe,i,o,L].filter(Boolean).join(" ")),c(W=>M(_({},W),{cardNumber:""})),v(W=>M(_({},W),{cardNumber:fe}))},be=g=>{let{name:m,value:Y}=g.target,fe=["routingNumber","accountNumber","confirmAccountNumber"];if(m=="name"){/^[a-zA-Z\s]*$/.test(Y)&&(re(W=>M(_({},W),{[m]:""})),P(W=>M(_({},W),{[m]:Y})));return}if(fe.includes(m)){(Y===""||/^[0-9]+$/.test(Y))&&(re(W=>M(_({},W),{[m]:""})),P(W=>M(_({},W),{[m]:Y})));return}re(W=>M(_({},W),{[m]:""})),P(W=>M(_({},W),{[m]:Y}))},Bt=()=>{var W,Ne,Pe,i,o,L;let g={},m=d,Y=parseInt((m==null?void 0:m.expiryMonth)||"",10),fe=(m==null?void 0:m.expiryYear)||"";if((W=m==null?void 0:m.cardName)!=null&&W.trim()||(g.cardName="Card name is required"),(Ne=m==null?void 0:m.cardNumber)!=null&&Ne.trim()||(g.cardNumber="Card number is required"),(!((Pe=m==null?void 0:m.expiryMonth)!=null&&Pe.trim())||!((i=m==null?void 0:m.expiryYear)!=null&&i.trim())||isNaN(Y)||Y<1||Y>12||fe.length!==4)&&(g.expiryMonth="Invalid Expiration Date."),(o=m==null?void 0:m.cvv)!=null&&o.trim()||(g.cvv="CVV is required"),(L=m==null?void 0:m.zipCode)!=null&&L.trim()||(g.zipCode="ZIP code is required"),m!=null&&m.expiryMonth&&(m!=null&&m.expiryYear)&&m.expiryMonth.length<=2&&m.expiryYear.length===4){let U=parseInt(m.expiryMonth,10),y=parseInt(m.expiryYear,10),R=new Date,ne=R.getMonth()+1,pe=R.getFullYear();(y<pe||y===pe&&U<ne)&&(g.expiryMonth="Card is expired")}return c(g),Object.keys(g).length>0},kt=()=>{var Y,fe,W,Ne,Pe,i,o,L;let g={},m=u;return(Y=m==null?void 0:m.name)!=null&&Y.trim()||(g.name="Name is required"),(fe=m==null?void 0:m.accountNumber)!=null&&fe.trim()||(g.accountNumber="Account number is required"),(W=m==null?void 0:m.accountNumber)!=null&&W.trim()&&((Ne=m==null?void 0:m.accountNumber)==null?void 0:Ne.trim())!==((Pe=m==null?void 0:m.confirmAccountNumber)==null?void 0:Pe.trim())&&(g.confirmAccountNumber="Account numbers must match"),(i=m==null?void 0:m.bankName)!=null&&i.trim()||(g.bankName="Bank name is required"),(o=m==null?void 0:m.routingNumber)!=null&&o.trim()||(g.routingNumber="Routing Number is required"),m!=null&&m.routingNumber&&((L=m==null?void 0:m.routingNumber)==null?void 0:L.length)!==9&&(g.routingNumber="Routing number must be 9 digits"),((m==null?void 0:m.accountType)==="business saving"||(m==null?void 0:m.accountType)==="business checking")&&(!(m!=null&&m.companyName)||(m==null?void 0:m.companyName)==="")&&(g.companyName="Company Name is required for business accounts"),re(g),Object.keys(g).length>0},ft=async g=>{var m,Y,fe,W,Ne,Pe,i,o,L,U,y,R,ne,pe,ie;if(g.preventDefault(),Ze!=="ach"){if(Bt())return;{let le=DatacapWebToken.validateCardNumber(d==null?void 0:d.cardNumber.replaceAll(" ","")),ae=DatacapWebToken.validateExpirationDate(d==null?void 0:d.expiryMonth,d==null?void 0:d.expiryYear),ce=DatacapWebToken.validateCVV(d==null?void 0:d.cvv),me={};if(le||(me.cardNumber="Invalid card Number"),ae||(me.expiryMonth="Invalid Expiration Date."),ce||(me.cvv="Invalid CVV"),c(me),le&&ce&&ae){b(!0);try{let ve=async function(Ce){var X,ge;if(Ce.Error)h(Ce.Error),b(!1);else{let We=d==null?void 0:d.cardName,$t=d==null?void 0:d.zipCode;Ce.name=We,Ce.postal_code=$t,Ce.isCardSave=`${l}`,Ce.isCharge=!0,Ce.posSalesIdEncode=(X=$==null?void 0:$.orderDetails)==null?void 0:X.orderId,Ce.partial_amount=Be,mt.emit("sendMessage",Ce);let tt=(ge=$==null?void 0:$.orderDetails)==null?void 0:ge.orderId;mt.on(tt,Ge=>{if(Cn(Ge==null?void 0:Ge.data)){let Mt=JSON.parse(Ge.data);Mt!=null&&Mt.result?(v({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),f(!1),wt(Mt==null?void 0:Mt.transactionId),se(!0),b(!1)):(b(!1),h((Mt==null?void 0:Mt.message)||"Something went wrong."))}else h("Something went wrong.")})}};if(($==null?void 0:$.paymentGateway)===32){let Ce={method:"POST",redirect:"follow"};try{let X=await Tn.post(`${Ie}api/v1/widget/generate-session`,Ce),ge=Number(d==null?void 0:d.expiryYear)%100,We=d==null?void 0:d.cardNumber;We=We==null?void 0:We.replace(/\s+/g,"");let $t=`${We}=${ge}${d==null?void 0:d.expiryMonth} ${d==null?void 0:d.cvv}`,Ge=forge.pki.publicKeyFromPem((Y=(m=X==null?void 0:X.data)==null?void 0:m.data)==null?void 0:Y.publicKeyPem).encrypt($t,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Mt=forge.util.encode64(Ge),Sn={"Content-Type":"application/json","x-app-session-key":(W=(fe=X.data)==null?void 0:fe.data)==null?void 0:W.session_key},Lt=JSON.stringify({enc_track2_data:`${Mt}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Pe=(Ne=X==null?void 0:X.data)==null?void 0:Ne.data)==null?void 0:Pe.session_key}`});try{let zt=await Tn.post(`${At}tokenizer/tokenize`,Lt,{headers:Sn}),sn=JSON.stringify(M(_({},(i=zt==null?void 0:zt.data)==null?void 0:i.data),{isSaveCardChecked:l,name:d==null?void 0:d.cardName,postal_code:d==null?void 0:d.zipCode,customer_id:e==null?void 0:e.customerId,partial_amount:Be})),Yn=JSON.stringify({pre_sales_id:`${(o=$==null?void 0:$.orderDetails)==null?void 0:o.orderId}`,token:`${(L=zt==null?void 0:zt.data)==null?void 0:L.data.token}`,json_response:`${sn}`}),Ht={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:Yn,redirect:"follow",isChargeviafractal:!0};mt.emit("sendMessage",Ht),mt.on("chargeviafractalgateway",tn=>{var Ut;if(Cn(tn==null?void 0:tn.data)){let jt=JSON.parse(tn==null?void 0:tn.data);jt!=null&&jt.result?(wt((Ut=jt==null?void 0:jt.data)==null?void 0:Ut.transactionId),se(!0),b(!1)):(b(!1),h((jt==null?void 0:jt.message)||"Something went wrong."))}else h("Something went wrong.")})}catch(zt){b(!1),h(((y=(U=zt==null?void 0:zt.response)==null?void 0:U.data)==null?void 0:y.message)||(zt==null?void 0:zt.message)||"Something went wrong.")}}catch(X){b(!1),h(((ne=(R=X==null?void 0:X.response)==null?void 0:R.data)==null?void 0:ne.message)||(X==null?void 0:X.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken($==null?void 0:$.dctoken,"PaymentForm",ve)}catch(ve){b(!1),h(((ie=(pe=ve==null?void 0:ve.response)==null?void 0:pe.data)==null?void 0:ie.message)||(ve==null?void 0:ve.message)||"Something went wrong.")}}}}else{if(kt())return;{b(!0);let le={fractalpayPublicKey:x,label:(u==null?void 0:u.name)||"John Doe",account_number:u==null?void 0:u.accountNumber,routing_number:u==null?void 0:u.routingNumber,bank_name:u==null?void 0:u.bankName,account_type:u==null?void 0:u.accountType,amount:String(xe||0),isSaveAch:D,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:(u==null?void 0:u.companyName)||""};mt.emit("sendMessage",le),mt.on("ach-incoming",ae=>{var ce;(ae==null?void 0:ae.status)=="Failed"?typeof(ae==null?void 0:ae.message)=="object"?Object.values(ae==null?void 0:ae.message).forEach(me=>{h(me||"Something went wrong")}):h((ae==null?void 0:ae.message)||"Something went wrong"):(wt((ce=ae==null?void 0:ae.data)==null?void 0:ce.transaction_id),se(!0),b(!1))})}}},_t=async()=>{var g,m,Y,fe,W,Ne,Pe,i,o,L,U,y,R,ne,pe,ie,de,le,ae,ce,me,ve,Ce;A();try{let X={fractalpayPublicKey:x,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,orderGuid:e==null?void 0:e.orderGuid},ge=await Tn.post(`${$e}get-payment-details`,X);if(Nt((g=ge==null?void 0:ge.data)==null?void 0:g.data),(Y=(m=ge==null?void 0:ge.data)==null?void 0:m.data)!=null&&Y.paymentGateway||(ye(),h("Something went wrong.")),(W=(fe=ge==null?void 0:ge.data)==null?void 0:fe.data)!=null&&W.card_list&&((i=(Pe=(Ne=ge==null?void 0:ge.data)==null?void 0:Ne.data)==null?void 0:Pe.card_list)==null?void 0:i.length)>0){let We=(U=(L=(o=ge==null?void 0:ge.data)==null?void 0:o.data)==null?void 0:L.card_list)==null?void 0:U.filter(tt=>(tt==null?void 0:tt.card_type)=="Bank"),$t=(ne=(R=(y=ge==null?void 0:ge.data)==null?void 0:y.data)==null?void 0:R.card_list)==null?void 0:ne.filter(tt=>(tt==null?void 0:tt.card_type)!=="Bank");console.log(We,"hohgohoo",$t),($t==null?void 0:$t.length)>0&&te("list"),(We==null?void 0:We.length)>0&&ze("list"),xt($t),nt(We)}else G("card");(ie=(pe=ge==null?void 0:ge.data)==null?void 0:pe.data)!=null&&ie.paymentDeviceList&&((ae=(le=(de=ge==null?void 0:ge.data)==null?void 0:de.data)==null?void 0:le.paymentDeviceList)==null?void 0:ae.length)>0&&Ae((me=(ce=ge==null?void 0:ge.data)==null?void 0:ce.data)==null?void 0:me.paymentDeviceList[0]),q()}catch(X){console.log(X),q(),h(((Ce=(ve=X==null?void 0:X.response)==null?void 0:ve.data)==null?void 0:Ce.message)||(X==null?void 0:X.message)||"Something went wrong")}},Tt=async()=>{let g=e==null?void 0:e.customerId,m=String(e==null?void 0:e.discount),Y=String(e==null?void 0:e.surcharge),fe=String(e==null?void 0:e.tax),W=e==null?void 0:e.merchantPublicKey,Ne=e==null?void 0:e.orderID,Pe=String(Be),i=lt==null?void 0:lt.id,o=lt==null?void 0:lt.card_type;if(W&&Ne&&Pe&&xe)if(g)if(i){let U={amount:o==="Bank"?xe:Pe,order_id:Ne,customer_id:g,card_id:i,fractalpayPublicKey:W,isCardSave:l,discount:m,surcharge:Y,tax:fe},L=U,{isCardSave:y}=L,R=vn(L,["isCardSave"]),pe=$e+(o==="Bank"?"charge-ach":"charge-by-card"),ie={"Content-Type":"application/json"};b(!0),mt.emit("sendMessage",{url:pe,body:o=="Bank"?R:U,isChargebycard:!0}),mt.on("charge-by-card",de=>{var le;(de==null?void 0:de.result)==!0||(de==null?void 0:de.status)==!0?(wt((le=de.data)==null?void 0:le.transaction_id),se(!0),b(!1)):h((de==null?void 0:de.message)||"Something went wrong.")})}else h("Please Select A Card/ACH");else h("Please Select Customer");else h("Something went wrong.")},Zt=async()=>{var W,Ne,Pe,i,o,L;let g=e==null?void 0:e.merchantPublicKey,m=e==null?void 0:e.orderID,Y=String(Be),fe=e==null?void 0:e.customerId;if(!(rt!=null&&rt.device_id)){h("Please Select A Payment Device");return}if(g&&m&&Y){b(!0);let U={amount:Y,fractalpayPublicKey:g,customer_order_id:m,device_id:rt==null?void 0:rt.device_id,customer_id:fe||""};try{let y=await Tn.post(`${$e}charge-with-reader`,U);((W=y==null?void 0:y.data)==null?void 0:W.result)==!0?(wt((Pe=(Ne=y==null?void 0:y.data)==null?void 0:Ne.data)==null?void 0:Pe.transaction_id),se(!0),b(!1)):(h(((i=y==null?void 0:y.data)==null?void 0:i.message)||"Something went wrong."),b(!1))}catch(y){h(((L=(o=y==null?void 0:y.response)==null?void 0:o.data)==null?void 0:L.message)||"Something went wrong."),b(!1)}}else h("Something went wrong.")},qt=()=>{pt==="card"?Tt():pt==="reader"&&Zt()};Qn(()=>{je&&x&&_t()},[x,je]);let Yt=async g=>{qn.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 m=>{if(m.isConfirmed){b(!0);try{let Y={card_id:g,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},fe=await Tn.post(`${$e}delete-customer-card`,Y);b(!1),_t(),qn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(Y){b(!1),qn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else m.dismiss===qn.DismissReason.cancel&&qn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},vt=g=>{switch(g==null?void 0:g.toLowerCase()){case"visa":return Q;case"mastercard":case"mc":case"m/c":return j;case"amex":case"american express":case"ae":return E;case"discover":case"dcvr":return Oe;case"bank":return Ke;default:return g}},Te=()=>{let g=xe||0;return(Number(Be)-g).toFixed(0)};return console.log(Ee,"activeinCard","activeinBank",De),t.createElement(t.Fragment,null,t.createElement(Qt,null),t.createElement(hn,null),t.createElement(bn,null),t.createElement(t.Fragment,null,t.createElement("button",{ref:w,style:{display:"none"},className:"paymentBtn",onClick:Xe},"Pay"),t.createElement(Gt,{open:je,onClose:ye},ee&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(nn,{error:ee,onClose:ye})),Me&&t.createElement(yn,{onClose:ye,tranId:Kt}),!ee&&!Me&&t.createElement(t.Fragment,null,(Fe||N)&&t.createElement(Vt,{loading:Fe||N}),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:ye},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:$==null?void 0:$.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:$==null?void 0:$.logo,id:"pay-logos"})),(ue==null?void 0:ue.length)>0&&Ze!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>G("cardList")}," ",t.createElement(On,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(cn,{label:"Card",amount:(St=Number(Be))==null?void 0:St.toFixed(2),value:"card",onChange:it,activetab:Ze}),($==null?void 0:$.isSkyFiAccount)&&t.createElement(cn,{label:"Bank",amount:(ht=Number(xe))==null?void 0:ht.toFixed(2),value:"ach",onChange:it,activetab:Ze})),xe&&xe>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,Ze==="card"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,Ue((Number(Be)-xe).toFixed(2)))):null)),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:we,alt:""}),t.createElement("img",{src:O,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!Fe&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},Ze!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(ue==null?void 0:ue.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>G("cardList")}," ",t.createElement(On,null)," Back"),($==null?void 0:$.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:g=>{it("card")},style:{border:Ze==="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:g=>{it("ach")},style:{border:Ze==="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"},"$",(Rt=Number(Be))==null?void 0:Rt.toFixed(2))),Ze!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Q,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:j,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:E,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Oe,width:35,alt:""})))),xe&&xe>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",xe)),xe&&xe>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,Ze==="card"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,Ue((Number(Be)-xe).toFixed(2)))):null):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",$==null?void 0:$.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",pt==="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"},"$",(Ve=Number(Be))==null?void 0:Ve.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:j,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:E,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Oe,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:Ze==="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"},(ue==null?void 0:ue.length)>0&&Ee==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>te("list")}," ",t.createElement(On,null)),xe&&xe>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",xe))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),Ze!="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:j,width:33,alt:""}),t.createElement("img",{src:E,alt:"",width:33}),t.createElement("img",{src:Oe,width:33,alt:""}))),Ee==="list"?t.createElement(t.Fragment,null,t.createElement(un,{listHeading:"Cards",paymentGateway:$==null?void 0:$.paymentGateway,ListItems:ue,selectedCard:lt,setSelectedCard:ct,handleDeleteCard:Yt,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{te("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:qt},Ue((Ft=Number(Be))==null?void 0:Ft.toFixed(2))))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:ft},t.createElement("div",{className:"ach-scrl",style:{minHeight:$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)>0?"444px":$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)==0?"456px":(ue==null?void 0:ue.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:(d==null?void 0:d.cardName)||"",onChange:g=>{let m=g.target.value;/^[a-zA-Z\s]*$/.test(m)&&Le("cardName",m)}}),(k==null?void 0:k.cardName)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.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:(d==null?void 0:d.cardNumber)||"",onChange:g=>at(g),"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:(d==null?void 0:d.expiryMonth)||"",onChange:g=>Le("expiryMonth",g.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:(d==null?void 0:d.expiryYear)||"",onChange:g=>Le("expiryYear",g.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:(d==null?void 0:d.cvv)||"",onChange:g=>Le("cvv",g.target.value)})))),(k==null?void 0:k.cardNumber)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.cardNumber),t.createElement("p",{style:{margin:"0"}},k!=null&&k.expiryMonth||k!=null&&k.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},k==null?void 0:k.expiryMonth):"",(k==null?void 0:k.cvv)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.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:(Pt=e==null?void 0:e.orderID)!=null?Pt:"",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:(et=d==null?void 0:d.zipCode)!=null?et:"",onChange:g=>Le("zipCode",g.target.value)}),(k==null?void 0:k.zipCode)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.zipCode)),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},t.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:l,onChange:g=>f(g.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"}},($==null?void 0:$.paymentDeviceList)&&((ot=$==null?void 0:$.paymentDeviceList)==null?void 0:ot.length)>0&&t.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>z(!Ct)},Ct?"Pay With Reader":"Pay With Card"),t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((en=Number(Be))==null?void 0:en.toFixed(2)))))),t.createElement("div",{id:"ach",style:{display:Ze==="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"},(Re==null?void 0:Re.length)>0&&De==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ze("list")}," ",t.createElement(On,null)),xe&&xe>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),t.createElement("div",null,"$",Te()))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),De==="list"?t.createElement(t.Fragment,null,t.createElement(un,{listHeading:"Banks",paymentGateway:$==null?void 0:$.paymentGateway,ListItems:Re,selectedCard:lt,setSelectedCard:ct,handleDeleteCard:Yt,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{ze("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:qt},Ue((Et=Number(xe))==null?void 0:Et.toFixed(2))))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:ft},t.createElement("div",{className:"ach-scrl",style:{minHeight:$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)>0?"444px":$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)==0?"436px":(ue==null?void 0:ue.length)>0?"462px":"520px",maxHeight:$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)>0?"444px":((ue==null?void 0:ue.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:(on=u==null?void 0:u.name)!=null?on:"",onChange:be}),(K==null?void 0:K.name)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(yt=u==null?void 0:u.routingNumber)!=null?yt:"",onChange:be}),(K==null?void 0:K.routingNumber)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(Xt=u==null?void 0:u.accountNumber)!=null?Xt:"",onChange:be}),(K==null?void 0:K.accountNumber)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(rn=u==null?void 0:u.confirmAccountNumber)!=null?rn:"",onChange:be}),(K==null?void 0:K.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(I=u==null?void 0:u.bankName)!=null?I:"",onChange:be}),(K==null?void 0:K.bankName)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.bankName)),((u==null?void 0:u.accountType)==="business saving"||(u==null?void 0:u.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:(p=u==null?void 0:u.companyName)!=null?p:"",onChange:be}),(K==null?void 0:K.companyName)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(J=u==null?void 0:u.accountType)!=null?J:"",onChange:be},t.createElement("option",{value:""},"Select account"),Nn.map(g=>t.createElement("option",{key:g.value,value:g.value},g.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:D,onChange:g=>F(g.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),D&&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"},Ue((He=Number(xe))==null?void 0:He.toFixed(2))))))))))))))))}export{Qi as AddCard,Ri as CardOnFile,Zi as GetPaymentPage,oa as PartialPayment,ia as PaymentWidget,Ei as PreAuthPayment,Fi as RequestPayment,zi as RequestPreAuthPayment};
2891
+ `)}import Ot from"axios";import{IoArrowBack as Xn}from"react-icons/io5";import _n from"sweetalert2";var ia=({amount:e,submitBtnText:w="Pay",session_token:j,customerId:Q,callback:E,merchantName:Oe="merchant",isPreAuth:V,surcharge:gt="0",submitBtnClass:Ke,submitBtnIcon:we,isRequest:O,pass_fee:he,pass_fee_amount:Fe})=>{var yt,Xt,rn,I,p,J,He,g,m,Y,fe,W,Ne,Pe;let[a,N]=ut("card"),[b,ee]=ut("card"),[h,Me]=ut(),[se,je]=ut({}),[C,Ze]=ut(),[G,pt]=ut({}),[S,Ee]=ut(!1),[te,De]=ut(!1),[ze,Ct]=ut(!1),[z,l]=ut(""),[f,D]=ut(!1),[F,x]=ut(""),[d,v]=ut(!1),[k,c]=ut(!1),[u,P]=ut([]),[K,re]=ut([]),[ue,xt]=ut(),[Re,nt]=ut(Number(e)),[lt,ct]=ut("form"),[rt,Ae]=ut("form"),[xe,Z]=ut(!1),[Be,Ge]=ut(0);console.log(Re,"cashDiscount");let $=oe+"widget/mc-img.svg",Nt=oe+"widget/visa-img.svg",Kt=oe+"widget/ae-img.svg",wt=oe+"widget/discover-img.svg",A=oe+"widget/card.svg",q=oe+"widget/Trash.svg",_e=oe+"widget/bank.svg",Se=oe+"widget/secure-img.png",ye=oe+"widget/pov-by.png",Xe=oe+"widget/pax.svg",it=oe+"widget/cardicon.svg",Le=oe+"widget/bankicon.svg",at=()=>v(!0),be=()=>v(!1),Bt=(i,o)=>{let L=(parseFloat(o)||0)/100,U=i/(1+L);return Math.round(U*100)/100},kt=async i=>{var o,L,U,y,R,ne,pe,ie,de;console.log(i,"ndfkjhdskjfhds");try{let le={pass_fee_amount:Number(e)-Re,pass_fee:he,Token:i==null?void 0:i.Token,amount:e,postal_code:i==null?void 0:i.postalCode},ae=await Ot.post(`${Ie}api/v1/gateway/charge/${j}`,le);if((o=ae==null?void 0:ae.data)!=null&&o.result){let ce;if(ze&&Q)try{let ve={postal_code:h==null?void 0:h.zipCode,customer_id:Q,gateway_token:(i==null?void 0:i.gateway_token)||(i==null?void 0:i.Token)};ce=await Ot.post(`${Ie}api/v1/gateway/add-card/${j}`,ve),console.log((L=ce==null?void 0:ce.data)==null?void 0:L.data,"addCard?.data?.data"),(U=ce==null?void 0:ce.data)!=null&&U.result&&(ce=(y=ce==null?void 0:ce.data)==null?void 0:y.data)}catch(ve){console.log(ve,"error"),be(),l(((ne=(R=ve==null?void 0:ve.response)==null?void 0:R.data)==null?void 0:ne.message)||"Something went wrong!")}let me={cardDetails:_(_({},ce),i),callback:M(_({},(pe=ae==null?void 0:ae.data)==null?void 0:pe.data),{name:h==null?void 0:h.cardName,isPreAuth:V})};ze||delete me.cardDetails,E(me),be(),Ft()}}catch(le){l(((de=(ie=le==null?void 0:le.response)==null?void 0:ie.data)==null?void 0:de.message)||"Something went wrong!"),be()}},ft=async i=>{var o,L,U,y,R,ne,pe,ie;try{let de={Token:i==null?void 0:i.Token,amount:e,postal_code:i==null?void 0:i.postalCode},le=await Ot.post(`${Ie}api/v1/gateway/preauth/${j}`,de);if((o=le==null?void 0:le.data)!=null&&o.result){let ae;if(ze&&Q)try{console.log(le,"preAuthResponse");let me={postal_code:h==null?void 0:h.zipCode,customer_id:Q,gateway_token:(i==null?void 0:i.Token)||(i==null?void 0:i.gateway_token)};ae=await Ot.post(`${Ie}api/v1/gateway/add-card/${j}`,me),(L=ae==null?void 0:ae.data)!=null&&L.result&&(ae=(U=ae==null?void 0:ae.data)==null?void 0:U.data)}catch(me){console.log(me,"error"),be(),l(((R=(y=me==null?void 0:me.response)==null?void 0:y.data)==null?void 0:R.message)||"Something went wrong!")}let ce={cardDetails:_(_({},ae),i),callback:M(_({},(ne=le==null?void 0:le.data)==null?void 0:ne.data),{name:h==null?void 0:h.cardName,isPreAuth:V})};ze||delete ce.cardDetails,E(ce),be(),Ft()}}catch(de){l(((ie=(pe=de==null?void 0:de.response)==null?void 0:pe.data)==null?void 0:ie.message)||"Something went wrong!"),be()}},_t=async i=>{var o,L,U,y;if(i.Error)l(i.Error),be();else{let R={token:i.Token,resp:i};try{let ne=await Ot.post(`${Ie}api/v1/gateway/update/token/${j}`,R);if((ne==null?void 0:ne.status)==200){let pe={Token:(L=(o=ne==null?void 0:ne.data)==null?void 0:o.data)==null?void 0:L.gateway_token,Brand:i.Brand,ExpirationMonth:i.ExpirationMonth,ExpirationYear:i.ExpirationYear,Last4:i.Last4,Bin:i.Bin,CVV:i.CVV,postalCode:h==null?void 0:h.zipCode},ie;V?ft(pe):kt(pe)}}catch(ne){console.log(ne,"error"),be(),l(((y=(U=ne==null?void 0:ne.response)==null?void 0:U.data)==null?void 0:y.message)||"Something went wrong!")}}},Tt=()=>De(!0),Zt=i=>{N(i)},qt=()=>{var L,U,y,R,ne,pe,ie,de;let i={},o=C;return(L=o==null?void 0:o.name)!=null&&L.trim()||(i.name="Name is required"),(U=o==null?void 0:o.accountNumber)!=null&&U.trim()||(i.accountNumber="Account number is required"),(y=o==null?void 0:o.accountNumber)!=null&&y.trim()&&((R=o==null?void 0:o.accountNumber)==null?void 0:R.trim())!==((ne=o==null?void 0:o.confirmAccountNumber)==null?void 0:ne.trim())&&(i.confirmAccountNumber="Account numbers must match"),(pe=o==null?void 0:o.bankName)!=null&&pe.trim()||(i.bankName="Bank name is required"),(ie=o==null?void 0:o.routingNumber)!=null&&ie.trim()||(i.routingNumber="Routing Number is required"),o!=null&&o.routingNumber&&((de=o==null?void 0:o.routingNumber)==null?void 0:de.length)!==9&&(i.routingNumber="Routing number must be 9 digits"),((o==null?void 0:o.accountType)==="business saving"||(o==null?void 0:o.accountType)==="business checking")&&(!(o!=null&&o.companyName)||(o==null?void 0:o.companyName)==="")&&(i.companyName="Company Name is required for business accounts"),pt(i),Object.keys(i).length>0},Yt=async()=>{var i,o,L,U,y,R,ne,pe,ie,de,le,ae,ce,me,ve,Ce;try{let X={method:"POST",redirect:"follow"},ge=await Ot.post(`${Ie}api/v1/widget/generate-session`,X),We=Number(h==null?void 0:h.expiryYear)%100,tt=`${(i=h==null?void 0:h.cardNumber)==null?void 0:i.replace(/\s+/g,"")}=${We}${h==null?void 0:h.expiryMonth} ${h==null?void 0:h.cvv}`,Mt=forge.pki.publicKeyFromPem((L=(o=ge==null?void 0:ge.data)==null?void 0:o.data)==null?void 0:L.publicKeyPem).encrypt(tt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Sn=forge.util.encode64(Mt),Lt={"Content-Type":"application/json","x-app-session-key":(y=(U=ge.data)==null?void 0:U.data)==null?void 0:y.session_key},zt=JSON.stringify({enc_track2_data:Sn,algorithm:"RSAES_OAEP_SHA_1",session_key:(ne=(R=ge==null?void 0:ge.data)==null?void 0:R.data)==null?void 0:ne.session_key}),sn=await Ot.post(`${At}tokenizer/tokenize`,zt,{headers:Lt});if((sn==null?void 0:sn.status)==200){let Yn=(ie=(pe=sn==null?void 0:sn.data)==null?void 0:pe.data)==null?void 0:ie.token;try{let Wt=await Ot.post(`${Ie}api/v1/gateway/verify-and-save/${j}`,{token:Yn});if((Wt==null?void 0:Wt.status)==200){let Ht=(de=Wt==null?void 0:Wt.data)==null?void 0:de.data,tn={Token:Ht.gateway_token,Brand:Ht.card_data.brand,ExpirationMonth:Ht.card_data.expire_mm,ExpirationYear:Ht.card_data.expire_yy,Last4:Ht.card_data.last4,Bin:Ht.card_data.bin,postalCode:h==null?void 0:h.zipCode},Ut;if(ze&&Q)try{let jt={postal_code:h==null?void 0:h.zipCode,customer_id:Q,gateway_token:Ht.gateway_token};Ut=await Ot.post(`${Ie}api/v1/gateway/add-card/${j}`,jt)}catch(jt){console.log(jt,"error"),be(),l(((ae=(le=jt==null?void 0:jt.response)==null?void 0:le.data)==null?void 0:ae.message)||"Something went wrong!")}V?ft(tn):kt(tn)}}catch(Wt){console.log(Wt,"error"),l(((me=(ce=Wt==null?void 0:Wt.response)==null?void 0:ce.data)==null?void 0:me.message)||"Something went wrong!"),be()}}}catch(X){be(),console.log(X,"error"),l(((Ce=(ve=X==null?void 0:X.response)==null?void 0:ve.data)==null?void 0:Ce.message)||"Something went wrong!")}},vt=()=>{var y,R,ne,pe,ie,de;let i={},o=h,L=parseInt((o==null?void 0:o.expiryMonth)||"",10),U=(o==null?void 0:o.expiryYear)||"";if((y=o==null?void 0:o.cardName)!=null&&y.trim()||(i.cardName="Card name is required"),(R=o==null?void 0:o.cardNumber)!=null&&R.trim()||(i.cardNumber="Card number is required"),(!((ne=o==null?void 0:o.expiryMonth)!=null&&ne.trim())||!((pe=o==null?void 0:o.expiryYear)!=null&&pe.trim())||isNaN(L)||L<1||L>12||U.length!==4)&&(i.expiryMonth="Invalid Expiration Date."),(ie=o==null?void 0:o.cvv)!=null&&ie.trim()||(i.cvv="CVV is required"),(de=o==null?void 0:o.zipCode)!=null&&de.trim()||(i.zipCode="ZIP code is required"),o!=null&&o.expiryMonth&&(o!=null&&o.expiryYear)&&o.expiryMonth.length<=2&&o.expiryYear.length===4){let le=parseInt(o.expiryMonth,10),ae=parseInt(o.expiryYear,10),ce=new Date,me=ce.getMonth()+1,ve=ce.getFullYear();(ae<ve||ae===ve&&le<me)&&(i.expiryMonth="Card is expired")}return je(i),Object.keys(i).length>0},Te=()=>{let i=DatacapWebToken.validateCardNumber(h==null?void 0:h.cardNumber.replaceAll(" ","")),o=DatacapWebToken.validateExpirationDate(h==null?void 0:h.expiryMonth,h==null?void 0:h.expiryYear),L=DatacapWebToken.validateCVV(h==null?void 0:h.cvv),U={};return i||(U.cardNumber="Invalid card Number"),o||(U.expiryMonth="Invalid Expiration Date."),L||(U.cvv="Invalid CVV"),je(U),i&&L&&o},St=async i=>{var o,L,U,y,R,ne,pe,ie,de,le,ae,ce,me,ve,Ce;if(i.preventDefault(),a!=="ach"){if(vt()||!Te())return}else if(qt())return;try{at();let X=await Ot.get(`${Ie}api/v1/gateway/token/${j}`);if((X==null?void 0:X.status)==200){let ge=(L=(o=X==null?void 0:X.data)==null?void 0:o.data)==null?void 0:L.gateway_token,We=(y=(U=X==null?void 0:X.data)==null?void 0:U.data)==null?void 0:y.paymentGateway;if(a!=="ach")We==((R=Vn)==null?void 0:R.FRACTALKEY)?await Yt():DatacapWebToken.requestToken(ge,"PaymentForm",_t);else{let $t;try{let tt=await Ot.post(`${Ie}api/v1/gateway/bank-charge/${j}`,{label:C==null?void 0:C.name,account_number:C==null?void 0:C.accountNumber,routing_number:C==null?void 0:C.routingNumber,bank_name:C==null?void 0:C.bankName,account_type:C==null?void 0:C.accountType,amount:`${Re}`,customer_id:null,isSaveAch:!1,tax:"0.00",discount:"0.00",surcharge:"0.00",order_id:"",company_name:(C==null?void 0:C.companyName)||""});if((ne=tt==null?void 0:tt.data)!=null&&ne.result){if(S&&Q)try{let Je=await Ot.post(`${Ie}api/v1/gateway/add-bank/${j}`,{name:C==null?void 0:C.name,account_number:C==null?void 0:C.accountNumber,routing_number:C==null?void 0:C.routingNumber,bank_name:C==null?void 0:C.bankName,account_type:C==null?void 0:C.accountType,customer_id:Q||"",company_name:(C==null?void 0:C.companyName)||""});Je.data.result&&($t={bankDetails:M(_({},(pe=Je==null?void 0:Je.data)==null?void 0:pe.data),{account_type:C==null?void 0:C.accountType})})}catch(Je){be(),l(((de=(ie=Je==null?void 0:Je.response)==null?void 0:ie.data)==null?void 0:de.message)||"Something went wrong!")}$t=M(_({},$t),{callback:M(_({},(le=tt==null?void 0:tt.data)==null?void 0:le.data),{name:C==null?void 0:C.name,isPreAuth:V})}),E($t),Ft(),be()}}catch(tt){console.log(tt,"errororor");let Je=(ae=tt==null?void 0:tt.response)==null?void 0:ae.data;typeof(Je==null?void 0:Je.message)=="object"?Object.values(Je==null?void 0:Je.message).forEach(Mt=>{l(Mt||"Something went wrong")}):l((Je==null?void 0:Je.message)||"Something went wrong"),be()}}}}catch(X){be(),E({error:((me=(ce=X==null?void 0:X.response)==null?void 0:ce.data)==null?void 0:me.message)||"Something went wrong!"}),l(((Ce=(ve=X==null?void 0:X.response)==null?void 0:ve.data)==null?void 0:Ce.message)||"Something went wrong!")}},ht=(i,o)=>{let L=i;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(L)){(o===""||/^[0-9]+$/.test(o))&&(je(y=>M(_({},y),{[L]:""})),Me(y=>M(_({},y),{[L]:o})));return}je(y=>M(_({},y),{[L]:""})),Me(y=>M(_({},y),{[L]:o}))},Rt=i=>{let L=i.target.value.replace(/\D/g,""),U="";/^3[47]/.test(L)?U=L.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(R,ne,pe,ie)=>[ne,pe,ie].filter(Boolean).join(" ")):U=L.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(R,ne,pe,ie,de)=>[ne,pe,ie,de].filter(Boolean).join(" ")),je(y=>M(_({},y),{cardNumber:""})),Me(y=>M(_({},y),{cardNumber:U}))},Ve=i=>{let{name:o,value:L}=i.target,U=["routingNumber","accountNumber","confirmAccountNumber"];if(o=="name"){/^[a-zA-Z\s]*$/.test(L)&&(pt(y=>M(_({},y),{[o]:""})),Ze(y=>M(_({},y),{[o]:L})));return}if(U.includes(o)){(L===""||/^[0-9]+$/.test(L))&&(pt(y=>M(_({},y),{[o]:""})),Ze(y=>M(_({},y),{[o]:L})));return}pt(y=>M(_({},y),{[o]:""})),Ze(y=>M(_({},y),{[o]:L}))},Ft=()=>{De(!1),N("card"),l(""),D(!1),x(""),Ze({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),pt({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),Me({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),je({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Ee(!1),Ct(!1),Ae("form"),ct("form"),Z(!1),Ge(0),nt(0),P([])},Pt=async()=>{var i,o,L,U;at();try{let y={isPreAuth:V,customerId:Q},R=await Ot.post(`${Ie}api/v1/gateway/card-list/${j}`,y);console.log("cardListData",R);let ne=((o=(i=R==null?void 0:R.data)==null?void 0:i.data)==null?void 0:o.cardList)||[],pe=ne==null?void 0:ne.filter(de=>(de==null?void 0:de.card_type)=="Bank"),ie=ne==null?void 0:ne.filter(de=>(de==null?void 0:de.card_type)!=="Bank");ie&&(ie==null?void 0:ie.length)>0?(N("card"),ct("list"),P(ie)):N("card"),pe&&(pe==null?void 0:pe.length)>0&&(Ae("list"),re(pe)),be()}catch(y){console.log(y),be(),l(((U=(L=y==null?void 0:y.response)==null?void 0:L.data)==null?void 0:U.message)||(y==null?void 0:y.message)||"Something went wrong")}};console.log(K,"lists",u);let et=i=>{switch(i==null?void 0:i.toLowerCase()){case"visa":return Nt;case"mastercard":case"mc":case"m/c":return $;case"amex":case"american express":case"ae":return Kt;case"discover":case"dcvr":return wt;case"bank":return _e;default:return i}},ot=async i=>{_n.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 o=>{var L,U;if(o.isConfirmed){c(!0);try{let y={card_id:i,customer_id:Q},R=await Ot.patch(`${Ie}api/v1/gateway/delete-card/${j}`,y);(L=R==null?void 0:R.data)!=null&&L.result?(c(!1),Pt(),_n.fire({icon:"success",title:"Deleted!",text:((U=R==null?void 0:R.data)==null?void 0:U.message)||"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})):(c(!1),_n.fire({icon:"error",title:"Failure!",text:"Card not deleted.",timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}}))}catch(y){c(!1),_n.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else o.dismiss===_n.DismissReason.cancel&&_n.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},en=async()=>{var U,y,R,ne;let i=Q,o=ue==null?void 0:ue.id,L=ue==null?void 0:ue.card_type;if(e)if(i)if(o){let pe={amount:(L==null?void 0:L.toLowerCase())==="bank"?`${Re}`:e,customer_id:i,card_id:o,pass_fee_amount:Number(e)-Re};V&&(pe.isPreauth=!0),console.log(pe,"chargeobj");let ie=Ie+"api/v1/gateway/charge-by-saved-details/"+j,de={"Content-Type":"application/json"};try{at();let le=await Ot.post(ie,pe);console.log(le,"res"),(U=le==null?void 0:le.data)!=null&&U.result&&(E({callback:M(_({},(y=le==null?void 0:le.data)==null?void 0:y.data),{isPreAuth:V})}),be(),Ft())}catch(le){console.log(le==null?void 0:le.response,"error by saved details"),be(),l(((ne=(R=le==null?void 0:le.response)==null?void 0:R.data)==null?void 0:ne.message)||"Something went wrong!")}}else l("Please Select A Card/ACH");else l("Please Select Customer");else l("Something went wrong.")};console.log(te,e,Q);let Et=async()=>{var i,o,L,U;try{at();let y=await Ot.get(`${Ie}api/v1/gateway/get-payment-details/${j}`);console.log(y,"respinse"),(y==null?void 0:y.status)==200&&(Z((o=(i=y==null?void 0:y.data)==null?void 0:i.data)==null?void 0:o.isBankActive),Ge(Number((U=(L=y==null?void 0:y.data)==null?void 0:L.data)==null?void 0:U.fee)||0),be())}catch(y){console.log(y,"error while getting payment details"),be()}};na(()=>{te&&Et()},[te]),ta(()=>{if(te&&Fe){let i=Number(e)-Number(Fe);i&&!isNaN(i)&&nt(i)}else if(te&&he&&Be){let i=Bt(e,Be);i&&!isNaN(i)&&nt(i)}else nt(Number(e));Q&&te&&!O&&Pt()},[Q,te,e,Be]);let on=()=>V?"Cards":"Cards/Bank";return console.log(xe,"scdgfhasgcf"),r.createElement(r.Fragment,null,r.createElement("link",{href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}),r.createElement(Qt,null),r.createElement(Jn,null),r.createElement(bn,null),r.createElement("button",{className:Ke||"paymentBtn",onClick:Tt},w,we),r.createElement(Gt,{open:te,onClose:Ft},z&&r.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},r.createElement(nn,{error:z,onClose:Ft})),!z&&r.createElement(r.Fragment,null,(d||k)&&r.createElement(Vt,{loading:d||k}),r.createElement("div",{className:"frac-card-payment-page frac-form frac-new-form"},r.createElement("div",{className:"parent-pay-container"},r.createElement("span",{className:"request-payment-close-popup",onClick:Ft},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},r.createElement("g",{clipPath:"url(#clip0_12425_52336)"},r.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"})),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_12425_52336"},r.createElement("rect",{width:"16",height:"16",fill:"white"}))))),r.createElement("div",{className:"pay-main-logo-res"}),r.createElement("div",{className:"pay-container"},r.createElement("div",{className:"pay-header pay-conatiner-one"},r.createElement("div",{className:"pay-conatiner-one-first"},r.createElement("div",{className:"pay-logo-container"},r.createElement("div",{className:"pay-main-logo"}),r.createElement("h1",{className:"pay-heading"},"Pay"),(u==null?void 0:u.length)>0&&a!=="cardList"&&r.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>N("cardList")}," ",r.createElement(Xn,null)," Back")),r.createElement("div",{className:"amt-pay-con"},r.createElement("div",{className:"pay-amount-conatiner"},r.createElement("small",{className:"pay-payment-amount"},"Select payment type"),r.createElement("div",{className:"frac-card-bank-radio-main"},r.createElement(cn,{label:"Card",amount:(yt=Number(e))==null?void 0:yt.toFixed(2),value:"card",onChange:Zt,activetab:a}),!V&&xe&&r.createElement(cn,{label:"Bank",amount:(Xt=Number(Re))==null?void 0:Xt.toFixed(2),value:"ach",onChange:Zt,activetab:a})),he&&Re&&Number(e)-Number(Re)>0?r.createElement("div",{className:"frac-cash-discount-fee"},r.createElement("small",null,a==="card"?"Cash Discount":"Cash Discount Savings"," "),r.createElement("p",null,Ue((Number(e)-Number(Re)).toFixed(2)))):null))),r.createElement("div",{className:"pay-conatiner-one-last"},r.createElement("img",{src:Se,alt:""}),r.createElement("img",{src:ye,alt:""}),"Secure payments powered by Fractal")),r.createElement("div",{className:"pay-tab pay-conatiner-two"},r.createElement("div",{className:"col-md-12"},r.createElement("div",{id:"payment-form-div"},r.createElement("div",{id:"ach",style:{display:a==="card"?"block":"none"},className:"tabcontent"},r.createElement("div",{className:"frac-heading-card-wrap"},r.createElement("div",{className:"frac-backarrow"},(u==null?void 0:u.length)>0&&lt==="form"&&r.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ct("list")}," ",r.createElement(Xn,null))),r.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),r.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},r.createElement("img",{src:Nt,alt:"",width:33}),r.createElement("img",{src:$,width:33,alt:""}),r.createElement("img",{src:Kt,alt:"",width:33}),r.createElement("img",{src:wt,width:33,alt:""})),lt==="list"&&(u==null?void 0:u.length)>0?r.createElement(r.Fragment,null,r.createElement(un,{headingClass:"card-ach-heading-frac",listHeading:"Card",ListItems:u,selectedCard:ue,setSelectedCard:xt,handleDeleteCard:ot,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{ct("form")}}),r.createElement("div",{className:"form-group-frac",style:{padding:"0"}},r.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:en},Ue((rn=Number(e))==null?void 0:rn.toFixed(2))))):r.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:St},r.createElement("div",{className:"ach-scrl",style:{minHeight:"398px",maxHeight:"398px",overflow:"auto",marginRight:"5px"}},r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),r.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"John Doe",value:(h==null?void 0:h.cardName)||"",onChange:i=>{let o=i.target.value;/^[a-zA-Z\s]*$/.test(o)&&ht("cardName",o)}}),(se==null?void 0:se.cardName)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.cardName)),r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),r.createElement("div",{className:"toggle-num-wrapper"},r.createElement("input",{className:"form-control-frac card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(h==null?void 0:h.cardNumber)||"",onChange:i=>Rt(i),"data-token":"card_number"}),r.createElement("div",{className:"card-crdi card-expiry-new"},r.createElement("div",{className:"exp-date-year-container"},r.createElement("div",{className:"exp-date form-group-frac"},r.createElement("input",{"data-token":"exp_month",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(h==null?void 0:h.expiryMonth)||"",onChange:i=>ht("expiryMonth",i.target.value)})),r.createElement("div",{className:"exp-year form-group-frac"},r.createElement("input",{"data-token":"exp_year",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(h==null?void 0:h.expiryYear)||"",onChange:i=>ht("expiryYear",i.target.value)})),r.createElement("div",{className:"security-digit form-group-frac"},r.createElement("input",{"data-token":"cvv",className:"form-control-frac card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(h==null?void 0:h.cvv)||"",onChange:i=>ht("cvv",i.target.value)})))),(se==null?void 0:se.cardNumber)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.cardNumber),r.createElement("p",{style:{margin:"0"}},se!=null&&se.expiryMonth||se!=null&&se.expiryYear?r.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},se==null?void 0:se.expiryMonth):"",(se==null?void 0:se.cvv)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.cvv)))),r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"zip"},"ZIP"),r.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"000000",value:(I=h==null?void 0:h.zipCode)!=null?I:"",onChange:i=>ht("zipCode",i.target.value)}),(se==null?void 0:se.zipCode)&&r.createElement("span",{className:"error-span"},se==null?void 0:se.zipCode)),Q&&r.createElement("div",{className:"form-group-frac"},r.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},r.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:ze,onChange:i=>Ct(i.target.checked)}),r.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),r.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),r.createElement("div",{className:"frac-tooltip-wrapper"},r.createElement("div",{className:"frac-tooltip-icon"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},r.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),r.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"}))),r.createElement("div",{className:"frac-tooltip-text"},r.createElement("p",null,"If checked, I agree to give the ",r.createElement("b",null,Oe||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),r.createElement("div",{className:"form-group-frac",style:{marginTop:"20px",padding:"0"}},r.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((p=Number(e))==null?void 0:p.toFixed(2)))))),r.createElement("div",{id:"ach",style:{display:a==="ach"?"block":"none"},className:"tabcontent"},r.createElement(r.Fragment,null,r.createElement("div",{className:"frac-heading-card-wrap"},r.createElement("div",{className:"frac-backarrow"},(K==null?void 0:K.length)>0&&rt==="form"&&r.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ae("list")}," ",r.createElement(Xn,null))),r.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment")),rt==="list"&&(K==null?void 0:K.length)>0?r.createElement(r.Fragment,null,r.createElement(un,{headingClass:"card-ach-heading-frac",listHeading:"Banks",ListItems:K,selectedCard:ue,setSelectedCard:xt,handleDeleteCard:ot,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Ae("form")}}),r.createElement("div",{className:"form-group-frac",style:{padding:"0"}},r.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:en},Ue((J=Number(Re))==null?void 0:J.toFixed(2))))):r.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:St},r.createElement("div",{className:"ach-scrl",style:{minHeight:"444px",maxHeight:"444px"}},r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),r.createElement("input",{type:"text",id:"nameonaccount",className:"form-control-frac",maxLength:100,placeholder:"John Doe",name:"name",value:(He=C==null?void 0:C.name)!=null?He:"",onChange:Ve}),(G==null?void 0:G.name)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.name)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"routingnumber"},"Routing number"),r.createElement("input",{type:"text",id:"routingnumber",className:"form-control-frac",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(g=C==null?void 0:C.routingNumber)!=null?g:"",onChange:Ve}),(G==null?void 0:G.routingNumber)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.routingNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"accountnumber"},"Account number"),r.createElement("input",{type:"text",id:"accountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(m=C==null?void 0:C.accountNumber)!=null?m:"",onChange:Ve}),(G==null?void 0:G.accountNumber)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.accountNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),r.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Y=C==null?void 0:C.confirmAccountNumber)!=null?Y:"",onChange:Ve}),(G==null?void 0:G.confirmAccountNumber)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.confirmAccountNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"bankname"},"Bank name"),r.createElement("input",{type:"text",id:"bankname",className:"form-control-frac",maxLength:100,placeholder:"My Bank",name:"bankName",value:(fe=C==null?void 0:C.bankName)!=null?fe:"",onChange:Ve}),(G==null?void 0:G.bankName)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.bankName)),((C==null?void 0:C.accountType)==="business saving"||(C==null?void 0:C.accountType)==="business checking")&&r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"companyName"},"Company name"),r.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(W=C==null?void 0:C.companyName)!=null?W:"",onChange:Ve}),(G==null?void 0:G.companyName)&&r.createElement("span",{className:"error-span"},G==null?void 0:G.companyName)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"accounttype"},"Select account type"),r.createElement("select",{name:"accountType",id:"accounttype",className:"form-control-frac",value:(Ne=C==null?void 0:C.accountType)!=null?Ne:"",onChange:Ve},r.createElement("option",{value:""},"Select account"),Nn.map(i=>r.createElement("option",{key:i.value,value:i.value},i.label)))),Q&&r.createElement("div",{className:"form-group-frac mb-4 save-ach-div",style:{paddingTop:"5px"}},r.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:S,onChange:i=>Ee(i.target.checked)}),r.createElement("label",{className:"saveachlabel",htmlFor:"saveACH"},"Save ACH")),S&&r.createElement("div",{className:"form-group-frac mb-4 saveachtext"},r.createElement("p",null,"If checked, I agree to give the ",r.createElement("b",null,Oe||"merchant")," permission to charge this bank account for agreed-upon purchases in the future."))),r.createElement("div",{className:"form-group-frac "},r.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Ue((Pe=Number(Re))==null?void 0:Pe.toFixed(2))))))))))))))))};import t,{useEffect as Qn,useRef as aa,useState as st}from"react";import Tn from"axios";import qn from"sweetalert2";import{IoArrowBack as On}from"react-icons/io5";function oa(e){var St,ht,Rt,Ve,Ft,Pt,et,ot,en,Et,on,yt,Xt,rn,I,p,J,He;let w=aa(null);Qn(()=>{e.onTriggerPay&&e.onTriggerPay(()=>{Xe()})},[e]);let j=oe+"widget/mc-img.svg",Q=oe+"widget/visa-img.svg",E=oe+"widget/ae-img.svg",Oe=oe+"widget/discover-img.svg",V=oe+"widget/card.svg",gt=oe+"widget/Trash.svg",Ke=oe+"widget/bank.svg",we=oe+"widget/secure-img.png",O=oe+"widget/pov-by.png",he=oe+"widget/pax.svg",[Fe,a]=st(!1),[N,b]=st(!1),[ee,h]=st(""),[Me,se]=st(!1),[je,C]=st(!1),[Ze,G]=st("card"),[pt,S]=st("card"),[Ee,te]=st("form"),[De,ze]=st("form"),[Ct,z]=st(!0),[l,f]=st(!1),[D,F]=st(!1),x=e.merchantPublicKey,[d,v]=st(),[k,c]=st({}),[u,P]=st(),[K,re]=st({}),[ue,xt]=st([]),[Re,nt]=st([]),[lt,ct]=st(),[rt,Ae]=st(),[xe,Z]=st(Number(e==null?void 0:e.amount)),[Be,Ge]=st(Number(e==null?void 0:e.amount));console.log(lt,"selectedCard");let[$,Nt]=st(),[Kt,wt]=st(""),A=()=>a(!0),q=()=>a(!1),_e=(g,m)=>{let Y=(parseFloat(m)||0)/100;return g-g*Y},Se=(g,m)=>{let Y=(Number(m)||0)/100;return+g+ +(g*Y)};Qn(()=>{if(je)if(e!=null&&e.pass_fee){let g=Se(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);Ge(g),Z(Number(e==null?void 0:e.amount))}else Ge(Number(e==null?void 0:e.amount)),Z(Number(e==null?void 0:e.amount))},[je,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let ye=()=>{C(!1),G("card"),h(""),se(!1),wt(""),P({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),re({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),v({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),c({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),F(!1),f(!1),ct({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),Ae({}),Z(0),S("card"),z(!0),ze("form"),te("form"),b(!1),a(!1),nt([]),xt([])},Xe=()=>C(!0),it=g=>{G(g)},Le=(g,m)=>{let Y=g;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(Y)){(m===""||/^[0-9]+$/.test(m))&&(c(W=>M(_({},W),{[Y]:""})),v(W=>M(_({},W),{[Y]:m})));return}c(W=>M(_({},W),{[Y]:""})),v(W=>M(_({},W),{[Y]:m}))},at=g=>{let Y=g.target.value.replace(/\D/g,""),fe="";/^3[47]/.test(Y)?fe=Y.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Ne,Pe,i,o)=>[Pe,i,o].filter(Boolean).join(" ")):fe=Y.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Ne,Pe,i,o,L)=>[Pe,i,o,L].filter(Boolean).join(" ")),c(W=>M(_({},W),{cardNumber:""})),v(W=>M(_({},W),{cardNumber:fe}))},be=g=>{let{name:m,value:Y}=g.target,fe=["routingNumber","accountNumber","confirmAccountNumber"];if(m=="name"){/^[a-zA-Z\s]*$/.test(Y)&&(re(W=>M(_({},W),{[m]:""})),P(W=>M(_({},W),{[m]:Y})));return}if(fe.includes(m)){(Y===""||/^[0-9]+$/.test(Y))&&(re(W=>M(_({},W),{[m]:""})),P(W=>M(_({},W),{[m]:Y})));return}re(W=>M(_({},W),{[m]:""})),P(W=>M(_({},W),{[m]:Y}))},Bt=()=>{var W,Ne,Pe,i,o,L;let g={},m=d,Y=parseInt((m==null?void 0:m.expiryMonth)||"",10),fe=(m==null?void 0:m.expiryYear)||"";if((W=m==null?void 0:m.cardName)!=null&&W.trim()||(g.cardName="Card name is required"),(Ne=m==null?void 0:m.cardNumber)!=null&&Ne.trim()||(g.cardNumber="Card number is required"),(!((Pe=m==null?void 0:m.expiryMonth)!=null&&Pe.trim())||!((i=m==null?void 0:m.expiryYear)!=null&&i.trim())||isNaN(Y)||Y<1||Y>12||fe.length!==4)&&(g.expiryMonth="Invalid Expiration Date."),(o=m==null?void 0:m.cvv)!=null&&o.trim()||(g.cvv="CVV is required"),(L=m==null?void 0:m.zipCode)!=null&&L.trim()||(g.zipCode="ZIP code is required"),m!=null&&m.expiryMonth&&(m!=null&&m.expiryYear)&&m.expiryMonth.length<=2&&m.expiryYear.length===4){let U=parseInt(m.expiryMonth,10),y=parseInt(m.expiryYear,10),R=new Date,ne=R.getMonth()+1,pe=R.getFullYear();(y<pe||y===pe&&U<ne)&&(g.expiryMonth="Card is expired")}return c(g),Object.keys(g).length>0},kt=()=>{var Y,fe,W,Ne,Pe,i,o,L;let g={},m=u;return(Y=m==null?void 0:m.name)!=null&&Y.trim()||(g.name="Name is required"),(fe=m==null?void 0:m.accountNumber)!=null&&fe.trim()||(g.accountNumber="Account number is required"),(W=m==null?void 0:m.accountNumber)!=null&&W.trim()&&((Ne=m==null?void 0:m.accountNumber)==null?void 0:Ne.trim())!==((Pe=m==null?void 0:m.confirmAccountNumber)==null?void 0:Pe.trim())&&(g.confirmAccountNumber="Account numbers must match"),(i=m==null?void 0:m.bankName)!=null&&i.trim()||(g.bankName="Bank name is required"),(o=m==null?void 0:m.routingNumber)!=null&&o.trim()||(g.routingNumber="Routing Number is required"),m!=null&&m.routingNumber&&((L=m==null?void 0:m.routingNumber)==null?void 0:L.length)!==9&&(g.routingNumber="Routing number must be 9 digits"),((m==null?void 0:m.accountType)==="business saving"||(m==null?void 0:m.accountType)==="business checking")&&(!(m!=null&&m.companyName)||(m==null?void 0:m.companyName)==="")&&(g.companyName="Company Name is required for business accounts"),re(g),Object.keys(g).length>0},ft=async g=>{var m,Y,fe,W,Ne,Pe,i,o,L,U,y,R,ne,pe,ie;if(g.preventDefault(),Ze!=="ach"){if(Bt())return;{let le=DatacapWebToken.validateCardNumber(d==null?void 0:d.cardNumber.replaceAll(" ","")),ae=DatacapWebToken.validateExpirationDate(d==null?void 0:d.expiryMonth,d==null?void 0:d.expiryYear),ce=DatacapWebToken.validateCVV(d==null?void 0:d.cvv),me={};if(le||(me.cardNumber="Invalid card Number"),ae||(me.expiryMonth="Invalid Expiration Date."),ce||(me.cvv="Invalid CVV"),c(me),le&&ce&&ae){b(!0);try{let ve=async function(Ce){var X,ge;if(Ce.Error)h(Ce.Error),b(!1);else{let We=d==null?void 0:d.cardName,$t=d==null?void 0:d.zipCode;Ce.name=We,Ce.postal_code=$t,Ce.isCardSave=`${l}`,Ce.isCharge=!0,Ce.posSalesIdEncode=(X=$==null?void 0:$.orderDetails)==null?void 0:X.orderId,Ce.partial_amount=Be,mt.emit("sendMessage",Ce);let tt=(ge=$==null?void 0:$.orderDetails)==null?void 0:ge.orderId;mt.on(tt,Je=>{if(Cn(Je==null?void 0:Je.data)){let Mt=JSON.parse(Je.data);Mt!=null&&Mt.result?(v({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),f(!1),wt(Mt==null?void 0:Mt.transactionId),se(!0),b(!1)):(b(!1),h((Mt==null?void 0:Mt.message)||"Something went wrong."))}else h("Something went wrong.")})}};if(($==null?void 0:$.paymentGateway)===32){let Ce={method:"POST",redirect:"follow"};try{let X=await Tn.post(`${Ie}api/v1/widget/generate-session`,Ce),ge=Number(d==null?void 0:d.expiryYear)%100,We=d==null?void 0:d.cardNumber;We=We==null?void 0:We.replace(/\s+/g,"");let $t=`${We}=${ge}${d==null?void 0:d.expiryMonth} ${d==null?void 0:d.cvv}`,Je=forge.pki.publicKeyFromPem((Y=(m=X==null?void 0:X.data)==null?void 0:m.data)==null?void 0:Y.publicKeyPem).encrypt($t,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Mt=forge.util.encode64(Je),Sn={"Content-Type":"application/json","x-app-session-key":(W=(fe=X.data)==null?void 0:fe.data)==null?void 0:W.session_key},Lt=JSON.stringify({enc_track2_data:`${Mt}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Pe=(Ne=X==null?void 0:X.data)==null?void 0:Ne.data)==null?void 0:Pe.session_key}`});try{let zt=await Tn.post(`${At}tokenizer/tokenize`,Lt,{headers:Sn}),sn=JSON.stringify(M(_({},(i=zt==null?void 0:zt.data)==null?void 0:i.data),{isSaveCardChecked:l,name:d==null?void 0:d.cardName,postal_code:d==null?void 0:d.zipCode,customer_id:e==null?void 0:e.customerId,partial_amount:Be})),Yn=JSON.stringify({pre_sales_id:`${(o=$==null?void 0:$.orderDetails)==null?void 0:o.orderId}`,token:`${(L=zt==null?void 0:zt.data)==null?void 0:L.data.token}`,json_response:`${sn}`}),Ht={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:Yn,redirect:"follow",isChargeviafractal:!0};mt.emit("sendMessage",Ht),mt.on("chargeviafractalgateway",tn=>{var Ut;if(Cn(tn==null?void 0:tn.data)){let jt=JSON.parse(tn==null?void 0:tn.data);jt!=null&&jt.result?(wt((Ut=jt==null?void 0:jt.data)==null?void 0:Ut.transactionId),se(!0),b(!1)):(b(!1),h((jt==null?void 0:jt.message)||"Something went wrong."))}else h("Something went wrong.")})}catch(zt){b(!1),h(((y=(U=zt==null?void 0:zt.response)==null?void 0:U.data)==null?void 0:y.message)||(zt==null?void 0:zt.message)||"Something went wrong.")}}catch(X){b(!1),h(((ne=(R=X==null?void 0:X.response)==null?void 0:R.data)==null?void 0:ne.message)||(X==null?void 0:X.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken($==null?void 0:$.dctoken,"PaymentForm",ve)}catch(ve){b(!1),h(((ie=(pe=ve==null?void 0:ve.response)==null?void 0:pe.data)==null?void 0:ie.message)||(ve==null?void 0:ve.message)||"Something went wrong.")}}}}else{if(kt())return;{b(!0);let le={fractalpayPublicKey:x,label:(u==null?void 0:u.name)||"John Doe",account_number:u==null?void 0:u.accountNumber,routing_number:u==null?void 0:u.routingNumber,bank_name:u==null?void 0:u.bankName,account_type:u==null?void 0:u.accountType,amount:String(xe||0),isSaveAch:D,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:(u==null?void 0:u.companyName)||""};mt.emit("sendMessage",le),mt.on("ach-incoming",ae=>{var ce;(ae==null?void 0:ae.status)=="Failed"?typeof(ae==null?void 0:ae.message)=="object"?Object.values(ae==null?void 0:ae.message).forEach(me=>{h(me||"Something went wrong")}):h((ae==null?void 0:ae.message)||"Something went wrong"):(wt((ce=ae==null?void 0:ae.data)==null?void 0:ce.transaction_id),se(!0),b(!1))})}}},_t=async()=>{var g,m,Y,fe,W,Ne,Pe,i,o,L,U,y,R,ne,pe,ie,de,le,ae,ce,me,ve,Ce;A();try{let X={fractalpayPublicKey:x,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,orderGuid:e==null?void 0:e.orderGuid},ge=await Tn.post(`${$e}get-payment-details`,X);if(Nt((g=ge==null?void 0:ge.data)==null?void 0:g.data),(Y=(m=ge==null?void 0:ge.data)==null?void 0:m.data)!=null&&Y.paymentGateway||(ye(),h("Something went wrong.")),(W=(fe=ge==null?void 0:ge.data)==null?void 0:fe.data)!=null&&W.card_list&&((i=(Pe=(Ne=ge==null?void 0:ge.data)==null?void 0:Ne.data)==null?void 0:Pe.card_list)==null?void 0:i.length)>0){let We=(U=(L=(o=ge==null?void 0:ge.data)==null?void 0:o.data)==null?void 0:L.card_list)==null?void 0:U.filter(tt=>(tt==null?void 0:tt.card_type)=="Bank"),$t=(ne=(R=(y=ge==null?void 0:ge.data)==null?void 0:y.data)==null?void 0:R.card_list)==null?void 0:ne.filter(tt=>(tt==null?void 0:tt.card_type)!=="Bank");console.log(We,"hohgohoo",$t),($t==null?void 0:$t.length)>0&&te("list"),(We==null?void 0:We.length)>0&&ze("list"),xt($t),nt(We)}else G("card");(ie=(pe=ge==null?void 0:ge.data)==null?void 0:pe.data)!=null&&ie.paymentDeviceList&&((ae=(le=(de=ge==null?void 0:ge.data)==null?void 0:de.data)==null?void 0:le.paymentDeviceList)==null?void 0:ae.length)>0&&Ae((me=(ce=ge==null?void 0:ge.data)==null?void 0:ce.data)==null?void 0:me.paymentDeviceList[0]),q()}catch(X){console.log(X),q(),h(((Ce=(ve=X==null?void 0:X.response)==null?void 0:ve.data)==null?void 0:Ce.message)||(X==null?void 0:X.message)||"Something went wrong")}},Tt=async()=>{let g=e==null?void 0:e.customerId,m=String(e==null?void 0:e.discount),Y=String(e==null?void 0:e.surcharge),fe=String(e==null?void 0:e.tax),W=e==null?void 0:e.merchantPublicKey,Ne=e==null?void 0:e.orderID,Pe=String(Be),i=lt==null?void 0:lt.id,o=lt==null?void 0:lt.card_type;if(W&&Ne&&Pe&&xe)if(g)if(i){let U={amount:o==="Bank"?xe:Pe,order_id:Ne,customer_id:g,card_id:i,fractalpayPublicKey:W,isCardSave:l,discount:m,surcharge:Y,tax:fe},L=U,{isCardSave:y}=L,R=vn(L,["isCardSave"]),pe=$e+(o==="Bank"?"charge-ach":"charge-by-card"),ie={"Content-Type":"application/json"};b(!0),mt.emit("sendMessage",{url:pe,body:o=="Bank"?R:U,isChargebycard:!0}),mt.on("charge-by-card",de=>{var le;(de==null?void 0:de.result)==!0||(de==null?void 0:de.status)==!0?(wt((le=de.data)==null?void 0:le.transaction_id),se(!0),b(!1)):h((de==null?void 0:de.message)||"Something went wrong.")})}else h("Please Select A Card/ACH");else h("Please Select Customer");else h("Something went wrong.")},Zt=async()=>{var W,Ne,Pe,i,o,L;let g=e==null?void 0:e.merchantPublicKey,m=e==null?void 0:e.orderID,Y=String(Be),fe=e==null?void 0:e.customerId;if(!(rt!=null&&rt.device_id)){h("Please Select A Payment Device");return}if(g&&m&&Y){b(!0);let U={amount:Y,fractalpayPublicKey:g,customer_order_id:m,device_id:rt==null?void 0:rt.device_id,customer_id:fe||""};try{let y=await Tn.post(`${$e}charge-with-reader`,U);((W=y==null?void 0:y.data)==null?void 0:W.result)==!0?(wt((Pe=(Ne=y==null?void 0:y.data)==null?void 0:Ne.data)==null?void 0:Pe.transaction_id),se(!0),b(!1)):(h(((i=y==null?void 0:y.data)==null?void 0:i.message)||"Something went wrong."),b(!1))}catch(y){h(((L=(o=y==null?void 0:y.response)==null?void 0:o.data)==null?void 0:L.message)||"Something went wrong."),b(!1)}}else h("Something went wrong.")},qt=()=>{pt==="card"?Tt():pt==="reader"&&Zt()};Qn(()=>{je&&x&&_t()},[x,je]);let Yt=async g=>{qn.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 m=>{if(m.isConfirmed){b(!0);try{let Y={card_id:g,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},fe=await Tn.post(`${$e}delete-customer-card`,Y);b(!1),_t(),qn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(Y){b(!1),qn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else m.dismiss===qn.DismissReason.cancel&&qn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},vt=g=>{switch(g==null?void 0:g.toLowerCase()){case"visa":return Q;case"mastercard":case"mc":case"m/c":return j;case"amex":case"american express":case"ae":return E;case"discover":case"dcvr":return Oe;case"bank":return Ke;default:return g}},Te=()=>{let g=xe||0;return(Number(Be)-g).toFixed(0)};return console.log(Ee,"activeinCard","activeinBank",De),t.createElement(t.Fragment,null,t.createElement(Qt,null),t.createElement(hn,null),t.createElement(bn,null),t.createElement(t.Fragment,null,t.createElement("button",{ref:w,style:{display:"none"},className:"paymentBtn",onClick:Xe},"Pay"),t.createElement(Gt,{open:je,onClose:ye},ee&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(nn,{error:ee,onClose:ye})),Me&&t.createElement(yn,{onClose:ye,tranId:Kt}),!ee&&!Me&&t.createElement(t.Fragment,null,(Fe||N)&&t.createElement(Vt,{loading:Fe||N}),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:ye},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:$==null?void 0:$.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:$==null?void 0:$.logo,id:"pay-logos"})),(ue==null?void 0:ue.length)>0&&Ze!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>G("cardList")}," ",t.createElement(On,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(cn,{label:"Card",amount:(St=Number(Be))==null?void 0:St.toFixed(2),value:"card",onChange:it,activetab:Ze}),($==null?void 0:$.isSkyFiAccount)&&t.createElement(cn,{label:"Bank",amount:(ht=Number(xe))==null?void 0:ht.toFixed(2),value:"ach",onChange:it,activetab:Ze})),xe&&xe>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,Ze==="card"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,Ue((Number(Be)-xe).toFixed(2)))):null)),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:we,alt:""}),t.createElement("img",{src:O,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!Fe&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},Ze!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(ue==null?void 0:ue.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>G("cardList")}," ",t.createElement(On,null)," Back"),($==null?void 0:$.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:g=>{it("card")},style:{border:Ze==="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:g=>{it("ach")},style:{border:Ze==="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"},"$",(Rt=Number(Be))==null?void 0:Rt.toFixed(2))),Ze!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Q,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:j,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:E,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Oe,width:35,alt:""})))),xe&&xe>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",xe)),xe&&xe>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,Ze==="card"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,Ue((Number(Be)-xe).toFixed(2)))):null):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",$==null?void 0:$.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",pt==="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"},"$",(Ve=Number(Be))==null?void 0:Ve.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:j,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:E,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Oe,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:Ze==="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"},(ue==null?void 0:ue.length)>0&&Ee==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>te("list")}," ",t.createElement(On,null)),xe&&xe>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",xe))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),Ze!="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:j,width:33,alt:""}),t.createElement("img",{src:E,alt:"",width:33}),t.createElement("img",{src:Oe,width:33,alt:""}))),Ee==="list"?t.createElement(t.Fragment,null,t.createElement(un,{listHeading:"Cards",paymentGateway:$==null?void 0:$.paymentGateway,ListItems:ue,selectedCard:lt,setSelectedCard:ct,handleDeleteCard:Yt,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{te("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:qt},Ue((Ft=Number(Be))==null?void 0:Ft.toFixed(2))))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:ft},t.createElement("div",{className:"ach-scrl",style:{minHeight:$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)>0?"444px":$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)==0?"456px":(ue==null?void 0:ue.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:(d==null?void 0:d.cardName)||"",onChange:g=>{let m=g.target.value;/^[a-zA-Z\s]*$/.test(m)&&Le("cardName",m)}}),(k==null?void 0:k.cardName)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.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:(d==null?void 0:d.cardNumber)||"",onChange:g=>at(g),"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:(d==null?void 0:d.expiryMonth)||"",onChange:g=>Le("expiryMonth",g.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:(d==null?void 0:d.expiryYear)||"",onChange:g=>Le("expiryYear",g.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:(d==null?void 0:d.cvv)||"",onChange:g=>Le("cvv",g.target.value)})))),(k==null?void 0:k.cardNumber)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.cardNumber),t.createElement("p",{style:{margin:"0"}},k!=null&&k.expiryMonth||k!=null&&k.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},k==null?void 0:k.expiryMonth):"",(k==null?void 0:k.cvv)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.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:(Pt=e==null?void 0:e.orderID)!=null?Pt:"",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:(et=d==null?void 0:d.zipCode)!=null?et:"",onChange:g=>Le("zipCode",g.target.value)}),(k==null?void 0:k.zipCode)&&t.createElement("span",{className:"error-span"},k==null?void 0:k.zipCode)),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},t.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:l,onChange:g=>f(g.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"}},($==null?void 0:$.paymentDeviceList)&&((ot=$==null?void 0:$.paymentDeviceList)==null?void 0:ot.length)>0&&t.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>z(!Ct)},Ct?"Pay With Reader":"Pay With Card"),t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ue((en=Number(Be))==null?void 0:en.toFixed(2)))))),t.createElement("div",{id:"ach",style:{display:Ze==="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"},(Re==null?void 0:Re.length)>0&&De==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ze("list")}," ",t.createElement(On,null)),xe&&xe>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),t.createElement("div",null,"$",Te()))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),De==="list"?t.createElement(t.Fragment,null,t.createElement(un,{listHeading:"Banks",paymentGateway:$==null?void 0:$.paymentGateway,ListItems:Re,selectedCard:lt,setSelectedCard:ct,handleDeleteCard:Yt,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{ze("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:qt},Ue((Et=Number(xe))==null?void 0:Et.toFixed(2))))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:ft},t.createElement("div",{className:"ach-scrl",style:{minHeight:$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)>0?"444px":$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)==0?"436px":(ue==null?void 0:ue.length)>0?"462px":"520px",maxHeight:$!=null&&$.isSkyFiAccount&&(ue==null?void 0:ue.length)>0?"444px":((ue==null?void 0:ue.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:(on=u==null?void 0:u.name)!=null?on:"",onChange:be}),(K==null?void 0:K.name)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(yt=u==null?void 0:u.routingNumber)!=null?yt:"",onChange:be}),(K==null?void 0:K.routingNumber)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(Xt=u==null?void 0:u.accountNumber)!=null?Xt:"",onChange:be}),(K==null?void 0:K.accountNumber)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(rn=u==null?void 0:u.confirmAccountNumber)!=null?rn:"",onChange:be}),(K==null?void 0:K.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(I=u==null?void 0:u.bankName)!=null?I:"",onChange:be}),(K==null?void 0:K.bankName)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.bankName)),((u==null?void 0:u.accountType)==="business saving"||(u==null?void 0:u.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:(p=u==null?void 0:u.companyName)!=null?p:"",onChange:be}),(K==null?void 0:K.companyName)&&t.createElement("span",{className:"error-span"},K==null?void 0:K.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:(J=u==null?void 0:u.accountType)!=null?J:"",onChange:be},t.createElement("option",{value:""},"Select account"),Nn.map(g=>t.createElement("option",{key:g.value,value:g.value},g.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:D,onChange:g=>F(g.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),D&&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"},Ue((He=Number(xe))==null?void 0:He.toFixed(2))))))))))))))))}export{Qi as AddCard,Ri as CardOnFile,Zi as GetPaymentPage,oa as PartialPayment,ia as PaymentWidget,Ei as PreAuthPayment,Fi as RequestPayment,zi as RequestPreAuthPayment};