@fractalpay/fractalpay-next-test 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,340 @@
1
- import{a as P,b as L,c as ei,d as bn,e as Yt,f as be,g as Kt,h as Ie,i as en,l as Wt,m as pn,n as Ln,o as qe,p as Zn,q as tn,r as nn,s as an,t as xn,u as mn,v as Wn}from"./chunk-GNTQ2MLR.mjs";import In from"react";var Yn;try{Yn=ei("next/dynamic")}catch(e){Yn=G=>{let R=In.lazy(G);return M=>In.createElement(In.Suspense,{fallback:null},In.createElement(R,P({},M)))}}var Gn=Yn;import"bootstrap/dist/js/bootstrap.bundle.min.js";import v,{useState as rn,useEffect as En}from"react";var ht={namerequired:"Full Name is required",amountrequired:"Amount is required",amountpositive:"Amount should be positive",amountzero:"Amount should not be zero",amountenter:"Please enter an amount",amountvalid:"Please enter a valid amount",phoneoremailrequired:"Phone or Email is required",invalidemail:"Please enter a valid email",invalidemailformat:"Invalid email format",onlylettersallowed:"Only letters are allowed",phonenumberlength:"Phone number should be 10 digits",phonenumberrequired:"Please enter a phone number",phonenumbervalid:"Please enter a valid phone number",phonenumbervalidnumberonly:"Please enter a valid phone number (numbers only)",orderidenter:"Please enter an order ID",orderidrequired:"Order ID is required",networkresponseerror:"Network response was not ok",anerroroccured:"An error occurred. Please try again.",montherror:"Please write month only 1 to 12",fieldrequired:"This field is required",fractalpayclientidrequired:"Fractalpay client key is missing or empty."};import ii from"axios";import{PatternFormat as ai}from"react-number-format";import ti from"react";var ni=e=>ti.createElement("style",null,`
1
+ var Pa=Object.defineProperty,Fa=Object.defineProperties;var Ma=Object.getOwnPropertyDescriptors;var Ti=Object.getOwnPropertySymbols;var la=Object.prototype.hasOwnProperty,da=Object.prototype.propertyIsEnumerable;var sa=(e,h,q)=>h in e?Pa(e,h,{enumerable:!0,configurable:!0,writable:!0,value:q}):e[h]=q,k=(e,h)=>{for(var q in h||(h={}))la.call(h,q)&&sa(e,q,h[q]);if(Ti)for(var q of Ti(h))da.call(h,q)&&sa(e,q,h[q]);return e},M=(e,h)=>Fa(e,Ma(h));var di=(e,h)=>{var q={};for(var $ in e)la.call(e,$)&&h.indexOf($)<0&&(q[$]=e[$]);if(e!=null&&Ti)for(var $ of Ti(e))h.indexOf($)<0&&da.call(e,$)&&(q[$]=e[$]);return q};var La=(e,h)=>()=>(h||e((h={exports:{}}).exports,h),h.exports);var ca=La((Vr,Ba)=>{Ba.exports={name:"@fractalpay/fractalpay-next-test",version:"0.0.22",private:!1,scripts:{dev:"next dev -p 4001",build:"next build",start:"next start",lint:"next lint",bundle:"tsup src/app/index.ts"},dependencies:{"@stripe/react-stripe-js":"^5.3.0","@stripe/stripe-js":"^8.3.0","@types/yup":"^0.29.14",axios:"^1.8.1",bootstrap:"^5.3.3","credit-card-type":"^10.0.1",formik:"^2.4.6","node-forge":"^1.3.1","react-bootstrap":"^2.10.5","react-bs-datatable":"^3.15.0","react-datepicker":"^7.5.0","react-icons":"^5.5.0","react-number-format":"^5.4.3","react-toastify":"^10.0.6","socket.io-client":"^4.8.1","styled-components":"^6.1.15",sweetalert2:"^11.22.0",yup:"^1.6.1"},peerdependencies:{next:"15.0.5",react:">=18.0.0 <20.0.0","react-dom":">=18.0.0 <20.0.0"},devDependencies:{"@types/estree":"^1.0.8","@types/node":"^20","@types/node-forge":"^1.3.11","@types/react":"^18","@types/react-dom":"^18",autoprefixer:"^10.4.20","credit-card-type":"^10.0.1",eslint:"^8","eslint-config-next":"15.0.3",next:"^15.0.5",react:"^18.3.1","react-bs-datatable":"^3.15.0","react-datepicker":"^7.5.0","react-dom":"^18.3.1","react-toastify":"^10.0.6",tsup:"^8.4.0",typescript:"^5"},author:"Mukul",license:"MIT",keywords:["nextjs","next","typescript","tailwindcss"],main:"dist/index.js",publishConfig:{access:"public"}}});import"bootstrap/dist/js/bootstrap.bundle.min.js";import T,{useState as Gn,useEffect as pa}from"react";import Qn from"react";import Aa from"react";var za=e=>Aa.createElement("style",null,`
2
+
3
+ .loader {
4
+ position: fixed; /* Fixed position to cover the viewport */
5
+ top: 0;
6
+ left: 0;
7
+ width: 100%;
8
+ height: 100%;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ /* background: rgba(255, 255, 0, 0.01); Adjust the blur effect */
13
+ background-color: rgba(31, 29, 29, 0.52); /* Semi-transparent black background */
14
+
15
+ backdrop-filter: blur(.5px); /* Blur effect */
16
+ z-index: 999999999999 !important; /* Ensure it's on top of other elements */
17
+ transform: translate(0%, 0%) !important
18
+ }
19
+
20
+ .lds-ellipsis {
21
+ display: inline-block;
22
+ position: relative;
23
+ width: 80px;
24
+ height: 80px;
25
+ }
26
+
27
+ .lds-ellipsis div {
28
+ position: absolute;
29
+ top: 33px;
30
+ width: 13px;
31
+ height: 13px;
32
+ border-radius: 50%;
33
+ background: #000;
34
+ animation-timing-function: cubic-bezier(0, 1, 1, 0);
35
+ }
36
+
37
+ .lds-ellipsis div:nth-child(1) {
38
+ left: 8px;
39
+ animation: lds-ellipsis1 0.6s infinite;
40
+ }
41
+
42
+ .lds-ellipsis div:nth-child(2) {
43
+ left: 8px;
44
+ animation: lds-ellipsis2 0.6s infinite;
45
+ }
46
+
47
+ .lds-ellipsis div:nth-child(3) {
48
+ left: 32px;
49
+ animation: lds-ellipsis2 0.6s infinite;
50
+ }
51
+
52
+ .lds-ellipsis div:nth-child(4) {
53
+ left: 56px;
54
+ animation: lds-ellipsis3 0.6s infinite;
55
+ }
56
+
57
+ @keyframes lds-ellipsis1 {
58
+ 0% {
59
+ transform: scale(0);
60
+ }
61
+ 100% {
62
+ transform: scale(1);
63
+ }
64
+ }
65
+
66
+ @keyframes lds-ellipsis2 {
67
+ 0% {
68
+ transform: translate(0, 0);
69
+ }
70
+ 100% {
71
+ transform: translate(24px, 0);
72
+ }
73
+ }
74
+
75
+ @keyframes lds-ellipsis3 {
76
+ 0% {
77
+ transform: scale(1);
78
+ }
79
+ 100% {
80
+ transform: scale(0);
81
+ }
82
+ }
83
+
84
+ `),ma=za;var Ia=e=>Qn.createElement(Qn.Fragment,null,Qn.createElement(ma,null),(e==null?void 0:e.loading)&&Qn.createElement("div",{className:"loader"},Qn.createElement("div",{className:"lds-ellipsis"},Qn.createElement("div",null),Qn.createElement("div",null),Qn.createElement("div",null),Qn.createElement("div",null)))),mn=Ia;var{name:qi}=ca(),D="https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/";qi==="@fractalpay/fractalpay-next-dev"?(Le="https://dev-sky-node.fractalpay.com/",tt="https://dev-widget.fractalpay.com/",cn="https://api-dev.merchant-trends.com/",ni="https://token-cert.dcap.com/v1/client",ii="pk_test_51RH5Wc2SlJvyNZ80hpUDy88r4rVdpijfKbNaWaUyQEE6rOrPmG2JQyAj7G5amBD5z5daC56WaeT4jfNhrrPcGOEP00UyKu6AOw"):qi==="@fractalpay/fractalpay-next-test"?(Le="https://testapi.fractalpay.com/",tt="https://staging-widget.fractalpay.com/",cn="https://api-dev.merchant-trends.com/",ni="https://token-cert.dcap.com/v1/client",ii="pk_test_51RH5Wc2SlJvyNZ80hpUDy88r4rVdpijfKbNaWaUyQEE6rOrPmG2JQyAj7G5amBD5z5daC56WaeT4jfNhrrPcGOEP00UyKu6AOw"):qi==="@fractalpay/fractalpay-next-testprod"?(Le="https://sky-node-prod.fractalpay.com/",tt="https://widget-prod.fractalpay.com/",cn="https://api.merchant-trends.com/",ni="https://token.dcap.com/v1/client",ii="pk_live_51RH5WXCZ90rBGeaYwqmjWqgUmudTgxL6uKOE1keu617jvRx9OvW2ke6zGf6SKgv4ixsBLcIPQ4sQIEhp8MgBX39500CqULxOPB"):qi==="@fractalpay/fractalpay-next"?(Le="https://api.fractalpay.com/",tt="https://widget.fractalpay.com/",cn="https://api.merchant-trends.com/",ni="https://token.dcap.com/v1/client",ii="pk_live_51RH5WXCZ90rBGeaYwqmjWqgUmudTgxL6uKOE1keu617jvRx9OvW2ke6zGf6SKgv4ixsBLcIPQ4sQIEhp8MgBX39500CqULxOPB"):(tt="http://localhost:8082/",Le="http://localhost:8081/",cn="https://api-dev.merchant-trends.com/",ni="https://token-cert.dcap.com/v1/client",ii="pk_test_51RH5Wc2SlJvyNZ80hpUDy88r4rVdpijfKbNaWaUyQEE6rOrPmG2JQyAj7G5amBD5z5daC56WaeT4jfNhrrPcGOEP00UyKu6AOw");var Le,tt,cn,ni,ii;var Qt={namerequired:"Full Name is required",amountrequired:"Amount is required",amountpositive:"Amount should be positive",amountzero:"Amount should not be zero",amountenter:"Please enter an amount",amountvalid:"Please enter a valid amount",phoneoremailrequired:"Phone or Email is required",invalidemail:"Please enter a valid email",invalidemailformat:"Invalid email format",onlylettersallowed:"Only letters are allowed",phonenumberlength:"Phone number should be 10 digits",phonenumberrequired:"Please enter a phone number",phonenumbervalid:"Please enter a valid phone number",phonenumbervalidnumberonly:"Please enter a valid phone number (numbers only)",orderidenter:"Please enter an order ID",orderidrequired:"Order ID is required",networkresponseerror:"Network response was not ok",anerroroccured:"An error occurred. Please try again.",montherror:"Please write month only 1 to 12",fieldrequired:"This field is required",fractalpayclientidrequired:"Fractalpay client key is missing or empty."};import Ni from"react";import Ta from"react";var qa=e=>Ta.createElement("style",null,`
85
+ .fractal-input::placeholder {
86
+ color: #35254D;
87
+ opacity: 1;
88
+ font-size: 15px;
89
+ }
90
+
91
+ .fractal-input::-ms-input-placeholder {
92
+ color: #35254D;
93
+ font-size: 15px;
94
+ }
95
+
96
+ .trigger{
97
+ text-align: center;
98
+ padding: 7px 13px;
99
+ background: #3e3e3e;
100
+ color: #fff;
101
+ font-size: 15px;
102
+ outline: none;
103
+ border: none;
104
+ border-radius: 5px;
105
+ font-family: cursive;
106
+ }
107
+
108
+ // .fractal-popup {
109
+ // position: fixed;
110
+ // z-index: 9999;
111
+ // top: 0;
112
+ // right: 0;
113
+ // bottom: 0;
114
+ // left: 0;
115
+ // width: 100%;
116
+ // // max-width:810px;
117
+ // height: 100%;
118
+ // background-color: rgba(0, 0, 0, 0.5);
119
+ // transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
120
+ // display: flex;
121
+ // justify-content: center;
122
+ // align-items: center;
123
+ // overflow:auto;
124
+ // }
125
+
126
+ .fractal-popup {
127
+ position: fixed;
128
+ z-index: 1050;
129
+ left: 0;
130
+ top: 0;
131
+ width: 100%;
132
+ height: 100%;
133
+ overflow: auto;
134
+ background-color: rgba(0, 0, 0, 0.8);
135
+ // padding:20px
136
+ }
137
+
138
+ .fractal-popup-content {
139
+ margin:20px auto !important;
140
+ transform :none;
141
+ background-color: white;
142
+ padding:20px;
143
+ border-radius: 0.5rem;
144
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
145
+ box-sizing: border-box;
146
+ position: relative;
147
+ // min-height : 585px;
148
+ max-width:810px;
149
+ width:90vw
150
+
151
+ }
152
+
153
+
154
+ // @media only screen and (min-width: 600px){
155
+ // .fractal-popup-content {
156
+ // max-width:810px;
157
+ // }
158
+ // }
159
+ // @media only screen and (max-width: 600px){
160
+ // .fractal-popup-content {
161
+ // width: 350px;
162
+ // }
163
+ // }
164
+ // @media only screen and (max-width: 450px){
165
+ // .fractal-popup-content {
166
+ // width: 300px;
167
+ // }
168
+ // }
169
+ .close-popup {
170
+ max-height:25px;
171
+ width:25px;
172
+ height: 25px;
173
+ color: #999;
174
+ position: absolute;
175
+ top: 2px;
176
+ right: 4px;
177
+ z-index: 7;
178
+ text-align: center;
179
+ cursor: pointer;
180
+ border-radius: 0.25rem;
181
+ font-size: 30px;
182
+ line-height: 30px;
183
+ display: flex;
184
+ align-items: center;
185
+ justify-content: center;
186
+ }
187
+
188
+ .close-popup:hover {
189
+ color: #000;
190
+ }
191
+
192
+ .fractal-inpt-list {
193
+ margin-bottom: 15px;
194
+ }
195
+
196
+ .fractal-label {
197
+ color: #727272;
198
+ margin-bottom: 3px;
199
+ font-family: "Inter", sans-serif;
200
+ font-weight: 500;
201
+ font-size: 12px;
202
+ display: block;
203
+ text-align: left;
204
+ }
205
+
206
+ .fractal-input {
207
+ display: block;
208
+ width: 100%;
209
+ padding: .320rem .75rem;
210
+ font-size: 1rem;
211
+ font-weight: 400;
212
+ line-height: 1.5;
213
+ color: #35254D;
214
+ appearance: none;
215
+ background-color:#ffffff;
216
+ background-clip: padding-box;
217
+ border:1px solid #dee2e6;
218
+ border-radius: 0.375rem;
219
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
220
+ }
221
+
222
+ .fractal-input:focus {border:#86b7fe 1px solid; outline: none;}
223
+
224
+ .fractal-group {
225
+ position: relative;
226
+ display: flex;
227
+ align-items: stretch;
228
+ width: 100%;
229
+ }
230
+
231
+ .fractal-group-icons {
232
+ display: flex;
233
+ align-items: center;
234
+ padding: 0.375rem 0.75rem;
235
+ font-size: 1rem;
236
+ font-weight: 400;
237
+ line-height: 1.5;
238
+ color: #212529;
239
+ text-align: center;
240
+ white-space: nowrap;
241
+ background-color: #f8f9fa;
242
+ border:#dee2e6 1px solid;
243
+ border-radius: 0.375rem 0 0 0.375rem ;
244
+ }
245
+
246
+ .fractal-group .fractal-input{
247
+ border-radius:0 0.375rem 0.375rem 0;
248
+ }
249
+
250
+
251
+ .pay-button {
252
+ outline: 0;
253
+ height: 46px;
254
+ font-size: 16px;
255
+ background: #727272;
256
+ border: none;
257
+ display: block;
258
+ color: #fff;
259
+ width: 100%;
260
+ border-radius: 180px;
261
+ margin: 10px 0;
262
+ text-decoration: none;
263
+ cursor:pointer,
264
+ font-family:
265
+ }
266
+
267
+ .pay-button:hover, .pay-button:focus {background: #222; color: #fff; cursor:pointer}
268
+
269
+ .fractal-powerd-by {
270
+ display: flex;
271
+ font-size: 12px;
272
+ text-align: center;
273
+ align-items: center;
274
+ justify-content: center;
275
+ margin: 5px 0 20px 0;
276
+ }
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+ /* ................................................................ */
285
+
286
+ .fractal-pay-popup {
287
+ position: fixed;
288
+ z-index: 9999;
289
+ top: 0;
290
+ right: 0;
291
+ bottom: 0;
292
+ left: 0;
293
+ width: 100%;
294
+ height: 100%;
295
+ background-color: rgba(0, 0, 0, 0.5);
296
+ transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
297
+ display: flex;
298
+ justify-content: center;
299
+ align-items: center;
300
+ }
301
+
302
+ .fractal-pay-popup-content {
303
+ background-color: white;
304
+ padding:0px;
305
+ border-radius: 0.5rem;
306
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
307
+ box-sizing: border-box;
308
+ position: relative;
309
+ height: 100%;
310
+ max-height:90%;
311
+ overflow: hidden;
312
+ }
313
+ .fractal-pay-popup-content iframe{height: 100% !important; }
314
+ .fractal-pay-popup-content iframe body{overflow: hidden;}
315
+ @media only screen and (min-width: 768px){
316
+ .fractal-pay-popup-content iframe{width: 768px;}
317
+ .fractal-pay-popup-content {
318
+ width: 750px;
319
+
320
+ }
321
+ }
322
+ @media only screen and (max-width: 600px){
323
+ .fractal-pay-popup-content {
324
+ width: 350px;
325
+ }
326
+ }
327
+ @media only screen and (max-width: 450px){
328
+ .fractal-pay-popup-content {
329
+ width: 300px;
330
+ }
331
+ }
332
+
333
+ .request-payment-popup-container {
334
+ padding: 0px !important;
335
+ border-radius: 12px !important;
336
+ }
337
+ `),$i=qa;var $a=({open:e,onClose:h,children:q,maxWidth:$})=>e?Ni.createElement(Ni.Fragment,null,Ni.createElement($i,null),Ni.createElement("div",{className:"fractal-popup"},Ni.createElement("div",{className:"fractal-popup-content request-payment-popup-container",style:{maxWidth:`${$!=null?$:"auto"}`}},q))):null,Pn=$a;import Za from"axios";import{PatternFormat as Wa}from"react-number-format";import Ya from"react";var Ha=e=>Ya.createElement("style",null,`
2
338
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
3
339
  body {
4
340
  font-family: 'Inter', sans-serif !important;
@@ -311,7 +647,7 @@ import{a as P,b as L,c as ei,d as bn,e as Yt,f as be,g as Kt,h as Ie,i as en,l a
311
647
  user-select: none;
312
648
  font-size: 14px;
313
649
  }
314
- `),An=ni;function ri(e){let G=e.merchantPublicKey,R=e==null?void 0:e.discount,ke=e==null?void 0:e.tax,M=e==null?void 0:e.surcharge,[se,I]=rn(!1),[yt,Ye]=rn(!1),[re,ne]=rn({}),[H,_e]=rn(null),[p,b]=rn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:G}),[U,$]=rn(!1),[g,Ae]=rn(void 0),[C,Ce]=rn(""),[Se,oe]=rn(!1),[He,et]=rn(null),at=u=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(u),dt=/[+-]?([0-9]*[.])?[0-9]+/,ot=u=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u),xt=u=>/^[A-Za-z\s]*$/.test(u),Ke=(u,f)=>{let S=(parseFloat(f)||0)/100,le=u/(1+S);return Math.round(le*100)/100};En(()=>{if(e!=null&&e.pass_fee){let u=Ke(e==null?void 0:e.amount,e==null?void 0:e.surcharge);Ae(u)}},[e==null?void 0:e.pass_fee]);let Ot=()=>{I(!1),ne({})},_=()=>I(!0),q=()=>{console.log(He,"apiresponse"),j(He),oe(!1)};function m(){b({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:G}),Ce("")}function j(u){let f={type:"preview.compiledcheck",other:L(P({},u),{status:!0})};window.parent.postMessage(f,"*")}let he=async()=>{if(!(Object.keys(re).length>0)){if(ne({}),!(p!=null&&p.email)&&H&&!at(H)){ne(u=>L(P({},u),{phone:ht.phonenumbervalid}));return}if(c())try{Ye(!0);let u={fractalpayPublicKey:G,amount:C,phone_number:H,order_id:p.order_id,action:"request",name:p.name,email:p.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:R,surcharge:M,tax:ke,require_3ds:e==null?void 0:e.require_3ds,pass_fee:e==null?void 0:e.pass_fee,allow_partial:U},f=await ii.post(`${Ie}create-widget-order`,u);(f==null?void 0:f.status)===200&&(oe(!0),I(!1),m(),et(f==null?void 0:f.data)),Ye(!1)}catch(u){console.log(u),Ye(!1)}}},x=Ie+"images/logo-img.png",i=u=>{let{value:f}=u.target,S=u.target.dataset.token;if(b(L(P({},p),{[S]:f})),S==="name"&&!xt(f)){ne(ce=>L(P({},ce),{[S]:ht.onlylettersallowed}));return}let le=re;S==="email"&&!H&&(delete le.phone,ne(le)),f&&(delete le[S],ne(le)),S==="email"&&!f&&(delete le[S],ne(le))},r=u=>{let{value:f}=u;if(Number(f)>0){let S=re;delete S.amount,ne(S)}Ce(f)},c=()=>{let u={};return C||(u.amount=ht.amountrequired),p.email&&!ot(p==null?void 0:p.email)&&(u.email=ht.invalidemail),!H&&!(p!=null&&p.email)&&(u.phone=ht.phoneoremailrequired),!H&&!(p!=null&&p.email)&&(u.email=ht.phoneoremailrequired),!H&&p.email&&!ot(p==null?void 0:p.email)&&(u.email=ht.invalidemail),e.from==="merchant"&&!p.order_id&&(u.order_id=ht.orderidrequired),ne(u),Object.keys(u).length===0};En(()=>{e&&(b(u=>L(P({},u),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),Ce(e.amount?e.amount:""),_e(e.phone?`${e.phone}`:null))},[e]);let h=u=>{let f=u==null?void 0:u.value;if(f&&(f==null?void 0:f.length)>0&&(f==null?void 0:f.length)!==10){ne(le=>L(P({},le),{phone:ht.phonenumberlength})),_e(f);return}else _e(f);let S=re;delete S.phone,f&&!(p!=null&&p.email)&&delete S.email,ne(S)};function s(u){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(u))}let z=u=>{let f=u.target.checked;$(f)};return v.createElement(v.Fragment,null,v.createElement(An,null),v.createElement(Yt,{loading:yt}),v.createElement(v.Fragment,null,v.createElement("button",{className:"paymentBtn",onClick:_},"Request Payment"),v.createElement(Wt,{open:se,onClose:()=>I(!1),maxWidth:"500px"},v.createElement("div",{style:{maxWidth:"500px"}},v.createElement("div",{className:"request-payment-amount-detail frac-form"},v.createElement("p",{className:"request-payment-merchantname"},"Pay ",e==null?void 0:e.webname),v.createElement("p",{className:"request-payment-amount"},s(e==null?void 0:e.amount)),g&&g>0&&v.createElement("div",{className:"frac-req-cash-discount"},v.createElement("div",{className:"frac-cashlabel"},"Cash Discount :"),v.createElement("div",null,qe((Number(e.amount)-g).toFixed(2)))),(e==null?void 0:e.from)==="merchant"&&v.createElement("p",{className:"request-payment-orderid"},p==null?void 0:p.order_id),v.createElement("span",{className:"request-payment-close-popup",onClick:Ot},v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},v.createElement("g",{clipPath:"url(#clip0_12425_52336)"},v.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"})),v.createElement("defs",null,v.createElement("clipPath",{id:"clip0_12425_52336"},v.createElement("rect",{width:"16",height:"16",fill:"white"})))))),v.createElement("form",{className:"request-payment-input-form"},v.createElement("div",{className:"request-payment-list-div"},v.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),v.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:i,value:p==null?void 0:p.name}),re.name&&v.createElement("small",{className:"request-payment-error-msg"},re.name)),v.createElement("div",{className:"request-payment-list-div"},v.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),v.createElement(ai,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:H,onValueChange:u=>{h(u)}}),re.phone&&v.createElement("small",{className:"request-payment-error-msg"},re.phone)),v.createElement("div",{className:"request-payment-list-div"},v.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),v.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:i,"data-token":"email",value:p==null?void 0:p.email}),re.email&&v.createElement("small",{className:"request-payment-error-msg"},re.email)),v.createElement("div",{className:"partial-toggle-div"},v.createElement("input",{className:"partial-input",type:"checkbox",role:"switch",style:{cursor:"pointer"},checked:U,onChange:u=>z(u),id:"partialSwitch"}),v.createElement("label",{className:"partial-label",htmlFor:"partialSwitch",style:{cursor:"pointer"}},"Allow Partial Payments?")),v.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:he,disabled:yt},yt?"Loading...":"Send Request"),v.createElement("div",{className:"request-payment-fractal-powerd-by"},v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},v.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 ",v.createElement("span",null,"Fractal"),v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"}),v.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"})))))),v.createElement(Wt,{open:Se,onClose:q,maxWidth:"500px"},v.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},v.createElement("div",{className:"request-payment-success-container"},v.createElement("span",{className:"request-payment-close-popup",onClick:q},v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},v.createElement("g",{clipPath:"url(#clip0_12425_52336)"},v.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"})),v.createElement("defs",null,v.createElement("clipPath",{id:"clip0_12425_52336"},v.createElement("rect",{width:"16",height:"16",fill:"white"}))))),v.createElement("div",{className:"request-payment-success-tick-div"},v.createElement("div",{className:"request-payment-success-tick"},v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},v.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"})))),v.createElement("h6",{className:"request-payment-success-text"},"The request ",v.createElement("br",null),"was sent"),v.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),v.createElement("div",{className:"request-payment-success-btn-div"},v.createElement("button",{onClick:q,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import k,{useState as dn,useEffect as oi}from"react";import li from"axios";import{PatternFormat as si}from"react-number-format";function mi(e){let G=e.merchantPublicKey,R=e==null?void 0:e.discount,ke=e==null?void 0:e.tax,M=e==null?void 0:e.surcharge,[se,I]=dn(!1),[yt,Ye]=dn(!1),[re,ne]=dn({}),[H,_e]=dn(null),[p,b]=dn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:G}),[U,$]=dn(""),[g,Ae]=dn(!1),[C,Ce]=dn(null),Se=i=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(i),oe=/[+-]?([0-9]*[.])?[0-9]+/,He=i=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i),et=i=>/^[A-Za-z\s]*$/.test(i),at=()=>{I(!1),ne({})},dt=()=>I(!0),ot=()=>{console.log(C,"apiresponse"),Ke(C),Ae(!1)};function xt(){b({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:G}),$("")}function Ke(i){let r={type:"preview.compiledcheck",other:L(P({},i),{status:!0})};window.parent.postMessage(r,"*")}let Ot=async()=>{if(!(Object.keys(re).length>0)){if(ne({}),!(p!=null&&p.email)&&H&&!Se(H)){ne(i=>L(P({},i),{phone:ht.phonenumbervalid}));return}if(j())try{Ye(!0);let i={fractalpayPublicKey:G,amount:U,phone_number:H,order_id:p.order_id,action:"request",name:p.name,email:p.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:R,surcharge:M,tax:ke,require_3ds:e==null?void 0:e.require_3ds},r=await li.post(`${Ie}send-request-pre-auth-payment`,i);(r==null?void 0:r.status)===200&&(Ae(!0),I(!1),xt(),Ce(r==null?void 0:r.data)),Ye(!1)}catch(i){console.log(i),Ye(!1)}}},_=Ie+"images/logo-img.png",q=i=>{let{value:r}=i.target,c=i.target.dataset.token;if(b(L(P({},p),{[c]:r})),c==="name"&&!et(r)){ne(s=>L(P({},s),{[c]:ht.onlylettersallowed}));return}let h=re;c==="email"&&!H&&(delete h.phone,ne(h)),r&&(delete h[c],ne(h)),c==="email"&&!r&&(delete h[c],ne(h))},m=i=>{let{value:r}=i;if(Number(r)>0){let c=re;delete c.amount,ne(c)}$(r)},j=()=>{let i={};return U||(i.amount=ht.amountrequired),p.email&&!He(p==null?void 0:p.email)&&(i.email=ht.invalidemail),!H&&!(p!=null&&p.email)&&(i.phone=ht.phoneoremailrequired),!H&&!(p!=null&&p.email)&&(i.email=ht.phoneoremailrequired),!H&&p.email&&!He(p==null?void 0:p.email)&&(i.email=ht.invalidemail),e.from==="merchant"&&!p.order_id&&(i.order_id=ht.orderidrequired),ne(i),Object.keys(i).length===0};oi(()=>{e&&(b(i=>L(P({},i),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),$(e.amount?e.amount:""),_e(e.phone?`${e.phone}`:null))},[e]);let he=i=>{let r=i==null?void 0:i.value;if(r&&(r==null?void 0:r.length)>0&&(r==null?void 0:r.length)!==10){ne(h=>L(P({},h),{phone:ht.phonenumberlength})),_e(r);return}else _e(r);let c=re;delete c.phone,r&&!(p!=null&&p.email)&&delete c.email,ne(c)};function x(i){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(i))}return k.createElement(k.Fragment,null,k.createElement(An,null),k.createElement(Yt,{loading:yt}),k.createElement(k.Fragment,null,k.createElement("button",{className:"paymentBtn",onClick:dt},"Send Request"),k.createElement("div",{className:"frac-form"},k.createElement(Wt,{open:se,onClose:()=>I(!1),maxWidth:"500px"},k.createElement("div",{className:"request-payment-amount-detail"},k.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),k.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",e==null?void 0:e.webname),k.createElement("p",{className:"request-payment-amount"},x(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&k.createElement("p",{className:"request-payment-orderid"},p==null?void 0:p.order_id),k.createElement("span",{className:"request-payment-close-popup",onClick:at},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},k.createElement("g",{clipPath:"url(#clip0_12425_52336)"},k.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),k.createElement("defs",null,k.createElement("clipPath",{id:"clip0_12425_52336"},k.createElement("rect",{width:"16",height:"16",fill:"white"})))))),k.createElement("form",{className:"request-payment-input-form"},k.createElement("div",{className:"request-payment-list-div"},k.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),k.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:q,value:p==null?void 0:p.name}),re.name&&k.createElement("small",{className:"request-payment-error-msg"},re.name)),k.createElement("div",{className:"request-payment-list-div"},k.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),k.createElement(si,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:H,onValueChange:i=>{he(i)}}),re.phone&&k.createElement("small",{className:"request-payment-error-msg"},re.phone)),k.createElement("div",{className:"request-payment-list-div"},k.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),k.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:q,"data-token":"email",value:p==null?void 0:p.email}),re.email&&k.createElement("small",{className:"request-payment-error-msg"},re.email)),k.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:Ot,disabled:yt},yt?"Loading...":"Send Request"),k.createElement("div",{className:"request-payment-fractal-powerd-by"},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},k.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",k.createElement("span",null,"Fractal"),k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},k.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),k.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),k.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),k.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),k.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),k.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),k.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),k.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),k.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),k.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),k.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),k.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),k.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),k.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),k.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),k.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),k.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),k.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"}))))),k.createElement(Wt,{open:g,onClose:ot,maxWidth:"500px"},k.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},k.createElement("div",{className:"request-payment-success-container"},k.createElement("span",{className:"request-payment-close-popup",onClick:ot},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},k.createElement("g",{clipPath:"url(#clip0_12425_52336)"},k.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),k.createElement("defs",null,k.createElement("clipPath",{id:"clip0_12425_52336"},k.createElement("rect",{width:"16",height:"16",fill:"white"}))))),k.createElement("div",{className:"request-payment-success-tick-div"},k.createElement("div",{className:"request-payment-success-tick"},k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},k.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),k.createElement("h6",{className:"request-payment-success-text"},"The request ",k.createElement("br",null),"was sent"),k.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),k.createElement("div",{className:"request-payment-success-btn-div"},k.createElement("button",{onClick:ot,className:"request-payment-success-btn2"},"Close"))))))))}import t,{useEffect as Un,useState as it}from"react";import di from"react";function gn(){let e="#000",G="#fff",R="#212529",ke="#dee2e6";return di.createElement("style",null,`
650
+ `),Yi=Ha;var mi=e=>{try{let h=JSON.parse(e);return typeof h=="object"&&h!==null}catch(h){return!1}},ci=[{value:"personal saving",label:"Personal Saving"},{value:"business saving",label:"Business Saving"},{value:"personal checking",label:"Personal Checking"},{value:"business checking",label:"Business Checking"}];function Se(e){let h=Number(e);return isNaN(h)?`$${e}`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(h)}var ja=D+"widget/mc-img.svg",Oa=D+"widget/visa-img.svg",Va=D+"widget/ae-img.svg",Ea=D+"widget/discover-img.svg",ki=D+"widget/card.svg",Ka=D+"widget/bank.svg",ao=D+"widget/Trash.svg",ro=D+"widget/secure-img.png",oo=D+"widget/pov-by.png",Hi=D+"widget/pax.svg",ua=D+"widget/Bank _New.svg",ga=e=>{switch(e==null?void 0:e.toLowerCase()){case"visa":return Oa;case"mastercard":case"mc":case"m/c":return ja;case"amex":case"american express":case"ae":return Va;case"discover":case"dcvr":return Ea;case"bank":return Ka;default:return ki}},Bn=(e,h)=>{let q=e.replace(/\D/g,""),$=e.slice(0,h).replace(/\D/g,"").length,N="",I="";if(/^3[47]/.test(q)?(N=q.slice(0,15),I=N.replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Q,L,Z,ae)=>[L,Z,ae].filter(Boolean).join(" "))):(N=q.slice(0,16),I=N.replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Q,L,Z,ae,w)=>[L,Z,ae,w].filter(Boolean).join(" "))),$===0)return{formatted:I,cursor:0};let ie=I.length,ge=0;for(let Q=0;Q<I.length;Q++)if(/\d/.test(I[Q])&&ge++,ge===$){ie=Q+1;break}return{formatted:I,cursor:ie}};function Ga(e){let h=e.merchantPublicKey,q=e==null?void 0:e.discount,$=e==null?void 0:e.tax,N=e==null?void 0:e.surcharge,[I,z]=Gn(!1),[ie,ge]=Gn(!1),[Q,L]=Gn({}),[Z,ae]=Gn(null),[w,v]=Gn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),[R,E]=Gn(!1),[y,Pe]=Gn(void 0),[C,Ae]=Gn(""),[$e,pe]=Gn(!1),[Ve,rt]=Gn(null),Ce=x=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(x),Xe=/[+-]?([0-9]*[.])?[0-9]+/,fe=x=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x),nt=x=>/^[A-Za-z\s]*$/.test(x),Ee=(x,S)=>{let F=(parseFloat(S)||0)/100,Ke=x/(1+F);return Math.round(Ke*100)/100};pa(()=>{if(e!=null&&e.pass_fee){let x=Ee(e==null?void 0:e.amount,e==null?void 0:e.surcharge);Pe(x)}},[e==null?void 0:e.pass_fee]);let pn=()=>{z(!1),L({})},Y=()=>z(!0),p=()=>{console.log(Ve,"apiresponse"),A(Ve),pe(!1)};function u(){v({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),Ae("")}function A(x){let S={type:"preview.compiledcheck",other:M(k({},x),{status:!0})};window.parent.postMessage(S,"*")}let re=async()=>{if(!(Object.keys(Q).length>0)){if(L({}),!(w!=null&&w.email)&&Z&&!Ce(Z)){L(x=>M(k({},x),{phone:Qt.phonenumbervalid}));return}if(b())try{ge(!0);let x={fractalpayPublicKey:h,amount:C,phone_number:Z,order_id:w.order_id,action:"request",name:w.name,email:w.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:q,surcharge:N,tax:$,require_3ds:e==null?void 0:e.require_3ds,pass_fee:e==null?void 0:e.pass_fee,allow_partial:R},S=await Za.post(`${tt}create-widget-order`,x);(S==null?void 0:S.status)===200&&(pe(!0),z(!1),u(),rt(S==null?void 0:S.data)),ge(!1)}catch(x){console.log(x),ge(!1)}}},o=tt+"images/logo-img.png",a=x=>{let{value:S}=x.target,F=x.target.dataset.token;if(v(M(k({},w),{[F]:S})),F==="name"&&!nt(S)){L(Ye=>M(k({},Ye),{[F]:Qt.onlylettersallowed}));return}let Ke=Q;F==="email"&&!Z&&(delete Ke.phone,L(Ke)),S&&(delete Ke[F],L(Ke)),F==="email"&&!S&&(delete Ke[F],L(Ke))},i=x=>{let{value:S}=x;if(Number(S)>0){let F=Q;delete F.amount,L(F)}Ae(S)},b=()=>{let x={};return C||(x.amount=Qt.amountrequired),w.email&&!fe(w==null?void 0:w.email)&&(x.email=Qt.invalidemail),!Z&&!(w!=null&&w.email)&&(x.phone=Qt.phoneoremailrequired),!Z&&!(w!=null&&w.email)&&(x.email=Qt.phoneoremailrequired),!Z&&w.email&&!fe(w==null?void 0:w.email)&&(x.email=Qt.invalidemail),e.from==="merchant"&&!w.order_id&&(x.order_id=Qt.orderidrequired),L(x),Object.keys(x).length===0};pa(()=>{e&&(v(x=>M(k({},x),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),Ae(e.amount?e.amount:""),ae(e.phone?`${e.phone}`:null))},[e]);let P=x=>{let S=x==null?void 0:x.value;if(S&&(S==null?void 0:S.length)>0&&(S==null?void 0:S.length)!==10){L(Ke=>M(k({},Ke),{phone:Qt.phonenumberlength})),ae(S);return}else ae(S);let F=Q;delete F.phone,S&&!(w!=null&&w.email)&&delete F.email,L(F)};function g(x){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(x))}let W=x=>{let S=x.target.checked;E(S)};return T.createElement(T.Fragment,null,T.createElement(Yi,null),T.createElement(mn,{loading:ie}),T.createElement(T.Fragment,null,T.createElement("button",{className:"paymentBtn",onClick:Y},"Request Payment"),T.createElement(Pn,{open:I,onClose:()=>z(!1),maxWidth:"500px"},T.createElement("div",{style:{maxWidth:"500px"}},T.createElement("div",{className:"request-payment-amount-detail frac-form"},T.createElement("p",{className:"request-payment-merchantname"},"Pay ",e==null?void 0:e.webname),T.createElement("p",{className:"request-payment-amount"},g(e==null?void 0:e.amount)),y&&y>0&&T.createElement("div",{className:"frac-req-cash-discount"},T.createElement("div",{className:"frac-cashlabel"},"Cash Discount :"),T.createElement("div",null,Se((Number(e.amount)-y).toFixed(2)))),(e==null?void 0:e.from)==="merchant"&&T.createElement("p",{className:"request-payment-orderid"},w==null?void 0:w.order_id),T.createElement("span",{className:"request-payment-close-popup",onClick:pn},T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},T.createElement("g",{clipPath:"url(#clip0_12425_52336)"},T.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),T.createElement("defs",null,T.createElement("clipPath",{id:"clip0_12425_52336"},T.createElement("rect",{width:"16",height:"16",fill:"white"})))))),T.createElement("form",{className:"request-payment-input-form"},T.createElement("div",{className:"request-payment-list-div"},T.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),T.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:a,value:w==null?void 0:w.name}),Q.name&&T.createElement("small",{className:"request-payment-error-msg"},Q.name)),T.createElement("div",{className:"request-payment-list-div"},T.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),T.createElement(Wa,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:Z,onValueChange:x=>{P(x)}}),Q.phone&&T.createElement("small",{className:"request-payment-error-msg"},Q.phone)),T.createElement("div",{className:"request-payment-list-div"},T.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),T.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:a,"data-token":"email",value:w==null?void 0:w.email}),Q.email&&T.createElement("small",{className:"request-payment-error-msg"},Q.email)),T.createElement("div",{className:"partial-toggle-div"},T.createElement("input",{className:"partial-input",type:"checkbox",role:"switch",style:{cursor:"pointer"},checked:R,onChange:x=>W(x),id:"partialSwitch"}),T.createElement("label",{className:"partial-label",htmlFor:"partialSwitch",style:{cursor:"pointer"}},"Allow Partial Payments?")),T.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:re,disabled:ie},ie?"Loading...":"Send Request"),T.createElement("div",{className:"request-payment-fractal-powerd-by"},T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},T.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 ",T.createElement("span",null,"Fractal"),T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"}),T.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"})))))),T.createElement(Pn,{open:$e,onClose:p,maxWidth:"500px"},T.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},T.createElement("div",{className:"request-payment-success-container"},T.createElement("span",{className:"request-payment-close-popup",onClick:p},T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},T.createElement("g",{clipPath:"url(#clip0_12425_52336)"},T.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),T.createElement("defs",null,T.createElement("clipPath",{id:"clip0_12425_52336"},T.createElement("rect",{width:"16",height:"16",fill:"white"}))))),T.createElement("div",{className:"request-payment-success-tick-div"},T.createElement("div",{className:"request-payment-success-tick"},T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},T.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"})))),T.createElement("h6",{className:"request-payment-success-text"},"The request ",T.createElement("br",null),"was sent"),T.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),T.createElement("div",{className:"request-payment-success-btn-div"},T.createElement("button",{onClick:p,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import O,{useState as Dn,useEffect as Ua}from"react";import Ja from"axios";import{PatternFormat as Qa}from"react-number-format";function Xa(e){let h=e.merchantPublicKey,q=e==null?void 0:e.discount,$=e==null?void 0:e.tax,N=e==null?void 0:e.surcharge,[I,z]=Dn(!1),[ie,ge]=Dn(!1),[Q,L]=Dn({}),[Z,ae]=Dn(null),[w,v]=Dn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),[R,E]=Dn(""),[y,Pe]=Dn(!1),[C,Ae]=Dn(null),$e=a=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(a),pe=/[+-]?([0-9]*[.])?[0-9]+/,Ve=a=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a),rt=a=>/^[A-Za-z\s]*$/.test(a),Ce=()=>{z(!1),L({})},Xe=()=>z(!0),fe=()=>{console.log(C,"apiresponse"),Ee(C),Pe(!1)};function nt(){v({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:h}),E("")}function Ee(a){let i={type:"preview.compiledcheck",other:M(k({},a),{status:!0})};window.parent.postMessage(i,"*")}let pn=async()=>{if(!(Object.keys(Q).length>0)){if(L({}),!(w!=null&&w.email)&&Z&&!$e(Z)){L(a=>M(k({},a),{phone:Qt.phonenumbervalid}));return}if(A())try{ge(!0);let a={fractalpayPublicKey:h,amount:R,phone_number:Z,order_id:w.order_id,action:"request",name:w.name,email:w.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:q,surcharge:N,tax:$,require_3ds:e==null?void 0:e.require_3ds},i=await Ja.post(`${tt}send-request-pre-auth-payment`,a);(i==null?void 0:i.status)===200&&(Pe(!0),z(!1),nt(),Ae(i==null?void 0:i.data)),ge(!1)}catch(a){console.log(a),ge(!1)}}},Y=tt+"images/logo-img.png",p=a=>{let{value:i}=a.target,b=a.target.dataset.token;if(v(M(k({},w),{[b]:i})),b==="name"&&!rt(i)){L(g=>M(k({},g),{[b]:Qt.onlylettersallowed}));return}let P=Q;b==="email"&&!Z&&(delete P.phone,L(P)),i&&(delete P[b],L(P)),b==="email"&&!i&&(delete P[b],L(P))},u=a=>{let{value:i}=a;if(Number(i)>0){let b=Q;delete b.amount,L(b)}E(i)},A=()=>{let a={};return R||(a.amount=Qt.amountrequired),w.email&&!Ve(w==null?void 0:w.email)&&(a.email=Qt.invalidemail),!Z&&!(w!=null&&w.email)&&(a.phone=Qt.phoneoremailrequired),!Z&&!(w!=null&&w.email)&&(a.email=Qt.phoneoremailrequired),!Z&&w.email&&!Ve(w==null?void 0:w.email)&&(a.email=Qt.invalidemail),e.from==="merchant"&&!w.order_id&&(a.order_id=Qt.orderidrequired),L(a),Object.keys(a).length===0};Ua(()=>{e&&(v(a=>M(k({},a),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),E(e.amount?e.amount:""),ae(e.phone?`${e.phone}`:null))},[e]);let re=a=>{let i=a==null?void 0:a.value;if(i&&(i==null?void 0:i.length)>0&&(i==null?void 0:i.length)!==10){L(P=>M(k({},P),{phone:Qt.phonenumberlength})),ae(i);return}else ae(i);let b=Q;delete b.phone,i&&!(w!=null&&w.email)&&delete b.email,L(b)};function o(a){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(a))}return O.createElement(O.Fragment,null,O.createElement(Yi,null),O.createElement(mn,{loading:ie}),O.createElement(O.Fragment,null,O.createElement("button",{className:"paymentBtn",onClick:Xe},"Send Request"),O.createElement("div",{className:"frac-form"},O.createElement(Pn,{open:I,onClose:()=>z(!1),maxWidth:"500px"},O.createElement("div",{className:"request-payment-amount-detail"},O.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),O.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",e==null?void 0:e.webname),O.createElement("p",{className:"request-payment-amount"},o(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&O.createElement("p",{className:"request-payment-orderid"},w==null?void 0:w.order_id),O.createElement("span",{className:"request-payment-close-popup",onClick:Ce},O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},O.createElement("g",{clipPath:"url(#clip0_12425_52336)"},O.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"})),O.createElement("defs",null,O.createElement("clipPath",{id:"clip0_12425_52336"},O.createElement("rect",{width:"16",height:"16",fill:"white"})))))),O.createElement("form",{className:"request-payment-input-form"},O.createElement("div",{className:"request-payment-list-div"},O.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),O.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:p,value:w==null?void 0:w.name}),Q.name&&O.createElement("small",{className:"request-payment-error-msg"},Q.name)),O.createElement("div",{className:"request-payment-list-div"},O.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),O.createElement(Qa,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:Z,onValueChange:a=>{re(a)}}),Q.phone&&O.createElement("small",{className:"request-payment-error-msg"},Q.phone)),O.createElement("div",{className:"request-payment-list-div"},O.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),O.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:p,"data-token":"email",value:w==null?void 0:w.email}),Q.email&&O.createElement("small",{className:"request-payment-error-msg"},Q.email)),O.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:pn,disabled:ie},ie?"Loading...":"Send Request"),O.createElement("div",{className:"request-payment-fractal-powerd-by"},O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},O.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 ",O.createElement("span",null,"Fractal"),O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}),O.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"}))))),O.createElement(Pn,{open:y,onClose:fe,maxWidth:"500px"},O.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},O.createElement("div",{className:"request-payment-success-container"},O.createElement("span",{className:"request-payment-close-popup",onClick:fe},O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},O.createElement("g",{clipPath:"url(#clip0_12425_52336)"},O.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"})),O.createElement("defs",null,O.createElement("clipPath",{id:"clip0_12425_52336"},O.createElement("rect",{width:"16",height:"16",fill:"white"}))))),O.createElement("div",{className:"request-payment-success-tick-div"},O.createElement("div",{className:"request-payment-success-tick"},O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},O.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"})))),O.createElement("h6",{className:"request-payment-success-text"},"The request ",O.createElement("br",null),"was sent"),O.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),O.createElement("div",{className:"request-payment-success-btn-div"},O.createElement("button",{onClick:fe,className:"request-payment-success-btn2"},"Close"))))))))}import t,{useEffect as ha,useState as Kt}from"react";import Da from"react";function ai(){let e="#000",h="#fff",q="#212529",$="#dee2e6";return Da.createElement("style",null,`
315
651
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
316
652
  body
317
653
  {
@@ -540,13 +876,13 @@ import{a as P,b as L,c as ei,d as bn,e as Yt,f as be,g as Kt,h as Ie,i as en,l a
540
876
  font-size: 1rem;
541
877
  font-weight: 400;
542
878
  line-height: 1.5;
543
- color: ${R};
879
+ color: ${q};
544
880
  -webkit-appearance: none;
545
881
  -moz-appearance: none;
546
882
  appearance: none;
547
- background-color: ${G};
883
+ background-color: ${h};
548
884
  background-clip: padding-box;
549
- border: 1px solid ${ke};
885
+ border: 1px solid ${$};
550
886
  border-radius: 0.375rem;
551
887
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
552
888
  }
@@ -564,7 +900,7 @@ import{a as P,b as L,c as ei,d as bn,e as Yt,f as be,g as Kt,h as Ie,i as en,l a
564
900
  }
565
901
  .card-crdi {
566
902
  display: flex;
567
- border: 1px solid ${ke};
903
+ border: 1px solid ${$};
568
904
  border-radius: 0.375rem;
569
905
  }
570
906
  .card-expiry-new{
@@ -590,7 +926,7 @@ import{a as P,b as L,c as ei,d as bn,e as Yt,f as be,g as Kt,h as Ie,i as en,l a
590
926
  border-top-right-radius: 0;
591
927
  border-bottom-right-radius: 0;
592
928
  border: 0;
593
- border-right: 1px solid ${ke};
929
+ border-right: 1px solid ${$};
594
930
  }
595
931
 
596
932
 
@@ -604,7 +940,7 @@ import{a as P,b as L,c as ei,d as bn,e as Yt,f as be,g as Kt,h as Ie,i as en,l a
604
940
  border-radius: 0;
605
941
  border-top: 0;
606
942
  border-bottom: 0;
607
- border-right: 1px solid ${ke};
943
+ border-right: 1px solid ${$};
608
944
  }
609
945
 
610
946
  .exp-date input:focus {
@@ -1020,7 +1356,7 @@ position:relative;
1020
1356
  margin-top: 12px !important;
1021
1357
  }
1022
1358
 
1023
- `)}import vn from"axios";import je from"react";import ci from"react";function Hn(){return ci.createElement("style",null,`
1359
+ `)}import ui from"axios";import _t from"react";import Ra from"react";function Gi(){return Ra.createElement("style",null,`
1024
1360
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
1025
1361
 
1026
1362
  body{
@@ -1215,7 +1551,186 @@ position:relative;
1215
1551
  gap: 6px;
1216
1552
  background-color: #161616;
1217
1553
  color: #fff;
1218
- }`)}function cn(e,G,R){e.preventDefault();let M={type:"preview.compiledcheck",other:{msg:"Payment success!",status:G==="close",data:{tran_id:R,key:G}}};console.log("message:",M),window.parent.postMessage(M,"*")}function fn({onClose:e,tranId:G}){return je.createElement(je.Fragment,null,je.createElement(Hn,null),je.createElement("div",{className:"payment-msg-container"},je.createElement("div",{className:"charge-payment-success-container"},je.createElement("div",{className:"charge-payment-success-tick-div"},je.createElement("div",{className:"charge-payment-success-tick"},je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},je.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"})))),je.createElement("h6",{className:"charge-payment-success-text"},"Your charge",je.createElement("br",null),"was successful"),je.createElement("h6",{className:"charge-payment-success-subtext"},"We\u2019ve processed your charge"),je.createElement("div",{className:"charge-success-payment-button-div"},je.createElement("button",{className:"charge-success-btn1",onClick:R=>cn(R,"print",G)},je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},je.createElement("path",{d:"M15.7729 8.7272C15.58 8.7272 15.395 8.80383 15.2586 8.94022C15.1222 9.07661 15.0456 9.2616 15.0456 9.45448V12.5185C15.045 13.0559 14.8313 13.5711 14.4513 13.9511C14.0713 14.3311 13.5561 14.5449 13.0187 14.5454H3.98149C3.44409 14.5449 2.92887 14.3311 2.54887 13.9511C2.16887 13.5711 1.95514 13.0559 1.95456 12.5185V9.45448C1.95456 9.2616 1.87794 9.07661 1.74154 8.94022C1.60515 8.80383 1.42017 8.7272 1.22728 8.7272C1.03439 8.7272 0.849407 8.80383 0.713015 8.94022C0.576624 9.07661 0.5 9.2616 0.5 9.45448V12.5185C0.500963 13.4416 0.86807 14.3265 1.52077 14.9792C2.17346 15.6319 3.05844 15.999 3.98149 16H13.0187C13.9417 15.999 14.8267 15.6319 15.4794 14.9792C16.1321 14.3265 16.4992 13.4416 16.5002 12.5185V9.45448C16.5002 9.2616 16.4235 9.07661 16.2871 8.94022C16.1507 8.80383 15.9658 8.7272 15.7729 8.7272Z",fill:"#161616"}),je.createElement("path",{d:"M4.65059 6.75861L7.7728 9.88082V0.72728C7.7728 0.534394 7.84942 0.349407 7.98581 0.213015C8.1222 0.0766239 8.30719 0 8.50008 0C8.69296 0 8.87795 0.0766239 9.01434 0.213015C9.15073 0.349407 9.22736 0.534394 9.22736 0.72728V9.88082L12.3496 6.75861C12.4867 6.62613 12.6704 6.55283 12.8611 6.55448C13.0518 6.55614 13.2342 6.63263 13.3691 6.76747C13.5039 6.90231 13.5804 7.08472 13.5821 7.27541C13.5837 7.46611 13.5104 7.64982 13.3779 7.78698L9.01427 12.1507C8.87788 12.287 8.69293 12.3636 8.50008 12.3636C8.30723 12.3636 8.12228 12.287 7.98589 12.1507L3.62221 7.78698C3.48973 7.64982 3.41643 7.46611 3.41808 7.27541C3.41974 7.08472 3.49623 6.90231 3.63107 6.76747C3.76592 6.63263 3.94833 6.55614 4.13902 6.55448C4.32971 6.55283 4.51342 6.62613 4.65059 6.75861Z",fill:"#161616"})),"Print receipt"),je.createElement("button",{className:"charge-success-btn1",onClick:R=>cn(R,"share",G)},je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},je.createElement("g",{clipPath:"url(#clip0_12420_50683)"},je.createElement("path",{d:"M9.30194 4.78664V2.31152C9.30194 2.09629 9.3862 1.88988 9.53631 1.73768C9.68634 1.5855 9.8899 1.5 10.1021 1.5C10.312 1.50089 10.5132 1.58542 10.6622 1.73534L16.2633 7.41595C16.3383 7.49142 16.3978 7.58117 16.4385 7.68001C16.4791 7.77894 16.5 7.885 16.5 7.99212C16.5 8.09924 16.4791 8.20531 16.4385 8.30423C16.3978 8.40307 16.3383 8.49283 16.2633 8.5683L10.6622 14.2489C10.5499 14.3606 10.4076 14.4362 10.2531 14.4663C10.0987 14.4964 9.93887 14.4797 9.79372 14.4182C9.64857 14.3568 9.52455 14.2532 9.43701 14.1206C9.34955 13.9881 9.30258 13.8323 9.30194 13.6727V11.157H8.62181C7.35764 11.1379 6.10443 11.3981 4.94932 11.9193C3.79422 12.4406 2.76481 13.2107 1.93249 14.1759C1.83215 14.3113 1.6926 14.4115 1.53337 14.4624C1.37406 14.5134 1.20306 14.5125 1.04431 14.4599C0.882759 14.4046 0.742811 14.2984 0.644952 14.1568C0.547092 14.0152 0.496363 13.8456 0.500203 13.6727C0.500203 6.27171 6.96548 5.00575 9.30194 4.78664ZM8.62181 9.51777C9.15695 9.51607 9.69162 9.55129 10.2221 9.62327C10.4115 9.6524 10.5844 9.74954 10.7092 9.89699C10.834 10.0444 10.9025 10.2324 10.9023 10.4267V11.717L14.567 7.99212L10.9023 4.26727V5.55758C10.9023 5.77281 10.8179 5.97922 10.6679 6.13141C10.5178 6.28359 10.3143 6.36909 10.1021 6.36909C9.37396 6.36909 3.61282 6.5314 2.36457 11.5871C4.17637 10.2324 6.3708 9.50665 8.62181 9.51777Z",fill:"#161616"})),je.createElement("defs",null,je.createElement("clipPath",{id:"clip0_12420_50683"},je.createElement("rect",{width:"16",height:"16",fill:"white",transform:"translate(0.5)"})))),"Send receipt"))),je.createElement("div",{className:"charge-payment-success-btn-div"},je.createElement("button",{className:"charge-payment-success-btn1",onClick:R=>cn(R,"tran",G)},"Go to Transactions"),je.createElement("button",{className:"charge-payment-success-btn2",onClick:R=>{e(),cn(R,"close",G)}},"Close"))))}import kn from"sweetalert2";import{IoArrowBack as Bn}from"react-icons/io5";import{io as ui}from"socket.io-client";var gi=ui(Ie,{transports:["websocket"],withCredentials:!1}),nt=gi;import Gt from"react";var zn=({listHeading:e="Readers",ListItems:G,selectedPax:R,setSlectedPax:ke,headingClass:M})=>Gt.createElement(Gt.Fragment,null,Gt.createElement("h6",{className:M||"card-ach-heading",style:{marginBottom:"10px !important"}},e),Gt.createElement("div",{className:"card-lint-div-in"},Gt.createElement("div",{className:"card-list-div"},G&&(G==null?void 0:G.length)>0&&(G==null?void 0:G.map((se,I)=>Gt.createElement("div",{key:se==null?void 0:se.id,className:"card-list-single-div"},Gt.createElement("div",{className:"card-number-radio"},Gt.createElement("input",{type:"radio",className:"cardRadio",name:"selected_reader",id:"",checked:(R==null?void 0:R.id)===(se==null?void 0:se.id),onChange:yt=>ke(se)}),Gt.createElement("label",{htmlFor:"",className:"card-number-last-four"},se==null?void 0:se.device_name)),Gt.createElement("div",{className:"card-number-radio"},Gt.createElement("span",{className:"visa-card"},Gt.createElement("img",{src:Zn,alt:""})))))))));function fi(e){var Qe,De,mt,wt,pe,kt,At,Ft,Ht,zt,Bt,Zt,$t,Rt,ut,ue,xe,Tt,qt,Ee;let[G,R]=it(!1),[ke,M]=it(!1),[se,I]=it(""),[yt,Ye]=it(!1),[re,ne]=it(!1),[H,_e]=it("card"),[p,b]=it("card"),[U,$]=it("form"),[g,Ae]=it("form"),[C,Ce]=it(!0),[Se,oe]=it(!1),[He,et]=it(!1),at=e.merchantPublicKey,dt=be+"widget/mc-img.svg",ot=be+"widget/visa-img.svg",xt=be+"widget/ae-img.svg",Ke=be+"widget/discover-img.svg",Ot=be+"widget/card.svg",_=be+"widget/Trash.svg",q=be+"widget/bank.svg",m=be+"widget/secure-img.png",j=be+"widget/pov-by.png",he=be+"widget/pax.svg",[x,i]=it(),[r,c]=it({}),[h,s]=it(),[z,u]=it({}),[f,S]=it([]),[le,ce]=it([]),[Pe,lt]=it(),[Ue,Je]=it(void 0),[J,X]=it(Number(e==null?void 0:e.amount));console.log(Pe,"selectedCard");let[F,ge]=it(),[Ne,O]=it(""),st=()=>R(!0),ze=()=>R(!1),vt=(y,d)=>{let K=(parseFloat(d)||0)/100,ve=y/(1+K);return Math.round(ve*100)/100};Un(()=>{if(re){let y=vt(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);X(y)}},[re,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let w=()=>{ne(!1),_e("card"),I(""),Ye(!1),O(""),s({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),u({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),i({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),c({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),et(!1),oe(!1),lt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),Je(null),X(0),b("card"),Ce(!0),Ae("form"),$("form"),M(!1),R(!1),ce([]),S([])},ct=()=>ne(!0),tt=y=>{_e(y)},fe=(y,d)=>{let K=y;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(K)){(d===""||/^[0-9]+$/.test(d))&&(c(Y=>L(P({},Y),{[K]:""})),i(Y=>L(P({},Y),{[K]:d})));return}c(Y=>L(P({},Y),{[K]:""})),i(Y=>L(P({},Y),{[K]:d}))},bt=y=>{let K=y.target.value.replace(/\D/g,""),ve="";/^3[47]/.test(K)?ve=K.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,($e,Oe,Ze,Ve)=>[Oe,Ze,Ve].filter(Boolean).join(" ")):ve=K.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,($e,Oe,Ze,Ve,E)=>[Oe,Ze,Ve,E].filter(Boolean).join(" ")),c(Y=>L(P({},Y),{cardNumber:""})),i(Y=>L(P({},Y),{cardNumber:ve}))},Lt=y=>{let{name:d,value:K}=y.target,ve=["routingNumber","accountNumber","confirmAccountNumber"];if(d=="name"){/^[a-zA-Z\s]*$/.test(K)&&(u(Y=>L(P({},Y),{[d]:""})),s(Y=>L(P({},Y),{[d]:K})));return}if(ve.includes(d)){(K===""||/^[0-9]+$/.test(K))&&(u(Y=>L(P({},Y),{[d]:""})),s(Y=>L(P({},Y),{[d]:K})));return}u(Y=>L(P({},Y),{[d]:""})),s(Y=>L(P({},Y),{[d]:K}))},un=()=>{var Y,$e,Oe,Ze,Ve,E;let y={},d=x,K=parseInt((d==null?void 0:d.expiryMonth)||"",10),ve=(d==null?void 0:d.expiryYear)||"";if((Y=d==null?void 0:d.cardName)!=null&&Y.trim()||(y.cardName="Card name is required"),($e=d==null?void 0:d.cardNumber)!=null&&$e.trim()||(y.cardNumber="Card number is required"),(!((Oe=d==null?void 0:d.expiryMonth)!=null&&Oe.trim())||!((Ze=d==null?void 0:d.expiryYear)!=null&&Ze.trim())||isNaN(K)||K<1||K>12||ve.length!==4)&&(y.expiryMonth="Invalid Expiration Date."),(Ve=d==null?void 0:d.cvv)!=null&&Ve.trim()||(y.cvv="CVV is required"),(E=d==null?void 0:d.zipCode)!=null&&E.trim()||(y.zipCode="ZIP code is required"),d!=null&&d.expiryMonth&&(d!=null&&d.expiryYear)&&d.expiryMonth.length<=2&&d.expiryYear.length===4){let _t=parseInt(d.expiryMonth,10),o=parseInt(d.expiryYear,10),l=new Date,B=l.getMonth()+1,Q=l.getFullYear();(o<Q||o===Q&&_t<B)&&(y.expiryMonth="Card is expired")}return c(y),Object.keys(y).length>0},Nt=()=>{var K,ve,Y,$e,Oe,Ze,Ve,E;let y={},d=h;return(K=d==null?void 0:d.name)!=null&&K.trim()||(y.name="Name is required"),(ve=d==null?void 0:d.accountNumber)!=null&&ve.trim()||(y.accountNumber="Account number is required"),(Y=d==null?void 0:d.accountNumber)!=null&&Y.trim()&&(($e=d==null?void 0:d.accountNumber)==null?void 0:$e.trim())!==((Oe=d==null?void 0:d.confirmAccountNumber)==null?void 0:Oe.trim())&&(y.confirmAccountNumber="Account numbers must match"),(Ze=d==null?void 0:d.bankName)!=null&&Ze.trim()||(y.bankName="Bank name is required"),(Ve=d==null?void 0:d.routingNumber)!=null&&Ve.trim()||(y.routingNumber="Routing Number is required"),d!=null&&d.routingNumber&&((E=d==null?void 0:d.routingNumber)==null?void 0:E.length)!==9&&(y.routingNumber="Routing number must be 9 digits"),((d==null?void 0:d.accountType)==="business saving"||(d==null?void 0:d.accountType)==="business checking")&&(!(d!=null&&d.companyName)||(d==null?void 0:d.companyName)==="")&&(y.companyName="Company Name is required for business accounts"),u(y),Object.keys(y).length>0},Et=async y=>{var d,K,ve,Y,$e,Oe,Ze,Ve,E,_t,o,l,B,Q,V,me;if(y.preventDefault(),H!=="ach"){if(un())return;{let Fe=DatacapWebToken.validateCardNumber(x==null?void 0:x.cardNumber.replaceAll(" ","")),W=DatacapWebToken.validateExpirationDate(x==null?void 0:x.expiryMonth,x==null?void 0:x.expiryYear),Te=DatacapWebToken.validateCVV(x==null?void 0:x.cvv),Re={};if(Fe||(Re.cardNumber="Invalid card Number"),W||(Re.expiryMonth="Invalid Expiration Date."),Te||(Re.cvv="Invalid CVV"),c(Re),Fe&&Te&&W){M(!0);try{let ae={amount:`${e.amount||0}`,fractalpayPublicKey:at,orderId:e==null?void 0:e.orderID,customer_id:e==null?void 0:e.customerId,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,pass_fee:e==null?void 0:e.pass_fee},ye=await vn.post(`${Ie}create-widget-order`,ae),te=async function(We){if(We.Error)I(We.Error),M(!1);else{let we=x==null?void 0:x.cardName,St=x==null?void 0:x.zipCode;We.name=we,We.postal_code=St,We.isCardSave=`${Se}`,We.isCharge=!0,We.posSalesIdEncode=ye==null?void 0:ye.data.data.posSalesIdEncode,nt.emit("sendMessage",We),nt.on(ye==null?void 0:ye.data.data.posSalesIdEncode,Me=>{if(pn(Me==null?void 0:Me.data)){let de=JSON.parse(Me.data);de!=null&&de.result?(i({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),oe(!1),O(de==null?void 0:de.transactionId),Ye(!0),M(!1)):(M(!1),I((de==null?void 0:de.message)||"Something went wrong."))}else I("Something went wrong.")})}};if((F==null?void 0:F.paymentGateway)===32){let We={method:"POST",redirect:"follow"};try{let we=await vn.post(`${Kt}api/v1/widget/generate-session`,We),St=Number(x==null?void 0:x.expiryYear)%100,Me=x==null?void 0:x.cardNumber;Me=Me==null?void 0:Me.replace(/\s+/g,"");let de=`${Me}=${St}${x==null?void 0:x.expiryMonth} ${x==null?void 0:x.cvv}`,Ut=forge.pki.publicKeyFromPem((K=(d=we==null?void 0:we.data)==null?void 0:d.data)==null?void 0:K.publicKeyPem).encrypt(de,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Vt=forge.util.encode64(Ut),Mt={"Content-Type":"application/json","x-app-session-key":(Y=(ve=we.data)==null?void 0:ve.data)==null?void 0:Y.session_key},Le=JSON.stringify({enc_track2_data:`${Vt}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Oe=($e=we==null?void 0:we.data)==null?void 0:$e.data)==null?void 0:Oe.session_key}`});try{let Z=await vn.post(`${en}tokenizer/tokenize`,Le,{headers:Mt}),It=JSON.stringify(L(P({},(Ze=Z==null?void 0:Z.data)==null?void 0:Ze.data),{isSaveCardChecked:Se,name:x==null?void 0:x.cardName,postal_code:x==null?void 0:x.zipCode,customer_id:e==null?void 0:e.customerId})),Jt=JSON.stringify({pre_sales_id:`${(E=(Ve=ye==null?void 0:ye.data)==null?void 0:Ve.data)==null?void 0:E.posSalesIdEncode}`,token:`${(_t=Z==null?void 0:Z.data)==null?void 0:_t.data.token}`,json_response:`${It}`}),sn={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:Jt,redirect:"follow",isChargeviafractal:!0};nt.emit("sendMessage",sn),nt.on("chargeviafractalgateway",Ct=>{var Mn;if(pn(Ct==null?void 0:Ct.data)){let Qt=JSON.parse(Ct==null?void 0:Ct.data);Qt!=null&&Qt.result?(O((Mn=Qt==null?void 0:Qt.data)==null?void 0:Mn.transactionId),Ye(!0),M(!1)):(M(!1),I((Qt==null?void 0:Qt.message)||"Something went wrong."))}else I("Something went wrong.")})}catch(Z){M(!1),I(((l=(o=Z==null?void 0:Z.response)==null?void 0:o.data)==null?void 0:l.message)||(Z==null?void 0:Z.message)||"Something went wrong.")}}catch(we){M(!1),I(((Q=(B=we==null?void 0:we.response)==null?void 0:B.data)==null?void 0:Q.message)||(we==null?void 0:we.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(ye==null?void 0:ye.data.data.dctoken,"PaymentForm",te)}catch(ae){M(!1),I(((me=(V=ae==null?void 0:ae.response)==null?void 0:V.data)==null?void 0:me.message)||(ae==null?void 0:ae.message)||"Something went wrong.")}}}}else{if(Nt())return;{M(!0);let Fe={fractalpayPublicKey:at,label:(h==null?void 0:h.name)||"John Doe",account_number:h==null?void 0:h.accountNumber,routing_number:h==null?void 0:h.routingNumber,bank_name:h==null?void 0:h.bankName,account_type:h==null?void 0:h.accountType,amount:String(J||0),isSaveAch:He,customer_id:e==null?void 0:e.customerId,order_id:e==null?void 0:e.orderID,tax:e==null?void 0:e.tax,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,isChargeACH:!0,company_name:(h==null?void 0:h.companyName)||""};nt.emit("sendMessage",Fe),nt.on("ach-incoming",W=>{var Te;(W==null?void 0:W.status)=="Failed"?typeof(W==null?void 0:W.message)=="object"?Object.values(W==null?void 0:W.message).forEach(Re=>{I(Re||"Something went wrong")}):I((W==null?void 0:W.message)||"Something went wrong"):(O((Te=W==null?void 0:W.data)==null?void 0:Te.transaction_id),Ye(!0),M(!1))})}}},T=async()=>{var y,d,K,ve,Y,$e,Oe,Ze,Ve,E,_t,o,l,B,Q,V,me,Be,Fe,W,Te,Re,ae;st();try{let ye={fractalpayPublicKey:at,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,isReader:e==null?void 0:e.isReader},te=await vn.post(`${Ie}get-payment-details`,ye);if(ge((y=te==null?void 0:te.data)==null?void 0:y.data),(K=(d=te==null?void 0:te.data)==null?void 0:d.data)!=null&&K.paymentGateway||(w(),I("Something went wrong.")),(Y=(ve=te==null?void 0:te.data)==null?void 0:ve.data)!=null&&Y.card_list&&((Ze=(Oe=($e=te==null?void 0:te.data)==null?void 0:$e.data)==null?void 0:Oe.card_list)==null?void 0:Ze.length)>0){let We=(_t=(E=(Ve=te==null?void 0:te.data)==null?void 0:Ve.data)==null?void 0:E.card_list)==null?void 0:_t.filter(St=>(St==null?void 0:St.card_type)=="Bank"),we=(B=(l=(o=te==null?void 0:te.data)==null?void 0:o.data)==null?void 0:l.card_list)==null?void 0:B.filter(St=>(St==null?void 0:St.card_type)!=="Bank");console.log(We,"hohgohoo",we),(we==null?void 0:we.length)>0&&$("list"),(We==null?void 0:We.length)>0&&Ae("list"),S(we),ce(We)}else _e("card");(V=(Q=te==null?void 0:te.data)==null?void 0:Q.data)!=null&&V.paymentDeviceList&&((Fe=(Be=(me=te==null?void 0:te.data)==null?void 0:me.data)==null?void 0:Be.paymentDeviceList)==null?void 0:Fe.length)>0&&Je((Te=(W=te==null?void 0:te.data)==null?void 0:W.data)==null?void 0:Te.paymentDeviceList[0]),ze()}catch(ye){console.log(ye),ze(),I(((ae=(Re=ye==null?void 0:ye.response)==null?void 0:Re.data)==null?void 0:ae.message)||(ye==null?void 0:ye.message)||"Something went wrong")}},A=async()=>{let y=e==null?void 0:e.customerId,d=String(e==null?void 0:e.discount),K=String(e==null?void 0:e.surcharge),ve=String(e==null?void 0:e.tax),Y=e==null?void 0:e.merchantPublicKey,$e=e==null?void 0:e.orderID,Oe=String(e==null?void 0:e.amount),Ze=Pe==null?void 0:Pe.id,Ve=Pe==null?void 0:Pe.card_type;if(Y&&$e&&Oe&&J)if(y)if(Ze){let _t={amount:Ve==="Bank"?`${J}`:Oe,order_id:$e,customer_id:y,card_id:Ze,fractalpayPublicKey:Y,isCardSave:Se,discount:d,surcharge:K,tax:ve},E=_t,{isCardSave:o}=E,l=bn(E,["isCardSave"]),Q=Ie+(Ve==="Bank"?"charge-ach":"charge-by-card"),V={"Content-Type":"application/json"};M(!0),nt.emit("sendMessage",{url:Q,body:Ve=="Bank"?l:_t,isChargebycard:!0}),nt.on("charge-by-card",me=>{var Be;(me==null?void 0:me.result)==!0||(me==null?void 0:me.status)==!0?(O((Be=me.data)==null?void 0:Be.transaction_id),Ye(!0),M(!1)):I((me==null?void 0:me.message)||"Something went wrong.")})}else I("Please Select A Card/ACH");else I("Please Select Customer");else I("Something went wrong.")},ie=async()=>{var Y,$e,Oe,Ze,Ve,E;let y=e==null?void 0:e.merchantPublicKey,d=e==null?void 0:e.orderID,K=String(e==null?void 0:e.amount),ve=e==null?void 0:e.customerId;if(!(Ue!=null&&Ue.device_id)){I("Please Select A Payment Device");return}if(y&&d&&K){M(!0);let _t={amount:K,fractalpayPublicKey:y,customer_order_id:d,device_id:Ue==null?void 0:Ue.device_id,customer_id:ve||""};try{let o=await vn.post(`${Ie}charge-with-reader`,_t);((Y=o==null?void 0:o.data)==null?void 0:Y.result)==!0?(O((Oe=($e=o==null?void 0:o.data)==null?void 0:$e.data)==null?void 0:Oe.transaction_id),Ye(!0),M(!1)):(I(((Ze=o==null?void 0:o.data)==null?void 0:Ze.message)||"Something went wrong."),M(!1))}catch(o){I(((E=(Ve=o==null?void 0:o.response)==null?void 0:Ve.data)==null?void 0:E.message)||"Something went wrong."),M(!1)}}else I("Something went wrong.")},Xe=()=>{p==="card"?A():p==="reader"&&ie()};Un(()=>{re&&at&&T()},[at,re]);let ee=async y=>{kn.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 d=>{if(d.isConfirmed){M(!0);try{let K={card_id:y,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},ve=await vn.post(`${Ie}delete-customer-card`,K);M(!1),T(),kn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(K){M(!1),kn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else d.dismiss===kn.DismissReason.cancel&&kn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},pt=y=>{switch(y==null?void 0:y.toLowerCase()){case"visa":return ot;case"mastercard":case"mc":case"m/c":return dt;case"amex":case"american express":case"ae":return xt;case"discover":case"dcvr":return Ke;case"bank":return q;default:return y}},rt=()=>{let y=J||0;return(Number(e.amount)-y).toFixed(0)};return console.log(U,"activeinCard","activeinBank",g),t.createElement(t.Fragment,null,t.createElement(tn,null),t.createElement(gn,null),t.createElement(xn,null),t.createElement(t.Fragment,null,t.createElement("button",{className:"paymentBtn",onClick:ct},"Pay"),t.createElement(Wt,{open:re,onClose:w},se&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(nn,{error:se,onClose:w})),yt&&t.createElement(fn,{onClose:w,tranId:Ne}),!se&&!yt&&t.createElement(t.Fragment,null,(G||ke)&&t.createElement(Yt,{loading:G||ke}),t.createElement("div",{className:"frac-card-payment-page frac-form"},t.createElement("div",{className:"parent-pay-container"},t.createElement("span",{className:"request-payment-close-popup",onClick:w},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t.createElement("g",{clipPath:"url(#clip0_12425_52336)"},t.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_12425_52336"},t.createElement("rect",{width:"16",height:"16",fill:"white"}))))),t.createElement("div",{className:"pay-main-logo-res"},t.createElement("img",{src:F==null?void 0:F.logo,id:"pay-logos"})),t.createElement("div",{className:"pay-container"},t.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},t.createElement("div",{className:"pay-conatiner-one-first"},t.createElement("div",{className:"pay-logo-container"},t.createElement("div",{className:"pay-main-logo"},t.createElement("img",{src:F==null?void 0:F.logo,id:"pay-logos"})),(f==null?void 0:f.length)>0&&H!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>_e("cardList")}," ",t.createElement(Bn,null)," Back")),t.createElement("div",{className:"amt-pay-con"},t.createElement("div",{className:"pay-amount-conatiner"},t.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),t.createElement("div",{className:"frac-card-bank-radio-main"},t.createElement(an,{label:"Card",amount:(Qe=Number(e==null?void 0:e.amount))==null?void 0:Qe.toFixed(2),value:"card",onChange:tt,activetab:H}),(F==null?void 0:F.isSkyFiAccount)&&t.createElement(an,{label:"Bank",amount:(De=Number(J))==null?void 0:De.toFixed(2),value:"ach",onChange:tt,activetab:H}),(e==null?void 0:e.isReader)&&(F==null?void 0:F.paymentDeviceList)&&((mt=F==null?void 0:F.paymentDeviceList)==null?void 0:mt.length)>0&&t.createElement(an,{label:"Reader",amount:(wt=Number(e==null?void 0:e.amount))==null?void 0:wt.toFixed(2),value:"reader",onChange:tt,activetab:H})),J&&J>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,H==="card"||H==="reader"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,qe((Number(e.amount)-J).toFixed(2)))):null)),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:m,alt:""}),t.createElement("img",{src:j,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!G&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},H!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(f==null?void 0:f.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>_e("cardList")}," ",t.createElement(Bn,null)," Back"),(F==null?void 0:F.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:y=>{tt("card")},style:{border:H==="card"?"1px solid":""}},t.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),t.createElement("button",{className:"tablinks",onClick:y=>{tt("ach")},style:{border:H==="ach"?"1px solid":""}},t.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(pe=Number(e==null?void 0:e.amount))==null?void 0:pe.toFixed(2))),H!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:ot,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:dt,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:xt,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Ke,width:35,alt:""})))),J&&J>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",J))):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",F==null?void 0:F.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",p==="card"?"Cards/Banks":"Readers"," "),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(kt=Number(e==null?void 0:e.amount))==null?void 0:kt.toFixed(2))),t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:ot,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:dt,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:xt,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Ke,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:H==="card"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(f==null?void 0:f.length)>0&&U==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>$("list")}," ",t.createElement(Bn,null)),J&&J>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",J))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),H!="ach"&&t.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},t.createElement("img",{src:ot,alt:"",width:33}),t.createElement("img",{src:dt,width:33,alt:""}),t.createElement("img",{src:xt,alt:"",width:33}),t.createElement("img",{src:Ke,width:33,alt:""}))),U==="list"?t.createElement(t.Fragment,null,t.createElement(mn,{listHeading:"Cards",paymentGateway:F==null?void 0:F.paymentGateway,ListItems:f,selectedCard:Pe,setSelectedCard:lt,handleDeleteCard:ee,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{$("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Xe},qe((At=Number(e==null?void 0:e.amount))==null?void 0:At.toFixed(2))))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Et},t.createElement("div",{className:"ach-scrl",style:{minHeight:F!=null&&F.isSkyFiAccount&&(f==null?void 0:f.length)>0?"444px":F!=null&&F.isSkyFiAccount&&(f==null?void 0:f.length)==0?"456px":(f==null?void 0:f.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(x==null?void 0:x.cardName)||"",onChange:y=>{let d=y.target.value;/^[a-zA-Z\s]*$/.test(d)&&fe("cardName",d)}}),(r==null?void 0:r.cardName)&&t.createElement("span",{className:"error-span"},r==null?void 0:r.cardName)),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),t.createElement("div",{className:"toggle-num-wrapper"},t.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(x==null?void 0:x.cardNumber)||"",onChange:y=>bt(y),"data-token":"card_number"}),t.createElement("div",{className:"card-crdi card-expiry-new"},t.createElement("div",{className:"exp-date-year-container"},t.createElement("div",{className:"exp-date form-group"},t.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(x==null?void 0:x.expiryMonth)||"",onChange:y=>fe("expiryMonth",y.target.value)})),t.createElement("div",{className:"exp-year form-group"},t.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(x==null?void 0:x.expiryYear)||"",onChange:y=>fe("expiryYear",y.target.value)})),t.createElement("div",{className:"security-digit form-group"},t.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(x==null?void 0:x.cvv)||"",onChange:y=>fe("cvv",y.target.value)})))),(r==null?void 0:r.cardNumber)&&t.createElement("span",{className:"error-span"},r==null?void 0:r.cardNumber),t.createElement("p",{style:{margin:"0"}},r!=null&&r.expiryMonth||r!=null&&r.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},r==null?void 0:r.expiryMonth):"",(r==null?void 0:r.cvv)&&t.createElement("span",{className:"error-span"},r==null?void 0:r.cvv)))),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(Ft=e==null?void 0:e.orderID)!=null?Ft:"",style:{background:"#F6F6F7",color:"#727272"}})),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"zip"},"ZIP"),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Ht=x==null?void 0:x.zipCode)!=null?Ht:"",onChange:y=>fe("zipCode",y.target.value)}),(r==null?void 0:r.zipCode)&&t.createElement("span",{className:"error-span"},r==null?void 0:r.zipCode)),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},t.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:Se,onChange:y=>oe(y.target.checked)}),t.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),t.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},t.createElement("g",{clipPath:"url(#clip0_12420_50192)"},t.createElement("rect",{width:"20",height:"20",fill:"white"}),t.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),t.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_12420_50192"},t.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),t.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},qe((zt=Number(e==null?void 0:e.amount))==null?void 0:zt.toFixed(2)))))),t.createElement("div",{id:"ach",style:{display:H==="ach"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(le==null?void 0:le.length)>0&&g==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ae("list")}," ",t.createElement(Bn,null)),J&&J>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),t.createElement("div",null,"$",rt()))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),g==="list"?t.createElement(t.Fragment,null,t.createElement(mn,{listHeading:"Banks",paymentGateway:F==null?void 0:F.paymentGateway,ListItems:le,selectedCard:Pe,setSelectedCard:lt,handleDeleteCard:ee,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Ae("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Xe},qe((Bt=Number(J))==null?void 0:Bt.toFixed(2))))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Et,autoComplete:"off"},t.createElement("div",{className:"ach-scrl",style:{minHeight:F!=null&&F.isSkyFiAccount&&(f==null?void 0:f.length)>0?"444px":F!=null&&F.isSkyFiAccount&&(f==null?void 0:f.length)==0?"436px":(f==null?void 0:f.length)>0?"462px":"520px",maxHeight:F!=null&&F.isSkyFiAccount&&(f==null?void 0:f.length)>0?"444px":((f==null?void 0:f.length)>0,"380px")}},t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),t.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(Zt=h==null?void 0:h.name)!=null?Zt:"",onChange:Lt}),(z==null?void 0:z.name)&&t.createElement("span",{className:"error-span"},z==null?void 0:z.name)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"routingnumber"},"Routing number"),t.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:($t=h==null?void 0:h.routingNumber)!=null?$t:"",onChange:Lt}),(z==null?void 0:z.routingNumber)&&t.createElement("span",{className:"error-span"},z==null?void 0:z.routingNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"accountnumber"},"Account number"),t.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Rt=h==null?void 0:h.accountNumber)!=null?Rt:"",onChange:Lt}),(z==null?void 0:z.accountNumber)&&t.createElement("span",{className:"error-span"},z==null?void 0:z.accountNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),t.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(ut=h==null?void 0:h.confirmAccountNumber)!=null?ut:"",onChange:Lt}),(z==null?void 0:z.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},z==null?void 0:z.confirmAccountNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"bankname"},"Bank name"),t.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(ue=h==null?void 0:h.bankName)!=null?ue:"",onChange:Lt}),(z==null?void 0:z.bankName)&&t.createElement("span",{className:"error-span"},z==null?void 0:z.bankName)),((h==null?void 0:h.accountType)==="business saving"||(h==null?void 0:h.accountType)==="business checking")&&t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"companyName"},"Company name"),t.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(xe=h==null?void 0:h.companyName)!=null?xe:"",onChange:Lt}),(z==null?void 0:z.companyName)&&t.createElement("span",{className:"error-span"},z==null?void 0:z.companyName)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"accounttype"},"Select account type"),t.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(Tt=h==null?void 0:h.accountType)!=null?Tt:"",onChange:Lt},t.createElement("option",{value:""},"Select account"),Ln.map(y=>t.createElement("option",{key:y.value,value:y.value},y.label)))),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},t.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:He,onChange:y=>et(y.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),He&&t.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},t.createElement("p",null,"If checked, I agree for ",t.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),t.createElement("div",{className:"form-group "},t.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},qe((qt=Number(J))==null?void 0:qt.toFixed(2)))))),t.createElement("div",{id:"reader",style:{display:H==="reader"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},J&&J>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",J))),t.createElement("h6",{className:"frac-card-payment-heading"},"Reader Payment"))),t.createElement(zn,{listHeading:"Reader",ListItems:F==null?void 0:F.paymentDeviceList,selectedPax:Ue,setSlectedPax:Je}),t.createElement("button",{onClick:ie,className:"pay-button"},"$",(Ee=Number(e==null?void 0:e.amount))==null?void 0:Ee.toFixed(2)))))))))))))}import a,{useEffect as Jn,useState as Pt}from"react";import Cn from"axios";import $n from"sweetalert2";import{IoArrowBack as hi}from"react-icons/io5";function yi(e){var w,ct,tt,fe,bt,Lt,un,Nt,Et;let[G,R]=Pt(!1),[ke,M]=Pt(!1),[se,I]=Pt(""),[yt,Ye]=Pt(!1),[re,ne]=Pt(!1),[H,_e]=Pt("card"),[p,b]=Pt(!1),[U,$]=Pt("card"),[g,Ae]=Pt("form"),C=e.merchantPublicKey,[Ce,Se]=Pt(void 0),oe=be+"widget/mc-img.svg",He=be+"widget/visa-img.svg",et=be+"widget/ae-img.svg",at=be+"widget/discover-img.svg",dt=be+"widget/card.svg",ot=be+"widget/Trash.svg",xt=be+"widget/bank.svg",Ke=be+"widget/secure-img.png",Ot=be+"widget/pov-by.png",[_,q]=Pt(),[m,j]=Pt({}),[he,x]=Pt([]),[i,r]=Pt(),[c,h]=Pt(void 0),[s,z]=Pt(),[u,f]=Pt(""),S=(T,A)=>{let ie=(parseFloat(A)||0)/100,Xe=T/(1+ie);return Math.round(Xe*100)/100};Jn(()=>{if(e!=null&&e.pass_fee){let T=S(e==null?void 0:e.amount,e==null?void 0:e.surcharge);h(T)}},[e==null?void 0:e.pass_fee]);let le=()=>R(!0),ce=()=>R(!1),Pe=()=>{ne(!1),_e("card"),M(!1),I(""),Ye(!1),f(""),q({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),j({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),b(!1),r({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},lt=()=>ne(!0),Ue=(T,A)=>{let ie=T;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(ie)){(A===""||/^[0-9]+$/.test(A))&&(j(ee=>L(P({},ee),{[ie]:""})),q(ee=>L(P({},ee),{[ie]:A})));return}j(ee=>L(P({},ee),{[ie]:""})),q(ee=>L(P({},ee),{[ie]:A}))},Je=T=>{let ie=T.target.value.replace(/\D/g,""),Xe="";/^3[47]/.test(ie)?Xe=ie.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(pt,rt,Qe,De)=>[rt,Qe,De].filter(Boolean).join(" ")):Xe=ie.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(pt,rt,Qe,De,mt)=>[rt,Qe,De,mt].filter(Boolean).join(" ")),j(ee=>L(P({},ee),{cardNumber:""})),q(ee=>L(P({},ee),{cardNumber:Xe}))},J=()=>{var ee,pt,rt,Qe,De,mt;let T={},A=_,ie=parseInt((A==null?void 0:A.expiryMonth)||"",10),Xe=(A==null?void 0:A.expiryYear)||"";if((ee=A==null?void 0:A.cardName)!=null&&ee.trim()||(T.cardName="Card name is required"),(pt=A==null?void 0:A.cardNumber)!=null&&pt.trim()||(T.cardNumber="Card number is required"),(!((rt=A==null?void 0:A.expiryMonth)!=null&&rt.trim())||!((Qe=A==null?void 0:A.expiryYear)!=null&&Qe.trim())||isNaN(ie)||ie<1||ie>12||Xe.length!==4)&&(T.expiryMonth="Invalid Expiration Date."),(De=A==null?void 0:A.cvv)!=null&&De.trim()||(T.cvv="CVV is required"),(mt=A==null?void 0:A.zipCode)!=null&&mt.trim()||(T.zipCode="ZIP code is required"),A!=null&&A.expiryMonth&&(A!=null&&A.expiryYear)&&A.expiryMonth.length<=2&&A.expiryYear.length===4){let wt=parseInt(A.expiryMonth,10),pe=parseInt(A.expiryYear,10),kt=new Date,At=kt.getMonth()+1,Ft=kt.getFullYear();(pe<Ft||pe===Ft&&wt<At)&&(T.expiryMonth="Card is expired")}return j(T),Object.keys(T).length>0},X=async T=>{var A,ie,Xe,ee,pt,rt,Qe,De,mt,wt,pe,kt,At,Ft,Ht,zt,Bt,Zt,$t;if(T.preventDefault(),H=="card"){if(J())return;{let ut=DatacapWebToken.validateCardNumber(_==null?void 0:_.cardNumber.replaceAll(" ","")),ue=DatacapWebToken.validateExpirationDate(_==null?void 0:_.expiryMonth,_==null?void 0:_.expiryYear),xe=DatacapWebToken.validateCVV(_==null?void 0:_.cvv),Tt={};if(ut||(Tt.cardNumber="Invalid card Number"),ue||(Tt.expiryMonth="Invalid Expiration Date."),xe||(Tt.cvv="Invalid CVV"),j(Tt),ut&&xe&&ue){M(!0);try{let qt=async function(Ee){if(Ee.Error)I(Ee.Error),M(!1);else{let y=_==null?void 0:_.cardName,d=_==null?void 0:_.zipCode;Ee.name=y,Ee.postal_code=d,Ee.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,Ee.amount=e==null?void 0:e.amount,Ee.order_id=e==null?void 0:e.orderID,Ee.preAuth_id="",Ee.isCardSave=p,Ee.customer_id=e==null?void 0:e.customerId,Ee.link_token="",Ee.gateway_id=s==null?void 0:s.paymentGateway,Ee.discount=e==null?void 0:e.discount,Ee.tax=e==null?void 0:e.tax,Ee.surcharge=e==null?void 0:e.surcharge,Ee.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let ve={method:"POST",body:JSON.stringify(Ee),redirect:"follow"};nt.emit("sendMessage",L(P({},ve),{isChargePreauth:!0})),nt.on("charge-preauth",Y=>{var $e;(Y==null?void 0:Y.status)=="Failed"?(M(!1),I((Y==null?void 0:Y.message)||"Something went wrong. Please try again later.")):(Ye(!0),f(($e=Y==null?void 0:Y.data)==null?void 0:$e.transaction_id),M(!1),q({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((s==null?void 0:s.paymentGateway)===32){let Ee={method:"POST",redirect:"follow"};try{let y=await Cn.post(`${Kt}api/v1/widget/generate-session`,Ee),d=Number(_==null?void 0:_.expiryYear)%100,K=_==null?void 0:_.cardNumber;K=K==null?void 0:K.replace(/\s+/g,"");let ve=`${K}=${d}${_==null?void 0:_.expiryMonth} ${_==null?void 0:_.cvv}`,$e=forge.pki.publicKeyFromPem((ie=(A=y==null?void 0:y.data)==null?void 0:A.data)==null?void 0:ie.publicKeyPem).encrypt(ve,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Oe=forge.util.encode64($e),Ze={"Content-Type":"application/json","x-app-session-key":(ee=(Xe=y.data)==null?void 0:Xe.data)==null?void 0:ee.session_key},Ve=JSON.stringify({enc_track2_data:`${Oe}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(rt=(pt=y==null?void 0:y.data)==null?void 0:pt.data)==null?void 0:rt.session_key}`});try{let E=await Cn.post(`${en}tokenizer/tokenize`,Ve,{headers:Ze}),_t=JSON.stringify(L(P({},(Qe=E==null?void 0:E.data)==null?void 0:Qe.data),{name:_==null?void 0:_.cardName,postal_code:_==null?void 0:_.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(mt=(De=E==null?void 0:E.data)==null?void 0:De.data)==null?void 0:mt.token}`,fractalpayPublicKey:C,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:p,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:_==null?void 0:_.expiryYear,ExpirationMonth:_==null?void 0:_.expiryMonth,CVV:_==null?void 0:_.cvv,Last4:(pe=(wt=E==null?void 0:E.data)==null?void 0:wt.data)==null?void 0:pe.last4,Brand:(At=(kt=E==null?void 0:E.data)==null?void 0:kt.data)==null?void 0:At.brand,gateway_id:s==null?void 0:s.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),l={method:"POST",headers:{"Content-Type":"application/json"},body:_t,redirect:"follow"};nt.emit("sendMessage",L(P({},l),{isFractalPreauth:!0})),nt.on("fractal-charge-preauth",B=>{var Q;(B==null?void 0:B.status)=="Failed"?(M(!1),I((B==null?void 0:B.message)||"Something went wrong , Try again later")):(f((Q=B==null?void 0:B.data)==null?void 0:Q.transaction_id),Ye(!0),M(!1))})}catch(E){console.log(E),M(!1),I(((Ht=(Ft=E==null?void 0:E.response)==null?void 0:Ft.data)==null?void 0:Ht.message)||(E==null?void 0:E.message)||"Something went wrong , Try again later")}}catch(y){M(!1),I(((Bt=(zt=y==null?void 0:y.response)==null?void 0:zt.data)==null?void 0:Bt.message)||(y==null?void 0:y.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(s==null?void 0:s.dctoken,"PaymentForm",qt)}catch(qt){M(!1),I((($t=(Zt=qt==null?void 0:qt.response)==null?void 0:Zt.data)==null?void 0:$t.message)||(qt==null?void 0:qt.message)||"Something went wrong.")}}}}},F=async()=>{var T,A,ie,Xe,ee,pt,rt,Qe,De,mt,wt,pe,kt,At,Ft,Ht,zt,Bt,Zt,$t,Rt;le();try{let ut={fractalpayPublicKey:C,customer_id:e==null?void 0:e.customerId,preauth:!0,isReader:!!(e!=null&&e.isReader)},ue=await Cn.post(`${Ie}get-payment-details`,ut);if(z((T=ue==null?void 0:ue.data)==null?void 0:T.data),(ie=(A=ue==null?void 0:ue.data)==null?void 0:A.data)!=null&&ie.paymentGateway||(Pe(),I("Something went wrong.")),(ee=(Xe=ue==null?void 0:ue.data)==null?void 0:Xe.data)!=null&&ee.card_list&&((Qe=(rt=(pt=ue==null?void 0:ue.data)==null?void 0:pt.data)==null?void 0:rt.card_list)==null?void 0:Qe.length)>0){_e("card"),x((mt=(De=ue==null?void 0:ue.data)==null?void 0:De.data)==null?void 0:mt.card_list),((kt=(pe=(wt=ue==null?void 0:ue.data)==null?void 0:wt.data)==null?void 0:pe.card_list)==null?void 0:kt.length)>0&&Ae("list");let xe=(Ht=(Ft=(At=ue==null?void 0:ue.data)==null?void 0:At.data)==null?void 0:Ft.card_list)==null?void 0:Ht.filter(Tt=>(Tt==null?void 0:Tt.primary_card)==1);xe!=null&&xe[0]&&((zt=xe==null?void 0:xe[0])==null?void 0:zt.payment_method_type)==((Zt=(Bt=ue==null?void 0:ue.data)==null?void 0:Bt.data)==null?void 0:Zt.paymentGateway)&&r(xe[0])}else _e("card");ce()}catch(ut){console.log(ut),ce(),I(((Rt=($t=ut==null?void 0:ut.response)==null?void 0:$t.data)==null?void 0:Rt.message)||(ut==null?void 0:ut.message)||"Something went wrong")}},ge=async()=>{var wt,pe,kt,At,Ft,Ht,zt;let T=e==null?void 0:e.customerId,A=e==null?void 0:e.discount,ie=e==null?void 0:e.surcharge,Xe=e==null?void 0:e.tax,ee=e==null?void 0:e.merchantPublicKey,pt=e==null?void 0:e.orderID,rt=e==null?void 0:e.amount,Qe=i==null?void 0:i.id,De=i==null?void 0:i.card_type;if(ee&&pt&&rt)if(T)if(Qe){let Bt={amount:rt,order_id:pt,customer_id:T,card_id:Qe,fractalpayPublicKey:ee,isCardSave:De!="Bank",discount:A,surcharge:ie,tax:Xe},mt=Bt,{isCardSave:Zt}=mt,$t=bn(mt,["isCardSave"]),ut=Ie+"authorize-by-card",ue={"Content-Type":"application/json"};M(!0);try{let xe=await Cn.post(ut,De=="Bank"?$t:Bt,{headers:ue});(wt=xe==null?void 0:xe.data)!=null&&wt.result&&(f((kt=(pe=xe==null?void 0:xe.data)==null?void 0:pe.data)==null?void 0:kt.transaction_id),Ye(!0),M(!1))}catch(xe){M(!1),console.log(xe),I(((Ft=(At=xe==null?void 0:xe.response)==null?void 0:At.data)==null?void 0:Ft.message)||((zt=(Ht=xe==null?void 0:xe.response)==null?void 0:Ht.data)==null?void 0:zt.status)||"Something went erong")}}else I("Please Select A Card/ACH");else I("Please Select Customer");else I("Something went wrong.")};Jn(()=>{re&&C&&F()},[C,re]);let Ne=async T=>{$n.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async A=>{if(A.isConfirmed){M(!0);try{let ie={card_id:T,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},Xe=await Cn.post(`${Ie}delete-customer-card`,ie);M(!1),F(),$n.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(ie){M(!1),$n.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},O=T=>{switch(T==null?void 0:T.toLowerCase()){case"visa":return He;case"mastercard":case"mc":case"m/c":return oe;case"amex":case"american express":case"ae":return et;case"discover":case"dcvr":return at;case"bank":return xt;default:return T}},st=T=>{_e(T)},ze=async()=>{var ee,pt,rt,Qe,De,mt;let T=e==null?void 0:e.merchantPublicKey,A=e==null?void 0:e.orderID,ie=String(e==null?void 0:e.amount),Xe=e==null?void 0:e.customerId;if(!(Ce!=null&&Ce.device_id)){I("Please Select A Payment Device");return}if(T&&A&&ie){M(!0);let wt={amount:ie,fractalpayPublicKey:T,customer_order_id:A,device_id:Ce==null?void 0:Ce.device_id,customer_id:Xe||"",is_auth:!0};try{let pe=await Cn.post(`${Ie}charge-with-reader`,wt);((ee=pe==null?void 0:pe.data)==null?void 0:ee.result)==!0?(f((rt=(pt=pe==null?void 0:pe.data)==null?void 0:pt.data)==null?void 0:rt.transaction_id),Ye(!0),M(!1)):(I(((Qe=pe==null?void 0:pe.data)==null?void 0:Qe.message)||"Something went wrong."),M(!1))}catch(pe){I(((mt=(De=pe==null?void 0:pe.response)==null?void 0:De.data)==null?void 0:mt.message)||"Something went wrong."),M(!1)}}else I("Something went wrong.")},vt=()=>{U==="card"?ge():U==="reader"&&ze()};return a.createElement(a.Fragment,null,a.createElement(tn,null),a.createElement(gn,null),a.createElement(xn,null),a.createElement(a.Fragment,null,a.createElement("button",{className:"paymentBtn",onClick:lt},"PreAuth Payment"),a.createElement(Wt,{open:re,onClose:Pe},se&&a.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},a.createElement(nn,{error:se,onClose:Pe})),yt&&a.createElement(fn,{onClose:Pe,tranId:u}),!se&&!yt&&a.createElement(a.Fragment,null,(G||ke)&&a.createElement(Yt,{loading:G||ke}),a.createElement("div",null,a.createElement("div",{className:"frac-card-payment-page frac-form"},a.createElement("div",{className:"parent-pay-container"},a.createElement("span",{className:"request-payment-close-popup",onClick:Pe},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12425_52336)"},a.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12425_52336"},a.createElement("rect",{width:"16",height:"16",fill:"white"}))))),a.createElement("div",{className:"pay-container"},a.createElement("div",{className:"pay-header pay-conatiner-one"},a.createElement("div",{className:"pay-conatiner-one-first"},a.createElement("div",{className:"pay-logo-container"},a.createElement("div",{className:"pay-main-logo"},a.createElement("img",{src:s==null?void 0:s.logo,id:"pay-logos"}))),a.createElement("div",{className:"amt-pay-con"},a.createElement("div",{className:"pay-amount-conatiner"},a.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),a.createElement("div",{className:"frac-card-bank-radio-main"},a.createElement(an,{label:"Card",amount:(w=Number(e==null?void 0:e.amount))==null?void 0:w.toFixed(2),value:"card",onChange:st,activetab:H}),(e==null?void 0:e.isReader)&&(s==null?void 0:s.paymentDeviceList)&&((ct=s==null?void 0:s.paymentDeviceList)==null?void 0:ct.length)>0&&a.createElement(an,{label:"Reader",amount:(tt=Number(e==null?void 0:e.amount))==null?void 0:tt.toFixed(2),value:"reader",onChange:st,activetab:H})))),a.createElement("div",{className:"pay-conatiner-one-last"},a.createElement("img",{src:Ke,alt:""}),a.createElement("img",{src:Ot,alt:""}),"Secure payments powered by Fractal"),a.createElement("div",null)),!G&&a.createElement("div",{className:"pay-tab pay-conatiner-two"},a.createElement("div",{className:"col-md-12"},a.createElement("div",{id:"payment-form-div"},H!=="cardList"?a.createElement("div",null,a.createElement("div",{className:""},a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},qe((fe=Number(e==null?void 0:e.amount))==null?void 0:fe.toFixed(2)))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:He,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:oe,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:et,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:at,width:35,alt:""})))),c&&c>0&&a.createElement("div",{className:"res-pay-con frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,qe(c.toFixed(2)))))):a.createElement("div",null,a.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",s==null?void 0:s.customer_name),a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},qe((bt=Number(e==null?void 0:e.amount))==null?void 0:bt.toFixed(2)))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:He,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:oe,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:et,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:at,width:35,alt:""})))),a.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),a.createElement("div",{id:"card",style:{display:H==="card"?"block":"none"},className:"tabcontent"},a.createElement("div",{className:"frac-card-payment"},a.createElement("div",{className:"frac-heading-card-wrap"},a.createElement("div",{className:"frac-backarrow"},(he==null?void 0:he.length)>0&&g==="form"&&a.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ae("list")}," ",a.createElement(hi,null)),c&&c>0&&a.createElement("div",{className:"res-pay-con frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,"$",c))),a.createElement("h6",{className:"frac-card-payment-heading"},"Card Authorization")),H!="ach"&&a.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},a.createElement("img",{src:He,alt:"",width:33}),a.createElement("img",{src:oe,width:33,alt:""}),a.createElement("img",{src:et,alt:"",width:33}),a.createElement("img",{src:at,width:33,alt:""}))),g==="list"?a.createElement(a.Fragment,null,a.createElement(mn,{listHeading:"Cards",paymentGateway:s==null?void 0:s.paymentGateway,ListItems:he,selectedCard:i,setSelectedCard:r,handleDeleteCard:Ne,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{Ae("form")}}),a.createElement("div",{className:"form-group",style:{padding:"0"}},a.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:vt},qe((Lt=Number(e==null?void 0:e.amount))==null?void 0:Lt.toFixed(2))))):a.createElement("div",{id:"card",style:{display:H==="card"?"block":"none"},className:"tabcontent"},a.createElement("form",{id:"PaymentForm",onSubmit:X},a.createElement("div",{className:"ach-scrl",style:{minHeight:(he==null?void 0:he.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),a.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(_==null?void 0:_.cardName)||"",onChange:T=>{let A=T.target.value;/^[a-zA-Z\s]*$/.test(A)&&Ue("cardName",A)}}),(m==null?void 0:m.cardName)&&a.createElement("span",{className:"error-span"},m==null?void 0:m.cardName)),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"cardNumber"},"Card Number"),a.createElement("div",{className:"toggle-num-wrapper"},a.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(_==null?void 0:_.cardNumber)||"",onChange:T=>Je(T),"data-token":"card_number"}),a.createElement("div",{className:"card-crdi card-expiry-new"},a.createElement("div",{className:"exp-date-year-container"},a.createElement("div",{className:"exp-date form-group"},a.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(_==null?void 0:_.expiryMonth)||"",onChange:T=>Ue("expiryMonth",T.target.value)})),a.createElement("div",{className:"exp-year form-group"},a.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(_==null?void 0:_.expiryYear)||"",onChange:T=>Ue("expiryYear",T.target.value)})),a.createElement("div",{className:"security-digit form-group"},a.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(_==null?void 0:_.cvv)||"",onChange:T=>Ue("cvv",T.target.value)})))),(m==null?void 0:m.cardNumber)&&a.createElement("span",{className:"error-span"},m==null?void 0:m.cardNumber),a.createElement("p",{style:{margin:"0"}},m!=null&&m.expiryMonth||m!=null&&m.expiryYear?a.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},m==null?void 0:m.expiryMonth):"",(m==null?void 0:m.cvv)&&a.createElement("span",{className:"error-span"},m==null?void 0:m.cvv)))),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"Enter Order id",disabled:!0,value:e==null?void 0:e.orderID,onChange:T=>Ue("orderId",T.target.value),style:{background:"#F6F6F7",color:"#727272"}})),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"zip"},"ZIP"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(un=_==null?void 0:_.zipCode)!=null?un:"",onChange:T=>Ue("zipCode",T.target.value)}),(m==null?void 0:m.zipCode)&&a.createElement("span",{className:"error-span"},m==null?void 0:m.zipCode)),(e==null?void 0:e.customerId)&&a.createElement("div",{className:"form-group"},a.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},a.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:p,onChange:T=>b(T.target.checked)}),a.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),a.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),a.createElement("div",{className:"frac-tooltip-wrapper"},a.createElement("div",{className:"frac-tooltip-icon"},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12420_50192)"},a.createElement("rect",{width:"20",height:"20",fill:"white"}),a.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),a.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12420_50192"},a.createElement("rect",{width:"20",height:"20",fill:"white"}))))),a.createElement("div",{className:"frac-tooltip-text"},a.createElement("p",null,"If checked, I agree to give the ",a.createElement("b",null,(s==null?void 0:s.bname)||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),a.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},a.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},qe((Nt=Number(e==null?void 0:e.amount))==null?void 0:Nt.toFixed(2))))))),a.createElement("div",{id:"reader",style:{display:H==="reader"?"block":"none"},className:"tabcontent"},a.createElement("div",{className:"frac-card-payment"},a.createElement("div",{className:"frac-heading-card-wrap"},a.createElement("div",{className:"frac-backarrow"},c&&c>0&&a.createElement("div",{className:"res-pay-con frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,"$",c))),a.createElement("h6",{className:"frac-card-payment-heading"},"Reader Authorization"))),a.createElement(zn,{listHeading:"Reader",ListItems:s==null?void 0:s.paymentDeviceList,selectedPax:Ce,setSlectedPax:Se}),a.createElement("button",{onClick:ze,className:"pay-button"},"$",(Et=Number(e==null?void 0:e.amount))==null?void 0:Et.toFixed(2))))))))))))))}import D,{useEffect as vi,useRef as _n,useState as hn}from"react";import Ci from"sweetalert2";import Nn from"axios";import bi from"react";function Vn(){let e="#000",G="#fff",R="#212529",ke="#dee2e6";return bi.createElement("style",null,`
1554
+ }`)}function Rn(e,h,q){e.preventDefault();let N={type:"preview.compiledcheck",other:{msg:"Payment success!",status:h==="close",data:{tran_id:q,key:h}}};console.log("message:",N),window.parent.postMessage(N,"*")}function ri({onClose:e,tranId:h}){return _t.createElement(_t.Fragment,null,_t.createElement(Gi,null),_t.createElement("div",{className:"payment-msg-container"},_t.createElement("div",{className:"charge-payment-success-container"},_t.createElement("div",{className:"charge-payment-success-tick-div"},_t.createElement("div",{className:"charge-payment-success-tick"},_t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},_t.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"})))),_t.createElement("h6",{className:"charge-payment-success-text"},"Your charge",_t.createElement("br",null),"was successful"),_t.createElement("h6",{className:"charge-payment-success-subtext"},"We\u2019ve processed your charge"),_t.createElement("div",{className:"charge-success-payment-button-div"},_t.createElement("button",{className:"charge-success-btn1",onClick:q=>Rn(q,"print",h)},_t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},_t.createElement("path",{d:"M15.7729 8.7272C15.58 8.7272 15.395 8.80383 15.2586 8.94022C15.1222 9.07661 15.0456 9.2616 15.0456 9.45448V12.5185C15.045 13.0559 14.8313 13.5711 14.4513 13.9511C14.0713 14.3311 13.5561 14.5449 13.0187 14.5454H3.98149C3.44409 14.5449 2.92887 14.3311 2.54887 13.9511C2.16887 13.5711 1.95514 13.0559 1.95456 12.5185V9.45448C1.95456 9.2616 1.87794 9.07661 1.74154 8.94022C1.60515 8.80383 1.42017 8.7272 1.22728 8.7272C1.03439 8.7272 0.849407 8.80383 0.713015 8.94022C0.576624 9.07661 0.5 9.2616 0.5 9.45448V12.5185C0.500963 13.4416 0.86807 14.3265 1.52077 14.9792C2.17346 15.6319 3.05844 15.999 3.98149 16H13.0187C13.9417 15.999 14.8267 15.6319 15.4794 14.9792C16.1321 14.3265 16.4992 13.4416 16.5002 12.5185V9.45448C16.5002 9.2616 16.4235 9.07661 16.2871 8.94022C16.1507 8.80383 15.9658 8.7272 15.7729 8.7272Z",fill:"#161616"}),_t.createElement("path",{d:"M4.65059 6.75861L7.7728 9.88082V0.72728C7.7728 0.534394 7.84942 0.349407 7.98581 0.213015C8.1222 0.0766239 8.30719 0 8.50008 0C8.69296 0 8.87795 0.0766239 9.01434 0.213015C9.15073 0.349407 9.22736 0.534394 9.22736 0.72728V9.88082L12.3496 6.75861C12.4867 6.62613 12.6704 6.55283 12.8611 6.55448C13.0518 6.55614 13.2342 6.63263 13.3691 6.76747C13.5039 6.90231 13.5804 7.08472 13.5821 7.27541C13.5837 7.46611 13.5104 7.64982 13.3779 7.78698L9.01427 12.1507C8.87788 12.287 8.69293 12.3636 8.50008 12.3636C8.30723 12.3636 8.12228 12.287 7.98589 12.1507L3.62221 7.78698C3.48973 7.64982 3.41643 7.46611 3.41808 7.27541C3.41974 7.08472 3.49623 6.90231 3.63107 6.76747C3.76592 6.63263 3.94833 6.55614 4.13902 6.55448C4.32971 6.55283 4.51342 6.62613 4.65059 6.75861Z",fill:"#161616"})),"Print receipt"),_t.createElement("button",{className:"charge-success-btn1",onClick:q=>Rn(q,"share",h)},_t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},_t.createElement("g",{clipPath:"url(#clip0_12420_50683)"},_t.createElement("path",{d:"M9.30194 4.78664V2.31152C9.30194 2.09629 9.3862 1.88988 9.53631 1.73768C9.68634 1.5855 9.8899 1.5 10.1021 1.5C10.312 1.50089 10.5132 1.58542 10.6622 1.73534L16.2633 7.41595C16.3383 7.49142 16.3978 7.58117 16.4385 7.68001C16.4791 7.77894 16.5 7.885 16.5 7.99212C16.5 8.09924 16.4791 8.20531 16.4385 8.30423C16.3978 8.40307 16.3383 8.49283 16.2633 8.5683L10.6622 14.2489C10.5499 14.3606 10.4076 14.4362 10.2531 14.4663C10.0987 14.4964 9.93887 14.4797 9.79372 14.4182C9.64857 14.3568 9.52455 14.2532 9.43701 14.1206C9.34955 13.9881 9.30258 13.8323 9.30194 13.6727V11.157H8.62181C7.35764 11.1379 6.10443 11.3981 4.94932 11.9193C3.79422 12.4406 2.76481 13.2107 1.93249 14.1759C1.83215 14.3113 1.6926 14.4115 1.53337 14.4624C1.37406 14.5134 1.20306 14.5125 1.04431 14.4599C0.882759 14.4046 0.742811 14.2984 0.644952 14.1568C0.547092 14.0152 0.496363 13.8456 0.500203 13.6727C0.500203 6.27171 6.96548 5.00575 9.30194 4.78664ZM8.62181 9.51777C9.15695 9.51607 9.69162 9.55129 10.2221 9.62327C10.4115 9.6524 10.5844 9.74954 10.7092 9.89699C10.834 10.0444 10.9025 10.2324 10.9023 10.4267V11.717L14.567 7.99212L10.9023 4.26727V5.55758C10.9023 5.77281 10.8179 5.97922 10.6679 6.13141C10.5178 6.28359 10.3143 6.36909 10.1021 6.36909C9.37396 6.36909 3.61282 6.5314 2.36457 11.5871C4.17637 10.2324 6.3708 9.50665 8.62181 9.51777Z",fill:"#161616"})),_t.createElement("defs",null,_t.createElement("clipPath",{id:"clip0_12420_50683"},_t.createElement("rect",{width:"16",height:"16",fill:"white",transform:"translate(0.5)"})))),"Send receipt"))),_t.createElement("div",{className:"charge-payment-success-btn-div"},_t.createElement("button",{className:"charge-payment-success-btn1",onClick:q=>Rn(q,"tran",h)},"Go to Transactions"),_t.createElement("button",{className:"charge-payment-success-btn2",onClick:q=>{e(),Rn(q,"close",h)}},"Close"))))}import Si from"sweetalert2";import{IoArrowBack as Oi}from"react-icons/io5";import{useEffect as fa}from"react";function An(){return fa(()=>{let e=ni;if(typeof window!="undefined"&&!window.DatacapWebToken&&!document.querySelector(`script[src="${e}"]`)){let h=document.createElement("script");h.src=e,h.async=!0,h.onload=()=>{window.DatacapWebToken||console.warn("\u26A0\uFE0F Script loaded, but DatacapWebToken not found")},h.onerror=q=>{console.error("\u274C Failed to load Datacap script",q)},document.head.appendChild(h)}},[]),fa(()=>{let e="forge-cdn-script";if(!document.getElementById(e)){let h=document.createElement("script");h.src="https://cdn.jsdelivr.net/npm/node-forge@1.0.0/dist/forge.min.js",h.id=e,h.async=!0,document.head.appendChild(h)}return()=>{let h=document.getElementById(e);h&&document.head.removeChild(h)}},[]),null}import zn from"react";import er from"react";function Ui(){return er.createElement("style",null,`
1555
+ .card-error .logo-container {
1556
+ display: flex;
1557
+ justify-content: center;
1558
+ align-items: center;
1559
+ margin-bottom: -50px; /* Adjust this to overlap the content */
1560
+ z-index: 10;
1561
+ }
1562
+
1563
+ .card-error .client-logo {
1564
+ max-width: 100px;
1565
+ height: auto;
1566
+ object-fit: contain;
1567
+ display: block;
1568
+ }
1569
+
1570
+ .card-error .payment-error-container {
1571
+ display: flex;
1572
+ flex-direction: column;
1573
+ align-items: center;
1574
+ padding: 18px 20px 24px;
1575
+ // width: 335px;
1576
+ min-height: 250px; /* Fixed height */
1577
+ background: #FFFFFF;
1578
+ border-radius: 12px;
1579
+ position: relative;
1580
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
1581
+ border: 1px solid #e3e3e3;
1582
+ justify-content: center;
1583
+ text-align: center;
1584
+ // margin-top: 50px; /* Adjust this to move the content down */
1585
+ margin: 50px auto 0 auto !important;
1586
+ }
1587
+
1588
+ .card-error .error-icon {
1589
+ display: flex;
1590
+ flex-direction: column;
1591
+ align-items: center;
1592
+ gap: 12px;
1593
+ min-height: 116px;
1594
+ z-index: 2;
1595
+ }
1596
+
1597
+ .card-error .circle {
1598
+ width: 50px;
1599
+ height: 50px;
1600
+ border: 1px solid red;
1601
+ border-radius: 50%;
1602
+ display: flex;
1603
+ justify-content: center;
1604
+ align-items: center;
1605
+ margin-bottom:20px
1606
+ }
1607
+
1608
+ .card-error .circle .fa-times {
1609
+ font-size: 30px;
1610
+ color: red;
1611
+ }
1612
+
1613
+ .card-error .error-text {
1614
+ display: flex;
1615
+ flex-direction: column;
1616
+ justify-content: center;
1617
+ align-items: center;
1618
+ gap: 4px;
1619
+ // width: 227px;
1620
+ }
1621
+
1622
+ .card-error .payment-error-text {
1623
+ font-family: 'Inter', sans-serif;
1624
+ font-weight: 500;
1625
+ font-size: 18px;
1626
+ line-height: 21px;
1627
+ text-align: center;
1628
+ letter-spacing: -0.02em;
1629
+ color: #161616;
1630
+ }
1631
+
1632
+ .card-error .thank-you-text {
1633
+ font-family: 'Inter', sans-serif;
1634
+ font-weight: 500;
1635
+ font-size: 16px;
1636
+ line-height: 18px;
1637
+ text-align: center;
1638
+ letter-spacing: -0.02em;
1639
+ color: #161616 !important;
1640
+ opacity: 0.5;
1641
+ padding-top:10px
1642
+ }
1643
+
1644
+ .card-error .error-btn-div{
1645
+ padding-top:30px;
1646
+
1647
+ }
1648
+ .card-error .error-btn-div button{
1649
+ border-radius: 0.25em;
1650
+ border:none;
1651
+ background: initial;
1652
+ background-color: #7066e0;
1653
+ box-shadow: var(--swal2-confirm-button-box-shadow);
1654
+ color: white;
1655
+ font-size: 1em;
1656
+ padding:10px 17px;
1657
+ cursor:pointer;
1658
+ }
1659
+ `)}var tr=({onClose:e,error:h})=>zn.createElement(zn.Fragment,null,zn.createElement(Ui,null),zn.createElement("div",{className:"card-error"},zn.createElement("div",{className:"payment-error-container"},zn.createElement("div",{className:"error-icon"},zn.createElement("div",{className:"circle"},zn.createElement("i",{className:"fa fa-times","aria-hidden":"true"})),zn.createElement("div",{className:"error-text"},zn.createElement("div",{className:"payment-error-text"},h),zn.createElement("div",{className:"thank-you-text"},"Try again later ")),zn.createElement("div",{className:"error-btn-div"},zn.createElement("button",{onClick:e},"OK")))))),Tn=tr;import{io as nr}from"socket.io-client";var ir=nr(tt,{transports:["websocket"],withCredentials:!1}),Et=ir;import Un from"react";var In=e=>Un.createElement(Un.Fragment,null,Un.createElement("div",{className:`frac-card-bank-radio ${e.activetab===e.value?"frac-active":""}`,onClick:()=>e.onChange(e.value),role:"radio"},Un.createElement("div",{className:"frac-card-title-main"},Un.createElement("img",{src:e.label.toLowerCase()==="card"?ki:e.label.toLowerCase()==="reader"?Hi:ua,className:"frac-payment-type-logo",alt:""}),Un.createElement("div",{className:"frac-card-label"},Un.createElement("div",{className:"frac-card-label-text"},e.label),Un.createElement("div",{className:"frac-card-label-amount"},Se(e.amount)))),Un.createElement("div",null,Un.createElement("input",{name:"paymenttype",checked:e.activetab===e.value,type:"radio",value:e.value,onChange:h=>{e.onChange(h.target.value)}}))));import ar from"react";function Xn({}){return ar.createElement("style",null,`
1660
+ .frac-card-bank-radio-main{
1661
+ display: flex;
1662
+ flex-direction: column;
1663
+ align-items: flex-start;
1664
+ align-self: stretch;
1665
+ border-radius: 14px;
1666
+ border: 1px solid #E0DFE2;
1667
+ overflow: hidden;
1668
+ }
1669
+
1670
+ .frac-card-bank-radio{
1671
+ display: flex;
1672
+ padding: 12px 16px;
1673
+ justify-content: space-between;
1674
+ align-items: center;
1675
+ align-self: stretch;
1676
+ }
1677
+
1678
+ input[type="radio"] {
1679
+ accent-color: #000;
1680
+ }
1681
+
1682
+ .frac-card-title-main{
1683
+ display: flex;
1684
+ align-items: center;
1685
+ gap: 12px;
1686
+ }
1687
+
1688
+ .frac-card-label{
1689
+ display: flex;
1690
+ flex-direction: column;
1691
+ align-items: flex-start;
1692
+ gap: 2px;
1693
+ }
1694
+
1695
+ .frac-card-label-text{
1696
+ color: #727272;
1697
+ font-family: Inter;
1698
+ font-size: 12px;
1699
+ font-style: normal;
1700
+ font-weight: 500;
1701
+ line-height: 18px;
1702
+ letter-spacing: -0.24px;
1703
+ }
1704
+
1705
+ .frac-card-label-amount{
1706
+ color: #161616;
1707
+ text-align: center;
1708
+ font-family: Inter;
1709
+ font-size: 16px;
1710
+ font-style: normal;
1711
+ font-weight: 500;
1712
+ line-height: 140%;
1713
+ letter-spacing: -0.32px;
1714
+ }
1715
+
1716
+ .frac-payment-type-logo{
1717
+ width: 24px;
1718
+ height: 24px;
1719
+ aspect-ratio: 1/1;
1720
+ }
1721
+
1722
+ .frac-card-bank-radio-main .frac-card-bank-radio:nth-child(2) {
1723
+ border-top: 1px solid #E0DFE2;
1724
+ }
1725
+
1726
+ .frac-card-bank-radio-main .frac-card-bank-radio:nth-child(3) {
1727
+ border-top: 1px solid #E0DFE2;
1728
+ }
1729
+
1730
+ .frac-card-bank-radio.frac-active {
1731
+ background: #F6F6F7;
1732
+ }
1733
+ `)}import un from"react";var En=({listHeading:e="Card",ListItems:h,selectedCard:q,setSelectedCard:$,paymentGateway:N,handleDeleteCard:I,otherButtonAction:z,otherButtonLabel:ie,headingClass:ge})=>{let Q=D+"widget/Trash.svg";return un.createElement(un.Fragment,null,un.createElement("h6",{className:ge||"card-ach-heading",style:{marginBottom:"10px !important"}},e),un.createElement("div",{className:"card-lint-div-in"},un.createElement("div",{className:"card-list-div"},h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.map((L,Z)=>{let ae=!1;return N&&(ae=N!=(L==null?void 0:L.payment_method_type)&&(L==null?void 0:L.card_type)!="Bank"),un.createElement("div",{key:L==null?void 0:L.id,className:"card-list-single-div"},un.createElement("div",{className:"card-number-radio"},un.createElement("input",{disabled:ae,type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:(q==null?void 0:q.id)===(L==null?void 0:L.id),onChange:w=>$(L)}),un.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",L==null?void 0:L.cardlastfourdigit),(L==null?void 0:L.card_type)!="Bank"&&un.createElement("h6",{className:"card-expiry-date"},L==null?void 0:L.expmonth,"/",L==null?void 0:L.expyear)),un.createElement("div",{className:"card-number-radio"},un.createElement("span",{className:"visa-card"},un.createElement("img",{src:ga(L==null?void 0:L.card_type),alt:""})),un.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>I(L==null?void 0:L.id)},un.createElement("img",{src:Q,alt:""}))))}))),un.createElement("div",{className:"pay-with-other-card",onClick:z},ie,un.createElement("img",{src:ki,alt:""}))))};import qn from"react";var ji=({listHeading:e="Readers",ListItems:h,selectedPax:q,setSlectedPax:$,headingClass:N})=>qn.createElement(qn.Fragment,null,qn.createElement("h6",{className:N||"card-ach-heading",style:{marginBottom:"10px !important"}},e),qn.createElement("div",{className:"card-lint-div-in"},qn.createElement("div",{className:"card-list-div"},h&&(h==null?void 0:h.length)>0&&(h==null?void 0:h.map((I,z)=>qn.createElement("div",{key:I==null?void 0:I.id,className:"card-list-single-div"},qn.createElement("div",{className:"card-number-radio"},qn.createElement("input",{type:"radio",className:"cardRadio",name:"selected_reader",id:"",checked:(q==null?void 0:q.id)===(I==null?void 0:I.id),onChange:ie=>$(I)}),qn.createElement("label",{htmlFor:"",className:"card-number-last-four"},I==null?void 0:I.device_name)),qn.createElement("div",{className:"card-number-radio"},qn.createElement("span",{className:"visa-card"},qn.createElement("img",{src:Hi,alt:""})))))))));function rr(e){var qt,Nt,jt,Gt,Je,Ut,ln,yt,dn,Xt,tn,fn,hn,Fn,Ot,Be,De,xn,vn,kt;let[h,q]=Kt(!1),[$,N]=Kt(!1),[I,z]=Kt(""),[ie,ge]=Kt(!1),[Q,L]=Kt(!1),[Z,ae]=Kt("card"),[w,v]=Kt("card"),[R,E]=Kt("form"),[y,Pe]=Kt("form"),[C,Ae]=Kt(!0),[$e,pe]=Kt(!1),[Ve,rt]=Kt(!1),Ce=e.merchantPublicKey,Xe=D+"widget/mc-img.svg",fe=D+"widget/visa-img.svg",nt=D+"widget/ae-img.svg",Ee=D+"widget/discover-img.svg",pn=D+"widget/card.svg",Y=D+"widget/Trash.svg",p=D+"widget/bank.svg",u=D+"widget/secure-img.png",A=D+"widget/pov-by.png",re=D+"widget/pax.svg",[o,a]=Kt(),[i,b]=Kt({}),[P,g]=Kt(),[W,x]=Kt({}),[S,F]=Kt([]),[Ke,Ye]=Kt([]),[gt,Yt]=Kt(),[Ct,wt]=Kt(void 0),[he,ce]=Kt(Number(e==null?void 0:e.amount));console.log(gt,"selectedCard");let[H,ze]=Kt(),[Ie,oe]=Kt(""),pt=()=>q(!0),mt=()=>q(!1),Pt=(_,f)=>{let de=(parseFloat(f)||0)/100,ct=_/(1+de);return Math.round(ct*100)/100};ha(()=>{if(Q){let _=Pt(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);ce(_)}},[Q,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let B=()=>{L(!1),ae("card"),z(""),ge(!1),oe(""),g({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),x({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),a({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),b({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),rt(!1),pe(!1),Yt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),wt(null),ce(0),v("card"),Ae(!0),Pe("form"),E("form"),N(!1),q(!1),Ye([]),F([])},Ht=()=>L(!0),vt=_=>{ae(_)},He=(_,f)=>{let de=_;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(de)){(f===""||/^[0-9]+$/.test(f))&&(b(ee=>M(k({},ee),{[de]:""})),a(ee=>M(k({},ee),{[de]:f})));return}b(ee=>M(k({},ee),{[de]:""})),a(ee=>M(k({},ee),{[de]:f}))},It=_=>{var ee;let f=_.target,{formatted:de,cursor:ct}=Bn(f.value,(ee=f.selectionStart)!=null?ee:0);b(We=>M(k({},We),{cardNumber:""})),a(We=>M(k({},We),{cardNumber:de})),requestAnimationFrame(()=>{f.setSelectionRange(ct,ct)})},sn=_=>{let{name:f,value:de}=_.target,ct=["routingNumber","accountNumber","confirmAccountNumber"];if(f=="name"){/^[a-zA-Z\s]*$/.test(de)&&(x(ee=>M(k({},ee),{[f]:""})),g(ee=>M(k({},ee),{[f]:de})));return}if(ct.includes(f)){(de===""||/^[0-9]+$/.test(de))&&(x(ee=>M(k({},ee),{[f]:""})),g(ee=>M(k({},ee),{[f]:de})));return}x(ee=>M(k({},ee),{[f]:""})),g(ee=>M(k({},ee),{[f]:de}))},Wn=()=>{var ee,We,ye,$t,Ft,be;let _={},f=o,de=parseInt((f==null?void 0:f.expiryMonth)||"",10),ct=(f==null?void 0:f.expiryYear)||"";if((ee=f==null?void 0:f.cardName)!=null&&ee.trim()||(_.cardName="Card name is required"),(We=f==null?void 0:f.cardNumber)!=null&&We.trim()||(_.cardNumber="Card number is required"),(!((ye=f==null?void 0:f.expiryMonth)!=null&&ye.trim())||!(($t=f==null?void 0:f.expiryYear)!=null&&$t.trim())||isNaN(de)||de<1||de>12||ct.length!==4)&&(_.expiryMonth="Invalid Expiration Date."),(Ft=f==null?void 0:f.cvv)!=null&&Ft.trim()||(_.cvv="CVV is required"),(be=f==null?void 0:f.zipCode)!=null&&be.trim()||(_.zipCode="ZIP code is required"),f!=null&&f.expiryMonth&&(f!=null&&f.expiryYear)&&f.expiryMonth.length<=2&&f.expiryYear.length===4){let Dt=parseInt(f.expiryMonth,10),c=parseInt(f.expiryYear,10),m=new Date,G=m.getMonth()+1,we=m.getFullYear();(c<we||c===we&&Dt<G)&&(_.expiryMonth="Card is expired")}return b(_),Object.keys(_).length>0},Zt=()=>{var de,ct,ee,We,ye,$t,Ft,be;let _={},f=P;return(de=f==null?void 0:f.name)!=null&&de.trim()||(_.name="Name is required"),(ct=f==null?void 0:f.accountNumber)!=null&&ct.trim()||(_.accountNumber="Account number is required"),(ee=f==null?void 0:f.accountNumber)!=null&&ee.trim()&&((We=f==null?void 0:f.accountNumber)==null?void 0:We.trim())!==((ye=f==null?void 0:f.confirmAccountNumber)==null?void 0:ye.trim())&&(_.confirmAccountNumber="Account numbers must match"),($t=f==null?void 0:f.bankName)!=null&&$t.trim()||(_.bankName="Bank name is required"),(Ft=f==null?void 0:f.routingNumber)!=null&&Ft.trim()||(_.routingNumber="Routing Number is required"),f!=null&&f.routingNumber&&((be=f==null?void 0:f.routingNumber)==null?void 0:be.length)!==9&&(_.routingNumber="Routing number must be 9 digits"),((f==null?void 0:f.accountType)==="business saving"||(f==null?void 0:f.accountType)==="business checking")&&(!(f!=null&&f.companyName)||(f==null?void 0:f.companyName)==="")&&(_.companyName="Company Name is required for business accounts"),x(_),Object.keys(_).length>0},Nn=async _=>{var f,de,ct,ee,We,ye,$t,Ft,be,Dt,c,m,G,we,ne,ft;if(_.preventDefault(),Z!=="ach"){if(Wn())return;{let xe=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),ue=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),Re=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),it={};if(xe||(it.cardNumber="Invalid card Number"),ue||(it.expiryMonth="Invalid Expiration Date."),Re||(it.cvv="Invalid CVV"),b(it),xe&&Re&&ue){N(!0);try{let Ne={amount:`${e.amount||0}`,fractalpayPublicKey:Ce,orderId:e==null?void 0:e.orderID,customer_id:e==null?void 0:e.customerId,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,pass_fee:e==null?void 0:e.pass_fee},at=await ui.post(`${tt}create-widget-order`,Ne),ve=async function(xt){if(xt.Error)z(xt.Error),N(!1);else{let ot=o==null?void 0:o.cardName,Rt=o==null?void 0:o.zipCode;xt.name=ot,xt.postal_code=Rt,xt.isCardSave=`${$e}`,xt.isCharge=!0,xt.posSalesIdEncode=at==null?void 0:at.data.data.posSalesIdEncode,Et.emit("sendMessage",xt),Et.on(at==null?void 0:at.data.data.posSalesIdEncode,ht=>{if(mi(ht==null?void 0:ht.data)){let je=JSON.parse(ht.data);je!=null&&je.result?(a({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),pe(!1),oe(je==null?void 0:je.transactionId),ge(!0),N(!1)):(N(!1),z((je==null?void 0:je.message)||"Something went wrong."))}else z("Something went wrong.")})}};if((H==null?void 0:H.paymentGateway)===32){let xt={method:"POST",redirect:"follow"};try{let ot=await ui.post(`${Le}api/v1/widget/generate-session`,xt),Rt=Number(o==null?void 0:o.expiryYear)%100,ht=o==null?void 0:o.cardNumber;ht=ht==null?void 0:ht.replace(/\s+/g,"");let je=`${ht}=${Rt}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,Mn=forge.pki.publicKeyFromPem((de=(f=ot==null?void 0:ot.data)==null?void 0:f.data)==null?void 0:de.publicKeyPem).encrypt(je,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Cn=forge.util.encode64(Mn),nn={"Content-Type":"application/json","x-app-session-key":(ee=(ct=ot.data)==null?void 0:ct.data)==null?void 0:ee.session_key},st=JSON.stringify({enc_track2_data:`${Cn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(ye=(We=ot==null?void 0:ot.data)==null?void 0:We.data)==null?void 0:ye.session_key}`});try{let se=await ui.post(`${cn}tokenizer/tokenize`,st,{headers:nn}),an=JSON.stringify(M(k({},($t=se==null?void 0:se.data)==null?void 0:$t.data),{isSaveCardChecked:$e,name:o==null?void 0:o.cardName,postal_code:o==null?void 0:o.zipCode,customer_id:e==null?void 0:e.customerId})),kn=JSON.stringify({pre_sales_id:`${(be=(Ft=at==null?void 0:at.data)==null?void 0:Ft.data)==null?void 0:be.posSalesIdEncode}`,token:`${(Dt=se==null?void 0:se.data)==null?void 0:Dt.data.token}`,json_response:`${an}`}),Yn={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:kn,redirect:"follow",isChargeviafractal:!0};Et.emit("sendMessage",Yn),Et.on("chargeviafractalgateway",Wt=>{var ei;if(mi(Wt==null?void 0:Wt.data)){let _n=JSON.parse(Wt==null?void 0:Wt.data);_n!=null&&_n.result?(oe((ei=_n==null?void 0:_n.data)==null?void 0:ei.transactionId),ge(!0),N(!1)):(N(!1),z((_n==null?void 0:_n.message)||"Something went wrong."))}else z("Something went wrong.")})}catch(se){N(!1),z(((m=(c=se==null?void 0:se.response)==null?void 0:c.data)==null?void 0:m.message)||(se==null?void 0:se.message)||"Something went wrong.")}}catch(ot){N(!1),z(((we=(G=ot==null?void 0:ot.response)==null?void 0:G.data)==null?void 0:we.message)||(ot==null?void 0:ot.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(at==null?void 0:at.data.data.dctoken,"PaymentForm",ve)}catch(Ne){N(!1),z(((ft=(ne=Ne==null?void 0:Ne.response)==null?void 0:ne.data)==null?void 0:ft.message)||(Ne==null?void 0:Ne.message)||"Something went wrong.")}}}}else{if(Zt())return;{N(!0);let xe={fractalpayPublicKey:Ce,label:(P==null?void 0:P.name)||"John Doe",account_number:P==null?void 0:P.accountNumber,routing_number:P==null?void 0:P.routingNumber,bank_name:P==null?void 0:P.bankName,account_type:P==null?void 0:P.accountType,amount:String(he||0),isSaveAch:Ve,customer_id:e==null?void 0:e.customerId,order_id:e==null?void 0:e.orderID,tax:e==null?void 0:e.tax,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,isChargeACH:!0,company_name:(P==null?void 0:P.companyName)||""};Et.emit("sendMessage",xe),Et.on("ach-incoming",ue=>{var Re;(ue==null?void 0:ue.status)=="Failed"?typeof(ue==null?void 0:ue.message)=="object"?Object.values(ue==null?void 0:ue.message).forEach(it=>{z(it||"Something went wrong")}):z((ue==null?void 0:ue.message)||"Something went wrong"):(oe((Re=ue==null?void 0:ue.data)==null?void 0:Re.transaction_id),ge(!0),N(!1))})}}},U=async()=>{var _,f,de,ct,ee,We,ye,$t,Ft,be,Dt,c,m,G,we,ne,ft,bt,xe,ue,Re,it,Ne;pt();try{let at={fractalpayPublicKey:Ce,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,isReader:e==null?void 0:e.isReader},ve=await ui.post(`${tt}get-payment-details`,at);if(ze((_=ve==null?void 0:ve.data)==null?void 0:_.data),(de=(f=ve==null?void 0:ve.data)==null?void 0:f.data)!=null&&de.paymentGateway||(B(),z("Something went wrong.")),(ee=(ct=ve==null?void 0:ve.data)==null?void 0:ct.data)!=null&&ee.card_list&&(($t=(ye=(We=ve==null?void 0:ve.data)==null?void 0:We.data)==null?void 0:ye.card_list)==null?void 0:$t.length)>0){let xt=(Dt=(be=(Ft=ve==null?void 0:ve.data)==null?void 0:Ft.data)==null?void 0:be.card_list)==null?void 0:Dt.filter(Rt=>(Rt==null?void 0:Rt.card_type)=="Bank"),ot=(G=(m=(c=ve==null?void 0:ve.data)==null?void 0:c.data)==null?void 0:m.card_list)==null?void 0:G.filter(Rt=>(Rt==null?void 0:Rt.card_type)!=="Bank");console.log(xt,"hohgohoo",ot),(ot==null?void 0:ot.length)>0&&E("list"),(xt==null?void 0:xt.length)>0&&Pe("list"),F(ot),Ye(xt)}else ae("card");(ne=(we=ve==null?void 0:ve.data)==null?void 0:we.data)!=null&&ne.paymentDeviceList&&((xe=(bt=(ft=ve==null?void 0:ve.data)==null?void 0:ft.data)==null?void 0:bt.paymentDeviceList)==null?void 0:xe.length)>0&&wt((Re=(ue=ve==null?void 0:ve.data)==null?void 0:ue.data)==null?void 0:Re.paymentDeviceList[0]),mt()}catch(at){console.log(at),mt(),z(((Ne=(it=at==null?void 0:at.response)==null?void 0:it.data)==null?void 0:Ne.message)||(at==null?void 0:at.message)||"Something went wrong")}},K=async()=>{let _=e==null?void 0:e.customerId,f=String(e==null?void 0:e.discount),de=String(e==null?void 0:e.surcharge),ct=String(e==null?void 0:e.tax),ee=e==null?void 0:e.merchantPublicKey,We=e==null?void 0:e.orderID,ye=String(e==null?void 0:e.amount),$t=gt==null?void 0:gt.id,Ft=gt==null?void 0:gt.card_type;if(ee&&We&&ye&&he)if(_)if($t){let Dt={amount:Ft==="Bank"?`${he}`:ye,order_id:We,customer_id:_,card_id:$t,fractalpayPublicKey:ee,isCardSave:$e,discount:f,surcharge:de,tax:ct,pass_fee:e==null?void 0:e.pass_fee,require3ds:!1},be=Dt,{isCardSave:c,pass_fee:m,require3ds:G}=be,we=di(be,["isCardSave","pass_fee","require3ds"]),ft=tt+(Ft==="Bank"?"charge-ach":"charge-by-card"),bt={"Content-Type":"application/json"};N(!0),Et.emit("sendMessage",{url:ft,body:Ft=="Bank"?we:Dt,isChargebycard:!0}),Et.on("charge-by-card",xe=>{var ue;(xe==null?void 0:xe.result)==!0||(xe==null?void 0:xe.status)==!0?(oe((ue=xe.data)==null?void 0:ue.transaction_id),ge(!0),N(!1)):z((xe==null?void 0:xe.message)||"Something went wrong.")})}else z("Please Select A Card/ACH");else z("Please Select Customer");else z("Something went wrong.")},Ze=async()=>{var ee,We,ye,$t,Ft,be;let _=e==null?void 0:e.merchantPublicKey,f=e==null?void 0:e.orderID,de=String(e==null?void 0:e.amount),ct=e==null?void 0:e.customerId;if(!(Ct!=null&&Ct.device_id)){z("Please Select A Payment Device");return}if(_&&f&&de){N(!0);let Dt={amount:de,fractalpayPublicKey:_,customer_order_id:f,device_id:Ct==null?void 0:Ct.device_id,customer_id:ct||""};try{let c=await ui.post(`${tt}charge-with-reader`,Dt);((ee=c==null?void 0:c.data)==null?void 0:ee.result)==!0?(oe((ye=(We=c==null?void 0:c.data)==null?void 0:We.data)==null?void 0:ye.transaction_id),ge(!0),N(!1)):(z((($t=c==null?void 0:c.data)==null?void 0:$t.message)||"Something went wrong."),N(!1))}catch(c){z(((be=(Ft=c==null?void 0:c.response)==null?void 0:Ft.data)==null?void 0:be.message)||"Something went wrong."),N(!1)}}else z("Something went wrong.")},Bt=()=>{w==="card"?K():w==="reader"&&Ze()};ha(()=>{Q&&Ce&&U()},[Ce,Q]);let Fe=async _=>{Si.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async f=>{if(f.isConfirmed){N(!0);try{let de={card_id:_,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},ct=await ui.post(`${tt}delete-customer-card`,de);N(!1),U(),Si.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(de){N(!1),Si.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else f.dismiss===Si.DismissReason.cancel&&Si.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},Lt=_=>{switch(_==null?void 0:_.toLowerCase()){case"visa":return fe;case"mastercard":case"mc":case"m/c":return Xe;case"amex":case"american express":case"ae":return nt;case"discover":case"dcvr":return Ee;case"bank":return p;default:return _}},Tt=()=>{let _=he||0;return(Number(e.amount)-_).toFixed(0)};return console.log(R,"activeinCard","activeinBank",y),t.createElement(t.Fragment,null,t.createElement(An,null),t.createElement(ai,null),t.createElement(Xn,null),t.createElement(t.Fragment,null,t.createElement("button",{className:"paymentBtn",onClick:Ht},"Pay"),t.createElement(Pn,{open:Q,onClose:B},I&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(Tn,{error:I,onClose:B})),ie&&t.createElement(ri,{onClose:B,tranId:Ie}),!I&&!ie&&t.createElement(t.Fragment,null,(h||$)&&t.createElement(mn,{loading:h||$}),t.createElement("div",{className:"frac-card-payment-page frac-form"},t.createElement("div",{className:"parent-pay-container"},t.createElement("span",{className:"request-payment-close-popup",onClick:B},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t.createElement("g",{clipPath:"url(#clip0_12425_52336)"},t.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_12425_52336"},t.createElement("rect",{width:"16",height:"16",fill:"white"}))))),t.createElement("div",{className:"pay-main-logo-res"},t.createElement("img",{src:H==null?void 0:H.logo,id:"pay-logos"})),t.createElement("div",{className:"pay-container"},t.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},t.createElement("div",{className:"pay-conatiner-one-first"},t.createElement("div",{className:"pay-logo-container"},t.createElement("div",{className:"pay-main-logo"},t.createElement("img",{src:H==null?void 0:H.logo,id:"pay-logos"})),(S==null?void 0:S.length)>0&&Z!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>ae("cardList")}," ",t.createElement(Oi,null)," Back")),t.createElement("div",{className:"amt-pay-con"},t.createElement("div",{className:"pay-amount-conatiner"},t.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),t.createElement("div",{className:"frac-card-bank-radio-main"},t.createElement(In,{label:"Card",amount:(qt=Number(e==null?void 0:e.amount))==null?void 0:qt.toFixed(2),value:"card",onChange:vt,activetab:Z}),(H==null?void 0:H.isSkyFiAccount)&&t.createElement(In,{label:"Bank",amount:(Nt=Number(he))==null?void 0:Nt.toFixed(2),value:"ach",onChange:vt,activetab:Z}),(e==null?void 0:e.isReader)&&(H==null?void 0:H.paymentDeviceList)&&((jt=H==null?void 0:H.paymentDeviceList)==null?void 0:jt.length)>0&&t.createElement(In,{label:"Reader",amount:(Gt=Number(e==null?void 0:e.amount))==null?void 0:Gt.toFixed(2),value:"reader",onChange:vt,activetab:Z})),he&&he>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,Z==="card"||Z==="reader"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,Se((Number(e.amount)-he).toFixed(2)))):null)),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:u,alt:""}),t.createElement("img",{src:A,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!h&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},Z!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(S==null?void 0:S.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ae("cardList")}," ",t.createElement(Oi,null)," Back"),(H==null?void 0:H.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:_=>{vt("card")},style:{border:Z==="card"?"1px solid":""}},t.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),t.createElement("button",{className:"tablinks",onClick:_=>{vt("ach")},style:{border:Z==="ach"?"1px solid":""}},t.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(Je=Number(e==null?void 0:e.amount))==null?void 0:Je.toFixed(2))),Z!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:fe,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Xe,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:nt,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Ee,width:35,alt:""})))),he&&he>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",he))):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",H==null?void 0:H.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",w==="card"?"Cards/Banks":"Readers"," "),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(Ut=Number(e==null?void 0:e.amount))==null?void 0:Ut.toFixed(2))),t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:fe,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Xe,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:nt,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:Ee,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:Z==="card"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(S==null?void 0:S.length)>0&&R==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>E("list")}," ",t.createElement(Oi,null)),he&&he>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",he))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),Z!="ach"&&t.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},t.createElement("img",{src:fe,alt:"",width:33}),t.createElement("img",{src:Xe,width:33,alt:""}),t.createElement("img",{src:nt,alt:"",width:33}),t.createElement("img",{src:Ee,width:33,alt:""}))),R==="list"?t.createElement(t.Fragment,null,t.createElement(En,{listHeading:"Cards",paymentGateway:H==null?void 0:H.paymentGateway,ListItems:S,selectedCard:gt,setSelectedCard:Yt,handleDeleteCard:Fe,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{E("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Bt},Se((ln=Number(e==null?void 0:e.amount))==null?void 0:ln.toFixed(2))))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Nn},t.createElement("div",{className:"ach-scrl",style:{minHeight:H!=null&&H.isSkyFiAccount&&(S==null?void 0:S.length)>0?"444px":H!=null&&H.isSkyFiAccount&&(S==null?void 0:S.length)==0?"456px":(S==null?void 0:S.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(o==null?void 0:o.cardName)||"",onChange:_=>{let f=_.target.value;/^[a-zA-Z\s]*$/.test(f)&&He("cardName",f)}}),(i==null?void 0:i.cardName)&&t.createElement("span",{className:"error-span"},i==null?void 0:i.cardName)),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),t.createElement("div",{className:"toggle-num-wrapper"},t.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(o==null?void 0:o.cardNumber)||"",onChange:_=>It(_),"data-token":"card_number"}),t.createElement("div",{className:"card-crdi card-expiry-new"},t.createElement("div",{className:"exp-date-year-container"},t.createElement("div",{className:"exp-date form-group"},t.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:_=>He("expiryMonth",_.target.value)})),t.createElement("div",{className:"exp-year form-group"},t.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:_=>He("expiryYear",_.target.value)})),t.createElement("div",{className:"security-digit form-group"},t.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(o==null?void 0:o.cvv)||"",onChange:_=>He("cvv",_.target.value)})))),(i==null?void 0:i.cardNumber)&&t.createElement("span",{className:"error-span"},i==null?void 0:i.cardNumber),t.createElement("p",{style:{margin:"0"}},i!=null&&i.expiryMonth||i!=null&&i.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},i==null?void 0:i.expiryMonth):"",(i==null?void 0:i.cvv)&&t.createElement("span",{className:"error-span"},i==null?void 0:i.cvv)))),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(yt=e==null?void 0:e.orderID)!=null?yt:"",style:{background:"#F6F6F7",color:"#727272"}})),t.createElement("div",{className:"form-group"},t.createElement("label",{htmlFor:"zip"},"ZIP"),t.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(dn=o==null?void 0:o.zipCode)!=null?dn:"",onChange:_=>He("zipCode",_.target.value)}),(i==null?void 0:i.zipCode)&&t.createElement("span",{className:"error-span"},i==null?void 0:i.zipCode)),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},t.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:$e,onChange:_=>pe(_.target.checked)}),t.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),t.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},t.createElement("g",{clipPath:"url(#clip0_12420_50192)"},t.createElement("rect",{width:"20",height:"20",fill:"white"}),t.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),t.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_12420_50192"},t.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),t.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Se((Xt=Number(e==null?void 0:e.amount))==null?void 0:Xt.toFixed(2)))))),t.createElement("div",{id:"ach",style:{display:Z==="ach"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},(Ke==null?void 0:Ke.length)>0&&y==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Pe("list")}," ",t.createElement(Oi,null)),he&&he>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),t.createElement("div",null,"$",Tt()))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),y==="list"?t.createElement(t.Fragment,null,t.createElement(En,{listHeading:"Banks",paymentGateway:H==null?void 0:H.paymentGateway,ListItems:Ke,selectedCard:gt,setSelectedCard:Yt,handleDeleteCard:Fe,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Pe("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Bt},Se((tn=Number(he))==null?void 0:tn.toFixed(2))))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Nn,autoComplete:"off"},t.createElement("div",{className:"ach-scrl",style:{minHeight:H!=null&&H.isSkyFiAccount&&(S==null?void 0:S.length)>0?"444px":H!=null&&H.isSkyFiAccount&&(S==null?void 0:S.length)==0?"436px":(S==null?void 0:S.length)>0?"462px":"520px",maxHeight:H!=null&&H.isSkyFiAccount&&(S==null?void 0:S.length)>0?"444px":((S==null?void 0:S.length)>0,"380px")}},t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),t.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(fn=P==null?void 0:P.name)!=null?fn:"",onChange:sn}),(W==null?void 0:W.name)&&t.createElement("span",{className:"error-span"},W==null?void 0:W.name)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"routingnumber"},"Routing number"),t.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(hn=P==null?void 0:P.routingNumber)!=null?hn:"",onChange:sn}),(W==null?void 0:W.routingNumber)&&t.createElement("span",{className:"error-span"},W==null?void 0:W.routingNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"accountnumber"},"Account number"),t.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Fn=P==null?void 0:P.accountNumber)!=null?Fn:"",onChange:sn}),(W==null?void 0:W.accountNumber)&&t.createElement("span",{className:"error-span"},W==null?void 0:W.accountNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),t.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Ot=P==null?void 0:P.confirmAccountNumber)!=null?Ot:"",onChange:sn}),(W==null?void 0:W.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},W==null?void 0:W.confirmAccountNumber)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"bankname"},"Bank name"),t.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(Be=P==null?void 0:P.bankName)!=null?Be:"",onChange:sn}),(W==null?void 0:W.bankName)&&t.createElement("span",{className:"error-span"},W==null?void 0:W.bankName)),((P==null?void 0:P.accountType)==="business saving"||(P==null?void 0:P.accountType)==="business checking")&&t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"companyName"},"Company name"),t.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(De=P==null?void 0:P.companyName)!=null?De:"",onChange:sn}),(W==null?void 0:W.companyName)&&t.createElement("span",{className:"error-span"},W==null?void 0:W.companyName)),t.createElement("div",{className:"form-group mb-4"},t.createElement("label",{htmlFor:"accounttype"},"Select account type"),t.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(xn=P==null?void 0:P.accountType)!=null?xn:"",onChange:sn},t.createElement("option",{value:""},"Select account"),ci.map(_=>t.createElement("option",{key:_.value,value:_.value},_.label)))),(e==null?void 0:e.customerId)&&t.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},t.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:Ve,onChange:_=>rt(_.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),Ve&&t.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},t.createElement("p",null,"If checked, I agree for ",t.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),t.createElement("div",{className:"form-group "},t.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Se((vn=Number(he))==null?void 0:vn.toFixed(2)))))),t.createElement("div",{id:"reader",style:{display:Z==="reader"?"block":"none"},className:"tabcontent"},t.createElement("div",{className:"frac-card-payment"},t.createElement("div",{className:"frac-heading-card-wrap"},t.createElement("div",{className:"frac-backarrow"},he&&he>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",he))),t.createElement("h6",{className:"frac-card-payment-heading"},"Reader Payment"))),t.createElement(ji,{listHeading:"Reader",ListItems:H==null?void 0:H.paymentDeviceList,selectedPax:Ct,setSlectedPax:wt}),t.createElement("button",{onClick:Ze,className:"pay-button"},"$",(kt=Number(e==null?void 0:e.amount))==null?void 0:kt.toFixed(2)))))))))))))}import l,{useEffect as ya,useState as gn}from"react";import gi from"axios";import Ji from"sweetalert2";import{IoArrowBack as or}from"react-icons/io5";function sr(e){var B,Ht,vt,He,It,sn,Wn,Zt,Nn;let[h,q]=gn(!1),[$,N]=gn(!1),[I,z]=gn(""),[ie,ge]=gn(!1),[Q,L]=gn(!1),[Z,ae]=gn("card"),[w,v]=gn(!1),[R,E]=gn("card"),[y,Pe]=gn("form"),C=e.merchantPublicKey,[Ae,$e]=gn(void 0),pe=D+"widget/mc-img.svg",Ve=D+"widget/visa-img.svg",rt=D+"widget/ae-img.svg",Ce=D+"widget/discover-img.svg",Xe=D+"widget/card.svg",fe=D+"widget/Trash.svg",nt=D+"widget/bank.svg",Ee=D+"widget/secure-img.png",pn=D+"widget/pov-by.png",[Y,p]=gn(),[u,A]=gn({}),[re,o]=gn([]),[a,i]=gn(),[b,P]=gn(void 0),[g,W]=gn(),[x,S]=gn(""),F=(U,K)=>{let Ze=(parseFloat(K)||0)/100,Bt=U/(1+Ze);return Math.round(Bt*100)/100};ya(()=>{if(e!=null&&e.pass_fee){let U=F(e==null?void 0:e.amount,e==null?void 0:e.surcharge);P(U)}},[e==null?void 0:e.pass_fee]);let Ke=()=>q(!0),Ye=()=>q(!1),gt=()=>{L(!1),ae("card"),N(!1),z(""),ge(!1),S(""),p({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),A({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),v(!1),i({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},Yt=()=>L(!0),Ct=(U,K)=>{let Ze=U;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(Ze)){(K===""||/^[0-9]+$/.test(K))&&(A(Fe=>M(k({},Fe),{[Ze]:""})),p(Fe=>M(k({},Fe),{[Ze]:K})));return}A(Fe=>M(k({},Fe),{[Ze]:""})),p(Fe=>M(k({},Fe),{[Ze]:K}))},wt=U=>{var Lt;let K=U.target,Ze=K.value.replace(/\D/g,""),{formatted:Bt,cursor:Fe}=Bn(K.value,(Lt=K.selectionStart)!=null?Lt:0);A(Tt=>M(k({},Tt),{cardNumber:""})),p(Tt=>M(k({},Tt),{cardNumber:Bt})),requestAnimationFrame(()=>{K.setSelectionRange(Fe,Fe)})},he=()=>{var Fe,Lt,Tt,qt,Nt,jt;let U={},K=Y,Ze=parseInt((K==null?void 0:K.expiryMonth)||"",10),Bt=(K==null?void 0:K.expiryYear)||"";if((Fe=K==null?void 0:K.cardName)!=null&&Fe.trim()||(U.cardName="Card name is required"),(Lt=K==null?void 0:K.cardNumber)!=null&&Lt.trim()||(U.cardNumber="Card number is required"),(!((Tt=K==null?void 0:K.expiryMonth)!=null&&Tt.trim())||!((qt=K==null?void 0:K.expiryYear)!=null&&qt.trim())||isNaN(Ze)||Ze<1||Ze>12||Bt.length!==4)&&(U.expiryMonth="Invalid Expiration Date."),(Nt=K==null?void 0:K.cvv)!=null&&Nt.trim()||(U.cvv="CVV is required"),(jt=K==null?void 0:K.zipCode)!=null&&jt.trim()||(U.zipCode="ZIP code is required"),K!=null&&K.expiryMonth&&(K!=null&&K.expiryYear)&&K.expiryMonth.length<=2&&K.expiryYear.length===4){let Gt=parseInt(K.expiryMonth,10),Je=parseInt(K.expiryYear,10),Ut=new Date,ln=Ut.getMonth()+1,yt=Ut.getFullYear();(Je<yt||Je===yt&&Gt<ln)&&(U.expiryMonth="Card is expired")}return A(U),Object.keys(U).length>0},ce=async U=>{var K,Ze,Bt,Fe,Lt,Tt,qt,Nt,jt,Gt,Je,Ut,ln,yt,dn,Xt,tn,fn,hn;if(U.preventDefault(),Z=="card"){if(he())return;{let Ot=DatacapWebToken.validateCardNumber(Y==null?void 0:Y.cardNumber.replaceAll(" ","")),Be=DatacapWebToken.validateExpirationDate(Y==null?void 0:Y.expiryMonth,Y==null?void 0:Y.expiryYear),De=DatacapWebToken.validateCVV(Y==null?void 0:Y.cvv),xn={};if(Ot||(xn.cardNumber="Invalid card Number"),Be||(xn.expiryMonth="Invalid Expiration Date."),De||(xn.cvv="Invalid CVV"),A(xn),Ot&&De&&Be){N(!0);try{let vn=async function(kt){if(kt.Error)z(kt.Error),N(!1);else{let _=Y==null?void 0:Y.cardName,f=Y==null?void 0:Y.zipCode;kt.name=_,kt.postal_code=f,kt.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,kt.amount=e==null?void 0:e.amount,kt.order_id=e==null?void 0:e.orderID,kt.preAuth_id="",kt.isCardSave=w,kt.customer_id=e==null?void 0:e.customerId,kt.link_token="",kt.gateway_id=g==null?void 0:g.paymentGateway,kt.discount=e==null?void 0:e.discount,kt.tax=e==null?void 0:e.tax,kt.surcharge=e==null?void 0:e.surcharge,kt.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let ct={method:"POST",body:JSON.stringify(kt),redirect:"follow"};Et.emit("sendMessage",M(k({},ct),{isChargePreauth:!0})),Et.on("charge-preauth",ee=>{var We;(ee==null?void 0:ee.status)=="Failed"?(N(!1),z((ee==null?void 0:ee.message)||"Something went wrong. Please try again later.")):(ge(!0),S((We=ee==null?void 0:ee.data)==null?void 0:We.transaction_id),N(!1),p({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((g==null?void 0:g.paymentGateway)===32){let kt={method:"POST",redirect:"follow"};try{let _=await gi.post(`${Le}api/v1/widget/generate-session`,kt),f=Number(Y==null?void 0:Y.expiryYear)%100,de=Y==null?void 0:Y.cardNumber;de=de==null?void 0:de.replace(/\s+/g,"");let ct=`${de}=${f}${Y==null?void 0:Y.expiryMonth} ${Y==null?void 0:Y.cvv}`,We=forge.pki.publicKeyFromPem((Ze=(K=_==null?void 0:_.data)==null?void 0:K.data)==null?void 0:Ze.publicKeyPem).encrypt(ct,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ye=forge.util.encode64(We),$t={"Content-Type":"application/json","x-app-session-key":(Fe=(Bt=_.data)==null?void 0:Bt.data)==null?void 0:Fe.session_key},Ft=JSON.stringify({enc_track2_data:`${ye}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Tt=(Lt=_==null?void 0:_.data)==null?void 0:Lt.data)==null?void 0:Tt.session_key}`});try{let be=await gi.post(`${cn}tokenizer/tokenize`,Ft,{headers:$t}),Dt=JSON.stringify(M(k({},(qt=be==null?void 0:be.data)==null?void 0:qt.data),{name:Y==null?void 0:Y.cardName,postal_code:Y==null?void 0:Y.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(jt=(Nt=be==null?void 0:be.data)==null?void 0:Nt.data)==null?void 0:jt.token}`,fractalpayPublicKey:C,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:w,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:Y==null?void 0:Y.expiryYear,ExpirationMonth:Y==null?void 0:Y.expiryMonth,CVV:Y==null?void 0:Y.cvv,Last4:(Je=(Gt=be==null?void 0:be.data)==null?void 0:Gt.data)==null?void 0:Je.last4,Brand:(ln=(Ut=be==null?void 0:be.data)==null?void 0:Ut.data)==null?void 0:ln.brand,gateway_id:g==null?void 0:g.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),m={method:"POST",headers:{"Content-Type":"application/json"},body:Dt,redirect:"follow"};Et.emit("sendMessage",M(k({},m),{isFractalPreauth:!0})),Et.on("fractal-charge-preauth",G=>{var we;(G==null?void 0:G.status)=="Failed"?(N(!1),z((G==null?void 0:G.message)||"Something went wrong , Try again later")):(S((we=G==null?void 0:G.data)==null?void 0:we.transaction_id),ge(!0),N(!1))})}catch(be){console.log(be),N(!1),z(((dn=(yt=be==null?void 0:be.response)==null?void 0:yt.data)==null?void 0:dn.message)||(be==null?void 0:be.message)||"Something went wrong , Try again later")}}catch(_){N(!1),z(((tn=(Xt=_==null?void 0:_.response)==null?void 0:Xt.data)==null?void 0:tn.message)||(_==null?void 0:_.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(g==null?void 0:g.dctoken,"PaymentForm",vn)}catch(vn){N(!1),z(((hn=(fn=vn==null?void 0:vn.response)==null?void 0:fn.data)==null?void 0:hn.message)||(vn==null?void 0:vn.message)||"Something went wrong.")}}}}},H=async()=>{var U,K,Ze,Bt,Fe,Lt,Tt,qt,Nt,jt,Gt,Je,Ut,ln,yt,dn,Xt,tn,fn,hn,Fn;Ke();try{let Ot={fractalpayPublicKey:C,customer_id:e==null?void 0:e.customerId,preauth:!0,isReader:!!(e!=null&&e.isReader)},Be=await gi.post(`${tt}get-payment-details`,Ot);if(W((U=Be==null?void 0:Be.data)==null?void 0:U.data),(Ze=(K=Be==null?void 0:Be.data)==null?void 0:K.data)!=null&&Ze.paymentGateway||(gt(),z("Something went wrong.")),(Fe=(Bt=Be==null?void 0:Be.data)==null?void 0:Bt.data)!=null&&Fe.card_list&&((qt=(Tt=(Lt=Be==null?void 0:Be.data)==null?void 0:Lt.data)==null?void 0:Tt.card_list)==null?void 0:qt.length)>0){ae("card"),o((jt=(Nt=Be==null?void 0:Be.data)==null?void 0:Nt.data)==null?void 0:jt.card_list),((Ut=(Je=(Gt=Be==null?void 0:Be.data)==null?void 0:Gt.data)==null?void 0:Je.card_list)==null?void 0:Ut.length)>0&&Pe("list");let De=(dn=(yt=(ln=Be==null?void 0:Be.data)==null?void 0:ln.data)==null?void 0:yt.card_list)==null?void 0:dn.filter(xn=>(xn==null?void 0:xn.primary_card)==1);De!=null&&De[0]&&((Xt=De==null?void 0:De[0])==null?void 0:Xt.payment_method_type)==((fn=(tn=Be==null?void 0:Be.data)==null?void 0:tn.data)==null?void 0:fn.paymentGateway)&&i(De[0])}else ae("card");Ye()}catch(Ot){console.log(Ot),Ye(),z(((Fn=(hn=Ot==null?void 0:Ot.response)==null?void 0:hn.data)==null?void 0:Fn.message)||(Ot==null?void 0:Ot.message)||"Something went wrong")}},ze=async()=>{var Gt,Je,Ut,ln,yt,dn,Xt;let U=e==null?void 0:e.customerId,K=e==null?void 0:e.discount,Ze=e==null?void 0:e.surcharge,Bt=e==null?void 0:e.tax,Fe=e==null?void 0:e.merchantPublicKey,Lt=e==null?void 0:e.orderID,Tt=e==null?void 0:e.amount,qt=a==null?void 0:a.id,Nt=a==null?void 0:a.card_type;if(Fe&&Lt&&Tt)if(U)if(qt){let tn={amount:Tt,order_id:Lt,customer_id:U,card_id:qt,fractalpayPublicKey:Fe,isCardSave:Nt!="Bank",discount:K,surcharge:Ze,tax:Bt},jt=tn,{isCardSave:fn}=jt,hn=di(jt,["isCardSave"]),Ot=tt+"authorize-by-card",Be={"Content-Type":"application/json"};N(!0);try{let De=await gi.post(Ot,Nt=="Bank"?hn:tn,{headers:Be});(Gt=De==null?void 0:De.data)!=null&&Gt.result&&(S((Ut=(Je=De==null?void 0:De.data)==null?void 0:Je.data)==null?void 0:Ut.transaction_id),ge(!0),N(!1))}catch(De){N(!1),console.log(De),z(((yt=(ln=De==null?void 0:De.response)==null?void 0:ln.data)==null?void 0:yt.message)||((Xt=(dn=De==null?void 0:De.response)==null?void 0:dn.data)==null?void 0:Xt.status)||"Something went erong")}}else z("Please Select A Card/ACH");else z("Please Select Customer");else z("Something went wrong.")};ya(()=>{Q&&C&&H()},[C,Q]);let Ie=async U=>{Ji.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 K=>{if(K.isConfirmed){N(!0);try{let Ze={card_id:U,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},Bt=await gi.post(`${tt}delete-customer-card`,Ze);N(!1),H(),Ji.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(Ze){N(!1),Ji.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},oe=U=>{switch(U==null?void 0:U.toLowerCase()){case"visa":return Ve;case"mastercard":case"mc":case"m/c":return pe;case"amex":case"american express":case"ae":return rt;case"discover":case"dcvr":return Ce;case"bank":return nt;default:return U}},pt=U=>{ae(U)},mt=async()=>{var Fe,Lt,Tt,qt,Nt,jt;let U=e==null?void 0:e.merchantPublicKey,K=e==null?void 0:e.orderID,Ze=String(e==null?void 0:e.amount),Bt=e==null?void 0:e.customerId;if(!(Ae!=null&&Ae.device_id)){z("Please Select A Payment Device");return}if(U&&K&&Ze){N(!0);let Gt={amount:Ze,fractalpayPublicKey:U,customer_order_id:K,device_id:Ae==null?void 0:Ae.device_id,customer_id:Bt||"",is_auth:!0};try{let Je=await gi.post(`${tt}charge-with-reader`,Gt);((Fe=Je==null?void 0:Je.data)==null?void 0:Fe.result)==!0?(S((Tt=(Lt=Je==null?void 0:Je.data)==null?void 0:Lt.data)==null?void 0:Tt.transaction_id),ge(!0),N(!1)):(z(((qt=Je==null?void 0:Je.data)==null?void 0:qt.message)||"Something went wrong."),N(!1))}catch(Je){z(((jt=(Nt=Je==null?void 0:Je.response)==null?void 0:Nt.data)==null?void 0:jt.message)||"Something went wrong."),N(!1)}}else z("Something went wrong.")},Pt=()=>{R==="card"?ze():R==="reader"&&mt()};return l.createElement(l.Fragment,null,l.createElement(An,null),l.createElement(ai,null),l.createElement(Xn,null),l.createElement(l.Fragment,null,l.createElement("button",{className:"paymentBtn",onClick:Yt},"PreAuth Payment"),l.createElement(Pn,{open:Q,onClose:gt},I&&l.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},l.createElement(Tn,{error:I,onClose:gt})),ie&&l.createElement(ri,{onClose:gt,tranId:x}),!I&&!ie&&l.createElement(l.Fragment,null,(h||$)&&l.createElement(mn,{loading:h||$}),l.createElement("div",null,l.createElement("div",{className:"frac-card-payment-page frac-form"},l.createElement("div",{className:"parent-pay-container"},l.createElement("span",{className:"request-payment-close-popup",onClick:gt},l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},l.createElement("g",{clipPath:"url(#clip0_12425_52336)"},l.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"})),l.createElement("defs",null,l.createElement("clipPath",{id:"clip0_12425_52336"},l.createElement("rect",{width:"16",height:"16",fill:"white"}))))),l.createElement("div",{className:"pay-container"},l.createElement("div",{className:"pay-header pay-conatiner-one"},l.createElement("div",{className:"pay-conatiner-one-first"},l.createElement("div",{className:"pay-logo-container"},l.createElement("div",{className:"pay-main-logo"},l.createElement("img",{src:g==null?void 0:g.logo,id:"pay-logos"}))),l.createElement("div",{className:"amt-pay-con"},l.createElement("div",{className:"pay-amount-conatiner"},l.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),l.createElement("div",{className:"frac-card-bank-radio-main"},l.createElement(In,{label:"Card",amount:(B=Number(e==null?void 0:e.amount))==null?void 0:B.toFixed(2),value:"card",onChange:pt,activetab:Z}),(e==null?void 0:e.isReader)&&(g==null?void 0:g.paymentDeviceList)&&((Ht=g==null?void 0:g.paymentDeviceList)==null?void 0:Ht.length)>0&&l.createElement(In,{label:"Reader",amount:(vt=Number(e==null?void 0:e.amount))==null?void 0:vt.toFixed(2),value:"reader",onChange:pt,activetab:Z})))),l.createElement("div",{className:"pay-conatiner-one-last"},l.createElement("img",{src:Ee,alt:""}),l.createElement("img",{src:pn,alt:""}),"Secure payments powered by Fractal"),l.createElement("div",null)),!h&&l.createElement("div",{className:"pay-tab pay-conatiner-two"},l.createElement("div",{className:"col-md-12"},l.createElement("div",{id:"payment-form-div"},Z!=="cardList"?l.createElement("div",null,l.createElement("div",{className:""},l.createElement("div",{className:"res-pay-con"},l.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},l.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),l.createElement("strong",{className:"pay-amount"},Se((He=Number(e==null?void 0:e.amount))==null?void 0:He.toFixed(2)))),l.createElement("div",null,l.createElement("div",null,l.createElement("img",{src:Ve,alt:"",width:35,style:{paddingRight:"5px"}}),l.createElement("img",{src:pe,width:35,alt:""})),l.createElement("div",null,l.createElement("img",{src:rt,alt:"",width:35,style:{paddingRight:"5px"}}),l.createElement("img",{src:Ce,width:35,alt:""})))),b&&b>0&&l.createElement("div",{className:"res-pay-con frac-cash-discount"},l.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),l.createElement("div",null,Se(b.toFixed(2)))))):l.createElement("div",null,l.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",g==null?void 0:g.customer_name),l.createElement("div",{className:"res-pay-con"},l.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},l.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),l.createElement("strong",{className:"pay-amount"},Se((It=Number(e==null?void 0:e.amount))==null?void 0:It.toFixed(2)))),l.createElement("div",null,l.createElement("div",null,l.createElement("img",{src:Ve,alt:"",width:35,style:{paddingRight:"5px"}}),l.createElement("img",{src:pe,width:35,alt:""})),l.createElement("div",null,l.createElement("img",{src:rt,alt:"",width:35,style:{paddingRight:"5px"}}),l.createElement("img",{src:Ce,width:35,alt:""})))),l.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),l.createElement("div",{id:"card",style:{display:Z==="card"?"block":"none"},className:"tabcontent"},l.createElement("div",{className:"frac-card-payment"},l.createElement("div",{className:"frac-heading-card-wrap"},l.createElement("div",{className:"frac-backarrow"},(re==null?void 0:re.length)>0&&y==="form"&&l.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Pe("list")}," ",l.createElement(or,null)),b&&b>0&&l.createElement("div",{className:"res-pay-con frac-cash-discount"},l.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),l.createElement("div",null,"$",b))),l.createElement("h6",{className:"frac-card-payment-heading"},"Card Authorization")),Z!="ach"&&l.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},l.createElement("img",{src:Ve,alt:"",width:33}),l.createElement("img",{src:pe,width:33,alt:""}),l.createElement("img",{src:rt,alt:"",width:33}),l.createElement("img",{src:Ce,width:33,alt:""}))),y==="list"?l.createElement(l.Fragment,null,l.createElement(En,{listHeading:"Cards",paymentGateway:g==null?void 0:g.paymentGateway,ListItems:re,selectedCard:a,setSelectedCard:i,handleDeleteCard:Ie,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{Pe("form")}}),l.createElement("div",{className:"form-group",style:{padding:"0"}},l.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Pt},Se((sn=Number(e==null?void 0:e.amount))==null?void 0:sn.toFixed(2))))):l.createElement("div",{id:"card",style:{display:Z==="card"?"block":"none"},className:"tabcontent"},l.createElement("form",{id:"PaymentForm",onSubmit:ce},l.createElement("div",{className:"ach-scrl",style:{minHeight:(re==null?void 0:re.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},l.createElement("div",{className:"form-group"},l.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),l.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(Y==null?void 0:Y.cardName)||"",onChange:U=>{let K=U.target.value;/^[a-zA-Z\s]*$/.test(K)&&Ct("cardName",K)}}),(u==null?void 0:u.cardName)&&l.createElement("span",{className:"error-span"},u==null?void 0:u.cardName)),l.createElement("div",{className:"form-group"},l.createElement("label",{htmlFor:"cardNumber"},"Card Number"),l.createElement("div",{className:"toggle-num-wrapper"},l.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(Y==null?void 0:Y.cardNumber)||"",onChange:U=>wt(U),"data-token":"card_number"}),l.createElement("div",{className:"card-crdi card-expiry-new"},l.createElement("div",{className:"exp-date-year-container"},l.createElement("div",{className:"exp-date form-group"},l.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(Y==null?void 0:Y.expiryMonth)||"",onChange:U=>Ct("expiryMonth",U.target.value)})),l.createElement("div",{className:"exp-year form-group"},l.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(Y==null?void 0:Y.expiryYear)||"",onChange:U=>Ct("expiryYear",U.target.value)})),l.createElement("div",{className:"security-digit form-group"},l.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(Y==null?void 0:Y.cvv)||"",onChange:U=>Ct("cvv",U.target.value)})))),(u==null?void 0:u.cardNumber)&&l.createElement("span",{className:"error-span"},u==null?void 0:u.cardNumber),l.createElement("p",{style:{margin:"0"}},u!=null&&u.expiryMonth||u!=null&&u.expiryYear?l.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},u==null?void 0:u.expiryMonth):"",(u==null?void 0:u.cvv)&&l.createElement("span",{className:"error-span"},u==null?void 0:u.cvv)))),l.createElement("div",{className:"form-group"},l.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),l.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"Enter Order id",disabled:!0,value:e==null?void 0:e.orderID,onChange:U=>Ct("orderId",U.target.value),style:{background:"#F6F6F7",color:"#727272"}})),l.createElement("div",{className:"form-group"},l.createElement("label",{htmlFor:"zip"},"ZIP"),l.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Wn=Y==null?void 0:Y.zipCode)!=null?Wn:"",onChange:U=>Ct("zipCode",U.target.value)}),(u==null?void 0:u.zipCode)&&l.createElement("span",{className:"error-span"},u==null?void 0:u.zipCode)),(e==null?void 0:e.customerId)&&l.createElement("div",{className:"form-group"},l.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},l.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:w,onChange:U=>v(U.target.checked)}),l.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),l.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),l.createElement("div",{className:"frac-tooltip-wrapper"},l.createElement("div",{className:"frac-tooltip-icon"},l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},l.createElement("g",{clipPath:"url(#clip0_12420_50192)"},l.createElement("rect",{width:"20",height:"20",fill:"white"}),l.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),l.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"})),l.createElement("defs",null,l.createElement("clipPath",{id:"clip0_12420_50192"},l.createElement("rect",{width:"20",height:"20",fill:"white"}))))),l.createElement("div",{className:"frac-tooltip-text"},l.createElement("p",null,"If checked, I agree to give the ",l.createElement("b",null,(g==null?void 0:g.bname)||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),l.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},l.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Se((Zt=Number(e==null?void 0:e.amount))==null?void 0:Zt.toFixed(2))))))),l.createElement("div",{id:"reader",style:{display:Z==="reader"?"block":"none"},className:"tabcontent"},l.createElement("div",{className:"frac-card-payment"},l.createElement("div",{className:"frac-heading-card-wrap"},l.createElement("div",{className:"frac-backarrow"},b&&b>0&&l.createElement("div",{className:"res-pay-con frac-cash-discount"},l.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),l.createElement("div",null,"$",b))),l.createElement("h6",{className:"frac-card-payment-heading"},"Reader Authorization"))),l.createElement(ji,{listHeading:"Reader",ListItems:g==null?void 0:g.paymentDeviceList,selectedPax:Ae,setSlectedPax:$e}),l.createElement("button",{onClick:mt,className:"pay-button"},"$",(Nn=Number(e==null?void 0:e.amount))==null?void 0:Nn.toFixed(2))))))))))))))}import _e,{useEffect as cr,useRef as _i,useState as oi}from"react";import ur from"sweetalert2";import pi from"axios";import lr from"react";function Qi(){let e="#000",h="#fff",q="#212529",$="#dee2e6";return lr.createElement("style",null,`
1219
1734
  .add-card {
1220
1735
  max-width:380px;
1221
1736
  padding: 0 20px
@@ -1474,7 +1989,7 @@ position:relative;
1474
1989
  }
1475
1990
  }
1476
1991
 
1477
- `)}import Dt from"react";import pi from"react";function jn(){return pi.createElement("style",null,`
1992
+ `)}import Kn from"react";import dr from"react";function Xi(){return dr.createElement("style",null,`
1478
1993
  .card-success .logo-container {
1479
1994
  display: flex;
1480
1995
  justify-content: center;
@@ -1562,7 +2077,7 @@ position:relative;
1562
2077
  color: #161616;
1563
2078
  opacity: 0.5;
1564
2079
  }
1565
- `)}var xi=({onClose:e})=>Dt.createElement(Dt.Fragment,null,Dt.createElement(jn,null),Dt.createElement("div",{className:"card-success"},Dt.createElement("div",{className:"payment-success-container"},Dt.createElement("div",{className:"success-icon"},Dt.createElement("div",{className:"circle"},Dt.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),Dt.createElement("div",{className:"success-text"},Dt.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),Dt.createElement("div",{className:"thank-you-text"},"Thank you ")))))),Xn=xi;function Ni(e){var _;let[G,R]=hn(!1),[ke,M]=hn(!1),[se,I]=hn(""),[yt,Ye]=hn(!1),re=_n(null),ne=_n(null),H=_n(null),_e=_n(null),p=_n(null),[b,U]=hn(),[$,g]=hn({}),[Ae,C]=hn(),Ce=()=>R(!0),Se=()=>R(!1),oe=q=>{Ci.fire({icon:"error",text:q,customClass:{popup:"custom-z-index"}})},He=()=>{Ye(!1),M(!1),I(""),U({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},et=()=>Ye(!0),at=()=>{He()},dt=(q,m)=>{var x,i,r;let j=q,he=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(j,m==null?void 0:m.length,"dfih",j==="expiryMonth"&&(m==null?void 0:m.length)===2),j==="expiryMonth"&&(m==null?void 0:m.length)===2&&((x=H==null?void 0:H.current)==null||x.focus()),j==="expiryYear"&&(m==null?void 0:m.length)===4&&((i=_e==null?void 0:_e.current)==null||i.focus()),j==="cvv"&&(m==null?void 0:m.length)===3&&((r=p==null?void 0:p.current)==null||r.focus()),he.includes(j)){(m===""||/^[0-9]+$/.test(m))&&(g(c=>L(P({},c),{[j]:""})),U(c=>L(P({},c),{[j]:m})));return}g(c=>L(P({},c),{[j]:""})),console.log(m,j),U(c=>L(P({},c),{[j]:m}))},ot=q=>{var x;let j=q.target.value.replace(/\D/g,""),he="";/^3[47]/.test(j)?he=j.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(r,c,h,s)=>[c,h,s].filter(Boolean).join(" ")):he=j.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(r,c,h,s,z)=>[c,h,s,z].filter(Boolean).join(" ")),g(i=>L(P({},i),{cardNumber:""})),U(i=>L(P({},i),{cardNumber:he})),console.log(j==null?void 0:j.length,"length"),(j==null?void 0:j.length)===16&&((x=ne==null?void 0:ne.current)==null||x.focus())},xt=()=>{var x,i,r,c,h,s;let q={},m=b,j=parseInt((m==null?void 0:m.expiryMonth)||"",10),he=(m==null?void 0:m.expiryYear)||"";if((x=m==null?void 0:m.cardName)!=null&&x.trim()||(q.cardName="Card name is required"),(i=m==null?void 0:m.cardNumber)!=null&&i.trim()||(q.cardNumber="Card number is required"),(r=m==null?void 0:m.expiryMonth)!=null&&r.trim()?(Number(m==null?void 0:m.expiryMonth)>12||Number(m==null?void 0:m.expiryMonth)<1)&&(q.expiryMonth="Invalid Expiration Month."):q.expiryMonth="Expiration month is required",(c=m==null?void 0:m.expiryYear)!=null&&c.trim()?((h=m==null?void 0:m.expiryYear)==null?void 0:h.trim().length)!==4||Number(m==null?void 0:m.expiryYear)<2025?q.expiryYear="Invalid Expiration Year.":(isNaN(j)||j<1||j>12||he.length!==4)&&(q.expiryMonth="Invalid Expiration Date."):q.expiryYear="Expiration year is required",(s=m==null?void 0:m.cvv)!=null&&s.trim()||(q.cvv="CVC is required"),m!=null&&m.expiryMonth&&(m!=null&&m.expiryYear)&&m.expiryMonth.length<=2&&m.expiryYear.length===4){let z=parseInt(m.expiryMonth,10),u=parseInt(m.expiryYear,10),f=new Date,S=f.getMonth()+1,le=f.getFullYear();(u<le||u===le&&z<S)&&(q.expiryMonth="Card is expired")}return g(q),Object.keys(q).length>0},Ke=async()=>{var q,m,j;Ce();try{let he={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},x=await Nn.post(`${Ie}get-payment-details`,he);console.log(x),C((q=x==null?void 0:x.data)==null?void 0:q.data),(j=(m=x==null?void 0:x.data)==null?void 0:m.data)!=null&&j.paymentGateway||(He(),I("Something went wrong.")),Se()}catch(he){console.log(he),Se(),He(),I("Something went wrong.")}};return vi(()=>{e!=null&&e.merchantPublicKey&&Ke()},[e==null?void 0:e.merchantPublicKey]),D.createElement(D.Fragment,null,D.createElement(tn,null),D.createElement(Vn,null),D.createElement(Yt,{loading:G}),se&&D.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},D.createElement(nn,{error:se,onClose:He})),ke&&D.createElement(Xn,{onClose:at}),!se&&!ke&&D.createElement(D.Fragment,null,D.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},D.createElement("form",{id:"creditCardForm",onSubmit:async q=>{var j,he,x,i,r,c,h,s,z,u,f,S,le,ce,Pe,lt;q.preventDefault();let m=xt();if(console.log(b),!m){let Ue=DatacapWebToken.validateCardNumber(b==null?void 0:b.cardNumber.replaceAll(" ","")),Je=DatacapWebToken.validateExpirationDate(b==null?void 0:b.expiryMonth,b==null?void 0:b.expiryYear),J=DatacapWebToken.validateCVV(b==null?void 0:b.cvv),X={};if(Ue||(X.cardNumber="Invalid card Number"),Je||(X.expiryMonth="Invalid Expiration Date."),J||(X.cvv="Invalid CVV"),g(X),Ue&&J&&Je){Ce();try{let F=async function(ge){var Ne,O,st,ze,vt;if(console.log(ge),ge.Error)console.log(ge==null?void 0:ge.Error),I(ge.Error),Se();else{let w={userId:e==null?void 0:e.customerId,cardName:b==null?void 0:b.cardName,zip:b==null?void 0:b.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:ge};try{let ct=await Nn.post(`${Ie}add-card`,w);console.log(ct);let tt={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:b==null?void 0:b.cardNumber.replaceAll(" ",""),exp_month:b==null?void 0:b.expiryMonth,exp_year:(Ne=b==null?void 0:b.expiryYear)==null?void 0:Ne.slice(-2),cvv:b==null?void 0:b.cvv};try{let fe=await Nn.post(`${Ie}link-wallet`,tt);console.log(fe),M(!0),Se(),U({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),cn(q,"close","")}catch(fe){console.log(fe),Se(),I(((st=(O=fe==null?void 0:fe.response)==null?void 0:O.data)==null?void 0:st.message)||(fe==null?void 0:fe.message)||"Something went wrong.")}}catch(ct){console.log(ct),Se(),I(((vt=(ze=ct==null?void 0:ct.response)==null?void 0:ze.data)==null?void 0:vt.message)||(ct==null?void 0:ct.message)||"Something went wrong.")}}};if((Ae==null?void 0:Ae.paymentGateway)===32){let ge={method:"POST",redirect:"follow"};try{let Ne=await Nn.post(`${Kt}api/v1/widget/generate-session`,ge),O=Number(b==null?void 0:b.expiryYear)%100,st=b==null?void 0:b.cardNumber;st=st==null?void 0:st.replace(/\s+/g,"");let ze=`${st}=${O}${b==null?void 0:b.expiryMonth} ${b==null?void 0:b.cvv}`,w=forge.pki.publicKeyFromPem((he=(j=Ne==null?void 0:Ne.data)==null?void 0:j.data)==null?void 0:he.publicKeyPem).encrypt(ze,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ct=forge.util.encode64(w),tt={"Content-Type":"application/json","x-app-session-key":(i=(x=Ne.data)==null?void 0:x.data)==null?void 0:i.session_key},fe=JSON.stringify({enc_track2_data:`${ct}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(c=(r=Ne==null?void 0:Ne.data)==null?void 0:r.data)==null?void 0:c.session_key}`});try{let bt=await Nn.post(`${en}tokenizer/tokenize`,fe,{headers:tt}),Lt=JSON.stringify(L(P({},(h=bt==null?void 0:bt.data)==null?void 0:h.data),{cvv:b==null?void 0:b.cvv,cardName:b==null?void 0:b.cardName,zip:b==null?void 0:b.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),un={"Content-Type":"application/json"};try{let Nt=await Nn.post(`${Ie}add-card`,Lt,{headers:un});console.log(Nt),(s=Nt==null?void 0:Nt.data)!=null&&s.result&&(M(!0),Se(),cn(q,"close",""))}catch(Nt){Se(),I(((u=(z=Nt==null?void 0:Nt.response)==null?void 0:z.data)==null?void 0:u.message)||(Nt==null?void 0:Nt.message)||"Something went wrong.")}}catch(bt){Se(),I(((S=(f=bt==null?void 0:bt.response)==null?void 0:f.data)==null?void 0:S.message)||(bt==null?void 0:bt.message)||"Something went wrong.")}}catch(Ne){Se(),I(((ce=(le=Ne==null?void 0:Ne.response)==null?void 0:le.data)==null?void 0:ce.message)||(Ne==null?void 0:Ne.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(Ae==null?void 0:Ae.dctoken,"creditCardForm",F)}catch(F){Se(),I(((lt=(Pe=F==null?void 0:F.response)==null?void 0:Pe.data)==null?void 0:lt.message)||(F==null?void 0:F.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},D.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},D.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},D.createElement("label",{htmlFor:"cardNumber"},"Card Number"),D.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(b==null?void 0:b.cardNumber)||"",onChange:q=>ot(q),ref:re}),($==null?void 0:$.cardNumber)&&D.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},$==null?void 0:$.cardNumber),D.createElement("br",null)),D.createElement("div",{className:"card-dtl"},D.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},D.createElement("div",{className:"form-group",style:{marginTop:"0"}},D.createElement("label",{htmlFor:"expMonth"},"MM"),D.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(b==null?void 0:b.expiryMonth)||"",onChange:q=>dt("expiryMonth",q.target.value),ref:ne}),($==null?void 0:$.expiryMonth)&&D.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},$==null?void 0:$.expiryMonth)),D.createElement("div",{className:"form-group",style:{marginTop:"0"}},D.createElement("label",{htmlFor:"expYear"},"YYYY"),D.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(b==null?void 0:b.expiryYear)||"",onChange:q=>dt("expiryYear",q.target.value),ref:H}),($==null?void 0:$.expiryYear)&&D.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},$==null?void 0:$.expiryYear)),D.createElement("div",{className:"form-group",style:{marginTop:"0"}},D.createElement("label",{htmlFor:"cvc"},"CVC"),D.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(b==null?void 0:b.cvv)||"",onChange:q=>dt("cvv",q.target.value),ref:_e}),($==null?void 0:$.cvv)&&D.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},$==null?void 0:$.cvv)))),D.createElement("div",{className:"form-group",style:{marginTop:"0"}},D.createElement("label",{htmlFor:"cardholderName"},"Name on card"),D.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(b==null?void 0:b.cardName)||"",onChange:q=>{let m=q.target.value;/^[a-zA-Z\s]*$/.test(m)&&dt("cardName",m)},ref:p}),($==null?void 0:$.cardName)&&D.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},$==null?void 0:$.cardName)),D.createElement("div",{className:"form-group",style:{marginTop:"0"}},D.createElement("label",{htmlFor:"zipcode"},"Zip"),D.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(_=b==null?void 0:b.zipCode)!=null?_:"",onChange:q=>dt("zipCode",q.target.value)}),($==null?void 0:$.zipCode)&&D.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},$==null?void 0:$.zipCode))),D.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import N,{useState as wn}from"react";import Sn from"axios";import wi from"react";function Kn({}){return wi.createElement("style",null,`
2080
+ `)}var mr=({onClose:e})=>Kn.createElement(Kn.Fragment,null,Kn.createElement(Xi,null),Kn.createElement("div",{className:"card-success"},Kn.createElement("div",{className:"payment-success-container"},Kn.createElement("div",{className:"success-icon"},Kn.createElement("div",{className:"circle"},Kn.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),Kn.createElement("div",{className:"success-text"},Kn.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),Kn.createElement("div",{className:"thank-you-text"},"Thank you ")))))),ba=mr;function gr(e){var Y;let[h,q]=oi(!1),[$,N]=oi(!1),[I,z]=oi(""),[ie,ge]=oi(!1),Q=_i(null),L=_i(null),Z=_i(null),ae=_i(null),w=_i(null),[v,R]=oi(),[E,y]=oi({}),[Pe,C]=oi(),Ae=()=>q(!0),$e=()=>q(!1),pe=p=>{ur.fire({icon:"error",text:p,customClass:{popup:"custom-z-index"}})},Ve=()=>{ge(!1),N(!1),z(""),R({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},rt=()=>ge(!0),Ce=()=>{Ve()},Xe=(p,u)=>{var o,a,i;let A=p,re=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(A,u==null?void 0:u.length,"dfih",A==="expiryMonth"&&(u==null?void 0:u.length)===2),A==="expiryMonth"&&(u==null?void 0:u.length)===2&&((o=Z==null?void 0:Z.current)==null||o.focus()),A==="expiryYear"&&(u==null?void 0:u.length)===4&&((a=ae==null?void 0:ae.current)==null||a.focus()),A==="cvv"&&(u==null?void 0:u.length)===3&&((i=w==null?void 0:w.current)==null||i.focus()),re.includes(A)){(u===""||/^[0-9]+$/.test(u))&&(y(b=>M(k({},b),{[A]:""})),R(b=>M(k({},b),{[A]:u})));return}y(b=>M(k({},b),{[A]:""})),console.log(u,A),R(b=>M(k({},b),{[A]:u}))},fe=p=>{var a,i;let u=p.target,A=u.value.replace(/\D/g,""),{formatted:re,cursor:o}=Bn(u.value,(a=u.selectionStart)!=null?a:0);y(b=>M(k({},b),{cardNumber:""})),R(b=>M(k({},b),{cardNumber:re})),console.log(A==null?void 0:A.length,"length"),(A==null?void 0:A.length)===16&&((i=L==null?void 0:L.current)==null||i.focus()),requestAnimationFrame(()=>{u.setSelectionRange(o,o)})},nt=()=>{var o,a,i,b,P,g;let p={},u=v,A=parseInt((u==null?void 0:u.expiryMonth)||"",10),re=(u==null?void 0:u.expiryYear)||"";if((o=u==null?void 0:u.cardName)!=null&&o.trim()||(p.cardName="Card name is required"),(a=u==null?void 0:u.cardNumber)!=null&&a.trim()||(p.cardNumber="Card number is required"),(i=u==null?void 0:u.expiryMonth)!=null&&i.trim()?(Number(u==null?void 0:u.expiryMonth)>12||Number(u==null?void 0:u.expiryMonth)<1)&&(p.expiryMonth="Invalid Expiration Month."):p.expiryMonth="Expiration month is required",(b=u==null?void 0:u.expiryYear)!=null&&b.trim()?((P=u==null?void 0:u.expiryYear)==null?void 0:P.trim().length)!==4||Number(u==null?void 0:u.expiryYear)<2025?p.expiryYear="Invalid Expiration Year.":(isNaN(A)||A<1||A>12||re.length!==4)&&(p.expiryMonth="Invalid Expiration Date."):p.expiryYear="Expiration year is required",(g=u==null?void 0:u.cvv)!=null&&g.trim()||(p.cvv="CVC is required"),u!=null&&u.expiryMonth&&(u!=null&&u.expiryYear)&&u.expiryMonth.length<=2&&u.expiryYear.length===4){let W=parseInt(u.expiryMonth,10),x=parseInt(u.expiryYear,10),S=new Date,F=S.getMonth()+1,Ke=S.getFullYear();(x<Ke||x===Ke&&W<F)&&(p.expiryMonth="Card is expired")}return y(p),Object.keys(p).length>0},Ee=async()=>{var p,u,A;Ae();try{let re={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},o=await pi.post(`${tt}get-payment-details`,re);console.log(o),C((p=o==null?void 0:o.data)==null?void 0:p.data),(A=(u=o==null?void 0:o.data)==null?void 0:u.data)!=null&&A.paymentGateway||(Ve(),z("Something went wrong.")),$e()}catch(re){console.log(re),$e(),Ve(),z("Something went wrong.")}};return cr(()=>{e!=null&&e.merchantPublicKey&&Ee()},[e==null?void 0:e.merchantPublicKey]),_e.createElement(_e.Fragment,null,_e.createElement(An,null),_e.createElement(Qi,null),_e.createElement(mn,{loading:h}),I&&_e.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},_e.createElement(Tn,{error:I,onClose:Ve})),$&&_e.createElement(ba,{onClose:Ce}),!I&&!$&&_e.createElement(_e.Fragment,null,_e.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},_e.createElement("form",{id:"creditCardForm",onSubmit:async p=>{var A,re,o,a,i,b,P,g,W,x,S,F,Ke,Ye,gt,Yt;p.preventDefault();let u=nt();if(console.log(v),!u){let Ct=DatacapWebToken.validateCardNumber(v==null?void 0:v.cardNumber.replaceAll(" ","")),wt=DatacapWebToken.validateExpirationDate(v==null?void 0:v.expiryMonth,v==null?void 0:v.expiryYear),he=DatacapWebToken.validateCVV(v==null?void 0:v.cvv),ce={};if(Ct||(ce.cardNumber="Invalid card Number"),wt||(ce.expiryMonth="Invalid Expiration Date."),he||(ce.cvv="Invalid CVV"),y(ce),Ct&&he&&wt){Ae();try{let H=async function(ze){var Ie,oe,pt,mt,Pt;if(console.log(ze),ze.Error)console.log(ze==null?void 0:ze.Error),z(ze.Error),$e();else{let B={userId:e==null?void 0:e.customerId,cardName:v==null?void 0:v.cardName,zip:v==null?void 0:v.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:ze};try{let Ht=await pi.post(`${tt}add-card`,B);console.log(Ht);let vt={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:v==null?void 0:v.cardNumber.replaceAll(" ",""),exp_month:v==null?void 0:v.expiryMonth,exp_year:(Ie=v==null?void 0:v.expiryYear)==null?void 0:Ie.slice(-2),cvv:v==null?void 0:v.cvv};try{let He=await pi.post(`${tt}link-wallet`,vt);console.log(He),N(!0),$e(),R({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Rn(p,"close","")}catch(He){console.log(He),$e(),z(((pt=(oe=He==null?void 0:He.response)==null?void 0:oe.data)==null?void 0:pt.message)||(He==null?void 0:He.message)||"Something went wrong.")}}catch(Ht){console.log(Ht),$e(),z(((Pt=(mt=Ht==null?void 0:Ht.response)==null?void 0:mt.data)==null?void 0:Pt.message)||(Ht==null?void 0:Ht.message)||"Something went wrong.")}}};if((Pe==null?void 0:Pe.paymentGateway)===32){let ze={method:"POST",redirect:"follow"};try{let Ie=await pi.post(`${Le}api/v1/widget/generate-session`,ze),oe=Number(v==null?void 0:v.expiryYear)%100,pt=v==null?void 0:v.cardNumber;pt=pt==null?void 0:pt.replace(/\s+/g,"");let mt=`${pt}=${oe}${v==null?void 0:v.expiryMonth} ${v==null?void 0:v.cvv}`,B=forge.pki.publicKeyFromPem((re=(A=Ie==null?void 0:Ie.data)==null?void 0:A.data)==null?void 0:re.publicKeyPem).encrypt(mt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Ht=forge.util.encode64(B),vt={"Content-Type":"application/json","x-app-session-key":(a=(o=Ie.data)==null?void 0:o.data)==null?void 0:a.session_key},He=JSON.stringify({enc_track2_data:`${Ht}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(b=(i=Ie==null?void 0:Ie.data)==null?void 0:i.data)==null?void 0:b.session_key}`});try{let It=await pi.post(`${cn}tokenizer/tokenize`,He,{headers:vt}),sn=JSON.stringify(M(k({},(P=It==null?void 0:It.data)==null?void 0:P.data),{cvv:v==null?void 0:v.cvv,cardName:v==null?void 0:v.cardName,zip:v==null?void 0:v.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),Wn={"Content-Type":"application/json"};try{let Zt=await pi.post(`${tt}add-card`,sn,{headers:Wn});console.log(Zt),(g=Zt==null?void 0:Zt.data)!=null&&g.result&&(N(!0),$e(),Rn(p,"close",""))}catch(Zt){$e(),z(((x=(W=Zt==null?void 0:Zt.response)==null?void 0:W.data)==null?void 0:x.message)||(Zt==null?void 0:Zt.message)||"Something went wrong.")}}catch(It){$e(),z(((F=(S=It==null?void 0:It.response)==null?void 0:S.data)==null?void 0:F.message)||(It==null?void 0:It.message)||"Something went wrong.")}}catch(Ie){$e(),z(((Ye=(Ke=Ie==null?void 0:Ie.response)==null?void 0:Ke.data)==null?void 0:Ye.message)||(Ie==null?void 0:Ie.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(Pe==null?void 0:Pe.dctoken,"creditCardForm",H)}catch(H){$e(),z(((Yt=(gt=H==null?void 0:H.response)==null?void 0:gt.data)==null?void 0:Yt.message)||(H==null?void 0:H.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},_e.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},_e.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},_e.createElement("label",{htmlFor:"cardNumber"},"Card Number"),_e.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(v==null?void 0:v.cardNumber)||"",onChange:p=>fe(p),ref:Q}),(E==null?void 0:E.cardNumber)&&_e.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},E==null?void 0:E.cardNumber),_e.createElement("br",null)),_e.createElement("div",{className:"card-dtl"},_e.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},_e.createElement("div",{className:"form-group",style:{marginTop:"0"}},_e.createElement("label",{htmlFor:"expMonth"},"MM"),_e.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(v==null?void 0:v.expiryMonth)||"",onChange:p=>Xe("expiryMonth",p.target.value),ref:L}),(E==null?void 0:E.expiryMonth)&&_e.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},E==null?void 0:E.expiryMonth)),_e.createElement("div",{className:"form-group",style:{marginTop:"0"}},_e.createElement("label",{htmlFor:"expYear"},"YYYY"),_e.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(v==null?void 0:v.expiryYear)||"",onChange:p=>Xe("expiryYear",p.target.value),ref:Z}),(E==null?void 0:E.expiryYear)&&_e.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},E==null?void 0:E.expiryYear)),_e.createElement("div",{className:"form-group",style:{marginTop:"0"}},_e.createElement("label",{htmlFor:"cvc"},"CVC"),_e.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(v==null?void 0:v.cvv)||"",onChange:p=>Xe("cvv",p.target.value),ref:ae}),(E==null?void 0:E.cvv)&&_e.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},E==null?void 0:E.cvv)))),_e.createElement("div",{className:"form-group",style:{marginTop:"0"}},_e.createElement("label",{htmlFor:"cardholderName"},"Name on card"),_e.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(v==null?void 0:v.cardName)||"",onChange:p=>{let u=p.target.value;/^[a-zA-Z\s]*$/.test(u)&&Xe("cardName",u)},ref:w}),(E==null?void 0:E.cardName)&&_e.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},E==null?void 0:E.cardName)),_e.createElement("div",{className:"form-group",style:{marginTop:"0"}},_e.createElement("label",{htmlFor:"zipcode"},"Zip"),_e.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(Y=v==null?void 0:v.zipCode)!=null?Y:"",onChange:p=>Xe("zipCode",p.target.value)}),(E==null?void 0:E.zipCode)&&_e.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},E==null?void 0:E.zipCode))),_e.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import j,{useState as fi}from"react";import Pi from"axios";var Vi={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import pr from"react";function Di({}){return pr.createElement("style",null,`
1566
2081
  @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap");
1567
2082
 
1568
2083
  .creditformbox {
@@ -1748,5 +2263,751 @@ position:relative;
1748
2263
  gap: 10px;
1749
2264
  padding-top: 10px;
1750
2265
  }
1751
- `)}function ki({session_token:e,callback:G,isloading:R,onCancel:ke,showChecks:M,merchantName:se,signCheckbox:I,checkedSignCheckbox:yt,onCheckSign:Ye,cancelbtnClass:re,savebtnClass:ne,inputClass:H,isDual:_e}){var x;let[p,b]=wn(!1),[U,$]=wn(!1),[g,Ae]=wn(),[C,Ce]=wn({}),[Se,oe]=wn(""),He=()=>b(!0),et=()=>b(!1),[at,dt]=wn(!1),ot=()=>{var s,z,u,f,S,le,ce,Pe;let i={},r=g,c=parseInt((r==null?void 0:r.expiryMonth)||"",10),h=(r==null?void 0:r.expiryYear)||"";return(s=r==null?void 0:r.firstName)!=null&&s.trim()||(i.firstName="Please enter a first name."),(z=r==null?void 0:r.lastName)!=null&&z.trim()||(i.lastName="Please enter a last name."),(u=r==null?void 0:r.cardNumber)!=null&&u.trim()||(i.cardNumber="Please enter a card number."),(f=r==null?void 0:r.expiryMonth)!=null&&f.trim()?(Number(r==null?void 0:r.expiryMonth)>12||Number(r==null?void 0:r.expiryMonth)<1)&&(i.expiryMonth="Invalid Expiration Month."):i.expiryMonth="Please enter an expiry month.",(S=r==null?void 0:r.expiryYear)!=null&&S.trim()?((le=r==null?void 0:r.expiryYear)==null?void 0:le.trim().length)!==4||Number(r==null?void 0:r.expiryYear)<2025?i.expiryYear="Invalid Expiration Year.":(isNaN(c)||c<1||c>12||h.length!==4)&&(i.expiryMonth="Invalid Expiration Date."):i.expiryYear="Please enter an expiry year.",(ce=r==null?void 0:r.cvv)!=null&&ce.trim()||(i.cvv="Please enter a CVV."),(Pe=r==null?void 0:r.zipCode)!=null&&Pe.trim()||(i.zipCode="Please enter a zip code."),I&&!yt&&(i.checkSign="You must authorize this before proceeding."),M&&!(r!=null&&r.authHold)&&(i.authHold="You must authorize this before proceeding."),M&&!(r!=null&&r.authorise)&&(i.authorise="Please confirm your authorization to continue."),Ce(i),Object.keys(i).length>0},xt=i=>{let c=i.target.value.replace(/\D/g,""),h="";/^3[47]/.test(c)?h=c.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(z,u,f,S)=>[u,f,S].filter(Boolean).join(" ")):h=c.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(z,u,f,S,le)=>[u,f,S,le].filter(Boolean).join(" ")),Ce(s=>L(P({},s),{cardNumber:""})),Ae(s=>L(P({},s),{cardNumber:h}))},Ke=(i,r)=>{let c=i;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(c)){(r===""||/^[0-9]+$/.test(r))&&(Ce(s=>L(P({},s),{[c]:""})),Ae(s=>L(P({},s),{[c]:r})));return}Ce(s=>L(P({},s),{[c]:""})),Ae(s=>L(P({},s),{[c]:r}))},Ot=()=>{let i=DatacapWebToken.validateCardNumber(g==null?void 0:g.cardNumber.replaceAll(" ","")),r=DatacapWebToken.validateExpirationDate(g==null?void 0:g.expiryMonth,g==null?void 0:g.expiryYear),c=DatacapWebToken.validateCVV(g==null?void 0:g.cvv),h={};return i||(h.cardNumber="Invalid card Number"),r||(h.expiryMonth="Invalid Expiration Date."),c||(h.cvv="Invalid CVV"),Ce(h),i&&c&&r},_=async i=>{var r,c;if(i.Error)oe(i.Error),et();else{let h={token:i.Token,resp:i},s=await Sn.post(`${Kt}api/v1/gateway/update/token/${e}`,h);if((s==null?void 0:s.status)==200){let z=P(P({Token:(c=(r=s==null?void 0:s.data)==null?void 0:r.data)==null?void 0:c.gateway_token,Brand:i.Brand,ExpirationMonth:i.ExpirationMonth,ExpirationYear:i.ExpirationYear,Last4:i.Last4,Bin:i.Bin,CVV:i.CVV,postalCode:g==null?void 0:g.zipCode},M&&{authHold:g==null?void 0:g.authHold}),M&&{authorise:g==null?void 0:g.authorise});et(),G(z)}}},q=async()=>{var i,r,c,h,s,z,u,f,S,le,ce,Pe,lt,Ue;try{let Je={method:"POST",redirect:"follow"},J=await Sn.post(`${Kt}api/v1/widget/generate-session`,Je),X=Number(g==null?void 0:g.expiryYear)%100,ge=`${(i=g==null?void 0:g.cardNumber)==null?void 0:i.replace(/\s+/g,"")}=${X}${g==null?void 0:g.expiryMonth} ${g==null?void 0:g.cvv}`,O=forge.pki.publicKeyFromPem((c=(r=J==null?void 0:J.data)==null?void 0:r.data)==null?void 0:c.publicKeyPem).encrypt(ge,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),st=forge.util.encode64(O),ze={"Content-Type":"application/json","x-app-session-key":(s=(h=J.data)==null?void 0:h.data)==null?void 0:s.session_key},vt=JSON.stringify({enc_track2_data:st,algorithm:"RSAES_OAEP_SHA_1",session_key:(u=(z=J==null?void 0:J.data)==null?void 0:z.data)==null?void 0:u.session_key}),w=await Sn.post(`${en}tokenizer/tokenize`,vt,{headers:ze});if((w==null?void 0:w.status)==200){let ct=(S=(f=w==null?void 0:w.data)==null?void 0:f.data)==null?void 0:S.token;try{let tt=await Sn.post(`${Kt}api/v1/gateway/verify-and-save/${e}`,{token:ct});if((tt==null?void 0:tt.status)==200){let fe=(le=tt==null?void 0:tt.data)==null?void 0:le.data,bt={Token:fe.gateway_token,Brand:fe.card_data.brand,ExpirationMonth:fe.card_data.expire_mm,ExpirationYear:fe.card_data.expire_yy,Last4:fe.card_data.last4,Bin:fe.card_data.bin,postalCode:g==null?void 0:g.zipCode};et(),G(bt)}}catch(tt){console.log(tt,"error"),et()}}}catch(Je){let J="Something went wrong!";try{let X=((ce=Je==null?void 0:Je.response)==null?void 0:ce.data)||(Je==null?void 0:Je.message)||"",F=typeof X=="string"?X:JSON.stringify(X),Ne=(((lt=(Pe=F.split)==null?void 0:Pe.call(F,`
1752
- `))==null?void 0:lt.filter(Boolean))||[]).at(-1)||"",O=(Ue=Ne.split)==null?void 0:Ue.call(Ne,": ");J=(O==null?void 0:O.length)>1?O.pop().trim():Ne.trim()||J}catch(X){J="Something went wrong!"}et(),oe(J)}},m=async i=>{var h,s,z,u,f,S,le;if(i.preventDefault(),!(ot()||!Ot())){He();try{let ce=await Sn.get(`${Kt}api/v1/gateway/token/${e}`,{params:{pass_fee:at}});if((ce==null?void 0:ce.status)==200){let Pe=(s=(h=ce==null?void 0:ce.data)==null?void 0:h.data)==null?void 0:s.gateway_token;((u=(z=ce==null?void 0:ce.data)==null?void 0:z.data)==null?void 0:u.paymentGateway)==((f=Wn)==null?void 0:f.FRACTALKEY)?await q():DatacapWebToken.requestToken(Pe,"creditCardForm",_)}}catch(ce){et(),oe(((le=(S=ce==null?void 0:ce.response)==null?void 0:S.data)==null?void 0:le.message)||"Something went wrong!")}}},j=()=>{oe("")},he=()=>{oe(""),Ae({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1,checkSign:!1}),ke()};return console.log(at,"aoapoaa"),N.createElement(N.Fragment,null,N.createElement(tn,null),N.createElement(Kn,null),N.createElement(Yt,{loading:p||R}),Se&&N.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},N.createElement(nn,{error:Se,onClose:j})),!Se&&N.createElement("div",{className:"creditformbox"},N.createElement("form",{id:"creditCardForm",onSubmit:m},N.createElement("div",{className:"name-row"},N.createElement("div",{className:"form-group"},N.createElement("label",null," First Name ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(g==null?void 0:g.firstName)||"",onChange:i=>{let r=i.target.value;/^[a-zA-Z\s]*$/.test(r)&&Ke("firstName",r)},className:H}),(C==null?void 0:C.firstName)&&N.createElement("small",{className:"error"},C==null?void 0:C.firstName)),N.createElement("div",{className:"form-group"},N.createElement("label",null," Last Name ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(g==null?void 0:g.lastName)||"",onChange:i=>{let r=i.target.value;/^[a-zA-Z\s]*$/.test(r)&&Ke("lastName",r)},className:H}),(C==null?void 0:C.lastName)&&N.createElement("small",{className:"error"},C==null?void 0:C.lastName))),N.createElement("div",{className:"form-pay-row"},N.createElement("div",{className:"form-group"},N.createElement("label",null," Card Number ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(g==null?void 0:g.cardNumber)||"",onChange:i=>xt(i),className:H}),(C==null?void 0:C.cardNumber)&&N.createElement("small",{className:"error"},C==null?void 0:C.cardNumber))),N.createElement("div",{className:"card-pay-row"},N.createElement("div",{className:"form-group"},N.createElement("label",null," Exp Month ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(g==null?void 0:g.expiryMonth)||"",onChange:i=>Ke("expiryMonth",i.target.value),className:H}),(C==null?void 0:C.expiryMonth)&&N.createElement("small",{className:"error"},C==null?void 0:C.expiryMonth)),N.createElement("div",{className:"form-group"},N.createElement("label",null," Exp Year ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(g==null?void 0:g.expiryYear)||"",onChange:i=>Ke("expiryYear",i.target.value),className:H}),(C==null?void 0:C.expiryYear)&&N.createElement("small",{className:"error"},C==null?void 0:C.expiryYear)),N.createElement("div",{className:"form-group"},N.createElement("label",null," CVV ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(g==null?void 0:g.cvv)||"",onChange:i=>Ke("cvv",i.target.value),className:H}),(C==null?void 0:C.cvv)&&N.createElement("small",{className:"error"},C==null?void 0:C.cvv)),N.createElement("div",{className:"form-group"},N.createElement("label",null," Zip ",N.createElement("span",{className:"text-danger"},"*")),N.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(x=g==null?void 0:g.zipCode)!=null?x:"",onChange:i=>Ke("zipCode",i.target.value),className:H}),(C==null?void 0:C.zipCode)&&N.createElement("small",{className:"error"},C==null?void 0:C.zipCode))),_e&&N.createElement("div",{className:"pass-fee-toggle-div"},N.createElement("input",{type:"checkbox",id:"pass_fee",className:"toggle-checkbox",checked:at,onChange:i=>{dt(i.target.checked)}}),N.createElement("label",{htmlFor:"pass_fee",className:"toggle-label"}),N.createElement("label",{htmlFor:"save_card"},"Cash Discount")),I&&N.createElement("div",{className:"checks-row"},N.createElement("input",{name:"discalosure",type:"checkbox",id:"disclosureCheck",checked:yt,onChange:i=>Ye(i.target.checked)}),N.createElement("label",{htmlFor:"disclosureCheck",className:"form-check-label"},"Please agree to the following in order to add Payment method.")),I&&(C==null?void 0:C.checkSign)&&N.createElement("small",{className:"check-error"},C==null?void 0:C.checkSign),M&&N.createElement(N.Fragment,null,N.createElement("div",{className:"checks-row"},N.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(g!=null&&g.authHold),onChange:i=>Ke("authHold",i.target.checked)}),N.createElement("label",{htmlFor:"authHold",className:"form-check-label"},"To securely save your card on file, we will place a temporary authorization hold of $1.00. This is not a charge and will be released by your card issuer shortly after verification.")),(C==null?void 0:C.authHold)&&N.createElement("small",{className:"check-error"},C==null?void 0:C.authHold),N.createElement("div",{className:"checks-row "},N.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(g!=null&&g.authorise),onChange:i=>Ke("authorise",i.target.checked)}),N.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},U?N.createElement(N.Fragment,null,N.createElement("span",null,"By providing your payment information, you authorize"," ",N.createElement("strong",null,se),", 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"," ",N.createElement("strong",null,se),". You may request the removal of your stored payment information at any time by contacting"," ",N.createElement("strong",null,se)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",N.createElement("a",{href:"#",onClick:i=>{i.preventDefault(),$(!1)}},"See less ..."))):N.createElement(N.Fragment,null,N.createElement("span",null,"By providing your payment information, you authorize ",se,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),N.createElement("a",{href:"#",onClick:i=>{i.preventDefault(),$(!0)}},"See more ...")))),(C==null?void 0:C.authorise)&&N.createElement("small",{className:"check-error"},C==null?void 0:C.authorise)),N.createElement("div",{className:"button-row"},N.createElement("button",{className:`cancelbtn ${re} `,type:"button",onClick:he},"Cancel"),N.createElement("button",{className:`savebtn ${ne} `,type:"submit"},"Save")))))}import n,{useEffect as Tn,useRef as _i,useState as Ge}from"react";import Pn from"axios";import Fn from"sweetalert2";import{IoArrowBack as qn}from"react-icons/io5";import{NumericFormat as Si}from"react-number-format";function Pi(e){var zt,Bt,Zt,$t,Rt,ut,ue,xe,Tt,qt,Ee,y,d,K,ve,Y,$e,Oe,Ze,Ve,E,_t;let G=_i(null);Tn(()=>{e.onTriggerPay&&e.onTriggerPay(()=>{T()})},[e]);let R=be+"widget/mc-img.svg",ke=be+"widget/visa-img.svg",M=be+"widget/ae-img.svg",se=be+"widget/discover-img.svg",I=be+"widget/card.svg",yt=be+"widget/Trash.svg",Ye=be+"widget/bank.svg",re=be+"widget/secure-img.png",ne=be+"widget/pov-by.png",H=be+"widget/pax.svg",[_e,p]=Ge(!1),[b,U]=Ge(!1),[$,g]=Ge(""),[Ae,C]=Ge(!1),[Ce,Se]=Ge(!1),[oe,He]=Ge("card"),[et,at]=Ge("card"),[dt,ot]=Ge("form"),[xt,Ke]=Ge("form"),[Ot,_]=Ge(!0),[q,m]=Ge(!1),[j,he]=Ge(!1),x=e.merchantPublicKey,[i,r]=Ge(),[c,h]=Ge({}),[s,z]=Ge(),[u,f]=Ge({}),[S,le]=Ge([]),[ce,Pe]=Ge([]),[lt,Ue]=Ge(),[Je,J]=Ge(),[X,F]=Ge(Number(e==null?void 0:e.amount)),[ge,Ne]=Ge(Number(e==null?void 0:e.amount)),[O,st]=Ge(""),[ze,vt]=Ge("");console.log(O,"partialAmount");let[w,ct]=Ge(),[tt,fe]=Ge(""),bt=()=>p(!0),Lt=()=>p(!1),un=(o,l)=>{let B=(parseFloat(l)||0)/100;return o-o*B},Nt=(o,l)=>{let B=(Number(l)||0)/100;return+o+ +(o*B)};Tn(()=>{Ce&&(e!=null&&e.pass_fee?(Ne(Number(e==null?void 0:e.amount)),F(Number(e==null?void 0:e.cashDiscount))):(Ne(Number(e==null?void 0:e.amount)),F(Number(e==null?void 0:e.amount))))},[Ce,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let Et=()=>{Se(!1),He("card"),g(""),C(!1),fe(""),z({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),f({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),r({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),h({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),he(!1),m(!1),Ue({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),J({}),F(0),at("card"),_(!0),Ke("form"),ot("form"),U(!1),p(!1),Pe([]),le([]),st(""),vt("")},T=()=>Se(!0),A=o=>{He(o)},ie=(o,l)=>{let B=o;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(B)){(l===""||/^[0-9]+$/.test(l))&&(h(V=>L(P({},V),{[B]:""})),r(V=>L(P({},V),{[B]:l})));return}h(V=>L(P({},V),{[B]:""})),r(V=>L(P({},V),{[B]:l}))},Xe=o=>{let B=o.target.value.replace(/\D/g,""),Q="";/^3[47]/.test(B)?Q=B.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(me,Be,Fe,W)=>[Be,Fe,W].filter(Boolean).join(" ")):Q=B.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(me,Be,Fe,W,Te)=>[Be,Fe,W,Te].filter(Boolean).join(" ")),h(V=>L(P({},V),{cardNumber:""})),r(V=>L(P({},V),{cardNumber:Q}))},ee=o=>{let{name:l,value:B}=o.target,Q=["routingNumber","accountNumber","confirmAccountNumber"];if(l=="name"){/^[a-zA-Z\s]*$/.test(B)&&(f(V=>L(P({},V),{[l]:""})),z(V=>L(P({},V),{[l]:B})));return}if(Q.includes(l)){(B===""||/^[0-9]+$/.test(B))&&(f(V=>L(P({},V),{[l]:""})),z(V=>L(P({},V),{[l]:B})));return}f(V=>L(P({},V),{[l]:""})),z(V=>L(P({},V),{[l]:B}))},pt=()=>{var V,me,Be,Fe,W,Te;let o={},l=i,B=parseInt((l==null?void 0:l.expiryMonth)||"",10),Q=(l==null?void 0:l.expiryYear)||"";if((V=l==null?void 0:l.cardName)!=null&&V.trim()||(o.cardName="Card name is required"),(me=l==null?void 0:l.cardNumber)!=null&&me.trim()||(o.cardNumber="Card number is required"),(!((Be=l==null?void 0:l.expiryMonth)!=null&&Be.trim())||!((Fe=l==null?void 0:l.expiryYear)!=null&&Fe.trim())||isNaN(B)||B<1||B>12||Q.length!==4)&&(o.expiryMonth="Invalid Expiration Date."),(W=l==null?void 0:l.cvv)!=null&&W.trim()||(o.cvv="CVV is required"),(Te=l==null?void 0:l.zipCode)!=null&&Te.trim()||(o.zipCode="ZIP code is required"),l!=null&&l.expiryMonth&&(l!=null&&l.expiryYear)&&l.expiryMonth.length<=2&&l.expiryYear.length===4){let Re=parseInt(l.expiryMonth,10),ae=parseInt(l.expiryYear,10),ye=new Date,te=ye.getMonth()+1,We=ye.getFullYear();(ae<We||ae===We&&Re<te)&&(o.expiryMonth="Card is expired")}return h(o),Object.keys(o).length>0},rt=()=>{var B,Q,V,me,Be,Fe,W,Te;let o={},l=s;return(B=l==null?void 0:l.name)!=null&&B.trim()||(o.name="Name is required"),(Q=l==null?void 0:l.accountNumber)!=null&&Q.trim()||(o.accountNumber="Account number is required"),(V=l==null?void 0:l.accountNumber)!=null&&V.trim()&&((me=l==null?void 0:l.accountNumber)==null?void 0:me.trim())!==((Be=l==null?void 0:l.confirmAccountNumber)==null?void 0:Be.trim())&&(o.confirmAccountNumber="Account numbers must match"),(Fe=l==null?void 0:l.bankName)!=null&&Fe.trim()||(o.bankName="Bank name is required"),(W=l==null?void 0:l.routingNumber)!=null&&W.trim()||(o.routingNumber="Routing Number is required"),l!=null&&l.routingNumber&&((Te=l==null?void 0:l.routingNumber)==null?void 0:Te.length)!==9&&(o.routingNumber="Routing number must be 9 digits"),((l==null?void 0:l.accountType)==="business saving"||(l==null?void 0:l.accountType)==="business checking")&&(!(l!=null&&l.companyName)||(l==null?void 0:l.companyName)==="")&&(o.companyName="Company Name is required for business accounts"),f(o),Object.keys(o).length>0},Qe=async o=>{var l,B,Q,V,me,Be,Fe,W,Te,Re,ae,ye,te,We,we;if(o.preventDefault(),!ze)if(oe!=="ach"){if(pt())return;{let Me=DatacapWebToken.validateCardNumber(i==null?void 0:i.cardNumber.replaceAll(" ","")),de=DatacapWebToken.validateExpirationDate(i==null?void 0:i.expiryMonth,i==null?void 0:i.expiryYear),on=DatacapWebToken.validateCVV(i==null?void 0:i.cvv),Ut={};if(Me||(Ut.cardNumber="Invalid card Number"),de||(Ut.expiryMonth="Invalid Expiration Date."),on||(Ut.cvv="Invalid CVV"),h(Ut),Me&&on&&de){U(!0);try{let Vt=async function(Mt){var Le,Z;if(Mt.Error)g(Mt.Error),U(!1);else{let It=i==null?void 0:i.cardName,Jt=i==null?void 0:i.zipCode;Mt.name=It,Mt.postal_code=Jt,Mt.isCardSave=`${q}`,Mt.isCharge=!0,Mt.posSalesIdEncode=(Le=w==null?void 0:w.orderDetails)==null?void 0:Le.orderId,Mt.partial_amount=O&&!ze?O:ge,nt.emit("sendMessage",Mt);let Xt=(Z=w==null?void 0:w.orderDetails)==null?void 0:Z.orderId;nt.on(Xt,sn=>{if(pn(sn==null?void 0:sn.data)){let Ct=JSON.parse(sn.data);Ct!=null&&Ct.result?(r({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),m(!1),fe(Ct==null?void 0:Ct.transactionId),C(!0),U(!1)):(U(!1),g((Ct==null?void 0:Ct.message)||"Something went wrong."))}else g("Something went wrong.")})}};if((w==null?void 0:w.paymentGateway)===32){let Mt={method:"POST",redirect:"follow"};try{let Le=await Pn.post(`${Kt}api/v1/widget/generate-session`,Mt),Z=Number(i==null?void 0:i.expiryYear)%100,It=i==null?void 0:i.cardNumber;It=It==null?void 0:It.replace(/\s+/g,"");let Jt=`${It}=${Z}${i==null?void 0:i.expiryMonth} ${i==null?void 0:i.cvv}`,sn=forge.pki.publicKeyFromPem((B=(l=Le==null?void 0:Le.data)==null?void 0:l.data)==null?void 0:B.publicKeyPem).encrypt(Jt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Ct=forge.util.encode64(sn),Mn={"Content-Type":"application/json","x-app-session-key":(V=(Q=Le.data)==null?void 0:Q.data)==null?void 0:V.session_key},Qt=JSON.stringify({enc_track2_data:`${Ct}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Be=(me=Le==null?void 0:Le.data)==null?void 0:me.data)==null?void 0:Be.session_key}`});try{let jt=await Pn.post(`${en}tokenizer/tokenize`,Qt,{headers:Mn}),Qn=JSON.stringify(L(P({},(Fe=jt==null?void 0:jt.data)==null?void 0:Fe.data),{isSaveCardChecked:q,name:i==null?void 0:i.cardName,postal_code:i==null?void 0:i.zipCode,customer_id:e==null?void 0:e.customerId,partial_amount:O&&!ze?O:ge})),Dn=JSON.stringify({pre_sales_id:`${(W=w==null?void 0:w.orderDetails)==null?void 0:W.orderId}`,token:`${(Te=jt==null?void 0:jt.data)==null?void 0:Te.data.token}`,json_response:`${Qn}`}),Rn={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:Dn,redirect:"follow",isChargeviafractal:!0};nt.emit("sendMessage",Rn),nt.on("chargeviafractalgateway",yn=>{var On;if(pn(yn==null?void 0:yn.data)){let ln=JSON.parse(yn==null?void 0:yn.data);ln!=null&&ln.result?(fe((On=ln==null?void 0:ln.data)==null?void 0:On.transactionId),C(!0),U(!1)):(U(!1),g((ln==null?void 0:ln.message)||"Something went wrong."))}else g("Something went wrong.")})}catch(jt){U(!1),g(((ae=(Re=jt==null?void 0:jt.response)==null?void 0:Re.data)==null?void 0:ae.message)||(jt==null?void 0:jt.message)||"Something went wrong.")}}catch(Le){U(!1),g(((te=(ye=Le==null?void 0:Le.response)==null?void 0:ye.data)==null?void 0:te.message)||(Le==null?void 0:Le.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(w==null?void 0:w.dctoken,"PaymentForm",Vt)}catch(Vt){U(!1),g(((we=(We=Vt==null?void 0:Vt.response)==null?void 0:We.data)==null?void 0:we.message)||(Vt==null?void 0:Vt.message)||"Something went wrong.")}}}}else{if(rt())return;{U(!0);let Me={fractalpayPublicKey:x,label:(s==null?void 0:s.name)||"John Doe",account_number:s==null?void 0:s.accountNumber,routing_number:s==null?void 0:s.routingNumber,bank_name:s==null?void 0:s.bankName,account_type:s==null?void 0:s.accountType,amount:O&&!ze?O:String(X||0),isSaveAch:j,customer_id:e==null?void 0:e.customerId,order_id:e==null?void 0:e.orderID,tax:e==null?void 0:e.tax,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,isChargeACH:!0,company_name:(s==null?void 0:s.companyName)||"",orderGuid:e==null?void 0:e.orderGuid};nt.emit("sendMessage",Me),nt.on("ach-incoming",de=>{var on;(de==null?void 0:de.status)=="Failed"?typeof(de==null?void 0:de.message)=="object"?Object.values(de==null?void 0:de.message).forEach(Ut=>{g(Ut||"Something went wrong")}):g((de==null?void 0:de.message)||"Something went wrong"):(fe((on=de==null?void 0:de.data)==null?void 0:on.transaction_id),C(!0),U(!1))})}}},De=async()=>{var o,l,B,Q,V,me,Be,Fe,W,Te,Re,ae,ye,te,We,we,St,Me,de,on,Ut,Vt,Mt;bt();try{let Le={fractalpayPublicKey:x,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,orderGuid:e==null?void 0:e.orderGuid},Z=await Pn.post(`${Ie}get-payment-details`,Le);if(ct((o=Z==null?void 0:Z.data)==null?void 0:o.data),(B=(l=Z==null?void 0:Z.data)==null?void 0:l.data)!=null&&B.paymentGateway||(Et(),g("Something went wrong.")),(V=(Q=Z==null?void 0:Z.data)==null?void 0:Q.data)!=null&&V.card_list&&((Fe=(Be=(me=Z==null?void 0:Z.data)==null?void 0:me.data)==null?void 0:Be.card_list)==null?void 0:Fe.length)>0){let It=(Re=(Te=(W=Z==null?void 0:Z.data)==null?void 0:W.data)==null?void 0:Te.card_list)==null?void 0:Re.filter(Xt=>(Xt==null?void 0:Xt.card_type)=="Bank"),Jt=(te=(ye=(ae=Z==null?void 0:Z.data)==null?void 0:ae.data)==null?void 0:ye.card_list)==null?void 0:te.filter(Xt=>(Xt==null?void 0:Xt.card_type)!=="Bank");console.log(It,"hohgohoo",Jt),(Jt==null?void 0:Jt.length)>0&&ot("list"),(It==null?void 0:It.length)>0&&Ke("list"),le(Jt),Pe(It)}else He("card");(we=(We=Z==null?void 0:Z.data)==null?void 0:We.data)!=null&&we.paymentDeviceList&&((de=(Me=(St=Z==null?void 0:Z.data)==null?void 0:St.data)==null?void 0:Me.paymentDeviceList)==null?void 0:de.length)>0&&J((Ut=(on=Z==null?void 0:Z.data)==null?void 0:on.data)==null?void 0:Ut.paymentDeviceList[0]),Lt()}catch(Le){console.log(Le),Lt(),g(((Mt=(Vt=Le==null?void 0:Le.response)==null?void 0:Vt.data)==null?void 0:Mt.message)||(Le==null?void 0:Le.message)||"Something went wrong")}},mt=async()=>{let o=e==null?void 0:e.customerId,l=String(e==null?void 0:e.discount),B=String(e==null?void 0:e.surcharge),Q=String(e==null?void 0:e.tax),V=e==null?void 0:e.merchantPublicKey,me=e==null?void 0:e.orderID,Be=O&&!ze?O:String(ge),Fe=lt==null?void 0:lt.id,W=lt==null?void 0:lt.card_type;if(!ze)if(V&&me&&Be&&X)if(o)if(Fe){let Re;O&&!ze?Re=O:W==="Bank"?Re=X:Re=ge;let ae={amount:Re,order_id:me,customer_id:o,card_id:Fe,fractalpayPublicKey:V,isCardSave:q,discount:l,surcharge:B,tax:Q,orderGuid:e==null?void 0:e.orderGuid};O&&!ze&&W!=="Bank"&&(ae.ispartialPayment=!0);let Te=ae,{isCardSave:ye}=Te,te=bn(Te,["isCardSave"]),we=Ie+(W==="Bank"?"charge-ach":"charge-by-card"),St={"Content-Type":"application/json"};U(!0),nt.emit("sendMessage",{url:we,body:W=="Bank"?te:ae,isChargebycard:!0}),nt.on("charge-by-card",Me=>{var de;(Me==null?void 0:Me.result)==!0||(Me==null?void 0:Me.status)==!0?(fe((de=Me.data)==null?void 0:de.transaction_id),C(!0),U(!1)):g((Me==null?void 0:Me.message)||"Something went wrong.")})}else g("Please Select A Card/ACH");else g("Please Select Customer");else g("Something went wrong.")},wt=async()=>{var V,me,Be,Fe,W,Te;let o=e==null?void 0:e.merchantPublicKey,l=e==null?void 0:e.orderID,B=O&&!ze?O:String(ge),Q=e==null?void 0:e.customerId;if(!(Je!=null&&Je.device_id)){g("Please Select A Payment Device");return}if(o&&l&&B){U(!0);let Re={amount:B,fractalpayPublicKey:o,customer_order_id:l,device_id:Je==null?void 0:Je.device_id,customer_id:Q||""};try{let ae=await Pn.post(`${Ie}charge-with-reader`,Re);((V=ae==null?void 0:ae.data)==null?void 0:V.result)==!0?(fe((Be=(me=ae==null?void 0:ae.data)==null?void 0:me.data)==null?void 0:Be.transaction_id),C(!0),U(!1)):(g(((Fe=ae==null?void 0:ae.data)==null?void 0:Fe.message)||"Something went wrong."),U(!1))}catch(ae){g(((Te=(W=ae==null?void 0:ae.response)==null?void 0:W.data)==null?void 0:Te.message)||"Something went wrong."),U(!1)}}else g("Something went wrong.")},pe=()=>{et==="card"?mt():et==="reader"&&wt()};Tn(()=>{Ce&&x&&De()},[x,Ce]);let kt=async o=>{Fn.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async l=>{if(l.isConfirmed){U(!0);try{let B={card_id:o,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},Q=await Pn.post(`${Ie}delete-customer-card`,B);U(!1),De(),Fn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(B){U(!1),Fn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else l.dismiss===Fn.DismissReason.cancel&&Fn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},At=o=>{switch(o==null?void 0:o.toLowerCase()){case"visa":return ke;case"mastercard":case"mc":case"m/c":return R;case"amex":case"american express":case"ae":return M;case"discover":case"dcvr":return se;case"bank":return Ye;default:return o}},Ft=()=>{let o=X||0;return(Number(ge)-o).toFixed(0)};console.log(dt,"activeinCard","activeinBank",xt);let Ht=o=>{var l,B,Q,V;console.log(o,"values"),oe==="ach"?((l=Number(X))==null?void 0:l.toFixed(2))<(o==null?void 0:o.floatValue)||(o==null?void 0:o.floatValue)<=0?(st(o==null?void 0:o.value),vt(`Partial amount cannot exceeds ${qe((B=Number(X))==null?void 0:B.toFixed(2))}`)):(st(o==null?void 0:o.value),vt("")):((Q=Number(ge))==null?void 0:Q.toFixed(2))<(o==null?void 0:o.floatValue)||(o==null?void 0:o.floatValue)<=0?(st(o==null?void 0:o.value),vt(`Partial amount cannot exceeds ${qe((V=Number(ge))==null?void 0:V.toFixed(2))}`)):(st(o==null?void 0:o.value),vt(""))};return Tn(()=>{let o=Number(oe==="ach"?X:ge),l=Number(O);O&&(l<=0||l>o)?vt(`Partial amount cannot exceed ${qe(o.toFixed(2))}`):vt("")},[oe,O,X,ge]),console.log(oe,"activetab"),n.createElement(n.Fragment,null,n.createElement(tn,null),n.createElement(gn,null),n.createElement(xn,null),n.createElement(n.Fragment,null,n.createElement("button",{ref:G,style:{display:"none"},className:"paymentBtn",onClick:T},"Pay"),n.createElement(Wt,{open:Ce,onClose:Et},$&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(nn,{error:$,onClose:Et})),Ae&&n.createElement(fn,{onClose:Et,tranId:tt}),!$&&!Ae&&n.createElement(n.Fragment,null,(_e||b)&&n.createElement(Yt,{loading:_e||b}),n.createElement("div",{className:"frac-card-payment-page frac-form"},n.createElement("div",{className:"parent-pay-container"},n.createElement("span",{className:"request-payment-close-popup",onClick:Et},n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12425_52336)"},n.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12425_52336"},n.createElement("rect",{width:"16",height:"16",fill:"white"}))))),n.createElement("div",{className:"pay-main-logo-res"},n.createElement("img",{src:w==null?void 0:w.logo,id:"pay-logos"})),n.createElement("div",{className:"pay-container"},n.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},n.createElement("div",{className:"pay-conatiner-one-first"},n.createElement("div",{className:"pay-logo-container"},n.createElement("div",{className:"pay-main-logo"},n.createElement("img",{src:w==null?void 0:w.logo,id:"pay-logos"})),(S==null?void 0:S.length)>0&&oe!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>He("cardList")}," ",n.createElement(qn,null)," Back")),n.createElement("div",{className:"amt-pay-con"},n.createElement("div",{className:"pay-amount-conatiner"},n.createElement("small",{className:"pay-payment-amount"},"Select payment type")),n.createElement("div",{className:"frac-card-bank-radio-main"},n.createElement(an,{label:"Card",amount:(zt=Number(ge))==null?void 0:zt.toFixed(2),value:"card",onChange:A,activetab:oe}),(w==null?void 0:w.isSkyFiAccount)&&n.createElement(an,{label:"Bank",amount:(Bt=Number(X))==null?void 0:Bt.toFixed(2),value:"ach",onChange:A,activetab:oe})),X&&X>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,oe==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,qe((Number(ge)-X).toFixed(2)))):null,(e==null?void 0:e.allowPartial)&&n.createElement("div",{className:"frac-partial-payment-input"},n.createElement("label",{htmlFor:"partialpayment"},"Partial Payment"),n.createElement(Si,{prefix:"$",className:"form-control",value:O,onValueChange:o=>{Ht(o)},thousandSeparator:!0,placeholder:"Enter partial amount",allowNegative:!1,allowLeadingZeros:!1,decimalScale:2,fixedDecimalScale:!0}),ze&&n.createElement("span",{className:"error-span"},ze)))),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:re,alt:""}),n.createElement("img",{src:ne,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},!_e&&n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},oe!=="cardList"?n.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(S==null?void 0:S.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>He("cardList")}," ",n.createElement(qn,null)," Back"),(w==null?void 0:w.isSkyFiAccount)&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks",onClick:o=>{A("card")},style:{border:oe==="card"?"1px solid":""}},n.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),n.createElement("button",{className:"tablinks",onClick:o=>{A("ach")},style:{border:oe==="ach"?"1px solid":""}},n.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),n.createElement("div",{className:"res-pay-con"},n.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",(Zt=Number(ge))==null?void 0:Zt.toFixed(2))),oe!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:ke,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:R,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:M,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:se,width:35,alt:""})))),X&&X>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",X)),X&&X>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,oe==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,qe((Number(ge)-X).toFixed(2)))):null):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",w==null?void 0:w.customer_name),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",et==="card"?"Cards/Banks":"Readers"," "),n.createElement("div",{className:"res-pay-con"},n.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",($t=Number(ge))==null?void 0:$t.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:ke,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:R,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:M,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:se,width:35,alt:""}))))),n.createElement("div",{id:"card",style:{display:oe==="card"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(S==null?void 0:S.length)>0&&dt==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ot("list")}," ",n.createElement(qn,null)),X&&X>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",X))),n.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),oe!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},n.createElement("img",{src:ke,alt:"",width:33}),n.createElement("img",{src:R,width:33,alt:""}),n.createElement("img",{src:M,alt:"",width:33}),n.createElement("img",{src:se,width:33,alt:""}))),dt==="list"?n.createElement(n.Fragment,null,n.createElement(mn,{listHeading:"Cards",paymentGateway:w==null?void 0:w.paymentGateway,ListItems:S,selectedCard:lt,setSelectedCard:Ue,handleDeleteCard:kt,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{ot("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:pe},O&&!ze?qe((Rt=Number(O))==null?void 0:Rt.toFixed(2)):qe((ut=Number(ge))==null?void 0:ut.toFixed(2))))):n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Qe},n.createElement("div",{className:"ach-scrl",style:{minHeight:w!=null&&w.isSkyFiAccount&&(S==null?void 0:S.length)>0?"444px":w!=null&&w.isSkyFiAccount&&(S==null?void 0:S.length)==0?"456px":(S==null?void 0:S.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(i==null?void 0:i.cardName)||"",onChange:o=>{let l=o.target.value;/^[a-zA-Z\s]*$/.test(l)&&ie("cardName",l)}}),(c==null?void 0:c.cardName)&&n.createElement("span",{className:"error-span"},c==null?void 0:c.cardName)),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(i==null?void 0:i.cardNumber)||"",onChange:o=>Xe(o),"data-token":"card_number"}),n.createElement("div",{className:"card-crdi card-expiry-new"},n.createElement("div",{className:"exp-date-year-container"},n.createElement("div",{className:"exp-date form-group"},n.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(i==null?void 0:i.expiryMonth)||"",onChange:o=>ie("expiryMonth",o.target.value)})),n.createElement("div",{className:"exp-year form-group"},n.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(i==null?void 0:i.expiryYear)||"",onChange:o=>ie("expiryYear",o.target.value)})),n.createElement("div",{className:"security-digit form-group"},n.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(i==null?void 0:i.cvv)||"",onChange:o=>ie("cvv",o.target.value)})))),(c==null?void 0:c.cardNumber)&&n.createElement("span",{className:"error-span"},c==null?void 0:c.cardNumber),n.createElement("p",{style:{margin:"0"}},c!=null&&c.expiryMonth||c!=null&&c.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},c==null?void 0:c.expiryMonth):"",(c==null?void 0:c.cvv)&&n.createElement("span",{className:"error-span"},c==null?void 0:c.cvv)))),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"Order Id",disabled:!0,value:(ue=e==null?void 0:e.orderID)!=null?ue:"",style:{background:"#F6F6F7",color:"#727272"}})),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(xe=i==null?void 0:i.zipCode)!=null?xe:"",onChange:o=>ie("zipCode",o.target.value)}),(c==null?void 0:c.zipCode)&&n.createElement("span",{className:"error-span"},c==null?void 0:c.zipCode)),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:q,onChange:o=>m(o.target.checked)}),n.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),n.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12420_50192)"},n.createElement("rect",{width:"20",height:"20",fill:"white"}),n.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),n.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12420_50192"},n.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),n.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(w==null?void 0:w.paymentDeviceList)&&((Tt=w==null?void 0:w.paymentDeviceList)==null?void 0:Tt.length)>0&&n.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>_(!Ot)},Ot?"Pay With Reader":"Pay With Card"),n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},O&&!ze?qe((qt=Number(O))==null?void 0:qt.toFixed(2)):qe((Ee=Number(ge))==null?void 0:Ee.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:oe==="ach"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(ce==null?void 0:ce.length)>0&&xt==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ke("list")}," ",n.createElement(qn,null)),X&&X>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),n.createElement("div",null,"$",Ft()))),n.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),xt==="list"?n.createElement(n.Fragment,null,n.createElement(mn,{listHeading:"Banks",paymentGateway:w==null?void 0:w.paymentGateway,ListItems:ce,selectedCard:lt,setSelectedCard:Ue,handleDeleteCard:kt,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Ke("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:pe},O&&!ze?qe((y=Number(O))==null?void 0:y.toFixed(2)):qe((d=Number(X))==null?void 0:d.toFixed(2))))):n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Qe,autoComplete:"off"},n.createElement("div",{className:"ach-scrl",style:{minHeight:w!=null&&w.isSkyFiAccount&&(S==null?void 0:S.length)>0?"444px":w!=null&&w.isSkyFiAccount&&(S==null?void 0:S.length)==0?"436px":(S==null?void 0:S.length)>0?"462px":"520px",maxHeight:w!=null&&w.isSkyFiAccount&&(S==null?void 0:S.length)>0?"444px":((S==null?void 0:S.length)>0,"380px")}},n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),n.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(K=s==null?void 0:s.name)!=null?K:"",onChange:ee}),(u==null?void 0:u.name)&&n.createElement("span",{className:"error-span"},u==null?void 0:u.name)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"routingnumber"},"Routing number"),n.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(ve=s==null?void 0:s.routingNumber)!=null?ve:"",onChange:ee}),(u==null?void 0:u.routingNumber)&&n.createElement("span",{className:"error-span"},u==null?void 0:u.routingNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accountnumber"},"Account number"),n.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Y=s==null?void 0:s.accountNumber)!=null?Y:"",onChange:ee}),(u==null?void 0:u.accountNumber)&&n.createElement("span",{className:"error-span"},u==null?void 0:u.accountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),n.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:($e=s==null?void 0:s.confirmAccountNumber)!=null?$e:"",onChange:ee}),(u==null?void 0:u.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},u==null?void 0:u.confirmAccountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"bankname"},"Bank name"),n.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(Oe=s==null?void 0:s.bankName)!=null?Oe:"",onChange:ee}),(u==null?void 0:u.bankName)&&n.createElement("span",{className:"error-span"},u==null?void 0:u.bankName)),((s==null?void 0:s.accountType)==="business saving"||(s==null?void 0:s.accountType)==="business checking")&&n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"companyName"},"Company name"),n.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(Ze=s==null?void 0:s.companyName)!=null?Ze:"",onChange:ee}),(u==null?void 0:u.companyName)&&n.createElement("span",{className:"error-span"},u==null?void 0:u.companyName)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accounttype"},"Select account type"),n.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(Ve=s==null?void 0:s.accountType)!=null?Ve:"",onChange:ee},n.createElement("option",{value:""},"Select account"),Ln.map(o=>n.createElement("option",{key:o.value,value:o.value},o.label)))),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},n.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:j,onChange:o=>he(o.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),j&&n.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},n.createElement("p",null,"If checked, I agree for ",n.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),n.createElement("div",{className:"form-group "},n.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},O&&!ze?qe((E=Number(O))==null?void 0:E.toFixed(2)):qe((_t=Number(X))==null?void 0:_t.toFixed(2))))))))))))))))}var Po=Gn(()=>import("./PayButtonWithForm-56YF56C5.mjs").then(e=>({default:e.PaymentWidget})));export{Ni as AddCard,ki as CardOnFile,fi as GetPaymentPage,Pi as PartialPayment,Po as PaymentWidget,yi as PreAuthPayment,ri as RequestPayment,mi as RequestPreAuthPayment};
2266
+ `)}function fr({session_token:e,callback:h,isloading:q,onCancel:$,showChecks:N,merchantName:I,signCheckbox:z,checkedSignCheckbox:ie,onCheckSign:ge,cancelbtnClass:Q,savebtnClass:L,inputClass:Z,isDual:ae}){var o;let[w,v]=fi(!1),[R,E]=fi(!1),[y,Pe]=fi(),[C,Ae]=fi({}),[$e,pe]=fi(""),Ve=()=>v(!0),rt=()=>v(!1),[Ce,Xe]=fi(!1),fe=()=>{var g,W,x,S,F,Ke,Ye,gt;let a={},i=y,b=parseInt((i==null?void 0:i.expiryMonth)||"",10),P=(i==null?void 0:i.expiryYear)||"";return(g=i==null?void 0:i.firstName)!=null&&g.trim()||(a.firstName="Please enter a first name."),(W=i==null?void 0:i.lastName)!=null&&W.trim()||(a.lastName="Please enter a last name."),(x=i==null?void 0:i.cardNumber)!=null&&x.trim()||(a.cardNumber="Please enter a card number."),(S=i==null?void 0:i.expiryMonth)!=null&&S.trim()?(Number(i==null?void 0:i.expiryMonth)>12||Number(i==null?void 0:i.expiryMonth)<1)&&(a.expiryMonth="Invalid Expiration Month."):a.expiryMonth="Please enter an expiry month.",(F=i==null?void 0:i.expiryYear)!=null&&F.trim()?((Ke=i==null?void 0:i.expiryYear)==null?void 0:Ke.trim().length)!==4||Number(i==null?void 0:i.expiryYear)<2025?a.expiryYear="Invalid Expiration Year.":(isNaN(b)||b<1||b>12||P.length!==4)&&(a.expiryMonth="Invalid Expiration Date."):a.expiryYear="Please enter an expiry year.",(Ye=i==null?void 0:i.cvv)!=null&&Ye.trim()||(a.cvv="Please enter a CVV."),(gt=i==null?void 0:i.zipCode)!=null&&gt.trim()||(a.zipCode="Please enter a zip code."),z&&!ie&&(a.checkSign="You must authorize this before proceeding."),N&&!(i!=null&&i.authHold)&&(a.authHold="You must authorize this before proceeding."),N&&!(i!=null&&i.authorise)&&(a.authorise="Please confirm your authorization to continue."),Ae(a),Object.keys(a).length>0},nt=a=>{var W;let i=a.target,b=i.value.replace(/\D/g,""),{formatted:P,cursor:g}=Bn(i.value,(W=i.selectionStart)!=null?W:0);Ae(x=>M(k({},x),{cardNumber:""})),Pe(x=>M(k({},x),{cardNumber:P})),requestAnimationFrame(()=>{i.setSelectionRange(g,g)})},Ee=(a,i)=>{let b=a;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(b)){(i===""||/^[0-9]+$/.test(i))&&(Ae(g=>M(k({},g),{[b]:""})),Pe(g=>M(k({},g),{[b]:i})));return}Ae(g=>M(k({},g),{[b]:""})),Pe(g=>M(k({},g),{[b]:i}))},pn=()=>{let a=DatacapWebToken.validateCardNumber(y==null?void 0:y.cardNumber.replaceAll(" ","")),i=DatacapWebToken.validateExpirationDate(y==null?void 0:y.expiryMonth,y==null?void 0:y.expiryYear),b=DatacapWebToken.validateCVV(y==null?void 0:y.cvv),P={};return a||(P.cardNumber="Invalid card Number"),i||(P.expiryMonth="Invalid Expiration Date."),b||(P.cvv="Invalid CVV"),Ae(P),a&&b&&i},Y=async a=>{var i,b;if(a.Error)pe(a.Error),rt();else{let P={token:a.Token,resp:a},g=await Pi.post(`${Le}api/v1/gateway/update/token/${e}`,P);if((g==null?void 0:g.status)==200){let W=k(k({Token:(b=(i=g==null?void 0:g.data)==null?void 0:i.data)==null?void 0:b.gateway_token,Brand:a.Brand,ExpirationMonth:a.ExpirationMonth,ExpirationYear:a.ExpirationYear,Last4:a.Last4,Bin:a.Bin,CVV:a.CVV,postalCode:y==null?void 0:y.zipCode},N&&{authHold:y==null?void 0:y.authHold}),N&&{authorise:y==null?void 0:y.authorise});rt(),h(W)}}},p=async()=>{var a,i,b,P,g,W,x,S,F,Ke,Ye,gt,Yt,Ct;try{let wt={method:"POST",redirect:"follow"},he=await Pi.post(`${Le}api/v1/widget/generate-session`,wt),ce=Number(y==null?void 0:y.expiryYear)%100,ze=`${(a=y==null?void 0:y.cardNumber)==null?void 0:a.replace(/\s+/g,"")}=${ce}${y==null?void 0:y.expiryMonth} ${y==null?void 0:y.cvv}`,oe=forge.pki.publicKeyFromPem((b=(i=he==null?void 0:he.data)==null?void 0:i.data)==null?void 0:b.publicKeyPem).encrypt(ze,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),pt=forge.util.encode64(oe),mt={"Content-Type":"application/json","x-app-session-key":(g=(P=he.data)==null?void 0:P.data)==null?void 0:g.session_key},Pt=JSON.stringify({enc_track2_data:pt,algorithm:"RSAES_OAEP_SHA_1",session_key:(x=(W=he==null?void 0:he.data)==null?void 0:W.data)==null?void 0:x.session_key}),B=await Pi.post(`${cn}tokenizer/tokenize`,Pt,{headers:mt});if((B==null?void 0:B.status)==200){let Ht=(F=(S=B==null?void 0:B.data)==null?void 0:S.data)==null?void 0:F.token;try{let vt=await Pi.post(`${Le}api/v1/gateway/verify-and-save/${e}`,{token:Ht});if((vt==null?void 0:vt.status)==200){let He=(Ke=vt==null?void 0:vt.data)==null?void 0:Ke.data,It={Token:He.gateway_token,Brand:He.card_data.brand,ExpirationMonth:He.card_data.expire_mm,ExpirationYear:He.card_data.expire_yy,Last4:He.card_data.last4,Bin:He.card_data.bin,postalCode:y==null?void 0:y.zipCode};rt(),h(It)}}catch(vt){console.log(vt,"error"),rt()}}}catch(wt){let he="Something went wrong!";try{let ce=((Ye=wt==null?void 0:wt.response)==null?void 0:Ye.data)||(wt==null?void 0:wt.message)||"",H=typeof ce=="string"?ce:JSON.stringify(ce),Ie=(((Yt=(gt=H.split)==null?void 0:gt.call(H,`
2267
+ `))==null?void 0:Yt.filter(Boolean))||[]).at(-1)||"",oe=(Ct=Ie.split)==null?void 0:Ct.call(Ie,": ");he=(oe==null?void 0:oe.length)>1?oe.pop().trim():Ie.trim()||he}catch(ce){he="Something went wrong!"}rt(),pe(he)}},u=async a=>{var P,g,W,x,S,F,Ke;if(a.preventDefault(),!(fe()||!pn())){Ve();try{let Ye=await Pi.get(`${Le}api/v1/gateway/token/${e}`,{params:{pass_fee:Ce}});if((Ye==null?void 0:Ye.status)==200){let gt=(g=(P=Ye==null?void 0:Ye.data)==null?void 0:P.data)==null?void 0:g.gateway_token;((x=(W=Ye==null?void 0:Ye.data)==null?void 0:W.data)==null?void 0:x.paymentGateway)==((S=Vi)==null?void 0:S.FRACTALKEY)?await p():DatacapWebToken.requestToken(gt,"creditCardForm",Y)}}catch(Ye){rt(),pe(((Ke=(F=Ye==null?void 0:Ye.response)==null?void 0:F.data)==null?void 0:Ke.message)||"Something went wrong!")}}},A=()=>{pe("")},re=()=>{pe(""),Pe({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1,checkSign:!1}),$()};return console.log(Ce,"aoapoaa"),j.createElement(j.Fragment,null,j.createElement(An,null),j.createElement(Di,null),j.createElement(mn,{loading:w||q}),$e&&j.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},j.createElement(Tn,{error:$e,onClose:A})),!$e&&j.createElement("div",{className:"creditformbox"},j.createElement("form",{id:"creditCardForm",onSubmit:u},j.createElement("div",{className:"name-row"},j.createElement("div",{className:"form-group"},j.createElement("label",null," First Name ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(y==null?void 0:y.firstName)||"",onChange:a=>{let i=a.target.value;/^[a-zA-Z\s]*$/.test(i)&&Ee("firstName",i)},className:Z}),(C==null?void 0:C.firstName)&&j.createElement("small",{className:"error"},C==null?void 0:C.firstName)),j.createElement("div",{className:"form-group"},j.createElement("label",null," Last Name ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(y==null?void 0:y.lastName)||"",onChange:a=>{let i=a.target.value;/^[a-zA-Z\s]*$/.test(i)&&Ee("lastName",i)},className:Z}),(C==null?void 0:C.lastName)&&j.createElement("small",{className:"error"},C==null?void 0:C.lastName))),j.createElement("div",{className:"form-pay-row"},j.createElement("div",{className:"form-group"},j.createElement("label",null," Card Number ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(y==null?void 0:y.cardNumber)||"",onChange:a=>nt(a),className:Z}),(C==null?void 0:C.cardNumber)&&j.createElement("small",{className:"error"},C==null?void 0:C.cardNumber))),j.createElement("div",{className:"card-pay-row"},j.createElement("div",{className:"form-group"},j.createElement("label",null," Exp Month ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(y==null?void 0:y.expiryMonth)||"",onChange:a=>Ee("expiryMonth",a.target.value),className:Z}),(C==null?void 0:C.expiryMonth)&&j.createElement("small",{className:"error"},C==null?void 0:C.expiryMonth)),j.createElement("div",{className:"form-group"},j.createElement("label",null," Exp Year ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(y==null?void 0:y.expiryYear)||"",onChange:a=>Ee("expiryYear",a.target.value),className:Z}),(C==null?void 0:C.expiryYear)&&j.createElement("small",{className:"error"},C==null?void 0:C.expiryYear)),j.createElement("div",{className:"form-group"},j.createElement("label",null," CVV ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(y==null?void 0:y.cvv)||"",onChange:a=>Ee("cvv",a.target.value),className:Z}),(C==null?void 0:C.cvv)&&j.createElement("small",{className:"error"},C==null?void 0:C.cvv)),j.createElement("div",{className:"form-group"},j.createElement("label",null," Zip ",j.createElement("span",{className:"text-danger"},"*")),j.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(o=y==null?void 0:y.zipCode)!=null?o:"",onChange:a=>Ee("zipCode",a.target.value),className:Z}),(C==null?void 0:C.zipCode)&&j.createElement("small",{className:"error"},C==null?void 0:C.zipCode))),ae&&j.createElement("div",{className:"pass-fee-toggle-div"},j.createElement("input",{type:"checkbox",id:"pass_fee",className:"toggle-checkbox",checked:Ce,onChange:a=>{Xe(a.target.checked)}}),j.createElement("label",{htmlFor:"pass_fee",className:"toggle-label"}),j.createElement("label",{htmlFor:"save_card"},"Cash Discount")),z&&j.createElement("div",{className:"checks-row"},j.createElement("input",{name:"discalosure",type:"checkbox",id:"disclosureCheck",checked:ie,onChange:a=>ge(a.target.checked)}),j.createElement("label",{htmlFor:"disclosureCheck",className:"form-check-label"},"Please agree to the following in order to add Payment method.")),z&&(C==null?void 0:C.checkSign)&&j.createElement("small",{className:"check-error"},C==null?void 0:C.checkSign),N&&j.createElement(j.Fragment,null,j.createElement("div",{className:"checks-row"},j.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(y!=null&&y.authHold),onChange:a=>Ee("authHold",a.target.checked)}),j.createElement("label",{htmlFor:"authHold",className:"form-check-label"},"To securely save your card on file, we will place a temporary authorization hold of $1.00. This is not a charge and will be released by your card issuer shortly after verification.")),(C==null?void 0:C.authHold)&&j.createElement("small",{className:"check-error"},C==null?void 0:C.authHold),j.createElement("div",{className:"checks-row "},j.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(y!=null&&y.authorise),onChange:a=>Ee("authorise",a.target.checked)}),j.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},R?j.createElement(j.Fragment,null,j.createElement("span",null,"By providing your payment information, you authorize"," ",j.createElement("strong",null,I),", 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"," ",j.createElement("strong",null,I),". You may request the removal of your stored payment information at any time by contacting"," ",j.createElement("strong",null,I)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",j.createElement("a",{href:"#",onClick:a=>{a.preventDefault(),E(!1)}},"See less ..."))):j.createElement(j.Fragment,null,j.createElement("span",null,"By providing your payment information, you authorize ",I,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),j.createElement("a",{href:"#",onClick:a=>{a.preventDefault(),E(!0)}},"See more ...")))),(C==null?void 0:C.authorise)&&j.createElement("small",{className:"check-error"},C==null?void 0:C.authorise)),j.createElement("div",{className:"button-row"},j.createElement("button",{className:`cancelbtn ${Q} `,type:"button",onClick:re},"Cancel"),j.createElement("button",{className:`savebtn ${L} `,type:"submit"},"Save")))))}import n,{useEffect as Ei,useRef as hr,useState as Mt}from"react";import Fi from"axios";import Mi from"sweetalert2";import{IoArrowBack as Ki}from"react-icons/io5";import{NumericFormat as yr}from"react-number-format";function br(e){var Xt,tn,fn,hn,Fn,Ot,Be,De,xn,vn,kt,_,f,de,ct,ee,We,ye,$t,Ft,be,Dt;let h=hr(null);Ei(()=>{e.onTriggerPay&&e.onTriggerPay(()=>{U()})},[e]);let q=D+"widget/mc-img.svg",$=D+"widget/visa-img.svg",N=D+"widget/ae-img.svg",I=D+"widget/discover-img.svg",z=D+"widget/card.svg",ie=D+"widget/Trash.svg",ge=D+"widget/bank.svg",Q=D+"widget/secure-img.png",L=D+"widget/pov-by.png",Z=D+"widget/pax.svg",[ae,w]=Mt(!1),[v,R]=Mt(!1),[E,y]=Mt(""),[Pe,C]=Mt(!1),[Ae,$e]=Mt(!1),[pe,Ve]=Mt("card"),[rt,Ce]=Mt("card"),[Xe,fe]=Mt("form"),[nt,Ee]=Mt("form"),[pn,Y]=Mt(!0),[p,u]=Mt(!1),[A,re]=Mt(!1),o=e.merchantPublicKey,[a,i]=Mt(),[b,P]=Mt({}),[g,W]=Mt(),[x,S]=Mt({}),[F,Ke]=Mt([]),[Ye,gt]=Mt([]),[Yt,Ct]=Mt(),[wt,he]=Mt(),[ce,H]=Mt(Number(e==null?void 0:e.amount)),[ze,Ie]=Mt(Number(e==null?void 0:e.amount)),[oe,pt]=Mt(""),[mt,Pt]=Mt("");console.log(oe,"partialAmount");let[B,Ht]=Mt(),[vt,He]=Mt(""),It=()=>w(!0),sn=()=>w(!1),Wn=(c,m)=>{let G=(parseFloat(m)||0)/100;return c-c*G},Zt=(c,m)=>{let G=(Number(m)||0)/100;return+c+ +(c*G)};Ei(()=>{Ae&&(e!=null&&e.pass_fee?(Ie(Number(e==null?void 0:e.amount)),H(Number(e==null?void 0:e.cashDiscount))):(Ie(Number(e==null?void 0:e.amount)),H(Number(e==null?void 0:e.amount))))},[Ae,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let Nn=()=>{$e(!1),Ve("card"),y(""),C(!1),He(""),W({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),S({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),i({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),P({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),re(!1),u(!1),Ct({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),he({}),H(0),Ce("card"),Y(!0),Ee("form"),fe("form"),R(!1),w(!1),gt([]),Ke([]),pt(""),Pt("")},U=()=>$e(!0),K=c=>{Ve(c)},Ze=(c,m)=>{let G=c;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(G)){(m===""||/^[0-9]+$/.test(m))&&(P(ne=>M(k({},ne),{[G]:""})),i(ne=>M(k({},ne),{[G]:m})));return}P(ne=>M(k({},ne),{[G]:""})),i(ne=>M(k({},ne),{[G]:m}))},Bt=c=>{var ft;let m=c.target,G=m.value.replace(/\D/g,""),{formatted:we,cursor:ne}=Bn(m.value,(ft=m.selectionStart)!=null?ft:0);P(bt=>M(k({},bt),{cardNumber:""})),i(bt=>M(k({},bt),{cardNumber:we})),requestAnimationFrame(()=>{m.setSelectionRange(ne,ne)})},Fe=c=>{let{name:m,value:G}=c.target,we=["routingNumber","accountNumber","confirmAccountNumber"];if(m=="name"){/^[a-zA-Z\s]*$/.test(G)&&(S(ne=>M(k({},ne),{[m]:""})),W(ne=>M(k({},ne),{[m]:G})));return}if(we.includes(m)){(G===""||/^[0-9]+$/.test(G))&&(S(ne=>M(k({},ne),{[m]:""})),W(ne=>M(k({},ne),{[m]:G})));return}S(ne=>M(k({},ne),{[m]:""})),W(ne=>M(k({},ne),{[m]:G}))},Lt=()=>{var ne,ft,bt,xe,ue,Re;let c={},m=a,G=parseInt((m==null?void 0:m.expiryMonth)||"",10),we=(m==null?void 0:m.expiryYear)||"";if((ne=m==null?void 0:m.cardName)!=null&&ne.trim()||(c.cardName="Card name is required"),(ft=m==null?void 0:m.cardNumber)!=null&&ft.trim()||(c.cardNumber="Card number is required"),(!((bt=m==null?void 0:m.expiryMonth)!=null&&bt.trim())||!((xe=m==null?void 0:m.expiryYear)!=null&&xe.trim())||isNaN(G)||G<1||G>12||we.length!==4)&&(c.expiryMonth="Invalid Expiration Date."),(ue=m==null?void 0:m.cvv)!=null&&ue.trim()||(c.cvv="CVV is required"),(Re=m==null?void 0:m.zipCode)!=null&&Re.trim()||(c.zipCode="ZIP code is required"),m!=null&&m.expiryMonth&&(m!=null&&m.expiryYear)&&m.expiryMonth.length<=2&&m.expiryYear.length===4){let it=parseInt(m.expiryMonth,10),Ne=parseInt(m.expiryYear,10),at=new Date,ve=at.getMonth()+1,xt=at.getFullYear();(Ne<xt||Ne===xt&&it<ve)&&(c.expiryMonth="Card is expired")}return P(c),Object.keys(c).length>0},Tt=()=>{var G,we,ne,ft,bt,xe,ue,Re;let c={},m=g;return(G=m==null?void 0:m.name)!=null&&G.trim()||(c.name="Name is required"),(we=m==null?void 0:m.accountNumber)!=null&&we.trim()||(c.accountNumber="Account number is required"),(ne=m==null?void 0:m.accountNumber)!=null&&ne.trim()&&((ft=m==null?void 0:m.accountNumber)==null?void 0:ft.trim())!==((bt=m==null?void 0:m.confirmAccountNumber)==null?void 0:bt.trim())&&(c.confirmAccountNumber="Account numbers must match"),(xe=m==null?void 0:m.bankName)!=null&&xe.trim()||(c.bankName="Bank name is required"),(ue=m==null?void 0:m.routingNumber)!=null&&ue.trim()||(c.routingNumber="Routing Number is required"),m!=null&&m.routingNumber&&((Re=m==null?void 0:m.routingNumber)==null?void 0:Re.length)!==9&&(c.routingNumber="Routing number must be 9 digits"),((m==null?void 0:m.accountType)==="business saving"||(m==null?void 0:m.accountType)==="business checking")&&(!(m!=null&&m.companyName)||(m==null?void 0:m.companyName)==="")&&(c.companyName="Company Name is required for business accounts"),S(c),Object.keys(c).length>0},qt=async c=>{var m,G,we,ne,ft,bt,xe,ue,Re,it,Ne,at,ve,xt,ot;if(c.preventDefault(),!mt)if(pe!=="ach"){if(Lt())return;{let ht=DatacapWebToken.validateCardNumber(a==null?void 0:a.cardNumber.replaceAll(" ","")),je=DatacapWebToken.validateExpirationDate(a==null?void 0:a.expiryMonth,a==null?void 0:a.expiryYear),$n=DatacapWebToken.validateCVV(a==null?void 0:a.cvv),Mn={};if(ht||(Mn.cardNumber="Invalid card Number"),je||(Mn.expiryMonth="Invalid Expiration Date."),$n||(Mn.cvv="Invalid CVV"),P(Mn),ht&&$n&&je){R(!0);try{let Cn=async function(nn){var st,se;if(nn.Error)y(nn.Error),R(!1);else{let an=a==null?void 0:a.cardName,kn=a==null?void 0:a.zipCode;nn.name=an,nn.postal_code=kn,nn.isCardSave=`${p}`,nn.isCharge=!0,nn.posSalesIdEncode=(st=B==null?void 0:B.orderDetails)==null?void 0:st.orderId,nn.partial_amount=oe&&!mt?oe:ze,Et.emit("sendMessage",nn);let Sn=(se=B==null?void 0:B.orderDetails)==null?void 0:se.orderId;Et.on(Sn,Yn=>{if(mi(Yn==null?void 0:Yn.data)){let Wt=JSON.parse(Yn.data);Wt!=null&&Wt.result?(i({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),u(!1),He(Wt==null?void 0:Wt.transactionId),C(!0),R(!1)):(R(!1),y((Wt==null?void 0:Wt.message)||"Something went wrong."))}else y("Something went wrong.")})}};if((B==null?void 0:B.paymentGateway)===32){let nn={method:"POST",redirect:"follow"};try{let st=await Fi.post(`${Le}api/v1/widget/generate-session`,nn),se=Number(a==null?void 0:a.expiryYear)%100,an=a==null?void 0:a.cardNumber;an=an==null?void 0:an.replace(/\s+/g,"");let kn=`${an}=${se}${a==null?void 0:a.expiryMonth} ${a==null?void 0:a.cvv}`,Yn=forge.pki.publicKeyFromPem((G=(m=st==null?void 0:st.data)==null?void 0:m.data)==null?void 0:G.publicKeyPem).encrypt(kn,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Wt=forge.util.encode64(Yn),ei={"Content-Type":"application/json","x-app-session-key":(ne=(we=st.data)==null?void 0:we.data)==null?void 0:ne.session_key},_n=JSON.stringify({enc_track2_data:`${Wt}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(bt=(ft=st==null?void 0:st.data)==null?void 0:ft.data)==null?void 0:bt.session_key}`});try{let yn=await Fi.post(`${cn}tokenizer/tokenize`,_n,{headers:ei}),Li=JSON.stringify(M(k({},(xe=yn==null?void 0:yn.data)==null?void 0:xe.data),{isSaveCardChecked:p,name:a==null?void 0:a.cardName,postal_code:a==null?void 0:a.zipCode,customer_id:e==null?void 0:e.customerId,partial_amount:oe&&!mt?oe:ze})),Ai=JSON.stringify({pre_sales_id:`${(ue=B==null?void 0:B.orderDetails)==null?void 0:ue.orderId}`,token:`${(Re=yn==null?void 0:yn.data)==null?void 0:Re.data.token}`,json_response:`${Li}`}),zi={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:Ai,redirect:"follow",isChargeviafractal:!0};Et.emit("sendMessage",zi),Et.on("chargeviafractalgateway",Jn=>{var bi;if(mi(Jn==null?void 0:Jn.data)){let r=JSON.parse(Jn==null?void 0:Jn.data);r!=null&&r.result?(He((bi=r==null?void 0:r.data)==null?void 0:bi.transactionId),C(!0),R(!1)):(R(!1),y((r==null?void 0:r.message)||"Something went wrong."))}else y("Something went wrong.")})}catch(yn){R(!1),y(((Ne=(it=yn==null?void 0:yn.response)==null?void 0:it.data)==null?void 0:Ne.message)||(yn==null?void 0:yn.message)||"Something went wrong.")}}catch(st){R(!1),y(((ve=(at=st==null?void 0:st.response)==null?void 0:at.data)==null?void 0:ve.message)||(st==null?void 0:st.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(B==null?void 0:B.dctoken,"PaymentForm",Cn)}catch(Cn){R(!1),y(((ot=(xt=Cn==null?void 0:Cn.response)==null?void 0:xt.data)==null?void 0:ot.message)||(Cn==null?void 0:Cn.message)||"Something went wrong.")}}}}else{if(Tt())return;{R(!0);let ht={fractalpayPublicKey:o,label:(g==null?void 0:g.name)||"John Doe",account_number:g==null?void 0:g.accountNumber,routing_number:g==null?void 0:g.routingNumber,bank_name:g==null?void 0:g.bankName,account_type:g==null?void 0:g.accountType,amount:oe&&!mt?oe:String(ce||0),isSaveAch:A,customer_id:e==null?void 0:e.customerId,order_id:e==null?void 0:e.orderID,tax:e==null?void 0:e.tax,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,isChargeACH:!0,company_name:(g==null?void 0:g.companyName)||"",orderGuid:e==null?void 0:e.orderGuid};Et.emit("sendMessage",ht),Et.on("ach-incoming",je=>{var $n;(je==null?void 0:je.status)=="Failed"?typeof(je==null?void 0:je.message)=="object"?Object.values(je==null?void 0:je.message).forEach(Mn=>{y(Mn||"Something went wrong")}):y((je==null?void 0:je.message)||"Something went wrong"):(He(($n=je==null?void 0:je.data)==null?void 0:$n.transaction_id),C(!0),R(!1))})}}},Nt=async()=>{var c,m,G,we,ne,ft,bt,xe,ue,Re,it,Ne,at,ve,xt,ot,Rt,ht,je,$n,Mn,Cn,nn;It();try{let st={fractalpayPublicKey:o,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,orderGuid:e==null?void 0:e.orderGuid},se=await Fi.post(`${tt}get-payment-details`,st);if(Ht((c=se==null?void 0:se.data)==null?void 0:c.data),(G=(m=se==null?void 0:se.data)==null?void 0:m.data)!=null&&G.paymentGateway||(Nn(),y("Something went wrong.")),(ne=(we=se==null?void 0:se.data)==null?void 0:we.data)!=null&&ne.card_list&&((xe=(bt=(ft=se==null?void 0:se.data)==null?void 0:ft.data)==null?void 0:bt.card_list)==null?void 0:xe.length)>0){let an=(it=(Re=(ue=se==null?void 0:se.data)==null?void 0:ue.data)==null?void 0:Re.card_list)==null?void 0:it.filter(Sn=>(Sn==null?void 0:Sn.card_type)=="Bank"),kn=(ve=(at=(Ne=se==null?void 0:se.data)==null?void 0:Ne.data)==null?void 0:at.card_list)==null?void 0:ve.filter(Sn=>(Sn==null?void 0:Sn.card_type)!=="Bank");console.log(an,"hohgohoo",kn),(kn==null?void 0:kn.length)>0&&fe("list"),(an==null?void 0:an.length)>0&&Ee("list"),Ke(kn),gt(an)}else Ve("card");(ot=(xt=se==null?void 0:se.data)==null?void 0:xt.data)!=null&&ot.paymentDeviceList&&((je=(ht=(Rt=se==null?void 0:se.data)==null?void 0:Rt.data)==null?void 0:ht.paymentDeviceList)==null?void 0:je.length)>0&&he((Mn=($n=se==null?void 0:se.data)==null?void 0:$n.data)==null?void 0:Mn.paymentDeviceList[0]),sn()}catch(st){console.log(st),sn(),y(((nn=(Cn=st==null?void 0:st.response)==null?void 0:Cn.data)==null?void 0:nn.message)||(st==null?void 0:st.message)||"Something went wrong")}},jt=async()=>{let c=e==null?void 0:e.customerId,m=String(e==null?void 0:e.discount),G=String(e==null?void 0:e.surcharge),we=String(e==null?void 0:e.tax),ne=e==null?void 0:e.merchantPublicKey,ft=e==null?void 0:e.orderID,bt=oe&&!mt?oe:String(ze),xe=Yt==null?void 0:Yt.id,ue=Yt==null?void 0:Yt.card_type;if(!mt)if(ne&&ft&&bt&&ce)if(c)if(xe){let it;oe&&!mt?it=oe:ue==="Bank"?it=ce:it=ze;let Ne={amount:it,order_id:ft,customer_id:c,card_id:xe,fractalpayPublicKey:ne,isCardSave:p,discount:m,surcharge:G,tax:we,orderGuid:e==null?void 0:e.orderGuid,pass_fee:e==null?void 0:e.pass_fee,require3ds:!1};oe&&!mt&&ue!=="Bank"&&(Ne.ispartialPayment=!0);let Re=Ne,{isCardSave:at}=Re,ve=di(Re,["isCardSave"]),ot=tt+(ue==="Bank"?"charge-ach":"charge-by-card"),Rt={"Content-Type":"application/json"};R(!0),Et.emit("sendMessage",{url:ot,body:ue=="Bank"?ve:Ne,isChargebycard:!0}),Et.on("charge-by-card",ht=>{var je;(ht==null?void 0:ht.result)==!0||(ht==null?void 0:ht.status)==!0?(He((je=ht.data)==null?void 0:je.transaction_id),C(!0),R(!1)):y((ht==null?void 0:ht.message)||"Something went wrong.")})}else y("Please Select A Card/ACH");else y("Please Select Customer");else y("Something went wrong.")},Gt=async()=>{var ne,ft,bt,xe,ue,Re;let c=e==null?void 0:e.merchantPublicKey,m=e==null?void 0:e.orderID,G=oe&&!mt?oe:String(ze),we=e==null?void 0:e.customerId;if(!(wt!=null&&wt.device_id)){y("Please Select A Payment Device");return}if(c&&m&&G){R(!0);let it={amount:G,fractalpayPublicKey:c,customer_order_id:m,device_id:wt==null?void 0:wt.device_id,customer_id:we||""};try{let Ne=await Fi.post(`${tt}charge-with-reader`,it);((ne=Ne==null?void 0:Ne.data)==null?void 0:ne.result)==!0?(He((bt=(ft=Ne==null?void 0:Ne.data)==null?void 0:ft.data)==null?void 0:bt.transaction_id),C(!0),R(!1)):(y(((xe=Ne==null?void 0:Ne.data)==null?void 0:xe.message)||"Something went wrong."),R(!1))}catch(Ne){y(((Re=(ue=Ne==null?void 0:Ne.response)==null?void 0:ue.data)==null?void 0:Re.message)||"Something went wrong."),R(!1)}}else y("Something went wrong.")},Je=()=>{rt==="card"?jt():rt==="reader"&&Gt()};Ei(()=>{Ae&&o&&Nt()},[o,Ae]);let Ut=async c=>{Mi.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){R(!0);try{let G={card_id:c,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},we=await Fi.post(`${tt}delete-customer-card`,G);R(!1),Nt(),Mi.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(G){R(!1),Mi.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else m.dismiss===Mi.DismissReason.cancel&&Mi.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},ln=c=>{switch(c==null?void 0:c.toLowerCase()){case"visa":return $;case"mastercard":case"mc":case"m/c":return q;case"amex":case"american express":case"ae":return N;case"discover":case"dcvr":return I;case"bank":return ge;default:return c}},yt=()=>{let c=ce||0;return(Number(ze)-c).toFixed(0)};console.log(Xe,"activeinCard","activeinBank",nt);let dn=c=>{var m,G,we,ne;console.log(c,"values"),pe==="ach"?((m=Number(ce))==null?void 0:m.toFixed(2))<(c==null?void 0:c.floatValue)||(c==null?void 0:c.floatValue)<=0?(pt(c==null?void 0:c.value),Pt(`Partial amount cannot exceed ${Se((G=Number(ce))==null?void 0:G.toFixed(2))}`)):(pt(c==null?void 0:c.value),Pt("")):((we=Number(ze))==null?void 0:we.toFixed(2))<(c==null?void 0:c.floatValue)||(c==null?void 0:c.floatValue)<=0?(pt(c==null?void 0:c.value),Pt(`Partial amount cannot exceed ${Se((ne=Number(ze))==null?void 0:ne.toFixed(2))}`)):(pt(c==null?void 0:c.value),Pt(""))};return Ei(()=>{let c=Number(pe==="ach"?ce:ze),m=Number(oe);oe&&(m<=0||m>c)?Pt(`Partial amount cannot exceed ${Se(c.toFixed(2))}`):Pt("")},[pe,oe,ce,ze]),console.log(pe,"activetab"),n.createElement(n.Fragment,null,n.createElement(An,null),n.createElement(ai,null),n.createElement(Xn,null),n.createElement(n.Fragment,null,n.createElement("button",{ref:h,style:{display:"none"},className:"paymentBtn",onClick:U},"Pay"),n.createElement(Pn,{open:Ae,onClose:Nn},E&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(Tn,{error:E,onClose:Nn})),Pe&&n.createElement(ri,{onClose:Nn,tranId:vt}),!E&&!Pe&&n.createElement(n.Fragment,null,(ae||v)&&n.createElement(mn,{loading:ae||v}),n.createElement("div",{className:"frac-card-payment-page frac-form"},n.createElement("div",{className:"parent-pay-container"},n.createElement("span",{className:"request-payment-close-popup",onClick:Nn},n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12425_52336)"},n.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12425_52336"},n.createElement("rect",{width:"16",height:"16",fill:"white"}))))),n.createElement("div",{className:"pay-main-logo-res"},n.createElement("img",{src:B==null?void 0:B.logo,id:"pay-logos"})),n.createElement("div",{className:"pay-container"},n.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},n.createElement("div",{className:"pay-conatiner-one-first"},n.createElement("div",{className:"pay-logo-container"},n.createElement("div",{className:"pay-main-logo"},n.createElement("img",{src:B==null?void 0:B.logo,id:"pay-logos"})),(F==null?void 0:F.length)>0&&pe!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>Ve("cardList")}," ",n.createElement(Ki,null)," Back")),n.createElement("div",{className:"amt-pay-con"},n.createElement("div",{className:"pay-amount-conatiner"},n.createElement("small",{className:"pay-payment-amount"},"Select payment type")),n.createElement("div",{className:"frac-card-bank-radio-main"},n.createElement(In,{label:"Card",amount:(Xt=Number(ze))==null?void 0:Xt.toFixed(2),value:"card",onChange:K,activetab:pe}),(B==null?void 0:B.isSkyFiAccount)&&n.createElement(In,{label:"Bank",amount:(tn=Number(ce))==null?void 0:tn.toFixed(2),value:"ach",onChange:K,activetab:pe})),ce&&ce>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,pe==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,Se((Number(ze)-ce).toFixed(2)))):null,(e==null?void 0:e.allowPartial)&&n.createElement("div",{className:"frac-partial-payment-input"},n.createElement("label",{htmlFor:"partialpayment"},"Partial Payment"),n.createElement(yr,{prefix:"$",className:"form-control",value:oe,onValueChange:c=>{dn(c)},thousandSeparator:!0,placeholder:"Enter partial amount",allowNegative:!1,allowLeadingZeros:!1,decimalScale:2,fixedDecimalScale:!0}),mt&&n.createElement("span",{className:"error-span"},mt)))),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:Q,alt:""}),n.createElement("img",{src:L,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},!ae&&n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},pe!=="cardList"?n.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(F==null?void 0:F.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ve("cardList")}," ",n.createElement(Ki,null)," Back"),(B==null?void 0:B.isSkyFiAccount)&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks",onClick:c=>{K("card")},style:{border:pe==="card"?"1px solid":""}},n.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),n.createElement("button",{className:"tablinks",onClick:c=>{K("ach")},style:{border:pe==="ach"?"1px solid":""}},n.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),n.createElement("div",{className:"res-pay-con"},n.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",(fn=Number(ze))==null?void 0:fn.toFixed(2))),pe!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:$,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:q,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:N,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:I,width:35,alt:""})))),ce&&ce>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",ce)),ce&&ce>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,pe==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,Se((Number(ze)-ce).toFixed(2)))):null):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",B==null?void 0:B.customer_name),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",rt==="card"?"Cards/Banks":"Readers"," "),n.createElement("div",{className:"res-pay-con"},n.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},n.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),n.createElement("strong",{className:"pay-amount"},"$",(hn=Number(ze))==null?void 0:hn.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:$,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:q,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:N,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:I,width:35,alt:""}))))),n.createElement("div",{id:"card",style:{display:pe==="card"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(F==null?void 0:F.length)>0&&Xe==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>fe("list")}," ",n.createElement(Ki,null)),ce&&ce>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",ce))),n.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),pe!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},n.createElement("img",{src:$,alt:"",width:33}),n.createElement("img",{src:q,width:33,alt:""}),n.createElement("img",{src:N,alt:"",width:33}),n.createElement("img",{src:I,width:33,alt:""}))),Xe==="list"?n.createElement(n.Fragment,null,n.createElement(En,{listHeading:"Cards",paymentGateway:B==null?void 0:B.paymentGateway,ListItems:F,selectedCard:Yt,setSelectedCard:Ct,handleDeleteCard:Ut,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{fe("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Je},oe&&!mt?Se((Fn=Number(oe))==null?void 0:Fn.toFixed(2)):Se((Ot=Number(ze))==null?void 0:Ot.toFixed(2))))):n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:qt},n.createElement("div",{className:"ach-scrl",style:{minHeight:B!=null&&B.isSkyFiAccount&&(F==null?void 0:F.length)>0?"444px":B!=null&&B.isSkyFiAccount&&(F==null?void 0:F.length)==0?"456px":(F==null?void 0:F.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(a==null?void 0:a.cardName)||"",onChange:c=>{let m=c.target.value;/^[a-zA-Z\s]*$/.test(m)&&Ze("cardName",m)}}),(b==null?void 0:b.cardName)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.cardName)),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),n.createElement("div",{className:"toggle-num-wrapper"},n.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(a==null?void 0:a.cardNumber)||"",onChange:c=>Bt(c),"data-token":"card_number"}),n.createElement("div",{className:"card-crdi card-expiry-new"},n.createElement("div",{className:"exp-date-year-container"},n.createElement("div",{className:"exp-date form-group"},n.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(a==null?void 0:a.expiryMonth)||"",onChange:c=>Ze("expiryMonth",c.target.value)})),n.createElement("div",{className:"exp-year form-group"},n.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(a==null?void 0:a.expiryYear)||"",onChange:c=>Ze("expiryYear",c.target.value)})),n.createElement("div",{className:"security-digit form-group"},n.createElement("input",{"data-token":"cvv",className:"form-control card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(a==null?void 0:a.cvv)||"",onChange:c=>Ze("cvv",c.target.value)})))),(b==null?void 0:b.cardNumber)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.cardNumber),n.createElement("p",{style:{margin:"0"}},b!=null&&b.expiryMonth||b!=null&&b.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},b==null?void 0:b.expiryMonth):"",(b==null?void 0:b.cvv)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.cvv)))),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"Order Id",disabled:!0,value:(Be=e==null?void 0:e.orderID)!=null?Be:"",style:{background:"#F6F6F7",color:"#727272"}})),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"zip"},"ZIP"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(De=a==null?void 0:a.zipCode)!=null?De:"",onChange:c=>Ze("zipCode",c.target.value)}),(b==null?void 0:b.zipCode)&&n.createElement("span",{className:"error-span"},b==null?void 0:b.zipCode)),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},n.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:p,onChange:c=>u(c.target.checked)}),n.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),n.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},n.createElement("g",{clipPath:"url(#clip0_12420_50192)"},n.createElement("rect",{width:"20",height:"20",fill:"white"}),n.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),n.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_12420_50192"},n.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),n.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(B==null?void 0:B.paymentDeviceList)&&((xn=B==null?void 0:B.paymentDeviceList)==null?void 0:xn.length)>0&&n.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>Y(!pn)},pn?"Pay With Reader":"Pay With Card"),n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},oe&&!mt?Se((vn=Number(oe))==null?void 0:vn.toFixed(2)):Se((kt=Number(ze))==null?void 0:kt.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:pe==="ach"?"block":"none"},className:"tabcontent"},n.createElement("div",{className:"frac-card-payment"},n.createElement("div",{className:"frac-heading-card-wrap"},n.createElement("div",{className:"frac-backarrow"},(Ye==null?void 0:Ye.length)>0&&nt==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Ee("list")}," ",n.createElement(Ki,null)),ce&&ce>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),n.createElement("div",null,"$",yt()))),n.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),nt==="list"?n.createElement(n.Fragment,null,n.createElement(En,{listHeading:"Banks",paymentGateway:B==null?void 0:B.paymentGateway,ListItems:Ye,selectedCard:Yt,setSelectedCard:Ct,handleDeleteCard:Ut,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Ee("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Je},oe&&!mt?Se((_=Number(oe))==null?void 0:_.toFixed(2)):Se((f=Number(ce))==null?void 0:f.toFixed(2))))):n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:qt,autoComplete:"off"},n.createElement("div",{className:"ach-scrl",style:{minHeight:B!=null&&B.isSkyFiAccount&&(F==null?void 0:F.length)>0?"444px":B!=null&&B.isSkyFiAccount&&(F==null?void 0:F.length)==0?"436px":(F==null?void 0:F.length)>0?"462px":"520px",maxHeight:B!=null&&B.isSkyFiAccount&&(F==null?void 0:F.length)>0?"444px":((F==null?void 0:F.length)>0,"380px")}},n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),n.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(de=g==null?void 0:g.name)!=null?de:"",onChange:Fe}),(x==null?void 0:x.name)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.name)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"routingnumber"},"Routing number"),n.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(ct=g==null?void 0:g.routingNumber)!=null?ct:"",onChange:Fe}),(x==null?void 0:x.routingNumber)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.routingNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accountnumber"},"Account number"),n.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(ee=g==null?void 0:g.accountNumber)!=null?ee:"",onChange:Fe}),(x==null?void 0:x.accountNumber)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.accountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),n.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(We=g==null?void 0:g.confirmAccountNumber)!=null?We:"",onChange:Fe}),(x==null?void 0:x.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.confirmAccountNumber)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"bankname"},"Bank name"),n.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(ye=g==null?void 0:g.bankName)!=null?ye:"",onChange:Fe}),(x==null?void 0:x.bankName)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.bankName)),((g==null?void 0:g.accountType)==="business saving"||(g==null?void 0:g.accountType)==="business checking")&&n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"companyName"},"Company name"),n.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:($t=g==null?void 0:g.companyName)!=null?$t:"",onChange:Fe}),(x==null?void 0:x.companyName)&&n.createElement("span",{className:"error-span"},x==null?void 0:x.companyName)),n.createElement("div",{className:"form-group mb-4"},n.createElement("label",{htmlFor:"accounttype"},"Select account type"),n.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(Ft=g==null?void 0:g.accountType)!=null?Ft:"",onChange:Fe},n.createElement("option",{value:""},"Select account"),ci.map(c=>n.createElement("option",{key:c.value,value:c.value},c.label)))),(e==null?void 0:e.customerId)&&n.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},n.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:A,onChange:c=>re(c.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),A&&n.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},n.createElement("p",null,"If checked, I agree for ",n.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),n.createElement("div",{className:"form-group "},n.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},oe&&!mt?Se((be=Number(oe))==null?void 0:be.toFixed(2)):Se((Dt=Number(ce))==null?void 0:Dt.toFixed(2))))))))))))))))}import Zn,{useEffect as Na,useState as yi,useMemo as Ar}from"react";import xr from"react";function Ri(){let e="#000",h="#fff",q="#212529",$="#dee2e6";return xr.createElement("style",null,`
2268
+ @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
2269
+ body
2270
+ {
2271
+ font-family: 'Inter', sans-serif;
2272
+ }
2273
+ input
2274
+ {
2275
+ font-family: 'Inter', sans-serif !important;
2276
+ }
2277
+ .frac-form .form-group-frac{
2278
+ margin:0 !important
2279
+ }
2280
+ .frac-form .mb-4{
2281
+ margin-bottom : 10px !important
2282
+ }
2283
+ .frac-form .save-ach-div{
2284
+ display:flex !important;
2285
+ gap:5px !important;
2286
+ align-items:center
2287
+ }
2288
+
2289
+ .frac-form .card-cvv-in{
2290
+ height : 36px !importantt;
2291
+ }
2292
+
2293
+ .frac-form .pay-payment-amount{
2294
+ text-align:start !important
2295
+ }
2296
+ .frac-form .pay-amount{
2297
+ text-align:start !important
2298
+ }
2299
+ .frac-form .pay-main-logo{
2300
+ text-align:start !important
2301
+ }
2302
+
2303
+
2304
+
2305
+ .paymentBtn {
2306
+ background-color: black;
2307
+ border: none;
2308
+ color: white;
2309
+ padding: 15px 32px;
2310
+ text-align: center;
2311
+ text-decoration: none;
2312
+ display: inline-block;
2313
+ font-size: 16px;
2314
+ margin: 4px 2px;
2315
+ cursor: pointer;
2316
+ border-radius: 180px;
2317
+ /* width: auto; */
2318
+ }
2319
+
2320
+ .main-logo {
2321
+ text-align: center;
2322
+ margin-bottom: 20px;
2323
+ }
2324
+
2325
+ .main-logo img {
2326
+ max-width: 180px;
2327
+ }
2328
+
2329
+ .pay-main-box {
2330
+ width: 365px !important;
2331
+ height: 93%;
2332
+ background: 0 0 #ffffff;
2333
+ border-radius: 12px;
2334
+
2335
+
2336
+ border: 1px solid #E0DFE2;
2337
+ margin: 0 auto;
2338
+ display: block;
2339
+ padding: 0px 26px !important
2340
+ }
2341
+ .pay-main-box .pay-header {
2342
+ display: flex;
2343
+ justify-content: center;
2344
+ align-items: center;
2345
+ text-align: center;
2346
+ }
2347
+
2348
+ .pay-main-box .pay-header button {
2349
+ border: 0;
2350
+ background: none;
2351
+ padding: 0;
2352
+ box-shadow: 0;
2353
+ outline: inherit;
2354
+ }
2355
+
2356
+ .pay-main-box h1 {
2357
+ margin: 0;
2358
+ flex: 1;
2359
+ padding: 10px 0;
2360
+ font-size: 23px;
2361
+ font-weight: 500;
2362
+ color: #35254D;
2363
+ align-items: start;
2364
+ display: flex;
2365
+ }
2366
+ .tab {
2367
+ overflow: hidden;
2368
+ padding: 5px;
2369
+ border-radius: 8px;
2370
+ display: flex;
2371
+ justify-content: space-around;
2372
+ margin-bottom:12px
2373
+ }
2374
+
2375
+ /* Style the buttons inside the tab */
2376
+ .tab button {
2377
+ float: left;
2378
+ border: none;
2379
+ outline: none;
2380
+ cursor: pointer;
2381
+ background:white;
2382
+ padding: 11px 16px;
2383
+ transition: 0.3s;
2384
+ font-size: 16px;
2385
+ width: 143px;
2386
+ border-radius: 5px;
2387
+ box-shadow: inherit;
2388
+ outline: none;
2389
+ color: ${e};
2390
+ }
2391
+
2392
+ /* Change background color of buttons on hover */
2393
+ .tab button:hover {
2394
+ background-color: #f0f0f0;
2395
+ }
2396
+
2397
+ /* Create an active/current tablink class */
2398
+ // .tab button.active {
2399
+ // background-color: #ccc;
2400
+ // }
2401
+
2402
+ /* Style the tab content */
2403
+
2404
+
2405
+ .parent-pay-container{
2406
+ padding: 24px;
2407
+ }
2408
+ .pay-container{
2409
+ display: grid;
2410
+ grid-template-columns: 2fr 3fr;
2411
+
2412
+ }
2413
+ .pay-main{
2414
+ padding-y: 20px}
2415
+
2416
+ .request-payment-close-popup {
2417
+ position: absolute;
2418
+ right: 20px;
2419
+ top: 20px;
2420
+ cursor: pointer;
2421
+ }
2422
+ .pay-conatiner-one{
2423
+ border-right: 1px solid #E0DFE2;
2424
+ display: flex;
2425
+ flex-direction: column;
2426
+ justify-content: space-between;
2427
+ }
2428
+ .pay-conatiner-one-first{
2429
+
2430
+ min-height:inherit !important;
2431
+ }
2432
+ .pay-conatiner-one-last{
2433
+ display:flex;
2434
+ font-size:12px;
2435
+ gap:5px;
2436
+ max-width:250px;
2437
+ align-items:center;
2438
+ color:black !important
2439
+ }
2440
+ .pay-conatiner-one-last img{
2441
+ width : 17px;
2442
+ height:17px
2443
+ }
2444
+ .pay-conatiner-two{
2445
+ padding: 0 5% 0;
2446
+ }
2447
+ .pay-logo-container{
2448
+ border-bottom: 1px solid #E0DFE2
2449
+ }
2450
+ .pay-heading{
2451
+ margin: 0;
2452
+ flex: 1;
2453
+ padding: 10px 0;
2454
+ font-size: 23px;
2455
+ font-weight: 500;
2456
+ color: #35254D;
2457
+ align-items: start;
2458
+ display: flex;
2459
+ }
2460
+ .pay-main-logo > img{
2461
+ width: 50%;
2462
+ }
2463
+ .pay-main-logo-res > img{
2464
+ width: 50%;
2465
+ display : none
2466
+ }
2467
+
2468
+ .pay-payment-amount{
2469
+ display: block;
2470
+ font-size: 12px;
2471
+ color: #727272;
2472
+ margin-bottom: 8px;
2473
+ }
2474
+ .pay-amount-conatiner{
2475
+ margin-top: 6%;
2476
+ }
2477
+ .pay-amount{
2478
+ color: #000000;
2479
+ font-size: 38px;
2480
+ display: block;
2481
+ line-height: 110%;
2482
+ letter-spacing: -1px;
2483
+ }
2484
+ .frac-form label{
2485
+ font-family: 'IBM Plex Mono', monospace !important;
2486
+ color: #727272 !important;
2487
+ margin-bottom: 2px !important;
2488
+ font-weight: 600 !important;
2489
+ font-size: 12px !important;
2490
+ display:block !important;
2491
+ text-align : left !important
2492
+ }
2493
+ .form-control-frac{
2494
+ display: block;
2495
+ width: 100%;
2496
+ padding: .375rem .75rem;
2497
+ font-size: 1rem;
2498
+ font-weight: 400;
2499
+ line-height: 1.5;
2500
+ color: ${q};
2501
+ -webkit-appearance: none;
2502
+ -moz-appearance: none;
2503
+ appearance: none;
2504
+ background-color: ${h};
2505
+ background-clip: padding-box;
2506
+ border: 1px solid ${$};
2507
+ border-radius: 0.375rem;
2508
+ transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
2509
+ }
2510
+ .form-control-frac:focus{
2511
+ border-color: #86b7fe;
2512
+ outline: 0;
2513
+ }
2514
+ .toggle-num-wrapper {
2515
+ position: relative;
2516
+ }
2517
+ .card-number-new{
2518
+ border-bottom: none;
2519
+ border-bottom-left-radius: 0px;
2520
+ border-bottom-right-radius: 0px;
2521
+ }
2522
+ .card-crdi {
2523
+ display: flex;
2524
+ border: 1px solid ${$};
2525
+ border-radius: 0.375rem;
2526
+ }
2527
+ .card-expiry-new{
2528
+ border-top-left-radius: 0px;
2529
+ border-top-right-radius: 0px;
2530
+ }
2531
+ .exp-date-year-container{
2532
+ display: flex;
2533
+ flex-wrap: wrap;
2534
+ }
2535
+ .exp-date-year-container .form-group-frac{
2536
+ flex:1;
2537
+ padding: 0px !important
2538
+
2539
+ }
2540
+
2541
+ .exp-date {
2542
+ float: left;
2543
+ // width: 30%
2544
+ }
2545
+
2546
+ .exp-date input {
2547
+ width: calc(100% + 1px);
2548
+ border-top-right-radius: 0;
2549
+ border-bottom-right-radius: 0;
2550
+ border: 0;
2551
+ border-right: 1px solid ${$};
2552
+ }
2553
+
2554
+
2555
+ .exp-year {
2556
+ float: left;
2557
+ // width: 30%
2558
+ }
2559
+
2560
+ .exp-year input {
2561
+ width: calc(100% + 1px);
2562
+ border-radius: 0;
2563
+ border-top: 0;
2564
+ border-bottom: 0;
2565
+ border-right: 1px solid ${$};
2566
+ }
2567
+
2568
+ .exp-date input:focus {
2569
+ position: relative;
2570
+ z-index: 10;
2571
+ }
2572
+
2573
+ .security-digit {
2574
+ float: right;
2575
+ // width: 40%;
2576
+ position: relative;
2577
+ }
2578
+
2579
+ .security-digit input {
2580
+ border-top-left-radius: 0;
2581
+ border-bottom-left-radius: 0;
2582
+ border-top: 0;
2583
+ border-bottom: 0;
2584
+ border-right:0;
2585
+ }
2586
+ .card-expiry-new{
2587
+ border-top-left-radius: 0px;
2588
+ border-top-right-radius: 0px;
2589
+ }
2590
+ .form-control-frac{box-sizing: border-box ;}
2591
+ #PaymentForm .form-group-frac{
2592
+ padding:5px 0 ;
2593
+ matgin: 0 !important
2594
+ }
2595
+
2596
+ .toggle-label {
2597
+ position: relative;
2598
+ display: inline-block;
2599
+ width: 40px;
2600
+ height: 24px;
2601
+ background-color: #ccc;
2602
+ border-radius: 12px;
2603
+ cursor: pointer;
2604
+ transition: background-color 0.3s;
2605
+ }
2606
+
2607
+ .toggle-label::before {
2608
+ content: "";
2609
+ position: absolute;
2610
+ top: 2px;
2611
+ left: 2px;
2612
+ width: 20px;
2613
+ height: 20px;
2614
+ background: #ffffff;
2615
+ border-radius: 50%;
2616
+ transition: left 300ms linear;
2617
+ }
2618
+
2619
+ .toggle-checkbox {
2620
+ display: none;
2621
+ }
2622
+
2623
+ .toggle-checkbox:checked + .toggle-label {
2624
+ background-color: #4caf50;
2625
+ }
2626
+
2627
+ .toggle-checkbox:checked + .toggle-label::before {
2628
+ left: 18px;
2629
+ }
2630
+ .ach-scrl {
2631
+ max-height: 380px;
2632
+ min-height: 380px;
2633
+ overflow-y: auto;
2634
+ padding-right: 6px;
2635
+ }
2636
+ .mb-4{
2637
+ margin-bottom:4px
2638
+ }
2639
+ .ach-scrl::-webkit-scrollbar {
2640
+ width: 3px;
2641
+ background-color: #F5F5F5;
2642
+ }
2643
+ .ach-scrl::-webkit-scrollbar-thumb {
2644
+ background-color: #35254D;
2645
+ }
2646
+
2647
+ .error-span{
2648
+ color:red !important;
2649
+ font-size:12px !important;
2650
+ text-align: left !important;
2651
+ width: 100% !important;
2652
+ display: block;
2653
+ }
2654
+
2655
+ .charge-customer-name-frac{
2656
+ color: #161616;
2657
+ font-family: Inter;
2658
+ font-size: 24px;
2659
+ font-style: normal;
2660
+ font-weight: 600;
2661
+ line-height: 32px;
2662
+ letter-spacing: -0.48px;
2663
+ text-transform: capitalize;
2664
+ margin-top:0;
2665
+ margin-bottom:16px !important;
2666
+ text-align:left !important
2667
+ }
2668
+ .card-ach-heading-frac {
2669
+ color: #727272;
2670
+ font-family: Inter;
2671
+ font-size: 12px;
2672
+ font-style: normal;
2673
+ font-weight: 500;
2674
+ line-height: 18px;
2675
+ letter-spacing: -0.24px;
2676
+ margin : 0 0 10px !important;
2677
+ text-align : left
2678
+ }
2679
+ .card-list-div{
2680
+ max-height : 190px;
2681
+ overflow-y : auto;
2682
+ border:1px solid #E0DFE2;
2683
+ border-radius : 8px
2684
+ }
2685
+
2686
+
2687
+ .card-list-div::-webkit-scrollbar{
2688
+ width:2px;
2689
+ background-color:#F5F5F5
2690
+ }
2691
+ .card-list-div::-webkit-scrollbar-thumb{
2692
+ background-color:#35254D
2693
+ }
2694
+
2695
+ .card-list-single-div{
2696
+ border-bottom: 1px solid #E0DFE2;
2697
+ padding : 8px 11px;
2698
+ display : flex ;
2699
+ align-items:center;
2700
+ justify-content : space-between;
2701
+ gap:12px
2702
+ }
2703
+ .card-list-single-div:last-child {
2704
+ border-bottom: none;
2705
+ }
2706
+ .card-lint-div-in{
2707
+ min-height:444px}
2708
+ .card-number-radio{
2709
+ display:flex;
2710
+ gap:12px;
2711
+ }
2712
+ .card-number-radio .card-number-last-four{
2713
+ color:#161616 !important;
2714
+ font-family:Inter !important;
2715
+ font-size:14px !important;
2716
+ font-weight:500 !important;
2717
+ font-style:normal !important;
2718
+ line-height : 18px !important;
2719
+ latter-spacing:-0.18px !important
2720
+ }
2721
+ .card-expiry-date{
2722
+ margin:0;
2723
+ color:#00000080;
2724
+ font-family:Inter;
2725
+ font-size:14px;
2726
+ font-weight:500;
2727
+ font-style"normal;
2728
+ line-height : 18px;
2729
+ latter-spacing:-0.18px
2730
+ }
2731
+ .pay-with-other-card {
2732
+ margin-top : 12px;
2733
+ padding:12px 32px;
2734
+ border :1px solid #E0DFE2;
2735
+ border-radius : 1000px;
2736
+ display: flex;
2737
+ justify-content : center;
2738
+ align-items:center;
2739
+ gap:10px;
2740
+ // width:100%;
2741
+ background:white;
2742
+ cursor:pointer;
2743
+ color:#161616;
2744
+ text-align:center
2745
+ font-family: Inter;
2746
+ font-size: 14px;
2747
+ font-style: normal;
2748
+ font-weight: 500;
2749
+ line-height: 24px;
2750
+ letter-spacing: -0.28px;
2751
+ // margin-bottom: 50px;
2752
+ }
2753
+ .charge-payment-back-btn {
2754
+ display: flex;
2755
+ padding: 6px 12px !important ;
2756
+ align-items: center;
2757
+ gap: 6px;
2758
+ border-radius: 1000px;
2759
+ border: 1px solid #E0DFE2;
2760
+ background: #FFF;
2761
+ box-shadow: 0px 6px 12px 0px rgba(206, 197, 221, 0.31);
2762
+ font-size:16px;
2763
+ curso:pointer;
2764
+ color:black
2765
+ }
2766
+ .res-charge-payment-back-btn{
2767
+ padding: 9px 16px;
2768
+ align-items: center;
2769
+ gap: 6px;
2770
+ margin-bottom: 20px;
2771
+ border-radius: 1000px;
2772
+ border: 1px solid #E0DFE2;
2773
+ background: #FFF;
2774
+ box-shadow: 0px 6px 12px 0px rgba(206, 197, 221, 0.31);
2775
+ font-size:16px;
2776
+ curso:pointer;
2777
+ color:black;
2778
+ display:none
2779
+ }
2780
+ .btn {
2781
+ padding: 11px 23px;
2782
+ background-color: black;
2783
+ color: white;
2784
+ border: none;
2785
+ border-radius: 6px;
2786
+ font-weight: bold;
2787
+ margin: 0 10px;
2788
+ cursor: pointer;
2789
+ }
2790
+
2791
+ .custom-swal-icon {
2792
+ margin: 20px auto;
2793
+ }
2794
+
2795
+ .custom-swal-popup {
2796
+ font-size: 16px;
2797
+ text-align: center;
2798
+ }
2799
+
2800
+ .frac-form .res-pay-con{
2801
+ display:none
2802
+ }
2803
+
2804
+ .saveachtext p, .saveachtext b {
2805
+ font-size: 12px !important;
2806
+ color: #727272 !important;
2807
+ }
2808
+
2809
+ .cardicon-img img {
2810
+ margin-top: -2px !important;
2811
+ }
2812
+
2813
+ .bankicon-img img {
2814
+ margin-top: -4px !important;
2815
+ }
2816
+
2817
+ .cardicon {
2818
+ margin-right : 8px !important;
2819
+ width : 18px !important;
2820
+ }
2821
+
2822
+ .bankicon {
2823
+ margin-right : 8px !important;
2824
+ width : 18px !important;
2825
+ }
2826
+
2827
+
2828
+ .frac-tooltip-wrapper {
2829
+ position: absolute;
2830
+ right:0;
2831
+ }
2832
+
2833
+ .frac-tooltip-icon {
2834
+ cursor: pointer;
2835
+ }
2836
+ .frac-tooltip-mn{
2837
+ position:relative;
2838
+ }
2839
+ .frac-tooltip-text {
2840
+ display: none;
2841
+ position: absolute;
2842
+ top:-15px;
2843
+ right: 22px;
2844
+ background: #161616;
2845
+ color: white;
2846
+ padding: 15px;
2847
+ border-radius: 10px;
2848
+ width: 200px;
2849
+ font-size:12px;
2850
+ word-break: break-word;
2851
+ white-space: normal;
2852
+ z-index: 999;
2853
+ }
2854
+
2855
+ .frac-tooltip-wrapper:hover .frac-tooltip-text {
2856
+ display: block;
2857
+ }
2858
+
2859
+ .frac-tooltip-text p,.frac-tooltip-text b {
2860
+ font-size : 12px !important;
2861
+ line-height : 1.5 !important;
2862
+ margin-bottom : 10px !important;
2863
+ }
2864
+
2865
+ .amt-pay-con {
2866
+ padding-right: 24px;
2867
+ }
2868
+
2869
+
2870
+
2871
+ @media (max-width: 768px) {
2872
+ .card-lint-div-in {
2873
+ min-height: auto;
2874
+ margin-bottom: 10px;
2875
+ }
2876
+ .ach-scrl {
2877
+ min-height: auto !important;
2878
+ margin-bottom: 10px;
2879
+ }
2880
+ .request-payment-close-popup {
2881
+ right: 12px !important;
2882
+ top: 12px !important;
2883
+ }
2884
+
2885
+ .parent-pay-container{
2886
+ padding:24px;
2887
+ }
2888
+ .pay-container {
2889
+ grid-template-columns: 1fr;
2890
+ padding: 10px 5%;
2891
+ border:1px solid #E0DFE2;
2892
+ border-radius : 12px
2893
+ }
2894
+ .pay-conatiner-one{
2895
+ border-right: none;
2896
+ }
2897
+ .pay-conatiner-one-first{
2898
+ min-height:0
2899
+ }
2900
+ .pay-main-logo > img{
2901
+ display: none;
2902
+ }
2903
+ .pay-main-logo-res > img {
2904
+ display:block;
2905
+ margin:auto
2906
+ }
2907
+
2908
+ .pay-logo-container{
2909
+ border :none
2910
+ }
2911
+ // .res-charge-payment-back-btn {
2912
+ // display:flex !important
2913
+ // }
2914
+ // .charge-payment-back-btn{
2915
+ // display:none !important
2916
+ // }
2917
+
2918
+ .frac-new-form .pay-amount-conatiner {
2919
+ margin-top: 0px;
2920
+ margin-bottom: 24px;
2921
+ }
2922
+ .frac-form .res-pay-con{
2923
+ display:flex;
2924
+ justify-content :space-between;
2925
+ align-items:center;
2926
+ padding-bottom : 10px
2927
+ }
2928
+ .amt-pay-con {
2929
+ padding-right: 0px;
2930
+ }
2931
+ .pay-conatiner-one-last{
2932
+ display:none}
2933
+ .pay-conatiner-two{
2934
+ padding:0
2935
+ }
2936
+
2937
+
2938
+ }
2939
+ @media (max-width : 512px){
2940
+ .tab button {
2941
+ padding: 6px 16px;
2942
+ }
2943
+
2944
+ }
2945
+
2946
+
2947
+ .frac-cash-discount-fee {
2948
+ display: flex;
2949
+ padding: 11px;
2950
+ justify-content: space-between;
2951
+ align-items: center;
2952
+ align-self: stretch;
2953
+ border-radius: 8px;
2954
+ border: 1px solid #E0DFE2;
2955
+ background: #F6F6F7;
2956
+ margin-top: 24px;
2957
+ }
2958
+ .frac-cash-discount-fee small {
2959
+ color:#727272;
2960
+ font-size: 12px;
2961
+ font-weight: 500;
2962
+ }
2963
+ .frac-cash-discount-fee p{
2964
+ margin:0px;
2965
+ font-size: 14px;
2966
+ font-weight: 500;
2967
+ }
2968
+ .frac-card-payment-heading {
2969
+ font-size: 24px;
2970
+ font-style: normal;
2971
+ font-weight: 600;
2972
+ margin:0px;
2973
+ }
2974
+
2975
+ .frac-heading-card-wrap {
2976
+ display: flex;
2977
+ align-items: center;
2978
+ margin-bottom:12px;
2979
+ }
2980
+ .frac-backarrow {
2981
+ margin-right: 10px;
2982
+ }
2983
+ .frac-charge-payment-back-btn-wrap , .frac-tab-2{
2984
+ display: none;
2985
+ }
2986
+ .frac-pay-conatiner-one{
2987
+ display: flex;
2988
+ flex-direction: column;
2989
+ justify-content: space-between;
2990
+ min-height: auto;
2991
+ }
2992
+
2993
+ .frac-form .saveachlabel {
2994
+ margin-bottom : 0px !important;
2995
+ }
2996
+
2997
+ .frac-partial-payment-input{
2998
+ margin-top: 12px !important;
2999
+ }
3000
+
3001
+ .challengeUrlclass-frac{
3002
+ height : 90vh;
3003
+ width : 100%;
3004
+ border-radius : 8px;
3005
+ border : none;
3006
+ }
3007
+
3008
+
3009
+
3010
+
3011
+
3012
+ `)}import s,{useCallback as Fr,useEffect as Zi,useRef as ta,useState as ut}from"react";import bn from"axios";import hi from"sweetalert2";import{useEffect as vr,useRef as Cr}from"react";function xa({challengeUrl:e,fractalToken:h,stripeIntentId:q,onSuccess:$,onError:N,containerRef:I}){let z=Cr(null);return vr(()=>{if(!e||typeof window=="undefined")return;let ie=I.current;if(!ie)return;z.current&&ie.contains(z.current)&&ie.removeChild(z.current);let ge=document.createElement("iframe");ge.className="challengeUrlclass-frac",ge.src=e,z.current=ge,ie.appendChild(ge);let Q=L=>{var Z;((Z=L.data)==null?void 0:Z.type)==="3ds-authentication-challenge-complete"&&(ie.innerHTML="",L.data.status==="succeeded"?$(h,q):N(L.data.status))};return window.addEventListener("message",Q),()=>{window.removeEventListener("message",Q),z.current&&ie.contains(z.current)&&ie.removeChild(z.current)}},[e,I,h,q,$,N]),null}import{Elements as Sr}from"@stripe/react-stripe-js";import{loadStripe as _r}from"@stripe/stripe-js";import{PaymentElement as va,useElements as wr,useStripe as Nr}from"@stripe/react-stripe-js";import kr from"axios";import{useState as Ca}from"react";var wa=({onSuccess:e,showLoader:h,setError:q,session_token:$,callback:N,hideLoader:I,handleClose:z,amount:ie,isPreAuth:ge})=>{var E;let Q=Nr(),L=wr(),[Z,ae]=Ca(!1),[w,v]=Ca(null);return React.createElement("form",{onSubmit:async y=>{var Pe,C,Ae,$e,pe,Ve,rt;if(y.preventDefault(),!Q||!L){console.warn("stripe nopt loaded");return}console.log("Stripe:",Q),console.log("Elements:",L),console.log("PaymentElement:",L.getElement(va)),h(),ae(!0);try{let{error:Ce,paymentIntent:Xe}=await Q.confirmPayment({elements:L,confirmParams:{},redirect:"if_required"});if(ae(!1),Ce)console.log(Ce,"paymentIntent error"),q(Ce.message||"Payment failed.");else if((Xe==null?void 0:Xe.status)==="succeeded"){if(v("\u2705 Payment successful!"),e){console.log(Xe,"paymentIntent");try{let fe=await kr.post(`${Le}api/v1/gateway/secure-charge/${$}`,{stripe_id:Xe==null?void 0:Xe.id});if(console.log(fe,"chargeDetails"),(Pe=fe==null?void 0:fe.data)!=null&&Pe.result){let nt=(C=fe==null?void 0:fe.data)==null?void 0:C.data;console.log(nt,"callbackdata"),N(M(k({},nt),{isPreAuth:ge})),z(),I()}console.log((Ae=fe==null?void 0:fe.data)==null?void 0:Ae.data,"chargeDetails")}catch(fe){console.log(fe==null?void 0:fe.response,"error"),q(((pe=($e=fe==null?void 0:fe.response)==null?void 0:$e.data)==null?void 0:pe.message)||"Something went wrong"),I()}}setTimeout(()=>window.close(),1500)}else v("Processing payment...")}catch(Ce){console.log(Ce==null?void 0:Ce.response,"error"),q(((rt=(Ve=Ce==null?void 0:Ce.response)==null?void 0:Ve.data)==null?void 0:rt.message)||"Something went wrong"),I()}}},React.createElement(va,null),React.createElement("button",{className:"pay-button",disabled:Z||!Q},Z?"Processing...":`${Se((E=Number(ie))==null?void 0:E.toFixed(2))}`))};var Pr=_r(ii);function ea({clientSecret:e,onSuccess:h,showLoader:q,setError:$,session_token:N,callback:I,hideLoader:z,handleClose:ie,amount:ge,isPreAuth:Q}){return e?React.createElement(Sr,{stripe:Pr,options:{clientSecret:e}},React.createElement(wa,{onSuccess:h,showLoader:q,hideLoader:z,setError:$,session_token:N,callback:I,handleClose:ie,amount:ge,isPreAuth:Q})):null}import{IoArrowBack as na}from"react-icons/io5";import{NumericFormat as Mr}from"react-number-format";var Lr=({amount:e,bankAmount:h,submitBtnText:q="Pay",session_token:$,customerId:N,callback:I,merchantName:z="merchant",isPreAuth:ie,surcharge:ge="0",submitBtnClass:Q,submitBtnIcon:L,isRequest:Z,pass_fee:ae,pass_fee_amount:w,require3ds:v=!1,autoTrigger:R=!1,show:E,setShow:y,setHandleCloseRef:Pe,isPartial:C,bankSurcharge:Ae,partialRef:$e,loadingPrev:pe=!1,orderGuid:Ve,remainingAmount:rt})=>{var st,se,an,kn,Sn,Yn,Wt,ei,_n,yn,Li,Ai,Wi,zi,Jn,bi;let Ce=ta(!1),Xe=ta(!1),fe=ta(null),[nt,Ee]=ut("card"),[pn,Y]=ut("card"),[p,u]=ut(),[A,re]=ut({}),[o,a]=ut(),[i,b]=ut({}),[P,g]=ut(!1),[W,x]=ut(!1),[S,F]=ut(""),[Ke,Ye]=ut(!1),[gt,Yt]=ut(""),[Ct,wt]=ut(!1),[he,ce]=ut(!1),[H,ze]=ut([]),[Ie,oe]=ut([]),[pt,mt]=ut(),[Pt,B]=ut(Number(e)),[Ht,vt]=ut("form"),[He,It]=ut("form"),[sn,Wn]=ut(!1),[Zt,Nn]=ut(0),[U,K]=ut(""),[Ze,Bt]=ut(null),[Fe,Lt]=ut(!1),[Tt,qt]=ut(!1),[Nt,jt]=ut(null),[Gt,Je]=ut(!1),[Ut,ln]=ut(Ve||null),[yt,dn]=ut(""),[Xt,tn]=ut(""),[fn,hn]=ut(""),Fn=D+"widget/mc-img.svg",Ot=D+"widget/visa-img.svg",Be=D+"widget/ae-img.svg",De=D+"widget/discover-img.svg",xn=D+"widget/card.svg",vn=D+"widget/Trash.svg",kt=D+"widget/bank.svg",_=D+"widget/secure-img.png",f=D+"widget/pov-by.png",de=D+"widget/pax.svg",ct=D+"widget/cardicon.svg",ee=D+"widget/bankicon.svg",We=()=>wt(!0),ye=()=>wt(!1),$t=(r,d)=>{let J=(parseFloat(d)||0)/100,le=r/(1+J);return Math.round(le*100)/100},Ft=async r=>{var d,J,le,X,te,Ge,lt,dt,me,ke,V,Qe,At,Vt,et,Hn,jn,On;try{let Ue={pass_fee_amount:Number(e)-Pt,pass_fee:ae,Token:r==null?void 0:r.Token,amount:yt||e,postal_code:r==null?void 0:r.postalCode,require3ds:v,isPartial:C,orderGuid:Ut||Ve};v&&(r!=null&&r.stripe_3ds_auth_id)&&(Ue.stripe_3ds_auth_id=r==null?void 0:r.stripe_3ds_auth_id);let en=await bn.post(`${Le}api/v1/gateway/charge/${$}`,Ue);if((d=en==null?void 0:en.data)!=null&&d.result){let zt;if(W&&N)try{let Oe={postal_code:p==null?void 0:p.zipCode,customer_id:N,gateway_token:(r==null?void 0:r.gateway_token)||(r==null?void 0:r.Token)};zt=await bn.post(`${Le}api/v1/gateway/add-card/${$}`,Oe),(J=zt==null?void 0:zt.data)!=null&&J.result&&(zt=(le=zt==null?void 0:zt.data)==null?void 0:le.data)}catch(Oe){console.log(Oe,"error"),ye(),I({error:((te=(X=Oe==null?void 0:Oe.response)==null?void 0:X.data)==null?void 0:te.message)||"Something went wrong!",result:(lt=(Ge=Oe==null?void 0:Oe.response)==null?void 0:Ge.data)==null?void 0:lt.result,statusCode:(dt=Oe==null?void 0:Oe.response)==null?void 0:dt.status}),F(((ke=(me=Oe==null?void 0:Oe.response)==null?void 0:me.data)==null?void 0:ke.message)||"Something went wrong!")}let Vn={cardDetails:k(k({},zt),r),callback:M(k({},(V=en==null?void 0:en.data)==null?void 0:V.data),{name:p==null?void 0:p.cardName,isPreAuth:ie})};W||delete Vn.cardDetails,I(Vn),ye(),it()}}catch(Ue){F(((At=(Qe=Ue==null?void 0:Ue.response)==null?void 0:Qe.data)==null?void 0:At.message)||"Something went wrong!"),I({error:((et=(Vt=Ue==null?void 0:Ue.response)==null?void 0:Vt.data)==null?void 0:et.message)||"Something went wrong!",result:(jn=(Hn=Ue==null?void 0:Ue.response)==null?void 0:Hn.data)==null?void 0:jn.result,statusCode:(On=Ue==null?void 0:Ue.response)==null?void 0:On.status}),ye()}},be=async r=>{var d,J,le,X,te,Ge,lt,dt,me,ke,V,Qe,At,Vt,et,Hn,jn,On;try{let Ue={Token:r==null?void 0:r.Token,amount:e,postal_code:r==null?void 0:r.postalCode},en=await bn.post(`${Le}api/v1/gateway/preauth/${$}`,Ue);if((d=en==null?void 0:en.data)!=null&&d.result){let zt;if(W&&N)try{let Oe={postal_code:p==null?void 0:p.zipCode,customer_id:N,gateway_token:(r==null?void 0:r.Token)||(r==null?void 0:r.gateway_token)};zt=await bn.post(`${Le}api/v1/gateway/add-card/${$}`,Oe),(J=zt==null?void 0:zt.data)!=null&&J.result&&(zt=(le=zt==null?void 0:zt.data)==null?void 0:le.data)}catch(Oe){console.log(Oe,"error"),ye(),F(((te=(X=Oe==null?void 0:Oe.response)==null?void 0:X.data)==null?void 0:te.message)||"Something went wrong!"),I({error:((lt=(Ge=Oe==null?void 0:Oe.response)==null?void 0:Ge.data)==null?void 0:lt.message)||"Something went wrong!",result:(me=(dt=Oe==null?void 0:Oe.response)==null?void 0:dt.data)==null?void 0:me.result,statusCode:(ke=Oe==null?void 0:Oe.response)==null?void 0:ke.status})}let Vn={cardDetails:k(k({},zt),r),callback:M(k({},(V=en==null?void 0:en.data)==null?void 0:V.data),{name:p==null?void 0:p.cardName,isPreAuth:ie})};W||delete Vn.cardDetails,I(Vn),ye(),it()}}catch(Ue){F(((At=(Qe=Ue==null?void 0:Ue.response)==null?void 0:Qe.data)==null?void 0:At.message)||"Something went wrong!"),I({error:((et=(Vt=Ue==null?void 0:Ue.response)==null?void 0:Vt.data)==null?void 0:et.message)||"Something went wrong!",result:(jn=(Hn=Ue==null?void 0:Ue.response)==null?void 0:Hn.data)==null?void 0:jn.result,statusCode:(On=Ue==null?void 0:Ue.response)==null?void 0:On.status}),ye()}},Dt=async r=>{var d,J,le,X,te,Ge,lt,dt,me;if(r.Error)F(r.Error),I({error:r.Error||"Something went wrong!"}),ye();else{let ke={token:r.Token,resp:r};try{let V=await bn.post(`${Le}api/v1/gateway/update/token/${$}`,ke);if((V==null?void 0:V.status)==200){let Qe={Token:(J=(d=V==null?void 0:V.data)==null?void 0:d.data)==null?void 0:J.gateway_token,Brand:r.Brand,ExpirationMonth:r.ExpirationMonth,ExpirationYear:r.ExpirationYear,Last4:r.Last4,Bin:r.Bin,CVV:r.CVV,postalCode:p==null?void 0:p.zipCode},At;ie?be(Qe):Ft(Qe)}}catch(V){console.log(V,"error"),ye(),F(((X=(le=V==null?void 0:V.response)==null?void 0:le.data)==null?void 0:X.message)||"Something went wrong!"),I({error:((Ge=(te=V==null?void 0:V.response)==null?void 0:te.data)==null?void 0:Ge.message)||"Something went wrong!",result:(dt=(lt=V==null?void 0:V.response)==null?void 0:lt.data)==null?void 0:dt.result,statusCode:(me=V==null?void 0:V.response)==null?void 0:me.status})}}},c=r=>{Ee(r)},m=()=>{var J,le,X,te,Ge,lt,dt,me;let r={},d=o;return(J=d==null?void 0:d.name)!=null&&J.trim()||(r.name="Name is required"),(le=d==null?void 0:d.accountNumber)!=null&&le.trim()||(r.accountNumber="Account number is required"),(X=d==null?void 0:d.accountNumber)!=null&&X.trim()&&((te=d==null?void 0:d.accountNumber)==null?void 0:te.trim())!==((Ge=d==null?void 0:d.confirmAccountNumber)==null?void 0:Ge.trim())&&(r.confirmAccountNumber="Account numbers must match"),(lt=d==null?void 0:d.bankName)!=null&&lt.trim()||(r.bankName="Bank name is required"),(dt=d==null?void 0:d.routingNumber)!=null&&dt.trim()||(r.routingNumber="Routing Number is required"),d!=null&&d.routingNumber&&((me=d==null?void 0:d.routingNumber)==null?void 0:me.length)!==9&&(r.routingNumber="Routing number must be 9 digits"),((d==null?void 0:d.accountType)==="business saving"||(d==null?void 0:d.accountType)==="business checking")&&(!(d!=null&&d.companyName)||(d==null?void 0:d.companyName)==="")&&(r.companyName="Company Name is required for business accounts"),b(r),Object.keys(r).length>0},G=async(r,d)=>{var J,le,X,te,Ge,lt,dt,me;try{let ke=r,V=await bn.post(`${Le}api/v1/gateway/verify-and-save/${$}`,{token:ke,require3ds:v,pass_fee:ae});if((V==null?void 0:V.status)==200){let Qe=(J=V==null?void 0:V.data)==null?void 0:J.data,At={Token:Qe.gateway_token,Brand:Qe.card_data.brand,ExpirationMonth:Qe.card_data.expire_mm,ExpirationYear:Qe.card_data.expire_yy,Last4:Qe.card_data.last4,Bin:Qe.card_data.bin,postalCode:p==null?void 0:p.zipCode,stripe_3ds_auth_id:d};ie?be(At):Ft(At)}}catch(ke){console.log(ke,"error"),F(((X=(le=ke==null?void 0:ke.response)==null?void 0:le.data)==null?void 0:X.message)||"Something went wrong!"),I({error:((Ge=(te=ke==null?void 0:ke.response)==null?void 0:te.data)==null?void 0:Ge.message)||"Something went wrong!",result:(dt=(lt=ke==null?void 0:ke.response)==null?void 0:lt.data)==null?void 0:dt.result,statusCode:(me=ke==null?void 0:ke.response)==null?void 0:me.status}),ye()}},we=async()=>{var r,d,J,le,X,te,Ge,lt,dt,me,ke,V,Qe,At,Vt,et,Hn,jn,On,Ue,en,zt,Vn,Oe,xi,St,vi,Ii,ti,Jt,Me,Ci;try{let rn={method:"POST",redirect:"follow"},Ln=await bn.post(`${Le}api/v1/widget/generate-session`,rn),si=Number(p==null?void 0:p.expiryYear)%100,aa=`${(r=p==null?void 0:p.cardNumber)==null?void 0:r.replace(/\s+/g,"")}=${si}${p==null?void 0:p.expiryMonth} ${p==null?void 0:p.cvv}`,li=forge.pki.publicKeyFromPem((J=(d=Ln==null?void 0:Ln.data)==null?void 0:d.data)==null?void 0:J.publicKeyPem).encrypt(aa,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ka=forge.util.encode64(li),Sa={"Content-Type":"application/json","x-app-session-key":(X=(le=Ln.data)==null?void 0:le.data)==null?void 0:X.session_key},ra={enc_track2_data:ka,algorithm:"RSAES_OAEP_SHA_1",session_key:(Ge=(te=Ln==null?void 0:Ln.data)==null?void 0:te.data)==null?void 0:Ge.session_key};if(v&&typeof window!="undefined"&&typeof navigator!="undefined"){let on=(lt=navigator.languages)!=null?lt:[navigator.language],oa=Array.isArray(on)?on[0]:on;ra.three_ds_data={amount:Math.round(yt?parseFloat(yt)*100:parseFloat(e)*100),currency:"usd",channel:{type:"browser",browser:{language:typeof oa=="string"?oa:null,color_depth:(me=(dt=window.screen)==null?void 0:dt.colorDepth)!=null?me:null,java_enabled:typeof navigator.javaEnabled=="function"?navigator.javaEnabled():!1,screen_height:(V=(ke=window.screen)==null?void 0:ke.height)!=null?V:null,screen_width:(At=(Qe=window.screen)==null?void 0:Qe.width)!=null?At:null,timezoneOffset:new Date().getTimezoneOffset()}}}}let _a=JSON.stringify(ra),wn=await bn.post(`${cn}tokenizer/tokenize`,_a,{headers:Sa});if((wn==null?void 0:wn.status)==200){let on=(et=(Vt=wn==null?void 0:wn.data)==null?void 0:Vt.data)==null?void 0:et.stripe_three_ds_response;v&&!on&&on.status==="200 OK"&&((Hn=on==null?void 0:on.data)!=null&&Hn.challenge_url)&&F("Something went wrong. Please try again later."),v?(jn=on==null?void 0:on.data)!=null&&jn.challenge_url?(ye(),jt(M(k({},on==null?void 0:on.data),{fractalToken:(Vn=(zt=wn==null?void 0:wn.data)==null?void 0:zt.data)==null?void 0:Vn.token}))):G((Ue=(On=wn==null?void 0:wn.data)==null?void 0:On.data)==null?void 0:Ue.token,(en=on==null?void 0:on.data)==null?void 0:en.id):G((xi=(Oe=wn==null?void 0:wn.data)==null?void 0:Oe.data)==null?void 0:xi.token,null)}}catch(rn){ye(),console.log(rn,"error");let Ln="Something went wrong!";try{let si=((St=rn==null?void 0:rn.response)==null?void 0:St.data)||(rn==null?void 0:rn.message)||"",Bi=typeof si=="string"?si:JSON.stringify(si),wi=(((Ii=(vi=Bi.split)==null?void 0:vi.call(Bi,`
3013
+ `))==null?void 0:Ii.filter(Boolean))||[]).at(-1)||"",li=(ti=wi.split)==null?void 0:ti.call(wi,": ");Ln=(li==null?void 0:li.length)>1?li.pop().trim():wi.trim()||Ln}catch(si){Ln="Something went wrong!"}F(Ln),I({error:Ln,result:(Me=(Jt=rn==null?void 0:rn.response)==null?void 0:Jt.data)==null?void 0:Me.result,statusCode:(Ci=rn==null?void 0:rn.response)==null?void 0:Ci.status})}},ne=()=>{var X,te,Ge,lt,dt,me;let r={},d=p,J=parseInt((d==null?void 0:d.expiryMonth)||"",10),le=(d==null?void 0:d.expiryYear)||"";if((X=d==null?void 0:d.cardName)!=null&&X.trim()||(r.cardName="Card name is required"),(te=d==null?void 0:d.cardNumber)!=null&&te.trim()||(r.cardNumber="Card number is required"),(!((Ge=d==null?void 0:d.expiryMonth)!=null&&Ge.trim())||!((lt=d==null?void 0:d.expiryYear)!=null&&lt.trim())||isNaN(J)||J<1||J>12||le.length!==4)&&(r.expiryMonth="Invalid Expiration Date."),(dt=d==null?void 0:d.cvv)!=null&&dt.trim()||(r.cvv="CVV is required"),(me=d==null?void 0:d.zipCode)!=null&&me.trim()||(r.zipCode="ZIP code is required"),d!=null&&d.expiryMonth&&(d!=null&&d.expiryYear)&&d.expiryMonth.length<=2&&d.expiryYear.length===4){let ke=parseInt(d.expiryMonth,10),V=parseInt(d.expiryYear,10),Qe=new Date,At=Qe.getMonth()+1,Vt=Qe.getFullYear();(V<Vt||V===Vt&&ke<At)&&(r.expiryMonth="Card is expired")}return re(r),Object.keys(r).length>0},ft=()=>{let r=DatacapWebToken.validateCardNumber(p==null?void 0:p.cardNumber.replaceAll(" ","")),d=DatacapWebToken.validateExpirationDate(p==null?void 0:p.expiryMonth,p==null?void 0:p.expiryYear),J=DatacapWebToken.validateCVV(p==null?void 0:p.cvv),le={};return r||(le.cardNumber="Invalid card Number"),d||(le.expiryMonth="Invalid Expiration Date."),J||(le.cvv="Invalid CVV"),re(le),r&&J&&d},bt=async r=>{var d,J,le,X,te,Ge,lt,dt,me,ke,V,Qe,At,Vt,et,Hn,jn,On,Ue,en,zt,Vn,Oe,xi;if(r.preventDefault(),!Xt){if(nt!=="ach"){if(ne()||!ft())return}else if(m())return;try{We();let St=await bn.get(`${Le}api/v1/gateway/token/${$}`,{params:{require3ds:v,pass_fee:ae}});if((St==null?void 0:St.status)==200){let vi=(J=(d=St==null?void 0:St.data)==null?void 0:d.data)==null?void 0:J.gateway_token,Ii=(X=(le=St==null?void 0:St.data)==null?void 0:le.data)==null?void 0:X.paymentGateway;if(nt!=="ach")Ii==((te=Vi)==null?void 0:te.FRACTALKEY)?await we():DatacapWebToken.requestToken(vi,"PaymentForm",Dt);else{let ti;try{let Jt=await bn.post(`${Le}api/v1/gateway/bank-charge/${$}`,{label:o==null?void 0:o.name,account_number:o==null?void 0:o.accountNumber,routing_number:o==null?void 0:o.routingNumber,bank_name:o==null?void 0:o.bankName,account_type:o==null?void 0:o.accountType,amount:`${h}`,customer_id:null,isSaveAch:!1,tax:"0.00",discount:"0.00",surcharge:"0.00",order_id:"",company_name:(o==null?void 0:o.companyName)||""});if((Ge=Jt==null?void 0:Jt.data)!=null&&Ge.result){if(P&&N)try{let Me=await bn.post(`${Le}api/v1/gateway/add-bank/${$}`,{name:o==null?void 0:o.name,account_number:o==null?void 0:o.accountNumber,routing_number:o==null?void 0:o.routingNumber,bank_name:o==null?void 0:o.bankName,account_type:o==null?void 0:o.accountType,customer_id:N||"",company_name:(o==null?void 0:o.companyName)||""});Me.data.result&&(ti={bankDetails:M(k({},(lt=Me==null?void 0:Me.data)==null?void 0:lt.data),{account_type:o==null?void 0:o.accountType})})}catch(Me){ye(),F(((me=(dt=Me==null?void 0:Me.response)==null?void 0:dt.data)==null?void 0:me.message)||"Something went wrong!"),I({error:((V=(ke=Me==null?void 0:Me.response)==null?void 0:ke.data)==null?void 0:V.message)||"Something went wrong!",result:(At=(Qe=Me==null?void 0:Me.response)==null?void 0:Qe.data)==null?void 0:At.result,statusCode:(Vt=Me==null?void 0:Me.response)==null?void 0:Vt.status})}ti=M(k({},ti),{callback:M(k({},(et=Jt==null?void 0:Jt.data)==null?void 0:et.data),{name:o==null?void 0:o.name,isPreAuth:ie})}),I(ti),it(),ye()}}catch(Jt){console.log(Jt,"errororor");let Me=(Hn=Jt==null?void 0:Jt.response)==null?void 0:Hn.data;typeof(Me==null?void 0:Me.message)=="object"?Object.values(Me==null?void 0:Me.message).forEach(Ci=>{var rn;F(Ci||"Something went wrong"),I({error:Ci||"Something went wrong!",result:(Me==null?void 0:Me.result)||!1,statusCode:(rn=Jt==null?void 0:Jt.response)==null?void 0:rn.status})}):(F((Me==null?void 0:Me.message)||"Something went wrong"),I({error:(Me==null?void 0:Me.message)||"Something went wrong!",result:(Me==null?void 0:Me.result)||!1,statusCode:(jn=Jt==null?void 0:Jt.response)==null?void 0:jn.status})),ye()}}}}catch(St){ye(),I({error:((Ue=(On=St==null?void 0:St.response)==null?void 0:On.data)==null?void 0:Ue.message)||"Something went wrong!",result:(zt=(en=St==null?void 0:St.response)==null?void 0:en.data)==null?void 0:zt.result,statusCode:(Vn=St==null?void 0:St.response)==null?void 0:Vn.status}),F(((xi=(Oe=St==null?void 0:St.response)==null?void 0:Oe.data)==null?void 0:xi.message)||"Something went wrong!")}}},xe=(r,d)=>{let J=r;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(J)){(d===""||/^[0-9]+$/.test(d))&&(re(X=>M(k({},X),{[J]:""})),u(X=>M(k({},X),{[J]:d})));return}re(X=>M(k({},X),{[J]:""})),u(X=>M(k({},X),{[J]:d}))},ue=r=>{var te;let d=r.target,J=d.value.replace(/\D/g,""),{formatted:le,cursor:X}=Bn(d.value,(te=d.selectionStart)!=null?te:0);re(Ge=>M(k({},Ge),{cardNumber:""})),u(Ge=>M(k({},Ge),{cardNumber:le})),requestAnimationFrame(()=>{d.setSelectionRange(X,X)})},Re=r=>{let{name:d,value:J}=r.target,le=["routingNumber","accountNumber","confirmAccountNumber"];if(d=="name"){/^[a-zA-Z\s]*$/.test(J)&&(b(X=>M(k({},X),{[d]:""})),a(X=>M(k({},X),{[d]:J})));return}if(le.includes(d)){(J===""||/^[0-9]+$/.test(J))&&(b(X=>M(k({},X),{[d]:""})),a(X=>M(k({},X),{[d]:J})));return}b(X=>M(k({},X),{[d]:""})),a(X=>M(k({},X),{[d]:J}))},it=()=>{y(!1),Ee("card"),F(""),Ye(!1),Yt(""),a({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),b({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),u({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),re({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),g(!1),x(!1),It("form"),vt("form"),Wn(!1),Nn(0),B(0),ze([]),Bt(null),K(null),Lt(!1),qt(!1),jt(null),ln(null),dn(""),tn(""),hn("")},Ne=async()=>{var r,d,J,le,X,te,Ge,lt,dt;We();try{let me={isPreAuth:ie,customerId:N},ke=await bn.post(`${Le}api/v1/gateway/card-list/${$}`,me),V=((d=(r=ke==null?void 0:ke.data)==null?void 0:r.data)==null?void 0:d.cardList)||[],Qe=V==null?void 0:V.filter(Vt=>(Vt==null?void 0:Vt.card_type)=="Bank"),At=V==null?void 0:V.filter(Vt=>(Vt==null?void 0:Vt.card_type)!=="Bank");At&&(At==null?void 0:At.length)>0?(Ee("card"),vt("list"),ze(At)):(Ee("card"),ze([])),Qe&&(Qe==null?void 0:Qe.length)>0?(It("list"),oe(Qe)):oe([]),ye()}catch(me){console.log(me),ye(),I({error:((le=(J=me==null?void 0:me.response)==null?void 0:J.data)==null?void 0:le.message)||"Something went wrong!",result:(te=(X=me==null?void 0:me.response)==null?void 0:X.data)==null?void 0:te.result,statusCode:(Ge=me==null?void 0:me.response)==null?void 0:Ge.status}),F(((dt=(lt=me==null?void 0:me.response)==null?void 0:lt.data)==null?void 0:dt.message)||(me==null?void 0:me.message)||"Something went wrong")}},at=r=>{switch(r==null?void 0:r.toLowerCase()){case"visa":return Ot;case"mastercard":case"mc":case"m/c":return Fn;case"amex":case"american express":case"ae":return Be;case"discover":case"dcvr":return De;case"bank":return kt;default:return r}},ve=async r=>{hi.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 d=>{var J,le;if(d.isConfirmed){ce(!0);try{let X={card_id:r,customer_id:N},te=await bn.patch(`${Le}api/v1/gateway/delete-card/${$}`,X);(J=te==null?void 0:te.data)!=null&&J.result?(ce(!1),Ne(),hi.fire({icon:"success",title:"Deleted!",text:((le=te==null?void 0:te.data)==null?void 0:le.message)||"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})):(ce(!1),hi.fire({icon:"error",title:"Failure!",text:"Card not deleted.",timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}}))}catch(X){ce(!1),hi.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else d.dismiss===hi.DismissReason.cancel&&hi.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},xt=async()=>{var le,X,te,Ge,lt,dt,me,ke,V;let r=N,d=pt==null?void 0:pt.id,J=pt==null?void 0:pt.card_type;if(!Xt)if(e)if(r)if(d){let Qe={amount:(J==null?void 0:J.toLowerCase())==="bank"?`${h}`:yt||e,customer_id:r,card_id:d,pass_fee:ae,pass_fee_amount:Number(e)-Pt};C&&(Qe.orderGuid=Ut||Ve,yt&&(Qe.ispartialPayment=!0)),ie&&(Qe.isPreauth=!0);let At=Le+"api/v1/gateway/charge-by-saved-details/"+$,Vt={"Content-Type":"application/json"};try{We();let et=await bn.post(At,Qe);(le=et==null?void 0:et.data)!=null&&le.result&&(I({callback:M(k({},(X=et==null?void 0:et.data)==null?void 0:X.data),{isPreAuth:ie})}),ye(),it())}catch(et){console.log(et==null?void 0:et.response,"error by saved details"),I({error:((Ge=(te=et==null?void 0:et.response)==null?void 0:te.data)==null?void 0:Ge.message)||"Something went wrong!",result:(dt=(lt=et==null?void 0:et.response)==null?void 0:lt.data)==null?void 0:dt.result,statusCode:(me=et==null?void 0:et.response)==null?void 0:me.status}),ye(),F(((V=(ke=et==null?void 0:et.response)==null?void 0:ke.data)==null?void 0:V.message)||"Something went wrong!")}}else F("Please Select A Card/Bank"),I({error:"Please Select A Card/Bank"});else F("Please Select Customer"),I({error:"Please Select Customer"});else F("Something went wrong."),I({error:"Something went wrong."})},ot=async()=>{var r,d,J,le,X,te,Ge,lt,dt,me,ke;try{We();let V=await bn.get(`${Le}api/v1/gateway/get-payment-details/${$}`);(V==null?void 0:V.status)==200&&(Wn((d=(r=V==null?void 0:V.data)==null?void 0:r.data)==null?void 0:d.isBankActive),Nn(Number((le=(J=V==null?void 0:V.data)==null?void 0:J.data)==null?void 0:le.fee)||0),ye())}catch(V){console.log((te=(X=V==null?void 0:V.response)==null?void 0:X.data)==null?void 0:te.result,"error while getting payment details"),I({error:((lt=(Ge=V==null?void 0:V.response)==null?void 0:Ge.data)==null?void 0:lt.message)||"Something went wrong!",result:(me=(dt=V==null?void 0:V.response)==null?void 0:dt.data)==null?void 0:me.result,statusCode:(ke=V==null?void 0:V.response)==null?void 0:ke.status}),ye()}},Rt=async()=>{var r,d,J,le,X;if(!Gt){Je(!0);try{let te=await bn.post(`${Le}api/v1/gateway/create-pay-order/${$}`,{amount:e,cashDiscount:Pt,bankAmount:h,bankSurcharge:Ae,customerId:N,passFee:ae,passFeeAmount:w||Number(e)-Pt,require3ds:v,isPartial:C});(r=te==null?void 0:te.data)!=null&&r.result&&(Je(!1),ln((J=(d=te==null?void 0:te.data)==null?void 0:d.data)==null?void 0:J.orderGuid),hn((X=(le=te==null?void 0:te.data)==null?void 0:le.data)==null?void 0:X.remainingAmount),Ce.current=!0)}catch(te){console.log("error in creating order",te),Je(!1)}}};Zi(()=>{!E&&!R&&(Ce.current=!1,Xe.current=!1)},[E,R]),Zi(()=>{!Ce.current&&(E||R)&&(ot(),C&&!$e&&Rt())},[E,R,C]),console.log(Ce,"hasRunRef",E,"show",C,"isPartial",fn,"remainingAmount",rt,"remAmount"),Zi(()=>{if((E||R)&&w){let r=Number(e)-Number(w);r&&!isNaN(r)&&B(r)}else if((E||R)&&ae&&Zt){let r=$t(e,Zt);r&&!isNaN(r)&&B(r)}else B(Number(e));!Xe.current&&N&&(E||R)&&!Z&&(Xe.current=!0,Ne())},[N,E,e,Zt,R]);let ht=()=>ie?"Cards":"Cards/Bank",je=Fr(async()=>{try{Lt(!0);let d=await(await fetch(`${Le}api/v1/gateway/create-payment-intent/${$}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e,require3ds:v,pass_fee:ae})})).json();d.is3dEnable?(Lt(!1),K(d.clientSecret),qt(d.is3dEnable)):(Lt(!1),qt(d.is3dEnable)),d.result||F(d.error||(d==null?void 0:d.message)||"Failed to get client secret")}catch(r){console.log(r.response,"err.response"),F(r.message)}},[e]),$n=()=>{},Mn=(r,d)=>{We(),G(r,d),jt(null)},Cn=r=>{console.error("3DS Auth failed \u274C",r),F(`3DS Authentication ${r}`)};Zi(()=>{Pe&&Pe(()=>it)},[]);let nn=r=>{var d,J;((d=Number(fn||rt))==null?void 0:d.toFixed(2))<(r==null?void 0:r.floatValue)||(r==null?void 0:r.floatValue)<=0?(dn(r==null?void 0:r.value),tn(`Partial amount cannot exceed ${Se((J=Number(fn||rt))==null?void 0:J.toFixed(2))}`)):(dn(r==null?void 0:r.value),tn(""))};return s.createElement(s.Fragment,null,Fe&&s.createElement(mn,{loading:Fe}),S&&s.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},s.createElement(Tn,{error:S,onClose:it})),!S&&s.createElement(s.Fragment,null,(Ct||he)&&s.createElement(mn,{loading:Ct||he||pe||Gt}),s.createElement("div",{className:"frac-card-payment-page frac-form frac-new-form"},s.createElement("div",{ref:fe,style:{width:"100%",height:"100%"}}),Nt!=null&&Nt.challenge_url?s.createElement(xa,{containerRef:fe,challengeUrl:Nt.challenge_url,fractalToken:Nt.fractalToken,stripeIntentId:Nt.id,onSuccess:Mn,onError:Cn}):s.createElement("div",{className:"parent-pay-container"},s.createElement("span",{style:{display:R?"none":"block"},className:"request-payment-close-popup",onClick:it},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12425_52336)"},s.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12425_52336"},s.createElement("rect",{width:"16",height:"16",fill:"white"}))))),s.createElement("div",{className:"pay-main-logo-res"}),s.createElement("div",{className:"pay-container"},s.createElement("div",{className:"pay-header pay-conatiner-one"},s.createElement("div",{className:"pay-conatiner-one-first"},s.createElement("div",{className:"pay-logo-container"},s.createElement("div",{className:"pay-main-logo"}),s.createElement("h1",{className:"pay-heading"},"Pay"),(H==null?void 0:H.length)>0&&nt!=="cardList"&&s.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>Ee("cardList")}," ",s.createElement(na,null)," Back")),s.createElement("div",{className:"amt-pay-con"},s.createElement("div",{className:"pay-amount-conatiner"},s.createElement("small",{className:"pay-payment-amount"},"Select payment type"),s.createElement("div",{className:"frac-card-bank-radio-main"},s.createElement(In,{label:"Card",amount:(st=Number(e))==null?void 0:st.toFixed(2),value:"card",onChange:c,activetab:nt}),!ie&&sn&&!C&&s.createElement(In,{label:"Bank",amount:(se=Number(h))==null?void 0:se.toFixed(2),value:"ach",onChange:c,activetab:nt})),ae&&nt==="card"&&Pt&&Number(e)-Number(Pt)>0?s.createElement("div",{className:"frac-cash-discount-fee"},s.createElement("small",null,nt==="card"?"Cash Discount":"Cash Discount Savings"," "),s.createElement("p",null,Se((Number(e)-Number(Pt)).toFixed(2)))):null,C&&s.createElement("div",{className:"frac-partial-payment-input"},s.createElement("label",{htmlFor:"partialpayment"},"Partial Payment"),s.createElement(Mr,{prefix:"$",className:"form-control-frac",value:yt,onValueChange:r=>{nn(r)},thousandSeparator:!0,placeholder:"Enter partial amount",allowNegative:!1,allowLeadingZeros:!1,decimalScale:2,fixedDecimalScale:!0}),Xt&&s.createElement("span",{className:"error-span"},Xt))))),s.createElement("div",{className:"pay-conatiner-one-last"},s.createElement("img",{src:_,alt:""}),s.createElement("img",{src:f,alt:""}),"Secure payments powered by Fractal")),s.createElement("div",{className:"pay-tab pay-conatiner-two"},s.createElement("div",{className:"col-md-12"},s.createElement("div",{id:"payment-form-div"},Tt?U&&s.createElement(ea,{onSuccess:$n,clientSecret:U,amount:e,showLoader:We,hideLoader:ye,callback:I,session_token:$,handleClose:it,setError:F,isPreAuth:ie}):s.createElement(s.Fragment,null,s.createElement("div",{id:"ach",style:{display:nt==="card"?"block":"none"},className:"tabcontent"},s.createElement("div",{className:"frac-heading-card-wrap"},s.createElement("div",{className:"frac-backarrow"},(H==null?void 0:H.length)>0&&Ht==="form"&&s.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>vt("list")}," ",s.createElement(na,null))),s.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),s.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},s.createElement("img",{src:Ot,alt:"",width:33}),s.createElement("img",{src:Fn,width:33,alt:""}),s.createElement("img",{src:Be,alt:"",width:33}),s.createElement("img",{src:De,width:33,alt:""})),Ht==="list"&&(H==null?void 0:H.length)>0?s.createElement(s.Fragment,null,s.createElement(En,{headingClass:"card-ach-heading-frac",listHeading:"Card",ListItems:H,selectedCard:pt,setSelectedCard:mt,handleDeleteCard:ve,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{vt("form")}}),s.createElement("div",{className:"form-group-frac",style:{padding:"0"}},s.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:xt},yt?Se((an=Number(yt))==null?void 0:an.toFixed(2)):Se((kn=Number(e))==null?void 0:kn.toFixed(2))))):s.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:bt},s.createElement("div",{className:"ach-scrl",style:{minHeight:"398px",maxHeight:"398px",overflow:"auto",marginRight:"5px"}},s.createElement("div",{className:"form-group-frac"},s.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),s.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"John Doe",value:(p==null?void 0:p.cardName)||"",onChange:r=>{let d=r.target.value;/^[a-zA-Z\s]*$/.test(d)&&xe("cardName",d)}}),(A==null?void 0:A.cardName)&&s.createElement("span",{className:"error-span"},A==null?void 0:A.cardName)),s.createElement("div",{className:"form-group-frac"},s.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),s.createElement("div",{className:"toggle-num-wrapper"},s.createElement("input",{className:"form-control-frac card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(p==null?void 0:p.cardNumber)||"",onChange:r=>ue(r),"data-token":"card_number"}),s.createElement("div",{className:"card-crdi card-expiry-new"},s.createElement("div",{className:"exp-date-year-container"},s.createElement("div",{className:"exp-date form-group-frac"},s.createElement("input",{"data-token":"exp_month",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(p==null?void 0:p.expiryMonth)||"",onChange:r=>xe("expiryMonth",r.target.value)})),s.createElement("div",{className:"exp-year form-group-frac"},s.createElement("input",{"data-token":"exp_year",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(p==null?void 0:p.expiryYear)||"",onChange:r=>xe("expiryYear",r.target.value)})),s.createElement("div",{className:"security-digit form-group-frac"},s.createElement("input",{"data-token":"cvv",className:"form-control-frac card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(p==null?void 0:p.cvv)||"",onChange:r=>xe("cvv",r.target.value)})))),(A==null?void 0:A.cardNumber)&&s.createElement("span",{className:"error-span"},A==null?void 0:A.cardNumber),s.createElement("p",{style:{margin:"0"}},A!=null&&A.expiryMonth||A!=null&&A.expiryYear?s.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},A==null?void 0:A.expiryMonth):"",(A==null?void 0:A.cvv)&&s.createElement("span",{className:"error-span"},A==null?void 0:A.cvv)))),s.createElement("div",{className:"form-group-frac"},s.createElement("label",{htmlFor:"zip"},"ZIP"),s.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"000000",value:(Sn=p==null?void 0:p.zipCode)!=null?Sn:"",onChange:r=>xe("zipCode",r.target.value)}),(A==null?void 0:A.zipCode)&&s.createElement("span",{className:"error-span"},A==null?void 0:A.zipCode)),N&&s.createElement("div",{className:"form-group-frac"},s.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},s.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:W,onChange:r=>x(r.target.checked)}),s.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),s.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),s.createElement("div",{className:"frac-tooltip-wrapper"},s.createElement("div",{className:"frac-tooltip-icon"},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},s.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),s.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"}))),s.createElement("div",{className:"frac-tooltip-text"},s.createElement("p",null,"If checked, I agree to give the ",s.createElement("b",null,z||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),s.createElement("div",{className:"form-group-frac",style:{marginTop:"20px",padding:"0"}},s.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},yt?Se((Yn=Number(yt))==null?void 0:Yn.toFixed(2)):Se((Wt=Number(e))==null?void 0:Wt.toFixed(2)))))),s.createElement("div",{id:"ach",style:{display:nt==="ach"?"block":"none"},className:"tabcontent"},s.createElement(s.Fragment,null,s.createElement("div",{className:"frac-heading-card-wrap"},s.createElement("div",{className:"frac-backarrow"},(Ie==null?void 0:Ie.length)>0&&He==="form"&&s.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>It("list")}," ",s.createElement(na,null))),s.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment")),He==="list"&&(Ie==null?void 0:Ie.length)>0?s.createElement(s.Fragment,null,s.createElement(En,{headingClass:"card-ach-heading-frac",listHeading:"Banks",ListItems:Ie,selectedCard:pt,setSelectedCard:mt,handleDeleteCard:ve,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{It("form")}}),s.createElement("div",{className:"form-group-frac",style:{padding:"0"}},s.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:xt},Se((ei=Number(h))==null?void 0:ei.toFixed(2))))):s.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:bt,autoComplete:"off"},s.createElement("div",{className:"ach-scrl",style:{minHeight:"444px",maxHeight:"444px"}},s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),s.createElement("input",{type:"text",id:"nameonaccount",className:"form-control-frac",maxLength:100,placeholder:"John Doe",name:"name",value:(_n=o==null?void 0:o.name)!=null?_n:"",onChange:Re}),(i==null?void 0:i.name)&&s.createElement("span",{className:"error-span"},i==null?void 0:i.name)),s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"routingnumber"},"Routing number"),s.createElement("input",{type:"text",id:"routingnumber",className:"form-control-frac",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(yn=o==null?void 0:o.routingNumber)!=null?yn:"",onChange:Re}),(i==null?void 0:i.routingNumber)&&s.createElement("span",{className:"error-span"},i==null?void 0:i.routingNumber)),s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"accountnumber"},"Account number"),s.createElement("input",{type:"text",id:"accountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Li=o==null?void 0:o.accountNumber)!=null?Li:"",onChange:Re}),(i==null?void 0:i.accountNumber)&&s.createElement("span",{className:"error-span"},i==null?void 0:i.accountNumber)),s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),s.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(Ai=o==null?void 0:o.confirmAccountNumber)!=null?Ai:"",onChange:Re}),(i==null?void 0:i.confirmAccountNumber)&&s.createElement("span",{className:"error-span"},i==null?void 0:i.confirmAccountNumber)),s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"bankname"},"Bank name"),s.createElement("input",{type:"text",id:"bankname",className:"form-control-frac",maxLength:100,placeholder:"My Bank",name:"bankName",value:(Wi=o==null?void 0:o.bankName)!=null?Wi:"",onChange:Re}),(i==null?void 0:i.bankName)&&s.createElement("span",{className:"error-span"},i==null?void 0:i.bankName)),((o==null?void 0:o.accountType)==="business saving"||(o==null?void 0:o.accountType)==="business checking")&&s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"companyName"},"Company name"),s.createElement("input",{type:"text",id:"companyName",className:"form-control-frac",maxLength:100,placeholder:"My Company",name:"companyName",value:(zi=o==null?void 0:o.companyName)!=null?zi:"",onChange:Re}),(i==null?void 0:i.companyName)&&s.createElement("span",{className:"error-span"},i==null?void 0:i.companyName)),s.createElement("div",{className:"form-group-frac mb-4"},s.createElement("label",{htmlFor:"accounttype"},"Select account type"),s.createElement("select",{name:"accountType",id:"accounttype",className:"form-control-frac",value:(Jn=o==null?void 0:o.accountType)!=null?Jn:"",onChange:Re},s.createElement("option",{value:""},"Select account"),ci.map(r=>s.createElement("option",{key:r.value,value:r.value},r.label)))),N&&s.createElement("div",{className:"form-group-frac mb-4 save-ach-div",style:{paddingTop:"5px"}},s.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:P,onChange:r=>g(r.target.checked)}),s.createElement("label",{className:"saveachlabel",htmlFor:"saveACH"},"Save ACH")),P&&s.createElement("div",{className:"form-group-frac mb-4 saveachtext"},s.createElement("p",null,"If checked, I agree to give the ",s.createElement("b",null,z||"merchant")," permission to charge this bank account for agreed-upon purchases in the future."))),s.createElement("div",{className:"form-group-frac "},s.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Se((bi=Number(h))==null?void 0:bi.toFixed(2))))))))))))))))},ia=Lr;import zr from"axios";var Ir=({amount:e,bankAmount:h,submitBtnText:q="Pay",session_token:$,customerId:N,callback:I,merchantName:z="merchant",isPreAuth:ie,surcharge:ge="0",submitBtnClass:Q,submitBtnIcon:L,isRequest:Z,pass_fee:ae,pass_fee_amount:w,require3ds:v=!1,autoTrigger:R=!1,isPartial:E,bankSurcharge:y,partialRef:Pe})=>{let[C,Ae]=yi(!1),[$e,pe]=yi(!1),[Ve,rt]=yi(()=>()=>{}),[Ce,Xe]=yi(null),[fe,nt]=yi(null),Ee=Ar(()=>({amount:e,bankAmount:h,submitBtnText:q,session_token:$,customerId:N,callback:I,merchantName:z,isPreAuth:ie,surcharge:ge,submitBtnClass:Q,submitBtnIcon:L,isRequest:Z,pass_fee:ae,pass_fee_amount:w,require3ds:v,autoTrigger:R,setShow:Ae,setHandleCloseRef:rt,isPartial:E,bankSurcharge:y,partialRef:Pe}),[e,h,q,$,N,I,z,ie,ge,Q,L,Z,ae,w,v,R,E,y,Pe]),[pn,Y]=yi(Ee);Na(()=>{C&&Y(Ee)},[C,Ee]);let p=async()=>{var u;pe(!0);try{let A=await zr.get(`${Le}api/v1/gateway/get-order-details/${$}`,{params:{isPartial:E,partialRef:Pe}});if((u=A==null?void 0:A.data)!=null&&u.result){let re=A.data.data;re!=null&&re.orderGuid&&(Xe(re==null?void 0:re.orderGuid),nt(re==null?void 0:re.remainingAmount)),Y(o=>M(k({},o),{amount:re.amount,pass_fee_amount:re.pass_fee_amount,pass_fee:re.pass_fee}))}}catch(A){console.log("error while getting skyosorderdeatils",A)}finally{pe(!1)}};return Na(()=>{C&&E&&Pe&&p()},[C,E,Pe]),Zn.createElement(Zn.Fragment,null,Zn.createElement("link",{href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}),Zn.createElement(An,null),Zn.createElement(Ri,null),Zn.createElement(Xn,null),Zn.createElement($i,null),!R&&Zn.createElement("button",{className:Q||"paymentBtn",onClick:()=>Ae(!0)},q,L),R?Zn.createElement(ia,M(k({show:C,loadingPrev:$e},pn),{orderGuid:Ce,remainingAmount:fe})):Zn.createElement(Pn,{open:C,onClose:Ve},Zn.createElement(ia,M(k({show:C,loadingPrev:$e},pn),{orderGuid:Ce,remainingAmount:fe}))))};export{gr as AddCard,fr as CardOnFile,rr as GetPaymentPage,br as PartialPayment,Ir as PaymentWidget,sr as PreAuthPayment,Ga as RequestPayment,Xa as RequestPreAuthPayment};