@fractalpay/fractalpay-next-dev 0.0.21 → 0.0.23

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
@@ -575,7 +575,7 @@ var mw=Object.defineProperty,bw=Object.defineProperties;var pw=Object.getOwnProp
575
575
 
576
576
  font-size: 12px;
577
577
  }
578
- `),_B=Nw;function Tw(A){let a=A.merchantPublicKey,x=A==null?void 0:A.discount,T=A==null?void 0:A.tax,b=A==null?void 0:A.surcharge,[nA,f]=fB(!1),[yA,DA]=fB(!1),[D,I]=fB({}),[n,e]=fB(null),[O,rA]=fB({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),[QA,H]=fB(""),[eA,P]=fB(!1),[fA,$]=fB(null),lA=c=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(c),o=/[+-]?([0-9]*[.])?[0-9]+/,uA=c=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c),s=c=>/^[A-Za-z\s]*$/.test(c),NA=()=>{f(!1),I({})},z=()=>f(!0),u=()=>{console.log(fA,"apiresponse"),E(fA),P(!1)};function w(){rA({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),H("")}function E(c){let h={type:"preview.compiledcheck",other:p(m({},c),{status:!0})};window.parent.postMessage(h,"*")}let Y=async()=>{if(!(Object.keys(D).length>0)){if(I({}),!(O!=null&&O.email)&&n&&!lA(n)){I(c=>p(m({},c),{phone:aA.phonenumbervalid}));return}if(j())try{DA(!0);let c={fractalpayPublicKey:a,amount:QA,phone_number:n,order_id:O.order_id,action:"request",name:O.name,email:O.email,customer_id:A!=null&&A.customerId?A==null?void 0:A.customerId:"",discount:x,surcharge:b,tax:T,require_3ds:A==null?void 0:A.require_3ds},h=await jw.post(`${HA}create-widget-order`,c);(h==null?void 0:h.status)===200&&(P(!0),f(!1),w(),$(h==null?void 0:h.data)),DA(!1)}catch(c){console.log(c),DA(!1)}}},y=HA+"images/logo-img.png",l=c=>{let{value:h}=c.target,v=c.target.dataset.token;if(rA(p(m({},O),{[v]:h})),v==="name"&&!s(h)){I(PA=>p(m({},PA),{[v]:aA.onlylettersallowed}));return}let K=D;v==="email"&&!n&&(delete K.phone,I(K)),h&&(delete K[v],I(K)),v==="email"&&!h&&(delete K[v],I(K))},Z=c=>{let{value:h}=c;if(Number(h)>0){let v=D;delete v.amount,I(v)}H(h)},j=()=>{let c={};return QA||(c.amount=aA.amountrequired),O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),!n&&!(O!=null&&O.email)&&(c.phone=aA.phoneoremailrequired),!n&&!(O!=null&&O.email)&&(c.email=aA.phoneoremailrequired),!n&&O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),A.from==="merchant"&&!O.order_id&&(c.order_id=aA.orderidrequired),I(c),Object.keys(c).length===0};Sw(()=>{A&&(rA(c=>p(m({},c),{order_id:A.orderID?A.orderID:"",name:A!=null&&A.name?A==null?void 0:A.name:"",email:A!=null&&A.email?A==null?void 0:A.email:""})),H(A.amount?A.amount:""),e(A.phone?`${A.phone}`:null))},[A]);let V=c=>{let h=c==null?void 0:c.value;if(h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.length)!==10){I(K=>p(m({},K),{phone:aA.phonenumberlength})),e(h);return}else e(h);let v=D;delete v.phone,h&&!(O!=null&&O.email)&&delete v.email,I(v)};function g(c){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(c))}return i.createElement(i.Fragment,null,i.createElement(_B,null),i.createElement(AB,{loading:yA}),i.createElement(i.Fragment,null,i.createElement("button",{className:"paymentBtn",onClick:z},"Request Payment"),i.createElement(HB,{open:nA,onClose:()=>f(!1),maxWidth:"500px"},i.createElement("div",{style:{maxWidth:"500px"}},i.createElement("div",{className:"request-payment-amount-detail frac-form"},i.createElement("p",{className:"request-payment-merchantname"},"Pay ",A==null?void 0:A.webname),i.createElement("p",{className:"request-payment-amount"},g(A==null?void 0:A.amount)),(A==null?void 0:A.from)==="merchant"&&i.createElement("p",{className:"request-payment-orderid"},O==null?void 0:O.order_id),i.createElement("span",{className:"request-payment-close-popup",onClick:NA},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("g",{clipPath:"url(#clip0_12425_52336)"},i.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"})),i.createElement("defs",null,i.createElement("clipPath",{id:"clip0_12425_52336"},i.createElement("rect",{width:"16",height:"16",fill:"white"})))))),i.createElement("form",{className:"request-payment-input-form"},i.createElement("div",{className:"request-payment-list-div"},i.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),i.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:l,value:O==null?void 0:O.name}),D.name&&i.createElement("small",{className:"request-payment-error-msg"},D.name)),i.createElement("div",{className:"request-payment-list-div"},i.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),i.createElement(Jw,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:n,onValueChange:c=>{V(c)}}),D.phone&&i.createElement("small",{className:"request-payment-error-msg"},D.phone)),i.createElement("div",{className:"request-payment-list-div"},i.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),i.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:l,"data-token":"email",value:O==null?void 0:O.email}),D.email&&i.createElement("small",{className:"request-payment-error-msg"},D.email)),i.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:Y,disabled:yA},yA?"Loading...":"Send Request"),i.createElement("div",{className:"request-payment-fractal-powerd-by"},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},i.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",i.createElement("span",null,"Fractal"),i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},i.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),i.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),i.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),i.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),i.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),i.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),i.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),i.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),i.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),i.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),i.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),i.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),i.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),i.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),i.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),i.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),i.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),i.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"})))))),i.createElement(HB,{open:eA,onClose:u,maxWidth:"500px"},i.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},i.createElement("div",{className:"request-payment-success-container"},i.createElement("span",{className:"request-payment-close-popup",onClick:u},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("g",{clipPath:"url(#clip0_12425_52336)"},i.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"})),i.createElement("defs",null,i.createElement("clipPath",{id:"clip0_12425_52336"},i.createElement("rect",{width:"16",height:"16",fill:"white"}))))),i.createElement("div",{className:"request-payment-success-tick-div"},i.createElement("div",{className:"request-payment-success-tick"},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),i.createElement("h6",{className:"request-payment-success-text"},"The request ",i.createElement("br",null),"was sent"),i.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),i.createElement("div",{className:"request-payment-success-btn-div"},i.createElement("button",{onClick:u,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import r,{useState as lB,useEffect as Fw}from"react";import Vw from"axios";import{PatternFormat as Zw}from"react-number-format";function Ww(A){let a=A.merchantPublicKey,x=A==null?void 0:A.discount,T=A==null?void 0:A.tax,b=A==null?void 0:A.surcharge,[nA,f]=lB(!1),[yA,DA]=lB(!1),[D,I]=lB({}),[n,e]=lB(null),[O,rA]=lB({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),[QA,H]=lB(""),[eA,P]=lB(!1),[fA,$]=lB(null),lA=c=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(c),o=/[+-]?([0-9]*[.])?[0-9]+/,uA=c=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c),s=c=>/^[A-Za-z\s]*$/.test(c),NA=()=>{f(!1),I({})},z=()=>f(!0),u=()=>{console.log(fA,"apiresponse"),E(fA),P(!1)};function w(){rA({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),H("")}function E(c){let h={type:"preview.compiledcheck",other:p(m({},c),{status:!0})};window.parent.postMessage(h,"*")}let Y=async()=>{if(!(Object.keys(D).length>0)){if(I({}),!(O!=null&&O.email)&&n&&!lA(n)){I(c=>p(m({},c),{phone:aA.phonenumbervalid}));return}if(j())try{DA(!0);let c={fractalpayPublicKey:a,amount:QA,phone_number:n,order_id:O.order_id,action:"request",name:O.name,email:O.email,customer_id:A!=null&&A.customerId?A==null?void 0:A.customerId:"",discount:x,surcharge:b,tax:T,require_3ds:A==null?void 0:A.require_3ds},h=await Vw.post(`${HA}send-request-pre-auth-payment`,c);(h==null?void 0:h.status)===200&&(P(!0),f(!1),w(),$(h==null?void 0:h.data)),DA(!1)}catch(c){console.log(c),DA(!1)}}},y=HA+"images/logo-img.png",l=c=>{let{value:h}=c.target,v=c.target.dataset.token;if(rA(p(m({},O),{[v]:h})),v==="name"&&!s(h)){I(PA=>p(m({},PA),{[v]:aA.onlylettersallowed}));return}let K=D;v==="email"&&!n&&(delete K.phone,I(K)),h&&(delete K[v],I(K)),v==="email"&&!h&&(delete K[v],I(K))},Z=c=>{let{value:h}=c;if(Number(h)>0){let v=D;delete v.amount,I(v)}H(h)},j=()=>{let c={};return QA||(c.amount=aA.amountrequired),O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),!n&&!(O!=null&&O.email)&&(c.phone=aA.phoneoremailrequired),!n&&!(O!=null&&O.email)&&(c.email=aA.phoneoremailrequired),!n&&O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),A.from==="merchant"&&!O.order_id&&(c.order_id=aA.orderidrequired),I(c),Object.keys(c).length===0};Fw(()=>{A&&(rA(c=>p(m({},c),{order_id:A.orderID?A.orderID:"",name:A!=null&&A.name?A==null?void 0:A.name:"",email:A!=null&&A.email?A==null?void 0:A.email:""})),H(A.amount?A.amount:""),e(A.phone?`${A.phone}`:null))},[A]);let V=c=>{let h=c==null?void 0:c.value;if(h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.length)!==10){I(K=>p(m({},K),{phone:aA.phonenumberlength})),e(h);return}else e(h);let v=D;delete v.phone,h&&!(O!=null&&O.email)&&delete v.email,I(v)};function g(c){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(c))}return r.createElement(r.Fragment,null,r.createElement(_B,null),r.createElement(AB,{loading:yA}),r.createElement(r.Fragment,null,r.createElement("button",{className:"paymentBtn",onClick:z},"Send Request"),r.createElement("div",{className:"frac-form"},r.createElement(HB,{open:nA,onClose:()=>f(!1),maxWidth:"500px"},r.createElement("div",{className:"request-payment-amount-detail"},r.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),r.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",A==null?void 0:A.webname),r.createElement("p",{className:"request-payment-amount"},g(A==null?void 0:A.amount)),(A==null?void 0:A.from)==="merchant"&&r.createElement("p",{className:"request-payment-orderid"},O==null?void 0:O.order_id),r.createElement("span",{className:"request-payment-close-popup",onClick:NA},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("form",{className:"request-payment-input-form"},r.createElement("div",{className:"request-payment-list-div"},r.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),r.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:l,value:O==null?void 0:O.name}),D.name&&r.createElement("small",{className:"request-payment-error-msg"},D.name)),r.createElement("div",{className:"request-payment-list-div"},r.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),r.createElement(Zw,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:n,onValueChange:c=>{V(c)}}),D.phone&&r.createElement("small",{className:"request-payment-error-msg"},D.phone)),r.createElement("div",{className:"request-payment-list-div"},r.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),r.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:l,"data-token":"email",value:O==null?void 0:O.email}),D.email&&r.createElement("small",{className:"request-payment-error-msg"},D.email)),r.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:Y,disabled:yA},yA?"Loading...":"Send Request"),r.createElement("div",{className:"request-payment-fractal-powerd-by"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},r.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",r.createElement("span",null,"Fractal"),r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},r.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),r.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),r.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),r.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),r.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),r.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),r.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),r.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),r.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),r.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),r.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),r.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),r.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),r.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),r.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),r.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),r.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),r.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"}))))),r.createElement(HB,{open:eA,onClose:u,maxWidth:"500px"},r.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},r.createElement("div",{className:"request-payment-success-container"},r.createElement("span",{className:"request-payment-close-popup",onClick:u},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:"request-payment-success-tick-div"},r.createElement("div",{className:"request-payment-success-tick"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},r.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),r.createElement("h6",{className:"request-payment-success-text"},"The request ",r.createElement("br",null),"was sent"),r.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),r.createElement("div",{className:"request-payment-success-btn-div"},r.createElement("button",{onClick:u,className:"request-payment-success-btn2"},"Close"))))))))}import B,{useEffect as EC,useState as bA}from"react";import Kw from"react";function JB(){let A="#000",a="#fff",x="#212529",T="#dee2e6";return Kw.createElement("style",null,`
578
+ `),_B=Nw;function Tw(A){let a=A.merchantPublicKey,x=A==null?void 0:A.discount,T=A==null?void 0:A.tax,b=A==null?void 0:A.surcharge,[nA,f]=fB(!1),[yA,DA]=fB(!1),[D,I]=fB({}),[n,e]=fB(null),[O,rA]=fB({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),[QA,H]=fB(""),[eA,P]=fB(!1),[fA,R]=fB(null),lA=c=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(c),o=/[+-]?([0-9]*[.])?[0-9]+/,uA=c=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c),s=c=>/^[A-Za-z\s]*$/.test(c),NA=()=>{f(!1),I({})},z=()=>f(!0),u=()=>{console.log(fA,"apiresponse"),E(fA),P(!1)};function w(){rA({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),H("")}function E(c){let h={type:"preview.compiledcheck",other:p(m({},c),{status:!0})};window.parent.postMessage(h,"*")}let Y=async()=>{if(!(Object.keys(D).length>0)){if(I({}),!(O!=null&&O.email)&&n&&!lA(n)){I(c=>p(m({},c),{phone:aA.phonenumbervalid}));return}if(j())try{DA(!0);let c={fractalpayPublicKey:a,amount:QA,phone_number:n,order_id:O.order_id,action:"request",name:O.name,email:O.email,customer_id:A!=null&&A.customerId?A==null?void 0:A.customerId:"",discount:x,surcharge:b,tax:T,require_3ds:A==null?void 0:A.require_3ds},h=await jw.post(`${HA}create-widget-order`,c);(h==null?void 0:h.status)===200&&(P(!0),f(!1),w(),R(h==null?void 0:h.data)),DA(!1)}catch(c){console.log(c),DA(!1)}}},y=HA+"images/logo-img.png",l=c=>{let{value:h}=c.target,v=c.target.dataset.token;if(rA(p(m({},O),{[v]:h})),v==="name"&&!s(h)){I(PA=>p(m({},PA),{[v]:aA.onlylettersallowed}));return}let K=D;v==="email"&&!n&&(delete K.phone,I(K)),h&&(delete K[v],I(K)),v==="email"&&!h&&(delete K[v],I(K))},Z=c=>{let{value:h}=c;if(Number(h)>0){let v=D;delete v.amount,I(v)}H(h)},j=()=>{let c={};return QA||(c.amount=aA.amountrequired),O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),!n&&!(O!=null&&O.email)&&(c.phone=aA.phoneoremailrequired),!n&&!(O!=null&&O.email)&&(c.email=aA.phoneoremailrequired),!n&&O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),A.from==="merchant"&&!O.order_id&&(c.order_id=aA.orderidrequired),I(c),Object.keys(c).length===0};Sw(()=>{A&&(rA(c=>p(m({},c),{order_id:A.orderID?A.orderID:"",name:A!=null&&A.name?A==null?void 0:A.name:"",email:A!=null&&A.email?A==null?void 0:A.email:""})),H(A.amount?A.amount:""),e(A.phone?`${A.phone}`:null))},[A]);let V=c=>{let h=c==null?void 0:c.value;if(h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.length)!==10){I(K=>p(m({},K),{phone:aA.phonenumberlength})),e(h);return}else e(h);let v=D;delete v.phone,h&&!(O!=null&&O.email)&&delete v.email,I(v)};function g(c){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(c))}return i.createElement(i.Fragment,null,i.createElement(_B,null),i.createElement(AB,{loading:yA}),i.createElement(i.Fragment,null,i.createElement("button",{className:"paymentBtn",onClick:z},"Request Payment"),i.createElement(HB,{open:nA,onClose:()=>f(!1),maxWidth:"500px"},i.createElement("div",{style:{maxWidth:"500px"}},i.createElement("div",{className:"request-payment-amount-detail frac-form"},i.createElement("p",{className:"request-payment-merchantname"},"Pay ",A==null?void 0:A.webname),i.createElement("p",{className:"request-payment-amount"},g(A==null?void 0:A.amount)),(A==null?void 0:A.from)==="merchant"&&i.createElement("p",{className:"request-payment-orderid"},O==null?void 0:O.order_id),i.createElement("span",{className:"request-payment-close-popup",onClick:NA},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("g",{clipPath:"url(#clip0_12425_52336)"},i.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"})),i.createElement("defs",null,i.createElement("clipPath",{id:"clip0_12425_52336"},i.createElement("rect",{width:"16",height:"16",fill:"white"})))))),i.createElement("form",{className:"request-payment-input-form"},i.createElement("div",{className:"request-payment-list-div"},i.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),i.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:l,value:O==null?void 0:O.name}),D.name&&i.createElement("small",{className:"request-payment-error-msg"},D.name)),i.createElement("div",{className:"request-payment-list-div"},i.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),i.createElement(Jw,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:n,onValueChange:c=>{V(c)}}),D.phone&&i.createElement("small",{className:"request-payment-error-msg"},D.phone)),i.createElement("div",{className:"request-payment-list-div"},i.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),i.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:l,"data-token":"email",value:O==null?void 0:O.email}),D.email&&i.createElement("small",{className:"request-payment-error-msg"},D.email)),i.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:Y,disabled:yA},yA?"Loading...":"Send Request"),i.createElement("div",{className:"request-payment-fractal-powerd-by"},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},i.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",i.createElement("span",null,"Fractal"),i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},i.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),i.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),i.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),i.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),i.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),i.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),i.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),i.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),i.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),i.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),i.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),i.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),i.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),i.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),i.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),i.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),i.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),i.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"})))))),i.createElement(HB,{open:eA,onClose:u,maxWidth:"500px"},i.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},i.createElement("div",{className:"request-payment-success-container"},i.createElement("span",{className:"request-payment-close-popup",onClick:u},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("g",{clipPath:"url(#clip0_12425_52336)"},i.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"})),i.createElement("defs",null,i.createElement("clipPath",{id:"clip0_12425_52336"},i.createElement("rect",{width:"16",height:"16",fill:"white"}))))),i.createElement("div",{className:"request-payment-success-tick-div"},i.createElement("div",{className:"request-payment-success-tick"},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),i.createElement("h6",{className:"request-payment-success-text"},"The request ",i.createElement("br",null),"was sent"),i.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),i.createElement("div",{className:"request-payment-success-btn-div"},i.createElement("button",{onClick:u,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import r,{useState as lB,useEffect as Fw}from"react";import Vw from"axios";import{PatternFormat as Zw}from"react-number-format";function Ww(A){let a=A.merchantPublicKey,x=A==null?void 0:A.discount,T=A==null?void 0:A.tax,b=A==null?void 0:A.surcharge,[nA,f]=lB(!1),[yA,DA]=lB(!1),[D,I]=lB({}),[n,e]=lB(null),[O,rA]=lB({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),[QA,H]=lB(""),[eA,P]=lB(!1),[fA,R]=lB(null),lA=c=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(c),o=/[+-]?([0-9]*[.])?[0-9]+/,uA=c=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c),s=c=>/^[A-Za-z\s]*$/.test(c),NA=()=>{f(!1),I({})},z=()=>f(!0),u=()=>{console.log(fA,"apiresponse"),E(fA),P(!1)};function w(){rA({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:a}),H("")}function E(c){let h={type:"preview.compiledcheck",other:p(m({},c),{status:!0})};window.parent.postMessage(h,"*")}let Y=async()=>{if(!(Object.keys(D).length>0)){if(I({}),!(O!=null&&O.email)&&n&&!lA(n)){I(c=>p(m({},c),{phone:aA.phonenumbervalid}));return}if(j())try{DA(!0);let c={fractalpayPublicKey:a,amount:QA,phone_number:n,order_id:O.order_id,action:"request",name:O.name,email:O.email,customer_id:A!=null&&A.customerId?A==null?void 0:A.customerId:"",discount:x,surcharge:b,tax:T,require_3ds:A==null?void 0:A.require_3ds},h=await Vw.post(`${HA}send-request-pre-auth-payment`,c);(h==null?void 0:h.status)===200&&(P(!0),f(!1),w(),R(h==null?void 0:h.data)),DA(!1)}catch(c){console.log(c),DA(!1)}}},y=HA+"images/logo-img.png",l=c=>{let{value:h}=c.target,v=c.target.dataset.token;if(rA(p(m({},O),{[v]:h})),v==="name"&&!s(h)){I(PA=>p(m({},PA),{[v]:aA.onlylettersallowed}));return}let K=D;v==="email"&&!n&&(delete K.phone,I(K)),h&&(delete K[v],I(K)),v==="email"&&!h&&(delete K[v],I(K))},Z=c=>{let{value:h}=c;if(Number(h)>0){let v=D;delete v.amount,I(v)}H(h)},j=()=>{let c={};return QA||(c.amount=aA.amountrequired),O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),!n&&!(O!=null&&O.email)&&(c.phone=aA.phoneoremailrequired),!n&&!(O!=null&&O.email)&&(c.email=aA.phoneoremailrequired),!n&&O.email&&!uA(O==null?void 0:O.email)&&(c.email=aA.invalidemail),A.from==="merchant"&&!O.order_id&&(c.order_id=aA.orderidrequired),I(c),Object.keys(c).length===0};Fw(()=>{A&&(rA(c=>p(m({},c),{order_id:A.orderID?A.orderID:"",name:A!=null&&A.name?A==null?void 0:A.name:"",email:A!=null&&A.email?A==null?void 0:A.email:""})),H(A.amount?A.amount:""),e(A.phone?`${A.phone}`:null))},[A]);let V=c=>{let h=c==null?void 0:c.value;if(h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.length)!==10){I(K=>p(m({},K),{phone:aA.phonenumberlength})),e(h);return}else e(h);let v=D;delete v.phone,h&&!(O!=null&&O.email)&&delete v.email,I(v)};function g(c){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(c))}return r.createElement(r.Fragment,null,r.createElement(_B,null),r.createElement(AB,{loading:yA}),r.createElement(r.Fragment,null,r.createElement("button",{className:"paymentBtn",onClick:z},"Send Request"),r.createElement("div",{className:"frac-form"},r.createElement(HB,{open:nA,onClose:()=>f(!1),maxWidth:"500px"},r.createElement("div",{className:"request-payment-amount-detail"},r.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),r.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",A==null?void 0:A.webname),r.createElement("p",{className:"request-payment-amount"},g(A==null?void 0:A.amount)),(A==null?void 0:A.from)==="merchant"&&r.createElement("p",{className:"request-payment-orderid"},O==null?void 0:O.order_id),r.createElement("span",{className:"request-payment-close-popup",onClick:NA},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("form",{className:"request-payment-input-form"},r.createElement("div",{className:"request-payment-list-div"},r.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),r.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:l,value:O==null?void 0:O.name}),D.name&&r.createElement("small",{className:"request-payment-error-msg"},D.name)),r.createElement("div",{className:"request-payment-list-div"},r.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),r.createElement(Zw,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:n,onValueChange:c=>{V(c)}}),D.phone&&r.createElement("small",{className:"request-payment-error-msg"},D.phone)),r.createElement("div",{className:"request-payment-list-div"},r.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),r.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:l,"data-token":"email",value:O==null?void 0:O.email}),D.email&&r.createElement("small",{className:"request-payment-error-msg"},D.email)),r.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:Y,disabled:yA},yA?"Loading...":"Send Request"),r.createElement("div",{className:"request-payment-fractal-powerd-by"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},r.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",r.createElement("span",null,"Fractal"),r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},r.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),r.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),r.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),r.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),r.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),r.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),r.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),r.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),r.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),r.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),r.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),r.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),r.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),r.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),r.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),r.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),r.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),r.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"}))))),r.createElement(HB,{open:eA,onClose:u,maxWidth:"500px"},r.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},r.createElement("div",{className:"request-payment-success-container"},r.createElement("span",{className:"request-payment-close-popup",onClick:u},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:"request-payment-success-tick-div"},r.createElement("div",{className:"request-payment-success-tick"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},r.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),r.createElement("h6",{className:"request-payment-success-text"},"The request ",r.createElement("br",null),"was sent"),r.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),r.createElement("div",{className:"request-payment-success-btn-div"},r.createElement("button",{onClick:u,className:"request-payment-success-btn2"},"Close"))))))))}import B,{useEffect as cC,useState as bA}from"react";import Kw from"react";function JB(){let A="#000",a="#fff",x="#212529",T="#dee2e6";return Kw.createElement("style",null,`
579
579
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
580
580
  body
581
581
  {
@@ -1469,7 +1469,7 @@ var mw=Object.defineProperty,bw=Object.defineProperties;var pw=Object.getOwnProp
1469
1469
  padding:10px 17px;
1470
1470
  cursor:pointer;
1471
1471
  }
1472
- `)}var Rw=({onClose:A,error:a})=>UA.createElement(UA.Fragment,null,UA.createElement(Mw,null),UA.createElement("div",{className:"card-error"},UA.createElement("div",{className:"payment-error-container"},UA.createElement("div",{className:"error-icon"},UA.createElement("div",{className:"circle"},UA.createElement("i",{className:"fa fa-times","aria-hidden":"true"})),UA.createElement("div",{className:"error-text"},UA.createElement("div",{className:"payment-error-text"},a),UA.createElement("div",{className:"thank-you-text"},"Try again later ")),UA.createElement("div",{className:"error-btn-div"},UA.createElement("button",{onClick:A},"OK")))))),vB=Rw;import{io as _w}from"socket.io-client";var $w=_w(HA,{transports:["websocket"],withCredentials:!1}),ZA=$w;var Dw=A=>{try{let a=JSON.parse(A);return typeof a=="object"&&a!==null}catch(a){return!1}};var $B=()=>React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,x:0,y:0,viewBox:"0 0 512 512",style:{enableBackground:"new 0 0 512 512"},xmlSpace:"preserve"},React.createElement("g",null,React.createElement("path",{d:"M201.548 388.647h-29.367a12.33 12.33 0 0 0-12.316 12.316v17.178a12.33 12.33 0 0 0 12.316 12.317h29.367a12.331 12.331 0 0 0 12.317-12.317v-17.178a12.331 12.331 0 0 0-12.317-12.316Zm-3.7 25.8H175.88v-9.78h21.969ZM339.822 279.91h-29.367a12.317 12.317 0 0 0-12.317 12.29v17.2a12.331 12.331 0 0 0 12.317 12.316h29.367A12.316 12.316 0 0 0 352.11 309.4v-17.2a12.3 12.3 0 0 0-12.288-12.29Zm-3.728 25.8h-21.94v-9.781h21.94Zm-148.635-41.84h137.056a21.2 21.2 0 0 0 21.189-21.16V162.8a21.213 21.213 0 0 0-21.189-21.189H187.459a21.212 21.212 0 0 0-21.188 21.189v79.909a21.2 21.2 0 0 0 21.188 21.157Zm-5.172-101.07a5.242 5.242 0 0 1 5.172-5.173h137.056a5.178 5.178 0 0 1 5.173 5.173v79.909a5.228 5.228 0 0 1-5.173 5.145H187.459a5.228 5.228 0 0 1-5.172-5.145Zm88.4 117.113h-29.369A12.317 12.317 0 0 0 229 292.2v17.2a12.331 12.331 0 0 0 12.317 12.316h29.367a12.316 12.316 0 0 0 12.289-12.316v-17.2a12.3 12.3 0 0 0-12.288-12.29Zm-3.727 25.8h-21.943v-9.781h21.941Zm116.272-200.859a56.72 56.72 0 0 0-41-17.671h-9.708V8a8.008 8.008 0 0 0-8.008-8.008H208.068A28.634 28.634 0 0 0 179.48 28.6v58.583h-9.708a56.737 56.737 0 0 0-41.038 17.7 50.926 50.926 0 0 0-14.269 38.056l17.207 314.2a59.707 59.707 0 0 0 16.716 38.56 53.673 53.673 0 0 0 38.618 16.313H325a53.658 53.658 0 0 0 38.6-16.312 59.621 59.621 0 0 0 16.7-38.567l17.235-314.194a51.011 51.011 0 0 0-14.303-38.085ZM195.5 28.6A12.6 12.6 0 0 1 208.068 16h108.439v95.869H195.5Zm186.045 113.462-17.234 314.2C363.076 478.912 346.174 496 325 496H187.006c-21.169 0-38.083-17.088-39.342-39.741l-17.207-314.2a35.063 35.063 0 0 1 9.912-26.167 40.653 40.653 0 0 1 29.4-12.691h9.708v8.675h-6.789a8.008 8.008 0 1 0 0 16.015h166.596a8.008 8.008 0 1 0 0-16.015h-6.761V103.2h9.708a40.631 40.631 0 0 1 29.369 12.666 35.133 35.133 0 0 1 9.945 26.196Zm-41.723 246.585h-29.367a12.331 12.331 0 0 0-12.317 12.316v17.178a12.331 12.331 0 0 0 12.317 12.317h29.367a12.317 12.317 0 0 0 12.288-12.317v-17.178a12.316 12.316 0 0 0-12.288-12.316Zm-3.728 25.8h-21.94v-9.78h21.94Zm-65.409-25.8h-29.367A12.331 12.331 0 0 0 229 400.963v17.178a12.331 12.331 0 0 0 12.317 12.317h29.367a12.317 12.317 0 0 0 12.288-12.317v-17.178a12.316 12.316 0 0 0-12.287-12.316Zm-3.727 25.8h-21.941v-9.78h21.941Zm3.727-80.164h-29.367A12.331 12.331 0 0 0 229 346.6v17.178a12.331 12.331 0 0 0 12.317 12.316h29.367a12.316 12.316 0 0 0 12.288-12.316V346.6a12.316 12.316 0 0 0-12.287-12.321Zm-3.727 25.8h-21.941v-9.78h21.941Zm-65.41-25.8h-29.367a12.33 12.33 0 0 0-12.316 12.317v17.178a12.33 12.33 0 0 0 12.316 12.316h29.367a12.331 12.331 0 0 0 12.317-12.316V346.6a12.331 12.331 0 0 0-12.317-12.321Zm-3.7 25.8H175.88v-9.78h21.969Zm141.973-25.8h-29.366a12.331 12.331 0 0 0-12.317 12.317v17.178a12.331 12.331 0 0 0 12.317 12.316h29.367a12.316 12.316 0 0 0 12.288-12.316V346.6a12.316 12.316 0 0 0-12.288-12.321Zm-3.728 25.8h-21.94v-9.78h21.94ZM201.548 279.91h-29.367a12.316 12.316 0 0 0-12.316 12.29v17.2a12.33 12.33 0 0 0 12.316 12.316h29.367a12.331 12.331 0 0 0 12.317-12.316v-17.2a12.317 12.317 0 0 0-12.317-12.29Zm-3.7 25.8H175.88v-9.781h21.969ZM212.277 76.4a8.008 8.008 0 0 1 8.008-8.008h71.433a8.008 8.008 0 0 1 0 16.016h-71.433a8.008 8.008 0 0 1-8.008-8.008Zm0-35.348a8.008 8.008 0 0 1 8.008-8.008h71.433a8.008 8.008 0 0 1 0 16.016h-71.433a8.008 8.008 0 0 1-8.008-8.011Z",fill:"#35254d",opacity:1,"data-original":"#35254d"})));var hB="./mc-img-DOAGH63G.svg";var eB="./visa-img-FX6P7OM3.svg";var YB="./ae-img-YGFM7U63.svg";var GB="./discover-img-4LBHC4QG.svg";var FB="./card-OY3NFHAU.svg";var Aw="./Trash-CXFDX4J7.svg";var Bw="./bank-ORJOWIKR.svg";var ww="./secure-img-4G7PSDVG.png";var Cw="./pov-by-MFWC23HA.png";function cC(A){var q,sA,gA,MA,zA,SA,wA,BB,wB,CB,kA,U,_A,gB,mB,dA,bB,MB,tA,vA,zB,nB,kB,FA,pB;let[a,x]=bA(!1),[T,b]=bA(!1),[nA,f]=bA(""),[yA,DA]=bA(!1),[D,I]=bA(!1),[n,e]=bA("card"),[O,rA]=bA("card"),[QA,H]=bA(!0),[eA,P]=bA(!1),[fA,$]=bA(!1),lA=A.merchantPublicKey,[o,uA]=bA(),[s,NA]=bA({}),[z,u]=bA(),[w,E]=bA({}),[Y,y]=bA([]),[l,Z]=bA(),[j,V]=bA(),[g,c]=bA(),[h,v]=bA(""),K=()=>x(!0),PA=()=>x(!1),WA=()=>{I(!1),e("card"),f(""),DA(!1),v(""),u({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),E({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),uA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),NA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),$(!1),P(!1),Z({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),V({}),rA("card"),H(!0)},dB=()=>I(!0),cB=Q=>{e(Q)},KA=(Q,M)=>{let N=Q;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(N)){(M===""||/^[0-9]+$/.test(M))&&(NA(k=>p(m({},k),{[N]:""})),uA(k=>p(m({},k),{[N]:M})));return}NA(k=>p(m({},k),{[N]:""})),uA(k=>p(m({},k),{[N]:M}))},tB=Q=>{let N=Q.target.value.replace(/\D/g,""),L="";/^3[47]/.test(N)?L=N.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(oA,cA,W,EA)=>[cA,W,EA].filter(Boolean).join(" ")):L=N.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(oA,cA,W,EA,mA)=>[cA,W,EA,mA].filter(Boolean).join(" ")),NA(k=>p(m({},k),{cardNumber:""})),uA(k=>p(m({},k),{cardNumber:L}))},TA=Q=>{let{name:M,value:N}=Q.target,L=["routingNumber","accountNumber","confirmAccountNumber"];if(M=="name"){/^[a-zA-Z\s]*$/.test(N)&&(E(k=>p(m({},k),{[M]:""})),u(k=>p(m({},k),{[M]:N})));return}if(L.includes(M)){(N===""||/^[0-9]+$/.test(N))&&(E(k=>p(m({},k),{[M]:""})),u(k=>p(m({},k),{[M]:N})));return}E(k=>p(m({},k),{[M]:""})),u(k=>p(m({},k),{[M]:N}))},xA=()=>{var k,oA,cA,W,EA,mA;let Q={},M=o,N=parseInt((M==null?void 0:M.expiryMonth)||"",10),L=(M==null?void 0:M.expiryYear)||"";if((k=M==null?void 0:M.cardName)!=null&&k.trim()||(Q.cardName="Card name is required"),(oA=M==null?void 0:M.cardNumber)!=null&&oA.trim()||(Q.cardNumber="Card number is required"),(!((cA=M==null?void 0:M.expiryMonth)!=null&&cA.trim())||!((W=M==null?void 0:M.expiryYear)!=null&&W.trim())||isNaN(N)||N<1||N>12||L.length!==4)&&(Q.expiryMonth="Invalid Expiration Date."),(EA=M==null?void 0:M.cvv)!=null&&EA.trim()||(Q.cvv="CVV is required"),(mA=M==null?void 0:M.zipCode)!=null&&mA.trim()||(Q.zipCode="ZIP code is required"),M!=null&&M.expiryMonth&&(M!=null&&M.expiryYear)&&M.expiryMonth.length<=2&&M.expiryYear.length===4){let jA=parseInt(M.expiryMonth,10),AA=parseInt(M.expiryYear,10),$A=new Date,DB=$A.getMonth()+1,JA=$A.getFullYear();(AA<JA||AA===JA&&jA<DB)&&(Q.expiryMonth="Card is expired")}return NA(Q),Object.keys(Q).length>0},G=()=>{var N,L,k,oA,cA,W,EA,mA,jA;let Q={},M=z;if((N=M==null?void 0:M.name)!=null&&N.trim()||(Q.name="Name is required"),(L=M==null?void 0:M.accountNumber)!=null&&L.trim()||(Q.accountNumber="account number is required"),(k=M==null?void 0:M.accountNumber)!=null&&k.trim()&&((oA=M==null?void 0:M.accountNumber)==null?void 0:oA.trim())!==((cA=M==null?void 0:M.confirmAccountNumber)==null?void 0:cA.trim())&&(Q.confirmAccountNumber="Account numbers must match"),(W=M==null?void 0:M.bankName)!=null&&W.trim()||(Q.bankName="Bank name is required"),(EA=M==null?void 0:M.routingNumber)!=null&&EA.trim()||(Q.routingNumber="Routing Number is required"),M!=null&&M.routingNumber&&((mA=M==null?void 0:M.routingNumber)==null?void 0:mA.length)!==9&&(Q.routingNumber="Routing number must be 9 digits"),((jA=M==null?void 0:M.routingNumber)==null?void 0:jA.length)==9){let AA=M==null?void 0:M.routingNumber,$A=[3,7,1],DB=0;for(let JA=0;JA<AA.length;JA++)DB+=parseInt(AA[JA],10)*$A[JA%3];DB%10!==0&&(Q.routingNumber="Invalid routing number")}return E(Q),Object.keys(Q).length>0},t=async Q=>{var M,N,L,k,oA,cA,W,EA,mA,jA,AA,$A,DB,JA,LB,XA;if(Q.preventDefault(),n!=="ach"){if(xA())return;{let XB=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),hA=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),oB=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),rB={};if(XB||(rB.cardNumber="Invalid card Number"),hA||(rB.expiryMonth="Invalid Expiration Date."),oB||(rB.cvv="Invalid CVV"),NA(rB),XB&&oB&&hA){b(!0);try{let QB=p(m({},o),{amount:`${A.amount||0}`,fractalpayPublicKey:lA,orderId:A==null?void 0:A.orderID,customer_id:A==null?void 0:A.customerId,discount:A==null?void 0:A.discount,surcharge:A==null?void 0:A.surcharge,tax:A==null?void 0:A.tax}),pA=await NB.post(`${HA}create-widget-order`,QB),qB=async function(VA){if(VA.Error)f(VA.Error),b(!1);else{let CA=o==null?void 0:o.cardName,F=o==null?void 0:o.zipCode;VA.name=CA,VA.postal_code=F,VA.isCardSave=`${eA}`,VA.isCharge=!0,VA.posSalesIdEncode=pA==null?void 0:pA.data.data.posSalesIdEncode,console.log(VA,"resppp"),console.log(pA==null?void 0:pA.data.data.posSalesIdEncode,"fkjdashgfuh"),ZA.emit("sendMessage",VA),ZA.on(pA==null?void 0:pA.data.data.posSalesIdEncode,OA=>{if(console.log(OA,"socket data"),Dw(OA==null?void 0:OA.data)){let LA=JSON.parse(OA.data);console.log("return data : ",LA),LA!=null&&LA.result?(uA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),P(!1),v(LA==null?void 0:LA.transactionId),DA(!0),b(!1)):(b(!1),f((LA==null?void 0:LA.message)||"Something went wrong."))}else f("Something went wrong.")})}};if((g==null?void 0:g.paymentGateway)===32){let VA={method:"POST",redirect:"follow"};try{let CA=await NB.post(`${IB}api/v1/widget/generate-session`,VA),F=Number(o==null?void 0:o.expiryYear)%100,OA=o==null?void 0:o.cardNumber;OA=OA==null?void 0:OA.replace(/\s+/g,"");let LA=`${OA}=${F}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,dw=forge.pki.publicKeyFromPem((N=(M=CA==null?void 0:CA.data)==null?void 0:M.data)==null?void 0:N.publicKeyPem).encrypt(LA,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ow=forge.util.encode64(dw),aw={"Content-Type":"application/json","x-app-session-key":(k=(L=CA.data)==null?void 0:L.data)==null?void 0:k.session_key},fw=JSON.stringify({enc_track2_data:`${ow}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(cA=(oA=CA==null?void 0:CA.data)==null?void 0:oA.data)==null?void 0:cA.session_key}`});try{let qA=await NB.post(`${aB}tokenizer/tokenize`,fw,{headers:aw}),lw=JSON.stringify(p(m({},(W=qA==null?void 0:qA.data)==null?void 0:W.data),{isSaveCardChecked:eA,name:o==null?void 0:o.cardName,postal_code:o==null?void 0:o.zipCode,customer_id:A==null?void 0:A.customerId})),uw=JSON.stringify({pre_sales_id:`${(mA=(EA=pA==null?void 0:pA.data)==null?void 0:EA.data)==null?void 0:mA.posSalesIdEncode}`,token:`${(jA=qA==null?void 0:qA.data)==null?void 0:jA.data.token}`,json_response:`${lw}`}),vw={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:uw,redirect:"follow",isChargeviafractal:!0};ZA.emit("sendMessage",vw),ZA.on("chargeviafractalgateway",PB=>{var Ow;if(console.log(PB,"socket data"),Dw(PB==null?void 0:PB.data)){let OB=JSON.parse(PB==null?void 0:PB.data);console.log(OB,"dfuigdasuf"),OB!=null&&OB.result?(v((Ow=OB==null?void 0:OB.data)==null?void 0:Ow.transactionId),DA(!0),b(!1)):(b(!1),f((OB==null?void 0:OB.message)||"Something went wrong."))}else f("Something went wrong.")})}catch(qA){b(!1),f((($A=(AA=qA==null?void 0:qA.response)==null?void 0:AA.data)==null?void 0:$A.message)||(qA==null?void 0:qA.message)||"Something went wrong.")}}catch(CA){b(!1),f(((JA=(DB=CA==null?void 0:CA.response)==null?void 0:DB.data)==null?void 0:JA.message)||(CA==null?void 0:CA.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(pA==null?void 0:pA.data.data.dctoken,"PaymentForm",qB)}catch(QB){b(!1),f(((XA=(LB=QB==null?void 0:QB.response)==null?void 0:LB.data)==null?void 0:XA.message)||(QB==null?void 0:QB.message)||"Something went wrong.")}}}}else{if(G())return;{b(!0);let XB={fractalpayPublicKey:lA,label:(z==null?void 0:z.name)||"John Doe",account_number:z==null?void 0:z.accountNumber,routing_number:z==null?void 0:z.routingNumber,bank_name:z==null?void 0:z.bankName,account_type:z==null?void 0:z.accountType,amount:String(A.amount||0),isSaveAch:fA,customer_id:A==null?void 0:A.customerId,order_id:A==null?void 0:A.orderID,tax:A==null?void 0:A.tax,discount:A==null?void 0:A.discount,surcharge:A==null?void 0:A.surcharge,isChargeACH:!0};ZA.emit("sendMessage",XB),ZA.on("ach-incoming",hA=>{var oB;console.log(hA,"sfhdwhf"),(hA==null?void 0:hA.status)=="Failed"?typeof(hA==null?void 0:hA.message)=="object"?Object.values(hA==null?void 0:hA.message).forEach(rB=>{f(rB||"Something went wrong")}):f((hA==null?void 0:hA.message)||"Something went wrong"):(v((oB=hA==null?void 0:hA.data)==null?void 0:oB.transaction_id),DA(!0),b(!1))})}}},X=async()=>{var Q,M,N,L,k,oA,cA,W,EA,mA,jA,AA,$A,DB,JA,LB,XA,yB,XB,hA,oB,rB,QB,pA,qB,VA;K();try{let CA={fractalpayPublicKey:lA,customer_id:A==null?void 0:A.customerId},F=await NB.post(`${HA}get-payment-details`,CA);if(c((Q=F==null?void 0:F.data)==null?void 0:Q.data),(N=(M=F==null?void 0:F.data)==null?void 0:M.data)!=null&&N.paymentGateway||(WA(),f("Something went wrong.")),(k=(L=F==null?void 0:F.data)==null?void 0:L.data)!=null&&k.card_list&&((W=(cA=(oA=F==null?void 0:F.data)==null?void 0:oA.data)==null?void 0:cA.card_list)==null?void 0:W.length)>0){y((mA=(EA=F==null?void 0:F.data)==null?void 0:EA.data)==null?void 0:mA.card_list),e("cardList");let OA=($A=(AA=(jA=F==null?void 0:F.data)==null?void 0:jA.data)==null?void 0:AA.card_list)==null?void 0:$A.filter(LA=>(LA==null?void 0:LA.primary_card)==1);(OA!=null&&OA[0]&&((DB=OA==null?void 0:OA[0])==null?void 0:DB.payment_method_type)==((LB=(JA=F==null?void 0:F.data)==null?void 0:JA.data)==null?void 0:LB.paymentGateway)||((XA=OA==null?void 0:OA[0])==null?void 0:XA.card_type)==="Bank")&&Z(OA[0])}else e("card");(XB=(yB=F==null?void 0:F.data)==null?void 0:yB.data)!=null&&XB.paymentDeviceList&&((rB=(oB=(hA=F==null?void 0:F.data)==null?void 0:hA.data)==null?void 0:oB.paymentDeviceList)==null?void 0:rB.length)>0&&V((pA=(QB=F==null?void 0:F.data)==null?void 0:QB.data)==null?void 0:pA.paymentDeviceList[0]),PA()}catch(CA){console.log(CA),PA(),f(((VA=(qB=CA==null?void 0:CA.response)==null?void 0:qB.data)==null?void 0:VA.message)||(CA==null?void 0:CA.message)||"Something went wrong")}},IA=async()=>{let Q=A==null?void 0:A.customerId,M=String(A==null?void 0:A.discount),N=String(A==null?void 0:A.surcharge),L=String(A==null?void 0:A.tax),k=A==null?void 0:A.merchantPublicKey,oA=A==null?void 0:A.orderID,cA=String(A==null?void 0:A.amount),W=l==null?void 0:l.id,EA=l==null?void 0:l.card_type;if(k&&oA&&cA)if(Q)if(W){let jA={amount:cA,order_id:oA,customer_id:Q,card_id:W,fractalpayPublicKey:k,isCardSave:eA,discount:M,surcharge:N,tax:L},mA=jA,{isCardSave:AA}=mA,$A=RB(mA,["isCardSave"]),JA=HA+(EA==="Bank"?"charge-ach":"charge-by-card"),LB={"Content-Type":"application/json"};b(!0),ZA.emit("sendMessage",{url:JA,body:EA=="Bank"?$A:jA,isChargebycard:!0}),ZA.on("charge-by-card",XA=>{var yB;console.log(XA,"response"),(XA==null?void 0:XA.result)==!0||(XA==null?void 0:XA.status)==!0?(v((yB=XA.data)==null?void 0:yB.transaction_id),DA(!0),b(!1)):f((XA==null?void 0:XA.message)||"Something went wrong.")})}else f("Please Select A Card/ACH");else f("Please Select Customer");else f("Something went wrong.")},J=async()=>{var k,oA,cA,W,EA,mA;let Q=A==null?void 0:A.merchantPublicKey,M=A==null?void 0:A.orderID,N=String(A==null?void 0:A.amount),L=A==null?void 0:A.customerId;if(!(j!=null&&j.device_id)){f("Please Select A Payment Device");return}if(Q&&M&&N){b(!0);let jA={amount:N,fractalpayPublicKey:Q,customer_order_id:M,device_id:j==null?void 0:j.device_id,customer_id:L||""};try{let AA=await NB.post(`${HA}charge-with-reader`,jA);console.log(AA,"response"),((k=AA==null?void 0:AA.data)==null?void 0:k.result)==!0?(v((cA=(oA=AA==null?void 0:AA.data)==null?void 0:oA.data)==null?void 0:cA.transaction_id),DA(!0),b(!1)):(f(((W=AA==null?void 0:AA.data)==null?void 0:W.message)||"Something went wrong."),b(!1))}catch(AA){f(((mA=(EA=AA==null?void 0:AA.response)==null?void 0:EA.data)==null?void 0:mA.message)||"Something went wrong."),b(!1)}}else f("Something went wrong.")},iA=()=>{O==="card"?IA():O==="reader"&&J()};EC(()=>{D&&lA&&X()},[lA,D]);let YA=async Q=>{VB.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 N={card_id:Q,customer_id:A==null?void 0:A.customerId,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey},L=await NB.post(`${HA}delete-customer-card`,N);b(!1),X(),VB.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(N){b(!1),VB.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else M.dismiss===VB.DismissReason.cancel&&VB.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},GA=Q=>{switch(Q==null?void 0:Q.toLowerCase()){case"visa":return eB;case"mastercard":case"mc":case"m/c":return hB;case"amex":case"american express":case"ae":return YB;case"discover":return GB;case"bank":return Bw;default:return Q}};return B.createElement(B.Fragment,null,B.createElement(sB,null),B.createElement(JB,null),B.createElement(B.Fragment,null,B.createElement("button",{className:"paymentBtn",onClick:dB},"Pay"),B.createElement(HB,{open:D,onClose:WA},nA&&B.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},B.createElement(vB,{error:nA,onClose:WA})),yA&&B.createElement(TB,{onClose:WA,tranId:h}),!nA&&!yA&&B.createElement(B.Fragment,null,(a||T)&&B.createElement(AB,{loading:a||T}),B.createElement("div",{className:"frac-card-payment-page frac-form"},B.createElement("div",{className:"parent-pay-container"},B.createElement("span",{className:"request-payment-close-popup",onClick:WA},B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},B.createElement("g",{clipPath:"url(#clip0_12425_52336)"},B.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"})),B.createElement("defs",null,B.createElement("clipPath",{id:"clip0_12425_52336"},B.createElement("rect",{width:"16",height:"16",fill:"white"}))))),B.createElement("div",{className:"pay-main-logo-res"},B.createElement("img",{src:g==null?void 0:g.logo,id:"pay-logos"})),B.createElement("div",{className:"pay-container"},B.createElement("div",{className:"pay-header pay-conatiner-one"},B.createElement("div",{className:"pay-conatiner-one-first"},B.createElement("div",{className:"pay-logo-container"},B.createElement("div",{className:"pay-main-logo"},B.createElement("img",{src:g==null?void 0:g.logo,id:"pay-logos"})),B.createElement("h1",{className:"pay-heading"},"Pay"),(Y==null?void 0:Y.length)>0&&n!=="cardList"&&B.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>e("cardList")}," ",B.createElement(nw,null)," Back")),B.createElement("div",{className:"amt-pay-con"},B.createElement("div",{className:"pay-amount-conatiner"},B.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),B.createElement("strong",{className:"pay-amount"},"$",(q=Number(A==null?void 0:A.amount))==null?void 0:q.toFixed(2))),n!="ach"&&B.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},B.createElement("img",{src:eB.src,alt:"",width:33}),B.createElement("img",{src:hB.src,width:33,alt:""}),B.createElement("img",{src:YB.src,alt:"",width:33}),B.createElement("img",{src:GB.src,width:33,alt:""})))),B.createElement("div",{className:"pay-conatiner-one-last"},B.createElement("img",{src:ww.src,alt:""}),B.createElement("img",{src:Cw.src,alt:""}),"Secure payments powered by Fractal"),B.createElement("div",null)),B.createElement("div",{className:"pay-tab pay-conatiner-two"},!a&&B.createElement("div",{className:"col-md-12"},B.createElement("div",{id:"payment-form-div"},n!=="cardList"?B.createElement("div",null,(Y==null?void 0:Y.length)>0&&B.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>e("cardList")}," ",B.createElement(nw,null)," Back"),(g==null?void 0:g.isSkyFiAccount)&&B.createElement("div",{className:"tab"},B.createElement("button",{className:"tablinks",onClick:Q=>{cB("card")},style:{border:n==="card"?"1px solid":""}},B.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),B.createElement("button",{className:"tablinks",onClick:Q=>{cB("ach")},style:{border:n==="ach"?"1px solid":""}},B.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),B.createElement("div",{className:"res-pay-con"},B.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},B.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),B.createElement("strong",{className:"pay-amount"},"$",(sA=Number(A==null?void 0:A.amount))==null?void 0:sA.toFixed(2))),n!="ach"&&B.createElement("div",null,B.createElement("div",null,B.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:hB.src,width:35,alt:""})),B.createElement("div",null,B.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:GB.src,width:35,alt:""}))))):B.createElement("div",null,B.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",g==null?void 0:g.customer_name),B.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",O==="card"?"Cards/Banks":"Readers"," "),B.createElement("div",{className:"res-pay-con"},B.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},B.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),B.createElement("strong",{className:"pay-amount"},"$",(gA=Number(A==null?void 0:A.amount))==null?void 0:gA.toFixed(2))),B.createElement("div",null,B.createElement("div",null,B.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:hB.src,width:35,alt:""})),B.createElement("div",null,B.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:GB.src,width:35,alt:""}))))),B.createElement("div",{id:"ach",style:{display:n==="cardList"?"block":"none"},className:"tabcontent"},B.createElement("div",{className:"card-lint-div-in"},B.createElement("div",{className:"card-list-div"},O==="card"?B.createElement(B.Fragment,null,(g==null?void 0:g.card_list)&&((MA=g==null?void 0:g.card_list)==null?void 0:MA.length)>0&&((zA=g==null?void 0:g.card_list)==null?void 0:zA.map((Q,M)=>B.createElement("div",{className:"card-list-single-div",key:M},B.createElement("div",{className:"card-number-radio"},B.createElement("input",{disabled:(g==null?void 0:g.paymentGateway)!=(Q==null?void 0:Q.payment_method_type)&&(Q==null?void 0:Q.card_type)!="Bank",type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:l===Q,onChange:N=>Z(Q)}),B.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",Q==null?void 0:Q.cardlastfourdigit),(Q==null?void 0:Q.card_type)!="Bank"&&B.createElement("h6",{className:"card-expiry-date"},Q==null?void 0:Q.expmonth,"/",Q==null?void 0:Q.expyear)),B.createElement("div",{className:"card-number-radio"},B.createElement("span",{className:"visa-card"},B.createElement("img",{src:GA(Q==null?void 0:Q.card_type).src,alt:""})),B.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>YA(Q==null?void 0:Q.id)},B.createElement("img",{src:Aw.src,alt:""}))))))):B.createElement(B.Fragment,null,(g==null?void 0:g.paymentDeviceList)&&((SA=g==null?void 0:g.paymentDeviceList)==null?void 0:SA.length)>0&&((wA=g==null?void 0:g.paymentDeviceList)==null?void 0:wA.map((Q,M)=>B.createElement("div",{className:"card-list-single-div",key:M},B.createElement("div",{className:"card-number-radio"},B.createElement("input",{type:"radio",className:"cardRadio",name:"selected_reader",id:"",checked:j===Q,onChange:N=>V(Q)}),B.createElement("label",{htmlFor:"",className:"card-number-last-four"},Q==null?void 0:Q.device_name)),B.createElement("div",{className:"card-number-radio"},B.createElement("span",{className:"visa-card"},B.createElement($B,null)))))))),B.createElement("div",{className:"pay-with-other-card",onClick:()=>e("card")},"Pay With Other Card",B.createElement("img",{src:FB.src,alt:""})),O==="card"&&(g==null?void 0:g.paymentDeviceList)&&((BB=g==null?void 0:g.paymentDeviceList)==null?void 0:BB.length)>0&&B.createElement("div",{className:"pay-with-other-card ",onClick:()=>rA("reader")},"Pay With Reader",B.createElement($B,null)),O==="reader"&&(g==null?void 0:g.paymentDeviceList)&&((wB=g==null?void 0:g.paymentDeviceList)==null?void 0:wB.length)>0&&B.createElement("div",{className:"pay-with-other-card ",onClick:()=>rA("card")},"Pay With Saved Card",B.createElement("img",{src:FB.src,alt:""}))),B.createElement("div",{className:"form-group",style:{padding:"0"}},B.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:iA},"$",(CB=Number(A==null?void 0:A.amount))==null?void 0:CB.toFixed(2)))),B.createElement("div",{id:"card",style:{display:n==="card"?"block":"none"},className:"tabcontent"},QA?B.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:t},B.createElement("div",{className:"ach-scrl",style:{minHeight:g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)>0?"398px":g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)==0?"456px":(Y==null?void 0:Y.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),B.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(o==null?void 0:o.cardName)||"",onChange:Q=>{let M=Q.target.value;/^[a-zA-Z\s]*$/.test(M)&&KA("cardName",M)}}),(s==null?void 0:s.cardName)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.cardName)),B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),B.createElement("div",{className:"toggle-num-wrapper"},B.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(o==null?void 0:o.cardNumber)||"",onChange:Q=>tB(Q),"data-token":"card_number"}),B.createElement("div",{className:"card-crdi card-expiry-new"},B.createElement("div",{className:"exp-date-year-container"},B.createElement("div",{className:"exp-date form-group"},B.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:Q=>KA("expiryMonth",Q.target.value)})),B.createElement("div",{className:"exp-year form-group"},B.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:Q=>KA("expiryYear",Q.target.value)})),B.createElement("div",{className:"security-digit form-group"},B.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(o==null?void 0:o.cvv)||"",onChange:Q=>KA("cvv",Q.target.value)})))),(s==null?void 0:s.cardNumber)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.cardNumber),B.createElement("p",{style:{margin:"0"}},s!=null&&s.expiryMonth||s!=null&&s.expiryYear?B.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},s==null?void 0:s.expiryMonth):"",(s==null?void 0:s.cvv)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.cvv)))),B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),B.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(kA=A==null?void 0:A.orderID)!=null?kA:"",style:{background:"#F6F6F7",color:"#727272"}})),B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"zip"},"ZIP"),B.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(U=o==null?void 0:o.zipCode)!=null?U:"",onChange:Q=>KA("zipCode",Q.target.value)}),(s==null?void 0:s.zipCode)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.zipCode)),(A==null?void 0:A.customerId)&&B.createElement("div",{className:"form-group"},B.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},B.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:eA,onChange:Q=>P(Q.target.checked)}),B.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),B.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},B.createElement("g",{clipPath:"url(#clip0_12420_50192)"},B.createElement("rect",{width:"20",height:"20",fill:"white"}),B.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),B.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"})),B.createElement("defs",null,B.createElement("clipPath",{id:"clip0_12420_50192"},B.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),B.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(g==null?void 0:g.paymentDeviceList)&&((_A=g==null?void 0:g.paymentDeviceList)==null?void 0:_A.length)>0&&B.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>H(!QA)},QA?"Pay With Reader":"Pay With Card"),B.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(gB=Number(A==null?void 0:A.amount))==null?void 0:gB.toFixed(2)))):B.createElement(B.Fragment,null,B.createElement("div",{className:"card-lint-div-in"},B.createElement("div",{className:"card-list-div"},(g==null?void 0:g.paymentDeviceList)&&((mB=g==null?void 0:g.paymentDeviceList)==null?void 0:mB.length)>0&&((dA=g==null?void 0:g.paymentDeviceList)==null?void 0:dA.map((Q,M)=>B.createElement("div",{className:"card-list-single-div",key:M},B.createElement("div",{className:"card-number-radio"},B.createElement("input",{type:"radio",className:"cardRadio",name:"selected_reader",id:"",checked:j===Q,onChange:N=>V(Q)}),B.createElement("label",{htmlFor:"",className:"card-number-last-four"},Q==null?void 0:Q.device_name)),B.createElement("div",{className:"card-number-radio"},B.createElement("span",{className:"visa-card"},B.createElement($B,null)))))))),B.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(g==null?void 0:g.paymentDeviceList)&&((bB=g==null?void 0:g.paymentDeviceList)==null?void 0:bB.length)>0&&B.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>H(!QA)},QA?"Pay With Reader":"Pay With Card"),B.createElement("button",{onClick:J,className:"pay-button"},"$",(MB=Number(A==null?void 0:A.amount))==null?void 0:MB.toFixed(2))))),B.createElement("div",{id:"ach",style:{display:n==="ach"?"block":"none"},className:"tabcontent"},B.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:t},B.createElement("div",{className:"ach-scrl",style:{minHeight:g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)>0?"378px":g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)==0?"436px":(Y==null?void 0:Y.length)>0?"462px":"520px",maxHeight:g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)>0?"358px":((Y==null?void 0:Y.length)>0,"380px")}},B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),B.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(tA=z==null?void 0:z.name)!=null?tA:"",onChange:TA}),(w==null?void 0:w.name)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.name)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"routingnumber"},"Routing number"),B.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(vA=z==null?void 0:z.routingNumber)!=null?vA:"",onChange:TA}),(w==null?void 0:w.routingNumber)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.routingNumber)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"accountnumber"},"Account number"),B.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(zB=z==null?void 0:z.accountNumber)!=null?zB:"",onChange:TA}),(w==null?void 0:w.accountNumber)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.accountNumber)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),B.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(nB=z==null?void 0:z.confirmAccountNumber)!=null?nB:"",onChange:TA}),(w==null?void 0:w.confirmAccountNumber)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.confirmAccountNumber)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"bankname"},"Bank name"),B.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(kB=z==null?void 0:z.bankName)!=null?kB:"",onChange:TA}),(w==null?void 0:w.bankName)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.bankName)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"accounttype"},"Select account type"),B.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(FA=z==null?void 0:z.accountType)!=null?FA:"",onChange:TA},B.createElement("option",{value:""},"Select account"),B.createElement("option",{value:"Personal Saving"},"Personal Saving"),B.createElement("option",{value:"Business Saving"},"Business Saving"),B.createElement("option",{value:"Personal Checking"},"Personal Checking"),B.createElement("option",{value:"Business Checking"},"Business Checking"))),(A==null?void 0:A.customerId)&&B.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},B.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:fA,onChange:Q=>$(Q.target.checked)}),B.createElement("label",{htmlFor:"saveACH"},"Save ACH")),fA&&B.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},B.createElement("p",null,"If checked, I agree for ",B.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),B.createElement("div",{className:"form-group "},B.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},"$",(pB=Number(A==null?void 0:A.amount))==null?void 0:pB.toFixed(2)))))))))))))))}import C,{useEffect as OC,useState as RA}from"react";import ZB from"axios";import Qw from"sweetalert2";import{IoArrowBack as rw}from"react-icons/io5";function HC(A){var K,PA,WA,dB,cB,KA,tB,TA,xA;let[a,x]=RA(!1),[T,b]=RA(!1),[nA,f]=RA(""),[yA,DA]=RA(!1),[D,I]=RA(!1),[n,e]=RA("card"),[O,rA]=RA(!1),QA=A.merchantPublicKey,[H,eA]=RA(),[P,fA]=RA({}),[$,lA]=RA([]),[o,uA]=RA(),[s,NA]=RA(),[z,u]=RA(""),w=()=>x(!0),E=()=>x(!1),Y=()=>{I(!1),e("card"),b(!1),f(""),DA(!1),u(""),eA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),fA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),rA(!1),uA({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},y=()=>I(!0),l=(G,t)=>{let X=G;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(X)){(t===""||/^[0-9]+$/.test(t))&&(fA(J=>p(m({},J),{[X]:""})),eA(J=>p(m({},J),{[X]:t})));return}fA(J=>p(m({},J),{[X]:""})),eA(J=>p(m({},J),{[X]:t}))},Z=G=>{let X=G.target.value.replace(/\D/g,""),IA="";/^3[47]/.test(X)?IA=X.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(iA,YA,GA,q)=>[YA,GA,q].filter(Boolean).join(" ")):IA=X.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(iA,YA,GA,q,sA)=>[YA,GA,q,sA].filter(Boolean).join(" ")),fA(J=>p(m({},J),{cardNumber:""})),eA(J=>p(m({},J),{cardNumber:IA}))},j=()=>{var J,iA,YA,GA,q,sA;let G={},t=H,X=parseInt((t==null?void 0:t.expiryMonth)||"",10),IA=(t==null?void 0:t.expiryYear)||"";if((J=t==null?void 0:t.cardName)!=null&&J.trim()||(G.cardName="Card name is required"),(iA=t==null?void 0:t.cardNumber)!=null&&iA.trim()||(G.cardNumber="Card number is required"),(!((YA=t==null?void 0:t.expiryMonth)!=null&&YA.trim())||!((GA=t==null?void 0:t.expiryYear)!=null&&GA.trim())||isNaN(X)||X<1||X>12||IA.length!==4)&&(G.expiryMonth="Invalid Expiration Date."),(q=t==null?void 0:t.cvv)!=null&&q.trim()||(G.cvv="CVV is required"),(sA=t==null?void 0:t.zipCode)!=null&&sA.trim()||(G.zipCode="ZIP code is required"),t!=null&&t.expiryMonth&&(t!=null&&t.expiryYear)&&t.expiryMonth.length<=2&&t.expiryYear.length===4){let gA=parseInt(t.expiryMonth,10),MA=parseInt(t.expiryYear,10),zA=new Date,SA=zA.getMonth()+1,wA=zA.getFullYear();(MA<wA||MA===wA&&gA<SA)&&(G.expiryMonth="Card is expired")}return fA(G),Object.keys(G).length>0},V=async G=>{var t,X,IA,J,iA,YA,GA,q,sA,gA,MA,zA,SA,wA,BB,wB,CB,kA,U;if(G.preventDefault(),n=="card"){if(j())return;{let gB=DatacapWebToken.validateCardNumber(H==null?void 0:H.cardNumber.replaceAll(" ","")),mB=DatacapWebToken.validateExpirationDate(H==null?void 0:H.expiryMonth,H==null?void 0:H.expiryYear),dA=DatacapWebToken.validateCVV(H==null?void 0:H.cvv),bB={};if(gB||(bB.cardNumber="Invalid card Number"),mB||(bB.expiryMonth="Invalid Expiration Date."),dA||(bB.cvv="Invalid CVV"),fA(bB),gB&&dA&&mB){b(!0);try{let MB=async function(tA){if(tA.Error)f(tA.Error),b(!1);else{let vA=H==null?void 0:H.cardName,zB=H==null?void 0:H.zipCode;tA.name=vA,tA.postal_code=zB,tA.fractalpayPublicKey=A==null?void 0:A.merchantPublicKey,tA.amount=A==null?void 0:A.amount,tA.order_id=A==null?void 0:A.orderID,tA.preAuth_id="",tA.isCardSave=O,tA.customer_id=A==null?void 0:A.customerId,tA.link_token="",tA.gateway_id=s==null?void 0:s.paymentGateway,tA.discount=A==null?void 0:A.discount,tA.tax=A==null?void 0:A.tax,tA.surcharge=A==null?void 0:A.surcharge,new Headers().append("Content-Type","application/json");let kB={method:"POST",body:JSON.stringify(tA),redirect:"follow"};ZA.emit("sendMessage",p(m({},kB),{isChargePreauth:!0})),ZA.on("charge-preauth",FA=>{var pB;console.log(FA,"datdata"),(FA==null?void 0:FA.status)=="Failed"?(b(!1),f((FA==null?void 0:FA.message)||"Something went wrong. Please try again later.")):(DA(!0),u((pB=FA==null?void 0:FA.data)==null?void 0:pB.transaction_id),b(!1),eA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((s==null?void 0:s.paymentGateway)===32){let tA={method:"POST",redirect:"follow"};try{let vA=await ZB.post(`${IB}api/v1/widget/generate-session`,tA),zB=Number(H==null?void 0:H.expiryYear)%100,nB=H==null?void 0:H.cardNumber;nB=nB==null?void 0:nB.replace(/\s+/g,"");let kB=`${nB}=${zB}${H==null?void 0:H.expiryMonth} ${H==null?void 0:H.cvv}`,pB=forge.pki.publicKeyFromPem((X=(t=vA==null?void 0:vA.data)==null?void 0:t.data)==null?void 0:X.publicKeyPem).encrypt(kB,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Q=forge.util.encode64(pB),M={"Content-Type":"application/json","x-app-session-key":(J=(IA=vA.data)==null?void 0:IA.data)==null?void 0:J.session_key},N=JSON.stringify({enc_track2_data:`${Q}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(YA=(iA=vA==null?void 0:vA.data)==null?void 0:iA.data)==null?void 0:YA.session_key}`});try{let L=await ZB.post(`${aB}tokenizer/tokenize`,N,{headers:M}),k=JSON.stringify(p(m({},(GA=L==null?void 0:L.data)==null?void 0:GA.data),{name:H==null?void 0:H.cardName,postal_code:H==null?void 0:H.zipCode,customer_id:A==null?void 0:A.customerId,amount:A==null?void 0:A.amount,Token:`${(sA=(q=L==null?void 0:L.data)==null?void 0:q.data)==null?void 0:sA.token}`,fractalpayPublicKey:QA,order_id:A==null?void 0:A.orderID,preAuth_id:"",isCardSave:O,discount:A==null?void 0:A.discount,surcharge:A==null?void 0:A.surcharge,tax:A==null?void 0:A.tax,link_token:"",ExpirationYear:H==null?void 0:H.expiryYear,ExpirationMonth:H==null?void 0:H.expiryMonth,CVV:H==null?void 0:H.cvv,Last4:(MA=(gA=L==null?void 0:L.data)==null?void 0:gA.data)==null?void 0:MA.last4,Brand:(SA=(zA=L==null?void 0:L.data)==null?void 0:zA.data)==null?void 0:SA.brand,gateway_id:s==null?void 0:s.paymentGateway})),cA={method:"POST",headers:{"Content-Type":"application/json"},body:k,redirect:"follow"};ZA.emit("sendMessage",p(m({},cA),{isFractalPreauth:!0})),ZA.on("fractal-charge-preauth",W=>{var EA;(W==null?void 0:W.status)=="Failed"?(b(!1),f((W==null?void 0:W.message)||"Something went wrong , Try again later")):(u((EA=W==null?void 0:W.data)==null?void 0:EA.transaction_id),DA(!0),b(!1))})}catch(L){console.log(L),b(!1),f(((BB=(wA=L==null?void 0:L.response)==null?void 0:wA.data)==null?void 0:BB.message)||(L==null?void 0:L.message)||"Something went wrong , Try again later")}}catch(vA){b(!1),f(((CB=(wB=vA==null?void 0:vA.response)==null?void 0:wB.data)==null?void 0:CB.message)||(vA==null?void 0:vA.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(s==null?void 0:s.dctoken,"PaymentForm",MB)}catch(MB){b(!1),f(((U=(kA=MB==null?void 0:MB.response)==null?void 0:kA.data)==null?void 0:U.message)||(MB==null?void 0:MB.message)||"Something went wrong.")}}}}},g=async()=>{var G,t,X,IA,J,iA,YA,GA,q,sA,gA,MA,zA,SA,wA,BB,wB,CB;w();try{let kA={fractalpayPublicKey:QA,customer_id:A==null?void 0:A.customerId,preauth:!0},U=await ZB.post(`${HA}get-payment-details`,kA);if(NA((G=U==null?void 0:U.data)==null?void 0:G.data),(X=(t=U==null?void 0:U.data)==null?void 0:t.data)!=null&&X.paymentGateway||(Y(),f("Something went wrong.")),(J=(IA=U==null?void 0:U.data)==null?void 0:IA.data)!=null&&J.card_list&&((GA=(YA=(iA=U==null?void 0:U.data)==null?void 0:iA.data)==null?void 0:YA.card_list)==null?void 0:GA.length)>0){lA((sA=(q=U==null?void 0:U.data)==null?void 0:q.data)==null?void 0:sA.card_list),e("cardList");let _A=(zA=(MA=(gA=U==null?void 0:U.data)==null?void 0:gA.data)==null?void 0:MA.card_list)==null?void 0:zA.filter(gB=>(gB==null?void 0:gB.primary_card)==1);_A!=null&&_A[0]&&((SA=_A==null?void 0:_A[0])==null?void 0:SA.payment_method_type)==((BB=(wA=U==null?void 0:U.data)==null?void 0:wA.data)==null?void 0:BB.paymentGateway)&&uA(_A[0])}else e("card");E()}catch(kA){console.log(kA),E(),f(((CB=(wB=kA==null?void 0:kA.response)==null?void 0:wB.data)==null?void 0:CB.message)||(kA==null?void 0:kA.message)||"Something went wrong")}},c=async()=>{var gA,MA,zA,SA,wA,BB,wB;let G=A==null?void 0:A.customerId,t=A==null?void 0:A.discount,X=A==null?void 0:A.surcharge,IA=A==null?void 0:A.tax,J=A==null?void 0:A.merchantPublicKey,iA=A==null?void 0:A.orderID,YA=A==null?void 0:A.amount,GA=o==null?void 0:o.id,q=o==null?void 0:o.card_type;if(J&&iA&&YA)if(G)if(GA){let CB={amount:YA,order_id:iA,customer_id:G,card_id:GA,fractalpayPublicKey:J,isCardSave:q!="Bank",discount:t,surcharge:X,tax:IA},sA=CB,{isCardSave:kA}=sA,U=RB(sA,["isCardSave"]),gB=HA+"authorize-by-card",mB={"Content-Type":"application/json"};b(!0);try{let dA=await ZB.post(gB,q=="Bank"?U:CB,{headers:mB});(gA=dA==null?void 0:dA.data)!=null&&gA.result&&(u((zA=(MA=dA==null?void 0:dA.data)==null?void 0:MA.data)==null?void 0:zA.transaction_id),DA(!0),b(!1))}catch(dA){b(!1),console.log(dA),f(((wA=(SA=dA==null?void 0:dA.response)==null?void 0:SA.data)==null?void 0:wA.message)||((wB=(BB=dA==null?void 0:dA.response)==null?void 0:BB.data)==null?void 0:wB.status)||"Something went erong")}}else f("Please Select A Card/ACH");else f("Please Select Customer");else f("Something went wrong.")};OC(()=>{D&&QA&&g()},[QA,D]);let h=async G=>{Qw.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 t=>{if(t.isConfirmed){b(!0);try{let X={card_id:G,customer_id:A==null?void 0:A.customerId,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey},IA=await ZB.post(`${HA}delete-customer-card`,X);b(!1),g(),Qw.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(X){b(!1),Qw.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},v=G=>{switch(G==null?void 0:G.toLowerCase()){case"visa":return eB;case"mastercard":case"mc":case"m/c":return hB;case"amex":case"american express":case"ae":return YB;case"discover":return GB;case"bank":return Bw;default:return G}};return C.createElement(C.Fragment,null,C.createElement(sB,null),C.createElement(JB,null),C.createElement(C.Fragment,null,C.createElement("button",{className:"paymentBtn",onClick:y},"PreAuth Payment"),C.createElement(HB,{open:D,onClose:Y},nA&&C.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},C.createElement(vB,{error:nA,onClose:Y})),yA&&C.createElement(TB,{onClose:Y,tranId:z}),!nA&&!yA&&C.createElement(C.Fragment,null,(a||T)&&C.createElement(AB,{loading:a||T}),C.createElement("div",null,C.createElement("div",{className:"frac-card-payment-page frac-form"},C.createElement("div",{className:"parent-pay-container"},C.createElement("span",{className:"request-payment-close-popup",onClick:Y},C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},C.createElement("g",{clipPath:"url(#clip0_12425_52336)"},C.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_12425_52336"},C.createElement("rect",{width:"16",height:"16",fill:"white"}))))),C.createElement("div",{className:"pay-container"},C.createElement("div",{className:"pay-header pay-conatiner-one"},C.createElement("div",{className:"pay-conatiner-one-first"},C.createElement("div",{className:"pay-logo-container"},C.createElement("div",{className:"pay-main-logo"},C.createElement("img",{src:s==null?void 0:s.logo,id:"pay-logos"})),C.createElement("h1",{className:"pay-heading"},"Pay"),($==null?void 0:$.length)>0&&n!=="cardList"&&C.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>e("cardList")}," ",C.createElement(rw,null)," Back")),C.createElement("div",{className:"amt-pay-con"},C.createElement("div",{className:"pay-amount-conatiner"},C.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),C.createElement("strong",{className:"pay-amount"},"$",(K=Number(A==null?void 0:A.amount))==null?void 0:K.toFixed(2))),n!="ach"&&C.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},C.createElement("img",{src:eB.src,alt:"",width:33}),C.createElement("img",{src:hB.src,width:33,alt:""}),C.createElement("img",{src:YB.src,alt:"",width:33}),C.createElement("img",{src:GB.src,width:33,alt:""})))),C.createElement("div",{className:"pay-conatiner-one-last"},C.createElement("img",{src:ww.src,alt:""}),C.createElement("img",{src:Cw.src,alt:""}),"Secure payments powered by Fractal"),C.createElement("div",null)),!a&&C.createElement("div",{className:"pay-tab pay-conatiner-two"},C.createElement("div",{className:"col-md-12"},C.createElement("div",{id:"payment-form-div"},n!=="cardList"?C.createElement("div",null,($==null?void 0:$.length)>0&&C.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>e("cardList")}," ",C.createElement(rw,null)," Back"),C.createElement("div",{className:""},C.createElement("div",{className:"res-pay-con"},C.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},C.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),C.createElement("strong",{className:"pay-amount"},"$",(PA=Number(A==null?void 0:A.amount))==null?void 0:PA.toFixed(2))),C.createElement("div",null,C.createElement("div",null,C.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:hB.src,width:35,alt:""})),C.createElement("div",null,C.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:GB.src,width:35,alt:""})))))):C.createElement("div",null,C.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",s==null?void 0:s.customer_name),C.createElement("div",{className:"res-pay-con"},C.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},C.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),C.createElement("strong",{className:"pay-amount"},"$",(WA=Number(A==null?void 0:A.amount))==null?void 0:WA.toFixed(2))),C.createElement("div",null,C.createElement("div",null,C.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:hB.src,width:35,alt:""})),C.createElement("div",null,C.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:GB.src,width:35,alt:""})))),C.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),C.createElement("div",{style:{display:n==="cardList"?"block":"none"},className:"tabcontent"},C.createElement("div",{className:"card-lint-div-in"},C.createElement("div",{className:"card-list-div"},(s==null?void 0:s.card_list)&&((dB=s==null?void 0:s.card_list)==null?void 0:dB.length)>0&&((cB=s==null?void 0:s.card_list)==null?void 0:cB.map((G,t)=>C.createElement("div",{className:"card-list-single-div",key:t},C.createElement("div",{className:"card-number-radio"},C.createElement("input",{disabled:(s==null?void 0:s.paymentGateway)!=(G==null?void 0:G.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:o===G,onChange:X=>uA(G)}),C.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",G==null?void 0:G.cardlastfourdigit),C.createElement("h6",{className:"card-expiry-date"},G==null?void 0:G.expmonth,"/",G==null?void 0:G.expyear)),C.createElement("div",{className:"card-number-radio"},C.createElement("span",{className:"visa-card"},C.createElement("img",{src:v(G==null?void 0:G.card_type).src,alt:""})),C.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>h(G==null?void 0:G.id)},C.createElement("img",{src:Aw.src,alt:""}))))))),C.createElement("div",{className:"pay-with-other-card ",onClick:()=>e("card")},"Authorize With Other Card",C.createElement("img",{src:FB.src,alt:""}))),C.createElement("div",{className:"form-group"},C.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:c},"$",(KA=Number(A==null?void 0:A.amount))==null?void 0:KA.toFixed(2)))),C.createElement("div",{id:"card",style:{display:n==="card"?"block":"none"},className:"tabcontent"},C.createElement("form",{id:"PaymentForm",onSubmit:V},C.createElement("div",{className:"ach-scrl",style:{minHeight:($==null?void 0:$.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),C.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(H==null?void 0:H.cardName)||"",onChange:G=>{let t=G.target.value;/^[a-zA-Z\s]*$/.test(t)&&l("cardName",t)}}),(P==null?void 0:P.cardName)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.cardName)),C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"cardNumber"},"Card Number"),C.createElement("div",{className:"toggle-num-wrapper"},C.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(H==null?void 0:H.cardNumber)||"",onChange:G=>Z(G),"data-token":"card_number"}),C.createElement("div",{className:"card-crdi card-expiry-new"},C.createElement("div",{className:"exp-date-year-container"},C.createElement("div",{className:"exp-date form-group"},C.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(H==null?void 0:H.expiryMonth)||"",onChange:G=>l("expiryMonth",G.target.value)})),C.createElement("div",{className:"exp-year form-group"},C.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(H==null?void 0:H.expiryYear)||"",onChange:G=>l("expiryYear",G.target.value)})),C.createElement("div",{className:"security-digit form-group"},C.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(H==null?void 0:H.cvv)||"",onChange:G=>l("cvv",G.target.value)})))),(P==null?void 0:P.cardNumber)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.cardNumber),C.createElement("p",{style:{margin:"0"}},P!=null&&P.expiryMonth||P!=null&&P.expiryYear?C.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},P==null?void 0:P.expiryMonth):"",(P==null?void 0:P.cvv)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.cvv)))),C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),C.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(tB=H==null?void 0:H.orderId)!=null?tB:"OID123456",onChange:G=>l("orderId",G.target.value),style:{background:"#F6F6F7",color:"#727272"}})),C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"zip"},"ZIP"),C.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(TA=H==null?void 0:H.zipCode)!=null?TA:"",onChange:G=>l("zipCode",G.target.value)}),(P==null?void 0:P.zipCode)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.zipCode)),(A==null?void 0:A.customerId)&&C.createElement("div",{className:"form-group"},C.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},C.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:O,onChange:G=>rA(G.target.checked)}),C.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),C.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},C.createElement("g",{clipPath:"url(#clip0_12420_50192)"},C.createElement("rect",{width:"20",height:"20",fill:"white"}),C.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),C.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"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_12420_50192"},C.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),C.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},C.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(xA=Number(A==null?void 0:A.amount))==null?void 0:xA.toFixed(2))))))))))))))))}import S,{useEffect as GC,useState as xB}from"react";import tC from"sweetalert2";import SB from"axios";import hC from"react";function Iw(){let A="#000",a="#fff",x="#212529",T="#dee2e6";return hC.createElement("style",null,`
1472
+ `)}var Rw=({onClose:A,error:a})=>UA.createElement(UA.Fragment,null,UA.createElement(Mw,null),UA.createElement("div",{className:"card-error"},UA.createElement("div",{className:"payment-error-container"},UA.createElement("div",{className:"error-icon"},UA.createElement("div",{className:"circle"},UA.createElement("i",{className:"fa fa-times","aria-hidden":"true"})),UA.createElement("div",{className:"error-text"},UA.createElement("div",{className:"payment-error-text"},a),UA.createElement("div",{className:"thank-you-text"},"Try again later ")),UA.createElement("div",{className:"error-btn-div"},UA.createElement("button",{onClick:A},"OK")))))),vB=Rw;import{io as _w}from"socket.io-client";var $w=_w(HA,{transports:["websocket"],withCredentials:!1}),ZA=$w;var Dw=A=>{try{let a=JSON.parse(A);return typeof a=="object"&&a!==null}catch(a){return!1}};var hB="./mc-img-DOAGH63G.svg";var eB="./visa-img-FX6P7OM3.svg";var YB="./ae-img-YGFM7U63.svg";var GB="./discover-img-4LBHC4QG.svg";var FB="./card-OY3NFHAU.svg";var $B="./Trash-CXFDX4J7.svg";var Aw="./bank-ORJOWIKR.svg";var Bw="./secure-img-4G7PSDVG.png";var ww="./pov-by-MFWC23HA.png";var Cw="./pax-D32QY2OJ.svg";function OC(A){var q,sA,gA,MA,zA,SA,wA,BB,wB,CB,kA,U,_A,gB,mB,dA,bB,MB,tA,vA,zB,nB,kB,FA,pB;let[a,x]=bA(!1),[T,b]=bA(!1),[nA,f]=bA(""),[yA,DA]=bA(!1),[D,I]=bA(!1),[n,e]=bA("card"),[O,rA]=bA("card"),[QA,H]=bA(!0),[eA,P]=bA(!1),[fA,R]=bA(!1),lA=A.merchantPublicKey,[o,uA]=bA(),[s,NA]=bA({}),[z,u]=bA(),[w,E]=bA({}),[Y,y]=bA([]),[l,Z]=bA(),[j,V]=bA(),[g,c]=bA(),[h,v]=bA(""),K=()=>x(!0),PA=()=>x(!1),WA=()=>{I(!1),e("card"),f(""),DA(!1),v(""),u({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),E({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),uA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),NA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),R(!1),P(!1),Z({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),V({}),rA("card"),H(!0)},dB=()=>I(!0),cB=Q=>{e(Q)},KA=(Q,M)=>{let N=Q;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(N)){(M===""||/^[0-9]+$/.test(M))&&(NA(k=>p(m({},k),{[N]:""})),uA(k=>p(m({},k),{[N]:M})));return}NA(k=>p(m({},k),{[N]:""})),uA(k=>p(m({},k),{[N]:M}))},tB=Q=>{let N=Q.target.value.replace(/\D/g,""),L="";/^3[47]/.test(N)?L=N.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(oA,cA,W,EA)=>[cA,W,EA].filter(Boolean).join(" ")):L=N.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(oA,cA,W,EA,mA)=>[cA,W,EA,mA].filter(Boolean).join(" ")),NA(k=>p(m({},k),{cardNumber:""})),uA(k=>p(m({},k),{cardNumber:L}))},TA=Q=>{let{name:M,value:N}=Q.target,L=["routingNumber","accountNumber","confirmAccountNumber"];if(M=="name"){/^[a-zA-Z\s]*$/.test(N)&&(E(k=>p(m({},k),{[M]:""})),u(k=>p(m({},k),{[M]:N})));return}if(L.includes(M)){(N===""||/^[0-9]+$/.test(N))&&(E(k=>p(m({},k),{[M]:""})),u(k=>p(m({},k),{[M]:N})));return}E(k=>p(m({},k),{[M]:""})),u(k=>p(m({},k),{[M]:N}))},xA=()=>{var k,oA,cA,W,EA,mA;let Q={},M=o,N=parseInt((M==null?void 0:M.expiryMonth)||"",10),L=(M==null?void 0:M.expiryYear)||"";if((k=M==null?void 0:M.cardName)!=null&&k.trim()||(Q.cardName="Card name is required"),(oA=M==null?void 0:M.cardNumber)!=null&&oA.trim()||(Q.cardNumber="Card number is required"),(!((cA=M==null?void 0:M.expiryMonth)!=null&&cA.trim())||!((W=M==null?void 0:M.expiryYear)!=null&&W.trim())||isNaN(N)||N<1||N>12||L.length!==4)&&(Q.expiryMonth="Invalid Expiration Date."),(EA=M==null?void 0:M.cvv)!=null&&EA.trim()||(Q.cvv="CVV is required"),(mA=M==null?void 0:M.zipCode)!=null&&mA.trim()||(Q.zipCode="ZIP code is required"),M!=null&&M.expiryMonth&&(M!=null&&M.expiryYear)&&M.expiryMonth.length<=2&&M.expiryYear.length===4){let jA=parseInt(M.expiryMonth,10),_=parseInt(M.expiryYear,10),$A=new Date,DB=$A.getMonth()+1,JA=$A.getFullYear();(_<JA||_===JA&&jA<DB)&&(Q.expiryMonth="Card is expired")}return NA(Q),Object.keys(Q).length>0},G=()=>{var N,L,k,oA,cA,W,EA,mA,jA;let Q={},M=z;if((N=M==null?void 0:M.name)!=null&&N.trim()||(Q.name="Name is required"),(L=M==null?void 0:M.accountNumber)!=null&&L.trim()||(Q.accountNumber="account number is required"),(k=M==null?void 0:M.accountNumber)!=null&&k.trim()&&((oA=M==null?void 0:M.accountNumber)==null?void 0:oA.trim())!==((cA=M==null?void 0:M.confirmAccountNumber)==null?void 0:cA.trim())&&(Q.confirmAccountNumber="Account numbers must match"),(W=M==null?void 0:M.bankName)!=null&&W.trim()||(Q.bankName="Bank name is required"),(EA=M==null?void 0:M.routingNumber)!=null&&EA.trim()||(Q.routingNumber="Routing Number is required"),M!=null&&M.routingNumber&&((mA=M==null?void 0:M.routingNumber)==null?void 0:mA.length)!==9&&(Q.routingNumber="Routing number must be 9 digits"),((jA=M==null?void 0:M.routingNumber)==null?void 0:jA.length)==9){let _=M==null?void 0:M.routingNumber,$A=[3,7,1],DB=0;for(let JA=0;JA<_.length;JA++)DB+=parseInt(_[JA],10)*$A[JA%3];DB%10!==0&&(Q.routingNumber="Invalid routing number")}return E(Q),Object.keys(Q).length>0},t=async Q=>{var M,N,L,k,oA,cA,W,EA,mA,jA,_,$A,DB,JA,LB,XA;if(Q.preventDefault(),n!=="ach"){if(xA())return;{let XB=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),hA=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),oB=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),rB={};if(XB||(rB.cardNumber="Invalid card Number"),hA||(rB.expiryMonth="Invalid Expiration Date."),oB||(rB.cvv="Invalid CVV"),NA(rB),XB&&oB&&hA){b(!0);try{let QB=p(m({},o),{amount:`${A.amount||0}`,fractalpayPublicKey:lA,orderId:A==null?void 0:A.orderID,customer_id:A==null?void 0:A.customerId,discount:A==null?void 0:A.discount,surcharge:A==null?void 0:A.surcharge,tax:A==null?void 0:A.tax}),pA=await NB.post(`${HA}create-widget-order`,QB),qB=async function(VA){if(VA.Error)f(VA.Error),b(!1);else{let CA=o==null?void 0:o.cardName,F=o==null?void 0:o.zipCode;VA.name=CA,VA.postal_code=F,VA.isCardSave=`${eA}`,VA.isCharge=!0,VA.posSalesIdEncode=pA==null?void 0:pA.data.data.posSalesIdEncode,console.log(VA,"resppp"),console.log(pA==null?void 0:pA.data.data.posSalesIdEncode,"fkjdashgfuh"),ZA.emit("sendMessage",VA),ZA.on(pA==null?void 0:pA.data.data.posSalesIdEncode,OA=>{if(console.log(OA,"socket data"),Dw(OA==null?void 0:OA.data)){let LA=JSON.parse(OA.data);console.log("return data : ",LA),LA!=null&&LA.result?(uA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),P(!1),v(LA==null?void 0:LA.transactionId),DA(!0),b(!1)):(b(!1),f((LA==null?void 0:LA.message)||"Something went wrong."))}else f("Something went wrong.")})}};if((g==null?void 0:g.paymentGateway)===32){let VA={method:"POST",redirect:"follow"};try{let CA=await NB.post(`${IB}api/v1/widget/generate-session`,VA),F=Number(o==null?void 0:o.expiryYear)%100,OA=o==null?void 0:o.cardNumber;OA=OA==null?void 0:OA.replace(/\s+/g,"");let LA=`${OA}=${F}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,dw=forge.pki.publicKeyFromPem((N=(M=CA==null?void 0:CA.data)==null?void 0:M.data)==null?void 0:N.publicKeyPem).encrypt(LA,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ow=forge.util.encode64(dw),aw={"Content-Type":"application/json","x-app-session-key":(k=(L=CA.data)==null?void 0:L.data)==null?void 0:k.session_key},fw=JSON.stringify({enc_track2_data:`${ow}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(cA=(oA=CA==null?void 0:CA.data)==null?void 0:oA.data)==null?void 0:cA.session_key}`});try{let qA=await NB.post(`${aB}tokenizer/tokenize`,fw,{headers:aw}),lw=JSON.stringify(p(m({},(W=qA==null?void 0:qA.data)==null?void 0:W.data),{isSaveCardChecked:eA,name:o==null?void 0:o.cardName,postal_code:o==null?void 0:o.zipCode,customer_id:A==null?void 0:A.customerId})),uw=JSON.stringify({pre_sales_id:`${(mA=(EA=pA==null?void 0:pA.data)==null?void 0:EA.data)==null?void 0:mA.posSalesIdEncode}`,token:`${(jA=qA==null?void 0:qA.data)==null?void 0:jA.data.token}`,json_response:`${lw}`}),vw={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:uw,redirect:"follow",isChargeviafractal:!0};ZA.emit("sendMessage",vw),ZA.on("chargeviafractalgateway",PB=>{var Ow;if(console.log(PB,"socket data"),Dw(PB==null?void 0:PB.data)){let OB=JSON.parse(PB==null?void 0:PB.data);console.log(OB,"dfuigdasuf"),OB!=null&&OB.result?(v((Ow=OB==null?void 0:OB.data)==null?void 0:Ow.transactionId),DA(!0),b(!1)):(b(!1),f((OB==null?void 0:OB.message)||"Something went wrong."))}else f("Something went wrong.")})}catch(qA){b(!1),f((($A=(_=qA==null?void 0:qA.response)==null?void 0:_.data)==null?void 0:$A.message)||(qA==null?void 0:qA.message)||"Something went wrong.")}}catch(CA){b(!1),f(((JA=(DB=CA==null?void 0:CA.response)==null?void 0:DB.data)==null?void 0:JA.message)||(CA==null?void 0:CA.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(pA==null?void 0:pA.data.data.dctoken,"PaymentForm",qB)}catch(QB){b(!1),f(((XA=(LB=QB==null?void 0:QB.response)==null?void 0:LB.data)==null?void 0:XA.message)||(QB==null?void 0:QB.message)||"Something went wrong.")}}}}else{if(G())return;{b(!0);let XB={fractalpayPublicKey:lA,label:(z==null?void 0:z.name)||"John Doe",account_number:z==null?void 0:z.accountNumber,routing_number:z==null?void 0:z.routingNumber,bank_name:z==null?void 0:z.bankName,account_type:z==null?void 0:z.accountType,amount:String(A.amount||0),isSaveAch:fA,customer_id:A==null?void 0:A.customerId,order_id:A==null?void 0:A.orderID,tax:A==null?void 0:A.tax,discount:A==null?void 0:A.discount,surcharge:A==null?void 0:A.surcharge,isChargeACH:!0};ZA.emit("sendMessage",XB),ZA.on("ach-incoming",hA=>{var oB;console.log(hA,"sfhdwhf"),(hA==null?void 0:hA.status)=="Failed"?typeof(hA==null?void 0:hA.message)=="object"?Object.values(hA==null?void 0:hA.message).forEach(rB=>{f(rB||"Something went wrong")}):f((hA==null?void 0:hA.message)||"Something went wrong"):(v((oB=hA==null?void 0:hA.data)==null?void 0:oB.transaction_id),DA(!0),b(!1))})}}},X=async()=>{var Q,M,N,L,k,oA,cA,W,EA,mA,jA,_,$A,DB,JA,LB,XA,yB,XB,hA,oB,rB,QB,pA,qB,VA;K();try{let CA={fractalpayPublicKey:lA,customer_id:A==null?void 0:A.customerId},F=await NB.post(`${HA}get-payment-details`,CA);if(c((Q=F==null?void 0:F.data)==null?void 0:Q.data),(N=(M=F==null?void 0:F.data)==null?void 0:M.data)!=null&&N.paymentGateway||(WA(),f("Something went wrong.")),(k=(L=F==null?void 0:F.data)==null?void 0:L.data)!=null&&k.card_list&&((W=(cA=(oA=F==null?void 0:F.data)==null?void 0:oA.data)==null?void 0:cA.card_list)==null?void 0:W.length)>0){y((mA=(EA=F==null?void 0:F.data)==null?void 0:EA.data)==null?void 0:mA.card_list),e("cardList");let OA=($A=(_=(jA=F==null?void 0:F.data)==null?void 0:jA.data)==null?void 0:_.card_list)==null?void 0:$A.filter(LA=>(LA==null?void 0:LA.primary_card)==1);(OA!=null&&OA[0]&&((DB=OA==null?void 0:OA[0])==null?void 0:DB.payment_method_type)==((LB=(JA=F==null?void 0:F.data)==null?void 0:JA.data)==null?void 0:LB.paymentGateway)||((XA=OA==null?void 0:OA[0])==null?void 0:XA.card_type)==="Bank")&&Z(OA[0])}else e("card");(XB=(yB=F==null?void 0:F.data)==null?void 0:yB.data)!=null&&XB.paymentDeviceList&&((rB=(oB=(hA=F==null?void 0:F.data)==null?void 0:hA.data)==null?void 0:oB.paymentDeviceList)==null?void 0:rB.length)>0&&V((pA=(QB=F==null?void 0:F.data)==null?void 0:QB.data)==null?void 0:pA.paymentDeviceList[0]),PA()}catch(CA){console.log(CA),PA(),f(((VA=(qB=CA==null?void 0:CA.response)==null?void 0:qB.data)==null?void 0:VA.message)||(CA==null?void 0:CA.message)||"Something went wrong")}},IA=async()=>{let Q=A==null?void 0:A.customerId,M=String(A==null?void 0:A.discount),N=String(A==null?void 0:A.surcharge),L=String(A==null?void 0:A.tax),k=A==null?void 0:A.merchantPublicKey,oA=A==null?void 0:A.orderID,cA=String(A==null?void 0:A.amount),W=l==null?void 0:l.id,EA=l==null?void 0:l.card_type;if(k&&oA&&cA)if(Q)if(W){let jA={amount:cA,order_id:oA,customer_id:Q,card_id:W,fractalpayPublicKey:k,isCardSave:eA,discount:M,surcharge:N,tax:L},mA=jA,{isCardSave:_}=mA,$A=RB(mA,["isCardSave"]),JA=HA+(EA==="Bank"?"charge-ach":"charge-by-card"),LB={"Content-Type":"application/json"};b(!0),ZA.emit("sendMessage",{url:JA,body:EA=="Bank"?$A:jA,isChargebycard:!0}),ZA.on("charge-by-card",XA=>{var yB;console.log(XA,"response"),(XA==null?void 0:XA.result)==!0||(XA==null?void 0:XA.status)==!0?(v((yB=XA.data)==null?void 0:yB.transaction_id),DA(!0),b(!1)):f((XA==null?void 0:XA.message)||"Something went wrong.")})}else f("Please Select A Card/ACH");else f("Please Select Customer");else f("Something went wrong.")},J=async()=>{var k,oA,cA,W,EA,mA;let Q=A==null?void 0:A.merchantPublicKey,M=A==null?void 0:A.orderID,N=String(A==null?void 0:A.amount),L=A==null?void 0:A.customerId;if(!(j!=null&&j.device_id)){f("Please Select A Payment Device");return}if(Q&&M&&N){b(!0);let jA={amount:N,fractalpayPublicKey:Q,customer_order_id:M,device_id:j==null?void 0:j.device_id,customer_id:L||""};try{let _=await NB.post(`${HA}charge-with-reader`,jA);console.log(_,"response"),((k=_==null?void 0:_.data)==null?void 0:k.result)==!0?(v((cA=(oA=_==null?void 0:_.data)==null?void 0:oA.data)==null?void 0:cA.transaction_id),DA(!0),b(!1)):(f(((W=_==null?void 0:_.data)==null?void 0:W.message)||"Something went wrong."),b(!1))}catch(_){f(((mA=(EA=_==null?void 0:_.response)==null?void 0:EA.data)==null?void 0:mA.message)||"Something went wrong."),b(!1)}}else f("Something went wrong.")},iA=()=>{O==="card"?IA():O==="reader"&&J()};cC(()=>{D&&lA&&X()},[lA,D]);let YA=async Q=>{VB.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 N={card_id:Q,customer_id:A==null?void 0:A.customerId,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey},L=await NB.post(`${HA}delete-customer-card`,N);b(!1),X(),VB.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(N){b(!1),VB.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else M.dismiss===VB.DismissReason.cancel&&VB.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},GA=Q=>{switch(Q==null?void 0:Q.toLowerCase()){case"visa":return eB;case"mastercard":case"mc":case"m/c":return hB;case"amex":case"american express":case"ae":return YB;case"discover":return GB;case"bank":return Aw;default:return Q}};return B.createElement(B.Fragment,null,B.createElement(sB,null),B.createElement(JB,null),B.createElement(B.Fragment,null,B.createElement("button",{className:"paymentBtn",onClick:dB},"Pay"),B.createElement(HB,{open:D,onClose:WA},nA&&B.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},B.createElement(vB,{error:nA,onClose:WA})),yA&&B.createElement(TB,{onClose:WA,tranId:h}),!nA&&!yA&&B.createElement(B.Fragment,null,(a||T)&&B.createElement(AB,{loading:a||T}),B.createElement("div",{className:"frac-card-payment-page frac-form"},B.createElement("div",{className:"parent-pay-container"},B.createElement("span",{className:"request-payment-close-popup",onClick:WA},B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},B.createElement("g",{clipPath:"url(#clip0_12425_52336)"},B.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"})),B.createElement("defs",null,B.createElement("clipPath",{id:"clip0_12425_52336"},B.createElement("rect",{width:"16",height:"16",fill:"white"}))))),B.createElement("div",{className:"pay-main-logo-res"},B.createElement("img",{src:g==null?void 0:g.logo,id:"pay-logos"})),B.createElement("div",{className:"pay-container"},B.createElement("div",{className:"pay-header pay-conatiner-one"},B.createElement("div",{className:"pay-conatiner-one-first"},B.createElement("div",{className:"pay-logo-container"},B.createElement("div",{className:"pay-main-logo"},B.createElement("img",{src:g==null?void 0:g.logo,id:"pay-logos"})),B.createElement("h1",{className:"pay-heading"},"Pay"),(Y==null?void 0:Y.length)>0&&n!=="cardList"&&B.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>e("cardList")}," ",B.createElement(nw,null)," Back")),B.createElement("div",{className:"amt-pay-con"},B.createElement("div",{className:"pay-amount-conatiner"},B.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),B.createElement("strong",{className:"pay-amount"},"$",(q=Number(A==null?void 0:A.amount))==null?void 0:q.toFixed(2))),n!="ach"&&B.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},B.createElement("img",{src:eB.src,alt:"",width:33}),B.createElement("img",{src:hB.src,width:33,alt:""}),B.createElement("img",{src:YB.src,alt:"",width:33}),B.createElement("img",{src:GB.src,width:33,alt:""})))),B.createElement("div",{className:"pay-conatiner-one-last"},B.createElement("img",{src:Bw.src,alt:""}),B.createElement("img",{src:ww.src,alt:""}),"Secure payments powered by Fractal"),B.createElement("div",null)),B.createElement("div",{className:"pay-tab pay-conatiner-two"},!a&&B.createElement("div",{className:"col-md-12"},B.createElement("div",{id:"payment-form-div"},n!=="cardList"?B.createElement("div",null,(Y==null?void 0:Y.length)>0&&B.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>e("cardList")}," ",B.createElement(nw,null)," Back"),(g==null?void 0:g.isSkyFiAccount)&&B.createElement("div",{className:"tab"},B.createElement("button",{className:"tablinks",onClick:Q=>{cB("card")},style:{border:n==="card"?"1px solid":""}},B.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),B.createElement("button",{className:"tablinks",onClick:Q=>{cB("ach")},style:{border:n==="ach"?"1px solid":""}},B.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),B.createElement("div",{className:"res-pay-con"},B.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},B.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),B.createElement("strong",{className:"pay-amount"},"$",(sA=Number(A==null?void 0:A.amount))==null?void 0:sA.toFixed(2))),n!="ach"&&B.createElement("div",null,B.createElement("div",null,B.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:hB.src,width:35,alt:""})),B.createElement("div",null,B.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:GB.src,width:35,alt:""}))))):B.createElement("div",null,B.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",g==null?void 0:g.customer_name),B.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",O==="card"?"Cards/Banks":"Readers"," "),B.createElement("div",{className:"res-pay-con"},B.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},B.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),B.createElement("strong",{className:"pay-amount"},"$",(gA=Number(A==null?void 0:A.amount))==null?void 0:gA.toFixed(2))),B.createElement("div",null,B.createElement("div",null,B.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:hB.src,width:35,alt:""})),B.createElement("div",null,B.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),B.createElement("img",{src:GB.src,width:35,alt:""}))))),B.createElement("div",{id:"ach",style:{display:n==="cardList"?"block":"none"},className:"tabcontent"},B.createElement("div",{className:"card-lint-div-in"},B.createElement("div",{className:"card-list-div"},O==="card"?B.createElement(B.Fragment,null,(g==null?void 0:g.card_list)&&((MA=g==null?void 0:g.card_list)==null?void 0:MA.length)>0&&((zA=g==null?void 0:g.card_list)==null?void 0:zA.map((Q,M)=>B.createElement("div",{className:"card-list-single-div",key:M},B.createElement("div",{className:"card-number-radio"},B.createElement("input",{disabled:(g==null?void 0:g.paymentGateway)!=(Q==null?void 0:Q.payment_method_type)&&(Q==null?void 0:Q.card_type)!="Bank",type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:l===Q,onChange:N=>Z(Q)}),B.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",Q==null?void 0:Q.cardlastfourdigit),(Q==null?void 0:Q.card_type)!="Bank"&&B.createElement("h6",{className:"card-expiry-date"},Q==null?void 0:Q.expmonth,"/",Q==null?void 0:Q.expyear)),B.createElement("div",{className:"card-number-radio"},B.createElement("span",{className:"visa-card"},B.createElement("img",{src:GA(Q==null?void 0:Q.card_type).src,alt:""})),B.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>YA(Q==null?void 0:Q.id)},B.createElement("img",{src:$B.src,alt:""}))))))):B.createElement(B.Fragment,null,(g==null?void 0:g.paymentDeviceList)&&((SA=g==null?void 0:g.paymentDeviceList)==null?void 0:SA.length)>0&&((wA=g==null?void 0:g.paymentDeviceList)==null?void 0:wA.map((Q,M)=>B.createElement("div",{className:"card-list-single-div",key:M},B.createElement("div",{className:"card-number-radio"},B.createElement("input",{type:"radio",className:"cardRadio",name:"selected_reader",id:"",checked:j===Q,onChange:N=>V(Q)}),B.createElement("label",{htmlFor:"",className:"card-number-last-four"},Q==null?void 0:Q.device_name)),B.createElement("div",{className:"card-number-radio"},B.createElement("span",{className:"visa-card"},B.createElement("img",{src:Cw.src,alt:""})))))))),B.createElement("div",{className:"pay-with-other-card",onClick:()=>e("card")},"Pay With Other Card",B.createElement("img",{src:FB.src,alt:""})),O==="card"&&(g==null?void 0:g.paymentDeviceList)&&((BB=g==null?void 0:g.paymentDeviceList)==null?void 0:BB.length)>0&&B.createElement("div",{className:"pay-with-other-card ",onClick:()=>rA("reader")},"Pay With Reader",B.createElement("img",{src:Cw.src,alt:""})),O==="reader"&&(g==null?void 0:g.paymentDeviceList)&&((wB=g==null?void 0:g.paymentDeviceList)==null?void 0:wB.length)>0&&B.createElement("div",{className:"pay-with-other-card ",onClick:()=>rA("card")},"Pay With Saved Card",B.createElement("img",{src:FB.src,alt:""}))),B.createElement("div",{className:"form-group",style:{padding:"0"}},B.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:iA},"$",(CB=Number(A==null?void 0:A.amount))==null?void 0:CB.toFixed(2)))),B.createElement("div",{id:"card",style:{display:n==="card"?"block":"none"},className:"tabcontent"},QA?B.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:t},B.createElement("div",{className:"ach-scrl",style:{minHeight:g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)>0?"398px":g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)==0?"456px":(Y==null?void 0:Y.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),B.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(o==null?void 0:o.cardName)||"",onChange:Q=>{let M=Q.target.value;/^[a-zA-Z\s]*$/.test(M)&&KA("cardName",M)}}),(s==null?void 0:s.cardName)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.cardName)),B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),B.createElement("div",{className:"toggle-num-wrapper"},B.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(o==null?void 0:o.cardNumber)||"",onChange:Q=>tB(Q),"data-token":"card_number"}),B.createElement("div",{className:"card-crdi card-expiry-new"},B.createElement("div",{className:"exp-date-year-container"},B.createElement("div",{className:"exp-date form-group"},B.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:Q=>KA("expiryMonth",Q.target.value)})),B.createElement("div",{className:"exp-year form-group"},B.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:Q=>KA("expiryYear",Q.target.value)})),B.createElement("div",{className:"security-digit form-group"},B.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(o==null?void 0:o.cvv)||"",onChange:Q=>KA("cvv",Q.target.value)})))),(s==null?void 0:s.cardNumber)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.cardNumber),B.createElement("p",{style:{margin:"0"}},s!=null&&s.expiryMonth||s!=null&&s.expiryYear?B.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},s==null?void 0:s.expiryMonth):"",(s==null?void 0:s.cvv)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.cvv)))),B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),B.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(kA=A==null?void 0:A.orderID)!=null?kA:"",style:{background:"#F6F6F7",color:"#727272"}})),B.createElement("div",{className:"form-group"},B.createElement("label",{htmlFor:"zip"},"ZIP"),B.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(U=o==null?void 0:o.zipCode)!=null?U:"",onChange:Q=>KA("zipCode",Q.target.value)}),(s==null?void 0:s.zipCode)&&B.createElement("span",{className:"error-span"},s==null?void 0:s.zipCode)),(A==null?void 0:A.customerId)&&B.createElement("div",{className:"form-group"},B.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},B.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:eA,onChange:Q=>P(Q.target.checked)}),B.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),B.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},B.createElement("g",{clipPath:"url(#clip0_12420_50192)"},B.createElement("rect",{width:"20",height:"20",fill:"white"}),B.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),B.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"})),B.createElement("defs",null,B.createElement("clipPath",{id:"clip0_12420_50192"},B.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),B.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(g==null?void 0:g.paymentDeviceList)&&((_A=g==null?void 0:g.paymentDeviceList)==null?void 0:_A.length)>0&&B.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>H(!QA)},QA?"Pay With Reader":"Pay With Card"),B.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(gB=Number(A==null?void 0:A.amount))==null?void 0:gB.toFixed(2)))):B.createElement(B.Fragment,null,B.createElement("div",{className:"card-lint-div-in"},B.createElement("div",{className:"card-list-div"},(g==null?void 0:g.paymentDeviceList)&&((mB=g==null?void 0:g.paymentDeviceList)==null?void 0:mB.length)>0&&((dA=g==null?void 0:g.paymentDeviceList)==null?void 0:dA.map((Q,M)=>B.createElement("div",{className:"card-list-single-div",key:M},B.createElement("div",{className:"card-number-radio"},B.createElement("input",{type:"radio",className:"cardRadio",name:"selected_reader",id:"",checked:j===Q,onChange:N=>V(Q)}),B.createElement("label",{htmlFor:"",className:"card-number-last-four"},Q==null?void 0:Q.device_name)),B.createElement("div",{className:"card-number-radio"},B.createElement("span",{className:"visa-card"},B.createElement("img",{src:Cw.src,alt:""})))))))),B.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(g==null?void 0:g.paymentDeviceList)&&((bB=g==null?void 0:g.paymentDeviceList)==null?void 0:bB.length)>0&&B.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>H(!QA)},QA?"Pay With Reader":"Pay With Card"),B.createElement("button",{onClick:J,className:"pay-button"},"$",(MB=Number(A==null?void 0:A.amount))==null?void 0:MB.toFixed(2))))),B.createElement("div",{id:"ach",style:{display:n==="ach"?"block":"none"},className:"tabcontent"},B.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:t},B.createElement("div",{className:"ach-scrl",style:{minHeight:g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)>0?"378px":g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)==0?"436px":(Y==null?void 0:Y.length)>0?"462px":"520px",maxHeight:g!=null&&g.isSkyFiAccount&&(Y==null?void 0:Y.length)>0?"358px":((Y==null?void 0:Y.length)>0,"380px")}},B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),B.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(tA=z==null?void 0:z.name)!=null?tA:"",onChange:TA}),(w==null?void 0:w.name)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.name)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"routingnumber"},"Routing number"),B.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(vA=z==null?void 0:z.routingNumber)!=null?vA:"",onChange:TA}),(w==null?void 0:w.routingNumber)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.routingNumber)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"accountnumber"},"Account number"),B.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(zB=z==null?void 0:z.accountNumber)!=null?zB:"",onChange:TA}),(w==null?void 0:w.accountNumber)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.accountNumber)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),B.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(nB=z==null?void 0:z.confirmAccountNumber)!=null?nB:"",onChange:TA}),(w==null?void 0:w.confirmAccountNumber)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.confirmAccountNumber)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"bankname"},"Bank name"),B.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(kB=z==null?void 0:z.bankName)!=null?kB:"",onChange:TA}),(w==null?void 0:w.bankName)&&B.createElement("span",{className:"error-span"},w==null?void 0:w.bankName)),B.createElement("div",{className:"form-group mb-4"},B.createElement("label",{htmlFor:"accounttype"},"Select account type"),B.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(FA=z==null?void 0:z.accountType)!=null?FA:"",onChange:TA},B.createElement("option",{value:""},"Select account"),B.createElement("option",{value:"Personal Saving"},"Personal Saving"),B.createElement("option",{value:"Business Saving"},"Business Saving"),B.createElement("option",{value:"Personal Checking"},"Personal Checking"),B.createElement("option",{value:"Business Checking"},"Business Checking"))),(A==null?void 0:A.customerId)&&B.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},B.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:fA,onChange:Q=>R(Q.target.checked)}),B.createElement("label",{htmlFor:"saveACH"},"Save ACH")),fA&&B.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},B.createElement("p",null,"If checked, I agree for ",B.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),B.createElement("div",{className:"form-group "},B.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},"$",(pB=Number(A==null?void 0:A.amount))==null?void 0:pB.toFixed(2)))))))))))))))}import C,{useEffect as HC,useState as RA}from"react";import ZB from"axios";import Qw from"sweetalert2";import{IoArrowBack as rw}from"react-icons/io5";function hC(A){var K,PA,WA,dB,cB,KA,tB,TA,xA;let[a,x]=RA(!1),[T,b]=RA(!1),[nA,f]=RA(""),[yA,DA]=RA(!1),[D,I]=RA(!1),[n,e]=RA("card"),[O,rA]=RA(!1),QA=A.merchantPublicKey,[H,eA]=RA(),[P,fA]=RA({}),[R,lA]=RA([]),[o,uA]=RA(),[s,NA]=RA(),[z,u]=RA(""),w=()=>x(!0),E=()=>x(!1),Y=()=>{I(!1),e("card"),b(!1),f(""),DA(!1),u(""),eA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),fA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),rA(!1),uA({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},y=()=>I(!0),l=(G,t)=>{let X=G;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(X)){(t===""||/^[0-9]+$/.test(t))&&(fA(J=>p(m({},J),{[X]:""})),eA(J=>p(m({},J),{[X]:t})));return}fA(J=>p(m({},J),{[X]:""})),eA(J=>p(m({},J),{[X]:t}))},Z=G=>{let X=G.target.value.replace(/\D/g,""),IA="";/^3[47]/.test(X)?IA=X.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(iA,YA,GA,q)=>[YA,GA,q].filter(Boolean).join(" ")):IA=X.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(iA,YA,GA,q,sA)=>[YA,GA,q,sA].filter(Boolean).join(" ")),fA(J=>p(m({},J),{cardNumber:""})),eA(J=>p(m({},J),{cardNumber:IA}))},j=()=>{var J,iA,YA,GA,q,sA;let G={},t=H,X=parseInt((t==null?void 0:t.expiryMonth)||"",10),IA=(t==null?void 0:t.expiryYear)||"";if((J=t==null?void 0:t.cardName)!=null&&J.trim()||(G.cardName="Card name is required"),(iA=t==null?void 0:t.cardNumber)!=null&&iA.trim()||(G.cardNumber="Card number is required"),(!((YA=t==null?void 0:t.expiryMonth)!=null&&YA.trim())||!((GA=t==null?void 0:t.expiryYear)!=null&&GA.trim())||isNaN(X)||X<1||X>12||IA.length!==4)&&(G.expiryMonth="Invalid Expiration Date."),(q=t==null?void 0:t.cvv)!=null&&q.trim()||(G.cvv="CVV is required"),(sA=t==null?void 0:t.zipCode)!=null&&sA.trim()||(G.zipCode="ZIP code is required"),t!=null&&t.expiryMonth&&(t!=null&&t.expiryYear)&&t.expiryMonth.length<=2&&t.expiryYear.length===4){let gA=parseInt(t.expiryMonth,10),MA=parseInt(t.expiryYear,10),zA=new Date,SA=zA.getMonth()+1,wA=zA.getFullYear();(MA<wA||MA===wA&&gA<SA)&&(G.expiryMonth="Card is expired")}return fA(G),Object.keys(G).length>0},V=async G=>{var t,X,IA,J,iA,YA,GA,q,sA,gA,MA,zA,SA,wA,BB,wB,CB,kA,U;if(G.preventDefault(),n=="card"){if(j())return;{let gB=DatacapWebToken.validateCardNumber(H==null?void 0:H.cardNumber.replaceAll(" ","")),mB=DatacapWebToken.validateExpirationDate(H==null?void 0:H.expiryMonth,H==null?void 0:H.expiryYear),dA=DatacapWebToken.validateCVV(H==null?void 0:H.cvv),bB={};if(gB||(bB.cardNumber="Invalid card Number"),mB||(bB.expiryMonth="Invalid Expiration Date."),dA||(bB.cvv="Invalid CVV"),fA(bB),gB&&dA&&mB){b(!0);try{let MB=async function(tA){if(tA.Error)f(tA.Error),b(!1);else{let vA=H==null?void 0:H.cardName,zB=H==null?void 0:H.zipCode;tA.name=vA,tA.postal_code=zB,tA.fractalpayPublicKey=A==null?void 0:A.merchantPublicKey,tA.amount=A==null?void 0:A.amount,tA.order_id=A==null?void 0:A.orderID,tA.preAuth_id="",tA.isCardSave=O,tA.customer_id=A==null?void 0:A.customerId,tA.link_token="",tA.gateway_id=s==null?void 0:s.paymentGateway,tA.discount=A==null?void 0:A.discount,tA.tax=A==null?void 0:A.tax,tA.surcharge=A==null?void 0:A.surcharge,new Headers().append("Content-Type","application/json");let kB={method:"POST",body:JSON.stringify(tA),redirect:"follow"};ZA.emit("sendMessage",p(m({},kB),{isChargePreauth:!0})),ZA.on("charge-preauth",FA=>{var pB;console.log(FA,"datdata"),(FA==null?void 0:FA.status)=="Failed"?(b(!1),f((FA==null?void 0:FA.message)||"Something went wrong. Please try again later.")):(DA(!0),u((pB=FA==null?void 0:FA.data)==null?void 0:pB.transaction_id),b(!1),eA({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((s==null?void 0:s.paymentGateway)===32){let tA={method:"POST",redirect:"follow"};try{let vA=await ZB.post(`${IB}api/v1/widget/generate-session`,tA),zB=Number(H==null?void 0:H.expiryYear)%100,nB=H==null?void 0:H.cardNumber;nB=nB==null?void 0:nB.replace(/\s+/g,"");let kB=`${nB}=${zB}${H==null?void 0:H.expiryMonth} ${H==null?void 0:H.cvv}`,pB=forge.pki.publicKeyFromPem((X=(t=vA==null?void 0:vA.data)==null?void 0:t.data)==null?void 0:X.publicKeyPem).encrypt(kB,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Q=forge.util.encode64(pB),M={"Content-Type":"application/json","x-app-session-key":(J=(IA=vA.data)==null?void 0:IA.data)==null?void 0:J.session_key},N=JSON.stringify({enc_track2_data:`${Q}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(YA=(iA=vA==null?void 0:vA.data)==null?void 0:iA.data)==null?void 0:YA.session_key}`});try{let L=await ZB.post(`${aB}tokenizer/tokenize`,N,{headers:M}),k=JSON.stringify(p(m({},(GA=L==null?void 0:L.data)==null?void 0:GA.data),{name:H==null?void 0:H.cardName,postal_code:H==null?void 0:H.zipCode,customer_id:A==null?void 0:A.customerId,amount:A==null?void 0:A.amount,Token:`${(sA=(q=L==null?void 0:L.data)==null?void 0:q.data)==null?void 0:sA.token}`,fractalpayPublicKey:QA,order_id:A==null?void 0:A.orderID,preAuth_id:"",isCardSave:O,discount:A==null?void 0:A.discount,surcharge:A==null?void 0:A.surcharge,tax:A==null?void 0:A.tax,link_token:"",ExpirationYear:H==null?void 0:H.expiryYear,ExpirationMonth:H==null?void 0:H.expiryMonth,CVV:H==null?void 0:H.cvv,Last4:(MA=(gA=L==null?void 0:L.data)==null?void 0:gA.data)==null?void 0:MA.last4,Brand:(SA=(zA=L==null?void 0:L.data)==null?void 0:zA.data)==null?void 0:SA.brand,gateway_id:s==null?void 0:s.paymentGateway})),cA={method:"POST",headers:{"Content-Type":"application/json"},body:k,redirect:"follow"};ZA.emit("sendMessage",p(m({},cA),{isFractalPreauth:!0})),ZA.on("fractal-charge-preauth",W=>{var EA;(W==null?void 0:W.status)=="Failed"?(b(!1),f((W==null?void 0:W.message)||"Something went wrong , Try again later")):(u((EA=W==null?void 0:W.data)==null?void 0:EA.transaction_id),DA(!0),b(!1))})}catch(L){console.log(L),b(!1),f(((BB=(wA=L==null?void 0:L.response)==null?void 0:wA.data)==null?void 0:BB.message)||(L==null?void 0:L.message)||"Something went wrong , Try again later")}}catch(vA){b(!1),f(((CB=(wB=vA==null?void 0:vA.response)==null?void 0:wB.data)==null?void 0:CB.message)||(vA==null?void 0:vA.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(s==null?void 0:s.dctoken,"PaymentForm",MB)}catch(MB){b(!1),f(((U=(kA=MB==null?void 0:MB.response)==null?void 0:kA.data)==null?void 0:U.message)||(MB==null?void 0:MB.message)||"Something went wrong.")}}}}},g=async()=>{var G,t,X,IA,J,iA,YA,GA,q,sA,gA,MA,zA,SA,wA,BB,wB,CB;w();try{let kA={fractalpayPublicKey:QA,customer_id:A==null?void 0:A.customerId,preauth:!0},U=await ZB.post(`${HA}get-payment-details`,kA);if(NA((G=U==null?void 0:U.data)==null?void 0:G.data),(X=(t=U==null?void 0:U.data)==null?void 0:t.data)!=null&&X.paymentGateway||(Y(),f("Something went wrong.")),(J=(IA=U==null?void 0:U.data)==null?void 0:IA.data)!=null&&J.card_list&&((GA=(YA=(iA=U==null?void 0:U.data)==null?void 0:iA.data)==null?void 0:YA.card_list)==null?void 0:GA.length)>0){lA((sA=(q=U==null?void 0:U.data)==null?void 0:q.data)==null?void 0:sA.card_list),e("cardList");let _A=(zA=(MA=(gA=U==null?void 0:U.data)==null?void 0:gA.data)==null?void 0:MA.card_list)==null?void 0:zA.filter(gB=>(gB==null?void 0:gB.primary_card)==1);_A!=null&&_A[0]&&((SA=_A==null?void 0:_A[0])==null?void 0:SA.payment_method_type)==((BB=(wA=U==null?void 0:U.data)==null?void 0:wA.data)==null?void 0:BB.paymentGateway)&&uA(_A[0])}else e("card");E()}catch(kA){console.log(kA),E(),f(((CB=(wB=kA==null?void 0:kA.response)==null?void 0:wB.data)==null?void 0:CB.message)||(kA==null?void 0:kA.message)||"Something went wrong")}},c=async()=>{var gA,MA,zA,SA,wA,BB,wB;let G=A==null?void 0:A.customerId,t=A==null?void 0:A.discount,X=A==null?void 0:A.surcharge,IA=A==null?void 0:A.tax,J=A==null?void 0:A.merchantPublicKey,iA=A==null?void 0:A.orderID,YA=A==null?void 0:A.amount,GA=o==null?void 0:o.id,q=o==null?void 0:o.card_type;if(J&&iA&&YA)if(G)if(GA){let CB={amount:YA,order_id:iA,customer_id:G,card_id:GA,fractalpayPublicKey:J,isCardSave:q!="Bank",discount:t,surcharge:X,tax:IA},sA=CB,{isCardSave:kA}=sA,U=RB(sA,["isCardSave"]),gB=HA+"authorize-by-card",mB={"Content-Type":"application/json"};b(!0);try{let dA=await ZB.post(gB,q=="Bank"?U:CB,{headers:mB});(gA=dA==null?void 0:dA.data)!=null&&gA.result&&(u((zA=(MA=dA==null?void 0:dA.data)==null?void 0:MA.data)==null?void 0:zA.transaction_id),DA(!0),b(!1))}catch(dA){b(!1),console.log(dA),f(((wA=(SA=dA==null?void 0:dA.response)==null?void 0:SA.data)==null?void 0:wA.message)||((wB=(BB=dA==null?void 0:dA.response)==null?void 0:BB.data)==null?void 0:wB.status)||"Something went erong")}}else f("Please Select A Card/ACH");else f("Please Select Customer");else f("Something went wrong.")};HC(()=>{D&&QA&&g()},[QA,D]);let h=async G=>{Qw.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 t=>{if(t.isConfirmed){b(!0);try{let X={card_id:G,customer_id:A==null?void 0:A.customerId,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey},IA=await ZB.post(`${HA}delete-customer-card`,X);b(!1),g(),Qw.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(X){b(!1),Qw.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},v=G=>{switch(G==null?void 0:G.toLowerCase()){case"visa":return eB;case"mastercard":case"mc":case"m/c":return hB;case"amex":case"american express":case"ae":return YB;case"discover":return GB;case"bank":return Aw;default:return G}};return C.createElement(C.Fragment,null,C.createElement(sB,null),C.createElement(JB,null),C.createElement(C.Fragment,null,C.createElement("button",{className:"paymentBtn",onClick:y},"PreAuth Payment"),C.createElement(HB,{open:D,onClose:Y},nA&&C.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},C.createElement(vB,{error:nA,onClose:Y})),yA&&C.createElement(TB,{onClose:Y,tranId:z}),!nA&&!yA&&C.createElement(C.Fragment,null,(a||T)&&C.createElement(AB,{loading:a||T}),C.createElement("div",null,C.createElement("div",{className:"frac-card-payment-page frac-form"},C.createElement("div",{className:"parent-pay-container"},C.createElement("span",{className:"request-payment-close-popup",onClick:Y},C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},C.createElement("g",{clipPath:"url(#clip0_12425_52336)"},C.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_12425_52336"},C.createElement("rect",{width:"16",height:"16",fill:"white"}))))),C.createElement("div",{className:"pay-container"},C.createElement("div",{className:"pay-header pay-conatiner-one"},C.createElement("div",{className:"pay-conatiner-one-first"},C.createElement("div",{className:"pay-logo-container"},C.createElement("div",{className:"pay-main-logo"},C.createElement("img",{src:s==null?void 0:s.logo,id:"pay-logos"})),C.createElement("h1",{className:"pay-heading"},"Pay"),(R==null?void 0:R.length)>0&&n!=="cardList"&&C.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>e("cardList")}," ",C.createElement(rw,null)," Back")),C.createElement("div",{className:"amt-pay-con"},C.createElement("div",{className:"pay-amount-conatiner"},C.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),C.createElement("strong",{className:"pay-amount"},"$",(K=Number(A==null?void 0:A.amount))==null?void 0:K.toFixed(2))),n!="ach"&&C.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},C.createElement("img",{src:eB.src,alt:"",width:33}),C.createElement("img",{src:hB.src,width:33,alt:""}),C.createElement("img",{src:YB.src,alt:"",width:33}),C.createElement("img",{src:GB.src,width:33,alt:""})))),C.createElement("div",{className:"pay-conatiner-one-last"},C.createElement("img",{src:Bw.src,alt:""}),C.createElement("img",{src:ww.src,alt:""}),"Secure payments powered by Fractal"),C.createElement("div",null)),!a&&C.createElement("div",{className:"pay-tab pay-conatiner-two"},C.createElement("div",{className:"col-md-12"},C.createElement("div",{id:"payment-form-div"},n!=="cardList"?C.createElement("div",null,(R==null?void 0:R.length)>0&&C.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>e("cardList")}," ",C.createElement(rw,null)," Back"),C.createElement("div",{className:""},C.createElement("div",{className:"res-pay-con"},C.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},C.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),C.createElement("strong",{className:"pay-amount"},"$",(PA=Number(A==null?void 0:A.amount))==null?void 0:PA.toFixed(2))),C.createElement("div",null,C.createElement("div",null,C.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:hB.src,width:35,alt:""})),C.createElement("div",null,C.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:GB.src,width:35,alt:""})))))):C.createElement("div",null,C.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",s==null?void 0:s.customer_name),C.createElement("div",{className:"res-pay-con"},C.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},C.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),C.createElement("strong",{className:"pay-amount"},"$",(WA=Number(A==null?void 0:A.amount))==null?void 0:WA.toFixed(2))),C.createElement("div",null,C.createElement("div",null,C.createElement("img",{src:eB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:hB.src,width:35,alt:""})),C.createElement("div",null,C.createElement("img",{src:YB.src,alt:"",width:35,style:{paddingRight:"5px"}}),C.createElement("img",{src:GB.src,width:35,alt:""})))),C.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),C.createElement("div",{style:{display:n==="cardList"?"block":"none"},className:"tabcontent"},C.createElement("div",{className:"card-lint-div-in"},C.createElement("div",{className:"card-list-div"},(s==null?void 0:s.card_list)&&((dB=s==null?void 0:s.card_list)==null?void 0:dB.length)>0&&((cB=s==null?void 0:s.card_list)==null?void 0:cB.map((G,t)=>C.createElement("div",{className:"card-list-single-div",key:t},C.createElement("div",{className:"card-number-radio"},C.createElement("input",{disabled:(s==null?void 0:s.paymentGateway)!=(G==null?void 0:G.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:o===G,onChange:X=>uA(G)}),C.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",G==null?void 0:G.cardlastfourdigit),C.createElement("h6",{className:"card-expiry-date"},G==null?void 0:G.expmonth,"/",G==null?void 0:G.expyear)),C.createElement("div",{className:"card-number-radio"},C.createElement("span",{className:"visa-card"},C.createElement("img",{src:v(G==null?void 0:G.card_type).src,alt:""})),C.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>h(G==null?void 0:G.id)},C.createElement("img",{src:$B.src,alt:""}))))))),C.createElement("div",{className:"pay-with-other-card ",onClick:()=>e("card")},"Authorize With Other Card",C.createElement("img",{src:FB.src,alt:""}))),C.createElement("div",{className:"form-group"},C.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:c},"$",(KA=Number(A==null?void 0:A.amount))==null?void 0:KA.toFixed(2)))),C.createElement("div",{id:"card",style:{display:n==="card"?"block":"none"},className:"tabcontent"},C.createElement("form",{id:"PaymentForm",onSubmit:V},C.createElement("div",{className:"ach-scrl",style:{minHeight:(R==null?void 0:R.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),C.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(H==null?void 0:H.cardName)||"",onChange:G=>{let t=G.target.value;/^[a-zA-Z\s]*$/.test(t)&&l("cardName",t)}}),(P==null?void 0:P.cardName)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.cardName)),C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"cardNumber"},"Card Number"),C.createElement("div",{className:"toggle-num-wrapper"},C.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(H==null?void 0:H.cardNumber)||"",onChange:G=>Z(G),"data-token":"card_number"}),C.createElement("div",{className:"card-crdi card-expiry-new"},C.createElement("div",{className:"exp-date-year-container"},C.createElement("div",{className:"exp-date form-group"},C.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(H==null?void 0:H.expiryMonth)||"",onChange:G=>l("expiryMonth",G.target.value)})),C.createElement("div",{className:"exp-year form-group"},C.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(H==null?void 0:H.expiryYear)||"",onChange:G=>l("expiryYear",G.target.value)})),C.createElement("div",{className:"security-digit form-group"},C.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(H==null?void 0:H.cvv)||"",onChange:G=>l("cvv",G.target.value)})))),(P==null?void 0:P.cardNumber)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.cardNumber),C.createElement("p",{style:{margin:"0"}},P!=null&&P.expiryMonth||P!=null&&P.expiryYear?C.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},P==null?void 0:P.expiryMonth):"",(P==null?void 0:P.cvv)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.cvv)))),C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),C.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(tB=H==null?void 0:H.orderId)!=null?tB:"OID123456",onChange:G=>l("orderId",G.target.value),style:{background:"#F6F6F7",color:"#727272"}})),C.createElement("div",{className:"form-group"},C.createElement("label",{htmlFor:"zip"},"ZIP"),C.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(TA=H==null?void 0:H.zipCode)!=null?TA:"",onChange:G=>l("zipCode",G.target.value)}),(P==null?void 0:P.zipCode)&&C.createElement("span",{className:"error-span"},P==null?void 0:P.zipCode)),(A==null?void 0:A.customerId)&&C.createElement("div",{className:"form-group"},C.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},C.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:O,onChange:G=>rA(G.target.checked)}),C.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),C.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},C.createElement("g",{clipPath:"url(#clip0_12420_50192)"},C.createElement("rect",{width:"20",height:"20",fill:"white"}),C.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),C.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"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_12420_50192"},C.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),C.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},C.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},"$",(xA=Number(A==null?void 0:A.amount))==null?void 0:xA.toFixed(2))))))))))))))))}import S,{useEffect as tC,useState as xB}from"react";import nC from"sweetalert2";import SB from"axios";import eC from"react";function Iw(){let A="#000",a="#fff",x="#212529",T="#dee2e6";return eC.createElement("style",null,`
1473
1473
  .add-card {
1474
1474
  max-width:380px;
1475
1475
  padding: 0 20px
@@ -1728,7 +1728,7 @@ var mw=Object.defineProperty,bw=Object.defineProperties;var pw=Object.getOwnProp
1728
1728
  }
1729
1729
  }
1730
1730
 
1731
- `)}import EB from"react";import eC from"react";function Ew(){return eC.createElement("style",null,`
1731
+ `)}import EB from"react";import YC from"react";function Ew(){return YC.createElement("style",null,`
1732
1732
  .card-success .logo-container {
1733
1733
  display: flex;
1734
1734
  justify-content: center;
@@ -1816,7 +1816,7 @@ var mw=Object.defineProperty,bw=Object.defineProperties;var pw=Object.getOwnProp
1816
1816
  color: #161616;
1817
1817
  opacity: 0.5;
1818
1818
  }
1819
- `)}var YC=({onClose:A})=>EB.createElement(EB.Fragment,null,EB.createElement(Ew,null),EB.createElement("div",{className:"card-success"},EB.createElement("div",{className:"payment-success-container"},EB.createElement("div",{className:"success-icon"},EB.createElement("div",{className:"circle"},EB.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),EB.createElement("div",{className:"success-text"},EB.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),EB.createElement("div",{className:"thank-you-text"},"Thank you ")))))),iw=YC;function nC(A){var z;let[a,x]=xB(!1),[T,b]=xB(!1),[nA,f]=xB(""),[yA,DA]=xB(!1),[D,I]=xB(),[n,e]=xB({}),[O,rA]=xB(),QA=()=>x(!0),H=()=>x(!1),eA=u=>{tC.fire({icon:"error",text:u,customClass:{popup:"custom-z-index"}})},P=()=>{DA(!1),b(!1),f(""),I({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},fA=()=>DA(!0),$=()=>{P()},lA=(u,w)=>{let E=u;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(E)){(w===""||/^[0-9]+$/.test(w))&&(e(y=>p(m({},y),{[E]:""})),I(y=>p(m({},y),{[E]:w})));return}e(y=>p(m({},y),{[E]:""})),console.log(w,E),I(y=>p(m({},y),{[E]:w}))},o=u=>{let E=u.target.value.replace(/\D/g,""),Y="";/^3[47]/.test(E)?Y=E.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(l,Z,j,V)=>[Z,j,V].filter(Boolean).join(" ")):Y=E.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(l,Z,j,V,g)=>[Z,j,V,g].filter(Boolean).join(" ")),e(y=>p(m({},y),{cardNumber:""})),I(y=>p(m({},y),{cardNumber:Y}))},uA=()=>{var y,l,Z,j,V,g;let u={},w=D,E=parseInt((w==null?void 0:w.expiryMonth)||"",10),Y=(w==null?void 0:w.expiryYear)||"";if((y=w==null?void 0:w.cardName)!=null&&y.trim()||(u.cardName="Card name is required"),(l=w==null?void 0:w.cardNumber)!=null&&l.trim()||(u.cardNumber="Card number is required"),(Z=w==null?void 0:w.expiryMonth)!=null&&Z.trim()?(Number(w==null?void 0:w.expiryMonth)>12||Number(w==null?void 0:w.expiryMonth)<1)&&(u.expiryMonth="Invalid Expiration Month."):u.expiryMonth="Expiration month is required",(j=w==null?void 0:w.expiryYear)!=null&&j.trim()?((V=w==null?void 0:w.expiryYear)==null?void 0:V.trim().length)!==4||Number(w==null?void 0:w.expiryYear)<2025?u.expiryYear="Invalid Expiration Year.":(isNaN(E)||E<1||E>12||Y.length!==4)&&(u.expiryMonth="Invalid Expiration Date."):u.expiryYear="Expiration year is required",(g=w==null?void 0:w.cvv)!=null&&g.trim()||(u.cvv="CVC is required"),w!=null&&w.expiryMonth&&(w!=null&&w.expiryYear)&&w.expiryMonth.length<=2&&w.expiryYear.length===4){let c=parseInt(w.expiryMonth,10),h=parseInt(w.expiryYear,10),v=new Date,K=v.getMonth()+1,PA=v.getFullYear();(h<PA||h===PA&&c<K)&&(u.expiryMonth="Card is expired")}return e(u),Object.keys(u).length>0},s=async()=>{var u,w,E;QA();try{let Y={fractalpayPublicKey:A==null?void 0:A.merchantPublicKey,customer_id:A==null?void 0:A.customerId,addcard:!0},y=await SB.post(`${HA}get-payment-details`,Y);console.log(y),rA((u=y==null?void 0:y.data)==null?void 0:u.data),(E=(w=y==null?void 0:y.data)==null?void 0:w.data)!=null&&E.paymentGateway||(P(),f("Something went wrong.")),H()}catch(Y){console.log(Y),H(),P(),f("Something went wrong.")}};return GC(()=>{A!=null&&A.merchantPublicKey&&s()},[A==null?void 0:A.merchantPublicKey]),S.createElement(S.Fragment,null,S.createElement(sB,null),S.createElement(Iw,null),S.createElement(AB,{loading:a}),nA&&S.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},S.createElement(vB,{error:nA,onClose:P})),T&&S.createElement(iw,{onClose:$}),!nA&&!T&&S.createElement(S.Fragment,null,S.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},S.createElement("form",{id:"creditCardForm",onSubmit:async u=>{var E,Y,y,l,Z,j,V,g,c,h,v,K,PA,WA,dB,cB;u.preventDefault();let w=uA();if(console.log(D),!w){let KA=DatacapWebToken.validateCardNumber(D==null?void 0:D.cardNumber.replaceAll(" ","")),tB=DatacapWebToken.validateExpirationDate(D==null?void 0:D.expiryMonth,D==null?void 0:D.expiryYear),TA=DatacapWebToken.validateCVV(D==null?void 0:D.cvv),xA={};if(KA||(xA.cardNumber="Invalid card Number"),tB||(xA.expiryMonth="Invalid Expiration Date."),TA||(xA.cvv="Invalid CVV"),e(xA),KA&&TA&&tB){QA();try{let G=async function(t){var X,IA,J,iA,YA;if(console.log(t),t.Error)console.log(t==null?void 0:t.Error),f(t.Error),H();else{let GA={userId:A==null?void 0:A.customerId,cardName:D==null?void 0:D.cardName,zip:D==null?void 0:D.zipCode,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey,token:t};try{let q=await SB.post(`${HA}add-card`,GA);console.log(q);let sA={fractalpayPublicKey:A==null?void 0:A.merchantPublicKey,wallet_id:"",card_number:D==null?void 0:D.cardNumber.replaceAll(" ",""),exp_month:D==null?void 0:D.expiryMonth,exp_year:(X=D==null?void 0:D.expiryYear)==null?void 0:X.slice(-2),cvv:D==null?void 0:D.cvv};try{let gA=await SB.post(`${HA}link-wallet`,sA);console.log(gA),b(!0),H(),I({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),uB(u,"close","")}catch(gA){console.log(gA),H(),f(((J=(IA=gA==null?void 0:gA.response)==null?void 0:IA.data)==null?void 0:J.message)||(gA==null?void 0:gA.message)||"Something went wrong.")}}catch(q){console.log(q),H(),f(((YA=(iA=q==null?void 0:q.response)==null?void 0:iA.data)==null?void 0:YA.message)||(q==null?void 0:q.message)||"Something went wrong.")}}};if((O==null?void 0:O.paymentGateway)===32){let t={method:"POST",redirect:"follow"};try{let X=await SB.post(`${IB}api/v1/widget/generate-session`,t),IA=Number(D==null?void 0:D.expiryYear)%100,J=D==null?void 0:D.cardNumber;J=J==null?void 0:J.replace(/\s+/g,"");let iA=`${J}=${IA}${D==null?void 0:D.expiryMonth} ${D==null?void 0:D.cvv}`,GA=forge.pki.publicKeyFromPem((Y=(E=X==null?void 0:X.data)==null?void 0:E.data)==null?void 0:Y.publicKeyPem).encrypt(iA,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),q=forge.util.encode64(GA),sA={"Content-Type":"application/json","x-app-session-key":(l=(y=X.data)==null?void 0:y.data)==null?void 0:l.session_key},gA=JSON.stringify({enc_track2_data:`${q}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(j=(Z=X==null?void 0:X.data)==null?void 0:Z.data)==null?void 0:j.session_key}`});try{let MA=await SB.post(`${aB}tokenizer/tokenize`,gA,{headers:sA}),zA=JSON.stringify(p(m({},(V=MA==null?void 0:MA.data)==null?void 0:V.data),{cvv:D==null?void 0:D.cvv,cardName:D==null?void 0:D.cardName,zip:D==null?void 0:D.zipCode,userId:A==null?void 0:A.customerId,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey})),SA={"Content-Type":"application/json"};try{let wA=await SB.post(`${HA}add-card`,zA,{headers:SA});console.log(wA),(g=wA==null?void 0:wA.data)!=null&&g.result&&(b(!0),H(),uB(u,"close",""))}catch(wA){H(),f(((h=(c=wA==null?void 0:wA.response)==null?void 0:c.data)==null?void 0:h.message)||(wA==null?void 0:wA.message)||"Something went wrong.")}}catch(MA){H(),f(((K=(v=MA==null?void 0:MA.response)==null?void 0:v.data)==null?void 0:K.message)||(MA==null?void 0:MA.message)||"Something went wrong.")}}catch(X){H(),f(((WA=(PA=X==null?void 0:X.response)==null?void 0:PA.data)==null?void 0:WA.message)||(X==null?void 0:X.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(O==null?void 0:O.dctoken,"creditCardForm",G)}catch(G){H(),f(((cB=(dB=G==null?void 0:G.response)==null?void 0:dB.data)==null?void 0:cB.message)||(G==null?void 0:G.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},S.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},S.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},S.createElement("label",{htmlFor:"cardNumber"},"Card Number"),S.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(D==null?void 0:D.cardNumber)||"",onChange:u=>o(u)}),(n==null?void 0:n.cardNumber)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.cardNumber),S.createElement("br",null)),S.createElement("div",{className:"card-dtl"},S.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"expMonth"},"MM"),S.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(D==null?void 0:D.expiryMonth)||"",onChange:u=>lA("expiryMonth",u.target.value)}),(n==null?void 0:n.expiryMonth)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.expiryMonth)),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"expYear"},"YYYY"),S.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(D==null?void 0:D.expiryYear)||"",onChange:u=>lA("expiryYear",u.target.value)}),(n==null?void 0:n.expiryYear)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.expiryYear)),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"cvc"},"CVC"),S.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(D==null?void 0:D.cvv)||"",onChange:u=>lA("cvv",u.target.value)}),(n==null?void 0:n.cvv)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.cvv)))),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"cardholderName"},"Name on card"),S.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(D==null?void 0:D.cardName)||"",onChange:u=>{let w=u.target.value;/^[a-zA-Z\s]*$/.test(w)&&lA("cardName",w)}}),(n==null?void 0:n.cardName)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.cardName)),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"zipcode"},"Zip"),S.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(z=D==null?void 0:D.zipCode)!=null?z:"",onChange:u=>lA("zipCode",u.target.value)}),(n==null?void 0:n.zipCode)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.zipCode))),S.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import d,{useState as WB}from"react";import KB from"axios";var sw={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import rC from"react";function cw({}){return rC.createElement("style",null,`
1819
+ `)}var GC=({onClose:A})=>EB.createElement(EB.Fragment,null,EB.createElement(Ew,null),EB.createElement("div",{className:"card-success"},EB.createElement("div",{className:"payment-success-container"},EB.createElement("div",{className:"success-icon"},EB.createElement("div",{className:"circle"},EB.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),EB.createElement("div",{className:"success-text"},EB.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),EB.createElement("div",{className:"thank-you-text"},"Thank you ")))))),iw=GC;function rC(A){var z;let[a,x]=xB(!1),[T,b]=xB(!1),[nA,f]=xB(""),[yA,DA]=xB(!1),[D,I]=xB(),[n,e]=xB({}),[O,rA]=xB(),QA=()=>x(!0),H=()=>x(!1),eA=u=>{nC.fire({icon:"error",text:u,customClass:{popup:"custom-z-index"}})},P=()=>{DA(!1),b(!1),f(""),I({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},fA=()=>DA(!0),R=()=>{P()},lA=(u,w)=>{let E=u;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(E)){(w===""||/^[0-9]+$/.test(w))&&(e(y=>p(m({},y),{[E]:""})),I(y=>p(m({},y),{[E]:w})));return}e(y=>p(m({},y),{[E]:""})),console.log(w,E),I(y=>p(m({},y),{[E]:w}))},o=u=>{let E=u.target.value.replace(/\D/g,""),Y="";/^3[47]/.test(E)?Y=E.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(l,Z,j,V)=>[Z,j,V].filter(Boolean).join(" ")):Y=E.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(l,Z,j,V,g)=>[Z,j,V,g].filter(Boolean).join(" ")),e(y=>p(m({},y),{cardNumber:""})),I(y=>p(m({},y),{cardNumber:Y}))},uA=()=>{var y,l,Z,j,V,g;let u={},w=D,E=parseInt((w==null?void 0:w.expiryMonth)||"",10),Y=(w==null?void 0:w.expiryYear)||"";if((y=w==null?void 0:w.cardName)!=null&&y.trim()||(u.cardName="Card name is required"),(l=w==null?void 0:w.cardNumber)!=null&&l.trim()||(u.cardNumber="Card number is required"),(Z=w==null?void 0:w.expiryMonth)!=null&&Z.trim()?(Number(w==null?void 0:w.expiryMonth)>12||Number(w==null?void 0:w.expiryMonth)<1)&&(u.expiryMonth="Invalid Expiration Month."):u.expiryMonth="Expiration month is required",(j=w==null?void 0:w.expiryYear)!=null&&j.trim()?((V=w==null?void 0:w.expiryYear)==null?void 0:V.trim().length)!==4||Number(w==null?void 0:w.expiryYear)<2025?u.expiryYear="Invalid Expiration Year.":(isNaN(E)||E<1||E>12||Y.length!==4)&&(u.expiryMonth="Invalid Expiration Date."):u.expiryYear="Expiration year is required",(g=w==null?void 0:w.cvv)!=null&&g.trim()||(u.cvv="CVC is required"),w!=null&&w.expiryMonth&&(w!=null&&w.expiryYear)&&w.expiryMonth.length<=2&&w.expiryYear.length===4){let c=parseInt(w.expiryMonth,10),h=parseInt(w.expiryYear,10),v=new Date,K=v.getMonth()+1,PA=v.getFullYear();(h<PA||h===PA&&c<K)&&(u.expiryMonth="Card is expired")}return e(u),Object.keys(u).length>0},s=async()=>{var u,w,E;QA();try{let Y={fractalpayPublicKey:A==null?void 0:A.merchantPublicKey,customer_id:A==null?void 0:A.customerId,addcard:!0},y=await SB.post(`${HA}get-payment-details`,Y);console.log(y),rA((u=y==null?void 0:y.data)==null?void 0:u.data),(E=(w=y==null?void 0:y.data)==null?void 0:w.data)!=null&&E.paymentGateway||(P(),f("Something went wrong.")),H()}catch(Y){console.log(Y),H(),P(),f("Something went wrong.")}};return tC(()=>{A!=null&&A.merchantPublicKey&&s()},[A==null?void 0:A.merchantPublicKey]),S.createElement(S.Fragment,null,S.createElement(sB,null),S.createElement(Iw,null),S.createElement(AB,{loading:a}),nA&&S.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},S.createElement(vB,{error:nA,onClose:P})),T&&S.createElement(iw,{onClose:R}),!nA&&!T&&S.createElement(S.Fragment,null,S.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},S.createElement("form",{id:"creditCardForm",onSubmit:async u=>{var E,Y,y,l,Z,j,V,g,c,h,v,K,PA,WA,dB,cB;u.preventDefault();let w=uA();if(console.log(D),!w){let KA=DatacapWebToken.validateCardNumber(D==null?void 0:D.cardNumber.replaceAll(" ","")),tB=DatacapWebToken.validateExpirationDate(D==null?void 0:D.expiryMonth,D==null?void 0:D.expiryYear),TA=DatacapWebToken.validateCVV(D==null?void 0:D.cvv),xA={};if(KA||(xA.cardNumber="Invalid card Number"),tB||(xA.expiryMonth="Invalid Expiration Date."),TA||(xA.cvv="Invalid CVV"),e(xA),KA&&TA&&tB){QA();try{let G=async function(t){var X,IA,J,iA,YA;if(console.log(t),t.Error)console.log(t==null?void 0:t.Error),f(t.Error),H();else{let GA={userId:A==null?void 0:A.customerId,cardName:D==null?void 0:D.cardName,zip:D==null?void 0:D.zipCode,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey,token:t};try{let q=await SB.post(`${HA}add-card`,GA);console.log(q);let sA={fractalpayPublicKey:A==null?void 0:A.merchantPublicKey,wallet_id:"",card_number:D==null?void 0:D.cardNumber.replaceAll(" ",""),exp_month:D==null?void 0:D.expiryMonth,exp_year:(X=D==null?void 0:D.expiryYear)==null?void 0:X.slice(-2),cvv:D==null?void 0:D.cvv};try{let gA=await SB.post(`${HA}link-wallet`,sA);console.log(gA),b(!0),H(),I({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),uB(u,"close","")}catch(gA){console.log(gA),H(),f(((J=(IA=gA==null?void 0:gA.response)==null?void 0:IA.data)==null?void 0:J.message)||(gA==null?void 0:gA.message)||"Something went wrong.")}}catch(q){console.log(q),H(),f(((YA=(iA=q==null?void 0:q.response)==null?void 0:iA.data)==null?void 0:YA.message)||(q==null?void 0:q.message)||"Something went wrong.")}}};if((O==null?void 0:O.paymentGateway)===32){let t={method:"POST",redirect:"follow"};try{let X=await SB.post(`${IB}api/v1/widget/generate-session`,t),IA=Number(D==null?void 0:D.expiryYear)%100,J=D==null?void 0:D.cardNumber;J=J==null?void 0:J.replace(/\s+/g,"");let iA=`${J}=${IA}${D==null?void 0:D.expiryMonth} ${D==null?void 0:D.cvv}`,GA=forge.pki.publicKeyFromPem((Y=(E=X==null?void 0:X.data)==null?void 0:E.data)==null?void 0:Y.publicKeyPem).encrypt(iA,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),q=forge.util.encode64(GA),sA={"Content-Type":"application/json","x-app-session-key":(l=(y=X.data)==null?void 0:y.data)==null?void 0:l.session_key},gA=JSON.stringify({enc_track2_data:`${q}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(j=(Z=X==null?void 0:X.data)==null?void 0:Z.data)==null?void 0:j.session_key}`});try{let MA=await SB.post(`${aB}tokenizer/tokenize`,gA,{headers:sA}),zA=JSON.stringify(p(m({},(V=MA==null?void 0:MA.data)==null?void 0:V.data),{cvv:D==null?void 0:D.cvv,cardName:D==null?void 0:D.cardName,zip:D==null?void 0:D.zipCode,userId:A==null?void 0:A.customerId,fractalpayPublicKey:A==null?void 0:A.merchantPublicKey})),SA={"Content-Type":"application/json"};try{let wA=await SB.post(`${HA}add-card`,zA,{headers:SA});console.log(wA),(g=wA==null?void 0:wA.data)!=null&&g.result&&(b(!0),H(),uB(u,"close",""))}catch(wA){H(),f(((h=(c=wA==null?void 0:wA.response)==null?void 0:c.data)==null?void 0:h.message)||(wA==null?void 0:wA.message)||"Something went wrong.")}}catch(MA){H(),f(((K=(v=MA==null?void 0:MA.response)==null?void 0:v.data)==null?void 0:K.message)||(MA==null?void 0:MA.message)||"Something went wrong.")}}catch(X){H(),f(((WA=(PA=X==null?void 0:X.response)==null?void 0:PA.data)==null?void 0:WA.message)||(X==null?void 0:X.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(O==null?void 0:O.dctoken,"creditCardForm",G)}catch(G){H(),f(((cB=(dB=G==null?void 0:G.response)==null?void 0:dB.data)==null?void 0:cB.message)||(G==null?void 0:G.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},S.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},S.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},S.createElement("label",{htmlFor:"cardNumber"},"Card Number"),S.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(D==null?void 0:D.cardNumber)||"",onChange:u=>o(u)}),(n==null?void 0:n.cardNumber)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.cardNumber),S.createElement("br",null)),S.createElement("div",{className:"card-dtl"},S.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"expMonth"},"MM"),S.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(D==null?void 0:D.expiryMonth)||"",onChange:u=>lA("expiryMonth",u.target.value)}),(n==null?void 0:n.expiryMonth)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.expiryMonth)),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"expYear"},"YYYY"),S.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(D==null?void 0:D.expiryYear)||"",onChange:u=>lA("expiryYear",u.target.value)}),(n==null?void 0:n.expiryYear)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.expiryYear)),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"cvc"},"CVC"),S.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(D==null?void 0:D.cvv)||"",onChange:u=>lA("cvv",u.target.value)}),(n==null?void 0:n.cvv)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.cvv)))),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"cardholderName"},"Name on card"),S.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(D==null?void 0:D.cardName)||"",onChange:u=>{let w=u.target.value;/^[a-zA-Z\s]*$/.test(w)&&lA("cardName",w)}}),(n==null?void 0:n.cardName)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.cardName)),S.createElement("div",{className:"form-group",style:{marginTop:"0"}},S.createElement("label",{htmlFor:"zipcode"},"Zip"),S.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(z=D==null?void 0:D.zipCode)!=null?z:"",onChange:u=>lA("zipCode",u.target.value)}),(n==null?void 0:n.zipCode)&&S.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},n==null?void 0:n.zipCode))),S.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import d,{useState as WB}from"react";import KB from"axios";var sw={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import iC from"react";function cw({}){return iC.createElement("style",null,`
1820
1820
  @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap");
1821
1821
 
1822
1822
  .creditformbox {
@@ -1961,4 +1961,4 @@ var mw=Object.defineProperty,bw=Object.defineProperties;var pw=Object.getOwnProp
1961
1961
  color:#ffffff !important;
1962
1962
  }
1963
1963
 
1964
- `)}function iC({session_token:A,callback:a,isloading:x,onCancel:T,showChecks:b,merchantName:nA}){var u;let[f,yA]=WB(!1),[DA,D]=WB(!1),[I,n]=WB(),[e,O]=WB({}),[rA,QA]=WB(""),H=()=>yA(!0),eA=()=>yA(!1),P=()=>{var l,Z,j,V,g,c,h,v;let w={},E=I,Y=parseInt((E==null?void 0:E.expiryMonth)||"",10),y=(E==null?void 0:E.expiryYear)||"";return(l=E==null?void 0:E.firstName)!=null&&l.trim()||(w.firstName="Please enter a first name."),(Z=E==null?void 0:E.lastName)!=null&&Z.trim()||(w.lastName="Please enter a last name."),(j=E==null?void 0:E.cardNumber)!=null&&j.trim()||(w.cardNumber="Please enter a card number."),(V=E==null?void 0:E.expiryMonth)!=null&&V.trim()?(Number(E==null?void 0:E.expiryMonth)>12||Number(E==null?void 0:E.expiryMonth)<1)&&(w.expiryMonth="Invalid Expiration Month."):w.expiryMonth="Please enter an expiry month.",(g=E==null?void 0:E.expiryYear)!=null&&g.trim()?((c=E==null?void 0:E.expiryYear)==null?void 0:c.trim().length)!==4||Number(E==null?void 0:E.expiryYear)<2025?w.expiryYear="Invalid Expiration Year.":(isNaN(Y)||Y<1||Y>12||y.length!==4)&&(w.expiryMonth="Invalid Expiration Date."):w.expiryYear="Please enter an expiry year.",(h=E==null?void 0:E.cvv)!=null&&h.trim()||(w.cvv="Please enter a CVV."),(v=E==null?void 0:E.zipCode)!=null&&v.trim()||(w.zipCode="Please enter a zip code."),b&&!(E!=null&&E.authHold)&&(w.authHold="You must authorize this before proceeding."),b&&!(E!=null&&E.authorise)&&(w.authorise="Please confirm your authorization to continue."),O(w),Object.keys(w).length>0},fA=w=>{let Y=w.target.value.replace(/\D/g,""),y="";/^3[47]/.test(Y)?y=Y.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Z,j,V,g)=>[j,V,g].filter(Boolean).join(" ")):y=Y.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Z,j,V,g,c)=>[j,V,g,c].filter(Boolean).join(" ")),O(l=>p(m({},l),{cardNumber:""})),n(l=>p(m({},l),{cardNumber:y}))},$=(w,E)=>{let Y=w;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(Y)){(E===""||/^[0-9]+$/.test(E))&&(O(l=>p(m({},l),{[Y]:""})),n(l=>p(m({},l),{[Y]:E})));return}O(l=>p(m({},l),{[Y]:""})),n(l=>p(m({},l),{[Y]:E}))},lA=()=>{let w=DatacapWebToken.validateCardNumber(I==null?void 0:I.cardNumber.replaceAll(" ","")),E=DatacapWebToken.validateExpirationDate(I==null?void 0:I.expiryMonth,I==null?void 0:I.expiryYear),Y=DatacapWebToken.validateCVV(I==null?void 0:I.cvv),y={};return w||(y.cardNumber="Invalid card Number"),E||(y.expiryMonth="Invalid Expiration Date."),Y||(y.cvv="Invalid CVV"),O(y),w&&Y&&E},o=async w=>{var E,Y;if(w.Error)QA(w.Error),eA();else{let y={token:w.Token,resp:w},l=await KB.post(`${IB}api/v1/gateway/update/token/${A}`,y);if((l==null?void 0:l.status)==200){let Z=m(m({Token:(Y=(E=l==null?void 0:l.data)==null?void 0:E.data)==null?void 0:Y.gateway_token,Brand:w.Brand,ExpirationMonth:w.ExpirationMonth,ExpirationYear:w.ExpirationYear,Last4:w.Last4,Bin:w.Bin,CVV:w.CVV,postalCode:I==null?void 0:I.zipCode},b&&{authHold:I==null?void 0:I.authHold}),b&&{authorise:I==null?void 0:I.authorise});eA(),a(Z)}}},uA=async()=>{var w,E,Y,y,l,Z,j,V,g,c;try{let h={method:"POST",redirect:"follow"},v=await KB.post(`${IB}api/v1/widget/generate-session`,h),K=Number(I==null?void 0:I.expiryYear)%100,WA=`${(w=I==null?void 0:I.cardNumber)==null?void 0:w.replace(/\s+/g,"")}=${K}${I==null?void 0:I.expiryMonth} ${I==null?void 0:I.cvv}`,cB=forge.pki.publicKeyFromPem((Y=(E=v==null?void 0:v.data)==null?void 0:E.data)==null?void 0:Y.publicKeyPem).encrypt(WA,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),KA=forge.util.encode64(cB),tB={"Content-Type":"application/json","x-app-session-key":(l=(y=v.data)==null?void 0:y.data)==null?void 0:l.session_key},TA=JSON.stringify({enc_track2_data:KA,algorithm:"RSAES_OAEP_SHA_1",session_key:(j=(Z=v==null?void 0:v.data)==null?void 0:Z.data)==null?void 0:j.session_key}),xA=await KB.post(`${aB}tokenizer/tokenize`,TA,{headers:tB});if((xA==null?void 0:xA.status)==200){let G=(g=(V=xA==null?void 0:xA.data)==null?void 0:V.data)==null?void 0:g.token;try{let t=await KB.post(`${IB}api/v1/gateway/verify-and-save/${A}`,{token:G});if((t==null?void 0:t.status)==200){let X=(c=t==null?void 0:t.data)==null?void 0:c.data,IA={Token:X.gateway_token,Brand:X.card_data.brand,ExpirationMonth:X.card_data.expire_mm,ExpirationYear:X.card_data.expire_yy,Last4:X.card_data.last4,Bin:X.card_data.bin,postalCode:I==null?void 0:I.zipCode};eA(),a(IA)}}catch(t){console.log(t,"error"),eA()}}}catch(h){console.log(h,"eroror")}},s=async w=>{var y,l,Z,j,V,g,c;if(w.preventDefault(),!(P()||!lA())){H();try{let h=await KB.get(`${IB}api/v1/gateway/token/${A}`);if((h==null?void 0:h.status)==200){let v=(l=(y=h==null?void 0:h.data)==null?void 0:y.data)==null?void 0:l.gateway_token;((j=(Z=h==null?void 0:h.data)==null?void 0:Z.data)==null?void 0:j.paymentGateway)==((V=sw)==null?void 0:V.FRACTALKEY)?await uA():DatacapWebToken.requestToken(v,"creditCardForm",o)}}catch(h){eA(),QA(((c=(g=h==null?void 0:h.response)==null?void 0:g.data)==null?void 0:c.message)||"Something went wrong!")}}},NA=()=>{QA("")},z=()=>{QA(""),n({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1}),T()};return d.createElement(d.Fragment,null,d.createElement(sB,null),d.createElement(cw,null),d.createElement(AB,{loading:f||x}),rA&&d.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},d.createElement(vB,{error:rA,onClose:NA})),!rA&&d.createElement("div",{className:"creditformbox"},d.createElement("form",{id:"creditCardForm",onSubmit:s},d.createElement("div",{className:"name-row"},d.createElement("div",{className:"form-group"},d.createElement("label",null," First Name ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(I==null?void 0:I.firstName)||"",onChange:w=>$("firstName",w.target.value)}),(e==null?void 0:e.firstName)&&d.createElement("small",{className:"error"},e==null?void 0:e.firstName)),d.createElement("div",{className:"form-group"},d.createElement("label",null," Last Name ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(I==null?void 0:I.lastName)||"",onChange:w=>$("lastName",w.target.value)}),(e==null?void 0:e.lastName)&&d.createElement("small",{className:"error"},e==null?void 0:e.lastName))),d.createElement("div",{className:"form-pay-row"},d.createElement("div",{className:"form-group"},d.createElement("label",null," Card Number ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(I==null?void 0:I.cardNumber)||"",onChange:w=>fA(w)}),(e==null?void 0:e.cardNumber)&&d.createElement("small",{className:"error"},e==null?void 0:e.cardNumber))),d.createElement("div",{className:"card-pay-row"},d.createElement("div",{className:"form-group"},d.createElement("label",null," Exp Month ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(I==null?void 0:I.expiryMonth)||"",onChange:w=>$("expiryMonth",w.target.value)}),(e==null?void 0:e.expiryMonth)&&d.createElement("small",{className:"error"},e==null?void 0:e.expiryMonth)),d.createElement("div",{className:"form-group"},d.createElement("label",null," Exp Year ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(I==null?void 0:I.expiryYear)||"",onChange:w=>$("expiryYear",w.target.value)}),(e==null?void 0:e.expiryYear)&&d.createElement("small",{className:"error"},e==null?void 0:e.expiryYear)),d.createElement("div",{className:"form-group"},d.createElement("label",null," CVV ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(I==null?void 0:I.cvv)||"",onChange:w=>$("cvv",w.target.value)}),(e==null?void 0:e.cvv)&&d.createElement("small",{className:"error"},e==null?void 0:e.cvv)),d.createElement("div",{className:"form-group"},d.createElement("label",null," Zip ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(u=I==null?void 0:I.zipCode)!=null?u:"",onChange:w=>$("zipCode",w.target.value)}),(e==null?void 0:e.zipCode)&&d.createElement("small",{className:"error"},e==null?void 0:e.zipCode))),b&&d.createElement(d.Fragment,null,d.createElement("div",{className:"checks-row"},d.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(I!=null&&I.authHold),onChange:w=>$("authHold",w.target.checked)}),d.createElement("label",{htmlFor:"authHold",className:"form-check-label"},"To securely save your card on file, we will place a temporary authorization hold of $1.00. This is not a charge and will be released by your card issuer shortly after verification.")),(e==null?void 0:e.authHold)&&d.createElement("small",{className:"check-error"},e==null?void 0:e.authHold),d.createElement("div",{className:"checks-row "},d.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(I!=null&&I.authorise),onChange:w=>$("authorise",w.target.checked)}),d.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},DA?d.createElement(d.Fragment,null,d.createElement("span",null,"By providing your payment information, you authorize"," ",d.createElement("strong",null,nA),", a Sky Systemz merchant, to securely store your card on file for future payments. Your card information will be encrypted and stored in compliance with PCI-DSS (Payment Card Industry Data Security Standard) regulations using Sky Systemz\u2019s secure payment technology. This information will be used solely for transactions you authorize with"," ",d.createElement("strong",null,nA),". You may request the removal of your stored payment information at any time by contacting"," ",d.createElement("strong",null,nA)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",d.createElement("a",{href:"#",onClick:w=>{w.preventDefault(),D(!1)}},"See less ..."))):d.createElement(d.Fragment,null,d.createElement("span",null,"By providing your payment information, you authorize ",nA,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),d.createElement("a",{href:"#",onClick:w=>{w.preventDefault(),D(!0)}},"See more ...")))),(e==null?void 0:e.authorise)&&d.createElement("small",{className:"check-error"},e==null?void 0:e.authorise)),d.createElement("div",{className:"button-row"},d.createElement("button",{className:"cancelbtn",type:"button",onClick:z},"Cancel"),d.createElement("button",{className:"savebtn",type:"submit"},"Save")))))}export{nC as AddCard,iC as AddCardSky,cC as GetPaymentPage,HC as PreAuthPayment,Tw as RequestPayment,Ww as RequestPreAuthPayment};
1964
+ `)}function sC({session_token:A,callback:a,isloading:x,onCancel:T,showChecks:b,merchantName:nA}){var u;let[f,yA]=WB(!1),[DA,D]=WB(!1),[I,n]=WB(),[e,O]=WB({}),[rA,QA]=WB(""),H=()=>yA(!0),eA=()=>yA(!1),P=()=>{var l,Z,j,V,g,c,h,v;let w={},E=I,Y=parseInt((E==null?void 0:E.expiryMonth)||"",10),y=(E==null?void 0:E.expiryYear)||"";return(l=E==null?void 0:E.firstName)!=null&&l.trim()||(w.firstName="Please enter a first name."),(Z=E==null?void 0:E.lastName)!=null&&Z.trim()||(w.lastName="Please enter a last name."),(j=E==null?void 0:E.cardNumber)!=null&&j.trim()||(w.cardNumber="Please enter a card number."),(V=E==null?void 0:E.expiryMonth)!=null&&V.trim()?(Number(E==null?void 0:E.expiryMonth)>12||Number(E==null?void 0:E.expiryMonth)<1)&&(w.expiryMonth="Invalid Expiration Month."):w.expiryMonth="Please enter an expiry month.",(g=E==null?void 0:E.expiryYear)!=null&&g.trim()?((c=E==null?void 0:E.expiryYear)==null?void 0:c.trim().length)!==4||Number(E==null?void 0:E.expiryYear)<2025?w.expiryYear="Invalid Expiration Year.":(isNaN(Y)||Y<1||Y>12||y.length!==4)&&(w.expiryMonth="Invalid Expiration Date."):w.expiryYear="Please enter an expiry year.",(h=E==null?void 0:E.cvv)!=null&&h.trim()||(w.cvv="Please enter a CVV."),(v=E==null?void 0:E.zipCode)!=null&&v.trim()||(w.zipCode="Please enter a zip code."),b&&!(E!=null&&E.authHold)&&(w.authHold="You must authorize this before proceeding."),b&&!(E!=null&&E.authorise)&&(w.authorise="Please confirm your authorization to continue."),O(w),Object.keys(w).length>0},fA=w=>{let Y=w.target.value.replace(/\D/g,""),y="";/^3[47]/.test(Y)?y=Y.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Z,j,V,g)=>[j,V,g].filter(Boolean).join(" ")):y=Y.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Z,j,V,g,c)=>[j,V,g,c].filter(Boolean).join(" ")),O(l=>p(m({},l),{cardNumber:""})),n(l=>p(m({},l),{cardNumber:y}))},R=(w,E)=>{let Y=w;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(Y)){(E===""||/^[0-9]+$/.test(E))&&(O(l=>p(m({},l),{[Y]:""})),n(l=>p(m({},l),{[Y]:E})));return}O(l=>p(m({},l),{[Y]:""})),n(l=>p(m({},l),{[Y]:E}))},lA=()=>{let w=DatacapWebToken.validateCardNumber(I==null?void 0:I.cardNumber.replaceAll(" ","")),E=DatacapWebToken.validateExpirationDate(I==null?void 0:I.expiryMonth,I==null?void 0:I.expiryYear),Y=DatacapWebToken.validateCVV(I==null?void 0:I.cvv),y={};return w||(y.cardNumber="Invalid card Number"),E||(y.expiryMonth="Invalid Expiration Date."),Y||(y.cvv="Invalid CVV"),O(y),w&&Y&&E},o=async w=>{var E,Y;if(w.Error)QA(w.Error),eA();else{let y={token:w.Token,resp:w},l=await KB.post(`${IB}api/v1/gateway/update/token/${A}`,y);if((l==null?void 0:l.status)==200){let Z=m(m({Token:(Y=(E=l==null?void 0:l.data)==null?void 0:E.data)==null?void 0:Y.gateway_token,Brand:w.Brand,ExpirationMonth:w.ExpirationMonth,ExpirationYear:w.ExpirationYear,Last4:w.Last4,Bin:w.Bin,CVV:w.CVV,postalCode:I==null?void 0:I.zipCode},b&&{authHold:I==null?void 0:I.authHold}),b&&{authorise:I==null?void 0:I.authorise});eA(),a(Z)}}},uA=async()=>{var w,E,Y,y,l,Z,j,V,g,c;try{let h={method:"POST",redirect:"follow"},v=await KB.post(`${IB}api/v1/widget/generate-session`,h),K=Number(I==null?void 0:I.expiryYear)%100,WA=`${(w=I==null?void 0:I.cardNumber)==null?void 0:w.replace(/\s+/g,"")}=${K}${I==null?void 0:I.expiryMonth} ${I==null?void 0:I.cvv}`,cB=forge.pki.publicKeyFromPem((Y=(E=v==null?void 0:v.data)==null?void 0:E.data)==null?void 0:Y.publicKeyPem).encrypt(WA,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),KA=forge.util.encode64(cB),tB={"Content-Type":"application/json","x-app-session-key":(l=(y=v.data)==null?void 0:y.data)==null?void 0:l.session_key},TA=JSON.stringify({enc_track2_data:KA,algorithm:"RSAES_OAEP_SHA_1",session_key:(j=(Z=v==null?void 0:v.data)==null?void 0:Z.data)==null?void 0:j.session_key}),xA=await KB.post(`${aB}tokenizer/tokenize`,TA,{headers:tB});if((xA==null?void 0:xA.status)==200){let G=(g=(V=xA==null?void 0:xA.data)==null?void 0:V.data)==null?void 0:g.token;try{let t=await KB.post(`${IB}api/v1/gateway/verify-and-save/${A}`,{token:G});if((t==null?void 0:t.status)==200){let X=(c=t==null?void 0:t.data)==null?void 0:c.data,IA={Token:X.gateway_token,Brand:X.card_data.brand,ExpirationMonth:X.card_data.expire_mm,ExpirationYear:X.card_data.expire_yy,Last4:X.card_data.last4,Bin:X.card_data.bin,postalCode:I==null?void 0:I.zipCode};eA(),a(IA)}}catch(t){console.log(t,"error"),eA()}}}catch(h){console.log(h,"eroror")}},s=async w=>{var y,l,Z,j,V,g,c;if(w.preventDefault(),!(P()||!lA())){H();try{let h=await KB.get(`${IB}api/v1/gateway/token/${A}`);if((h==null?void 0:h.status)==200){let v=(l=(y=h==null?void 0:h.data)==null?void 0:y.data)==null?void 0:l.gateway_token;((j=(Z=h==null?void 0:h.data)==null?void 0:Z.data)==null?void 0:j.paymentGateway)==((V=sw)==null?void 0:V.FRACTALKEY)?await uA():DatacapWebToken.requestToken(v,"creditCardForm",o)}}catch(h){eA(),QA(((c=(g=h==null?void 0:h.response)==null?void 0:g.data)==null?void 0:c.message)||"Something went wrong!")}}},NA=()=>{QA("")},z=()=>{QA(""),n({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1}),T()};return d.createElement(d.Fragment,null,d.createElement(sB,null),d.createElement(cw,null),d.createElement(AB,{loading:f||x}),rA&&d.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},d.createElement(vB,{error:rA,onClose:NA})),!rA&&d.createElement("div",{className:"creditformbox"},d.createElement("form",{id:"creditCardForm",onSubmit:s},d.createElement("div",{className:"name-row"},d.createElement("div",{className:"form-group"},d.createElement("label",null," First Name ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(I==null?void 0:I.firstName)||"",onChange:w=>R("firstName",w.target.value)}),(e==null?void 0:e.firstName)&&d.createElement("small",{className:"error"},e==null?void 0:e.firstName)),d.createElement("div",{className:"form-group"},d.createElement("label",null," Last Name ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(I==null?void 0:I.lastName)||"",onChange:w=>R("lastName",w.target.value)}),(e==null?void 0:e.lastName)&&d.createElement("small",{className:"error"},e==null?void 0:e.lastName))),d.createElement("div",{className:"form-pay-row"},d.createElement("div",{className:"form-group"},d.createElement("label",null," Card Number ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(I==null?void 0:I.cardNumber)||"",onChange:w=>fA(w)}),(e==null?void 0:e.cardNumber)&&d.createElement("small",{className:"error"},e==null?void 0:e.cardNumber))),d.createElement("div",{className:"card-pay-row"},d.createElement("div",{className:"form-group"},d.createElement("label",null," Exp Month ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(I==null?void 0:I.expiryMonth)||"",onChange:w=>R("expiryMonth",w.target.value)}),(e==null?void 0:e.expiryMonth)&&d.createElement("small",{className:"error"},e==null?void 0:e.expiryMonth)),d.createElement("div",{className:"form-group"},d.createElement("label",null," Exp Year ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(I==null?void 0:I.expiryYear)||"",onChange:w=>R("expiryYear",w.target.value)}),(e==null?void 0:e.expiryYear)&&d.createElement("small",{className:"error"},e==null?void 0:e.expiryYear)),d.createElement("div",{className:"form-group"},d.createElement("label",null," CVV ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(I==null?void 0:I.cvv)||"",onChange:w=>R("cvv",w.target.value)}),(e==null?void 0:e.cvv)&&d.createElement("small",{className:"error"},e==null?void 0:e.cvv)),d.createElement("div",{className:"form-group"},d.createElement("label",null," Zip ",d.createElement("span",{className:"text-danger"},"*")),d.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(u=I==null?void 0:I.zipCode)!=null?u:"",onChange:w=>R("zipCode",w.target.value)}),(e==null?void 0:e.zipCode)&&d.createElement("small",{className:"error"},e==null?void 0:e.zipCode))),b&&d.createElement(d.Fragment,null,d.createElement("div",{className:"checks-row"},d.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(I!=null&&I.authHold),onChange:w=>R("authHold",w.target.checked)}),d.createElement("label",{htmlFor:"authHold",className:"form-check-label"},"To securely save your card on file, we will place a temporary authorization hold of $1.00. This is not a charge and will be released by your card issuer shortly after verification.")),(e==null?void 0:e.authHold)&&d.createElement("small",{className:"check-error"},e==null?void 0:e.authHold),d.createElement("div",{className:"checks-row "},d.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(I!=null&&I.authorise),onChange:w=>R("authorise",w.target.checked)}),d.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},DA?d.createElement(d.Fragment,null,d.createElement("span",null,"By providing your payment information, you authorize"," ",d.createElement("strong",null,nA),", a Sky Systemz merchant, to securely store your card on file for future payments. Your card information will be encrypted and stored in compliance with PCI-DSS (Payment Card Industry Data Security Standard) regulations using Sky Systemz\u2019s secure payment technology. This information will be used solely for transactions you authorize with"," ",d.createElement("strong",null,nA),". You may request the removal of your stored payment information at any time by contacting"," ",d.createElement("strong",null,nA)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",d.createElement("a",{href:"#",onClick:w=>{w.preventDefault(),D(!1)}},"See less ..."))):d.createElement(d.Fragment,null,d.createElement("span",null,"By providing your payment information, you authorize ",nA,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),d.createElement("a",{href:"#",onClick:w=>{w.preventDefault(),D(!0)}},"See more ...")))),(e==null?void 0:e.authorise)&&d.createElement("small",{className:"check-error"},e==null?void 0:e.authorise)),d.createElement("div",{className:"button-row"},d.createElement("button",{className:"cancelbtn",type:"button",onClick:z},"Cancel"),d.createElement("button",{className:"savebtn",type:"submit"},"Save")))))}export{rC as AddCard,sC as AddCardSky,OC as GetPaymentPage,hC as PreAuthPayment,Tw as RequestPayment,Ww as RequestPreAuthPayment};