@fractalpay/fractalpay-next-dev 0.0.106 → 0.0.107
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/PayButtonWithForm-PQCLPHH7.mjs +729 -0
- package/dist/chunk-URJRZDIB.mjs +512 -0
- package/dist/index.d.mts +34 -33
- package/dist/index.d.ts +34 -33
- package/dist/index.js +1693 -1693
- package/dist/index.mjs +13 -1252
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -1,340 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
`),ri=_i;var Si=e=>gn.createElement(gn.Fragment,null,gn.createElement(ri,null),(e==null?void 0:e.loading)&&gn.createElement("div",{className:"loader"},gn.createElement("div",{className:"lds-ellipsis"},gn.createElement("div",null),gn.createElement("div",null),gn.createElement("div",null),gn.createElement("div",null)))),Ot=Si;var{name:zn}=si();console.log(zn,"dgijiisdfhg");var ie="https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/";zn==="@fractalpay/fractalpay-next-dev"?(Pe="https://dev-sky-node.fractalpay.com/",Be="https://dev-widget.fractalpay.com/",Ht="https://api-dev.merchant-trends.com/",xn="https://token-cert.dcap.com/v1/client"):zn==="@fractalpay/fractalpay-next-test"?(Pe="https://testapi.fractalpay.com/",Be="https://staging-widget.fractalpay.com/",Ht="https://api-dev.merchant-trends.com/",xn="https://token-cert.dcap.com/v1/client"):zn==="@fractalpay/fractalpay-next-testprod"?(Pe="https://sky-node-prod.fractalpay.com/",Be="https://widget-prod.fractalpay.com/",Ht="https://api.merchant-trends.com/",xn="https://token.dcap.com/v1/client"):zn==="@fractalpay/fractalpay-next"?(Pe="https://api.fractalpay.com/",Be="https://widget.fractalpay.com/",Ht="https://api.merchant-trends.com/",xn="https://token.dcap.com/v1/client"):(Be="http://localhost:8082/",Pe="http://localhost:8081/",Ht="https://api-dev.merchant-trends.com/",xn="https://token-cert.dcap.com/v1/client");var Pe,Be,Ht,xn;var Lt={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 An from"react";import Pi from"react";var Mi=e=>Pi.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
|
-
`),li=Mi;var Li=({open:e,onClose:C,children:ee,maxWidth:R})=>e?An.createElement(An.Fragment,null,An.createElement(li,null),An.createElement("div",{className:"fractal-popup"},An.createElement("div",{className:"fractal-popup-content request-payment-popup-container",style:{maxWidth:`${R!=null?R:"auto"}`}},ee))):null,Ut=Li;import $i from"axios";import{PatternFormat as Hi}from"react-number-format";import zi from"react";var Ai=e=>zi.createElement("style",null,`
|
|
1
|
+
import{a as M,b as A,c as gn,d as Lt,e as de,f as Yt,g as Se,h as Ut,j as Vt,k as hn,l as Sn,m as pe,n as Jt,o as Xt,p as fn,q as Pn,r as yn,s as Hn}from"./chunk-URJRZDIB.mjs";import Ci from"next/dynamic";import"bootstrap/dist/js/bootstrap.bundle.min.js";import w,{useState as Qt,useEffect as $n}from"react";var lt={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 Qn from"axios";import{PatternFormat as Dn}from"react-number-format";import Jn from"react";var Xn=e=>Jn.createElement("style",null,`
|
|
338
2
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
339
3
|
body {
|
|
340
4
|
font-family: 'Inter', sans-serif !important;
|
|
@@ -647,7 +311,7 @@ var vi=Object.defineProperty,Ci=Object.defineProperties;var Ni=Object.getOwnProp
|
|
|
647
311
|
user-select: none;
|
|
648
312
|
font-size: 14px;
|
|
649
313
|
}
|
|
650
|
-
`),Kn=Ai;var Sn=e=>{try{let C=JSON.parse(e);return typeof C=="object"&&C!==null}catch(C){return!1}},Fn=[{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 Ce(e){let C=Number(e);return isNaN(C)?`$${e}`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(C)}var Ii=ie+"widget/mc-img.svg",Bi=ie+"widget/visa-img.svg",Ti=ie+"widget/ae-img.svg",qi=ie+"widget/discover-img.svg",In=ie+"widget/card.svg",Yi=ie+"widget/bank.svg",ja=ie+"widget/Trash.svg",Va=ie+"widget/secure-img.png",Ka=ie+"widget/pov-by.png",Oa=ie+"widget/pax.svg",mi=ie+"widget/Bank _New.svg",di=e=>{switch(e==null?void 0:e.toLowerCase()){case"visa":return Bi;case"mastercard":case"mc":case"m/c":return Ii;case"amex":case"american express":case"ae":return Ti;case"discover":case"dcvr":return qi;case"bank":return Yi;default:return In}};function ji(e){let C=e.merchantPublicKey,ee=e==null?void 0:e.discount,R=e==null?void 0:e.tax,$=e==null?void 0:e.surcharge,[Me,U]=mn(!1),[$e,Ue]=mn(!1),[ye,O]=mn({}),[me,ve]=mn(null),[o,y]=mn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:C}),[f,Q]=mn(!1),[ce,k]=mn(void 0),[Ge,ne]=mn(""),[Fe,b]=mn(!1),[we,oe]=mn(null),I=h=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(h),Je=/[+-]?([0-9]*[.])?[0-9]+/,ae=h=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h),Te=h=>/^[A-Za-z\s]*$/.test(h),Xe=(h,w)=>{let G=(parseFloat(w)||0)/100,ke=h/(1+G);return Math.round(ke*100)/100};ci(()=>{if(e!=null&&e.pass_fee){let h=Xe(e==null?void 0:e.amount,e==null?void 0:e.surcharge);k(h)}},[e==null?void 0:e.pass_fee]);let Pt=()=>{U(!1),O({})},B=()=>U(!0),g=()=>{console.log(we,"apiresponse"),J(we),b(!1)};function c(){y({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:C}),ne("")}function J(h){let w={type:"preview.compiledcheck",other:A(F({},h),{status:!0})};window.parent.postMessage(w,"*")}let L=async()=>{if(!(Object.keys(ye).length>0)){if(O({}),!(o!=null&&o.email)&&me&&!I(me)){O(h=>A(F({},h),{phone:Lt.phonenumbervalid}));return}if(S())try{Ue(!0);let h={fractalpayPublicKey:C,amount:Ge,phone_number:me,order_id:o.order_id,action:"request",name:o.name,email:o.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:ee,surcharge:$,tax:R,require_3ds:e==null?void 0:e.require_3ds,pass_fee:e==null?void 0:e.pass_fee,allow_partial:f},w=await $i.post(`${Be}create-widget-order`,h);(w==null?void 0:w.status)===200&&(b(!0),U(!1),c(),oe(w==null?void 0:w.data)),Ue(!1)}catch(h){console.log(h),Ue(!1)}}},x=Be+"images/logo-img.png",d=h=>{let{value:w}=h.target,G=h.target.dataset.token;if(y(A(F({},o),{[G]:w})),G==="name"&&!Te(w)){O(zt=>A(F({},zt),{[G]:Lt.onlylettersallowed}));return}let ke=ye;G==="email"&&!me&&(delete ke.phone,O(ke)),w&&(delete ke[G],O(ke)),G==="email"&&!w&&(delete ke[G],O(ke))},v=h=>{let{value:w}=h;if(Number(w)>0){let G=ye;delete G.amount,O(G)}ne(w)},S=()=>{let h={};return Ge||(h.amount=Lt.amountrequired),o.email&&!ae(o==null?void 0:o.email)&&(h.email=Lt.invalidemail),!me&&!(o!=null&&o.email)&&(h.phone=Lt.phoneoremailrequired),!me&&!(o!=null&&o.email)&&(h.email=Lt.phoneoremailrequired),!me&&o.email&&!ae(o==null?void 0:o.email)&&(h.email=Lt.invalidemail),e.from==="merchant"&&!o.order_id&&(h.order_id=Lt.orderidrequired),O(h),Object.keys(h).length===0};ci(()=>{e&&(y(h=>A(F({},h),{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:""})),ne(e.amount?e.amount:""),ve(e.phone?`${e.phone}`:null))},[e]);let M=h=>{let w=h==null?void 0:h.value;if(w&&(w==null?void 0:w.length)>0&&(w==null?void 0:w.length)!==10){O(ke=>A(F({},ke),{phone:Lt.phonenumberlength})),ve(w);return}else ve(w);let G=ye;delete G.phone,w&&!(o!=null&&o.email)&&delete G.email,O(G)};function _(h){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(h))}let q=h=>{let w=h.target.checked;Q(w)};return T.createElement(T.Fragment,null,T.createElement(Kn,null),T.createElement(Ot,{loading:$e}),T.createElement(T.Fragment,null,T.createElement("button",{className:"paymentBtn",onClick:B},"Request Payment"),T.createElement(Ut,{open:Me,onClose:()=>U(!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"},_(e==null?void 0:e.amount)),ce&&ce>0&&T.createElement("div",{className:"frac-req-cash-discount"},T.createElement("div",{className:"frac-cashlabel"},"Cash Discount :"),T.createElement("div",null,Ce((Number(e.amount)-ce).toFixed(2)))),(e==null?void 0:e.from)==="merchant"&&T.createElement("p",{className:"request-payment-orderid"},o==null?void 0:o.order_id),T.createElement("span",{className:"request-payment-close-popup",onClick:Pt},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:d,value:o==null?void 0:o.name}),ye.name&&T.createElement("small",{className:"request-payment-error-msg"},ye.name)),T.createElement("div",{className:"request-payment-list-div"},T.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),T.createElement(Hi,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:me,onValueChange:h=>{M(h)}}),ye.phone&&T.createElement("small",{className:"request-payment-error-msg"},ye.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:d,"data-token":"email",value:o==null?void 0:o.email}),ye.email&&T.createElement("small",{className:"request-payment-error-msg"},ye.email)),T.createElement("div",{className:"partial-toggle-div"},T.createElement("input",{className:"partial-input",type:"checkbox",role:"switch",style:{cursor:"pointer"},checked:f,onChange:h=>q(h),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:L,disabled:$e},$e?"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(Ut,{open:Fe,onClose:g,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:g},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:g,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import V,{useState as yn,useEffect as Vi}from"react";import Ki from"axios";import{PatternFormat as Oi}from"react-number-format";function Zi(e){let C=e.merchantPublicKey,ee=e==null?void 0:e.discount,R=e==null?void 0:e.tax,$=e==null?void 0:e.surcharge,[Me,U]=yn(!1),[$e,Ue]=yn(!1),[ye,O]=yn({}),[me,ve]=yn(null),[o,y]=yn({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:C}),[f,Q]=yn(""),[ce,k]=yn(!1),[Ge,ne]=yn(null),Fe=d=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(d),b=/[+-]?([0-9]*[.])?[0-9]+/,we=d=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d),oe=d=>/^[A-Za-z\s]*$/.test(d),I=()=>{U(!1),O({})},Je=()=>U(!0),ae=()=>{console.log(Ge,"apiresponse"),Xe(Ge),k(!1)};function Te(){y({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:C}),Q("")}function Xe(d){let v={type:"preview.compiledcheck",other:A(F({},d),{status:!0})};window.parent.postMessage(v,"*")}let Pt=async()=>{if(!(Object.keys(ye).length>0)){if(O({}),!(o!=null&&o.email)&&me&&!Fe(me)){O(d=>A(F({},d),{phone:Lt.phonenumbervalid}));return}if(J())try{Ue(!0);let d={fractalpayPublicKey:C,amount:f,phone_number:me,order_id:o.order_id,action:"request",name:o.name,email:o.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:ee,surcharge:$,tax:R,require_3ds:e==null?void 0:e.require_3ds},v=await Ki.post(`${Be}send-request-pre-auth-payment`,d);(v==null?void 0:v.status)===200&&(k(!0),U(!1),Te(),ne(v==null?void 0:v.data)),Ue(!1)}catch(d){console.log(d),Ue(!1)}}},B=Be+"images/logo-img.png",g=d=>{let{value:v}=d.target,S=d.target.dataset.token;if(y(A(F({},o),{[S]:v})),S==="name"&&!oe(v)){O(_=>A(F({},_),{[S]:Lt.onlylettersallowed}));return}let M=ye;S==="email"&&!me&&(delete M.phone,O(M)),v&&(delete M[S],O(M)),S==="email"&&!v&&(delete M[S],O(M))},c=d=>{let{value:v}=d;if(Number(v)>0){let S=ye;delete S.amount,O(S)}Q(v)},J=()=>{let d={};return f||(d.amount=Lt.amountrequired),o.email&&!we(o==null?void 0:o.email)&&(d.email=Lt.invalidemail),!me&&!(o!=null&&o.email)&&(d.phone=Lt.phoneoremailrequired),!me&&!(o!=null&&o.email)&&(d.email=Lt.phoneoremailrequired),!me&&o.email&&!we(o==null?void 0:o.email)&&(d.email=Lt.invalidemail),e.from==="merchant"&&!o.order_id&&(d.order_id=Lt.orderidrequired),O(d),Object.keys(d).length===0};Vi(()=>{e&&(y(d=>A(F({},d),{order_id:e.orderID?e.orderID:"",name:e!=null&&e.name?e==null?void 0:e.name:"",email:e!=null&&e.email?e==null?void 0:e.email:""})),Q(e.amount?e.amount:""),ve(e.phone?`${e.phone}`:null))},[e]);let L=d=>{let v=d==null?void 0:d.value;if(v&&(v==null?void 0:v.length)>0&&(v==null?void 0:v.length)!==10){O(M=>A(F({},M),{phone:Lt.phonenumberlength})),ve(v);return}else ve(v);let S=ye;delete S.phone,v&&!(o!=null&&o.email)&&delete S.email,O(S)};function x(d){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(d))}return V.createElement(V.Fragment,null,V.createElement(Kn,null),V.createElement(Ot,{loading:$e}),V.createElement(V.Fragment,null,V.createElement("button",{className:"paymentBtn",onClick:Je},"Send Request"),V.createElement("div",{className:"frac-form"},V.createElement(Ut,{open:Me,onClose:()=>U(!1),maxWidth:"500px"},V.createElement("div",{className:"request-payment-amount-detail"},V.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),V.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",e==null?void 0:e.webname),V.createElement("p",{className:"request-payment-amount"},x(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&V.createElement("p",{className:"request-payment-orderid"},o==null?void 0:o.order_id),V.createElement("span",{className:"request-payment-close-popup",onClick:I},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:g,value:o==null?void 0:o.name}),ye.name&&V.createElement("small",{className:"request-payment-error-msg"},ye.name)),V.createElement("div",{className:"request-payment-list-div"},V.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),V.createElement(Oi,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:me,onValueChange:d=>{L(d)}}),ye.phone&&V.createElement("small",{className:"request-payment-error-msg"},ye.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:g,"data-token":"email",value:o==null?void 0:o.email}),ye.email&&V.createElement("small",{className:"request-payment-error-msg"},ye.email)),V.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:Pt,disabled:$e},$e?"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(Ut,{open:ce,onClose:ae,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:ae},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:ae,className:"request-payment-success-btn2"},"Close"))))))))}import i,{useEffect as gi,useState as vt}from"react";import Ei from"react";function vn(){let e="#000",C="#fff",ee="#212529",R="#dee2e6";return Ei.createElement("style",null,`
|
|
314
|
+
`),Fn=Xn;function Rn(e){let ae=e.merchantPublicKey,oe=e==null?void 0:e.discount,Ae=e==null?void 0:e.tax,Y=e==null?void 0:e.surcharge,[$e,T]=Qt(!1),[gt,ze]=Qt(!1),[ee,R]=Qt({}),[W,re]=Qt(null),[i,y]=Qt({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:ae}),[u,q]=Qt(!1),[Z,be]=Qt(void 0),[Ge,Ve]=Qt(""),[Pe,he]=Qt(!1),[ce,kt]=Qt(null),k=h=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(h),je=/[+-]?([0-9]*[.])?[0-9]+/,V=h=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h),Ue=h=>/^[A-Za-z\s]*$/.test(h),Be=(h,C)=>{let B=(parseFloat(C)||0)/100,Fe=h/(1+B);return Math.round(Fe*100)/100};$n(()=>{if(e!=null&&e.pass_fee){let h=Be(e==null?void 0:e.amount,e==null?void 0:e.surcharge);be(h)}},[e==null?void 0:e.pass_fee]);let At=()=>{T(!1),R({})},_=()=>T(!0),m=()=>{console.log(ce,"apiresponse"),z(ce),he(!1)};function c(){y({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:ae}),Ve("")}function z(h){let C={type:"preview.compiledcheck",other:A(M({},h),{status:!0})};window.parent.postMessage(C,"*")}let v=async()=>{if(!(Object.keys(ee).length>0)){if(R({}),!(i!=null&&i.email)&&W&&!k(W)){R(h=>A(M({},h),{phone:lt.phonenumbervalid}));return}if(p())try{ze(!0);let h={fractalpayPublicKey:ae,amount:Ge,phone_number:W,order_id:i.order_id,action:"request",name:i.name,email:i.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:oe,surcharge:Y,tax:Ae,require_3ds:e==null?void 0:e.require_3ds,pass_fee:e==null?void 0:e.pass_fee,allow_partial:u},C=await Qn.post(`${Se}create-widget-order`,h);(C==null?void 0:C.status)===200&&(he(!0),T(!1),c(),kt(C==null?void 0:C.data)),ze(!1)}catch(h){console.log(h),ze(!1)}}},g=Se+"images/logo-img.png",r=h=>{let{value:C}=h.target,B=h.target.dataset.token;if(y(A(M({},i),{[B]:C})),B==="name"&&!Ue(C)){R(Nt=>A(M({},Nt),{[B]:lt.onlylettersallowed}));return}let Fe=ee;B==="email"&&!W&&(delete Fe.phone,R(Fe)),C&&(delete Fe[B],R(Fe)),B==="email"&&!C&&(delete Fe[B],R(Fe))},f=h=>{let{value:C}=h;if(Number(C)>0){let B=ee;delete B.amount,R(B)}Ve(C)},p=()=>{let h={};return Ge||(h.amount=lt.amountrequired),i.email&&!V(i==null?void 0:i.email)&&(h.email=lt.invalidemail),!W&&!(i!=null&&i.email)&&(h.phone=lt.phoneoremailrequired),!W&&!(i!=null&&i.email)&&(h.email=lt.phoneoremailrequired),!W&&i.email&&!V(i==null?void 0:i.email)&&(h.email=lt.invalidemail),e.from==="merchant"&&!i.order_id&&(h.order_id=lt.orderidrequired),R(h),Object.keys(h).length===0};$n(()=>{e&&(y(h=>A(M({},h),{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:""})),Ve(e.amount?e.amount:""),re(e.phone?`${e.phone}`:null))},[e]);let x=h=>{let C=h==null?void 0:h.value;if(C&&(C==null?void 0:C.length)>0&&(C==null?void 0:C.length)!==10){R(Fe=>A(M({},Fe),{phone:lt.phonenumberlength})),re(C);return}else re(C);let B=ee;delete B.phone,C&&!(i!=null&&i.email)&&delete B.email,R(B)};function b(h){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(h))}let L=h=>{let C=h.target.checked;q(C)};return w.createElement(w.Fragment,null,w.createElement(Fn,null),w.createElement(Lt,{loading:gt}),w.createElement(w.Fragment,null,w.createElement("button",{className:"paymentBtn",onClick:_},"Request Payment"),w.createElement(Vt,{open:$e,onClose:()=>T(!1),maxWidth:"500px"},w.createElement("div",{style:{maxWidth:"500px"}},w.createElement("div",{className:"request-payment-amount-detail frac-form"},w.createElement("p",{className:"request-payment-merchantname"},"Pay ",e==null?void 0:e.webname),w.createElement("p",{className:"request-payment-amount"},b(e==null?void 0:e.amount)),Z&&Z>0&&w.createElement("div",{className:"frac-req-cash-discount"},w.createElement("div",{className:"frac-cashlabel"},"Cash Discount :"),w.createElement("div",null,pe((Number(e.amount)-Z).toFixed(2)))),(e==null?void 0:e.from)==="merchant"&&w.createElement("p",{className:"request-payment-orderid"},i==null?void 0:i.order_id),w.createElement("span",{className:"request-payment-close-popup",onClick:At},w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},w.createElement("g",{clipPath:"url(#clip0_12425_52336)"},w.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"})),w.createElement("defs",null,w.createElement("clipPath",{id:"clip0_12425_52336"},w.createElement("rect",{width:"16",height:"16",fill:"white"})))))),w.createElement("form",{className:"request-payment-input-form"},w.createElement("div",{className:"request-payment-list-div"},w.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),w.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:r,value:i==null?void 0:i.name}),ee.name&&w.createElement("small",{className:"request-payment-error-msg"},ee.name)),w.createElement("div",{className:"request-payment-list-div"},w.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),w.createElement(Dn,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:W,onValueChange:h=>{x(h)}}),ee.phone&&w.createElement("small",{className:"request-payment-error-msg"},ee.phone)),w.createElement("div",{className:"request-payment-list-div"},w.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),w.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:r,"data-token":"email",value:i==null?void 0:i.email}),ee.email&&w.createElement("small",{className:"request-payment-error-msg"},ee.email)),w.createElement("div",{className:"partial-toggle-div"},w.createElement("input",{className:"partial-input",type:"checkbox",role:"switch",style:{cursor:"pointer"},checked:u,onChange:h=>L(h),id:"partialSwitch"}),w.createElement("label",{className:"partial-label",htmlFor:"partialSwitch",style:{cursor:"pointer"}},"Allow Partial Payments?")),w.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:v,disabled:gt},gt?"Loading...":"Send Request"),w.createElement("div",{className:"request-payment-fractal-powerd-by"},w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},w.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 ",w.createElement("span",null,"Fractal"),w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"}),w.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"})))))),w.createElement(Vt,{open:Pe,onClose:m,maxWidth:"500px"},w.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},w.createElement("div",{className:"request-payment-success-container"},w.createElement("span",{className:"request-payment-close-popup",onClick:m},w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},w.createElement("g",{clipPath:"url(#clip0_12425_52336)"},w.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"})),w.createElement("defs",null,w.createElement("clipPath",{id:"clip0_12425_52336"},w.createElement("rect",{width:"16",height:"16",fill:"white"}))))),w.createElement("div",{className:"request-payment-success-tick-div"},w.createElement("div",{className:"request-payment-success-tick"},w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},w.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"})))),w.createElement("h6",{className:"request-payment-success-text"},"The request ",w.createElement("br",null),"was sent"),w.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),w.createElement("div",{className:"request-payment-success-btn-div"},w.createElement("button",{onClick:m,className:"request-payment-success-btn2"},"Close")))))))}import"bootstrap/dist/js/bootstrap.bundle.min.js";import P,{useState as an,useEffect as ei}from"react";import ti from"axios";import{PatternFormat as ni}from"react-number-format";function ii(e){let ae=e.merchantPublicKey,oe=e==null?void 0:e.discount,Ae=e==null?void 0:e.tax,Y=e==null?void 0:e.surcharge,[$e,T]=an(!1),[gt,ze]=an(!1),[ee,R]=an({}),[W,re]=an(null),[i,y]=an({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:ae}),[u,q]=an(""),[Z,be]=an(!1),[Ge,Ve]=an(null),Pe=r=>/^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(r),he=/[+-]?([0-9]*[.])?[0-9]+/,ce=r=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r),kt=r=>/^[A-Za-z\s]*$/.test(r),k=()=>{T(!1),R({})},je=()=>T(!0),V=()=>{console.log(Ge,"apiresponse"),Be(Ge),be(!1)};function Ue(){y({email:"",phone_number:"",order_id:"",name:"",fractalpayPublicKey:ae}),q("")}function Be(r){let f={type:"preview.compiledcheck",other:A(M({},r),{status:!0})};window.parent.postMessage(f,"*")}let At=async()=>{if(!(Object.keys(ee).length>0)){if(R({}),!(i!=null&&i.email)&&W&&!Pe(W)){R(r=>A(M({},r),{phone:lt.phonenumbervalid}));return}if(z())try{ze(!0);let r={fractalpayPublicKey:ae,amount:u,phone_number:W,order_id:i.order_id,action:"request",name:i.name,email:i.email,customer_id:e!=null&&e.customerId?e==null?void 0:e.customerId:"",discount:oe,surcharge:Y,tax:Ae,require_3ds:e==null?void 0:e.require_3ds},f=await ti.post(`${Se}send-request-pre-auth-payment`,r);(f==null?void 0:f.status)===200&&(be(!0),T(!1),Ue(),Ve(f==null?void 0:f.data)),ze(!1)}catch(r){console.log(r),ze(!1)}}},_=Se+"images/logo-img.png",m=r=>{let{value:f}=r.target,p=r.target.dataset.token;if(y(A(M({},i),{[p]:f})),p==="name"&&!kt(f)){R(b=>A(M({},b),{[p]:lt.onlylettersallowed}));return}let x=ee;p==="email"&&!W&&(delete x.phone,R(x)),f&&(delete x[p],R(x)),p==="email"&&!f&&(delete x[p],R(x))},c=r=>{let{value:f}=r;if(Number(f)>0){let p=ee;delete p.amount,R(p)}q(f)},z=()=>{let r={};return u||(r.amount=lt.amountrequired),i.email&&!ce(i==null?void 0:i.email)&&(r.email=lt.invalidemail),!W&&!(i!=null&&i.email)&&(r.phone=lt.phoneoremailrequired),!W&&!(i!=null&&i.email)&&(r.email=lt.phoneoremailrequired),!W&&i.email&&!ce(i==null?void 0:i.email)&&(r.email=lt.invalidemail),e.from==="merchant"&&!i.order_id&&(r.order_id=lt.orderidrequired),R(r),Object.keys(r).length===0};ei(()=>{e&&(y(r=>A(M({},r),{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:""})),q(e.amount?e.amount:""),re(e.phone?`${e.phone}`:null))},[e]);let v=r=>{let f=r==null?void 0:r.value;if(f&&(f==null?void 0:f.length)>0&&(f==null?void 0:f.length)!==10){R(x=>A(M({},x),{phone:lt.phonenumberlength})),re(f);return}else re(f);let p=ee;delete p.phone,f&&!(i!=null&&i.email)&&delete p.email,R(p)};function g(r){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(r))}return P.createElement(P.Fragment,null,P.createElement(Fn,null),P.createElement(Lt,{loading:gt}),P.createElement(P.Fragment,null,P.createElement("button",{className:"paymentBtn",onClick:je},"Send Request"),P.createElement("div",{className:"frac-form"},P.createElement(Vt,{open:$e,onClose:()=>T(!1),maxWidth:"500px"},P.createElement("div",{className:"request-payment-amount-detail"},P.createElement("p",{className:"request-payment-merchantname"},"Authorization Request"),P.createElement("p",{className:"request-payment-pre-auth-merchantname"},"Pay ",e==null?void 0:e.webname),P.createElement("p",{className:"request-payment-amount"},g(e==null?void 0:e.amount)),(e==null?void 0:e.from)==="merchant"&&P.createElement("p",{className:"request-payment-orderid"},i==null?void 0:i.order_id),P.createElement("span",{className:"request-payment-close-popup",onClick:k},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},P.createElement("g",{clipPath:"url(#clip0_12425_52336)"},P.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),P.createElement("defs",null,P.createElement("clipPath",{id:"clip0_12425_52336"},P.createElement("rect",{width:"16",height:"16",fill:"white"})))))),P.createElement("form",{className:"request-payment-input-form"},P.createElement("div",{className:"request-payment-list-div"},P.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"FULL NAME"),P.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Full Name","data-token":"name",onChange:m,value:i==null?void 0:i.name}),ee.name&&P.createElement("small",{className:"request-payment-error-msg"},ee.name)),P.createElement("div",{className:"request-payment-list-div"},P.createElement("label",{htmlFor:"requestPhoneNumber",className:"request-payment-input-label"},"Phone Number"),P.createElement(ni,{className:"request-payment-input-box",placeholder:"Mobile number",format:"+1 (###) ###-####",value:W,onValueChange:r=>{v(r)}}),ee.phone&&P.createElement("small",{className:"request-payment-error-msg"},ee.phone)),P.createElement("div",{className:"request-payment-list-div"},P.createElement("label",{htmlFor:"exampleFormControlInput2",className:"request-payment-input-label"},"EMAIL"),P.createElement("input",{className:"request-payment-input-box",type:"text",placeholder:"Email",onChange:m,"data-token":"email",value:i==null?void 0:i.email}),ee.email&&P.createElement("small",{className:"request-payment-error-msg"},ee.email)),P.createElement("button",{type:"button",className:"request-payment-submit-button",onClick:At,disabled:gt},gt?"Loading...":"Send Request"),P.createElement("div",{className:"request-payment-fractal-powerd-by"},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},P.createElement("path",{d:"M15.2165 4.11839C15.1973 3.69746 15.1973 3.29567 15.1973 2.89387C15.1973 2.56861 14.9486 2.31988 14.6234 2.31988C12.2317 2.31988 10.4141 1.63109 8.90257 0.157848C8.67298 -0.0526158 8.32858 -0.0526158 8.09898 0.157848C6.58748 1.63109 4.76984 2.31988 2.37821 2.31988C2.05295 2.31988 1.80422 2.56861 1.80422 2.89387C1.80422 3.29567 1.80422 3.69746 1.78508 4.11839C1.70855 8.13632 1.59375 13.6466 8.30945 15.9617L8.50078 16L8.69211 15.9617C15.3887 13.6466 15.293 8.15546 15.2165 4.11839ZM8.04159 9.6861C7.92679 9.78176 7.79286 9.83916 7.63979 9.83916H7.62066C7.46759 9.83916 7.31453 9.76263 7.21887 9.64783L5.43949 7.67713L6.30048 6.91181L7.69719 8.46158L10.7967 5.5151L11.5812 6.35695L8.04159 9.6861Z",fill:"#727272"})),"Secure payments powered by ",P.createElement("span",null,"Fractal"),P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},P.createElement("path",{d:"M17.4999 5.49758V7.01156C17.4999 7.05924 17.4595 7.09898 17.411 7.09898H12.3516C12.9169 6.54266 13.4781 5.99032 14.0434 5.434C14.0596 5.4181 14.0838 5.41016 14.104 5.41016H17.411C17.4595 5.41016 17.4999 5.44989 17.4999 5.49758Z",fill:"#61C699"}),P.createElement("path",{d:"M12.3462 10.9037V9.29836C12.3462 9.25067 12.3866 9.21094 12.435 9.21094H13.8523C13.929 9.21094 13.9694 9.30631 13.9129 9.35796C13.392 9.87455 12.8711 10.3911 12.3462 10.9037Z",fill:"#61C699"}),P.createElement("path",{d:"M12.4404 9.00523H15.6949C15.7434 9.00523 15.7838 8.96549 15.7838 8.91781V7.40383C15.7838 7.35614 15.7434 7.31641 15.6949 7.31641H12.4404C12.3919 7.31641 12.3516 7.35614 12.3516 7.40383V8.91781C12.3516 8.96549 12.3919 9.00523 12.4404 9.00523Z",fill:"#61C699"}),P.createElement("path",{d:"M10.1581 0.0120725L11.4906 0.77105C11.531 0.794892 11.5471 0.84655 11.5229 0.890261L8.99114 5.20173C8.78521 4.44275 8.57927 3.68775 8.37334 2.92877C8.36527 2.90493 8.3693 2.88109 8.38142 2.86122L10.0329 0.0438621C10.0612 0.000151419 10.1177 -0.0117697 10.1581 0.0120725Z",fill:"#61C699"}),P.createElement("path",{d:"M12.3382 7.10006L10.9289 6.29737C10.8886 6.27353 10.8724 6.22187 10.8966 6.17816L11.6033 4.97015C11.6436 4.9026 11.7446 4.91452 11.7648 4.99002C11.9546 5.69734 12.1484 6.40068 12.3382 7.10006Z",fill:"#61C699"}),P.createElement("path",{d:"M10.7107 6.0771L12.338 3.30345C12.3622 3.26372 12.346 3.20808 12.3057 3.18424L10.9732 2.42526C10.9328 2.40142 10.8763 2.41732 10.852 2.45705L9.22476 5.2307C9.20053 5.27044 9.21669 5.32607 9.25706 5.34991L10.5896 6.10889C10.634 6.13273 10.6865 6.11683 10.7107 6.0771Z",fill:"#61C699"}),P.createElement("path",{d:"M1.66713 3.51237L2.99963 2.75339C3.04001 2.72955 3.09654 2.74544 3.12077 2.78518L5.65251 7.09665C4.88128 6.89399 4.11408 6.69133 3.34285 6.48867C3.31862 6.4847 3.30247 6.4688 3.29036 6.44893L1.63483 3.63158C1.6106 3.58787 1.62271 3.53621 1.66713 3.51237Z",fill:"#61C699"}),P.createElement("path",{d:"M8.99793 5.20018L7.58871 5.99889C7.54833 6.02274 7.4918 6.00684 7.46757 5.9671L6.76095 4.76307C6.72057 4.69552 6.78517 4.61605 6.86189 4.63591C7.57256 4.82268 8.28726 5.00944 8.99793 5.20018Z",fill:"#61C699"}),P.createElement("path",{d:"M7.27986 6.07054L5.6526 3.2969C5.62837 3.25716 5.57588 3.24127 5.53146 3.26511L4.19896 4.02409C4.15858 4.04793 4.14243 4.09959 4.16666 4.1433L5.79392 6.91694C5.81815 6.95668 5.87064 6.97257 5.91506 6.94873L7.24756 6.18975C7.28794 6.16591 7.30409 6.11425 7.27986 6.07054Z",fill:"#61C699"}),P.createElement("path",{d:"M0.5 12.4998V10.9859C0.5 10.9382 0.540379 10.8984 0.588833 10.8984H5.64829C5.08299 11.4548 4.52172 12.0071 3.95642 12.5634C3.94027 12.5793 3.91604 12.5873 3.89585 12.5873H0.588833C0.540379 12.5873 0.5 12.5475 0.5 12.4998Z",fill:"#61C699"}),P.createElement("path",{d:"M5.65129 7.09766V8.70303C5.65129 8.75072 5.61091 8.79045 5.56246 8.79045H4.14516C4.06844 8.79045 4.02806 8.69508 4.08459 8.64343C4.60548 8.12685 5.12637 7.61424 5.65129 7.09766Z",fill:"#61C699"}),P.createElement("path",{d:"M5.55967 8.99609H2.30514C2.25669 8.99609 2.21631 9.03583 2.21631 9.08352V10.5975C2.21631 10.6452 2.25669 10.6849 2.30514 10.6849H5.55967C5.60813 10.6849 5.6485 10.6452 5.6485 10.5975V9.08352C5.6485 9.03583 5.60813 8.99609 5.55967 8.99609Z",fill:"#61C699"}),P.createElement("path",{d:"M7.82638 17.9865L6.49388 17.2276C6.4535 17.2037 6.43735 17.1521 6.46158 17.1083L8.99333 12.7969C9.19926 13.5559 9.40519 14.3109 9.61112 15.0698C9.6192 15.0937 9.61516 15.1175 9.60305 15.1374L7.95155 17.9547C7.91925 17.9985 7.86676 18.0104 7.82638 17.9865Z",fill:"#61C699"}),P.createElement("path",{d:"M5.64795 10.8984L7.05717 11.7011C7.09755 11.725 7.1137 11.7766 7.08947 11.8203L6.38284 13.0283C6.34246 13.0959 6.24152 13.084 6.22133 13.0085C6.02751 12.3012 5.83773 11.5978 5.64795 10.8984Z",fill:"#61C699"}),P.createElement("path",{d:"M7.2739 11.9258L5.64664 14.6994C5.62241 14.7392 5.63856 14.7948 5.67894 14.8187L7.01144 15.5776C7.05182 15.6015 7.10835 15.5856 7.13258 15.5458L8.75984 12.7722C8.78407 12.7325 8.76792 12.6768 8.72754 12.653L7.39504 11.894C7.35062 11.8702 7.29813 11.8861 7.2739 11.9258Z",fill:"#61C699"}),P.createElement("path",{d:"M16.3199 14.4866L14.9874 15.2456C14.947 15.2694 14.8904 15.2535 14.8662 15.2138L12.3345 10.9023C13.1057 11.105 13.8729 11.3077 14.6441 11.5103C14.6684 11.5143 14.6845 11.5302 14.6966 11.5501L16.3481 14.3674C16.3764 14.4111 16.3643 14.4628 16.3199 14.4866Z",fill:"#61C699"}),P.createElement("path",{d:"M8.99121 12.7983L10.4004 11.9956C10.4408 11.9717 10.4973 11.9876 10.5216 12.0274L11.2282 13.2354C11.2686 13.3029 11.204 13.3824 11.1272 13.3625C10.4166 13.1758 9.70188 12.989 8.99121 12.7983Z",fill:"#61C699"}),P.createElement("path",{d:"M10.7077 11.9285L12.3349 14.7021C12.3592 14.7418 12.4117 14.7577 12.4561 14.7339L13.7886 13.9749C13.829 13.9511 13.8451 13.8994 13.8209 13.8557L12.1936 11.0821C12.1694 11.0423 12.1169 11.0264 12.0725 11.0503L10.74 11.8092C10.6996 11.8331 10.6834 11.8847 10.7077 11.9285Z",fill:"#61C699"}))))),P.createElement(Vt,{open:Z,onClose:V,maxWidth:"500px"},P.createElement("div",{className:"fractal-popup-content",style:{padding:"0px",maxWidth:"500px"}},P.createElement("div",{className:"request-payment-success-container"},P.createElement("span",{className:"request-payment-close-popup",onClick:V},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},P.createElement("g",{clipPath:"url(#clip0_12425_52336)"},P.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),P.createElement("defs",null,P.createElement("clipPath",{id:"clip0_12425_52336"},P.createElement("rect",{width:"16",height:"16",fill:"white"}))))),P.createElement("div",{className:"request-payment-success-tick-div"},P.createElement("div",{className:"request-payment-success-tick"},P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},P.createElement("path",{d:"M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z",fill:"#61C699"})))),P.createElement("h6",{className:"request-payment-success-text"},"The request ",P.createElement("br",null),"was sent"),P.createElement("h6",{className:"request-payment-success-subtext"},"Please wait for the customer to pay"),P.createElement("div",{className:"request-payment-success-btn-div"},P.createElement("button",{onClick:V,className:"request-payment-success-btn2"},"Close"))))))))}import n,{useEffect as Vn,useState as Xe}from"react";import ai from"react";function mn(){let e="#000",ae="#fff",oe="#212529",Ae="#dee2e6";return ai.createElement("style",null,`
|
|
651
315
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
652
316
|
body
|
|
653
317
|
{
|
|
@@ -876,13 +540,13 @@ var vi=Object.defineProperty,Ci=Object.defineProperties;var Ni=Object.getOwnProp
|
|
|
876
540
|
font-size: 1rem;
|
|
877
541
|
font-weight: 400;
|
|
878
542
|
line-height: 1.5;
|
|
879
|
-
color: ${
|
|
543
|
+
color: ${oe};
|
|
880
544
|
-webkit-appearance: none;
|
|
881
545
|
-moz-appearance: none;
|
|
882
546
|
appearance: none;
|
|
883
|
-
background-color: ${
|
|
547
|
+
background-color: ${ae};
|
|
884
548
|
background-clip: padding-box;
|
|
885
|
-
border: 1px solid ${
|
|
549
|
+
border: 1px solid ${Ae};
|
|
886
550
|
border-radius: 0.375rem;
|
|
887
551
|
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
|
888
552
|
}
|
|
@@ -900,7 +564,7 @@ var vi=Object.defineProperty,Ci=Object.defineProperties;var Ni=Object.getOwnProp
|
|
|
900
564
|
}
|
|
901
565
|
.card-crdi {
|
|
902
566
|
display: flex;
|
|
903
|
-
border: 1px solid ${
|
|
567
|
+
border: 1px solid ${Ae};
|
|
904
568
|
border-radius: 0.375rem;
|
|
905
569
|
}
|
|
906
570
|
.card-expiry-new{
|
|
@@ -926,7 +590,7 @@ var vi=Object.defineProperty,Ci=Object.defineProperties;var Ni=Object.getOwnProp
|
|
|
926
590
|
border-top-right-radius: 0;
|
|
927
591
|
border-bottom-right-radius: 0;
|
|
928
592
|
border: 0;
|
|
929
|
-
border-right: 1px solid ${
|
|
593
|
+
border-right: 1px solid ${Ae};
|
|
930
594
|
}
|
|
931
595
|
|
|
932
596
|
|
|
@@ -940,7 +604,7 @@ var vi=Object.defineProperty,Ci=Object.defineProperties;var Ni=Object.getOwnProp
|
|
|
940
604
|
border-radius: 0;
|
|
941
605
|
border-top: 0;
|
|
942
606
|
border-bottom: 0;
|
|
943
|
-
border-right: 1px solid ${
|
|
607
|
+
border-right: 1px solid ${Ae};
|
|
944
608
|
}
|
|
945
609
|
|
|
946
610
|
.exp-date input:focus {
|
|
@@ -1356,7 +1020,7 @@ position:relative;
|
|
|
1356
1020
|
margin-top: 12px !important;
|
|
1357
1021
|
}
|
|
1358
1022
|
|
|
1359
|
-
`)}import
|
|
1023
|
+
`)}import pn from"axios";import Ie from"react";import oi from"react";function An(){return oi.createElement("style",null,`
|
|
1360
1024
|
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
1361
1025
|
|
|
1362
1026
|
body{
|
|
@@ -1551,182 +1215,7 @@ position:relative;
|
|
|
1551
1215
|
gap: 6px;
|
|
1552
1216
|
background-color: #161616;
|
|
1553
1217
|
color: #fff;
|
|
1554
|
-
}`)}function bn(e,C,ee){e.preventDefault();let $={type:"preview.compiledcheck",other:{msg:"Payment success!",status:C==="close",data:{tran_id:ee,key:C}}};console.log("message:",$),window.parent.postMessage($,"*")}function Cn({onClose:e,tranId:C}){return lt.createElement(lt.Fragment,null,lt.createElement(Gn,null),lt.createElement("div",{className:"payment-msg-container"},lt.createElement("div",{className:"charge-payment-success-container"},lt.createElement("div",{className:"charge-payment-success-tick-div"},lt.createElement("div",{className:"charge-payment-success-tick"},lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},lt.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"})))),lt.createElement("h6",{className:"charge-payment-success-text"},"Your charge",lt.createElement("br",null),"was successful"),lt.createElement("h6",{className:"charge-payment-success-subtext"},"We\u2019ve processed your charge"),lt.createElement("div",{className:"charge-success-payment-button-div"},lt.createElement("button",{className:"charge-success-btn1",onClick:ee=>bn(ee,"print",C)},lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},lt.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"}),lt.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"),lt.createElement("button",{className:"charge-success-btn1",onClick:ee=>bn(ee,"share",C)},lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},lt.createElement("g",{clipPath:"url(#clip0_12420_50683)"},lt.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"})),lt.createElement("defs",null,lt.createElement("clipPath",{id:"clip0_12420_50683"},lt.createElement("rect",{width:"16",height:"16",fill:"white",transform:"translate(0.5)"})))),"Send receipt"))),lt.createElement("div",{className:"charge-payment-success-btn-div"},lt.createElement("button",{className:"charge-payment-success-btn1",onClick:ee=>bn(ee,"tran",C)},"Go to Transactions"),lt.createElement("button",{className:"charge-payment-success-btn2",onClick:ee=>{e(),bn(ee,"close",C)}},"Close"))))}import Bn from"sweetalert2";import{IoArrowBack as On}from"react-icons/io5";import{useEffect as ui}from"react";function Dt(){return ui(()=>{let e=xn;if(typeof window!="undefined"){if(window.DatacapWebToken){console.log("\u2705 Datacap already available");return}if(document.querySelector(`script[src="${e}"]`))console.log("\u2139\uFE0F Script already in DOM, waiting for Datacap...");else{let C=document.createElement("script");C.src=e,C.async=!0,C.onload=()=>{console.log("\u2705 Datacap script loaded"),window.DatacapWebToken?console.log("\u2705 DatacapWebToken is ready:",window.DatacapWebToken):console.warn("\u26A0\uFE0F Script loaded, but DatacapWebToken not found")},C.onerror=ee=>{console.error("\u274C Failed to load Datacap script",ee)},document.head.appendChild(C)}}},[]),ui(()=>{let e="forge-cdn-script";if(!document.getElementById(e)){let C=document.createElement("script");C.src="https://cdn.jsdelivr.net/npm/node-forge@1.0.0/dist/forge.min.js",C.id=e,C.async=!0,document.head.appendChild(C)}return()=>{let C=document.getElementById(e);C&&document.head.removeChild(C)}},[]),null}import Rt from"react";import Ui from"react";function Jn(){return Ui.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 Gi=({onClose:e,error:C})=>Rt.createElement(Rt.Fragment,null,Rt.createElement(Jn,null),Rt.createElement("div",{className:"card-error"},Rt.createElement("div",{className:"payment-error-container"},Rt.createElement("div",{className:"error-icon"},Rt.createElement("div",{className:"circle"},Rt.createElement("i",{className:"fa fa-times","aria-hidden":"true"})),Rt.createElement("div",{className:"error-text"},Rt.createElement("div",{className:"payment-error-text"},C),Rt.createElement("div",{className:"thank-you-text"},"Try again later ")),Rt.createElement("div",{className:"error-btn-div"},Rt.createElement("button",{onClick:e},"OK")))))),tn=Gi;import{io as Ji}from"socket.io-client";var Xi=Ji(Be,{transports:["websocket"],withCredentials:!1}),xt=Xi;import dn from"react";var pn=e=>dn.createElement(dn.Fragment,null,dn.createElement("div",{className:`frac-card-bank-radio ${e.activetab===e.value?"frac-active":""}`,onClick:()=>e.onChange(e.value),role:"radio"},dn.createElement("div",{className:"frac-card-title-main"},dn.createElement("img",{src:e.label.toLowerCase()==="card"?In:mi,className:"frac-payment-type-logo",alt:""}),dn.createElement("div",{className:"frac-card-label"},dn.createElement("div",{className:"frac-card-label-text"},e.label),dn.createElement("div",{className:"frac-card-label-amount"},Ce(e.amount)))),dn.createElement("div",null,dn.createElement("input",{name:"paymenttype",checked:e.activetab===e.value,type:"radio",value:e.value,onChange:C=>{e.onChange(C.target.value)}}))));import Qi from"react";function Nn({}){return Qi.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.frac-active {
|
|
1727
|
-
background: #F6F6F7;
|
|
1728
|
-
}
|
|
1729
|
-
`)}import jt from"react";var fn=({listHeading:e="Card",ListItems:C,selectedCard:ee,setSelectedCard:R,paymentGateway:$,handleDeleteCard:Me,otherButtonAction:U,otherButtonLabel:$e,headingClass:Ue})=>{let ye=ie+"widget/Trash.svg";return console.log(ee,"selectedCard another",C),jt.createElement(jt.Fragment,null,jt.createElement("h6",{className:Ue||"card-ach-heading",style:{marginBottom:"10px !important"}},e),jt.createElement("div",{className:"card-lint-div-in"},jt.createElement("div",{className:"card-list-div"},C&&(C==null?void 0:C.length)>0&&(C==null?void 0:C.map((O,me)=>{let ve=!1;return $&&(ve=$!=(O==null?void 0:O.payment_method_type)&&(O==null?void 0:O.card_type)!="Bank"),jt.createElement("div",{key:O==null?void 0:O.id,className:"card-list-single-div"},jt.createElement("div",{className:"card-number-radio"},jt.createElement("input",{disabled:ve,type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:(ee==null?void 0:ee.id)===(O==null?void 0:O.id),onChange:o=>R(O)}),jt.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",O==null?void 0:O.cardlastfourdigit),(O==null?void 0:O.card_type)!="Bank"&&jt.createElement("h6",{className:"card-expiry-date"},O==null?void 0:O.expmonth,"/",O==null?void 0:O.expyear)),jt.createElement("div",{className:"card-number-radio"},jt.createElement("span",{className:"visa-card"},jt.createElement("img",{src:di(O==null?void 0:O.card_type),alt:""})),jt.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Me(O==null?void 0:O.id)},jt.createElement("img",{src:ye,alt:""}))))}))),jt.createElement("div",{className:"pay-with-other-card",onClick:U},$e,jt.createElement("img",{src:In,alt:""}))))};function Di(e){var Tt,St,Le,Vt,Kt,Xt,ot,nn,Ft,ze,ut,rn,Et,en,At,an,sn,ln;let[C,ee]=vt(!1),[R,$]=vt(!1),[Me,U]=vt(""),[$e,Ue]=vt(!1),[ye,O]=vt(!1),[me,ve]=vt("card"),[o,y]=vt("card"),[f,Q]=vt("form"),[ce,k]=vt("form"),[Ge,ne]=vt(!0),[Fe,b]=vt(!1),[we,oe]=vt(!1),I=e.merchantPublicKey,Je=ie+"widget/mc-img.svg",ae=ie+"widget/visa-img.svg",Te=ie+"widget/ae-img.svg",Xe=ie+"widget/discover-img.svg",Pt=ie+"widget/card.svg",B=ie+"widget/Trash.svg",g=ie+"widget/bank.svg",c=ie+"widget/secure-img.png",J=ie+"widget/pov-by.png",L=ie+"widget/pax.svg",[x,d]=vt(),[v,S]=vt({}),[M,_]=vt(),[q,h]=vt({}),[w,G]=vt([]),[ke,zt]=vt([]),[at,pt]=vt(),[Mt,mt]=vt(),[qe,le]=vt(Number(e==null?void 0:e.amount));console.log(at,"selectedCard");let[Z,Ne]=vt(),[Qe,he]=vt(""),Ct=()=>ee(!0),tt=()=>ee(!1),z=(Y,l)=>{let ue=(parseFloat(l)||0)/100,je=Y/(1+ue);return Math.round(je*100)/100};gi(()=>{if(ye){let Y=z(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);le(Y)}},[ye,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let u=()=>{O(!1),ve("card"),U(""),Ue(!1),he(""),_({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),h({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),d({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),S({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),oe(!1),b(!1),pt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),mt({}),le(0),y("card"),ne(!0),k("form"),Q("form"),$(!1),ee(!1),zt([]),G([])},ge=()=>O(!0),De=Y=>{ve(Y)},re=(Y,l)=>{let ue=Y;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(ue)){(l===""||/^[0-9]+$/.test(l))&&(S(se=>A(F({},se),{[ue]:""})),d(se=>A(F({},se),{[ue]:l})));return}S(se=>A(F({},se),{[ue]:""})),d(se=>A(F({},se),{[ue]:l}))},Oe=Y=>{let ue=Y.target.value.replace(/\D/g,""),je="";/^3[47]/.test(ue)?je=ue.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Se,Ee,rt,nt)=>[Ee,rt,nt].filter(Boolean).join(" ")):je=ue.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Se,Ee,rt,nt,gt)=>[Ee,rt,nt,gt].filter(Boolean).join(" ")),S(se=>A(F({},se),{cardNumber:""})),d(se=>A(F({},se),{cardNumber:je}))},Ze=Y=>{let{name:l,value:ue}=Y.target,je=["routingNumber","accountNumber","confirmAccountNumber"];if(l=="name"){/^[a-zA-Z\s]*$/.test(ue)&&(h(se=>A(F({},se),{[l]:""})),_(se=>A(F({},se),{[l]:ue})));return}if(je.includes(l)){(ue===""||/^[0-9]+$/.test(ue))&&(h(se=>A(F({},se),{[l]:""})),_(se=>A(F({},se),{[l]:ue})));return}h(se=>A(F({},se),{[l]:""})),_(se=>A(F({},se),{[l]:ue}))},wt=()=>{var se,Se,Ee,rt,nt,gt;let Y={},l=x,ue=parseInt((l==null?void 0:l.expiryMonth)||"",10),je=(l==null?void 0:l.expiryYear)||"";if((se=l==null?void 0:l.cardName)!=null&&se.trim()||(Y.cardName="Card name is required"),(Se=l==null?void 0:l.cardNumber)!=null&&Se.trim()||(Y.cardNumber="Card number is required"),(!((Ee=l==null?void 0:l.expiryMonth)!=null&&Ee.trim())||!((rt=l==null?void 0:l.expiryYear)!=null&&rt.trim())||isNaN(ue)||ue<1||ue>12||je.length!==4)&&(Y.expiryMonth="Invalid Expiration Date."),(nt=l==null?void 0:l.cvv)!=null&&nt.trim()||(Y.cvv="CVV is required"),(gt=l==null?void 0:l.zipCode)!=null&>.trim()||(Y.zipCode="ZIP code is required"),l!=null&&l.expiryMonth&&(l!=null&&l.expiryYear)&&l.expiryMonth.length<=2&&l.expiryYear.length===4){let Bt=parseInt(l.expiryMonth,10),Re=parseInt(l.expiryYear,10),m=new Date,t=m.getMonth()+1,a=m.getFullYear();(Re<a||Re===a&&Bt<t)&&(Y.expiryMonth="Card is expired")}return S(Y),Object.keys(Y).length>0},He=()=>{var ue,je,se,Se,Ee,rt,nt,gt;let Y={},l=M;return(ue=l==null?void 0:l.name)!=null&&ue.trim()||(Y.name="Name is required"),(je=l==null?void 0:l.accountNumber)!=null&&je.trim()||(Y.accountNumber="Account number is required"),(se=l==null?void 0:l.accountNumber)!=null&&se.trim()&&((Se=l==null?void 0:l.accountNumber)==null?void 0:Se.trim())!==((Ee=l==null?void 0:l.confirmAccountNumber)==null?void 0:Ee.trim())&&(Y.confirmAccountNumber="Account numbers must match"),(rt=l==null?void 0:l.bankName)!=null&&rt.trim()||(Y.bankName="Bank name is required"),(nt=l==null?void 0:l.routingNumber)!=null&&nt.trim()||(Y.routingNumber="Routing Number is required"),l!=null&&l.routingNumber&&((gt=l==null?void 0:l.routingNumber)==null?void 0:gt.length)!==9&&(Y.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)==="")&&(Y.companyName="Company Name is required for business accounts"),h(Y),Object.keys(Y).length>0},yt=async Y=>{var l,ue,je,se,Se,Ee,rt,nt,gt,Bt,Re,m,t,a,N,p;if(Y.preventDefault(),me!=="ach"){if(wt())return;{let E=DatacapWebToken.validateCardNumber(x==null?void 0:x.cardNumber.replaceAll(" ","")),j=DatacapWebToken.validateExpirationDate(x==null?void 0:x.expiryMonth,x==null?void 0:x.expiryYear),te=DatacapWebToken.validateCVV(x==null?void 0:x.cvv),X={};if(E||(X.cardNumber="Invalid card Number"),j||(X.expiryMonth="Invalid Expiration Date."),te||(X.cvv="Invalid CVV"),S(X),E&&te&&j){$(!0);try{let W=A(F({},x),{amount:`${e.amount||0}`,fractalpayPublicKey:I,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}),D=await Pn.post(`${Be}create-widget-order`,W),H=async function(pe){if(pe.Error)U(pe.Error),$(!1);else{let de=x==null?void 0:x.cardName,st=x==null?void 0:x.zipCode;pe.name=de,pe.postal_code=st,pe.isCardSave=`${Fe}`,pe.isCharge=!0,pe.posSalesIdEncode=D==null?void 0:D.data.data.posSalesIdEncode,xt.emit("sendMessage",pe),xt.on(D==null?void 0:D.data.data.posSalesIdEncode,fe=>{if(Sn(fe==null?void 0:fe.data)){let it=JSON.parse(fe.data);it!=null&&it.result?(d({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),b(!1),he(it==null?void 0:it.transactionId),Ue(!0),$(!1)):($(!1),U((it==null?void 0:it.message)||"Something went wrong."))}else U("Something went wrong.")})}};if((Z==null?void 0:Z.paymentGateway)===32){let pe={method:"POST",redirect:"follow"};try{let de=await Pn.post(`${Pe}api/v1/widget/generate-session`,pe),st=Number(x==null?void 0:x.expiryYear)%100,fe=x==null?void 0:x.cardNumber;fe=fe==null?void 0:fe.replace(/\s+/g,"");let it=`${fe}=${st}${x==null?void 0:x.expiryMonth} ${x==null?void 0:x.cvv}`,Ye=forge.pki.publicKeyFromPem((ue=(l=de==null?void 0:de.data)==null?void 0:l.data)==null?void 0:ue.publicKeyPem).encrypt(it,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ft=forge.util.encode64(Ye),Ve={"Content-Type":"application/json","x-app-session-key":(se=(je=de.data)==null?void 0:je.data)==null?void 0:se.session_key},qt=JSON.stringify({enc_track2_data:`${ft}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Ee=(Se=de==null?void 0:de.data)==null?void 0:Se.data)==null?void 0:Ee.session_key}`});try{let We=await Pn.post(`${Ht}tokenizer/tokenize`,qt,{headers:Ve}),Ke=JSON.stringify(A(F({},(rt=We==null?void 0:We.data)==null?void 0:rt.data),{isSaveCardChecked:Fe,name:x==null?void 0:x.cardName,postal_code:x==null?void 0:x.zipCode,customer_id:e==null?void 0:e.customerId})),_e=JSON.stringify({pre_sales_id:`${(gt=(nt=D==null?void 0:D.data)==null?void 0:nt.data)==null?void 0:gt.posSalesIdEncode}`,token:`${(Bt=We==null?void 0:We.data)==null?void 0:Bt.data.token}`,json_response:`${Ke}`}),cn={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:_e,redirect:"follow",isChargeviafractal:!0};xt.emit("sendMessage",cn),xt.on("chargeviafractalgateway",et=>{var $t;if(Sn(et==null?void 0:et.data)){let ht=JSON.parse(et==null?void 0:et.data);ht!=null&&ht.result?(he(($t=ht==null?void 0:ht.data)==null?void 0:$t.transactionId),Ue(!0),$(!1)):($(!1),U((ht==null?void 0:ht.message)||"Something went wrong."))}else U("Something went wrong.")})}catch(We){$(!1),U(((m=(Re=We==null?void 0:We.response)==null?void 0:Re.data)==null?void 0:m.message)||(We==null?void 0:We.message)||"Something went wrong.")}}catch(de){$(!1),U(((a=(t=de==null?void 0:de.response)==null?void 0:t.data)==null?void 0:a.message)||(de==null?void 0:de.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(D==null?void 0:D.data.data.dctoken,"PaymentForm",H)}catch(W){$(!1),U(((p=(N=W==null?void 0:W.response)==null?void 0:N.data)==null?void 0:p.message)||(W==null?void 0:W.message)||"Something went wrong.")}}}}else{if(He())return;{$(!0);let E={fractalpayPublicKey:I,label:(M==null?void 0:M.name)||"John Doe",account_number:M==null?void 0:M.accountNumber,routing_number:M==null?void 0:M.routingNumber,bank_name:M==null?void 0:M.bankName,account_type:M==null?void 0:M.accountType,amount:String(qe||0),isSaveAch:we,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:(M==null?void 0:M.companyName)||""};xt.emit("sendMessage",E),xt.on("ach-incoming",j=>{var te;(j==null?void 0:j.status)=="Failed"?typeof(j==null?void 0:j.message)=="object"?Object.values(j==null?void 0:j.message).forEach(X=>{U(X||"Something went wrong")}):U((j==null?void 0:j.message)||"Something went wrong"):(he((te=j==null?void 0:j.data)==null?void 0:te.transaction_id),Ue(!0),$(!1))})}}},kt=async()=>{var Y,l,ue,je,se,Se,Ee,rt,nt,gt,Bt,Re,m,t,a,N,p,P,E,j,te,X,W;Ct();try{let D={fractalpayPublicKey:I,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee},H=await Pn.post(`${Be}get-payment-details`,D);if(Ne((Y=H==null?void 0:H.data)==null?void 0:Y.data),(ue=(l=H==null?void 0:H.data)==null?void 0:l.data)!=null&&ue.paymentGateway||(u(),U("Something went wrong.")),(se=(je=H==null?void 0:H.data)==null?void 0:je.data)!=null&&se.card_list&&((rt=(Ee=(Se=H==null?void 0:H.data)==null?void 0:Se.data)==null?void 0:Ee.card_list)==null?void 0:rt.length)>0){let pe=(Bt=(gt=(nt=H==null?void 0:H.data)==null?void 0:nt.data)==null?void 0:gt.card_list)==null?void 0:Bt.filter(st=>(st==null?void 0:st.card_type)=="Bank"),de=(t=(m=(Re=H==null?void 0:H.data)==null?void 0:Re.data)==null?void 0:m.card_list)==null?void 0:t.filter(st=>(st==null?void 0:st.card_type)!=="Bank");console.log(pe,"hohgohoo",de),(de==null?void 0:de.length)>0&&Q("list"),(pe==null?void 0:pe.length)>0&&k("list"),G(de),zt(pe)}else ve("card");(N=(a=H==null?void 0:H.data)==null?void 0:a.data)!=null&&N.paymentDeviceList&&((E=(P=(p=H==null?void 0:H.data)==null?void 0:p.data)==null?void 0:P.paymentDeviceList)==null?void 0:E.length)>0&&mt((te=(j=H==null?void 0:H.data)==null?void 0:j.data)==null?void 0:te.paymentDeviceList[0]),tt()}catch(D){console.log(D),tt(),U(((W=(X=D==null?void 0:D.response)==null?void 0:X.data)==null?void 0:W.message)||(D==null?void 0:D.message)||"Something went wrong")}},xe=async()=>{let Y=e==null?void 0:e.customerId,l=String(e==null?void 0:e.discount),ue=String(e==null?void 0:e.surcharge),je=String(e==null?void 0:e.tax),se=e==null?void 0:e.merchantPublicKey,Se=e==null?void 0:e.orderID,Ee=String(e==null?void 0:e.amount),rt=at==null?void 0:at.id,nt=at==null?void 0:at.card_type;if(se&&Se&&Ee&&qe)if(Y)if(rt){let Bt={amount:nt==="Bank"?qe:Ee,order_id:Se,customer_id:Y,card_id:rt,fractalpayPublicKey:se,isCardSave:Fe,discount:l,surcharge:ue,tax:je},gt=Bt,{isCardSave:Re}=gt,m=_n(gt,["isCardSave"]),a=Be+(nt==="Bank"?"charge-ach":"charge-by-card"),N={"Content-Type":"application/json"};$(!0),xt.emit("sendMessage",{url:a,body:nt=="Bank"?m:Bt,isChargebycard:!0}),xt.on("charge-by-card",p=>{var P;(p==null?void 0:p.result)==!0||(p==null?void 0:p.status)==!0?(he((P=p.data)==null?void 0:P.transaction_id),Ue(!0),$(!1)):U((p==null?void 0:p.message)||"Something went wrong.")})}else U("Please Select A Card/ACH");else U("Please Select Customer");else U("Something went wrong.")},_t=async()=>{var se,Se,Ee,rt,nt,gt;let Y=e==null?void 0:e.merchantPublicKey,l=e==null?void 0:e.orderID,ue=String(e==null?void 0:e.amount),je=e==null?void 0:e.customerId;if(!(Mt!=null&&Mt.device_id)){U("Please Select A Payment Device");return}if(Y&&l&&ue){$(!0);let Bt={amount:ue,fractalpayPublicKey:Y,customer_order_id:l,device_id:Mt==null?void 0:Mt.device_id,customer_id:je||""};try{let Re=await Pn.post(`${Be}charge-with-reader`,Bt);((se=Re==null?void 0:Re.data)==null?void 0:se.result)==!0?(he((Ee=(Se=Re==null?void 0:Re.data)==null?void 0:Se.data)==null?void 0:Ee.transaction_id),Ue(!0),$(!1)):(U(((rt=Re==null?void 0:Re.data)==null?void 0:rt.message)||"Something went wrong."),$(!1))}catch(Re){U(((gt=(nt=Re==null?void 0:Re.response)==null?void 0:nt.data)==null?void 0:gt.message)||"Something went wrong."),$(!1)}}else U("Something went wrong.")},It=()=>{o==="card"?xe():o==="reader"&&_t()};gi(()=>{ye&&I&&kt()},[I,ye]);let ct=async Y=>{Bn.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){$(!0);try{let ue={card_id:Y,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},je=await Pn.post(`${Be}delete-customer-card`,ue);$(!1),kt(),Bn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(ue){$(!1),Bn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else l.dismiss===Bn.DismissReason.cancel&&Bn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},Jt=Y=>{switch(Y==null?void 0:Y.toLowerCase()){case"visa":return ae;case"mastercard":case"mc":case"m/c":return Je;case"amex":case"american express":case"ae":return Te;case"discover":case"dcvr":return Xe;case"bank":return g;default:return Y}},Wt=()=>{let Y=qe||0;return(Number(e.amount)-Y).toFixed(0)};return console.log(f,"activeinCard","activeinBank",ce),i.createElement(i.Fragment,null,i.createElement(Dt,null),i.createElement(vn,null),i.createElement(Nn,null),i.createElement(i.Fragment,null,i.createElement("button",{className:"paymentBtn",onClick:ge},"Pay"),i.createElement(Ut,{open:ye,onClose:u},Me&&i.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},i.createElement(tn,{error:Me,onClose:u})),$e&&i.createElement(Cn,{onClose:u,tranId:Qe}),!Me&&!$e&&i.createElement(i.Fragment,null,(C||R)&&i.createElement(Ot,{loading:C||R}),i.createElement("div",{className:"frac-card-payment-page frac-form"},i.createElement("div",{className:"parent-pay-container"},i.createElement("span",{className:"request-payment-close-popup",onClick:u},i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},i.createElement("g",{clipPath:"url(#clip0_12425_52336)"},i.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),i.createElement("defs",null,i.createElement("clipPath",{id:"clip0_12425_52336"},i.createElement("rect",{width:"16",height:"16",fill:"white"}))))),i.createElement("div",{className:"pay-main-logo-res"},i.createElement("img",{src:Z==null?void 0:Z.logo,id:"pay-logos"})),i.createElement("div",{className:"pay-container"},i.createElement("div",{className:"pay-header pay-conatiner-one frac-pay-conatiner-one"},i.createElement("div",{className:"pay-conatiner-one-first"},i.createElement("div",{className:"pay-logo-container"},i.createElement("div",{className:"pay-main-logo"},i.createElement("img",{src:Z==null?void 0:Z.logo,id:"pay-logos"})),(w==null?void 0:w.length)>0&&me!=="cardList"&&i.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>ve("cardList")}," ",i.createElement(On,null)," Back")),i.createElement("div",{className:"amt-pay-con"},i.createElement("div",{className:"pay-amount-conatiner"},i.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),i.createElement("div",{className:"frac-card-bank-radio-main"},i.createElement(pn,{label:"Card",amount:(Tt=Number(e==null?void 0:e.amount))==null?void 0:Tt.toFixed(2),value:"card",onChange:De,activetab:me}),(Z==null?void 0:Z.isSkyFiAccount)&&i.createElement(pn,{label:"Bank",amount:(St=Number(qe))==null?void 0:St.toFixed(2),value:"ach",onChange:De,activetab:me})),qe&&qe>0&&(e!=null&&e.pass_fee)?i.createElement("div",{className:"frac-cash-discount-fee"},i.createElement("small",null,me==="card"?"Cash Discount":"Cash Discount Savings"," "),i.createElement("p",null,Ce((Number(e.amount)-qe).toFixed(2)))):null)),i.createElement("div",{className:"pay-conatiner-one-last"},i.createElement("img",{src:c,alt:""}),i.createElement("img",{src:J,alt:""}),"Secure payments powered by Fractal")),i.createElement("div",{className:"pay-tab pay-conatiner-two"},!C&&i.createElement("div",{className:"col-md-12"},i.createElement("div",{id:"payment-form-div"},me!=="cardList"?i.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(w==null?void 0:w.length)>0&&i.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ve("cardList")}," ",i.createElement(On,null)," Back"),(Z==null?void 0:Z.isSkyFiAccount)&&i.createElement("div",{className:"tab"},i.createElement("button",{className:"tablinks",onClick:Y=>{De("card")},style:{border:me==="card"?"1px solid":""}},i.createElement("i",{className:"fas fa-credit-card me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Card"),i.createElement("button",{className:"tablinks",onClick:Y=>{De("ach")},style:{border:me==="ach"?"1px solid":""}},i.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),i.createElement("div",{className:"res-pay-con"},i.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},i.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),i.createElement("strong",{className:"pay-amount"},"$",(Le=Number(e==null?void 0:e.amount))==null?void 0:Le.toFixed(2))),me!="ach"&&i.createElement("div",null,i.createElement("div",null,i.createElement("img",{src:ae,alt:"",width:35,style:{paddingRight:"5px"}}),i.createElement("img",{src:Je,width:35,alt:""})),i.createElement("div",null,i.createElement("img",{src:Te,alt:"",width:35,style:{paddingRight:"5px"}}),i.createElement("img",{src:Xe,width:35,alt:""})))),qe&&qe>0&&i.createElement("div",{className:"res-pay-con frac-cash-discount"},i.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),i.createElement("div",null,"$",qe))):i.createElement("div",null,i.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",Z==null?void 0:Z.customer_name),i.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",o==="card"?"Cards/Banks":"Readers"," "),i.createElement("div",{className:"res-pay-con"},i.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},i.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),i.createElement("strong",{className:"pay-amount"},"$",(Vt=Number(e==null?void 0:e.amount))==null?void 0:Vt.toFixed(2))),i.createElement("div",null,i.createElement("div",null,i.createElement("img",{src:ae,alt:"",width:35,style:{paddingRight:"5px"}}),i.createElement("img",{src:Je,width:35,alt:""})),i.createElement("div",null,i.createElement("img",{src:Te,alt:"",width:35,style:{paddingRight:"5px"}}),i.createElement("img",{src:Xe,width:35,alt:""}))))),i.createElement("div",{id:"card",style:{display:me==="card"?"block":"none"},className:"tabcontent"},i.createElement("div",{className:"frac-card-payment"},i.createElement("div",{className:"frac-heading-card-wrap"},i.createElement("div",{className:"frac-backarrow"},(w==null?void 0:w.length)>0&&f==="form"&&i.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Q("list")}," ",i.createElement(On,null)),qe&&qe>0&&i.createElement("div",{className:"res-pay-con frac-cash-discount"},i.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),i.createElement("div",null,"$",qe))),i.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),me!="ach"&&i.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},i.createElement("img",{src:ae,alt:"",width:33}),i.createElement("img",{src:Je,width:33,alt:""}),i.createElement("img",{src:Te,alt:"",width:33}),i.createElement("img",{src:Xe,width:33,alt:""}))),f==="list"?i.createElement(i.Fragment,null,i.createElement(fn,{listHeading:"Cards",paymentGateway:Z==null?void 0:Z.paymentGateway,ListItems:w,selectedCard:at,setSelectedCard:pt,handleDeleteCard:ct,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{Q("form")}}),i.createElement("div",{className:"form-group",style:{padding:"0"}},i.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:It},Ce((Kt=Number(e==null?void 0:e.amount))==null?void 0:Kt.toFixed(2))))):i.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:yt},i.createElement("div",{className:"ach-scrl",style:{minHeight:Z!=null&&Z.isSkyFiAccount&&(w==null?void 0:w.length)>0?"444px":Z!=null&&Z.isSkyFiAccount&&(w==null?void 0:w.length)==0?"456px":(w==null?void 0:w.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},i.createElement("div",{className:"form-group"},i.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),i.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"John Doe",value:(x==null?void 0:x.cardName)||"",onChange:Y=>{let l=Y.target.value;/^[a-zA-Z\s]*$/.test(l)&&re("cardName",l)}}),(v==null?void 0:v.cardName)&&i.createElement("span",{className:"error-span"},v==null?void 0:v.cardName)),i.createElement("div",{className:"form-group"},i.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),i.createElement("div",{className:"toggle-num-wrapper"},i.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=>Oe(Y),"data-token":"card_number"}),i.createElement("div",{className:"card-crdi card-expiry-new"},i.createElement("div",{className:"exp-date-year-container"},i.createElement("div",{className:"exp-date form-group"},i.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=>re("expiryMonth",Y.target.value)})),i.createElement("div",{className:"exp-year form-group"},i.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=>re("expiryYear",Y.target.value)})),i.createElement("div",{className:"security-digit form-group"},i.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=>re("cvv",Y.target.value)})))),(v==null?void 0:v.cardNumber)&&i.createElement("span",{className:"error-span"},v==null?void 0:v.cardNumber),i.createElement("p",{style:{margin:"0"}},v!=null&&v.expiryMonth||v!=null&&v.expiryYear?i.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},v==null?void 0:v.expiryMonth):"",(v==null?void 0:v.cvv)&&i.createElement("span",{className:"error-span"},v==null?void 0:v.cvv)))),i.createElement("div",{className:"form-group"},i.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),i.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(Xt=e==null?void 0:e.orderID)!=null?Xt:"",style:{background:"#F6F6F7",color:"#727272"}})),i.createElement("div",{className:"form-group"},i.createElement("label",{htmlFor:"zip"},"ZIP"),i.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(ot=x==null?void 0:x.zipCode)!=null?ot:"",onChange:Y=>re("zipCode",Y.target.value)}),(v==null?void 0:v.zipCode)&&i.createElement("span",{className:"error-span"},v==null?void 0:v.zipCode)),(e==null?void 0:e.customerId)&&i.createElement("div",{className:"form-group"},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},i.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:Fe,onChange:Y=>b(Y.target.checked)}),i.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),i.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},i.createElement("g",{clipPath:"url(#clip0_12420_50192)"},i.createElement("rect",{width:"20",height:"20",fill:"white"}),i.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),i.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"})),i.createElement("defs",null,i.createElement("clipPath",{id:"clip0_12420_50192"},i.createElement("rect",{width:"20",height:"20",fill:"white"}))))))),i.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:"0"}},(Z==null?void 0:Z.paymentDeviceList)&&((nn=Z==null?void 0:Z.paymentDeviceList)==null?void 0:nn.length)>0&&i.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>ne(!Ge)},Ge?"Pay With Reader":"Pay With Card"),i.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ce((Ft=Number(e==null?void 0:e.amount))==null?void 0:Ft.toFixed(2)))))),i.createElement("div",{id:"ach",style:{display:me==="ach"?"block":"none"},className:"tabcontent"},i.createElement("div",{className:"frac-card-payment"},i.createElement("div",{className:"frac-heading-card-wrap"},i.createElement("div",{className:"frac-backarrow"},(ke==null?void 0:ke.length)>0&&ce==="form"&&i.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>k("list")}," ",i.createElement(On,null)),qe&&qe>0&&i.createElement("div",{className:"res-pay-con frac-cash-discount"},i.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),i.createElement("div",null,"$",Wt()))),i.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),ce==="list"?i.createElement(i.Fragment,null,i.createElement(fn,{listHeading:"Banks",paymentGateway:Z==null?void 0:Z.paymentGateway,ListItems:ke,selectedCard:at,setSelectedCard:pt,handleDeleteCard:ct,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{k("form")}}),i.createElement("div",{className:"form-group",style:{padding:"0"}},i.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:It},Ce((ze=Number(qe))==null?void 0:ze.toFixed(2))))):i.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:yt},i.createElement("div",{className:"ach-scrl",style:{minHeight:Z!=null&&Z.isSkyFiAccount&&(w==null?void 0:w.length)>0?"444px":Z!=null&&Z.isSkyFiAccount&&(w==null?void 0:w.length)==0?"436px":(w==null?void 0:w.length)>0?"462px":"520px",maxHeight:Z!=null&&Z.isSkyFiAccount&&(w==null?void 0:w.length)>0?"444px":((w==null?void 0:w.length)>0,"380px")}},i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),i.createElement("input",{type:"text",id:"nameonaccount",className:"form-control",maxLength:100,placeholder:"John Doe",name:"name",value:(ut=M==null?void 0:M.name)!=null?ut:"",onChange:Ze}),(q==null?void 0:q.name)&&i.createElement("span",{className:"error-span"},q==null?void 0:q.name)),i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"routingnumber"},"Routing number"),i.createElement("input",{type:"text",id:"routingnumber",className:"form-control",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(rn=M==null?void 0:M.routingNumber)!=null?rn:"",onChange:Ze}),(q==null?void 0:q.routingNumber)&&i.createElement("span",{className:"error-span"},q==null?void 0:q.routingNumber)),i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"accountnumber"},"Account number"),i.createElement("input",{type:"text",id:"accountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Et=M==null?void 0:M.accountNumber)!=null?Et:"",onChange:Ze}),(q==null?void 0:q.accountNumber)&&i.createElement("span",{className:"error-span"},q==null?void 0:q.accountNumber)),i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),i.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(en=M==null?void 0:M.confirmAccountNumber)!=null?en:"",onChange:Ze}),(q==null?void 0:q.confirmAccountNumber)&&i.createElement("span",{className:"error-span"},q==null?void 0:q.confirmAccountNumber)),i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"bankname"},"Bank name"),i.createElement("input",{type:"text",id:"bankname",className:"form-control",maxLength:100,placeholder:"My Bank",name:"bankName",value:(At=M==null?void 0:M.bankName)!=null?At:"",onChange:Ze}),(q==null?void 0:q.bankName)&&i.createElement("span",{className:"error-span"},q==null?void 0:q.bankName)),((M==null?void 0:M.accountType)==="business saving"||(M==null?void 0:M.accountType)==="business checking")&&i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"companyName"},"Company name"),i.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(an=M==null?void 0:M.companyName)!=null?an:"",onChange:Ze}),(q==null?void 0:q.companyName)&&i.createElement("span",{className:"error-span"},q==null?void 0:q.companyName)),i.createElement("div",{className:"form-group mb-4"},i.createElement("label",{htmlFor:"accounttype"},"Select account type"),i.createElement("select",{name:"accountType",id:"accounttype",className:"form-control",value:(sn=M==null?void 0:M.accountType)!=null?sn:"",onChange:Ze},i.createElement("option",{value:""},"Select account"),Fn.map(Y=>i.createElement("option",{key:Y.value,value:Y.value},Y.label)))),(e==null?void 0:e.customerId)&&i.createElement("div",{className:"form-group mb-4 save-ach-div",style:{paddingTop:"5px"}},i.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:we,onChange:Y=>oe(Y.target.checked)}),i.createElement("label",{htmlFor:"saveACH"},"Save ACH")),we&&i.createElement("div",{className:"form-group mb-4",style:{fontSize:"12px",color:"#727272"}},i.createElement("p",null,"If checked, I agree for ",i.createElement("b",null,"ecommerce")," to have my permission to charge this credit card for agreed upon purchases in the future."))),i.createElement("div",{className:"form-group "},i.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Ce((ln=Number(qe))==null?void 0:ln.toFixed(2))))))))))))))))}import s,{useEffect as pi,useState as Gt}from"react";import Tn from"axios";import Xn from"sweetalert2";import{IoArrowBack as fi}from"react-icons/io5";function Ri(e){var qe,le,Z,Ne,Qe,he,Ct,tt;let[C,ee]=Gt(!1),[R,$]=Gt(!1),[Me,U]=Gt(""),[$e,Ue]=Gt(!1),[ye,O]=Gt(!1),[me,ve]=Gt("card"),[o,y]=Gt(!1),f=e.merchantPublicKey,Q=ie+"widget/mc-img.svg",ce=ie+"widget/visa-img.svg",k=ie+"widget/ae-img.svg",Ge=ie+"widget/discover-img.svg",ne=ie+"widget/card.svg",Fe=ie+"widget/Trash.svg",b=ie+"widget/bank.svg",we=ie+"widget/secure-img.png",oe=ie+"widget/pov-by.png",[I,Je]=Gt(),[ae,Te]=Gt({}),[Xe,Pt]=Gt([]),[B,g]=Gt(),[c,J]=Gt(void 0),[L,x]=Gt(),[d,v]=Gt(""),S=(z,u)=>{let ge=(parseFloat(u)||0)/100,De=z/(1+ge);return Math.round(De*100)/100};pi(()=>{if(e!=null&&e.pass_fee){let z=S(e==null?void 0:e.amount,e==null?void 0:e.surcharge);J(z)}},[e==null?void 0:e.pass_fee]);let M=()=>ee(!0),_=()=>ee(!1),q=()=>{O(!1),ve("card"),$(!1),U(""),Ue(!1),v(""),Je({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Te({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),y(!1),g({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},h=()=>O(!0),w=(z,u)=>{let ge=z;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(ge)){(u===""||/^[0-9]+$/.test(u))&&(Te(re=>A(F({},re),{[ge]:""})),Je(re=>A(F({},re),{[ge]:u})));return}Te(re=>A(F({},re),{[ge]:""})),Je(re=>A(F({},re),{[ge]:u}))},G=z=>{let ge=z.target.value.replace(/\D/g,""),De="";/^3[47]/.test(ge)?De=ge.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Oe,Ze,wt,He)=>[Ze,wt,He].filter(Boolean).join(" ")):De=ge.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Oe,Ze,wt,He,yt)=>[Ze,wt,He,yt].filter(Boolean).join(" ")),Te(re=>A(F({},re),{cardNumber:""})),Je(re=>A(F({},re),{cardNumber:De}))},ke=()=>{var re,Oe,Ze,wt,He,yt;let z={},u=I,ge=parseInt((u==null?void 0:u.expiryMonth)||"",10),De=(u==null?void 0:u.expiryYear)||"";if((re=u==null?void 0:u.cardName)!=null&&re.trim()||(z.cardName="Card name is required"),(Oe=u==null?void 0:u.cardNumber)!=null&&Oe.trim()||(z.cardNumber="Card number is required"),(!((Ze=u==null?void 0:u.expiryMonth)!=null&&Ze.trim())||!((wt=u==null?void 0:u.expiryYear)!=null&&wt.trim())||isNaN(ge)||ge<1||ge>12||De.length!==4)&&(z.expiryMonth="Invalid Expiration Date."),(He=u==null?void 0:u.cvv)!=null&&He.trim()||(z.cvv="CVV is required"),(yt=u==null?void 0:u.zipCode)!=null&&yt.trim()||(z.zipCode="ZIP code is required"),u!=null&&u.expiryMonth&&(u!=null&&u.expiryYear)&&u.expiryMonth.length<=2&&u.expiryYear.length===4){let kt=parseInt(u.expiryMonth,10),xe=parseInt(u.expiryYear,10),_t=new Date,It=_t.getMonth()+1,ct=_t.getFullYear();(xe<ct||xe===ct&&kt<It)&&(z.expiryMonth="Card is expired")}return Te(z),Object.keys(z).length>0},zt=async z=>{var u,ge,De,re,Oe,Ze,wt,He,yt,kt,xe,_t,It,ct,Jt,Wt,Tt,St,Le;if(z.preventDefault(),me=="card"){if(ke())return;{let Kt=DatacapWebToken.validateCardNumber(I==null?void 0:I.cardNumber.replaceAll(" ","")),Xt=DatacapWebToken.validateExpirationDate(I==null?void 0:I.expiryMonth,I==null?void 0:I.expiryYear),ot=DatacapWebToken.validateCVV(I==null?void 0:I.cvv),nn={};if(Kt||(nn.cardNumber="Invalid card Number"),Xt||(nn.expiryMonth="Invalid Expiration Date."),ot||(nn.cvv="Invalid CVV"),Te(nn),Kt&&ot&&Xt){$(!0);try{let Ft=async function(ze){if(ze.Error)U(ze.Error),$(!1);else{let ut=I==null?void 0:I.cardName,rn=I==null?void 0:I.zipCode;ze.name=ut,ze.postal_code=rn,ze.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,ze.amount=e==null?void 0:e.amount,ze.order_id=e==null?void 0:e.orderID,ze.preAuth_id="",ze.isCardSave=o,ze.customer_id=e==null?void 0:e.customerId,ze.link_token="",ze.gateway_id=L==null?void 0:L.paymentGateway,ze.discount=e==null?void 0:e.discount,ze.tax=e==null?void 0:e.tax,ze.surcharge=e==null?void 0:e.surcharge,ze.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let en={method:"POST",body:JSON.stringify(ze),redirect:"follow"};xt.emit("sendMessage",A(F({},en),{isChargePreauth:!0})),xt.on("charge-preauth",At=>{var an;console.log(At,"datdata"),(At==null?void 0:At.status)=="Failed"?($(!1),U((At==null?void 0:At.message)||"Something went wrong. Please try again later.")):(Ue(!0),v((an=At==null?void 0:At.data)==null?void 0:an.transaction_id),$(!1),Je({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((L==null?void 0:L.paymentGateway)===32){let ze={method:"POST",redirect:"follow"};try{let ut=await Tn.post(`${Pe}api/v1/widget/generate-session`,ze),rn=Number(I==null?void 0:I.expiryYear)%100,Et=I==null?void 0:I.cardNumber;Et=Et==null?void 0:Et.replace(/\s+/g,"");let en=`${Et}=${rn}${I==null?void 0:I.expiryMonth} ${I==null?void 0:I.cvv}`,an=forge.pki.publicKeyFromPem((ge=(u=ut==null?void 0:ut.data)==null?void 0:u.data)==null?void 0:ge.publicKeyPem).encrypt(en,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),sn=forge.util.encode64(an),ln={"Content-Type":"application/json","x-app-session-key":(re=(De=ut.data)==null?void 0:De.data)==null?void 0:re.session_key},Y=JSON.stringify({enc_track2_data:`${sn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Ze=(Oe=ut==null?void 0:ut.data)==null?void 0:Oe.data)==null?void 0:Ze.session_key}`});try{let l=await Tn.post(`${Ht}tokenizer/tokenize`,Y,{headers:ln}),ue=JSON.stringify(A(F({},(wt=l==null?void 0:l.data)==null?void 0:wt.data),{name:I==null?void 0:I.cardName,postal_code:I==null?void 0:I.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(yt=(He=l==null?void 0:l.data)==null?void 0:He.data)==null?void 0:yt.token}`,fractalpayPublicKey:f,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:o,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:I==null?void 0:I.expiryYear,ExpirationMonth:I==null?void 0:I.expiryMonth,CVV:I==null?void 0:I.cvv,Last4:(xe=(kt=l==null?void 0:l.data)==null?void 0:kt.data)==null?void 0:xe.last4,Brand:(It=(_t=l==null?void 0:l.data)==null?void 0:_t.data)==null?void 0:It.brand,gateway_id:L==null?void 0:L.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),se={method:"POST",headers:{"Content-Type":"application/json"},body:ue,redirect:"follow"};xt.emit("sendMessage",A(F({},se),{isFractalPreauth:!0})),xt.on("fractal-charge-preauth",Se=>{var Ee;(Se==null?void 0:Se.status)=="Failed"?($(!1),U((Se==null?void 0:Se.message)||"Something went wrong , Try again later")):(v((Ee=Se==null?void 0:Se.data)==null?void 0:Ee.transaction_id),Ue(!0),$(!1))})}catch(l){console.log(l),$(!1),U(((Jt=(ct=l==null?void 0:l.response)==null?void 0:ct.data)==null?void 0:Jt.message)||(l==null?void 0:l.message)||"Something went wrong , Try again later")}}catch(ut){$(!1),U(((Tt=(Wt=ut==null?void 0:ut.response)==null?void 0:Wt.data)==null?void 0:Tt.message)||(ut==null?void 0:ut.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(L==null?void 0:L.dctoken,"PaymentForm",Ft)}catch(Ft){$(!1),U(((Le=(St=Ft==null?void 0:Ft.response)==null?void 0:St.data)==null?void 0:Le.message)||(Ft==null?void 0:Ft.message)||"Something went wrong.")}}}}},at=async()=>{var z,u,ge,De,re,Oe,Ze,wt,He,yt,kt,xe,_t,It,ct,Jt,Wt,Tt;M();try{let St={fractalpayPublicKey:f,customer_id:e==null?void 0:e.customerId,preauth:!0},Le=await Tn.post(`${Be}get-payment-details`,St);if(x((z=Le==null?void 0:Le.data)==null?void 0:z.data),(ge=(u=Le==null?void 0:Le.data)==null?void 0:u.data)!=null&&ge.paymentGateway||(q(),U("Something went wrong.")),(re=(De=Le==null?void 0:Le.data)==null?void 0:De.data)!=null&&re.card_list&&((wt=(Ze=(Oe=Le==null?void 0:Le.data)==null?void 0:Oe.data)==null?void 0:Ze.card_list)==null?void 0:wt.length)>0){Pt((yt=(He=Le==null?void 0:Le.data)==null?void 0:He.data)==null?void 0:yt.card_list),ve("cardList");let Vt=(_t=(xe=(kt=Le==null?void 0:Le.data)==null?void 0:kt.data)==null?void 0:xe.card_list)==null?void 0:_t.filter(Kt=>(Kt==null?void 0:Kt.primary_card)==1);Vt!=null&&Vt[0]&&((It=Vt==null?void 0:Vt[0])==null?void 0:It.payment_method_type)==((Jt=(ct=Le==null?void 0:Le.data)==null?void 0:ct.data)==null?void 0:Jt.paymentGateway)&&g(Vt[0])}else ve("card");_()}catch(St){console.log(St),_(),U(((Tt=(Wt=St==null?void 0:St.response)==null?void 0:Wt.data)==null?void 0:Tt.message)||(St==null?void 0:St.message)||"Something went wrong")}},pt=async()=>{var kt,xe,_t,It,ct,Jt,Wt;let z=e==null?void 0:e.customerId,u=e==null?void 0:e.discount,ge=e==null?void 0:e.surcharge,De=e==null?void 0:e.tax,re=e==null?void 0:e.merchantPublicKey,Oe=e==null?void 0:e.orderID,Ze=e==null?void 0:e.amount,wt=B==null?void 0:B.id,He=B==null?void 0:B.card_type;if(re&&Oe&&Ze)if(z)if(wt){let Tt={amount:Ze,order_id:Oe,customer_id:z,card_id:wt,fractalpayPublicKey:re,isCardSave:He!="Bank",discount:u,surcharge:ge,tax:De},yt=Tt,{isCardSave:St}=yt,Le=_n(yt,["isCardSave"]),Kt=Be+"authorize-by-card",Xt={"Content-Type":"application/json"};$(!0);try{let ot=await Tn.post(Kt,He=="Bank"?Le:Tt,{headers:Xt});(kt=ot==null?void 0:ot.data)!=null&&kt.result&&(v((_t=(xe=ot==null?void 0:ot.data)==null?void 0:xe.data)==null?void 0:_t.transaction_id),Ue(!0),$(!1))}catch(ot){$(!1),console.log(ot),U(((ct=(It=ot==null?void 0:ot.response)==null?void 0:It.data)==null?void 0:ct.message)||((Wt=(Jt=ot==null?void 0:ot.response)==null?void 0:Jt.data)==null?void 0:Wt.status)||"Something went erong")}}else U("Please Select A Card/ACH");else U("Please Select Customer");else U("Something went wrong.")};pi(()=>{ye&&f&&at()},[f,ye]);let Mt=async z=>{Xn.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 u=>{if(u.isConfirmed){$(!0);try{let ge={card_id:z,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},De=await Tn.post(`${Be}delete-customer-card`,ge);$(!1),at(),Xn.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(ge){$(!1),Xn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},mt=z=>{switch(z==null?void 0:z.toLowerCase()){case"visa":return ce;case"mastercard":case"mc":case"m/c":return Q;case"amex":case"american express":case"ae":return k;case"discover":case"dcvr":return Ge;case"bank":return b;default:return z}};return s.createElement(s.Fragment,null,s.createElement(Dt,null),s.createElement(vn,null),s.createElement(s.Fragment,null,s.createElement("button",{className:"paymentBtn",onClick:h},"PreAuth Payment"),s.createElement(Ut,{open:ye,onClose:q},Me&&s.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},s.createElement(tn,{error:Me,onClose:q})),$e&&s.createElement(Cn,{onClose:q,tranId:d}),!Me&&!$e&&s.createElement(s.Fragment,null,(C||R)&&s.createElement(Ot,{loading:C||R}),s.createElement("div",null,s.createElement("div",{className:"frac-card-payment-page frac-form"},s.createElement("div",{className:"parent-pay-container"},s.createElement("span",{className:"request-payment-close-popup",onClick:q},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12425_52336)"},s.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12425_52336"},s.createElement("rect",{width:"16",height:"16",fill:"white"}))))),s.createElement("div",{className:"pay-container"},s.createElement("div",{className:"pay-header pay-conatiner-one"},s.createElement("div",{className:"pay-conatiner-one-first"},s.createElement("div",{className:"pay-logo-container"},s.createElement("div",{className:"pay-main-logo"},s.createElement("img",{src:L==null?void 0:L.logo,id:"pay-logos"})),s.createElement("h1",{className:"pay-heading"},"Pay"),(Xe==null?void 0:Xe.length)>0&&me!=="cardList"&&s.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>ve("cardList")}," ",s.createElement(fi,null)," Back")),s.createElement("div",{className:"amt-pay-con"},s.createElement("div",{className:"pay-amount-conatiner"},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ce((qe=Number(e==null?void 0:e.amount))==null?void 0:qe.toFixed(2))),c&&c>0&&s.createElement("div",{style:{width:"80%"},className:"frac-cash-discount"},s.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),s.createElement("div",null,Ce(c.toFixed(2))))),me!="ach"&&s.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},s.createElement("img",{src:ce,alt:"",width:33}),s.createElement("img",{src:Q,width:33,alt:""}),s.createElement("img",{src:k,alt:"",width:33}),s.createElement("img",{src:Ge,width:33,alt:""})))),s.createElement("div",{className:"pay-conatiner-one-last"},s.createElement("img",{src:we,alt:""}),s.createElement("img",{src:oe,alt:""}),"Secure payments powered by Fractal"),s.createElement("div",null)),!C&&s.createElement("div",{className:"pay-tab pay-conatiner-two"},s.createElement("div",{className:"col-md-12"},s.createElement("div",{id:"payment-form-div"},me!=="cardList"?s.createElement("div",null,(Xe==null?void 0:Xe.length)>0&&s.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ve("cardList")}," ",s.createElement(fi,null)," Back"),s.createElement("div",{className:""},s.createElement("div",{className:"res-pay-con"},s.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ce((le=Number(e==null?void 0:e.amount))==null?void 0:le.toFixed(2)))),s.createElement("div",null,s.createElement("div",null,s.createElement("img",{src:ce,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:Q,width:35,alt:""})),s.createElement("div",null,s.createElement("img",{src:k,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:Ge,width:35,alt:""})))),c&&c>0&&s.createElement("div",{className:"res-pay-con frac-cash-discount"},s.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),s.createElement("div",null,Ce(c.toFixed(2)))))):s.createElement("div",null,s.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",L==null?void 0:L.customer_name),s.createElement("div",{className:"res-pay-con"},s.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},s.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),s.createElement("strong",{className:"pay-amount"},Ce((Z=Number(e==null?void 0:e.amount))==null?void 0:Z.toFixed(2)))),s.createElement("div",null,s.createElement("div",null,s.createElement("img",{src:ce,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:Q,width:35,alt:""})),s.createElement("div",null,s.createElement("img",{src:k,alt:"",width:35,style:{paddingRight:"5px"}}),s.createElement("img",{src:Ge,width:35,alt:""})))),s.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),s.createElement("div",{style:{display:me==="cardList"?"block":"none"},className:"tabcontent"},s.createElement("div",{className:"card-lint-div-in"},s.createElement("div",{className:"card-list-div"},(L==null?void 0:L.card_list)&&((Ne=L==null?void 0:L.card_list)==null?void 0:Ne.length)>0&&((Qe=L==null?void 0:L.card_list)==null?void 0:Qe.map((z,u)=>s.createElement("div",{className:"card-list-single-div",key:u},s.createElement("div",{className:"card-number-radio"},s.createElement("input",{disabled:(L==null?void 0:L.paymentGateway)!=(z==null?void 0:z.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:B===z,onChange:ge=>g(z)}),s.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",z==null?void 0:z.cardlastfourdigit),s.createElement("h6",{className:"card-expiry-date"},z==null?void 0:z.expmonth,"/",z==null?void 0:z.expyear)),s.createElement("div",{className:"card-number-radio"},s.createElement("span",{className:"visa-card"},s.createElement("img",{src:mt(z==null?void 0:z.card_type),alt:""})),s.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>Mt(z==null?void 0:z.id)},s.createElement("img",{src:Fe,alt:""}))))))),s.createElement("div",{className:"pay-with-other-card ",onClick:()=>ve("card")},"Authorize With Other Card",s.createElement("img",{src:ne,alt:""}))),s.createElement("div",{className:"form-group"},s.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:pt},Ce((he=Number(e==null?void 0:e.amount))==null?void 0:he.toFixed(2))))),s.createElement("div",{id:"card",style:{display:me==="card"?"block":"none"},className:"tabcontent"},s.createElement("form",{id:"PaymentForm",onSubmit:zt},s.createElement("div",{className:"ach-scrl",style:{minHeight:(Xe==null?void 0:Xe.length)>0?"462px":"520px",overflow:"auto",marginRight:"5px"}},s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"cardHolderName"},"Name on Card"),s.createElement("input",{type:"text",className:"form-control",placeholder:"John Doe",value:(I==null?void 0:I.cardName)||"",onChange:z=>{let u=z.target.value;/^[a-zA-Z\s]*$/.test(u)&&w("cardName",u)}}),(ae==null?void 0:ae.cardName)&&s.createElement("span",{className:"error-span"},ae==null?void 0:ae.cardName)),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"cardNumber"},"Card Number"),s.createElement("div",{className:"toggle-num-wrapper"},s.createElement("input",{className:"form-control card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(I==null?void 0:I.cardNumber)||"",onChange:z=>G(z),"data-token":"card_number"}),s.createElement("div",{className:"card-crdi card-expiry-new"},s.createElement("div",{className:"exp-date-year-container"},s.createElement("div",{className:"exp-date form-group"},s.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(I==null?void 0:I.expiryMonth)||"",onChange:z=>w("expiryMonth",z.target.value)})),s.createElement("div",{className:"exp-year form-group"},s.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(I==null?void 0:I.expiryYear)||"",onChange:z=>w("expiryYear",z.target.value)})),s.createElement("div",{className:"security-digit form-group"},s.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(I==null?void 0:I.cvv)||"",onChange:z=>w("cvv",z.target.value)})))),(ae==null?void 0:ae.cardNumber)&&s.createElement("span",{className:"error-span"},ae==null?void 0:ae.cardNumber),s.createElement("p",{style:{margin:"0"}},ae!=null&&ae.expiryMonth||ae!=null&&ae.expiryYear?s.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},ae==null?void 0:ae.expiryMonth):"",(ae==null?void 0:ae.cvv)&&s.createElement("span",{className:"error-span"},ae==null?void 0:ae.cvv)))),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),s.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"Enter Order id",disabled:!0,value:e==null?void 0:e.orderID,onChange:z=>w("orderId",z.target.value),style:{background:"#F6F6F7",color:"#727272"}})),s.createElement("div",{className:"form-group"},s.createElement("label",{htmlFor:"zip"},"ZIP"),s.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(Ct=I==null?void 0:I.zipCode)!=null?Ct:"",onChange:z=>w("zipCode",z.target.value)}),(ae==null?void 0:ae.zipCode)&&s.createElement("span",{className:"error-span"},ae==null?void 0:ae.zipCode)),(e==null?void 0:e.customerId)&&s.createElement("div",{className:"form-group"},s.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},s.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:o,onChange:z=>y(z.target.checked)}),s.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),s.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),s.createElement("div",{className:"frac-tooltip-wrapper"},s.createElement("div",{className:"frac-tooltip-icon"},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},s.createElement("g",{clipPath:"url(#clip0_12420_50192)"},s.createElement("rect",{width:"20",height:"20",fill:"white"}),s.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),s.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_12420_50192"},s.createElement("rect",{width:"20",height:"20",fill:"white"}))))),s.createElement("div",{className:"frac-tooltip-text"},s.createElement("p",null,"If checked, I agree to give the ",s.createElement("b",null,(L==null?void 0:L.bname)||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),s.createElement("div",{className:"form-group",style:{marginTop:"20px",padding:0}},s.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ce((tt=Number(e==null?void 0:e.amount))==null?void 0:tt.toFixed(2)))))))))))))))))}import be,{useEffect as ia,useRef as qn,useState as wn}from"react";import aa from"sweetalert2";import Mn from"axios";import ea from"react";function Qn(){let e="#000",C="#fff",ee="#212529",R="#dee2e6";return ea.createElement("style",null,`
|
|
1218
|
+
}`)}function on(e,ae,oe){e.preventDefault();let Y={type:"preview.compiledcheck",other:{msg:"Payment success!",status:ae==="close",data:{tran_id:oe,key:ae}}};console.log("message:",Y),window.parent.postMessage(Y,"*")}function dn({onClose:e,tranId:ae}){return Ie.createElement(Ie.Fragment,null,Ie.createElement(An,null),Ie.createElement("div",{className:"payment-msg-container"},Ie.createElement("div",{className:"charge-payment-success-container"},Ie.createElement("div",{className:"charge-payment-success-tick-div"},Ie.createElement("div",{className:"charge-payment-success-tick"},Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},Ie.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"})))),Ie.createElement("h6",{className:"charge-payment-success-text"},"Your charge",Ie.createElement("br",null),"was successful"),Ie.createElement("h6",{className:"charge-payment-success-subtext"},"We\u2019ve processed your charge"),Ie.createElement("div",{className:"charge-success-payment-button-div"},Ie.createElement("button",{className:"charge-success-btn1",onClick:oe=>on(oe,"print",ae)},Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},Ie.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"}),Ie.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"),Ie.createElement("button",{className:"charge-success-btn1",onClick:oe=>on(oe,"share",ae)},Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},Ie.createElement("g",{clipPath:"url(#clip0_12420_50683)"},Ie.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"})),Ie.createElement("defs",null,Ie.createElement("clipPath",{id:"clip0_12420_50683"},Ie.createElement("rect",{width:"16",height:"16",fill:"white",transform:"translate(0.5)"})))),"Send receipt"))),Ie.createElement("div",{className:"charge-payment-success-btn-div"},Ie.createElement("button",{className:"charge-payment-success-btn1",onClick:oe=>on(oe,"tran",ae)},"Go to Transactions"),Ie.createElement("button",{className:"charge-payment-success-btn2",onClick:oe=>{e(),on(oe,"close",ae)}},"Close"))))}import xn from"sweetalert2";import{IoArrowBack as Mn}from"react-icons/io5";import{io as ri}from"socket.io-client";var li=ri(Se,{transports:["websocket"],withCredentials:!1}),Je=li;function si(e){var Pt,ct,ue,Ft,Mt,Zt,nt,Dt,zt,Ze,Re,Rt,$t,en,xt,Wt,rn,ln;let[ae,oe]=Xe(!1),[Ae,Y]=Xe(!1),[$e,T]=Xe(""),[gt,ze]=Xe(!1),[ee,R]=Xe(!1),[W,re]=Xe("card"),[i,y]=Xe("card"),[u,q]=Xe("form"),[Z,be]=Xe("form"),[Ge,Ve]=Xe(!0),[Pe,he]=Xe(!1),[ce,kt]=Xe(!1),k=e.merchantPublicKey,je=de+"widget/mc-img.svg",V=de+"widget/visa-img.svg",Ue=de+"widget/ae-img.svg",Be=de+"widget/discover-img.svg",At=de+"widget/card.svg",_=de+"widget/Trash.svg",m=de+"widget/bank.svg",c=de+"widget/secure-img.png",z=de+"widget/pov-by.png",v=de+"widget/pax.svg",[g,r]=Xe(),[f,p]=Xe({}),[x,b]=Xe(),[L,h]=Xe({}),[C,B]=Xe([]),[Fe,Nt]=Xe([]),[ot,st]=Xe(),[bt,tt]=Xe(),[xe,G]=Xe(Number(e==null?void 0:e.amount));console.log(ot,"selectedCard");let[I,ne]=Xe(),[Ke,D]=Xe(""),mt=()=>oe(!0),Oe=()=>oe(!1),N=(S,o)=>{let E=(parseFloat(o)||0)/100,ke=S/(1+E);return Math.round(ke*100)/100};Vn(()=>{if(ee){let S=N(e==null?void 0:e.amount,(e==null?void 0:e.surcharge)||0);G(S)}},[ee,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let s=()=>{R(!1),re("card"),T(""),ze(!1),D(""),b({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),h({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),r({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),p({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),kt(!1),he(!1),st({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),tt({}),G(0),y("card"),Ve(!0),be("form"),q("form"),Y(!1),oe(!1),Nt([]),B([])},J=()=>R(!0),Ce=S=>{re(S)},K=(S,o)=>{let E=S;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(E)){(o===""||/^[0-9]+$/.test(o))&&(p(O=>A(M({},O),{[E]:""})),r(O=>A(M({},O),{[E]:o})));return}p(O=>A(M({},O),{[E]:""})),r(O=>A(M({},O),{[E]:o}))},Ne=S=>{let E=S.target.value.replace(/\D/g,""),ke="";/^3[47]/.test(E)?ke=E.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(le,Me,Ee,We)=>[Me,Ee,We].filter(Boolean).join(" ")):ke=E.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(le,Me,Ee,We,et)=>[Me,Ee,We,et].filter(Boolean).join(" ")),p(O=>A(M({},O),{cardNumber:""})),r(O=>A(M({},O),{cardNumber:ke}))},we=S=>{let{name:o,value:E}=S.target,ke=["routingNumber","accountNumber","confirmAccountNumber"];if(o=="name"){/^[a-zA-Z\s]*$/.test(E)&&(h(O=>A(M({},O),{[o]:""})),b(O=>A(M({},O),{[o]:E})));return}if(ke.includes(o)){(E===""||/^[0-9]+$/.test(E))&&(h(O=>A(M({},O),{[o]:""})),b(O=>A(M({},O),{[o]:E})));return}h(O=>A(M({},O),{[o]:""})),b(O=>A(M({},O),{[o]:E}))},rt=()=>{var O,le,Me,Ee,We,et;let S={},o=g,E=parseInt((o==null?void 0:o.expiryMonth)||"",10),ke=(o==null?void 0:o.expiryYear)||"";if((O=o==null?void 0:o.cardName)!=null&&O.trim()||(S.cardName="Card name is required"),(le=o==null?void 0:o.cardNumber)!=null&&le.trim()||(S.cardNumber="Card number is required"),(!((Me=o==null?void 0:o.expiryMonth)!=null&&Me.trim())||!((Ee=o==null?void 0:o.expiryYear)!=null&&Ee.trim())||isNaN(E)||E<1||E>12||ke.length!==4)&&(S.expiryMonth="Invalid Expiration Date."),(We=o==null?void 0:o.cvv)!=null&&We.trim()||(S.cvv="CVV is required"),(et=o==null?void 0:o.zipCode)!=null&&et.trim()||(S.zipCode="ZIP code is required"),o!=null&&o.expiryMonth&&(o!=null&&o.expiryYear)&&o.expiryMonth.length<=2&&o.expiryYear.length===4){let St=parseInt(o.expiryMonth,10),qe=parseInt(o.expiryYear,10),Bt=new Date,d=Bt.getMonth()+1,l=Bt.getFullYear();(qe<l||qe===l&&St<d)&&(S.expiryMonth="Card is expired")}return p(S),Object.keys(S).length>0},fe=()=>{var E,ke,O,le,Me,Ee,We,et;let S={},o=x;return(E=o==null?void 0:o.name)!=null&&E.trim()||(S.name="Name is required"),(ke=o==null?void 0:o.accountNumber)!=null&&ke.trim()||(S.accountNumber="Account number is required"),(O=o==null?void 0:o.accountNumber)!=null&&O.trim()&&((le=o==null?void 0:o.accountNumber)==null?void 0:le.trim())!==((Me=o==null?void 0:o.confirmAccountNumber)==null?void 0:Me.trim())&&(S.confirmAccountNumber="Account numbers must match"),(Ee=o==null?void 0:o.bankName)!=null&&Ee.trim()||(S.bankName="Bank name is required"),(We=o==null?void 0:o.routingNumber)!=null&&We.trim()||(S.routingNumber="Routing Number is required"),o!=null&&o.routingNumber&&((et=o==null?void 0:o.routingNumber)==null?void 0:et.length)!==9&&(S.routingNumber="Routing number must be 9 digits"),((o==null?void 0:o.accountType)==="business saving"||(o==null?void 0:o.accountType)==="business checking")&&(!(o!=null&&o.companyName)||(o==null?void 0:o.companyName)==="")&&(S.companyName="Company Name is required for business accounts"),h(S),Object.keys(S).length>0},Qe=async S=>{var o,E,ke,O,le,Me,Ee,We,et,St,qe,Bt,d,l,j,U;if(S.preventDefault(),W!=="ach"){if(rt())return;{let Le=DatacapWebToken.validateCardNumber(g==null?void 0:g.cardNumber.replaceAll(" ","")),X=DatacapWebToken.validateExpirationDate(g==null?void 0:g.expiryMonth,g==null?void 0:g.expiryYear),ye=DatacapWebToken.validateCVV(g==null?void 0:g.cvv),se={};if(Le||(se.cardNumber="Invalid card Number"),X||(se.expiryMonth="Invalid Expiration Date."),ye||(se.cvv="Invalid CVV"),p(se),Le&&ye&&X){Y(!0);try{let ge=A(M({},g),{amount:`${e.amount||0}`,fractalpayPublicKey:k,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}),te=await pn.post(`${Se}create-widget-order`,ge),H=async function(Te){if(Te.Error)T(Te.Error),Y(!1);else{let me=g==null?void 0:g.cardName,it=g==null?void 0:g.zipCode;Te.name=me,Te.postal_code=it,Te.isCardSave=`${Pe}`,Te.isCharge=!0,Te.posSalesIdEncode=te==null?void 0:te.data.data.posSalesIdEncode,Je.emit("sendMessage",Te),Je.on(te==null?void 0:te.data.data.posSalesIdEncode,ft=>{if(hn(ft==null?void 0:ft.data)){let vt=JSON.parse(ft.data);vt!=null&&vt.result?(r({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),he(!1),D(vt==null?void 0:vt.transactionId),ze(!0),Y(!1)):(Y(!1),T((vt==null?void 0:vt.message)||"Something went wrong."))}else T("Something went wrong.")})}};if((I==null?void 0:I.paymentGateway)===32){let Te={method:"POST",redirect:"follow"};try{let me=await pn.post(`${Yt}api/v1/widget/generate-session`,Te),it=Number(g==null?void 0:g.expiryYear)%100,ft=g==null?void 0:g.cardNumber;ft=ft==null?void 0:ft.replace(/\s+/g,"");let vt=`${ft}=${it}${g==null?void 0:g.expiryMonth} ${g==null?void 0:g.cvv}`,Ye=forge.pki.publicKeyFromPem((E=(o=me==null?void 0:me.data)==null?void 0:o.data)==null?void 0:E.publicKeyPem).encrypt(vt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),Gt=forge.util.encode64(Ye),Kt={"Content-Type":"application/json","x-app-session-key":(O=(ke=me.data)==null?void 0:ke.data)==null?void 0:O.session_key},qt=JSON.stringify({enc_track2_data:`${Gt}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(Me=(le=me==null?void 0:me.data)==null?void 0:le.data)==null?void 0:Me.session_key}`});try{let _e=await pn.post(`${Ut}tokenizer/tokenize`,qt,{headers:Kt}),ve=JSON.stringify(A(M({},(Ee=_e==null?void 0:_e.data)==null?void 0:Ee.data),{isSaveCardChecked:Pe,name:g==null?void 0:g.cardName,postal_code:g==null?void 0:g.zipCode,customer_id:e==null?void 0:e.customerId})),ie=JSON.stringify({pre_sales_id:`${(et=(We=te==null?void 0:te.data)==null?void 0:We.data)==null?void 0:et.posSalesIdEncode}`,token:`${(St=_e==null?void 0:_e.data)==null?void 0:St.data.token}`,json_response:`${ve}`}),sn={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:ie,redirect:"follow",isChargeviafractal:!0};Je.emit("sendMessage",sn),Je.on("chargeviafractalgateway",Ct=>{var tn;if(hn(Ct==null?void 0:Ct.data)){let at=JSON.parse(Ct==null?void 0:Ct.data);at!=null&&at.result?(D((tn=at==null?void 0:at.data)==null?void 0:tn.transactionId),ze(!0),Y(!1)):(Y(!1),T((at==null?void 0:at.message)||"Something went wrong."))}else T("Something went wrong.")})}catch(_e){Y(!1),T(((Bt=(qe=_e==null?void 0:_e.response)==null?void 0:qe.data)==null?void 0:Bt.message)||(_e==null?void 0:_e.message)||"Something went wrong.")}}catch(me){Y(!1),T(((l=(d=me==null?void 0:me.response)==null?void 0:d.data)==null?void 0:l.message)||(me==null?void 0:me.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(te==null?void 0:te.data.data.dctoken,"PaymentForm",H)}catch(ge){Y(!1),T(((U=(j=ge==null?void 0:ge.response)==null?void 0:j.data)==null?void 0:U.message)||(ge==null?void 0:ge.message)||"Something went wrong.")}}}}else{if(fe())return;{Y(!0);let Le={fractalpayPublicKey:k,label:(x==null?void 0:x.name)||"John Doe",account_number:x==null?void 0:x.accountNumber,routing_number:x==null?void 0:x.routingNumber,bank_name:x==null?void 0:x.bankName,account_type:x==null?void 0:x.accountType,amount:String(xe||0),isSaveAch:ce,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:(x==null?void 0:x.companyName)||""};Je.emit("sendMessage",Le),Je.on("ach-incoming",X=>{var ye;(X==null?void 0:X.status)=="Failed"?typeof(X==null?void 0:X.message)=="object"?Object.values(X==null?void 0:X.message).forEach(se=>{T(se||"Something went wrong")}):T((X==null?void 0:X.message)||"Something went wrong"):(D((ye=X==null?void 0:X.data)==null?void 0:ye.transaction_id),ze(!0),Y(!1))})}}},wt=async()=>{var S,o,E,ke,O,le,Me,Ee,We,et,St,qe,Bt,d,l,j,U,$,Le,X,ye,se,ge;mt();try{let te={fractalpayPublicKey:k,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee},H=await pn.post(`${Se}get-payment-details`,te);if(ne((S=H==null?void 0:H.data)==null?void 0:S.data),(E=(o=H==null?void 0:H.data)==null?void 0:o.data)!=null&&E.paymentGateway||(s(),T("Something went wrong.")),(O=(ke=H==null?void 0:H.data)==null?void 0:ke.data)!=null&&O.card_list&&((Ee=(Me=(le=H==null?void 0:H.data)==null?void 0:le.data)==null?void 0:Me.card_list)==null?void 0:Ee.length)>0){let Te=(St=(et=(We=H==null?void 0:H.data)==null?void 0:We.data)==null?void 0:et.card_list)==null?void 0:St.filter(it=>(it==null?void 0:it.card_type)=="Bank"),me=(d=(Bt=(qe=H==null?void 0:H.data)==null?void 0:qe.data)==null?void 0:Bt.card_list)==null?void 0:d.filter(it=>(it==null?void 0:it.card_type)!=="Bank");console.log(Te,"hohgohoo",me),(me==null?void 0:me.length)>0&&q("list"),(Te==null?void 0:Te.length)>0&&be("list"),B(me),Nt(Te)}else re("card");(j=(l=H==null?void 0:H.data)==null?void 0:l.data)!=null&&j.paymentDeviceList&&((Le=($=(U=H==null?void 0:H.data)==null?void 0:U.data)==null?void 0:$.paymentDeviceList)==null?void 0:Le.length)>0&&tt((ye=(X=H==null?void 0:H.data)==null?void 0:X.data)==null?void 0:ye.paymentDeviceList[0]),Oe()}catch(te){console.log(te),Oe(),T(((ge=(se=te==null?void 0:te.response)==null?void 0:se.data)==null?void 0:ge.message)||(te==null?void 0:te.message)||"Something went wrong")}},ht=async()=>{let S=e==null?void 0:e.customerId,o=String(e==null?void 0:e.discount),E=String(e==null?void 0:e.surcharge),ke=String(e==null?void 0:e.tax),O=e==null?void 0:e.merchantPublicKey,le=e==null?void 0:e.orderID,Me=String(e==null?void 0:e.amount),Ee=ot==null?void 0:ot.id,We=ot==null?void 0:ot.card_type;if(O&&le&&Me&&xe)if(S)if(Ee){let St={amount:We==="Bank"?xe:Me,order_id:le,customer_id:S,card_id:Ee,fractalpayPublicKey:O,isCardSave:Pe,discount:o,surcharge:E,tax:ke},et=St,{isCardSave:qe}=et,Bt=gn(et,["isCardSave"]),l=Se+(We==="Bank"?"charge-ach":"charge-by-card"),j={"Content-Type":"application/json"};Y(!0),Je.emit("sendMessage",{url:l,body:We=="Bank"?Bt:St,isChargebycard:!0}),Je.on("charge-by-card",U=>{var $;(U==null?void 0:U.result)==!0||(U==null?void 0:U.status)==!0?(D(($=U.data)==null?void 0:$.transaction_id),ze(!0),Y(!1)):T((U==null?void 0:U.message)||"Something went wrong.")})}else T("Please Select A Card/ACH");else T("Please Select Customer");else T("Something went wrong.")},dt=async()=>{var O,le,Me,Ee,We,et;let S=e==null?void 0:e.merchantPublicKey,o=e==null?void 0:e.orderID,E=String(e==null?void 0:e.amount),ke=e==null?void 0:e.customerId;if(!(bt!=null&&bt.device_id)){T("Please Select A Payment Device");return}if(S&&o&&E){Y(!0);let St={amount:E,fractalpayPublicKey:S,customer_order_id:o,device_id:bt==null?void 0:bt.device_id,customer_id:ke||""};try{let qe=await pn.post(`${Se}charge-with-reader`,St);((O=qe==null?void 0:qe.data)==null?void 0:O.result)==!0?(D((Me=(le=qe==null?void 0:qe.data)==null?void 0:le.data)==null?void 0:Me.transaction_id),ze(!0),Y(!1)):(T(((Ee=qe==null?void 0:qe.data)==null?void 0:Ee.message)||"Something went wrong."),Y(!1))}catch(qe){T(((et=(We=qe==null?void 0:qe.response)==null?void 0:We.data)==null?void 0:et.message)||"Something went wrong."),Y(!1)}}else T("Something went wrong.")},_t=()=>{i==="card"?ht():i==="reader"&&dt()};Vn(()=>{ee&&k&&wt()},[k,ee]);let De=async S=>{xn.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async o=>{if(o.isConfirmed){Y(!0);try{let E={card_id:S,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},ke=await pn.post(`${Se}delete-customer-card`,E);Y(!1),wt(),xn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(E){Y(!1),xn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else o.dismiss===xn.DismissReason.cancel&&xn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},jt=S=>{switch(S==null?void 0:S.toLowerCase()){case"visa":return V;case"mastercard":case"mc":case"m/c":return je;case"amex":case"american express":case"ae":return Ue;case"discover":case"dcvr":return Be;case"bank":return m;default:return S}},Ht=()=>{let S=xe||0;return(Number(e.amount)-S).toFixed(0)};return console.log(u,"activeinCard","activeinBank",Z),n.createElement(n.Fragment,null,n.createElement(Jt,null),n.createElement(mn,null),n.createElement(Pn,null),n.createElement(n.Fragment,null,n.createElement("button",{className:"paymentBtn",onClick:J},"Pay"),n.createElement(Vt,{open:ee,onClose:s},$e&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(Xt,{error:$e,onClose:s})),gt&&n.createElement(dn,{onClose:s,tranId:Ke}),!$e&&!gt&&n.createElement(n.Fragment,null,(ae||Ae)&&n.createElement(Lt,{loading:ae||Ae}),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:s},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:I==null?void 0:I.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:I==null?void 0:I.logo,id:"pay-logos"})),(C==null?void 0:C.length)>0&&W!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>re("cardList")}," ",n.createElement(Mn,null)," Back")),n.createElement("div",{className:"amt-pay-con"},n.createElement("div",{className:"pay-amount-conatiner"},n.createElement("small",{className:"pay-payment-amount"},"Select paymet type")),n.createElement("div",{className:"frac-card-bank-radio-main"},n.createElement(fn,{label:"Card",amount:(Pt=Number(e==null?void 0:e.amount))==null?void 0:Pt.toFixed(2),value:"card",onChange:Ce,activetab:W}),(I==null?void 0:I.isSkyFiAccount)&&n.createElement(fn,{label:"Bank",amount:(ct=Number(xe))==null?void 0:ct.toFixed(2),value:"ach",onChange:Ce,activetab:W})),xe&&xe>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,W==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,pe((Number(e.amount)-xe).toFixed(2)))):null)),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:c,alt:""}),n.createElement("img",{src:z,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"},W!=="cardList"?n.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(C==null?void 0:C.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>re("cardList")}," ",n.createElement(Mn,null)," Back"),(I==null?void 0:I.isSkyFiAccount)&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks",onClick:S=>{Ce("card")},style:{border:W==="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:S=>{Ce("ach")},style:{border:W==="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"},"$",(ue=Number(e==null?void 0:e.amount))==null?void 0:ue.toFixed(2))),W!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:V,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:je,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:Ue,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Be,width:35,alt:""})))),xe&&xe>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",xe))):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",I==null?void 0:I.customer_name),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",i==="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"},"$",(Ft=Number(e==null?void 0:e.amount))==null?void 0:Ft.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:V,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:je,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:Ue,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Be,width:35,alt:""}))))),n.createElement("div",{id:"card",style:{display:W==="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"},(C==null?void 0:C.length)>0&&u==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>q("list")}," ",n.createElement(Mn,null)),xe&&xe>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",xe))),n.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),W!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},n.createElement("img",{src:V,alt:"",width:33}),n.createElement("img",{src:je,width:33,alt:""}),n.createElement("img",{src:Ue,alt:"",width:33}),n.createElement("img",{src:Be,width:33,alt:""}))),u==="list"?n.createElement(n.Fragment,null,n.createElement(yn,{listHeading:"Cards",paymentGateway:I==null?void 0:I.paymentGateway,ListItems:C,selectedCard:ot,setSelectedCard:st,handleDeleteCard:De,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{q("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:_t},pe((Mt=Number(e==null?void 0:e.amount))==null?void 0:Mt.toFixed(2))))):n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Qe},n.createElement("div",{className:"ach-scrl",style:{minHeight:I!=null&&I.isSkyFiAccount&&(C==null?void 0:C.length)>0?"444px":I!=null&&I.isSkyFiAccount&&(C==null?void 0:C.length)==0?"456px":(C==null?void 0:C.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:(g==null?void 0:g.cardName)||"",onChange:S=>{let o=S.target.value;/^[a-zA-Z\s]*$/.test(o)&&K("cardName",o)}}),(f==null?void 0:f.cardName)&&n.createElement("span",{className:"error-span"},f==null?void 0:f.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:(g==null?void 0:g.cardNumber)||"",onChange:S=>Ne(S),"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:(g==null?void 0:g.expiryMonth)||"",onChange:S=>K("expiryMonth",S.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:(g==null?void 0:g.expiryYear)||"",onChange:S=>K("expiryYear",S.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:(g==null?void 0:g.cvv)||"",onChange:S=>K("cvv",S.target.value)})))),(f==null?void 0:f.cardNumber)&&n.createElement("span",{className:"error-span"},f==null?void 0:f.cardNumber),n.createElement("p",{style:{margin:"0"}},f!=null&&f.expiryMonth||f!=null&&f.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},f==null?void 0:f.expiryMonth):"",(f==null?void 0:f.cvv)&&n.createElement("span",{className:"error-span"},f==null?void 0:f.cvv)))),n.createElement("div",{className:"form-group"},n.createElement("label",{htmlFor:"OrderId"},"Order ID / Description"),n.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"OID123456",disabled:!0,value:(Zt=e==null?void 0:e.orderID)!=null?Zt:"",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:(nt=g==null?void 0:g.zipCode)!=null?nt:"",onChange:S=>K("zipCode",S.target.value)}),(f==null?void 0:f.zipCode)&&n.createElement("span",{className:"error-span"},f==null?void 0:f.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:Pe,onChange:S=>he(S.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"}},(I==null?void 0:I.paymentDeviceList)&&((Dt=I==null?void 0:I.paymentDeviceList)==null?void 0:Dt.length)>0&&n.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>Ve(!Ge)},Ge?"Pay With Reader":"Pay With Card"),n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},pe((zt=Number(e==null?void 0:e.amount))==null?void 0:zt.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:W==="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"},(Fe==null?void 0:Fe.length)>0&&Z==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>be("list")}," ",n.createElement(Mn,null)),xe&&xe>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),n.createElement("div",null,"$",Ht()))),n.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),Z==="list"?n.createElement(n.Fragment,null,n.createElement(yn,{listHeading:"Banks",paymentGateway:I==null?void 0:I.paymentGateway,ListItems:Fe,selectedCard:ot,setSelectedCard:st,handleDeleteCard:De,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{be("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:_t},pe((Ze=Number(xe))==null?void 0:Ze.toFixed(2))))):n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Qe},n.createElement("div",{className:"ach-scrl",style:{minHeight:I!=null&&I.isSkyFiAccount&&(C==null?void 0:C.length)>0?"444px":I!=null&&I.isSkyFiAccount&&(C==null?void 0:C.length)==0?"436px":(C==null?void 0:C.length)>0?"462px":"520px",maxHeight:I!=null&&I.isSkyFiAccount&&(C==null?void 0:C.length)>0?"444px":((C==null?void 0:C.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:(Re=x==null?void 0:x.name)!=null?Re:"",onChange:we}),(L==null?void 0:L.name)&&n.createElement("span",{className:"error-span"},L==null?void 0:L.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:(Rt=x==null?void 0:x.routingNumber)!=null?Rt:"",onChange:we}),(L==null?void 0:L.routingNumber)&&n.createElement("span",{className:"error-span"},L==null?void 0:L.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:($t=x==null?void 0:x.accountNumber)!=null?$t:"",onChange:we}),(L==null?void 0:L.accountNumber)&&n.createElement("span",{className:"error-span"},L==null?void 0:L.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:(en=x==null?void 0:x.confirmAccountNumber)!=null?en:"",onChange:we}),(L==null?void 0:L.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},L==null?void 0:L.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:(xt=x==null?void 0:x.bankName)!=null?xt:"",onChange:we}),(L==null?void 0:L.bankName)&&n.createElement("span",{className:"error-span"},L==null?void 0:L.bankName)),((x==null?void 0:x.accountType)==="business saving"||(x==null?void 0:x.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:(Wt=x==null?void 0:x.companyName)!=null?Wt:"",onChange:we}),(L==null?void 0:L.companyName)&&n.createElement("span",{className:"error-span"},L==null?void 0:L.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:(rn=x==null?void 0:x.accountType)!=null?rn:"",onChange:we},n.createElement("option",{value:""},"Select account"),Sn.map(S=>n.createElement("option",{key:S.value,value:S.value},S.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:ce,onChange:S=>kt(S.target.checked)}),n.createElement("label",{htmlFor:"saveACH"},"Save ACH")),ce&&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"},pe((ln=Number(xe))==null?void 0:ln.toFixed(2))))))))))))))))}import a,{useEffect as jn,useState as It}from"react";import vn from"axios";import zn from"sweetalert2";import{IoArrowBack as Kn}from"react-icons/io5";function mi(e){var xe,G,I,ne,Ke,D,mt,Oe;let[ae,oe]=It(!1),[Ae,Y]=It(!1),[$e,T]=It(""),[gt,ze]=It(!1),[ee,R]=It(!1),[W,re]=It("card"),[i,y]=It(!1),u=e.merchantPublicKey,q=de+"widget/mc-img.svg",Z=de+"widget/visa-img.svg",be=de+"widget/ae-img.svg",Ge=de+"widget/discover-img.svg",Ve=de+"widget/card.svg",Pe=de+"widget/Trash.svg",he=de+"widget/bank.svg",ce=de+"widget/secure-img.png",kt=de+"widget/pov-by.png",[k,je]=It(),[V,Ue]=It({}),[Be,At]=It([]),[_,m]=It(),[c,z]=It(void 0),[v,g]=It(),[r,f]=It(""),p=(N,s)=>{let J=(parseFloat(s)||0)/100,Ce=N/(1+J);return Math.round(Ce*100)/100};jn(()=>{if(e!=null&&e.pass_fee){let N=p(e==null?void 0:e.amount,e==null?void 0:e.surcharge);z(N)}},[e==null?void 0:e.pass_fee]);let x=()=>oe(!0),b=()=>oe(!1),L=()=>{R(!1),re("card"),Y(!1),T(""),ze(!1),f(""),je({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Ue({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),y(!1),m({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""})},h=()=>R(!0),C=(N,s)=>{let J=N;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(J)){(s===""||/^[0-9]+$/.test(s))&&(Ue(K=>A(M({},K),{[J]:""})),je(K=>A(M({},K),{[J]:s})));return}Ue(K=>A(M({},K),{[J]:""})),je(K=>A(M({},K),{[J]:s}))},B=N=>{let J=N.target.value.replace(/\D/g,""),Ce="";/^3[47]/.test(J)?Ce=J.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Ne,we,rt,fe)=>[we,rt,fe].filter(Boolean).join(" ")):Ce=J.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Ne,we,rt,fe,Qe)=>[we,rt,fe,Qe].filter(Boolean).join(" ")),Ue(K=>A(M({},K),{cardNumber:""})),je(K=>A(M({},K),{cardNumber:Ce}))},Fe=()=>{var K,Ne,we,rt,fe,Qe;let N={},s=k,J=parseInt((s==null?void 0:s.expiryMonth)||"",10),Ce=(s==null?void 0:s.expiryYear)||"";if((K=s==null?void 0:s.cardName)!=null&&K.trim()||(N.cardName="Card name is required"),(Ne=s==null?void 0:s.cardNumber)!=null&&Ne.trim()||(N.cardNumber="Card number is required"),(!((we=s==null?void 0:s.expiryMonth)!=null&&we.trim())||!((rt=s==null?void 0:s.expiryYear)!=null&&rt.trim())||isNaN(J)||J<1||J>12||Ce.length!==4)&&(N.expiryMonth="Invalid Expiration Date."),(fe=s==null?void 0:s.cvv)!=null&&fe.trim()||(N.cvv="CVV is required"),(Qe=s==null?void 0:s.zipCode)!=null&&Qe.trim()||(N.zipCode="ZIP code is required"),s!=null&&s.expiryMonth&&(s!=null&&s.expiryYear)&&s.expiryMonth.length<=2&&s.expiryYear.length===4){let wt=parseInt(s.expiryMonth,10),ht=parseInt(s.expiryYear,10),dt=new Date,_t=dt.getMonth()+1,De=dt.getFullYear();(ht<De||ht===De&&wt<_t)&&(N.expiryMonth="Card is expired")}return Ue(N),Object.keys(N).length>0},Nt=async N=>{var s,J,Ce,K,Ne,we,rt,fe,Qe,wt,ht,dt,_t,De,jt,Ht,Pt,ct,ue;if(N.preventDefault(),W=="card"){if(Fe())return;{let Mt=DatacapWebToken.validateCardNumber(k==null?void 0:k.cardNumber.replaceAll(" ","")),Zt=DatacapWebToken.validateExpirationDate(k==null?void 0:k.expiryMonth,k==null?void 0:k.expiryYear),nt=DatacapWebToken.validateCVV(k==null?void 0:k.cvv),Dt={};if(Mt||(Dt.cardNumber="Invalid card Number"),Zt||(Dt.expiryMonth="Invalid Expiration Date."),nt||(Dt.cvv="Invalid CVV"),Ue(Dt),Mt&&nt&&Zt){Y(!0);try{let zt=async function(Ze){if(Ze.Error)T(Ze.Error),Y(!1);else{let Re=k==null?void 0:k.cardName,Rt=k==null?void 0:k.zipCode;Ze.name=Re,Ze.postal_code=Rt,Ze.fractalpayPublicKey=e==null?void 0:e.merchantPublicKey,Ze.amount=e==null?void 0:e.amount,Ze.order_id=e==null?void 0:e.orderID,Ze.preAuth_id="",Ze.isCardSave=i,Ze.customer_id=e==null?void 0:e.customerId,Ze.link_token="",Ze.gateway_id=v==null?void 0:v.paymentGateway,Ze.discount=e==null?void 0:e.discount,Ze.tax=e==null?void 0:e.tax,Ze.surcharge=e==null?void 0:e.surcharge,Ze.pass_fee=e==null?void 0:e.pass_fee,new Headers().append("Content-Type","application/json");let en={method:"POST",body:JSON.stringify(Ze),redirect:"follow"};Je.emit("sendMessage",A(M({},en),{isChargePreauth:!0})),Je.on("charge-preauth",xt=>{var Wt;console.log(xt,"datdata"),(xt==null?void 0:xt.status)=="Failed"?(Y(!1),T((xt==null?void 0:xt.message)||"Something went wrong. Please try again later.")):(ze(!0),f((Wt=xt==null?void 0:xt.data)==null?void 0:Wt.transaction_id),Y(!1),je({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}))})}};if((v==null?void 0:v.paymentGateway)===32){let Ze={method:"POST",redirect:"follow"};try{let Re=await vn.post(`${Yt}api/v1/widget/generate-session`,Ze),Rt=Number(k==null?void 0:k.expiryYear)%100,$t=k==null?void 0:k.cardNumber;$t=$t==null?void 0:$t.replace(/\s+/g,"");let en=`${$t}=${Rt}${k==null?void 0:k.expiryMonth} ${k==null?void 0:k.cvv}`,Wt=forge.pki.publicKeyFromPem((J=(s=Re==null?void 0:Re.data)==null?void 0:s.data)==null?void 0:J.publicKeyPem).encrypt(en,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),rn=forge.util.encode64(Wt),ln={"Content-Type":"application/json","x-app-session-key":(K=(Ce=Re.data)==null?void 0:Ce.data)==null?void 0:K.session_key},S=JSON.stringify({enc_track2_data:`${rn}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(we=(Ne=Re==null?void 0:Re.data)==null?void 0:Ne.data)==null?void 0:we.session_key}`});try{let o=await vn.post(`${Ut}tokenizer/tokenize`,S,{headers:ln}),E=JSON.stringify(A(M({},(rt=o==null?void 0:o.data)==null?void 0:rt.data),{name:k==null?void 0:k.cardName,postal_code:k==null?void 0:k.zipCode,customer_id:e==null?void 0:e.customerId,amount:e==null?void 0:e.amount,Token:`${(Qe=(fe=o==null?void 0:o.data)==null?void 0:fe.data)==null?void 0:Qe.token}`,fractalpayPublicKey:u,order_id:e==null?void 0:e.orderID,preAuth_id:"",isCardSave:i,discount:e==null?void 0:e.discount,surcharge:e==null?void 0:e.surcharge,tax:e==null?void 0:e.tax,link_token:"",ExpirationYear:k==null?void 0:k.expiryYear,ExpirationMonth:k==null?void 0:k.expiryMonth,CVV:k==null?void 0:k.cvv,Last4:(ht=(wt=o==null?void 0:o.data)==null?void 0:wt.data)==null?void 0:ht.last4,Brand:(_t=(dt=o==null?void 0:o.data)==null?void 0:dt.data)==null?void 0:_t.brand,gateway_id:v==null?void 0:v.paymentGateway,pass_fee:e==null?void 0:e.pass_fee})),O={method:"POST",headers:{"Content-Type":"application/json"},body:E,redirect:"follow"};Je.emit("sendMessage",A(M({},O),{isFractalPreauth:!0})),Je.on("fractal-charge-preauth",le=>{var Me;(le==null?void 0:le.status)=="Failed"?(Y(!1),T((le==null?void 0:le.message)||"Something went wrong , Try again later")):(f((Me=le==null?void 0:le.data)==null?void 0:Me.transaction_id),ze(!0),Y(!1))})}catch(o){console.log(o),Y(!1),T(((jt=(De=o==null?void 0:o.response)==null?void 0:De.data)==null?void 0:jt.message)||(o==null?void 0:o.message)||"Something went wrong , Try again later")}}catch(Re){Y(!1),T(((Pt=(Ht=Re==null?void 0:Re.response)==null?void 0:Ht.data)==null?void 0:Pt.message)||(Re==null?void 0:Re.message)||"Something went wrong , Try again later")}}else DatacapWebToken.requestToken(v==null?void 0:v.dctoken,"PaymentForm",zt)}catch(zt){Y(!1),T(((ue=(ct=zt==null?void 0:zt.response)==null?void 0:ct.data)==null?void 0:ue.message)||(zt==null?void 0:zt.message)||"Something went wrong.")}}}}},ot=async()=>{var N,s,J,Ce,K,Ne,we,rt,fe,Qe,wt,ht,dt,_t,De,jt,Ht,Pt;x();try{let ct={fractalpayPublicKey:u,customer_id:e==null?void 0:e.customerId,preauth:!0},ue=await vn.post(`${Se}get-payment-details`,ct);if(g((N=ue==null?void 0:ue.data)==null?void 0:N.data),(J=(s=ue==null?void 0:ue.data)==null?void 0:s.data)!=null&&J.paymentGateway||(L(),T("Something went wrong.")),(K=(Ce=ue==null?void 0:ue.data)==null?void 0:Ce.data)!=null&&K.card_list&&((rt=(we=(Ne=ue==null?void 0:ue.data)==null?void 0:Ne.data)==null?void 0:we.card_list)==null?void 0:rt.length)>0){At((Qe=(fe=ue==null?void 0:ue.data)==null?void 0:fe.data)==null?void 0:Qe.card_list),re("cardList");let Ft=(dt=(ht=(wt=ue==null?void 0:ue.data)==null?void 0:wt.data)==null?void 0:ht.card_list)==null?void 0:dt.filter(Mt=>(Mt==null?void 0:Mt.primary_card)==1);Ft!=null&&Ft[0]&&((_t=Ft==null?void 0:Ft[0])==null?void 0:_t.payment_method_type)==((jt=(De=ue==null?void 0:ue.data)==null?void 0:De.data)==null?void 0:jt.paymentGateway)&&m(Ft[0])}else re("card");b()}catch(ct){console.log(ct),b(),T(((Pt=(Ht=ct==null?void 0:ct.response)==null?void 0:Ht.data)==null?void 0:Pt.message)||(ct==null?void 0:ct.message)||"Something went wrong")}},st=async()=>{var wt,ht,dt,_t,De,jt,Ht;let N=e==null?void 0:e.customerId,s=e==null?void 0:e.discount,J=e==null?void 0:e.surcharge,Ce=e==null?void 0:e.tax,K=e==null?void 0:e.merchantPublicKey,Ne=e==null?void 0:e.orderID,we=e==null?void 0:e.amount,rt=_==null?void 0:_.id,fe=_==null?void 0:_.card_type;if(K&&Ne&&we)if(N)if(rt){let Pt={amount:we,order_id:Ne,customer_id:N,card_id:rt,fractalpayPublicKey:K,isCardSave:fe!="Bank",discount:s,surcharge:J,tax:Ce},Qe=Pt,{isCardSave:ct}=Qe,ue=gn(Qe,["isCardSave"]),Mt=Se+"authorize-by-card",Zt={"Content-Type":"application/json"};Y(!0);try{let nt=await vn.post(Mt,fe=="Bank"?ue:Pt,{headers:Zt});(wt=nt==null?void 0:nt.data)!=null&&wt.result&&(f((dt=(ht=nt==null?void 0:nt.data)==null?void 0:ht.data)==null?void 0:dt.transaction_id),ze(!0),Y(!1))}catch(nt){Y(!1),console.log(nt),T(((De=(_t=nt==null?void 0:nt.response)==null?void 0:_t.data)==null?void 0:De.message)||((Ht=(jt=nt==null?void 0:nt.response)==null?void 0:jt.data)==null?void 0:Ht.status)||"Something went erong")}}else T("Please Select A Card/ACH");else T("Please Select Customer");else T("Something went wrong.")};jn(()=>{ee&&u&&ot()},[u,ee]);let bt=async N=>{zn.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async s=>{if(s.isConfirmed){Y(!0);try{let J={card_id:N,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},Ce=await vn.post(`${Se}delete-customer-card`,J);Y(!1),ot(),zn.fire({icon:"success",title:"Deleted!",text:"The card has been deleted.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}catch(J){Y(!1),zn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}})},tt=N=>{switch(N==null?void 0:N.toLowerCase()){case"visa":return Z;case"mastercard":case"mc":case"m/c":return q;case"amex":case"american express":case"ae":return be;case"discover":case"dcvr":return Ge;case"bank":return he;default:return N}};return a.createElement(a.Fragment,null,a.createElement(Jt,null),a.createElement(mn,null),a.createElement(a.Fragment,null,a.createElement("button",{className:"paymentBtn",onClick:h},"PreAuth Payment"),a.createElement(Vt,{open:ee,onClose:L},$e&&a.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},a.createElement(Xt,{error:$e,onClose:L})),gt&&a.createElement(dn,{onClose:L,tranId:r}),!$e&&!gt&&a.createElement(a.Fragment,null,(ae||Ae)&&a.createElement(Lt,{loading:ae||Ae}),a.createElement("div",null,a.createElement("div",{className:"frac-card-payment-page frac-form"},a.createElement("div",{className:"parent-pay-container"},a.createElement("span",{className:"request-payment-close-popup",onClick:L},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},a.createElement("g",{clipPath:"url(#clip0_12425_52336)"},a.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),a.createElement("defs",null,a.createElement("clipPath",{id:"clip0_12425_52336"},a.createElement("rect",{width:"16",height:"16",fill:"white"}))))),a.createElement("div",{className:"pay-container"},a.createElement("div",{className:"pay-header pay-conatiner-one"},a.createElement("div",{className:"pay-conatiner-one-first"},a.createElement("div",{className:"pay-logo-container"},a.createElement("div",{className:"pay-main-logo"},a.createElement("img",{src:v==null?void 0:v.logo,id:"pay-logos"})),a.createElement("h1",{className:"pay-heading"},"Pay"),(Be==null?void 0:Be.length)>0&&W!=="cardList"&&a.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>re("cardList")}," ",a.createElement(Kn,null)," Back")),a.createElement("div",{className:"amt-pay-con"},a.createElement("div",{className:"pay-amount-conatiner"},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},pe((xe=Number(e==null?void 0:e.amount))==null?void 0:xe.toFixed(2))),c&&c>0&&a.createElement("div",{style:{width:"80%"},className:"frac-cash-discount"},a.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),a.createElement("div",null,pe(c.toFixed(2))))),W!="ach"&&a.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0"}},a.createElement("img",{src:Z,alt:"",width:33}),a.createElement("img",{src:q,width:33,alt:""}),a.createElement("img",{src:be,alt:"",width:33}),a.createElement("img",{src:Ge,width:33,alt:""})))),a.createElement("div",{className:"pay-conatiner-one-last"},a.createElement("img",{src:ce,alt:""}),a.createElement("img",{src:kt,alt:""}),"Secure payments powered by Fractal"),a.createElement("div",null)),!ae&&a.createElement("div",{className:"pay-tab pay-conatiner-two"},a.createElement("div",{className:"col-md-12"},a.createElement("div",{id:"payment-form-div"},W!=="cardList"?a.createElement("div",null,(Be==null?void 0:Be.length)>0&&a.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>re("cardList")}," ",a.createElement(Kn,null)," Back"),a.createElement("div",{className:""},a.createElement("div",{className:"res-pay-con"},a.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},a.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),a.createElement("strong",{className:"pay-amount"},pe((G=Number(e==null?void 0:e.amount))==null?void 0:G.toFixed(2)))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:Z,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:q,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:be,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:Ge,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,pe(c.toFixed(2)))))):a.createElement("div",null,a.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",v==null?void 0:v.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"},pe((I=Number(e==null?void 0:e.amount))==null?void 0:I.toFixed(2)))),a.createElement("div",null,a.createElement("div",null,a.createElement("img",{src:Z,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:q,width:35,alt:""})),a.createElement("div",null,a.createElement("img",{src:be,alt:"",width:35,style:{paddingRight:"5px"}}),a.createElement("img",{src:Ge,width:35,alt:""})))),a.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," Cards")),a.createElement("div",{style:{display:W==="cardList"?"block":"none"},className:"tabcontent"},a.createElement("div",{className:"card-lint-div-in"},a.createElement("div",{className:"card-list-div"},(v==null?void 0:v.card_list)&&((ne=v==null?void 0:v.card_list)==null?void 0:ne.length)>0&&((Ke=v==null?void 0:v.card_list)==null?void 0:Ke.map((N,s)=>a.createElement("div",{className:"card-list-single-div",key:s},a.createElement("div",{className:"card-number-radio"},a.createElement("input",{disabled:(v==null?void 0:v.paymentGateway)!=(N==null?void 0:N.payment_method_type),type:"radio",className:"cardRadio",name:"selected_card",id:"",checked:_===N,onChange:J=>m(N)}),a.createElement("label",{htmlFor:"",className:"card-number-last-four"},"**** ",N==null?void 0:N.cardlastfourdigit),a.createElement("h6",{className:"card-expiry-date"},N==null?void 0:N.expmonth,"/",N==null?void 0:N.expyear)),a.createElement("div",{className:"card-number-radio"},a.createElement("span",{className:"visa-card"},a.createElement("img",{src:tt(N==null?void 0:N.card_type),alt:""})),a.createElement("span",{className:"visa-card",style:{cursor:"pointer"},onClick:()=>bt(N==null?void 0:N.id)},a.createElement("img",{src:Pe,alt:""}))))))),a.createElement("div",{className:"pay-with-other-card ",onClick:()=>re("card")},"Authorize With Other Card",a.createElement("img",{src:Ve,alt:""}))),a.createElement("div",{className:"form-group"},a.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:st},pe((D=Number(e==null?void 0:e.amount))==null?void 0:D.toFixed(2))))),a.createElement("div",{id:"card",style:{display:W==="card"?"block":"none"},className:"tabcontent"},a.createElement("form",{id:"PaymentForm",onSubmit:Nt},a.createElement("div",{className:"ach-scrl",style:{minHeight:(Be==null?void 0:Be.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:(k==null?void 0:k.cardName)||"",onChange:N=>{let s=N.target.value;/^[a-zA-Z\s]*$/.test(s)&&C("cardName",s)}}),(V==null?void 0:V.cardName)&&a.createElement("span",{className:"error-span"},V==null?void 0:V.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:(k==null?void 0:k.cardNumber)||"",onChange:N=>B(N),"data-token":"card_number"}),a.createElement("div",{className:"card-crdi card-expiry-new"},a.createElement("div",{className:"exp-date-year-container"},a.createElement("div",{className:"exp-date form-group"},a.createElement("input",{"data-token":"exp_month",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(k==null?void 0:k.expiryMonth)||"",onChange:N=>C("expiryMonth",N.target.value)})),a.createElement("div",{className:"exp-year form-group"},a.createElement("input",{"data-token":"exp_year",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(k==null?void 0:k.expiryYear)||"",onChange:N=>C("expiryYear",N.target.value)})),a.createElement("div",{className:"security-digit form-group"},a.createElement("input",{"data-token":"cvv",className:"form-control required card-cvv-in",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(k==null?void 0:k.cvv)||"",onChange:N=>C("cvv",N.target.value)})))),(V==null?void 0:V.cardNumber)&&a.createElement("span",{className:"error-span"},V==null?void 0:V.cardNumber),a.createElement("p",{style:{margin:"0"}},V!=null&&V.expiryMonth||V!=null&&V.expiryYear?a.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},V==null?void 0:V.expiryMonth):"",(V==null?void 0:V.cvv)&&a.createElement("span",{className:"error-span"},V==null?void 0:V.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:N=>C("orderId",N.target.value),style:{background:"#F6F6F7",color:"#727272"}})),a.createElement("div",{className:"form-group"},a.createElement("label",{htmlFor:"zip"},"ZIP"),a.createElement("input",{type:"text",className:"form-control",maxLength:100,placeholder:"000000",value:(mt=k==null?void 0:k.zipCode)!=null?mt:"",onChange:N=>C("zipCode",N.target.value)}),(V==null?void 0:V.zipCode)&&a.createElement("span",{className:"error-span"},V==null?void 0:V.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:i,onChange:N=>y(N.target.checked)}),a.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),a.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),a.createElement("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,(v==null?void 0:v.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"},pe((Oe=Number(e==null?void 0:e.amount))==null?void 0:Oe.toFixed(2)))))))))))))))))}import Q,{useEffect as gi,useRef as Cn,useState as cn}from"react";import hi from"sweetalert2";import bn from"axios";import di from"react";function Bn(){let e="#000",ae="#fff",oe="#212529",Ae="#dee2e6";return di.createElement("style",null,`
|
|
1730
1219
|
.add-card {
|
|
1731
1220
|
max-width:380px;
|
|
1732
1221
|
padding: 0 20px
|
|
@@ -1985,7 +1474,7 @@ position:relative;
|
|
|
1985
1474
|
}
|
|
1986
1475
|
}
|
|
1987
1476
|
|
|
1988
|
-
`)}import
|
|
1477
|
+
`)}import Ot from"react";import ci from"react";function qn(){return ci.createElement("style",null,`
|
|
1989
1478
|
.card-success .logo-container {
|
|
1990
1479
|
display: flex;
|
|
1991
1480
|
justify-content: center;
|
|
@@ -2073,7 +1562,7 @@ position:relative;
|
|
|
2073
1562
|
color: #161616;
|
|
2074
1563
|
opacity: 0.5;
|
|
2075
1564
|
}
|
|
2076
|
-
`)}var na=({onClose:e})=>on.createElement(on.Fragment,null,on.createElement(Dn,null),on.createElement("div",{className:"card-success"},on.createElement("div",{className:"payment-success-container"},on.createElement("div",{className:"success-icon"},on.createElement("div",{className:"circle"},on.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),on.createElement("div",{className:"success-text"},on.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),on.createElement("div",{className:"thank-you-text"},"Thank you ")))))),hi=na;function oa(e){var B;let[C,ee]=wn(!1),[R,$]=wn(!1),[Me,U]=wn(""),[$e,Ue]=wn(!1),ye=qn(null),O=qn(null),me=qn(null),ve=qn(null),o=qn(null),[y,f]=wn(),[Q,ce]=wn({}),[k,Ge]=wn(),ne=()=>ee(!0),Fe=()=>ee(!1),b=g=>{aa.fire({icon:"error",text:g,customClass:{popup:"custom-z-index"}})},we=()=>{Ue(!1),$(!1),U(""),f({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},oe=()=>Ue(!0),I=()=>{we()},Je=(g,c)=>{var x,d,v;let J=g,L=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(J,c==null?void 0:c.length,"dfih",J==="expiryMonth"&&(c==null?void 0:c.length)===2),J==="expiryMonth"&&(c==null?void 0:c.length)===2&&((x=me==null?void 0:me.current)==null||x.focus()),J==="expiryYear"&&(c==null?void 0:c.length)===4&&((d=ve==null?void 0:ve.current)==null||d.focus()),J==="cvv"&&(c==null?void 0:c.length)===3&&((v=o==null?void 0:o.current)==null||v.focus()),L.includes(J)){(c===""||/^[0-9]+$/.test(c))&&(ce(S=>A(F({},S),{[J]:""})),f(S=>A(F({},S),{[J]:c})));return}ce(S=>A(F({},S),{[J]:""})),console.log(c,J),f(S=>A(F({},S),{[J]:c}))},ae=g=>{var x;let J=g.target.value.replace(/\D/g,""),L="";/^3[47]/.test(J)?L=J.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(v,S,M,_)=>[S,M,_].filter(Boolean).join(" ")):L=J.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(v,S,M,_,q)=>[S,M,_,q].filter(Boolean).join(" ")),ce(d=>A(F({},d),{cardNumber:""})),f(d=>A(F({},d),{cardNumber:L})),console.log(J==null?void 0:J.length,"length"),(J==null?void 0:J.length)===16&&((x=O==null?void 0:O.current)==null||x.focus())},Te=()=>{var x,d,v,S,M,_;let g={},c=y,J=parseInt((c==null?void 0:c.expiryMonth)||"",10),L=(c==null?void 0:c.expiryYear)||"";if((x=c==null?void 0:c.cardName)!=null&&x.trim()||(g.cardName="Card name is required"),(d=c==null?void 0:c.cardNumber)!=null&&d.trim()||(g.cardNumber="Card number is required"),(v=c==null?void 0:c.expiryMonth)!=null&&v.trim()?(Number(c==null?void 0:c.expiryMonth)>12||Number(c==null?void 0:c.expiryMonth)<1)&&(g.expiryMonth="Invalid Expiration Month."):g.expiryMonth="Expiration month is required",(S=c==null?void 0:c.expiryYear)!=null&&S.trim()?((M=c==null?void 0:c.expiryYear)==null?void 0:M.trim().length)!==4||Number(c==null?void 0:c.expiryYear)<2025?g.expiryYear="Invalid Expiration Year.":(isNaN(J)||J<1||J>12||L.length!==4)&&(g.expiryMonth="Invalid Expiration Date."):g.expiryYear="Expiration year is required",(_=c==null?void 0:c.cvv)!=null&&_.trim()||(g.cvv="CVC is required"),c!=null&&c.expiryMonth&&(c!=null&&c.expiryYear)&&c.expiryMonth.length<=2&&c.expiryYear.length===4){let q=parseInt(c.expiryMonth,10),h=parseInt(c.expiryYear,10),w=new Date,G=w.getMonth()+1,ke=w.getFullYear();(h<ke||h===ke&&q<G)&&(g.expiryMonth="Card is expired")}return ce(g),Object.keys(g).length>0},Xe=async()=>{var g,c,J;ne();try{let L={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},x=await Mn.post(`${Be}get-payment-details`,L);console.log(x),Ge((g=x==null?void 0:x.data)==null?void 0:g.data),(J=(c=x==null?void 0:x.data)==null?void 0:c.data)!=null&&J.paymentGateway||(we(),U("Something went wrong.")),Fe()}catch(L){console.log(L),Fe(),we(),U("Something went wrong.")}};return ia(()=>{e!=null&&e.merchantPublicKey&&Xe()},[e==null?void 0:e.merchantPublicKey]),be.createElement(be.Fragment,null,be.createElement(Dt,null),be.createElement(Qn,null),be.createElement(Ot,{loading:C}),Me&&be.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},be.createElement(tn,{error:Me,onClose:we})),R&&be.createElement(hi,{onClose:I}),!Me&&!R&&be.createElement(be.Fragment,null,be.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},be.createElement("form",{id:"creditCardForm",onSubmit:async g=>{var J,L,x,d,v,S,M,_,q,h,w,G,ke,zt,at,pt;g.preventDefault();let c=Te();if(console.log(y),!c){let Mt=DatacapWebToken.validateCardNumber(y==null?void 0:y.cardNumber.replaceAll(" ","")),mt=DatacapWebToken.validateExpirationDate(y==null?void 0:y.expiryMonth,y==null?void 0:y.expiryYear),qe=DatacapWebToken.validateCVV(y==null?void 0:y.cvv),le={};if(Mt||(le.cardNumber="Invalid card Number"),mt||(le.expiryMonth="Invalid Expiration Date."),qe||(le.cvv="Invalid CVV"),ce(le),Mt&&qe&&mt){ne();try{let Z=async function(Ne){var Qe,he,Ct,tt,z;if(console.log(Ne),Ne.Error)console.log(Ne==null?void 0:Ne.Error),U(Ne.Error),Fe();else{let u={userId:e==null?void 0:e.customerId,cardName:y==null?void 0:y.cardName,zip:y==null?void 0:y.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:Ne};try{let ge=await Mn.post(`${Be}add-card`,u);console.log(ge);let De={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:y==null?void 0:y.cardNumber.replaceAll(" ",""),exp_month:y==null?void 0:y.expiryMonth,exp_year:(Qe=y==null?void 0:y.expiryYear)==null?void 0:Qe.slice(-2),cvv:y==null?void 0:y.cvv};try{let re=await Mn.post(`${Be}link-wallet`,De);console.log(re),$(!0),Fe(),f({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),bn(g,"close","")}catch(re){console.log(re),Fe(),U(((Ct=(he=re==null?void 0:re.response)==null?void 0:he.data)==null?void 0:Ct.message)||(re==null?void 0:re.message)||"Something went wrong.")}}catch(ge){console.log(ge),Fe(),U(((z=(tt=ge==null?void 0:ge.response)==null?void 0:tt.data)==null?void 0:z.message)||(ge==null?void 0:ge.message)||"Something went wrong.")}}};if((k==null?void 0:k.paymentGateway)===32){let Ne={method:"POST",redirect:"follow"};try{let Qe=await Mn.post(`${Pe}api/v1/widget/generate-session`,Ne),he=Number(y==null?void 0:y.expiryYear)%100,Ct=y==null?void 0:y.cardNumber;Ct=Ct==null?void 0:Ct.replace(/\s+/g,"");let tt=`${Ct}=${he}${y==null?void 0:y.expiryMonth} ${y==null?void 0:y.cvv}`,u=forge.pki.publicKeyFromPem((L=(J=Qe==null?void 0:Qe.data)==null?void 0:J.data)==null?void 0:L.publicKeyPem).encrypt(tt,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ge=forge.util.encode64(u),De={"Content-Type":"application/json","x-app-session-key":(d=(x=Qe.data)==null?void 0:x.data)==null?void 0:d.session_key},re=JSON.stringify({enc_track2_data:`${ge}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(S=(v=Qe==null?void 0:Qe.data)==null?void 0:v.data)==null?void 0:S.session_key}`});try{let Oe=await Mn.post(`${Ht}tokenizer/tokenize`,re,{headers:De}),Ze=JSON.stringify(A(F({},(M=Oe==null?void 0:Oe.data)==null?void 0:M.data),{cvv:y==null?void 0:y.cvv,cardName:y==null?void 0:y.cardName,zip:y==null?void 0:y.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),wt={"Content-Type":"application/json"};try{let He=await Mn.post(`${Be}add-card`,Ze,{headers:wt});console.log(He),(_=He==null?void 0:He.data)!=null&&_.result&&($(!0),Fe(),bn(g,"close",""))}catch(He){Fe(),U(((h=(q=He==null?void 0:He.response)==null?void 0:q.data)==null?void 0:h.message)||(He==null?void 0:He.message)||"Something went wrong.")}}catch(Oe){Fe(),U(((G=(w=Oe==null?void 0:Oe.response)==null?void 0:w.data)==null?void 0:G.message)||(Oe==null?void 0:Oe.message)||"Something went wrong.")}}catch(Qe){Fe(),U(((zt=(ke=Qe==null?void 0:Qe.response)==null?void 0:ke.data)==null?void 0:zt.message)||(Qe==null?void 0:Qe.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(k==null?void 0:k.dctoken,"creditCardForm",Z)}catch(Z){Fe(),U(((pt=(at=Z==null?void 0:Z.response)==null?void 0:at.data)==null?void 0:pt.message)||(Z==null?void 0:Z.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},be.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},be.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},be.createElement("label",{htmlFor:"cardNumber"},"Card Number"),be.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(y==null?void 0:y.cardNumber)||"",onChange:g=>ae(g),ref:ye}),(Q==null?void 0:Q.cardNumber)&&be.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},Q==null?void 0:Q.cardNumber),be.createElement("br",null)),be.createElement("div",{className:"card-dtl"},be.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},be.createElement("div",{className:"form-group",style:{marginTop:"0"}},be.createElement("label",{htmlFor:"expMonth"},"MM"),be.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(y==null?void 0:y.expiryMonth)||"",onChange:g=>Je("expiryMonth",g.target.value),ref:O}),(Q==null?void 0:Q.expiryMonth)&&be.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},Q==null?void 0:Q.expiryMonth)),be.createElement("div",{className:"form-group",style:{marginTop:"0"}},be.createElement("label",{htmlFor:"expYear"},"YYYY"),be.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(y==null?void 0:y.expiryYear)||"",onChange:g=>Je("expiryYear",g.target.value),ref:me}),(Q==null?void 0:Q.expiryYear)&&be.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},Q==null?void 0:Q.expiryYear)),be.createElement("div",{className:"form-group",style:{marginTop:"0"}},be.createElement("label",{htmlFor:"cvc"},"CVC"),be.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(y==null?void 0:y.cvv)||"",onChange:g=>Je("cvv",g.target.value),ref:ve}),(Q==null?void 0:Q.cvv)&&be.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},Q==null?void 0:Q.cvv)))),be.createElement("div",{className:"form-group",style:{marginTop:"0"}},be.createElement("label",{htmlFor:"cardholderName"},"Name on card"),be.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(y==null?void 0:y.cardName)||"",onChange:g=>{let c=g.target.value;/^[a-zA-Z\s]*$/.test(c)&&Je("cardName",c)},ref:o}),(Q==null?void 0:Q.cardName)&&be.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},Q==null?void 0:Q.cardName)),be.createElement("div",{className:"form-group",style:{marginTop:"0"}},be.createElement("label",{htmlFor:"zipcode"},"Zip"),be.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(B=y==null?void 0:y.zipCode)!=null?B:"",onChange:g=>Je("zipCode",g.target.value)}),(Q==null?void 0:Q.zipCode)&&be.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},Q==null?void 0:Q.zipCode))),be.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import K,{useState as Yn}from"react";import $n from"axios";var Zn={PROPAYKEY:"25",PAYARCKEY:"26",STRIPEKEYCC:"27",PAYRIXKEY:"28",SKYFIACHKEY:"29",JUSTIFIKEY:"30",INFINICEPTKEY:"31",FRACTALKEY:"32"};import ra from"react";function Rn({}){return ra.createElement("style",null,`
|
|
1565
|
+
`)}var ui=({onClose:e})=>Ot.createElement(Ot.Fragment,null,Ot.createElement(qn,null),Ot.createElement("div",{className:"card-success"},Ot.createElement("div",{className:"payment-success-container"},Ot.createElement("div",{className:"success-icon"},Ot.createElement("div",{className:"circle"},Ot.createElement("i",{className:"fa fa-check-circle","aria-hidden":"true"})),Ot.createElement("div",{className:"success-text"},Ot.createElement("div",{className:"payment-success-text"},"Your card was added successfully."),Ot.createElement("div",{className:"thank-you-text"},"Thank you ")))))),On=ui;function fi(e){var _;let[ae,oe]=cn(!1),[Ae,Y]=cn(!1),[$e,T]=cn(""),[gt,ze]=cn(!1),ee=Cn(null),R=Cn(null),W=Cn(null),re=Cn(null),i=Cn(null),[y,u]=cn(),[q,Z]=cn({}),[be,Ge]=cn(),Ve=()=>oe(!0),Pe=()=>oe(!1),he=m=>{hi.fire({icon:"error",text:m,customClass:{popup:"custom-z-index"}})},ce=()=>{ze(!1),Y(!1),T(""),u({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""})},kt=()=>ze(!0),k=()=>{ce()},je=(m,c)=>{var g,r,f;let z=m,v=["expiryMonth","expiryYear","zipCode","cvv"];if(console.log(z,c==null?void 0:c.length,"dfih",z==="expiryMonth"&&(c==null?void 0:c.length)===2),z==="expiryMonth"&&(c==null?void 0:c.length)===2&&((g=W==null?void 0:W.current)==null||g.focus()),z==="expiryYear"&&(c==null?void 0:c.length)===4&&((r=re==null?void 0:re.current)==null||r.focus()),z==="cvv"&&(c==null?void 0:c.length)===3&&((f=i==null?void 0:i.current)==null||f.focus()),v.includes(z)){(c===""||/^[0-9]+$/.test(c))&&(Z(p=>A(M({},p),{[z]:""})),u(p=>A(M({},p),{[z]:c})));return}Z(p=>A(M({},p),{[z]:""})),console.log(c,z),u(p=>A(M({},p),{[z]:c}))},V=m=>{var g;let z=m.target.value.replace(/\D/g,""),v="";/^3[47]/.test(z)?v=z.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(f,p,x,b)=>[p,x,b].filter(Boolean).join(" ")):v=z.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(f,p,x,b,L)=>[p,x,b,L].filter(Boolean).join(" ")),Z(r=>A(M({},r),{cardNumber:""})),u(r=>A(M({},r),{cardNumber:v})),console.log(z==null?void 0:z.length,"length"),(z==null?void 0:z.length)===16&&((g=R==null?void 0:R.current)==null||g.focus())},Ue=()=>{var g,r,f,p,x,b;let m={},c=y,z=parseInt((c==null?void 0:c.expiryMonth)||"",10),v=(c==null?void 0:c.expiryYear)||"";if((g=c==null?void 0:c.cardName)!=null&&g.trim()||(m.cardName="Card name is required"),(r=c==null?void 0:c.cardNumber)!=null&&r.trim()||(m.cardNumber="Card number is required"),(f=c==null?void 0:c.expiryMonth)!=null&&f.trim()?(Number(c==null?void 0:c.expiryMonth)>12||Number(c==null?void 0:c.expiryMonth)<1)&&(m.expiryMonth="Invalid Expiration Month."):m.expiryMonth="Expiration month is required",(p=c==null?void 0:c.expiryYear)!=null&&p.trim()?((x=c==null?void 0:c.expiryYear)==null?void 0:x.trim().length)!==4||Number(c==null?void 0:c.expiryYear)<2025?m.expiryYear="Invalid Expiration Year.":(isNaN(z)||z<1||z>12||v.length!==4)&&(m.expiryMonth="Invalid Expiration Date."):m.expiryYear="Expiration year is required",(b=c==null?void 0:c.cvv)!=null&&b.trim()||(m.cvv="CVC is required"),c!=null&&c.expiryMonth&&(c!=null&&c.expiryYear)&&c.expiryMonth.length<=2&&c.expiryYear.length===4){let L=parseInt(c.expiryMonth,10),h=parseInt(c.expiryYear,10),C=new Date,B=C.getMonth()+1,Fe=C.getFullYear();(h<Fe||h===Fe&&L<B)&&(m.expiryMonth="Card is expired")}return Z(m),Object.keys(m).length>0},Be=async()=>{var m,c,z;Ve();try{let v={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,customer_id:e==null?void 0:e.customerId,addcard:!0},g=await bn.post(`${Se}get-payment-details`,v);console.log(g),Ge((m=g==null?void 0:g.data)==null?void 0:m.data),(z=(c=g==null?void 0:g.data)==null?void 0:c.data)!=null&&z.paymentGateway||(ce(),T("Something went wrong.")),Pe()}catch(v){console.log(v),Pe(),ce(),T("Something went wrong.")}};return gi(()=>{e!=null&&e.merchantPublicKey&&Be()},[e==null?void 0:e.merchantPublicKey]),Q.createElement(Q.Fragment,null,Q.createElement(Jt,null),Q.createElement(Bn,null),Q.createElement(Lt,{loading:ae}),$e&&Q.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},Q.createElement(Xt,{error:$e,onClose:ce})),Ae&&Q.createElement(On,{onClose:k}),!$e&&!Ae&&Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"container-creditcard add-card modal-content",id:"add-credit-card-panel",style:{margin:"auto"}},Q.createElement("form",{id:"creditCardForm",onSubmit:async m=>{var z,v,g,r,f,p,x,b,L,h,C,B,Fe,Nt,ot,st;m.preventDefault();let c=Ue();if(console.log(y),!c){let bt=DatacapWebToken.validateCardNumber(y==null?void 0:y.cardNumber.replaceAll(" ","")),tt=DatacapWebToken.validateExpirationDate(y==null?void 0:y.expiryMonth,y==null?void 0:y.expiryYear),xe=DatacapWebToken.validateCVV(y==null?void 0:y.cvv),G={};if(bt||(G.cardNumber="Invalid card Number"),tt||(G.expiryMonth="Invalid Expiration Date."),xe||(G.cvv="Invalid CVV"),Z(G),bt&&xe&&tt){Ve();try{let I=async function(ne){var Ke,D,mt,Oe,N;if(console.log(ne),ne.Error)console.log(ne==null?void 0:ne.Error),T(ne.Error),Pe();else{let s={userId:e==null?void 0:e.customerId,cardName:y==null?void 0:y.cardName,zip:y==null?void 0:y.zipCode,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,token:ne};try{let J=await bn.post(`${Se}add-card`,s);console.log(J);let Ce={fractalpayPublicKey:e==null?void 0:e.merchantPublicKey,wallet_id:"",card_number:y==null?void 0:y.cardNumber.replaceAll(" ",""),exp_month:y==null?void 0:y.expiryMonth,exp_year:(Ke=y==null?void 0:y.expiryYear)==null?void 0:Ke.slice(-2),cvv:y==null?void 0:y.cvv};try{let K=await bn.post(`${Se}link-wallet`,Ce);console.log(K),Y(!0),Pe(),u({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),on(m,"close","")}catch(K){console.log(K),Pe(),T(((mt=(D=K==null?void 0:K.response)==null?void 0:D.data)==null?void 0:mt.message)||(K==null?void 0:K.message)||"Something went wrong.")}}catch(J){console.log(J),Pe(),T(((N=(Oe=J==null?void 0:J.response)==null?void 0:Oe.data)==null?void 0:N.message)||(J==null?void 0:J.message)||"Something went wrong.")}}};if((be==null?void 0:be.paymentGateway)===32){let ne={method:"POST",redirect:"follow"};try{let Ke=await bn.post(`${Yt}api/v1/widget/generate-session`,ne),D=Number(y==null?void 0:y.expiryYear)%100,mt=y==null?void 0:y.cardNumber;mt=mt==null?void 0:mt.replace(/\s+/g,"");let Oe=`${mt}=${D}${y==null?void 0:y.expiryMonth} ${y==null?void 0:y.cvv}`,s=forge.pki.publicKeyFromPem((v=(z=Ke==null?void 0:Ke.data)==null?void 0:z.data)==null?void 0:v.publicKeyPem).encrypt(Oe,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),J=forge.util.encode64(s),Ce={"Content-Type":"application/json","x-app-session-key":(r=(g=Ke.data)==null?void 0:g.data)==null?void 0:r.session_key},K=JSON.stringify({enc_track2_data:`${J}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(p=(f=Ke==null?void 0:Ke.data)==null?void 0:f.data)==null?void 0:p.session_key}`});try{let Ne=await bn.post(`${Ut}tokenizer/tokenize`,K,{headers:Ce}),we=JSON.stringify(A(M({},(x=Ne==null?void 0:Ne.data)==null?void 0:x.data),{cvv:y==null?void 0:y.cvv,cardName:y==null?void 0:y.cardName,zip:y==null?void 0:y.zipCode,userId:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey})),rt={"Content-Type":"application/json"};try{let fe=await bn.post(`${Se}add-card`,we,{headers:rt});console.log(fe),(b=fe==null?void 0:fe.data)!=null&&b.result&&(Y(!0),Pe(),on(m,"close",""))}catch(fe){Pe(),T(((h=(L=fe==null?void 0:fe.response)==null?void 0:L.data)==null?void 0:h.message)||(fe==null?void 0:fe.message)||"Something went wrong.")}}catch(Ne){Pe(),T(((B=(C=Ne==null?void 0:Ne.response)==null?void 0:C.data)==null?void 0:B.message)||(Ne==null?void 0:Ne.message)||"Something went wrong.")}}catch(Ke){Pe(),T(((Nt=(Fe=Ke==null?void 0:Ke.response)==null?void 0:Fe.data)==null?void 0:Nt.message)||(Ke==null?void 0:Ke.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(be==null?void 0:be.dctoken,"creditCardForm",I)}catch(I){Pe(),T(((st=(ot=I==null?void 0:I.response)==null?void 0:ot.data)==null?void 0:st.message)||(I==null?void 0:I.message)||"Something went wrong.")}}}},style:{padding:"0 10px"}},Q.createElement("div",{style:{maxHeight:"350px",minHeight:"0"},className:"card-scrl"},Q.createElement("div",{className:"form-group",style:{marginTop:"0",marginBottom:"10px"}},Q.createElement("label",{htmlFor:"cardNumber"},"Card Number"),Q.createElement("input",{type:"text","data-token":"card_number",placeholder:"Enter card number",maxLength:19,inputMode:"numeric",value:(y==null?void 0:y.cardNumber)||"",onChange:m=>V(m),ref:ee}),(q==null?void 0:q.cardNumber)&&Q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},q==null?void 0:q.cardNumber),Q.createElement("br",null)),Q.createElement("div",{className:"card-dtl"},Q.createElement("div",{className:"exp-cvc-container",style:{margin:"0"}},Q.createElement("div",{className:"form-group",style:{marginTop:"0"}},Q.createElement("label",{htmlFor:"expMonth"},"MM"),Q.createElement("input",{"data-token":"exp_month",className:"form-control required",type:"text",placeholder:"MM",maxLength:2,value:(y==null?void 0:y.expiryMonth)||"",onChange:m=>je("expiryMonth",m.target.value),ref:R}),(q==null?void 0:q.expiryMonth)&&Q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},q==null?void 0:q.expiryMonth)),Q.createElement("div",{className:"form-group",style:{marginTop:"0"}},Q.createElement("label",{htmlFor:"expYear"},"YYYY"),Q.createElement("input",{"data-token":"exp_year",className:"form-control required",type:"text",placeholder:"YYYY",maxLength:4,value:(y==null?void 0:y.expiryYear)||"",onChange:m=>je("expiryYear",m.target.value),ref:W}),(q==null?void 0:q.expiryYear)&&Q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},q==null?void 0:q.expiryYear)),Q.createElement("div",{className:"form-group",style:{marginTop:"0"}},Q.createElement("label",{htmlFor:"cvc"},"CVC"),Q.createElement("input",{"data-token":"cvv",className:"form-control required",type:"text",placeholder:"CVC",maxLength:4,value:(y==null?void 0:y.cvv)||"",onChange:m=>je("cvv",m.target.value),ref:re}),(q==null?void 0:q.cvv)&&Q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},q==null?void 0:q.cvv)))),Q.createElement("div",{className:"form-group",style:{marginTop:"0"}},Q.createElement("label",{htmlFor:"cardholderName"},"Name on card"),Q.createElement("input",{type:"text",id:"cardholderName",name:"cardholderName",placeholder:"Name on card required",value:(y==null?void 0:y.cardName)||"",onChange:m=>{let c=m.target.value;/^[a-zA-Z\s]*$/.test(c)&&je("cardName",c)},ref:i}),(q==null?void 0:q.cardName)&&Q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},q==null?void 0:q.cardName)),Q.createElement("div",{className:"form-group",style:{marginTop:"0"}},Q.createElement("label",{htmlFor:"zipcode"},"Zip"),Q.createElement("input",{type:"text",id:"",name:"zipcode",placeholder:"Zip",value:(_=y==null?void 0:y.zipCode)!=null?_:"",onChange:m=>je("zipCode",m.target.value)}),(q==null?void 0:q.zipCode)&&Q.createElement("span",{className:"error-span",style:{color:"red",fontSize:"12px"}},q==null?void 0:q.zipCode))),Q.createElement("input",{type:"submit",className:"idle-green-btn w-100",defaultValue:"Submit"})))))}import F,{useState as Nn}from"react";import wn from"axios";import yi from"react";function Tn({}){return yi.createElement("style",null,`
|
|
2077
1566
|
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap");
|
|
2078
1567
|
|
|
2079
1568
|
.creditformbox {
|
|
@@ -2217,732 +1706,4 @@ position:relative;
|
|
|
2217
1706
|
background:#2979FF !important;
|
|
2218
1707
|
color:#ffffff !important;
|
|
2219
1708
|
}
|
|
2220
|
-
`)}function sa({session_token:e,callback:C,isloading:ee,onCancel:R,showChecks:$,merchantName:Me,signCheckbox:U,checkedSignCheckbox:$e,onCheckSign:Ue}){var Pt;let[ye,O]=Yn(!1),[me,ve]=Yn(!1),[o,y]=Yn(),[f,Q]=Yn({}),[ce,k]=Yn(""),Ge=()=>O(!0),ne=()=>O(!1),Fe=()=>{var L,x,d,v,S,M,_,q;let B={},g=o,c=parseInt((g==null?void 0:g.expiryMonth)||"",10),J=(g==null?void 0:g.expiryYear)||"";return(L=g==null?void 0:g.firstName)!=null&&L.trim()||(B.firstName="Please enter a first name."),(x=g==null?void 0:g.lastName)!=null&&x.trim()||(B.lastName="Please enter a last name."),(d=g==null?void 0:g.cardNumber)!=null&&d.trim()||(B.cardNumber="Please enter a card number."),(v=g==null?void 0:g.expiryMonth)!=null&&v.trim()?(Number(g==null?void 0:g.expiryMonth)>12||Number(g==null?void 0:g.expiryMonth)<1)&&(B.expiryMonth="Invalid Expiration Month."):B.expiryMonth="Please enter an expiry month.",(S=g==null?void 0:g.expiryYear)!=null&&S.trim()?((M=g==null?void 0:g.expiryYear)==null?void 0:M.trim().length)!==4||Number(g==null?void 0:g.expiryYear)<2025?B.expiryYear="Invalid Expiration Year.":(isNaN(c)||c<1||c>12||J.length!==4)&&(B.expiryMonth="Invalid Expiration Date."):B.expiryYear="Please enter an expiry year.",(_=g==null?void 0:g.cvv)!=null&&_.trim()||(B.cvv="Please enter a CVV."),(q=g==null?void 0:g.zipCode)!=null&&q.trim()||(B.zipCode="Please enter a zip code."),U&&!$e&&(B.checkSign="You must authorize this before proceeding."),$&&!(g!=null&&g.authHold)&&(B.authHold="You must authorize this before proceeding."),$&&!(g!=null&&g.authorise)&&(B.authorise="Please confirm your authorization to continue."),Q(B),Object.keys(B).length>0},b=B=>{let c=B.target.value.replace(/\D/g,""),J="";/^3[47]/.test(c)?J=c.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(x,d,v,S)=>[d,v,S].filter(Boolean).join(" ")):J=c.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(x,d,v,S,M)=>[d,v,S,M].filter(Boolean).join(" ")),Q(L=>A(F({},L),{cardNumber:""})),y(L=>A(F({},L),{cardNumber:J}))},we=(B,g)=>{let c=B;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(c)){(g===""||/^[0-9]+$/.test(g))&&(Q(L=>A(F({},L),{[c]:""})),y(L=>A(F({},L),{[c]:g})));return}Q(L=>A(F({},L),{[c]:""})),y(L=>A(F({},L),{[c]:g}))},oe=()=>{let B=DatacapWebToken.validateCardNumber(o==null?void 0:o.cardNumber.replaceAll(" ","")),g=DatacapWebToken.validateExpirationDate(o==null?void 0:o.expiryMonth,o==null?void 0:o.expiryYear),c=DatacapWebToken.validateCVV(o==null?void 0:o.cvv),J={};return B||(J.cardNumber="Invalid card Number"),g||(J.expiryMonth="Invalid Expiration Date."),c||(J.cvv="Invalid CVV"),Q(J),B&&c&&g},I=async B=>{var g,c;if(B.Error)k(B.Error),ne();else{let J={token:B.Token,resp:B},L=await $n.post(`${Pe}api/v1/gateway/update/token/${e}`,J);if((L==null?void 0:L.status)==200){let x=F(F({Token:(c=(g=L==null?void 0:L.data)==null?void 0:g.data)==null?void 0:c.gateway_token,Brand:B.Brand,ExpirationMonth:B.ExpirationMonth,ExpirationYear:B.ExpirationYear,Last4:B.Last4,Bin:B.Bin,CVV:B.CVV,postalCode:o==null?void 0:o.zipCode},$&&{authHold:o==null?void 0:o.authHold}),$&&{authorise:o==null?void 0:o.authorise});ne(),C(x)}}},Je=async()=>{var B,g,c,J,L,x,d,v,S,M;try{let _={method:"POST",redirect:"follow"},q=await $n.post(`${Pe}api/v1/widget/generate-session`,_),h=Number(o==null?void 0:o.expiryYear)%100,G=`${(B=o==null?void 0:o.cardNumber)==null?void 0:B.replace(/\s+/g,"")}=${h}${o==null?void 0:o.expiryMonth} ${o==null?void 0:o.cvv}`,zt=forge.pki.publicKeyFromPem((c=(g=q==null?void 0:q.data)==null?void 0:g.data)==null?void 0:c.publicKeyPem).encrypt(G,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),at=forge.util.encode64(zt),pt={"Content-Type":"application/json","x-app-session-key":(L=(J=q.data)==null?void 0:J.data)==null?void 0:L.session_key},Mt=JSON.stringify({enc_track2_data:at,algorithm:"RSAES_OAEP_SHA_1",session_key:(d=(x=q==null?void 0:q.data)==null?void 0:x.data)==null?void 0:d.session_key}),mt=await $n.post(`${Ht}tokenizer/tokenize`,Mt,{headers:pt});if((mt==null?void 0:mt.status)==200){let qe=(S=(v=mt==null?void 0:mt.data)==null?void 0:v.data)==null?void 0:S.token;try{let le=await $n.post(`${Pe}api/v1/gateway/verify-and-save/${e}`,{token:qe});if((le==null?void 0:le.status)==200){let Z=(M=le==null?void 0:le.data)==null?void 0:M.data,Ne={Token:Z.gateway_token,Brand:Z.card_data.brand,ExpirationMonth:Z.card_data.expire_mm,ExpirationYear:Z.card_data.expire_yy,Last4:Z.card_data.last4,Bin:Z.card_data.bin,postalCode:o==null?void 0:o.zipCode};ne(),C(Ne)}}catch(le){console.log(le,"error"),ne()}}}catch(_){console.log(_,"eroror")}},ae=async B=>{var J,L,x,d,v,S,M;if(B.preventDefault(),!(Fe()||!oe())){Ge();try{let _=await $n.get(`${Pe}api/v1/gateway/token/${e}`);if((_==null?void 0:_.status)==200){let q=(L=(J=_==null?void 0:_.data)==null?void 0:J.data)==null?void 0:L.gateway_token;((d=(x=_==null?void 0:_.data)==null?void 0:x.data)==null?void 0:d.paymentGateway)==((v=Zn)==null?void 0:v.FRACTALKEY)?await Je():DatacapWebToken.requestToken(q,"creditCardForm",I)}}catch(_){ne(),k(((M=(S=_==null?void 0:_.response)==null?void 0:S.data)==null?void 0:M.message)||"Something went wrong!")}}},Te=()=>{k("")},Xe=()=>{k(""),y({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1,checkSign:!1}),R()};return K.createElement(K.Fragment,null,K.createElement(Dt,null),K.createElement(Rn,null),K.createElement(Ot,{loading:ye||ee}),ce&&K.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},K.createElement(tn,{error:ce,onClose:Te})),!ce&&K.createElement("div",{className:"creditformbox"},K.createElement("form",{id:"creditCardForm",onSubmit:ae},K.createElement("div",{className:"name-row"},K.createElement("div",{className:"form-group"},K.createElement("label",null," First Name ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(o==null?void 0:o.firstName)||"",onChange:B=>{let g=B.target.value;/^[a-zA-Z\s]*$/.test(g)&&we("firstName",g)}}),(f==null?void 0:f.firstName)&&K.createElement("small",{className:"error"},f==null?void 0:f.firstName)),K.createElement("div",{className:"form-group"},K.createElement("label",null," Last Name ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(o==null?void 0:o.lastName)||"",onChange:B=>{let g=B.target.value;/^[a-zA-Z\s]*$/.test(g)&&we("lastName",g)}}),(f==null?void 0:f.lastName)&&K.createElement("small",{className:"error"},f==null?void 0:f.lastName))),K.createElement("div",{className:"form-pay-row"},K.createElement("div",{className:"form-group"},K.createElement("label",null," Card Number ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(o==null?void 0:o.cardNumber)||"",onChange:B=>b(B)}),(f==null?void 0:f.cardNumber)&&K.createElement("small",{className:"error"},f==null?void 0:f.cardNumber))),K.createElement("div",{className:"card-pay-row"},K.createElement("div",{className:"form-group"},K.createElement("label",null," Exp Month ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(o==null?void 0:o.expiryMonth)||"",onChange:B=>we("expiryMonth",B.target.value)}),(f==null?void 0:f.expiryMonth)&&K.createElement("small",{className:"error"},f==null?void 0:f.expiryMonth)),K.createElement("div",{className:"form-group"},K.createElement("label",null," Exp Year ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(o==null?void 0:o.expiryYear)||"",onChange:B=>we("expiryYear",B.target.value)}),(f==null?void 0:f.expiryYear)&&K.createElement("small",{className:"error"},f==null?void 0:f.expiryYear)),K.createElement("div",{className:"form-group"},K.createElement("label",null," CVV ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(o==null?void 0:o.cvv)||"",onChange:B=>we("cvv",B.target.value)}),(f==null?void 0:f.cvv)&&K.createElement("small",{className:"error"},f==null?void 0:f.cvv)),K.createElement("div",{className:"form-group"},K.createElement("label",null," Zip ",K.createElement("span",{className:"text-danger"},"*")),K.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(Pt=o==null?void 0:o.zipCode)!=null?Pt:"",onChange:B=>we("zipCode",B.target.value)}),(f==null?void 0:f.zipCode)&&K.createElement("small",{className:"error"},f==null?void 0:f.zipCode))),U&&K.createElement("div",{className:"checks-row"},K.createElement("input",{name:"discalosure",type:"checkbox",id:"disclosureCheck",checked:$e,onChange:B=>Ue(B.target.checked)}),K.createElement("label",{htmlFor:"disclosureCheck",className:"form-check-label"},"Please agree to the following in order to add Payment method.")),U&&(f==null?void 0:f.checkSign)&&K.createElement("small",{className:"check-error"},f==null?void 0:f.checkSign),$&&K.createElement(K.Fragment,null,K.createElement("div",{className:"checks-row"},K.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(o!=null&&o.authHold),onChange:B=>we("authHold",B.target.checked)}),K.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.")),(f==null?void 0:f.authHold)&&K.createElement("small",{className:"check-error"},f==null?void 0:f.authHold),K.createElement("div",{className:"checks-row "},K.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(o!=null&&o.authorise),onChange:B=>we("authorise",B.target.checked)}),K.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},me?K.createElement(K.Fragment,null,K.createElement("span",null,"By providing your payment information, you authorize"," ",K.createElement("strong",null,Me),", 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"," ",K.createElement("strong",null,Me),". You may request the removal of your stored payment information at any time by contacting"," ",K.createElement("strong",null,Me)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",K.createElement("a",{href:"#",onClick:B=>{B.preventDefault(),ve(!1)}},"See less ..."))):K.createElement(K.Fragment,null,K.createElement("span",null,"By providing your payment information, you authorize ",Me,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),K.createElement("a",{href:"#",onClick:B=>{B.preventDefault(),ve(!0)}},"See more ...")))),(f==null?void 0:f.authorise)&&K.createElement("small",{className:"check-error"},f==null?void 0:f.authorise)),K.createElement("div",{className:"button-row"},K.createElement("button",{className:"cancelbtn",type:"button",onClick:Xe},"Cancel"),K.createElement("button",{className:"savebtn",type:"submit"},"Save")))))}import r,{useEffect as ma,useLayoutEffect as da,useState as Nt}from"react";import la from"react";function ei(){let e="#000",C="#fff",ee="#212529",R="#dee2e6";return la.createElement("style",null,`
|
|
2221
|
-
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
2222
|
-
body
|
|
2223
|
-
{
|
|
2224
|
-
font-family: 'Inter', sans-serif;
|
|
2225
|
-
}
|
|
2226
|
-
input
|
|
2227
|
-
{
|
|
2228
|
-
font-family: 'Inter', sans-serif !important;
|
|
2229
|
-
}
|
|
2230
|
-
.frac-form .form-group-frac{
|
|
2231
|
-
margin:0 !important
|
|
2232
|
-
}
|
|
2233
|
-
.frac-form .mb-4{
|
|
2234
|
-
margin-bottom : 10px !important
|
|
2235
|
-
}
|
|
2236
|
-
.frac-form .save-ach-div{
|
|
2237
|
-
display:flex !important;
|
|
2238
|
-
gap:5px !important;
|
|
2239
|
-
align-items:center
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
.frac-form .card-cvv-in{
|
|
2243
|
-
height : 36px !importantt;
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
.frac-form .pay-payment-amount{
|
|
2247
|
-
text-align:start !important
|
|
2248
|
-
}
|
|
2249
|
-
.frac-form .pay-amount{
|
|
2250
|
-
text-align:start !important
|
|
2251
|
-
}
|
|
2252
|
-
.frac-form .pay-main-logo{
|
|
2253
|
-
text-align:start !important
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
.paymentBtn {
|
|
2259
|
-
background-color: black;
|
|
2260
|
-
border: none;
|
|
2261
|
-
color: white;
|
|
2262
|
-
padding: 15px 32px;
|
|
2263
|
-
text-align: center;
|
|
2264
|
-
text-decoration: none;
|
|
2265
|
-
display: inline-block;
|
|
2266
|
-
font-size: 16px;
|
|
2267
|
-
margin: 4px 2px;
|
|
2268
|
-
cursor: pointer;
|
|
2269
|
-
border-radius: 180px;
|
|
2270
|
-
/* width: auto; */
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
.main-logo {
|
|
2274
|
-
text-align: center;
|
|
2275
|
-
margin-bottom: 20px;
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
.main-logo img {
|
|
2279
|
-
max-width: 180px;
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
.pay-main-box {
|
|
2283
|
-
width: 365px !important;
|
|
2284
|
-
height: 93%;
|
|
2285
|
-
background: 0 0 #ffffff;
|
|
2286
|
-
border-radius: 12px;
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
border: 1px solid #E0DFE2;
|
|
2290
|
-
margin: 0 auto;
|
|
2291
|
-
display: block;
|
|
2292
|
-
padding: 0px 26px !important
|
|
2293
|
-
}
|
|
2294
|
-
.pay-main-box .pay-header {
|
|
2295
|
-
display: flex;
|
|
2296
|
-
justify-content: center;
|
|
2297
|
-
align-items: center;
|
|
2298
|
-
text-align: center;
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
|
-
.pay-main-box .pay-header button {
|
|
2302
|
-
border: 0;
|
|
2303
|
-
background: none;
|
|
2304
|
-
padding: 0;
|
|
2305
|
-
box-shadow: 0;
|
|
2306
|
-
outline: inherit;
|
|
2307
|
-
}
|
|
2308
|
-
|
|
2309
|
-
.pay-main-box h1 {
|
|
2310
|
-
margin: 0;
|
|
2311
|
-
flex: 1;
|
|
2312
|
-
padding: 10px 0;
|
|
2313
|
-
font-size: 23px;
|
|
2314
|
-
font-weight: 500;
|
|
2315
|
-
color: #35254D;
|
|
2316
|
-
align-items: start;
|
|
2317
|
-
display: flex;
|
|
2318
|
-
}
|
|
2319
|
-
.tab {
|
|
2320
|
-
overflow: hidden;
|
|
2321
|
-
padding: 5px;
|
|
2322
|
-
border-radius: 8px;
|
|
2323
|
-
display: flex;
|
|
2324
|
-
justify-content: space-around;
|
|
2325
|
-
margin-bottom:12px
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
|
-
/* Style the buttons inside the tab */
|
|
2329
|
-
.tab button {
|
|
2330
|
-
float: left;
|
|
2331
|
-
border: none;
|
|
2332
|
-
outline: none;
|
|
2333
|
-
cursor: pointer;
|
|
2334
|
-
background:white;
|
|
2335
|
-
padding: 11px 16px;
|
|
2336
|
-
transition: 0.3s;
|
|
2337
|
-
font-size: 16px;
|
|
2338
|
-
width: 143px;
|
|
2339
|
-
border-radius: 5px;
|
|
2340
|
-
box-shadow: inherit;
|
|
2341
|
-
outline: none;
|
|
2342
|
-
color: ${e};
|
|
2343
|
-
}
|
|
2344
|
-
|
|
2345
|
-
/* Change background color of buttons on hover */
|
|
2346
|
-
.tab button:hover {
|
|
2347
|
-
background-color: #f0f0f0;
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
|
-
/* Create an active/current tablink class */
|
|
2351
|
-
// .tab button.active {
|
|
2352
|
-
// background-color: #ccc;
|
|
2353
|
-
// }
|
|
2354
|
-
|
|
2355
|
-
/* Style the tab content */
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
.parent-pay-container{
|
|
2359
|
-
padding: 24px;
|
|
2360
|
-
}
|
|
2361
|
-
.pay-container{
|
|
2362
|
-
display: grid;
|
|
2363
|
-
grid-template-columns: 2fr 3fr;
|
|
2364
|
-
|
|
2365
|
-
}
|
|
2366
|
-
.pay-main{
|
|
2367
|
-
padding-y: 20px}
|
|
2368
|
-
|
|
2369
|
-
.request-payment-close-popup {
|
|
2370
|
-
position: absolute;
|
|
2371
|
-
right: 20px;
|
|
2372
|
-
top: 20px;
|
|
2373
|
-
cursor: pointer;
|
|
2374
|
-
}
|
|
2375
|
-
.pay-conatiner-one{
|
|
2376
|
-
border-right: 1px solid #E0DFE2;
|
|
2377
|
-
display: flex;
|
|
2378
|
-
flex-direction: column;
|
|
2379
|
-
justify-content: space-between;
|
|
2380
|
-
}
|
|
2381
|
-
.pay-conatiner-one-first{
|
|
2382
|
-
|
|
2383
|
-
min-height:inherit !important;
|
|
2384
|
-
}
|
|
2385
|
-
.pay-conatiner-one-last{
|
|
2386
|
-
display:flex;
|
|
2387
|
-
font-size:12px;
|
|
2388
|
-
gap:5px;
|
|
2389
|
-
max-width:250px;
|
|
2390
|
-
align-items:center;
|
|
2391
|
-
color:black !important
|
|
2392
|
-
}
|
|
2393
|
-
.pay-conatiner-one-last img{
|
|
2394
|
-
width : 17px;
|
|
2395
|
-
height:17px
|
|
2396
|
-
}
|
|
2397
|
-
.pay-conatiner-two{
|
|
2398
|
-
padding: 0 5% 0;
|
|
2399
|
-
}
|
|
2400
|
-
.pay-logo-container{
|
|
2401
|
-
border-bottom: 1px solid #E0DFE2
|
|
2402
|
-
}
|
|
2403
|
-
.pay-heading{
|
|
2404
|
-
margin: 0;
|
|
2405
|
-
flex: 1;
|
|
2406
|
-
padding: 10px 0;
|
|
2407
|
-
font-size: 23px;
|
|
2408
|
-
font-weight: 500;
|
|
2409
|
-
color: #35254D;
|
|
2410
|
-
align-items: start;
|
|
2411
|
-
display: flex;
|
|
2412
|
-
}
|
|
2413
|
-
.pay-main-logo > img{
|
|
2414
|
-
width: 50%;
|
|
2415
|
-
}
|
|
2416
|
-
.pay-main-logo-res > img{
|
|
2417
|
-
width: 50%;
|
|
2418
|
-
display : none
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2421
|
-
.pay-payment-amount{
|
|
2422
|
-
display: block;
|
|
2423
|
-
font-size: 12px;
|
|
2424
|
-
color: #727272;
|
|
2425
|
-
margin-bottom: 8px;
|
|
2426
|
-
}
|
|
2427
|
-
.pay-amount-conatiner{
|
|
2428
|
-
margin-top: 6%;
|
|
2429
|
-
}
|
|
2430
|
-
.pay-amount{
|
|
2431
|
-
color: #000000;
|
|
2432
|
-
font-size: 38px;
|
|
2433
|
-
display: block;
|
|
2434
|
-
line-height: 110%;
|
|
2435
|
-
letter-spacing: -1px;
|
|
2436
|
-
}
|
|
2437
|
-
.frac-form label{
|
|
2438
|
-
font-family: 'IBM Plex Mono', monospace !important;
|
|
2439
|
-
color: #727272 !important;
|
|
2440
|
-
margin-bottom: 2px !important;
|
|
2441
|
-
font-weight: 600 !important;
|
|
2442
|
-
font-size: 12px !important;
|
|
2443
|
-
display:block !important;
|
|
2444
|
-
text-align : left !important
|
|
2445
|
-
}
|
|
2446
|
-
.form-control-frac{
|
|
2447
|
-
display: block;
|
|
2448
|
-
width: 100%;
|
|
2449
|
-
padding: .375rem .75rem;
|
|
2450
|
-
font-size: 1rem;
|
|
2451
|
-
font-weight: 400;
|
|
2452
|
-
line-height: 1.5;
|
|
2453
|
-
color: ${ee};
|
|
2454
|
-
-webkit-appearance: none;
|
|
2455
|
-
-moz-appearance: none;
|
|
2456
|
-
appearance: none;
|
|
2457
|
-
background-color: ${C};
|
|
2458
|
-
background-clip: padding-box;
|
|
2459
|
-
border: 1px solid ${R};
|
|
2460
|
-
border-radius: 0.375rem;
|
|
2461
|
-
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
|
2462
|
-
}
|
|
2463
|
-
.form-control-frac:focus{
|
|
2464
|
-
border-color: #86b7fe;
|
|
2465
|
-
outline: 0;
|
|
2466
|
-
}
|
|
2467
|
-
.toggle-num-wrapper {
|
|
2468
|
-
position: relative;
|
|
2469
|
-
}
|
|
2470
|
-
.card-number-new{
|
|
2471
|
-
border-bottom: none;
|
|
2472
|
-
border-bottom-left-radius: 0px;
|
|
2473
|
-
border-bottom-right-radius: 0px;
|
|
2474
|
-
}
|
|
2475
|
-
.card-crdi {
|
|
2476
|
-
display: flex;
|
|
2477
|
-
border: 1px solid ${R};
|
|
2478
|
-
border-radius: 0.375rem;
|
|
2479
|
-
}
|
|
2480
|
-
.card-expiry-new{
|
|
2481
|
-
border-top-left-radius: 0px;
|
|
2482
|
-
border-top-right-radius: 0px;
|
|
2483
|
-
}
|
|
2484
|
-
.exp-date-year-container{
|
|
2485
|
-
display: flex;
|
|
2486
|
-
flex-wrap: wrap;
|
|
2487
|
-
}
|
|
2488
|
-
.exp-date-year-container .form-group-frac{
|
|
2489
|
-
flex:1;
|
|
2490
|
-
padding: 0px !important
|
|
2491
|
-
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
.exp-date {
|
|
2495
|
-
float: left;
|
|
2496
|
-
// width: 30%
|
|
2497
|
-
}
|
|
2498
|
-
|
|
2499
|
-
.exp-date input {
|
|
2500
|
-
width: calc(100% + 1px);
|
|
2501
|
-
border-top-right-radius: 0;
|
|
2502
|
-
border-bottom-right-radius: 0;
|
|
2503
|
-
border: 0;
|
|
2504
|
-
border-right: 1px solid ${R};
|
|
2505
|
-
}
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
.exp-year {
|
|
2509
|
-
float: left;
|
|
2510
|
-
// width: 30%
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
.exp-year input {
|
|
2514
|
-
width: calc(100% + 1px);
|
|
2515
|
-
border-radius: 0;
|
|
2516
|
-
border-top: 0;
|
|
2517
|
-
border-bottom: 0;
|
|
2518
|
-
border-right: 1px solid ${R};
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
.exp-date input:focus {
|
|
2522
|
-
position: relative;
|
|
2523
|
-
z-index: 10;
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
.security-digit {
|
|
2527
|
-
float: right;
|
|
2528
|
-
// width: 40%;
|
|
2529
|
-
position: relative;
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
.security-digit input {
|
|
2533
|
-
border-top-left-radius: 0;
|
|
2534
|
-
border-bottom-left-radius: 0;
|
|
2535
|
-
border-top: 0;
|
|
2536
|
-
border-bottom: 0;
|
|
2537
|
-
border-right:0;
|
|
2538
|
-
}
|
|
2539
|
-
.card-expiry-new{
|
|
2540
|
-
border-top-left-radius: 0px;
|
|
2541
|
-
border-top-right-radius: 0px;
|
|
2542
|
-
}
|
|
2543
|
-
.form-control-frac{box-sizing: border-box ;}
|
|
2544
|
-
#PaymentForm .form-group-frac{
|
|
2545
|
-
padding:5px 0 ;
|
|
2546
|
-
matgin: 0 !important
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
.toggle-label {
|
|
2550
|
-
position: relative;
|
|
2551
|
-
display: inline-block;
|
|
2552
|
-
width: 40px;
|
|
2553
|
-
height: 24px;
|
|
2554
|
-
background-color: #ccc;
|
|
2555
|
-
border-radius: 12px;
|
|
2556
|
-
cursor: pointer;
|
|
2557
|
-
transition: background-color 0.3s;
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
|
-
.toggle-label::before {
|
|
2561
|
-
content: "";
|
|
2562
|
-
position: absolute;
|
|
2563
|
-
top: 2px;
|
|
2564
|
-
left: 2px;
|
|
2565
|
-
width: 20px;
|
|
2566
|
-
height: 20px;
|
|
2567
|
-
background: #ffffff;
|
|
2568
|
-
border-radius: 50%;
|
|
2569
|
-
transition: left 300ms linear;
|
|
2570
|
-
}
|
|
2571
|
-
|
|
2572
|
-
.toggle-checkbox {
|
|
2573
|
-
display: none;
|
|
2574
|
-
}
|
|
2575
|
-
|
|
2576
|
-
.toggle-checkbox:checked + .toggle-label {
|
|
2577
|
-
background-color: #4caf50;
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2580
|
-
.toggle-checkbox:checked + .toggle-label::before {
|
|
2581
|
-
left: 18px;
|
|
2582
|
-
}
|
|
2583
|
-
.ach-scrl {
|
|
2584
|
-
max-height: 380px;
|
|
2585
|
-
min-height: 380px;
|
|
2586
|
-
overflow-y: auto;
|
|
2587
|
-
padding-right: 6px;
|
|
2588
|
-
}
|
|
2589
|
-
.mb-4{
|
|
2590
|
-
margin-bottom:4px
|
|
2591
|
-
}
|
|
2592
|
-
.ach-scrl::-webkit-scrollbar {
|
|
2593
|
-
width: 3px;
|
|
2594
|
-
background-color: #F5F5F5;
|
|
2595
|
-
}
|
|
2596
|
-
.ach-scrl::-webkit-scrollbar-thumb {
|
|
2597
|
-
background-color: #35254D;
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2600
|
-
.error-span{
|
|
2601
|
-
color:red !important;
|
|
2602
|
-
font-size:12px !important;
|
|
2603
|
-
text-align: left !important;
|
|
2604
|
-
width: 100% !important;
|
|
2605
|
-
display: block;
|
|
2606
|
-
}
|
|
2607
|
-
|
|
2608
|
-
.charge-customer-name-frac{
|
|
2609
|
-
color: #161616;
|
|
2610
|
-
font-family: Inter;
|
|
2611
|
-
font-size: 24px;
|
|
2612
|
-
font-style: normal;
|
|
2613
|
-
font-weight: 600;
|
|
2614
|
-
line-height: 32px;
|
|
2615
|
-
letter-spacing: -0.48px;
|
|
2616
|
-
text-transform: capitalize;
|
|
2617
|
-
margin-top:0;
|
|
2618
|
-
margin-bottom:16px !important;
|
|
2619
|
-
text-align:left !important
|
|
2620
|
-
}
|
|
2621
|
-
.card-ach-heading-frac {
|
|
2622
|
-
color: #727272;
|
|
2623
|
-
font-family: Inter;
|
|
2624
|
-
font-size: 12px;
|
|
2625
|
-
font-style: normal;
|
|
2626
|
-
font-weight: 500;
|
|
2627
|
-
line-height: 18px;
|
|
2628
|
-
letter-spacing: -0.24px;
|
|
2629
|
-
margin : 0 0 10px !important;
|
|
2630
|
-
text-align : left
|
|
2631
|
-
}
|
|
2632
|
-
.card-list-div{
|
|
2633
|
-
max-height : 190px;
|
|
2634
|
-
overflow-y : auto;
|
|
2635
|
-
border:1px solid #E0DFE2;
|
|
2636
|
-
border-radius : 8px
|
|
2637
|
-
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
.card-list-div::-webkit-scrollbar{
|
|
2641
|
-
width:2px;
|
|
2642
|
-
background-color:#F5F5F5
|
|
2643
|
-
}
|
|
2644
|
-
.card-list-div::-webkit-scrollbar-thumb{
|
|
2645
|
-
background-color:#35254D
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
.card-list-single-div{
|
|
2649
|
-
border-bottom: 1px solid #E0DFE2;
|
|
2650
|
-
padding : 8px 11px;
|
|
2651
|
-
display : flex ;
|
|
2652
|
-
align-items:center;
|
|
2653
|
-
justify-content : space-between;
|
|
2654
|
-
gap:12px
|
|
2655
|
-
}
|
|
2656
|
-
.card-list-single-div:last-child {
|
|
2657
|
-
border-bottom: none;
|
|
2658
|
-
}
|
|
2659
|
-
.card-lint-div-in{
|
|
2660
|
-
min-height:444px}
|
|
2661
|
-
.card-number-radio{
|
|
2662
|
-
display:flex;
|
|
2663
|
-
gap:12px;
|
|
2664
|
-
}
|
|
2665
|
-
.card-number-radio .card-number-last-four{
|
|
2666
|
-
color:#161616 !important;
|
|
2667
|
-
font-family:Inter !important;
|
|
2668
|
-
font-size:14px !important;
|
|
2669
|
-
font-weight:500 !important;
|
|
2670
|
-
font-style:normal !important;
|
|
2671
|
-
line-height : 18px !important;
|
|
2672
|
-
latter-spacing:-0.18px !important
|
|
2673
|
-
}
|
|
2674
|
-
.card-expiry-date{
|
|
2675
|
-
margin:0;
|
|
2676
|
-
color:#00000080;
|
|
2677
|
-
font-family:Inter;
|
|
2678
|
-
font-size:14px;
|
|
2679
|
-
font-weight:500;
|
|
2680
|
-
font-style"normal;
|
|
2681
|
-
line-height : 18px;
|
|
2682
|
-
latter-spacing:-0.18px
|
|
2683
|
-
}
|
|
2684
|
-
.pay-with-other-card {
|
|
2685
|
-
margin-top : 12px;
|
|
2686
|
-
padding:12px 32px;
|
|
2687
|
-
border :1px solid #E0DFE2;
|
|
2688
|
-
border-radius : 1000px;
|
|
2689
|
-
display: flex;
|
|
2690
|
-
justify-content : center;
|
|
2691
|
-
align-items:center;
|
|
2692
|
-
gap:10px;
|
|
2693
|
-
// width:100%;
|
|
2694
|
-
background:white;
|
|
2695
|
-
cursor:pointer;
|
|
2696
|
-
color:#161616;
|
|
2697
|
-
text-align:center
|
|
2698
|
-
font-family: Inter;
|
|
2699
|
-
font-size: 14px;
|
|
2700
|
-
font-style: normal;
|
|
2701
|
-
font-weight: 500;
|
|
2702
|
-
line-height: 24px;
|
|
2703
|
-
letter-spacing: -0.28px;
|
|
2704
|
-
// margin-bottom: 50px;
|
|
2705
|
-
}
|
|
2706
|
-
.charge-payment-back-btn {
|
|
2707
|
-
display: flex;
|
|
2708
|
-
padding: 6px 12px !important ;
|
|
2709
|
-
align-items: center;
|
|
2710
|
-
gap: 6px;
|
|
2711
|
-
border-radius: 1000px;
|
|
2712
|
-
border: 1px solid #E0DFE2;
|
|
2713
|
-
background: #FFF;
|
|
2714
|
-
box-shadow: 0px 6px 12px 0px rgba(206, 197, 221, 0.31);
|
|
2715
|
-
font-size:16px;
|
|
2716
|
-
curso:pointer;
|
|
2717
|
-
color:black
|
|
2718
|
-
}
|
|
2719
|
-
.res-charge-payment-back-btn{
|
|
2720
|
-
padding: 9px 16px;
|
|
2721
|
-
align-items: center;
|
|
2722
|
-
gap: 6px;
|
|
2723
|
-
margin-bottom: 20px;
|
|
2724
|
-
border-radius: 1000px;
|
|
2725
|
-
border: 1px solid #E0DFE2;
|
|
2726
|
-
background: #FFF;
|
|
2727
|
-
box-shadow: 0px 6px 12px 0px rgba(206, 197, 221, 0.31);
|
|
2728
|
-
font-size:16px;
|
|
2729
|
-
curso:pointer;
|
|
2730
|
-
color:black;
|
|
2731
|
-
display:none
|
|
2732
|
-
}
|
|
2733
|
-
.btn {
|
|
2734
|
-
padding: 11px 23px;
|
|
2735
|
-
background-color: black;
|
|
2736
|
-
color: white;
|
|
2737
|
-
border: none;
|
|
2738
|
-
border-radius: 6px;
|
|
2739
|
-
font-weight: bold;
|
|
2740
|
-
margin: 0 10px;
|
|
2741
|
-
cursor: pointer;
|
|
2742
|
-
}
|
|
2743
|
-
|
|
2744
|
-
.custom-swal-icon {
|
|
2745
|
-
margin: 20px auto;
|
|
2746
|
-
}
|
|
2747
|
-
|
|
2748
|
-
.custom-swal-popup {
|
|
2749
|
-
font-size: 16px;
|
|
2750
|
-
text-align: center;
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2753
|
-
.frac-form .res-pay-con{
|
|
2754
|
-
display:none
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
.saveachtext p, .saveachtext b {
|
|
2758
|
-
font-size: 12px !important;
|
|
2759
|
-
color: #727272 !important;
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
.cardicon-img img {
|
|
2763
|
-
margin-top: -2px !important;
|
|
2764
|
-
}
|
|
2765
|
-
|
|
2766
|
-
.bankicon-img img {
|
|
2767
|
-
margin-top: -4px !important;
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
.cardicon {
|
|
2771
|
-
margin-right : 8px !important;
|
|
2772
|
-
width : 18px !important;
|
|
2773
|
-
}
|
|
2774
|
-
|
|
2775
|
-
.bankicon {
|
|
2776
|
-
margin-right : 8px !important;
|
|
2777
|
-
width : 18px !important;
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
.frac-tooltip-wrapper {
|
|
2782
|
-
position: absolute;
|
|
2783
|
-
right:0;
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
|
-
.frac-tooltip-icon {
|
|
2787
|
-
cursor: pointer;
|
|
2788
|
-
}
|
|
2789
|
-
.frac-tooltip-mn{
|
|
2790
|
-
position:relative;
|
|
2791
|
-
}
|
|
2792
|
-
.frac-tooltip-text {
|
|
2793
|
-
display: none;
|
|
2794
|
-
position: absolute;
|
|
2795
|
-
top:-15px;
|
|
2796
|
-
right: 22px;
|
|
2797
|
-
background: #161616;
|
|
2798
|
-
color: white;
|
|
2799
|
-
padding: 15px;
|
|
2800
|
-
border-radius: 10px;
|
|
2801
|
-
width: 200px;
|
|
2802
|
-
font-size:12px;
|
|
2803
|
-
word-break: break-word;
|
|
2804
|
-
white-space: normal;
|
|
2805
|
-
z-index: 999;
|
|
2806
|
-
}
|
|
2807
|
-
|
|
2808
|
-
.frac-tooltip-wrapper:hover .frac-tooltip-text {
|
|
2809
|
-
display: block;
|
|
2810
|
-
}
|
|
2811
|
-
|
|
2812
|
-
.frac-tooltip-text p,.frac-tooltip-text b {
|
|
2813
|
-
font-size : 12px !important;
|
|
2814
|
-
line-height : 1.5 !important;
|
|
2815
|
-
margin-bottom : 10px !important;
|
|
2816
|
-
}
|
|
2817
|
-
|
|
2818
|
-
.amt-pay-con {
|
|
2819
|
-
padding-right: 24px;
|
|
2820
|
-
}
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
@media (max-width: 768px) {
|
|
2825
|
-
.request-payment-close-popup {
|
|
2826
|
-
right: 12px !important;
|
|
2827
|
-
top: 12px !important;
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
.parent-pay-container{
|
|
2831
|
-
padding:24px;
|
|
2832
|
-
}
|
|
2833
|
-
.pay-container {
|
|
2834
|
-
grid-template-columns: 1fr;
|
|
2835
|
-
padding: 10px 5%;
|
|
2836
|
-
border:1px solid #E0DFE2;
|
|
2837
|
-
border-radius : 12px
|
|
2838
|
-
}
|
|
2839
|
-
.pay-conatiner-one{
|
|
2840
|
-
border-right: none;
|
|
2841
|
-
}
|
|
2842
|
-
.pay-conatiner-one-first{
|
|
2843
|
-
min-height:0
|
|
2844
|
-
}
|
|
2845
|
-
.pay-main-logo > img{
|
|
2846
|
-
display: none;
|
|
2847
|
-
}
|
|
2848
|
-
.pay-main-logo-res > img {
|
|
2849
|
-
display:block;
|
|
2850
|
-
margin:auto
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
.pay-logo-container{
|
|
2854
|
-
border :none
|
|
2855
|
-
}
|
|
2856
|
-
// .res-charge-payment-back-btn {
|
|
2857
|
-
// display:flex !important
|
|
2858
|
-
// }
|
|
2859
|
-
// .charge-payment-back-btn{
|
|
2860
|
-
// display:none !important
|
|
2861
|
-
// }
|
|
2862
|
-
|
|
2863
|
-
.frac-new-form .pay-amount-conatiner {
|
|
2864
|
-
margin-top: 0px;
|
|
2865
|
-
margin-bottom: 24px;
|
|
2866
|
-
}
|
|
2867
|
-
.frac-form .res-pay-con{
|
|
2868
|
-
display:flex;
|
|
2869
|
-
justify-content :space-between;
|
|
2870
|
-
align-items:center;
|
|
2871
|
-
padding-bottom : 10px
|
|
2872
|
-
}
|
|
2873
|
-
.amt-pay-con {
|
|
2874
|
-
padding-right: 0px;
|
|
2875
|
-
}
|
|
2876
|
-
.pay-conatiner-one-last{
|
|
2877
|
-
display:none}
|
|
2878
|
-
.pay-conatiner-two{
|
|
2879
|
-
padding:0
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
}
|
|
2884
|
-
@media (max-width : 512px){
|
|
2885
|
-
.tab button {
|
|
2886
|
-
padding: 6px 16px;
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
.frac-cash-discount-fee {
|
|
2892
|
-
display: flex;
|
|
2893
|
-
padding: 11px;
|
|
2894
|
-
justify-content: space-between;
|
|
2895
|
-
align-items: center;
|
|
2896
|
-
align-self: stretch;
|
|
2897
|
-
border-radius: 8px;
|
|
2898
|
-
border: 1px solid #E0DFE2;
|
|
2899
|
-
background: #F6F6F7;
|
|
2900
|
-
margin-top: 24px;
|
|
2901
|
-
}
|
|
2902
|
-
.frac-cash-discount-fee small {
|
|
2903
|
-
color:#727272;
|
|
2904
|
-
font-size: 12px;
|
|
2905
|
-
font-weight: 500;
|
|
2906
|
-
}
|
|
2907
|
-
.frac-cash-discount-fee p{
|
|
2908
|
-
margin:0px;
|
|
2909
|
-
font-size: 14px;
|
|
2910
|
-
font-weight: 500;
|
|
2911
|
-
}
|
|
2912
|
-
.frac-card-payment-heading {
|
|
2913
|
-
font-size: 24px;
|
|
2914
|
-
font-style: normal;
|
|
2915
|
-
font-weight: 600;
|
|
2916
|
-
margin:0px;
|
|
2917
|
-
}
|
|
2918
|
-
|
|
2919
|
-
.frac-heading-card-wrap {
|
|
2920
|
-
display: flex;
|
|
2921
|
-
align-items: center;
|
|
2922
|
-
margin-bottom:12px;
|
|
2923
|
-
}
|
|
2924
|
-
.frac-backarrow {
|
|
2925
|
-
margin-right: 10px;
|
|
2926
|
-
}
|
|
2927
|
-
.frac-charge-payment-back-btn-wrap , .frac-tab-2{
|
|
2928
|
-
display: none;
|
|
2929
|
-
}
|
|
2930
|
-
.frac-pay-conatiner-one{
|
|
2931
|
-
display: flex;
|
|
2932
|
-
flex-direction: column;
|
|
2933
|
-
justify-content: space-between;
|
|
2934
|
-
min-height: auto;
|
|
2935
|
-
}
|
|
2936
|
-
|
|
2937
|
-
.frac-form .saveachlabel {
|
|
2938
|
-
margin-bottom : 0px !important;
|
|
2939
|
-
}
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
`)}import Zt from"axios";import{IoArrowBack as ti}from"react-icons/io5";import Ln from"sweetalert2";var ca=({amount:e,bankAmount:C,submitBtnText:ee="Pay",session_token:R,customerId:$,callback:Me,merchantName:U="merchant",isPreAuth:$e,surcharge:Ue="0",submitBtnClass:ye,submitBtnIcon:O,isRequest:me,pass_fee:ve,pass_fee_amount:o})=>{var sn,ln,Y,l,ue,je,se,Se,Ee,rt,nt,gt,Bt,Re;let[y,f]=Nt("card"),[Q,ce]=Nt("card"),[k,Ge]=Nt(),[ne,Fe]=Nt({}),[b,we]=Nt(),[oe,I]=Nt({}),[Je,ae]=Nt(!1),[Te,Xe]=Nt(!1),[Pt,B]=Nt(!1),[g,c]=Nt(""),[J,L]=Nt(!1),[x,d]=Nt(""),[v,S]=Nt(!1),[M,_]=Nt(!1),[q,h]=Nt([]),[w,G]=Nt([]),[ke,zt]=Nt(),[at,pt]=Nt(Number(e)),[Mt,mt]=Nt("form"),[qe,le]=Nt("form"),[Z,Ne]=Nt(!1),[Qe,he]=Nt(0);console.log(at,"cashDiscount");let Ct=ie+"widget/mc-img.svg",tt=ie+"widget/visa-img.svg",z=ie+"widget/ae-img.svg",u=ie+"widget/discover-img.svg",ge=ie+"widget/card.svg",De=ie+"widget/Trash.svg",re=ie+"widget/bank.svg",Oe=ie+"widget/secure-img.png",Ze=ie+"widget/pov-by.png",wt=ie+"widget/pax.svg",He=ie+"widget/cardicon.svg",yt=ie+"widget/bankicon.svg",kt=()=>S(!0),xe=()=>S(!1),_t=(m,t)=>{let a=(parseFloat(t)||0)/100,N=m/(1+a);return Math.round(N*100)/100},It=async m=>{var t,a,N,p,P,E,j,te,X;console.log(m,"ndfkjhdskjfhds");try{let W={pass_fee_amount:Number(e)-at,pass_fee:ve,Token:m==null?void 0:m.Token,amount:e,postal_code:m==null?void 0:m.postalCode},D=await Zt.post(`${Pe}api/v1/gateway/charge/${R}`,W);if((t=D==null?void 0:D.data)!=null&&t.result){let H;if(Pt&&$)try{let de={postal_code:k==null?void 0:k.zipCode,customer_id:$,gateway_token:(m==null?void 0:m.gateway_token)||(m==null?void 0:m.Token)};H=await Zt.post(`${Pe}api/v1/gateway/add-card/${R}`,de),console.log((a=H==null?void 0:H.data)==null?void 0:a.data,"addCard?.data?.data"),(N=H==null?void 0:H.data)!=null&&N.result&&(H=(p=H==null?void 0:H.data)==null?void 0:p.data)}catch(de){console.log(de,"error"),xe(),c(((E=(P=de==null?void 0:de.response)==null?void 0:P.data)==null?void 0:E.message)||"Something went wrong!")}let pe={cardDetails:F(F({},H),m),callback:A(F({},(j=D==null?void 0:D.data)==null?void 0:j.data),{name:k==null?void 0:k.cardName,isPreAuth:$e})};Pt||delete pe.cardDetails,Me(pe),xe(),ze()}}catch(W){c(((X=(te=W==null?void 0:W.response)==null?void 0:te.data)==null?void 0:X.message)||"Something went wrong!"),xe()}},ct=async m=>{var t,a,N,p,P,E,j,te;try{let X={Token:m==null?void 0:m.Token,amount:e,postal_code:m==null?void 0:m.postalCode},W=await Zt.post(`${Pe}api/v1/gateway/preauth/${R}`,X);if((t=W==null?void 0:W.data)!=null&&t.result){let D;if(Pt&&$)try{console.log(W,"preAuthResponse");let pe={postal_code:k==null?void 0:k.zipCode,customer_id:$,gateway_token:(m==null?void 0:m.Token)||(m==null?void 0:m.gateway_token)};D=await Zt.post(`${Pe}api/v1/gateway/add-card/${R}`,pe),(a=D==null?void 0:D.data)!=null&&a.result&&(D=(N=D==null?void 0:D.data)==null?void 0:N.data)}catch(pe){console.log(pe,"error"),xe(),c(((P=(p=pe==null?void 0:pe.response)==null?void 0:p.data)==null?void 0:P.message)||"Something went wrong!")}let H={cardDetails:F(F({},D),m),callback:A(F({},(E=W==null?void 0:W.data)==null?void 0:E.data),{name:k==null?void 0:k.cardName,isPreAuth:$e})};Pt||delete H.cardDetails,Me(H),xe(),ze()}}catch(X){c(((te=(j=X==null?void 0:X.response)==null?void 0:j.data)==null?void 0:te.message)||"Something went wrong!"),xe()}},Jt=async m=>{var t,a,N,p;if(m.Error)c(m.Error),xe();else{let P={token:m.Token,resp:m};try{let E=await Zt.post(`${Pe}api/v1/gateway/update/token/${R}`,P);if((E==null?void 0:E.status)==200){let j={Token:(a=(t=E==null?void 0:E.data)==null?void 0:t.data)==null?void 0:a.gateway_token,Brand:m.Brand,ExpirationMonth:m.ExpirationMonth,ExpirationYear:m.ExpirationYear,Last4:m.Last4,Bin:m.Bin,CVV:m.CVV,postalCode:k==null?void 0:k.zipCode},te;$e?ct(j):It(j)}}catch(E){console.log(E,"error"),xe(),c(((p=(N=E==null?void 0:E.response)==null?void 0:N.data)==null?void 0:p.message)||"Something went wrong!")}}},Wt=()=>Xe(!0),Tt=m=>{f(m)},St=()=>{var a,N,p,P,E,j,te,X;let m={},t=b;return(a=t==null?void 0:t.name)!=null&&a.trim()||(m.name="Name is required"),(N=t==null?void 0:t.accountNumber)!=null&&N.trim()||(m.accountNumber="Account number is required"),(p=t==null?void 0:t.accountNumber)!=null&&p.trim()&&((P=t==null?void 0:t.accountNumber)==null?void 0:P.trim())!==((E=t==null?void 0:t.confirmAccountNumber)==null?void 0:E.trim())&&(m.confirmAccountNumber="Account numbers must match"),(j=t==null?void 0:t.bankName)!=null&&j.trim()||(m.bankName="Bank name is required"),(te=t==null?void 0:t.routingNumber)!=null&&te.trim()||(m.routingNumber="Routing Number is required"),t!=null&&t.routingNumber&&((X=t==null?void 0:t.routingNumber)==null?void 0:X.length)!==9&&(m.routingNumber="Routing number must be 9 digits"),((t==null?void 0:t.accountType)==="business saving"||(t==null?void 0:t.accountType)==="business checking")&&(!(t!=null&&t.companyName)||(t==null?void 0:t.companyName)==="")&&(m.companyName="Company Name is required for business accounts"),I(m),Object.keys(m).length>0},Le=async()=>{var m,t,a,N,p,P,E,j,te,X,W,D,H,pe,de,st;try{let fe={method:"POST",redirect:"follow"},it=await Zt.post(`${Pe}api/v1/widget/generate-session`,fe),bt=Number(k==null?void 0:k.expiryYear)%100,ft=`${(m=k==null?void 0:k.cardNumber)==null?void 0:m.replace(/\s+/g,"")}=${bt}${k==null?void 0:k.expiryMonth} ${k==null?void 0:k.cvv}`,qt=forge.pki.publicKeyFromPem((a=(t=it==null?void 0:it.data)==null?void 0:t.data)==null?void 0:a.publicKeyPem).encrypt(ft,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),We=forge.util.encode64(qt),Ke={"Content-Type":"application/json","x-app-session-key":(p=(N=it.data)==null?void 0:N.data)==null?void 0:p.session_key},_e=JSON.stringify({enc_track2_data:We,algorithm:"RSAES_OAEP_SHA_1",session_key:(E=(P=it==null?void 0:it.data)==null?void 0:P.data)==null?void 0:E.session_key}),Yt=await Zt.post(`${Ht}tokenizer/tokenize`,_e,{headers:Ke});if((Yt==null?void 0:Yt.status)==200){let cn=(te=(j=Yt==null?void 0:Yt.data)==null?void 0:j.data)==null?void 0:te.token;try{let et=await Zt.post(`${Pe}api/v1/gateway/verify-and-save/${R}`,{token:cn});if((et==null?void 0:et.status)==200){let $t=(X=et==null?void 0:et.data)==null?void 0:X.data,ht={Token:$t.gateway_token,Brand:$t.card_data.brand,ExpirationMonth:$t.card_data.expire_mm,ExpirationYear:$t.card_data.expire_yy,Last4:$t.card_data.last4,Bin:$t.card_data.bin,postalCode:k==null?void 0:k.zipCode},Un;if(Pt&&$)try{let hn={postal_code:k==null?void 0:k.zipCode,customer_id:$,gateway_token:$t.gateway_token};Un=await Zt.post(`${Pe}api/v1/gateway/add-card/${R}`,hn)}catch(hn){console.log(hn,"error"),xe(),c(((D=(W=hn==null?void 0:hn.response)==null?void 0:W.data)==null?void 0:D.message)||"Something went wrong!")}$e?ct(ht):It(ht)}}catch(et){console.log(et,"error"),c(((pe=(H=et==null?void 0:et.response)==null?void 0:H.data)==null?void 0:pe.message)||"Something went wrong!"),xe()}}}catch(fe){xe(),console.log(fe,"error"),c(((st=(de=fe==null?void 0:fe.response)==null?void 0:de.data)==null?void 0:st.message)||"Something went wrong!")}},Vt=()=>{var p,P,E,j,te,X;let m={},t=k,a=parseInt((t==null?void 0:t.expiryMonth)||"",10),N=(t==null?void 0:t.expiryYear)||"";if((p=t==null?void 0:t.cardName)!=null&&p.trim()||(m.cardName="Card name is required"),(P=t==null?void 0:t.cardNumber)!=null&&P.trim()||(m.cardNumber="Card number is required"),(!((E=t==null?void 0:t.expiryMonth)!=null&&E.trim())||!((j=t==null?void 0:t.expiryYear)!=null&&j.trim())||isNaN(a)||a<1||a>12||N.length!==4)&&(m.expiryMonth="Invalid Expiration Date."),(te=t==null?void 0:t.cvv)!=null&&te.trim()||(m.cvv="CVV is required"),(X=t==null?void 0:t.zipCode)!=null&&X.trim()||(m.zipCode="ZIP code is required"),t!=null&&t.expiryMonth&&(t!=null&&t.expiryYear)&&t.expiryMonth.length<=2&&t.expiryYear.length===4){let W=parseInt(t.expiryMonth,10),D=parseInt(t.expiryYear,10),H=new Date,pe=H.getMonth()+1,de=H.getFullYear();(D<de||D===de&&W<pe)&&(m.expiryMonth="Card is expired")}return Fe(m),Object.keys(m).length>0},Kt=()=>{let m=DatacapWebToken.validateCardNumber(k==null?void 0:k.cardNumber.replaceAll(" ","")),t=DatacapWebToken.validateExpirationDate(k==null?void 0:k.expiryMonth,k==null?void 0:k.expiryYear),a=DatacapWebToken.validateCVV(k==null?void 0:k.cvv),N={};return m||(N.cardNumber="Invalid card Number"),t||(N.expiryMonth="Invalid Expiration Date."),a||(N.cvv="Invalid CVV"),Fe(N),m&&a&&t},Xt=async m=>{var t,a,N,p,P,E,j,te,X,W,D,H,pe,de,st;if(m.preventDefault(),y!=="ach"){if(Vt()||!Kt())return}else if(St())return;try{kt();let fe=await Zt.get(`${Pe}api/v1/gateway/token/${R}`);if((fe==null?void 0:fe.status)==200){let it=(a=(t=fe==null?void 0:fe.data)==null?void 0:t.data)==null?void 0:a.gateway_token,bt=(p=(N=fe==null?void 0:fe.data)==null?void 0:N.data)==null?void 0:p.paymentGateway;if(y!=="ach")bt==((P=Zn)==null?void 0:P.FRACTALKEY)?await Le():DatacapWebToken.requestToken(it,"PaymentForm",Jt);else{let Ye;try{let ft=await Zt.post(`${Pe}api/v1/gateway/bank-charge/${R}`,{label:b==null?void 0:b.name,account_number:b==null?void 0:b.accountNumber,routing_number:b==null?void 0:b.routingNumber,bank_name:b==null?void 0:b.bankName,account_type:b==null?void 0:b.accountType,amount:`${C}`,customer_id:null,isSaveAch:!1,tax:"0.00",discount:"0.00",surcharge:"0.00",order_id:"",company_name:(b==null?void 0:b.companyName)||""});if((E=ft==null?void 0:ft.data)!=null&&E.result){if(Je&&$)try{let Ve=await Zt.post(`${Pe}api/v1/gateway/add-bank/${R}`,{name:b==null?void 0:b.name,account_number:b==null?void 0:b.accountNumber,routing_number:b==null?void 0:b.routingNumber,bank_name:b==null?void 0:b.bankName,account_type:b==null?void 0:b.accountType,customer_id:$||"",company_name:(b==null?void 0:b.companyName)||""});Ve.data.result&&(Ye={bankDetails:A(F({},(j=Ve==null?void 0:Ve.data)==null?void 0:j.data),{account_type:b==null?void 0:b.accountType})})}catch(Ve){xe(),c(((X=(te=Ve==null?void 0:Ve.response)==null?void 0:te.data)==null?void 0:X.message)||"Something went wrong!")}Ye=A(F({},Ye),{callback:A(F({},(W=ft==null?void 0:ft.data)==null?void 0:W.data),{name:b==null?void 0:b.name,isPreAuth:$e})}),Me(Ye),ze(),xe()}}catch(ft){console.log(ft,"errororor");let Ve=(D=ft==null?void 0:ft.response)==null?void 0:D.data;typeof(Ve==null?void 0:Ve.message)=="object"?Object.values(Ve==null?void 0:Ve.message).forEach(qt=>{c(qt||"Something went wrong")}):c((Ve==null?void 0:Ve.message)||"Something went wrong"),xe()}}}}catch(fe){xe(),Me({error:((pe=(H=fe==null?void 0:fe.response)==null?void 0:H.data)==null?void 0:pe.message)||"Something went wrong!"}),c(((st=(de=fe==null?void 0:fe.response)==null?void 0:de.data)==null?void 0:st.message)||"Something went wrong!")}},ot=(m,t)=>{let a=m;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(a)){(t===""||/^[0-9]+$/.test(t))&&(Fe(p=>A(F({},p),{[a]:""})),Ge(p=>A(F({},p),{[a]:t})));return}Fe(p=>A(F({},p),{[a]:""})),Ge(p=>A(F({},p),{[a]:t}))},nn=m=>{let a=m.target.value.replace(/\D/g,""),N="";/^3[47]/.test(a)?N=a.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(P,E,j,te)=>[E,j,te].filter(Boolean).join(" ")):N=a.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(P,E,j,te,X)=>[E,j,te,X].filter(Boolean).join(" ")),Fe(p=>A(F({},p),{cardNumber:""})),Ge(p=>A(F({},p),{cardNumber:N}))},Ft=m=>{let{name:t,value:a}=m.target,N=["routingNumber","accountNumber","confirmAccountNumber"];if(t=="name"){/^[a-zA-Z\s]*$/.test(a)&&(I(p=>A(F({},p),{[t]:""})),we(p=>A(F({},p),{[t]:a})));return}if(N.includes(t)){(a===""||/^[0-9]+$/.test(a))&&(I(p=>A(F({},p),{[t]:""})),we(p=>A(F({},p),{[t]:a})));return}I(p=>A(F({},p),{[t]:""})),we(p=>A(F({},p),{[t]:a}))},ze=()=>{Xe(!1),f("card"),c(""),L(!1),d(""),we({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),I({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),Ge({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),Fe({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),ae(!1),B(!1),le("form"),mt("form"),Ne(!1),he(0),pt(0),h([])},ut=async()=>{var m,t,a,N;kt();try{let p={isPreAuth:$e,customerId:$},P=await Zt.post(`${Pe}api/v1/gateway/card-list/${R}`,p);console.log("cardListData",P);let E=((t=(m=P==null?void 0:P.data)==null?void 0:m.data)==null?void 0:t.cardList)||[],j=E==null?void 0:E.filter(X=>(X==null?void 0:X.card_type)=="Bank"),te=E==null?void 0:E.filter(X=>(X==null?void 0:X.card_type)!=="Bank");te&&(te==null?void 0:te.length)>0?(f("card"),mt("list"),h(te)):(f("card"),h([])),j&&(j==null?void 0:j.length)>0?(le("list"),G(j)):G([]),xe()}catch(p){console.log(p),xe(),c(((N=(a=p==null?void 0:p.response)==null?void 0:a.data)==null?void 0:N.message)||(p==null?void 0:p.message)||"Something went wrong")}};console.log(w,"lists",q);let rn=m=>{switch(m==null?void 0:m.toLowerCase()){case"visa":return tt;case"mastercard":case"mc":case"m/c":return Ct;case"amex":case"american express":case"ae":return z;case"discover":case"dcvr":return u;case"bank":return re;default:return m}},Et=async m=>{Ln.fire({icon:"warning",text:"Do you want to delete the card?",showCancelButton:!0,confirmButtonText:"Yes",cancelButtonText:"No",reverseButtons:!0,buttonsStyling:!1,customClass:{confirmButton:"swal2-confirm btn btn-dark",cancelButton:"swal2-cancel btn btn-dark",popup:"custom-swal-popup",icon:"custom-swal-icon"}}).then(async t=>{var a,N;if(t.isConfirmed){_(!0);try{let p={card_id:m,customer_id:$},P=await Zt.patch(`${Pe}api/v1/gateway/delete-card/${R}`,p);(a=P==null?void 0:P.data)!=null&&a.result?(_(!1),ut(),Ln.fire({icon:"success",title:"Deleted!",text:((N=P==null?void 0:P.data)==null?void 0:N.message)||"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})):(_(!1),Ln.fire({icon:"error",title:"Failure!",text:"Card not deleted.",timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}}))}catch(p){_(!1),Ln.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else t.dismiss===Ln.DismissReason.cancel&&Ln.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},en=async()=>{var N,p,P,E;let m=$,t=ke==null?void 0:ke.id,a=ke==null?void 0:ke.card_type;if(e)if(m)if(t){let j={amount:(a==null?void 0:a.toLowerCase())==="bank"?`${C}`:e,customer_id:m,card_id:t,pass_fee_amount:Number(e)-at};$e&&(j.isPreauth=!0),console.log(j,"chargeobj");let te=Pe+"api/v1/gateway/charge-by-saved-details/"+R,X={"Content-Type":"application/json"};try{kt();let W=await Zt.post(te,j);console.log(W,"res"),(N=W==null?void 0:W.data)!=null&&N.result&&(Me({callback:A(F({},(p=W==null?void 0:W.data)==null?void 0:p.data),{isPreAuth:$e})}),xe(),ze())}catch(W){console.log(W==null?void 0:W.response,"error by saved details"),xe(),c(((E=(P=W==null?void 0:W.response)==null?void 0:P.data)==null?void 0:E.message)||"Something went wrong!")}}else c("Please Select A Card/ACH");else c("Please Select Customer");else c("Something went wrong.")};console.log(Te,e,$);let At=async()=>{var m,t,a,N;try{kt();let p=await Zt.get(`${Pe}api/v1/gateway/get-payment-details/${R}`);console.log(p,"respinse"),(p==null?void 0:p.status)==200&&(Ne((t=(m=p==null?void 0:p.data)==null?void 0:m.data)==null?void 0:t.isBankActive),he(Number((N=(a=p==null?void 0:p.data)==null?void 0:a.data)==null?void 0:N.fee)||0),xe())}catch(p){console.log(p,"error while getting payment details"),xe()}};da(()=>{Te&&At()},[Te]),ma(()=>{if(Te&&o){let m=Number(e)-Number(o);m&&!isNaN(m)&&pt(m)}else if(Te&&ve&&Qe){let m=_t(e,Qe);m&&!isNaN(m)&&pt(m)}else pt(Number(e));$&&Te&&!me&&ut()},[$,Te,e,Qe]);let an=()=>$e?"Cards":"Cards/Bank";return console.log(Z,"scdgfhasgcf"),r.createElement(r.Fragment,null,r.createElement("link",{href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}),r.createElement(Dt,null),r.createElement(ei,null),r.createElement(Nn,null),r.createElement("button",{className:ye||"paymentBtn",onClick:Wt},ee,O),r.createElement(Ut,{open:Te,onClose:ze},g&&r.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},r.createElement(tn,{error:g,onClose:ze})),!g&&r.createElement(r.Fragment,null,(v||M)&&r.createElement(Ot,{loading:v||M}),r.createElement("div",{className:"frac-card-payment-page frac-form frac-new-form"},r.createElement("div",{className:"parent-pay-container"},r.createElement("span",{className:"request-payment-close-popup",onClick:ze},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},r.createElement("g",{clipPath:"url(#clip0_12425_52336)"},r.createElement("path",{d:"M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z",fill:"#727272"})),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_12425_52336"},r.createElement("rect",{width:"16",height:"16",fill:"white"}))))),r.createElement("div",{className:"pay-main-logo-res"}),r.createElement("div",{className:"pay-container"},r.createElement("div",{className:"pay-header pay-conatiner-one"},r.createElement("div",{className:"pay-conatiner-one-first"},r.createElement("div",{className:"pay-logo-container"},r.createElement("div",{className:"pay-main-logo"}),r.createElement("h1",{className:"pay-heading"},"Pay"),(q==null?void 0:q.length)>0&&y!=="cardList"&&r.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>f("cardList")}," ",r.createElement(ti,null)," Back")),r.createElement("div",{className:"amt-pay-con"},r.createElement("div",{className:"pay-amount-conatiner"},r.createElement("small",{className:"pay-payment-amount"},"Select payment type"),r.createElement("div",{className:"frac-card-bank-radio-main"},r.createElement(pn,{label:"Card",amount:(sn=Number(e))==null?void 0:sn.toFixed(2),value:"card",onChange:Tt,activetab:y}),!$e&&Z&&r.createElement(pn,{label:"Bank",amount:(ln=Number(C))==null?void 0:ln.toFixed(2),value:"ach",onChange:Tt,activetab:y})),ve&&y==="card"&&at&&Number(e)-Number(at)>0?r.createElement("div",{className:"frac-cash-discount-fee"},r.createElement("small",null,y==="card"?"Cash Discount":"Cash Discount Savings"," "),r.createElement("p",null,Ce((Number(e)-Number(at)).toFixed(2)))):null))),r.createElement("div",{className:"pay-conatiner-one-last"},r.createElement("img",{src:Oe,alt:""}),r.createElement("img",{src:Ze,alt:""}),"Secure payments powered by Fractal")),r.createElement("div",{className:"pay-tab pay-conatiner-two"},r.createElement("div",{className:"col-md-12"},r.createElement("div",{id:"payment-form-div"},r.createElement("div",{id:"ach",style:{display:y==="card"?"block":"none"},className:"tabcontent"},r.createElement("div",{className:"frac-heading-card-wrap"},r.createElement("div",{className:"frac-backarrow"},(q==null?void 0:q.length)>0&&Mt==="form"&&r.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>mt("list")}," ",r.createElement(ti,null))),r.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),r.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},r.createElement("img",{src:tt,alt:"",width:33}),r.createElement("img",{src:Ct,width:33,alt:""}),r.createElement("img",{src:z,alt:"",width:33}),r.createElement("img",{src:u,width:33,alt:""})),Mt==="list"&&(q==null?void 0:q.length)>0?r.createElement(r.Fragment,null,r.createElement(fn,{headingClass:"card-ach-heading-frac",listHeading:"Card",ListItems:q,selectedCard:ke,setSelectedCard:zt,handleDeleteCard:Et,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{mt("form")}}),r.createElement("div",{className:"form-group-frac",style:{padding:"0"}},r.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:en},Ce((Y=Number(e))==null?void 0:Y.toFixed(2))))):r.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Xt},r.createElement("div",{className:"ach-scrl",style:{minHeight:"398px",maxHeight:"398px",overflow:"auto",marginRight:"5px"}},r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"cardHolderName"},"NAME ON CARD "),r.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"John Doe",value:(k==null?void 0:k.cardName)||"",onChange:m=>{let t=m.target.value;/^[a-zA-Z\s]*$/.test(t)&&ot("cardName",t)}}),(ne==null?void 0:ne.cardName)&&r.createElement("span",{className:"error-span"},ne==null?void 0:ne.cardName)),r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"cardNumber"},"CARD NUMBER"),r.createElement("div",{className:"toggle-num-wrapper"},r.createElement("input",{className:"form-control-frac card-number-new",type:"text",maxLength:19,inputMode:"numeric",placeholder:"0000 0000 0000 0000",value:(k==null?void 0:k.cardNumber)||"",onChange:m=>nn(m),"data-token":"card_number"}),r.createElement("div",{className:"card-crdi card-expiry-new"},r.createElement("div",{className:"exp-date-year-container"},r.createElement("div",{className:"exp-date form-group-frac"},r.createElement("input",{"data-token":"exp_month",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"MM",maxLength:2,value:(k==null?void 0:k.expiryMonth)||"",onChange:m=>ot("expiryMonth",m.target.value)})),r.createElement("div",{className:"exp-year form-group-frac"},r.createElement("input",{"data-token":"exp_year",className:"form-control-frac required card-cvv-in",type:"text",style:{maxHeight:"36px"},placeholder:"YYYY",maxLength:4,value:(k==null?void 0:k.expiryYear)||"",onChange:m=>ot("expiryYear",m.target.value)})),r.createElement("div",{className:"security-digit form-group-frac"},r.createElement("input",{"data-token":"cvv",className:"form-control-frac card-cvv-in required",type:"text",style:{maxHeight:"36px"},maxLength:4,placeholder:"CVC",value:(k==null?void 0:k.cvv)||"",onChange:m=>ot("cvv",m.target.value)})))),(ne==null?void 0:ne.cardNumber)&&r.createElement("span",{className:"error-span"},ne==null?void 0:ne.cardNumber),r.createElement("p",{style:{margin:"0"}},ne!=null&&ne.expiryMonth||ne!=null&&ne.expiryYear?r.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},ne==null?void 0:ne.expiryMonth):"",(ne==null?void 0:ne.cvv)&&r.createElement("span",{className:"error-span"},ne==null?void 0:ne.cvv)))),r.createElement("div",{className:"form-group-frac"},r.createElement("label",{htmlFor:"zip"},"ZIP"),r.createElement("input",{type:"text",className:"form-control-frac",maxLength:100,placeholder:"000000",value:(l=k==null?void 0:k.zipCode)!=null?l:"",onChange:m=>ot("zipCode",m.target.value)}),(ne==null?void 0:ne.zipCode)&&r.createElement("span",{className:"error-span"},ne==null?void 0:ne.zipCode)),$&&r.createElement("div",{className:"form-group-frac"},r.createElement("div",{className:"frac-tooltip-mn",style:{display:"flex",alignItems:"center",gap:"10px",paddingTop:"10px"}},r.createElement("input",{type:"checkbox",id:"save_card",className:"toggle-checkbox",checked:Pt,onChange:m=>B(m.target.checked)}),r.createElement("label",{htmlFor:"save_card",className:"toggle-label"}),r.createElement("label",{htmlFor:"save_card"},"Save card for future payments "),r.createElement("div",{className:"frac-tooltip-wrapper"},r.createElement("div",{className:"frac-tooltip-icon"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},r.createElement("circle",{cx:"10",cy:"10",r:"10",fill:"#E0DFE2"}),r.createElement("path",{d:"M9.03406 12.0979V12.0072C9.04055 11.4153 9.10057 10.9443 9.21411 10.5943C9.3309 10.2442 9.49635 9.96102 9.71046 9.74463C9.92457 9.52824 10.1825 9.33095 10.4842 9.15274C10.6788 9.03182 10.854 8.89658 11.0097 8.74702C11.1655 8.59745 11.2887 8.42562 11.3796 8.2315C11.4704 8.03739 11.5158 7.82259 11.5158 7.58711C11.5158 7.3039 11.4477 7.05887 11.3114 6.85203C11.1752 6.64519 10.9935 6.48608 10.7664 6.3747C10.5426 6.26014 10.2928 6.20286 10.017 6.20286C9.76723 6.20286 9.52879 6.25378 9.3017 6.35561C9.07461 6.45744 8.88646 6.61655 8.73723 6.83294C8.588 7.04614 8.50203 7.3214 8.47932 7.65871H7C7.02271 7.08592 7.17032 6.60223 7.44282 6.20764C7.71533 5.80986 8.07543 5.50915 8.52311 5.30549C8.97405 5.10183 9.47202 5 10.017 5C10.6139 5 11.1363 5.10979 11.5839 5.32936C12.0316 5.54574 12.3788 5.84964 12.6253 6.24105C12.8751 6.62928 13 7.08274 13 7.60143C13 7.95784 12.9432 8.27924 12.8297 8.56563C12.7161 8.84885 12.5539 9.10183 12.3431 9.32458C12.1354 9.54733 11.8856 9.74463 11.5937 9.91647C11.3179 10.0851 11.0941 10.2601 10.9221 10.4415C10.7534 10.6229 10.6302 10.8377 10.5523 11.0859C10.4745 11.3341 10.4323 11.6412 10.4258 12.0072V12.0979H9.03406ZM9.76886 15C9.50284 15 9.27413 14.9077 9.08273 14.7232C8.89132 14.5354 8.79562 14.3095 8.79562 14.0453C8.79562 13.7844 8.89132 13.5617 9.08273 13.3771C9.27413 13.1893 9.50284 13.0955 9.76886 13.0955C10.0316 13.0955 10.2587 13.1893 10.4501 13.3771C10.6448 13.5617 10.7421 13.7844 10.7421 14.0453C10.7421 14.2204 10.6967 14.3811 10.6058 14.5274C10.5182 14.6706 10.4015 14.7852 10.2555 14.8711C10.1095 14.957 9.94728 15 9.76886 15Z",fill:"#161616"}))),r.createElement("div",{className:"frac-tooltip-text"},r.createElement("p",null,"If checked, I agree to give the ",r.createElement("b",null,U||"merchant")," permission to charge this credit card for agreed-upon purchases in the future.")))))),r.createElement("div",{className:"form-group-frac",style:{marginTop:"20px",padding:"0"}},r.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},Ce((ue=Number(e))==null?void 0:ue.toFixed(2)))))),r.createElement("div",{id:"ach",style:{display:y==="ach"?"block":"none"},className:"tabcontent"},r.createElement(r.Fragment,null,r.createElement("div",{className:"frac-heading-card-wrap"},r.createElement("div",{className:"frac-backarrow"},(w==null?void 0:w.length)>0&&qe==="form"&&r.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>le("list")}," ",r.createElement(ti,null))),r.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment")),qe==="list"&&(w==null?void 0:w.length)>0?r.createElement(r.Fragment,null,r.createElement(fn,{headingClass:"card-ach-heading-frac",listHeading:"Banks",ListItems:w,selectedCard:ke,setSelectedCard:zt,handleDeleteCard:Et,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{le("form")}}),r.createElement("div",{className:"form-group-frac",style:{padding:"0"}},r.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:en},Ce((je=Number(C))==null?void 0:je.toFixed(2))))):r.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Xt},r.createElement("div",{className:"ach-scrl",style:{minHeight:"444px",maxHeight:"444px"}},r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"nameonaccount"},"Name on account"),r.createElement("input",{type:"text",id:"nameonaccount",className:"form-control-frac",maxLength:100,placeholder:"John Doe",name:"name",value:(se=b==null?void 0:b.name)!=null?se:"",onChange:Ft}),(oe==null?void 0:oe.name)&&r.createElement("span",{className:"error-span"},oe==null?void 0:oe.name)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"routingnumber"},"Routing number"),r.createElement("input",{type:"text",id:"routingnumber",className:"form-control-frac",maxLength:9,placeholder:"000000000",name:"routingNumber",value:(Se=b==null?void 0:b.routingNumber)!=null?Se:"",onChange:Ft}),(oe==null?void 0:oe.routingNumber)&&r.createElement("span",{className:"error-span"},oe==null?void 0:oe.routingNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"accountnumber"},"Account number"),r.createElement("input",{type:"text",id:"accountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"accountNumber",value:(Ee=b==null?void 0:b.accountNumber)!=null?Ee:"",onChange:Ft}),(oe==null?void 0:oe.accountNumber)&&r.createElement("span",{className:"error-span"},oe==null?void 0:oe.accountNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"confirmaccountnumber"},"Confirm account number"),r.createElement("input",{type:"text",id:"confirmaccountnumber",className:"form-control-frac",maxLength:16,placeholder:"0000000000",name:"confirmAccountNumber",value:(rt=b==null?void 0:b.confirmAccountNumber)!=null?rt:"",onChange:Ft}),(oe==null?void 0:oe.confirmAccountNumber)&&r.createElement("span",{className:"error-span"},oe==null?void 0:oe.confirmAccountNumber)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"bankname"},"Bank name"),r.createElement("input",{type:"text",id:"bankname",className:"form-control-frac",maxLength:100,placeholder:"My Bank",name:"bankName",value:(nt=b==null?void 0:b.bankName)!=null?nt:"",onChange:Ft}),(oe==null?void 0:oe.bankName)&&r.createElement("span",{className:"error-span"},oe==null?void 0:oe.bankName)),((b==null?void 0:b.accountType)==="business saving"||(b==null?void 0:b.accountType)==="business checking")&&r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"companyName"},"Company name"),r.createElement("input",{type:"text",id:"companyName",className:"form-control",maxLength:100,placeholder:"My Company",name:"companyName",value:(gt=b==null?void 0:b.companyName)!=null?gt:"",onChange:Ft}),(oe==null?void 0:oe.companyName)&&r.createElement("span",{className:"error-span"},oe==null?void 0:oe.companyName)),r.createElement("div",{className:"form-group-frac mb-4"},r.createElement("label",{htmlFor:"accounttype"},"Select account type"),r.createElement("select",{name:"accountType",id:"accounttype",className:"form-control-frac",value:(Bt=b==null?void 0:b.accountType)!=null?Bt:"",onChange:Ft},r.createElement("option",{value:""},"Select account"),Fn.map(m=>r.createElement("option",{key:m.value,value:m.value},m.label)))),$&&r.createElement("div",{className:"form-group-frac mb-4 save-ach-div",style:{paddingTop:"5px"}},r.createElement("input",{type:"checkbox",id:"saveACH",className:"",maxLength:100,placeholder:"My Bank",checked:Je,onChange:m=>ae(m.target.checked)}),r.createElement("label",{className:"saveachlabel",htmlFor:"saveACH"},"Save ACH")),Je&&r.createElement("div",{className:"form-group-frac mb-4 saveachtext"},r.createElement("p",null,"If checked, I agree to give the ",r.createElement("b",null,U||"merchant")," permission to charge this bank account for agreed-upon purchases in the future."))),r.createElement("div",{className:"form-group-frac "},r.createElement("button",{className:"pay-button",style:{margin:"20px 0 0"},type:"submit"},Ce((Re=Number(C))==null?void 0:Re.toFixed(2))))))))))))))))};import n,{useEffect as En,useRef as ua,useState as dt}from"react";import Hn from"axios";import jn from"sweetalert2";import{IoArrowBack as Wn}from"react-icons/io5";import{NumericFormat as ga}from"react-number-format";function pa(e){var ze,ut,rn,Et,en,At,an,sn,ln,Y,l,ue,je,se,Se,Ee,rt,nt,gt,Bt,Re,m;let C=ua(null);En(()=>{e.onTriggerPay&&e.onTriggerPay(()=>{kt()})},[e]);let ee=ie+"widget/mc-img.svg",R=ie+"widget/visa-img.svg",$=ie+"widget/ae-img.svg",Me=ie+"widget/discover-img.svg",U=ie+"widget/card.svg",$e=ie+"widget/Trash.svg",Ue=ie+"widget/bank.svg",ye=ie+"widget/secure-img.png",O=ie+"widget/pov-by.png",me=ie+"widget/pax.svg",[ve,o]=dt(!1),[y,f]=dt(!1),[Q,ce]=dt(""),[k,Ge]=dt(!1),[ne,Fe]=dt(!1),[b,we]=dt("card"),[oe,I]=dt("card"),[Je,ae]=dt("form"),[Te,Xe]=dt("form"),[Pt,B]=dt(!0),[g,c]=dt(!1),[J,L]=dt(!1),x=e.merchantPublicKey,[d,v]=dt(),[S,M]=dt({}),[_,q]=dt(),[h,w]=dt({}),[G,ke]=dt([]),[zt,at]=dt([]),[pt,Mt]=dt(),[mt,qe]=dt(),[le,Z]=dt(Number(e==null?void 0:e.amount)),[Ne,Qe]=dt(Number(e==null?void 0:e.amount)),[he,Ct]=dt(""),[tt,z]=dt("");console.log(he,"partialAmount");let[u,ge]=dt(),[De,re]=dt(""),Oe=()=>o(!0),Ze=()=>o(!1),wt=(t,a)=>{let N=(parseFloat(a)||0)/100;return t-t*N},He=(t,a)=>{let N=(Number(a)||0)/100;return+t+ +(t*N)};En(()=>{ne&&(e!=null&&e.pass_fee?(Qe(Number(e==null?void 0:e.amount)),Z(Number(e==null?void 0:e.cashDiscount))):(Qe(Number(e==null?void 0:e.amount)),Z(Number(e==null?void 0:e.amount))))},[ne,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let yt=()=>{Fe(!1),we("card"),ce(""),Ge(!1),re(""),q({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),w({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),v({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),M({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),L(!1),c(!1),Mt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),qe({}),Z(0),I("card"),B(!0),Xe("form"),ae("form"),f(!1),o(!1),at([]),ke([]),Ct(""),z("")},kt=()=>Fe(!0),xe=t=>{we(t)},_t=(t,a)=>{let N=t;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(N)){(a===""||/^[0-9]+$/.test(a))&&(M(P=>A(F({},P),{[N]:""})),v(P=>A(F({},P),{[N]:a})));return}M(P=>A(F({},P),{[N]:""})),v(P=>A(F({},P),{[N]:a}))},It=t=>{let N=t.target.value.replace(/\D/g,""),p="";/^3[47]/.test(N)?p=N.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(E,j,te,X)=>[j,te,X].filter(Boolean).join(" ")):p=N.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(E,j,te,X,W)=>[j,te,X,W].filter(Boolean).join(" ")),M(P=>A(F({},P),{cardNumber:""})),v(P=>A(F({},P),{cardNumber:p}))},ct=t=>{let{name:a,value:N}=t.target,p=["routingNumber","accountNumber","confirmAccountNumber"];if(a=="name"){/^[a-zA-Z\s]*$/.test(N)&&(w(P=>A(F({},P),{[a]:""})),q(P=>A(F({},P),{[a]:N})));return}if(p.includes(a)){(N===""||/^[0-9]+$/.test(N))&&(w(P=>A(F({},P),{[a]:""})),q(P=>A(F({},P),{[a]:N})));return}w(P=>A(F({},P),{[a]:""})),q(P=>A(F({},P),{[a]:N}))},Jt=()=>{var P,E,j,te,X,W;let t={},a=d,N=parseInt((a==null?void 0:a.expiryMonth)||"",10),p=(a==null?void 0:a.expiryYear)||"";if((P=a==null?void 0:a.cardName)!=null&&P.trim()||(t.cardName="Card name is required"),(E=a==null?void 0:a.cardNumber)!=null&&E.trim()||(t.cardNumber="Card number is required"),(!((j=a==null?void 0:a.expiryMonth)!=null&&j.trim())||!((te=a==null?void 0:a.expiryYear)!=null&&te.trim())||isNaN(N)||N<1||N>12||p.length!==4)&&(t.expiryMonth="Invalid Expiration Date."),(X=a==null?void 0:a.cvv)!=null&&X.trim()||(t.cvv="CVV is required"),(W=a==null?void 0:a.zipCode)!=null&&W.trim()||(t.zipCode="ZIP code is required"),a!=null&&a.expiryMonth&&(a!=null&&a.expiryYear)&&a.expiryMonth.length<=2&&a.expiryYear.length===4){let D=parseInt(a.expiryMonth,10),H=parseInt(a.expiryYear,10),pe=new Date,de=pe.getMonth()+1,st=pe.getFullYear();(H<st||H===st&&D<de)&&(t.expiryMonth="Card is expired")}return M(t),Object.keys(t).length>0},Wt=()=>{var N,p,P,E,j,te,X,W;let t={},a=_;return(N=a==null?void 0:a.name)!=null&&N.trim()||(t.name="Name is required"),(p=a==null?void 0:a.accountNumber)!=null&&p.trim()||(t.accountNumber="Account number is required"),(P=a==null?void 0:a.accountNumber)!=null&&P.trim()&&((E=a==null?void 0:a.accountNumber)==null?void 0:E.trim())!==((j=a==null?void 0:a.confirmAccountNumber)==null?void 0:j.trim())&&(t.confirmAccountNumber="Account numbers must match"),(te=a==null?void 0:a.bankName)!=null&&te.trim()||(t.bankName="Bank name is required"),(X=a==null?void 0:a.routingNumber)!=null&&X.trim()||(t.routingNumber="Routing Number is required"),a!=null&&a.routingNumber&&((W=a==null?void 0:a.routingNumber)==null?void 0:W.length)!==9&&(t.routingNumber="Routing number must be 9 digits"),((a==null?void 0:a.accountType)==="business saving"||(a==null?void 0:a.accountType)==="business checking")&&(!(a!=null&&a.companyName)||(a==null?void 0:a.companyName)==="")&&(t.companyName="Company Name is required for business accounts"),w(t),Object.keys(t).length>0},Tt=async t=>{var a,N,p,P,E,j,te,X,W,D,H,pe,de,st,fe;if(t.preventDefault(),!tt)if(b!=="ach"){if(Jt())return;{let bt=DatacapWebToken.validateCardNumber(d==null?void 0:d.cardNumber.replaceAll(" ","")),Ye=DatacapWebToken.validateExpirationDate(d==null?void 0:d.expiryMonth,d==null?void 0:d.expiryYear),ft=DatacapWebToken.validateCVV(d==null?void 0:d.cvv),Ve={};if(bt||(Ve.cardNumber="Invalid card Number"),Ye||(Ve.expiryMonth="Invalid Expiration Date."),ft||(Ve.cvv="Invalid CVV"),M(Ve),bt&&ft&&Ye){f(!0);try{let qt=async function(We){var Ke,_e;if(We.Error)ce(We.Error),f(!1);else{let Yt=d==null?void 0:d.cardName,cn=d==null?void 0:d.zipCode;We.name=Yt,We.postal_code=cn,We.isCardSave=`${g}`,We.isCharge=!0,We.posSalesIdEncode=(Ke=u==null?void 0:u.orderDetails)==null?void 0:Ke.orderId,We.partial_amount=he&&!tt?he:Ne,xt.emit("sendMessage",We);let et=(_e=u==null?void 0:u.orderDetails)==null?void 0:_e.orderId;xt.on(et,$t=>{if(Sn($t==null?void 0:$t.data)){let ht=JSON.parse($t.data);ht!=null&&ht.result?(v({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),c(!1),re(ht==null?void 0:ht.transactionId),Ge(!0),f(!1)):(f(!1),ce((ht==null?void 0:ht.message)||"Something went wrong."))}else ce("Something went wrong.")})}};if((u==null?void 0:u.paymentGateway)===32){let We={method:"POST",redirect:"follow"};try{let Ke=await Hn.post(`${Pe}api/v1/widget/generate-session`,We),_e=Number(d==null?void 0:d.expiryYear)%100,Yt=d==null?void 0:d.cardNumber;Yt=Yt==null?void 0:Yt.replace(/\s+/g,"");let cn=`${Yt}=${_e}${d==null?void 0:d.expiryMonth} ${d==null?void 0:d.cvv}`,$t=forge.pki.publicKeyFromPem((N=(a=Ke==null?void 0:Ke.data)==null?void 0:a.data)==null?void 0:N.publicKeyPem).encrypt(cn,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ht=forge.util.encode64($t),Un={"Content-Type":"application/json","x-app-session-key":(P=(p=Ke.data)==null?void 0:p.data)==null?void 0:P.session_key},hn=JSON.stringify({enc_track2_data:`${ht}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(j=(E=Ke==null?void 0:Ke.data)==null?void 0:E.data)==null?void 0:j.session_key}`});try{let Qt=await Hn.post(`${Ht}tokenizer/tokenize`,hn,{headers:Un}),yi=JSON.stringify(A(F({},(te=Qt==null?void 0:Qt.data)==null?void 0:te.data),{isSaveCardChecked:g,name:d==null?void 0:d.cardName,postal_code:d==null?void 0:d.zipCode,customer_id:e==null?void 0:e.customerId,partial_amount:he&&!tt?he:Ne})),bi=JSON.stringify({pre_sales_id:`${(X=u==null?void 0:u.orderDetails)==null?void 0:X.orderId}`,token:`${(W=Qt==null?void 0:Qt.data)==null?void 0:W.data.token}`,json_response:`${yi}`}),xi={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:bi,redirect:"follow",isChargeviafractal:!0};xt.emit("sendMessage",xi),xt.on("chargeviafractalgateway",kn=>{var ni;if(Sn(kn==null?void 0:kn.data)){let un=JSON.parse(kn==null?void 0:kn.data);un!=null&&un.result?(re((ni=un==null?void 0:un.data)==null?void 0:ni.transactionId),Ge(!0),f(!1)):(f(!1),ce((un==null?void 0:un.message)||"Something went wrong."))}else ce("Something went wrong.")})}catch(Qt){f(!1),ce(((H=(D=Qt==null?void 0:Qt.response)==null?void 0:D.data)==null?void 0:H.message)||(Qt==null?void 0:Qt.message)||"Something went wrong.")}}catch(Ke){f(!1),ce(((de=(pe=Ke==null?void 0:Ke.response)==null?void 0:pe.data)==null?void 0:de.message)||(Ke==null?void 0:Ke.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(u==null?void 0:u.dctoken,"PaymentForm",qt)}catch(qt){f(!1),ce(((fe=(st=qt==null?void 0:qt.response)==null?void 0:st.data)==null?void 0:fe.message)||(qt==null?void 0:qt.message)||"Something went wrong.")}}}}else{if(Wt())return;{f(!0);let bt={fractalpayPublicKey:x,label:(_==null?void 0:_.name)||"John Doe",account_number:_==null?void 0:_.accountNumber,routing_number:_==null?void 0:_.routingNumber,bank_name:_==null?void 0:_.bankName,account_type:_==null?void 0:_.accountType,amount:he&&!tt?he:String(le||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:(_==null?void 0:_.companyName)||"",orderGuid:e==null?void 0:e.orderGuid};xt.emit("sendMessage",bt),xt.on("ach-incoming",Ye=>{var ft;(Ye==null?void 0:Ye.status)=="Failed"?typeof(Ye==null?void 0:Ye.message)=="object"?Object.values(Ye==null?void 0:Ye.message).forEach(Ve=>{ce(Ve||"Something went wrong")}):ce((Ye==null?void 0:Ye.message)||"Something went wrong"):(re((ft=Ye==null?void 0:Ye.data)==null?void 0:ft.transaction_id),Ge(!0),f(!1))})}}},St=async()=>{var t,a,N,p,P,E,j,te,X,W,D,H,pe,de,st,fe,it,bt,Ye,ft,Ve,qt,We;Oe();try{let Ke={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},_e=await Hn.post(`${Be}get-payment-details`,Ke);if(ge((t=_e==null?void 0:_e.data)==null?void 0:t.data),(N=(a=_e==null?void 0:_e.data)==null?void 0:a.data)!=null&&N.paymentGateway||(yt(),ce("Something went wrong.")),(P=(p=_e==null?void 0:_e.data)==null?void 0:p.data)!=null&&P.card_list&&((te=(j=(E=_e==null?void 0:_e.data)==null?void 0:E.data)==null?void 0:j.card_list)==null?void 0:te.length)>0){let Yt=(D=(W=(X=_e==null?void 0:_e.data)==null?void 0:X.data)==null?void 0:W.card_list)==null?void 0:D.filter(et=>(et==null?void 0:et.card_type)=="Bank"),cn=(de=(pe=(H=_e==null?void 0:_e.data)==null?void 0:H.data)==null?void 0:pe.card_list)==null?void 0:de.filter(et=>(et==null?void 0:et.card_type)!=="Bank");console.log(Yt,"hohgohoo",cn),ke([]),at([])}else we("card");(fe=(st=_e==null?void 0:_e.data)==null?void 0:st.data)!=null&&fe.paymentDeviceList&&((Ye=(bt=(it=_e==null?void 0:_e.data)==null?void 0:it.data)==null?void 0:bt.paymentDeviceList)==null?void 0:Ye.length)>0&&qe((Ve=(ft=_e==null?void 0:_e.data)==null?void 0:ft.data)==null?void 0:Ve.paymentDeviceList[0]),Ze()}catch(Ke){console.log(Ke),Ze(),ce(((We=(qt=Ke==null?void 0:Ke.response)==null?void 0:qt.data)==null?void 0:We.message)||(Ke==null?void 0:Ke.message)||"Something went wrong")}},Le=async()=>{let t=e==null?void 0:e.customerId,a=String(e==null?void 0:e.discount),N=String(e==null?void 0:e.surcharge),p=String(e==null?void 0:e.tax),P=e==null?void 0:e.merchantPublicKey,E=e==null?void 0:e.orderID,j=he&&!tt?he:String(Ne),te=pt==null?void 0:pt.id,X=pt==null?void 0:pt.card_type;if(!tt)if(P&&E&&j&&le)if(t)if(te){let D;he&&!tt?D=he:X==="Bank"?D=le:D=Ne;let H={amount:D,order_id:E,customer_id:t,card_id:te,fractalpayPublicKey:P,isCardSave:g,discount:a,surcharge:N,tax:p},W=H,{isCardSave:pe}=W,de=_n(W,["isCardSave"]),fe=Be+(X==="Bank"?"charge-ach":"charge-by-card"),it={"Content-Type":"application/json"};f(!0),xt.emit("sendMessage",{url:fe,body:X=="Bank"?de:H,isChargebycard:!0}),xt.on("charge-by-card",bt=>{var Ye;(bt==null?void 0:bt.result)==!0||(bt==null?void 0:bt.status)==!0?(re((Ye=bt.data)==null?void 0:Ye.transaction_id),Ge(!0),f(!1)):ce((bt==null?void 0:bt.message)||"Something went wrong.")})}else ce("Please Select A Card/ACH");else ce("Please Select Customer");else ce("Something went wrong.")},Vt=async()=>{var P,E,j,te,X,W;let t=e==null?void 0:e.merchantPublicKey,a=e==null?void 0:e.orderID,N=he&&!tt?he:String(Ne),p=e==null?void 0:e.customerId;if(!(mt!=null&&mt.device_id)){ce("Please Select A Payment Device");return}if(t&&a&&N){f(!0);let D={amount:N,fractalpayPublicKey:t,customer_order_id:a,device_id:mt==null?void 0:mt.device_id,customer_id:p||""};try{let H=await Hn.post(`${Be}charge-with-reader`,D);((P=H==null?void 0:H.data)==null?void 0:P.result)==!0?(re((j=(E=H==null?void 0:H.data)==null?void 0:E.data)==null?void 0:j.transaction_id),Ge(!0),f(!1)):(ce(((te=H==null?void 0:H.data)==null?void 0:te.message)||"Something went wrong."),f(!1))}catch(H){ce(((W=(X=H==null?void 0:H.response)==null?void 0:X.data)==null?void 0:W.message)||"Something went wrong."),f(!1)}}else ce("Something went wrong.")},Kt=()=>{oe==="card"?Le():oe==="reader"&&Vt()};En(()=>{ne&&x&&St()},[x,ne]);let Xt=async t=>{jn.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){f(!0);try{let N={card_id:t,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},p=await Hn.post(`${Be}delete-customer-card`,N);f(!1),St(),jn.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(N){f(!1),jn.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else a.dismiss===jn.DismissReason.cancel&&jn.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},ot=t=>{switch(t==null?void 0:t.toLowerCase()){case"visa":return R;case"mastercard":case"mc":case"m/c":return ee;case"amex":case"american express":case"ae":return $;case"discover":case"dcvr":return Me;case"bank":return Ue;default:return t}},nn=()=>{let t=le||0;return(Number(Ne)-t).toFixed(0)};console.log(Je,"activeinCard","activeinBank",Te);let Ft=t=>{var a,N,p,P;console.log(t,"values"),b==="ach"?((a=Number(le))==null?void 0:a.toFixed(2))<(t==null?void 0:t.floatValue)||(t==null?void 0:t.floatValue)<=0?(Ct(t==null?void 0:t.value),z(`Partial amount cannot exceeds ${Ce((N=Number(le))==null?void 0:N.toFixed(2))}`)):(Ct(t==null?void 0:t.value),z("")):((p=Number(Ne))==null?void 0:p.toFixed(2))<(t==null?void 0:t.floatValue)||(t==null?void 0:t.floatValue)<=0?(Ct(t==null?void 0:t.value),z(`Partial amount cannot exceeds ${Ce((P=Number(Ne))==null?void 0:P.toFixed(2))}`)):(Ct(t==null?void 0:t.value),z(""))};return En(()=>{let t=Number(b==="ach"?le:Ne),a=Number(he);he&&(a<=0||a>t)?z(`Partial amount cannot exceed ${Ce(t.toFixed(2))}`):z("")},[b,he,le,Ne]),console.log(b,"activetab"),n.createElement(n.Fragment,null,n.createElement(Dt,null),n.createElement(vn,null),n.createElement(Nn,null),n.createElement(n.Fragment,null,n.createElement("button",{ref:C,style:{display:"none"},className:"paymentBtn",onClick:kt},"Pay"),n.createElement(Ut,{open:ne,onClose:yt},Q&&n.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},n.createElement(tn,{error:Q,onClose:yt})),k&&n.createElement(Cn,{onClose:yt,tranId:De}),!Q&&!k&&n.createElement(n.Fragment,null,(ve||y)&&n.createElement(Ot,{loading:ve||y}),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:yt},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:u==null?void 0:u.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:u==null?void 0:u.logo,id:"pay-logos"})),(G==null?void 0:G.length)>0&&b!=="cardList"&&n.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>we("cardList")}," ",n.createElement(Wn,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(pn,{label:"Card",amount:(ze=Number(Ne))==null?void 0:ze.toFixed(2),value:"card",onChange:xe,activetab:b}),(u==null?void 0:u.isSkyFiAccount)&&n.createElement(pn,{label:"Bank",amount:(ut=Number(le))==null?void 0:ut.toFixed(2),value:"ach",onChange:xe,activetab:b})),le&&le>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,b==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,Ce((Number(Ne)-le).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(ga,{prefix:"$",className:"form-control",value:he,onValueChange:t=>{Ft(t)},thousandSeparator:!0,placeholder:"Enter partial amount",allowNegative:!1,allowLeadingZeros:!1,decimalScale:2,fixedDecimalScale:!0}),tt&&n.createElement("span",{className:"error-span"},tt)))),n.createElement("div",{className:"pay-conatiner-one-last"},n.createElement("img",{src:ye,alt:""}),n.createElement("img",{src:O,alt:""}),"Secure payments powered by Fractal")),n.createElement("div",{className:"pay-tab pay-conatiner-two"},!ve&&n.createElement("div",{className:"col-md-12"},n.createElement("div",{id:"payment-form-div"},b!=="cardList"?n.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(G==null?void 0:G.length)>0&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>we("cardList")}," ",n.createElement(Wn,null)," Back"),(u==null?void 0:u.isSkyFiAccount)&&n.createElement("div",{className:"tab"},n.createElement("button",{className:"tablinks",onClick:t=>{xe("card")},style:{border:b==="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:t=>{xe("ach")},style:{border:b==="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"},"$",(rn=Number(Ne))==null?void 0:rn.toFixed(2))),b!="ach"&&n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:R,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:ee,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:$,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Me,width:35,alt:""})))),le&&le>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",le)),le&&le>0&&(e!=null&&e.pass_fee)?n.createElement("div",{className:"frac-cash-discount-fee"},n.createElement("small",null,b==="card"?"Cash Discount":"Cash Discount Savings"," "),n.createElement("p",null,Ce((Number(Ne)-le).toFixed(2)))):null):n.createElement("div",null,n.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",u==null?void 0:u.customer_name),n.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",oe==="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"},"$",(Et=Number(Ne))==null?void 0:Et.toFixed(2))),n.createElement("div",null,n.createElement("div",null,n.createElement("img",{src:R,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:ee,width:35,alt:""})),n.createElement("div",null,n.createElement("img",{src:$,alt:"",width:35,style:{paddingRight:"5px"}}),n.createElement("img",{src:Me,width:35,alt:""}))))),n.createElement("div",{id:"card",style:{display:b==="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"},(G==null?void 0:G.length)>0&&Je==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ae("list")}," ",n.createElement(Wn,null)),le&&le>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),n.createElement("div",null,"$",le))),n.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),b!="ach"&&n.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},n.createElement("img",{src:R,alt:"",width:33}),n.createElement("img",{src:ee,width:33,alt:""}),n.createElement("img",{src:$,alt:"",width:33}),n.createElement("img",{src:Me,width:33,alt:""}))),Je==="list"?n.createElement(n.Fragment,null,n.createElement(fn,{listHeading:"Cards",paymentGateway:u==null?void 0:u.paymentGateway,ListItems:G,selectedCard:pt,setSelectedCard:Mt,handleDeleteCard:Xt,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{ae("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Kt},he&&!tt?Ce((en=Number(he))==null?void 0:en.toFixed(2)):Ce((At=Number(Ne))==null?void 0:At.toFixed(2))))):n.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Tt},n.createElement("div",{className:"ach-scrl",style:{minHeight:u!=null&&u.isSkyFiAccount&&(G==null?void 0:G.length)>0?"444px":u!=null&&u.isSkyFiAccount&&(G==null?void 0:G.length)==0?"456px":(G==null?void 0:G.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:(d==null?void 0:d.cardName)||"",onChange:t=>{let a=t.target.value;/^[a-zA-Z\s]*$/.test(a)&&_t("cardName",a)}}),(S==null?void 0:S.cardName)&&n.createElement("span",{className:"error-span"},S==null?void 0:S.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:(d==null?void 0:d.cardNumber)||"",onChange:t=>It(t),"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:(d==null?void 0:d.expiryMonth)||"",onChange:t=>_t("expiryMonth",t.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:(d==null?void 0:d.expiryYear)||"",onChange:t=>_t("expiryYear",t.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:(d==null?void 0:d.cvv)||"",onChange:t=>_t("cvv",t.target.value)})))),(S==null?void 0:S.cardNumber)&&n.createElement("span",{className:"error-span"},S==null?void 0:S.cardNumber),n.createElement("p",{style:{margin:"0"}},S!=null&&S.expiryMonth||S!=null&&S.expiryYear?n.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},S==null?void 0:S.expiryMonth):"",(S==null?void 0:S.cvv)&&n.createElement("span",{className:"error-span"},S==null?void 0:S.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:(an=e==null?void 0:e.orderID)!=null?an:"",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:(sn=d==null?void 0:d.zipCode)!=null?sn:"",onChange:t=>_t("zipCode",t.target.value)}),(S==null?void 0:S.zipCode)&&n.createElement("span",{className:"error-span"},S==null?void 0:S.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:g,onChange:t=>c(t.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"}},(u==null?void 0:u.paymentDeviceList)&&((ln=u==null?void 0:u.paymentDeviceList)==null?void 0:ln.length)>0&&n.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>B(!Pt)},Pt?"Pay With Reader":"Pay With Card"),n.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},he&&!tt?Ce((Y=Number(he))==null?void 0:Y.toFixed(2)):Ce((l=Number(Ne))==null?void 0:l.toFixed(2)))))),n.createElement("div",{id:"ach",style:{display:b==="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"},(zt==null?void 0:zt.length)>0&&Te==="form"&&n.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Xe("list")}," ",n.createElement(Wn,null)),le&&le>0&&n.createElement("div",{className:"res-pay-con frac-cash-discount"},n.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),n.createElement("div",null,"$",nn()))),n.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),Te==="list"?n.createElement(n.Fragment,null,n.createElement(fn,{listHeading:"Banks",paymentGateway:u==null?void 0:u.paymentGateway,ListItems:zt,selectedCard:pt,setSelectedCard:Mt,handleDeleteCard:Xt,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Xe("form")}}),n.createElement("div",{className:"form-group",style:{padding:"0"}},n.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Kt},he&&!tt?Ce((ue=Number(he))==null?void 0:ue.toFixed(2)):Ce((je=Number(le))==null?void 0:je.toFixed(2))))):n.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Tt},n.createElement("div",{className:"ach-scrl",style:{minHeight:u!=null&&u.isSkyFiAccount&&(G==null?void 0:G.length)>0?"444px":u!=null&&u.isSkyFiAccount&&(G==null?void 0:G.length)==0?"436px":(G==null?void 0:G.length)>0?"462px":"520px",maxHeight:u!=null&&u.isSkyFiAccount&&(G==null?void 0:G.length)>0?"444px":((G==null?void 0:G.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:(se=_==null?void 0:_.name)!=null?se:"",onChange:ct}),(h==null?void 0:h.name)&&n.createElement("span",{className:"error-span"},h==null?void 0:h.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:(Se=_==null?void 0:_.routingNumber)!=null?Se:"",onChange:ct}),(h==null?void 0:h.routingNumber)&&n.createElement("span",{className:"error-span"},h==null?void 0:h.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=_==null?void 0:_.accountNumber)!=null?Ee:"",onChange:ct}),(h==null?void 0:h.accountNumber)&&n.createElement("span",{className:"error-span"},h==null?void 0:h.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:(rt=_==null?void 0:_.confirmAccountNumber)!=null?rt:"",onChange:ct}),(h==null?void 0:h.confirmAccountNumber)&&n.createElement("span",{className:"error-span"},h==null?void 0:h.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:(nt=_==null?void 0:_.bankName)!=null?nt:"",onChange:ct}),(h==null?void 0:h.bankName)&&n.createElement("span",{className:"error-span"},h==null?void 0:h.bankName)),((_==null?void 0:_.accountType)==="business saving"||(_==null?void 0:_.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:(gt=_==null?void 0:_.companyName)!=null?gt:"",onChange:ct}),(h==null?void 0:h.companyName)&&n.createElement("span",{className:"error-span"},h==null?void 0:h.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:(Bt=_==null?void 0:_.accountType)!=null?Bt:"",onChange:ct},n.createElement("option",{value:""},"Select account"),Fn.map(t=>n.createElement("option",{key:t.value,value:t.value},t.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:t=>L(t.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"},he&&!tt?Ce((Re=Number(he))==null?void 0:Re.toFixed(2)):Ce((m=Number(le))==null?void 0:m.toFixed(2))))))))))))))))}export{oa as AddCard,sa as CardOnFile,Di as GetPaymentPage,pa as PartialPayment,ca as PaymentWidget,Ri as PreAuthPayment,ji as RequestPayment,Zi as RequestPreAuthPayment};
|
|
1709
|
+
`)}function pi({session_token:e,callback:ae,isloading:oe,onCancel:Ae,showChecks:Y,merchantName:$e,signCheckbox:T,checkedSignCheckbox:gt,onCheckSign:ze}){var At;let[ee,R]=Nn(!1),[W,re]=Nn(!1),[i,y]=Nn(),[u,q]=Nn({}),[Z,be]=Nn(""),Ge=()=>R(!0),Ve=()=>R(!1),Pe=()=>{var v,g,r,f,p,x,b,L;let _={},m=i,c=parseInt((m==null?void 0:m.expiryMonth)||"",10),z=(m==null?void 0:m.expiryYear)||"";return(v=m==null?void 0:m.firstName)!=null&&v.trim()||(_.firstName="Please enter a first name."),(g=m==null?void 0:m.lastName)!=null&&g.trim()||(_.lastName="Please enter a last name."),(r=m==null?void 0:m.cardNumber)!=null&&r.trim()||(_.cardNumber="Please enter a card number."),(f=m==null?void 0:m.expiryMonth)!=null&&f.trim()?(Number(m==null?void 0:m.expiryMonth)>12||Number(m==null?void 0:m.expiryMonth)<1)&&(_.expiryMonth="Invalid Expiration Month."):_.expiryMonth="Please enter an expiry month.",(p=m==null?void 0:m.expiryYear)!=null&&p.trim()?((x=m==null?void 0:m.expiryYear)==null?void 0:x.trim().length)!==4||Number(m==null?void 0:m.expiryYear)<2025?_.expiryYear="Invalid Expiration Year.":(isNaN(c)||c<1||c>12||z.length!==4)&&(_.expiryMonth="Invalid Expiration Date."):_.expiryYear="Please enter an expiry year.",(b=m==null?void 0:m.cvv)!=null&&b.trim()||(_.cvv="Please enter a CVV."),(L=m==null?void 0:m.zipCode)!=null&&L.trim()||(_.zipCode="Please enter a zip code."),T&&!gt&&(_.checkSign="You must authorize this before proceeding."),Y&&!(m!=null&&m.authHold)&&(_.authHold="You must authorize this before proceeding."),Y&&!(m!=null&&m.authorise)&&(_.authorise="Please confirm your authorization to continue."),q(_),Object.keys(_).length>0},he=_=>{let c=_.target.value.replace(/\D/g,""),z="";/^3[47]/.test(c)?z=c.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(g,r,f,p)=>[r,f,p].filter(Boolean).join(" ")):z=c.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(g,r,f,p,x)=>[r,f,p,x].filter(Boolean).join(" ")),q(v=>A(M({},v),{cardNumber:""})),y(v=>A(M({},v),{cardNumber:z}))},ce=(_,m)=>{let c=_;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(c)){(m===""||/^[0-9]+$/.test(m))&&(q(v=>A(M({},v),{[c]:""})),y(v=>A(M({},v),{[c]:m})));return}q(v=>A(M({},v),{[c]:""})),y(v=>A(M({},v),{[c]:m}))},kt=()=>{let _=DatacapWebToken.validateCardNumber(i==null?void 0:i.cardNumber.replaceAll(" ","")),m=DatacapWebToken.validateExpirationDate(i==null?void 0:i.expiryMonth,i==null?void 0:i.expiryYear),c=DatacapWebToken.validateCVV(i==null?void 0:i.cvv),z={};return _||(z.cardNumber="Invalid card Number"),m||(z.expiryMonth="Invalid Expiration Date."),c||(z.cvv="Invalid CVV"),q(z),_&&c&&m},k=async _=>{var m,c;if(_.Error)be(_.Error),Ve();else{let z={token:_.Token,resp:_},v=await wn.post(`${Yt}api/v1/gateway/update/token/${e}`,z);if((v==null?void 0:v.status)==200){let g=M(M({Token:(c=(m=v==null?void 0:v.data)==null?void 0:m.data)==null?void 0:c.gateway_token,Brand:_.Brand,ExpirationMonth:_.ExpirationMonth,ExpirationYear:_.ExpirationYear,Last4:_.Last4,Bin:_.Bin,CVV:_.CVV,postalCode:i==null?void 0:i.zipCode},Y&&{authHold:i==null?void 0:i.authHold}),Y&&{authorise:i==null?void 0:i.authorise});Ve(),ae(g)}}},je=async()=>{var _,m,c,z,v,g,r,f,p,x;try{let b={method:"POST",redirect:"follow"},L=await wn.post(`${Yt}api/v1/widget/generate-session`,b),h=Number(i==null?void 0:i.expiryYear)%100,B=`${(_=i==null?void 0:i.cardNumber)==null?void 0:_.replace(/\s+/g,"")}=${h}${i==null?void 0:i.expiryMonth} ${i==null?void 0:i.cvv}`,Nt=forge.pki.publicKeyFromPem((c=(m=L==null?void 0:L.data)==null?void 0:m.data)==null?void 0:c.publicKeyPem).encrypt(B,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),ot=forge.util.encode64(Nt),st={"Content-Type":"application/json","x-app-session-key":(v=(z=L.data)==null?void 0:z.data)==null?void 0:v.session_key},bt=JSON.stringify({enc_track2_data:ot,algorithm:"RSAES_OAEP_SHA_1",session_key:(r=(g=L==null?void 0:L.data)==null?void 0:g.data)==null?void 0:r.session_key}),tt=await wn.post(`${Ut}tokenizer/tokenize`,bt,{headers:st});if((tt==null?void 0:tt.status)==200){let xe=(p=(f=tt==null?void 0:tt.data)==null?void 0:f.data)==null?void 0:p.token;try{let G=await wn.post(`${Yt}api/v1/gateway/verify-and-save/${e}`,{token:xe});if((G==null?void 0:G.status)==200){let I=(x=G==null?void 0:G.data)==null?void 0:x.data,ne={Token:I.gateway_token,Brand:I.card_data.brand,ExpirationMonth:I.card_data.expire_mm,ExpirationYear:I.card_data.expire_yy,Last4:I.card_data.last4,Bin:I.card_data.bin,postalCode:i==null?void 0:i.zipCode};Ve(),ae(ne)}}catch(G){console.log(G,"error"),Ve()}}}catch(b){console.log(b,"eroror")}},V=async _=>{var z,v,g,r,f,p,x;if(_.preventDefault(),!(Pe()||!kt())){Ge();try{let b=await wn.get(`${Yt}api/v1/gateway/token/${e}`);if((b==null?void 0:b.status)==200){let L=(v=(z=b==null?void 0:b.data)==null?void 0:z.data)==null?void 0:v.gateway_token;((r=(g=b==null?void 0:b.data)==null?void 0:g.data)==null?void 0:r.paymentGateway)==((f=Hn)==null?void 0:f.FRACTALKEY)?await je():DatacapWebToken.requestToken(L,"creditCardForm",k)}}catch(b){Ve(),be(((x=(p=b==null?void 0:b.response)==null?void 0:p.data)==null?void 0:x.message)||"Something went wrong!")}}},Ue=()=>{be("")},Be=()=>{be(""),y({firstName:"",lastName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",zipCode:"",authHold:!1,authorise:!1,checkSign:!1}),Ae()};return F.createElement(F.Fragment,null,F.createElement(Jt,null),F.createElement(Tn,null),F.createElement(Lt,{loading:ee||oe}),Z&&F.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},F.createElement(Xt,{error:Z,onClose:Ue})),!Z&&F.createElement("div",{className:"creditformbox"},F.createElement("form",{id:"creditCardForm",onSubmit:V},F.createElement("div",{className:"name-row"},F.createElement("div",{className:"form-group"},F.createElement("label",null," First Name ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text",name:"first_name",placeholder:"First Name",value:(i==null?void 0:i.firstName)||"",onChange:_=>{let m=_.target.value;/^[a-zA-Z\s]*$/.test(m)&&ce("firstName",m)}}),(u==null?void 0:u.firstName)&&F.createElement("small",{className:"error"},u==null?void 0:u.firstName)),F.createElement("div",{className:"form-group"},F.createElement("label",null," Last Name ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text",name:"last_name",placeholder:"Last Name",value:(i==null?void 0:i.lastName)||"",onChange:_=>{let m=_.target.value;/^[a-zA-Z\s]*$/.test(m)&&ce("lastName",m)}}),(u==null?void 0:u.lastName)&&F.createElement("small",{className:"error"},u==null?void 0:u.lastName))),F.createElement("div",{className:"form-pay-row"},F.createElement("div",{className:"form-group"},F.createElement("label",null," Card Number ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text","data-token":"card_number",placeholder:"Card Number",maxLength:19,inputMode:"numeric",value:(i==null?void 0:i.cardNumber)||"",onChange:_=>he(_)}),(u==null?void 0:u.cardNumber)&&F.createElement("small",{className:"error"},u==null?void 0:u.cardNumber))),F.createElement("div",{className:"card-pay-row"},F.createElement("div",{className:"form-group"},F.createElement("label",null," Exp Month ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text","data-token":"exp_month",placeholder:"MM",maxLength:2,value:(i==null?void 0:i.expiryMonth)||"",onChange:_=>ce("expiryMonth",_.target.value)}),(u==null?void 0:u.expiryMonth)&&F.createElement("small",{className:"error"},u==null?void 0:u.expiryMonth)),F.createElement("div",{className:"form-group"},F.createElement("label",null," Exp Year ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text","data-token":"exp_year",placeholder:"YYYY",maxLength:4,value:(i==null?void 0:i.expiryYear)||"",onChange:_=>ce("expiryYear",_.target.value)}),(u==null?void 0:u.expiryYear)&&F.createElement("small",{className:"error"},u==null?void 0:u.expiryYear)),F.createElement("div",{className:"form-group"},F.createElement("label",null," CVV ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text","data-token":"cvv",placeholder:"CVV",maxLength:4,value:(i==null?void 0:i.cvv)||"",onChange:_=>ce("cvv",_.target.value)}),(u==null?void 0:u.cvv)&&F.createElement("small",{className:"error"},u==null?void 0:u.cvv)),F.createElement("div",{className:"form-group"},F.createElement("label",null," Zip ",F.createElement("span",{className:"text-danger"},"*")),F.createElement("input",{type:"text",name:"zipcode",placeholder:"Zip Code",value:(At=i==null?void 0:i.zipCode)!=null?At:"",onChange:_=>ce("zipCode",_.target.value)}),(u==null?void 0:u.zipCode)&&F.createElement("small",{className:"error"},u==null?void 0:u.zipCode))),T&&F.createElement("div",{className:"checks-row"},F.createElement("input",{name:"discalosure",type:"checkbox",id:"disclosureCheck",checked:gt,onChange:_=>ze(_.target.checked)}),F.createElement("label",{htmlFor:"disclosureCheck",className:"form-check-label"},"Please agree to the following in order to add Payment method.")),T&&(u==null?void 0:u.checkSign)&&F.createElement("small",{className:"check-error"},u==null?void 0:u.checkSign),Y&&F.createElement(F.Fragment,null,F.createElement("div",{className:"checks-row"},F.createElement("input",{name:"authHold",type:"checkbox",id:"authHold",checked:!!(i!=null&&i.authHold),onChange:_=>ce("authHold",_.target.checked)}),F.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.")),(u==null?void 0:u.authHold)&&F.createElement("small",{className:"check-error"},u==null?void 0:u.authHold),F.createElement("div",{className:"checks-row "},F.createElement("input",{name:"authorise",type:"checkbox",id:"authorise",checked:!!(i!=null&&i.authorise),onChange:_=>ce("authorise",_.target.checked)}),F.createElement("label",{htmlFor:"authorise",className:"form-check-label see-more"},W?F.createElement(F.Fragment,null,F.createElement("span",null,"By providing your payment information, you authorize"," ",F.createElement("strong",null,$e),", 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"," ",F.createElement("strong",null,$e),". You may request the removal of your stored payment information at any time by contacting"," ",F.createElement("strong",null,$e)," directly. By signing or proceeding with this transaction, you acknowledge and agree to this card on file authorization.",F.createElement("a",{href:"#",onClick:_=>{_.preventDefault(),re(!1)}},"See less ..."))):F.createElement(F.Fragment,null,F.createElement("span",null,"By providing your payment information, you authorize ",$e,", a Sky Systemz merchant, to securely store your card on file for future pay..."," "),F.createElement("a",{href:"#",onClick:_=>{_.preventDefault(),re(!0)}},"See more ...")))),(u==null?void 0:u.authorise)&&F.createElement("small",{className:"check-error"},u==null?void 0:u.authorise)),F.createElement("div",{className:"button-row"},F.createElement("button",{className:"cancelbtn",type:"button",onClick:Be},"Cancel"),F.createElement("button",{className:"savebtn",type:"submit"},"Save")))))}import t,{useEffect as Ln,useRef as bi,useState as He}from"react";import kn from"axios";import _n from"sweetalert2";import{IoArrowBack as In}from"react-icons/io5";import{NumericFormat as xi}from"react-number-format";function vi(e){var Ze,Re,Rt,$t,en,xt,Wt,rn,ln,S,o,E,ke,O,le,Me,Ee,We,et,St,qe,Bt;let ae=bi(null);Ln(()=>{e.onTriggerPay&&e.onTriggerPay(()=>{wt()})},[e]);let oe=de+"widget/mc-img.svg",Ae=de+"widget/visa-img.svg",Y=de+"widget/ae-img.svg",$e=de+"widget/discover-img.svg",T=de+"widget/card.svg",gt=de+"widget/Trash.svg",ze=de+"widget/bank.svg",ee=de+"widget/secure-img.png",R=de+"widget/pov-by.png",W=de+"widget/pax.svg",[re,i]=He(!1),[y,u]=He(!1),[q,Z]=He(""),[be,Ge]=He(!1),[Ve,Pe]=He(!1),[he,ce]=He("card"),[kt,k]=He("card"),[je,V]=He("form"),[Ue,Be]=He("form"),[At,_]=He(!0),[m,c]=He(!1),[z,v]=He(!1),g=e.merchantPublicKey,[r,f]=He(),[p,x]=He({}),[b,L]=He(),[h,C]=He({}),[B,Fe]=He([]),[Nt,ot]=He([]),[st,bt]=He(),[tt,xe]=He(),[G,I]=He(Number(e==null?void 0:e.amount)),[ne,Ke]=He(Number(e==null?void 0:e.amount)),[D,mt]=He(""),[Oe,N]=He("");console.log(D,"partialAmount");let[s,J]=He(),[Ce,K]=He(""),Ne=()=>i(!0),we=()=>i(!1),rt=(d,l)=>{let j=(parseFloat(l)||0)/100;return d-d*j},fe=(d,l)=>{let j=(Number(l)||0)/100;return+d+ +(d*j)};Ln(()=>{Ve&&(e!=null&&e.pass_fee?(Ke(Number(e==null?void 0:e.amount)),I(Number(e==null?void 0:e.cashDiscount))):(Ke(Number(e==null?void 0:e.amount)),I(Number(e==null?void 0:e.amount))))},[Ve,e==null?void 0:e.pass_fee,e==null?void 0:e.amount,e==null?void 0:e.surcharge]);let Qe=()=>{Pe(!1),ce("card"),Z(""),Ge(!1),K(""),L({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),C({name:"",routingNumber:"",accountNumber:"",confirmAccountNumber:"",bankName:"",accountType:""}),f({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),x({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),v(!1),c(!1),bt({card_type:"",cardlastfourdigit:"",expmonth:1,expyear:2025,primary_card:0,firstname:"",id:"",lastname:""}),xe({}),I(0),k("card"),_(!0),Be("form"),V("form"),u(!1),i(!1),ot([]),Fe([]),mt(""),N("")},wt=()=>Pe(!0),ht=d=>{ce(d)},dt=(d,l)=>{let j=d;if(["expiryMonth","expiryYear","zipCode","cvv"].includes(j)){(l===""||/^[0-9]+$/.test(l))&&(x($=>A(M({},$),{[j]:""})),f($=>A(M({},$),{[j]:l})));return}x($=>A(M({},$),{[j]:""})),f($=>A(M({},$),{[j]:l}))},_t=d=>{let j=d.target.value.replace(/\D/g,""),U="";/^3[47]/.test(j)?U=j.slice(0,15).replace(/^(\d{1,4})(\d{1,6})?(\d{1,5})?$/,(Le,X,ye,se)=>[X,ye,se].filter(Boolean).join(" ")):U=j.slice(0,16).replace(/^(\d{1,4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/,(Le,X,ye,se,ge)=>[X,ye,se,ge].filter(Boolean).join(" ")),x($=>A(M({},$),{cardNumber:""})),f($=>A(M({},$),{cardNumber:U}))},De=d=>{let{name:l,value:j}=d.target,U=["routingNumber","accountNumber","confirmAccountNumber"];if(l=="name"){/^[a-zA-Z\s]*$/.test(j)&&(C($=>A(M({},$),{[l]:""})),L($=>A(M({},$),{[l]:j})));return}if(U.includes(l)){(j===""||/^[0-9]+$/.test(j))&&(C($=>A(M({},$),{[l]:""})),L($=>A(M({},$),{[l]:j})));return}C($=>A(M({},$),{[l]:""})),L($=>A(M({},$),{[l]:j}))},jt=()=>{var $,Le,X,ye,se,ge;let d={},l=r,j=parseInt((l==null?void 0:l.expiryMonth)||"",10),U=(l==null?void 0:l.expiryYear)||"";if(($=l==null?void 0:l.cardName)!=null&&$.trim()||(d.cardName="Card name is required"),(Le=l==null?void 0:l.cardNumber)!=null&&Le.trim()||(d.cardNumber="Card number is required"),(!((X=l==null?void 0:l.expiryMonth)!=null&&X.trim())||!((ye=l==null?void 0:l.expiryYear)!=null&&ye.trim())||isNaN(j)||j<1||j>12||U.length!==4)&&(d.expiryMonth="Invalid Expiration Date."),(se=l==null?void 0:l.cvv)!=null&&se.trim()||(d.cvv="CVV is required"),(ge=l==null?void 0:l.zipCode)!=null&&ge.trim()||(d.zipCode="ZIP code is required"),l!=null&&l.expiryMonth&&(l!=null&&l.expiryYear)&&l.expiryMonth.length<=2&&l.expiryYear.length===4){let te=parseInt(l.expiryMonth,10),H=parseInt(l.expiryYear,10),Te=new Date,me=Te.getMonth()+1,it=Te.getFullYear();(H<it||H===it&&te<me)&&(d.expiryMonth="Card is expired")}return x(d),Object.keys(d).length>0},Ht=()=>{var j,U,$,Le,X,ye,se,ge;let d={},l=b;return(j=l==null?void 0:l.name)!=null&&j.trim()||(d.name="Name is required"),(U=l==null?void 0:l.accountNumber)!=null&&U.trim()||(d.accountNumber="Account number is required"),($=l==null?void 0:l.accountNumber)!=null&&$.trim()&&((Le=l==null?void 0:l.accountNumber)==null?void 0:Le.trim())!==((X=l==null?void 0:l.confirmAccountNumber)==null?void 0:X.trim())&&(d.confirmAccountNumber="Account numbers must match"),(ye=l==null?void 0:l.bankName)!=null&&ye.trim()||(d.bankName="Bank name is required"),(se=l==null?void 0:l.routingNumber)!=null&&se.trim()||(d.routingNumber="Routing Number is required"),l!=null&&l.routingNumber&&((ge=l==null?void 0:l.routingNumber)==null?void 0:ge.length)!==9&&(d.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)==="")&&(d.companyName="Company Name is required for business accounts"),C(d),Object.keys(d).length>0},Pt=async d=>{var l,j,U,$,Le,X,ye,se,ge,te,H,Te,me,it,ft;if(d.preventDefault(),!Oe)if(he!=="ach"){if(jt())return;{let ut=DatacapWebToken.validateCardNumber(r==null?void 0:r.cardNumber.replaceAll(" ","")),Ye=DatacapWebToken.validateExpirationDate(r==null?void 0:r.expiryMonth,r==null?void 0:r.expiryYear),Gt=DatacapWebToken.validateCVV(r==null?void 0:r.cvv),Kt={};if(ut||(Kt.cardNumber="Invalid card Number"),Ye||(Kt.expiryMonth="Invalid Expiration Date."),Gt||(Kt.cvv="Invalid CVV"),x(Kt),ut&&Gt&&Ye){u(!0);try{let qt=async function(_e){var ve,ie;if(_e.Error)Z(_e.Error),u(!1);else{let Et=r==null?void 0:r.cardName,sn=r==null?void 0:r.zipCode;_e.name=Et,_e.postal_code=sn,_e.isCardSave=`${m}`,_e.isCharge=!0,_e.posSalesIdEncode=(ve=s==null?void 0:s.orderDetails)==null?void 0:ve.orderId,_e.partial_amount=D&&!Oe?D:ne,Je.emit("sendMessage",_e);let Ct=(ie=s==null?void 0:s.orderDetails)==null?void 0:ie.orderId;Je.on(Ct,tn=>{if(hn(tn==null?void 0:tn.data)){let at=JSON.parse(tn.data);at!=null&&at.result?(f({cardName:"",cardNumber:"",expiryMonth:"",expiryYear:"",cvv:"",orderId:"",zipCode:""}),c(!1),K(at==null?void 0:at.transactionId),Ge(!0),u(!1)):(u(!1),Z((at==null?void 0:at.message)||"Something went wrong."))}else Z("Something went wrong.")})}};if((s==null?void 0:s.paymentGateway)===32){let _e={method:"POST",redirect:"follow"};try{let ve=await kn.post(`${Yt}api/v1/widget/generate-session`,_e),ie=Number(r==null?void 0:r.expiryYear)%100,Et=r==null?void 0:r.cardNumber;Et=Et==null?void 0:Et.replace(/\s+/g,"");let sn=`${Et}=${ie}${r==null?void 0:r.expiryMonth} ${r==null?void 0:r.cvv}`,tn=forge.pki.publicKeyFromPem((j=(l=ve==null?void 0:ve.data)==null?void 0:l.data)==null?void 0:j.publicKeyPem).encrypt(sn,"RSA-OAEP",{md:forge.md.sha1.create(),mgf1:{md:forge.md.sha1.create()}}),at=forge.util.encode64(tn),Zn={"Content-Type":"application/json","x-app-session-key":($=(U=ve.data)==null?void 0:U.data)==null?void 0:$.session_key},Wn=JSON.stringify({enc_track2_data:`${at}`,algorithm:"RSAES_OAEP_SHA_1",session_key:`${(X=(Le=ve==null?void 0:ve.data)==null?void 0:Le.data)==null?void 0:X.session_key}`});try{let Tt=await kn.post(`${Ut}tokenizer/tokenize`,Wn,{headers:Zn}),Gn=JSON.stringify(A(M({},(ye=Tt==null?void 0:Tt.data)==null?void 0:ye.data),{isSaveCardChecked:m,name:r==null?void 0:r.cardName,postal_code:r==null?void 0:r.zipCode,customer_id:e==null?void 0:e.customerId,partial_amount:D&&!Oe?D:ne})),En=JSON.stringify({pre_sales_id:`${(se=s==null?void 0:s.orderDetails)==null?void 0:se.orderId}`,token:`${(ge=Tt==null?void 0:Tt.data)==null?void 0:ge.data.token}`,json_response:`${Gn}`}),Un={method:"POST",headers:JSON.stringify({"Content-Type":"application/json"}),body:En,redirect:"follow",isChargeviafractal:!0};Je.emit("sendMessage",Un),Je.on("chargeviafractalgateway",un=>{var Yn;if(hn(un==null?void 0:un.data)){let nn=JSON.parse(un==null?void 0:un.data);nn!=null&&nn.result?(K((Yn=nn==null?void 0:nn.data)==null?void 0:Yn.transactionId),Ge(!0),u(!1)):(u(!1),Z((nn==null?void 0:nn.message)||"Something went wrong."))}else Z("Something went wrong.")})}catch(Tt){u(!1),Z(((H=(te=Tt==null?void 0:Tt.response)==null?void 0:te.data)==null?void 0:H.message)||(Tt==null?void 0:Tt.message)||"Something went wrong.")}}catch(ve){u(!1),Z(((me=(Te=ve==null?void 0:ve.response)==null?void 0:Te.data)==null?void 0:me.message)||(ve==null?void 0:ve.message)||"Something went wrong.")}}else typeof DatacapWebToken!="undefined"&&DatacapWebToken.requestToken(s==null?void 0:s.dctoken,"PaymentForm",qt)}catch(qt){u(!1),Z(((ft=(it=qt==null?void 0:qt.response)==null?void 0:it.data)==null?void 0:ft.message)||(qt==null?void 0:qt.message)||"Something went wrong.")}}}}else{if(Ht())return;{u(!0);let ut={fractalpayPublicKey:g,label:(b==null?void 0:b.name)||"John Doe",account_number:b==null?void 0:b.accountNumber,routing_number:b==null?void 0:b.routingNumber,bank_name:b==null?void 0:b.bankName,account_type:b==null?void 0:b.accountType,amount:D&&!Oe?D:String(G||0),isSaveAch:z,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:(b==null?void 0:b.companyName)||"",orderGuid:e==null?void 0:e.orderGuid};Je.emit("sendMessage",ut),Je.on("ach-incoming",Ye=>{var Gt;(Ye==null?void 0:Ye.status)=="Failed"?typeof(Ye==null?void 0:Ye.message)=="object"?Object.values(Ye==null?void 0:Ye.message).forEach(Kt=>{Z(Kt||"Something went wrong")}):Z((Ye==null?void 0:Ye.message)||"Something went wrong"):(K((Gt=Ye==null?void 0:Ye.data)==null?void 0:Gt.transaction_id),Ge(!0),u(!1))})}}},ct=async()=>{var d,l,j,U,$,Le,X,ye,se,ge,te,H,Te,me,it,ft,vt,ut,Ye,Gt,Kt,qt,_e;Ne();try{let ve={fractalpayPublicKey:g,customer_id:e==null?void 0:e.customerId,pass_fee:e==null?void 0:e.pass_fee,orderGuid:e==null?void 0:e.orderGuid},ie=await kn.post(`${Se}get-payment-details`,ve);if(J((d=ie==null?void 0:ie.data)==null?void 0:d.data),(j=(l=ie==null?void 0:ie.data)==null?void 0:l.data)!=null&&j.paymentGateway||(Qe(),Z("Something went wrong.")),($=(U=ie==null?void 0:ie.data)==null?void 0:U.data)!=null&&$.card_list&&((ye=(X=(Le=ie==null?void 0:ie.data)==null?void 0:Le.data)==null?void 0:X.card_list)==null?void 0:ye.length)>0){let Et=(te=(ge=(se=ie==null?void 0:ie.data)==null?void 0:se.data)==null?void 0:ge.card_list)==null?void 0:te.filter(Ct=>(Ct==null?void 0:Ct.card_type)=="Bank"),sn=(me=(Te=(H=ie==null?void 0:ie.data)==null?void 0:H.data)==null?void 0:Te.card_list)==null?void 0:me.filter(Ct=>(Ct==null?void 0:Ct.card_type)!=="Bank");console.log(Et,"hohgohoo",sn),Fe([]),ot([])}else ce("card");(ft=(it=ie==null?void 0:ie.data)==null?void 0:it.data)!=null&&ft.paymentDeviceList&&((Ye=(ut=(vt=ie==null?void 0:ie.data)==null?void 0:vt.data)==null?void 0:ut.paymentDeviceList)==null?void 0:Ye.length)>0&&xe((Kt=(Gt=ie==null?void 0:ie.data)==null?void 0:Gt.data)==null?void 0:Kt.paymentDeviceList[0]),we()}catch(ve){console.log(ve),we(),Z(((_e=(qt=ve==null?void 0:ve.response)==null?void 0:qt.data)==null?void 0:_e.message)||(ve==null?void 0:ve.message)||"Something went wrong")}},ue=async()=>{let d=e==null?void 0:e.customerId,l=String(e==null?void 0:e.discount),j=String(e==null?void 0:e.surcharge),U=String(e==null?void 0:e.tax),$=e==null?void 0:e.merchantPublicKey,Le=e==null?void 0:e.orderID,X=D&&!Oe?D:String(ne),ye=st==null?void 0:st.id,se=st==null?void 0:st.card_type;if(!Oe)if($&&Le&&X&&G)if(d)if(ye){let te;D&&!Oe?te=D:se==="Bank"?te=G:te=ne;let H={amount:te,order_id:Le,customer_id:d,card_id:ye,fractalpayPublicKey:$,isCardSave:m,discount:l,surcharge:j,tax:U},ge=H,{isCardSave:Te}=ge,me=gn(ge,["isCardSave"]),ft=Se+(se==="Bank"?"charge-ach":"charge-by-card"),vt={"Content-Type":"application/json"};u(!0),Je.emit("sendMessage",{url:ft,body:se=="Bank"?me:H,isChargebycard:!0}),Je.on("charge-by-card",ut=>{var Ye;(ut==null?void 0:ut.result)==!0||(ut==null?void 0:ut.status)==!0?(K((Ye=ut.data)==null?void 0:Ye.transaction_id),Ge(!0),u(!1)):Z((ut==null?void 0:ut.message)||"Something went wrong.")})}else Z("Please Select A Card/ACH");else Z("Please Select Customer");else Z("Something went wrong.")},Ft=async()=>{var $,Le,X,ye,se,ge;let d=e==null?void 0:e.merchantPublicKey,l=e==null?void 0:e.orderID,j=D&&!Oe?D:String(ne),U=e==null?void 0:e.customerId;if(!(tt!=null&&tt.device_id)){Z("Please Select A Payment Device");return}if(d&&l&&j){u(!0);let te={amount:j,fractalpayPublicKey:d,customer_order_id:l,device_id:tt==null?void 0:tt.device_id,customer_id:U||""};try{let H=await kn.post(`${Se}charge-with-reader`,te);(($=H==null?void 0:H.data)==null?void 0:$.result)==!0?(K((X=(Le=H==null?void 0:H.data)==null?void 0:Le.data)==null?void 0:X.transaction_id),Ge(!0),u(!1)):(Z(((ye=H==null?void 0:H.data)==null?void 0:ye.message)||"Something went wrong."),u(!1))}catch(H){Z(((ge=(se=H==null?void 0:H.response)==null?void 0:se.data)==null?void 0:ge.message)||"Something went wrong."),u(!1)}}else Z("Something went wrong.")},Mt=()=>{kt==="card"?ue():kt==="reader"&&Ft()};Ln(()=>{Ve&&g&&ct()},[g,Ve]);let Zt=async d=>{_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 l=>{if(l.isConfirmed){u(!0);try{let j={card_id:d,customer_id:e==null?void 0:e.customerId,fractalpayPublicKey:e==null?void 0:e.merchantPublicKey},U=await kn.post(`${Se}delete-customer-card`,j);u(!1),ct(),_n.fire({icon:"success",title:"Deleted!",text:"Card deleted.",confirmButtonText:"OK",showConfirmButton:!0,timer:1e3,timerProgressBar:!0,customClass:{confirmButton:"btn btn-dark"}})}catch(j){u(!1),_n.fire({icon:"error",title:"Error!",text:"Failed to delete the card.",confirmButtonText:"OK",customClass:{confirmButton:"btn btn-dark"}})}}else l.dismiss===_n.DismissReason.cancel&&_n.fire({icon:"info",text:"Card not deleted",confirmButtonText:"OK",buttonsStyling:!1,customClass:{confirmButton:"btn btn-dark float-end",actions:"swal2-actions-end"}})})},nt=d=>{switch(d==null?void 0:d.toLowerCase()){case"visa":return Ae;case"mastercard":case"mc":case"m/c":return oe;case"amex":case"american express":case"ae":return Y;case"discover":case"dcvr":return $e;case"bank":return ze;default:return d}},Dt=()=>{let d=G||0;return(Number(ne)-d).toFixed(0)};console.log(je,"activeinCard","activeinBank",Ue);let zt=d=>{var l,j,U,$;console.log(d,"values"),he==="ach"?((l=Number(G))==null?void 0:l.toFixed(2))<(d==null?void 0:d.floatValue)||(d==null?void 0:d.floatValue)<=0?(mt(d==null?void 0:d.value),N(`Partial amount cannot exceeds ${pe((j=Number(G))==null?void 0:j.toFixed(2))}`)):(mt(d==null?void 0:d.value),N("")):((U=Number(ne))==null?void 0:U.toFixed(2))<(d==null?void 0:d.floatValue)||(d==null?void 0:d.floatValue)<=0?(mt(d==null?void 0:d.value),N(`Partial amount cannot exceeds ${pe(($=Number(ne))==null?void 0:$.toFixed(2))}`)):(mt(d==null?void 0:d.value),N(""))};return Ln(()=>{let d=Number(he==="ach"?G:ne),l=Number(D);D&&(l<=0||l>d)?N(`Partial amount cannot exceed ${pe(d.toFixed(2))}`):N("")},[he,D,G,ne]),console.log(he,"activetab"),t.createElement(t.Fragment,null,t.createElement(Jt,null),t.createElement(mn,null),t.createElement(Pn,null),t.createElement(t.Fragment,null,t.createElement("button",{ref:ae,style:{display:"none"},className:"paymentBtn",onClick:wt},"Pay"),t.createElement(Vt,{open:Ve,onClose:Qe},q&&t.createElement("div",{style:{maxHeight:"606px",minHeight:"60vh",padding:"40px"}},t.createElement(Xt,{error:q,onClose:Qe})),be&&t.createElement(dn,{onClose:Qe,tranId:Ce}),!q&&!be&&t.createElement(t.Fragment,null,(re||y)&&t.createElement(Lt,{loading:re||y}),t.createElement("div",{className:"frac-card-payment-page frac-form"},t.createElement("div",{className:"parent-pay-container"},t.createElement("span",{className:"request-payment-close-popup",onClick:Qe},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:s==null?void 0:s.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:s==null?void 0:s.logo,id:"pay-logos"})),(B==null?void 0:B.length)>0&&he!=="cardList"&&t.createElement("button",{className:"res-charge-payment-back-btn ",onClick:()=>ce("cardList")}," ",t.createElement(In,null)," Back")),t.createElement("div",{className:"amt-pay-con"},t.createElement("div",{className:"pay-amount-conatiner"},t.createElement("small",{className:"pay-payment-amount"},"Select payment type")),t.createElement("div",{className:"frac-card-bank-radio-main"},t.createElement(fn,{label:"Card",amount:(Ze=Number(ne))==null?void 0:Ze.toFixed(2),value:"card",onChange:ht,activetab:he}),(s==null?void 0:s.isSkyFiAccount)&&t.createElement(fn,{label:"Bank",amount:(Re=Number(G))==null?void 0:Re.toFixed(2),value:"ach",onChange:ht,activetab:he})),G&&G>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,he==="card"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,pe((Number(ne)-G).toFixed(2)))):null,(e==null?void 0:e.allowPartial)&&t.createElement("div",{className:"frac-partial-payment-input"},t.createElement("label",{htmlFor:"partialpayment"},"Partial Payment"),t.createElement(xi,{prefix:"$",className:"form-control",value:D,onValueChange:d=>{zt(d)},thousandSeparator:!0,placeholder:"Enter partial amount",allowNegative:!1,allowLeadingZeros:!1,decimalScale:2,fixedDecimalScale:!0}),Oe&&t.createElement("span",{className:"error-span"},Oe)))),t.createElement("div",{className:"pay-conatiner-one-last"},t.createElement("img",{src:ee,alt:""}),t.createElement("img",{src:R,alt:""}),"Secure payments powered by Fractal")),t.createElement("div",{className:"pay-tab pay-conatiner-two"},!re&&t.createElement("div",{className:"col-md-12"},t.createElement("div",{id:"payment-form-div"},he!=="cardList"?t.createElement("div",{className:"frac-charge-payment-back-btn-wrap "},(B==null?void 0:B.length)>0&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>ce("cardList")}," ",t.createElement(In,null)," Back"),(s==null?void 0:s.isSkyFiAccount)&&t.createElement("div",{className:"tab"},t.createElement("button",{className:"tablinks",onClick:d=>{ht("card")},style:{border:he==="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:d=>{ht("ach")},style:{border:he==="ach"?"1px solid":""}},t.createElement("i",{className:"fas fa-university me-2",style:{marginRight:"8px",fontSize:"15px"}}),"Bank")),t.createElement("div",{className:"res-pay-con"},t.createElement("div",{className:"pay-amount-conatiner",style:{margin:0}},t.createElement("small",{className:"pay-payment-amount"},"Payment Amount"),t.createElement("strong",{className:"pay-amount"},"$",(Rt=Number(ne))==null?void 0:Rt.toFixed(2))),he!="ach"&&t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Ae,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:oe,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:Y,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:$e,width:35,alt:""})))),G&&G>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",G)),G&&G>0&&(e!=null&&e.pass_fee)?t.createElement("div",{className:"frac-cash-discount-fee"},t.createElement("small",null,he==="card"?"Cash Discount":"Cash Discount Savings"," "),t.createElement("p",null,pe((Number(ne)-G).toFixed(2)))):null):t.createElement("div",null,t.createElement("h6",{className:"charge-customer-name",style:{marginBottom:"16px !important"}}," Charge ",s==null?void 0:s.customer_name),t.createElement("h6",{className:"card-ach-heading",style:{marginBottom:"10px !important"}}," ",kt==="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"},"$",($t=Number(ne))==null?void 0:$t.toFixed(2))),t.createElement("div",null,t.createElement("div",null,t.createElement("img",{src:Ae,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:oe,width:35,alt:""})),t.createElement("div",null,t.createElement("img",{src:Y,alt:"",width:35,style:{paddingRight:"5px"}}),t.createElement("img",{src:$e,width:35,alt:""}))))),t.createElement("div",{id:"card",style:{display:he==="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"},(B==null?void 0:B.length)>0&&je==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>V("list")}," ",t.createElement(In,null)),G&&G>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount"),t.createElement("div",null,"$",G))),t.createElement("h6",{className:"frac-card-payment-heading"},"Card Payment")),he!="ach"&&t.createElement("div",{style:{display:"flex",gap:"8px",margin:"8px 0px 19px 0px"}},t.createElement("img",{src:Ae,alt:"",width:33}),t.createElement("img",{src:oe,width:33,alt:""}),t.createElement("img",{src:Y,alt:"",width:33}),t.createElement("img",{src:$e,width:33,alt:""}))),je==="list"?t.createElement(t.Fragment,null,t.createElement(yn,{listHeading:"Cards",paymentGateway:s==null?void 0:s.paymentGateway,ListItems:B,selectedCard:st,setSelectedCard:bt,handleDeleteCard:Zt,otherButtonLabel:"Pay With Other Card",otherButtonAction:()=>{V("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Mt},D&&!Oe?pe((en=Number(D))==null?void 0:en.toFixed(2)):pe((xt=Number(ne))==null?void 0:xt.toFixed(2))))):t.createElement("form",{id:"PaymentForm",style:{textAlign:"start"},onSubmit:Pt},t.createElement("div",{className:"ach-scrl",style:{minHeight:s!=null&&s.isSkyFiAccount&&(B==null?void 0:B.length)>0?"444px":s!=null&&s.isSkyFiAccount&&(B==null?void 0:B.length)==0?"456px":(B==null?void 0:B.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:(r==null?void 0:r.cardName)||"",onChange:d=>{let l=d.target.value;/^[a-zA-Z\s]*$/.test(l)&&dt("cardName",l)}}),(p==null?void 0:p.cardName)&&t.createElement("span",{className:"error-span"},p==null?void 0:p.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:(r==null?void 0:r.cardNumber)||"",onChange:d=>_t(d),"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:(r==null?void 0:r.expiryMonth)||"",onChange:d=>dt("expiryMonth",d.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:(r==null?void 0:r.expiryYear)||"",onChange:d=>dt("expiryYear",d.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:(r==null?void 0:r.cvv)||"",onChange:d=>dt("cvv",d.target.value)})))),(p==null?void 0:p.cardNumber)&&t.createElement("span",{className:"error-span"},p==null?void 0:p.cardNumber),t.createElement("p",{style:{margin:"0"}},p!=null&&p.expiryMonth||p!=null&&p.expiryYear?t.createElement("span",{className:"error-span",style:{paddingRight:"4px"}},p==null?void 0:p.expiryMonth):"",(p==null?void 0:p.cvv)&&t.createElement("span",{className:"error-span"},p==null?void 0:p.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:"Order Id",disabled:!0,value:(Wt=e==null?void 0:e.orderID)!=null?Wt:"",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:(rn=r==null?void 0:r.zipCode)!=null?rn:"",onChange:d=>dt("zipCode",d.target.value)}),(p==null?void 0:p.zipCode)&&t.createElement("span",{className:"error-span"},p==null?void 0:p.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:m,onChange:d=>c(d.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"}},(s==null?void 0:s.paymentDeviceList)&&((ln=s==null?void 0:s.paymentDeviceList)==null?void 0:ln.length)>0&&t.createElement("button",{type:"button",style:{marginBottom:"10px"},className:"pay-button",onClick:()=>_(!At)},At?"Pay With Reader":"Pay With Card"),t.createElement("button",{type:"submit",style:{margin:0},className:"pay-button"},D&&!Oe?pe((S=Number(D))==null?void 0:S.toFixed(2)):pe((o=Number(ne))==null?void 0:o.toFixed(2)))))),t.createElement("div",{id:"ach",style:{display:he==="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"},(Nt==null?void 0:Nt.length)>0&&Ue==="form"&&t.createElement("button",{className:"charge-payment-back-btn ",onClick:()=>Be("list")}," ",t.createElement(In,null)),G&&G>0&&t.createElement("div",{className:"res-pay-con frac-cash-discount"},t.createElement("div",{className:"frac-cashlabel"},"Cash Discount Savings"),t.createElement("div",null,"$",Dt()))),t.createElement("h6",{className:"frac-card-payment-heading"},"Bank Payment"))),Ue==="list"?t.createElement(t.Fragment,null,t.createElement(yn,{listHeading:"Banks",paymentGateway:s==null?void 0:s.paymentGateway,ListItems:Nt,selectedCard:st,setSelectedCard:bt,handleDeleteCard:Zt,otherButtonLabel:"Pay With Other Bank",otherButtonAction:()=>{Be("form")}}),t.createElement("div",{className:"form-group",style:{padding:"0"}},t.createElement("button",{className:"pay-button",style:{margin:"0px"},type:"submit",onClick:Mt},D&&!Oe?pe((E=Number(D))==null?void 0:E.toFixed(2)):pe((ke=Number(G))==null?void 0:ke.toFixed(2))))):t.createElement("form",{id:"ACHPaymentForm",style:{textAlign:"start"},onSubmit:Pt},t.createElement("div",{className:"ach-scrl",style:{minHeight:s!=null&&s.isSkyFiAccount&&(B==null?void 0:B.length)>0?"444px":s!=null&&s.isSkyFiAccount&&(B==null?void 0:B.length)==0?"436px":(B==null?void 0:B.length)>0?"462px":"520px",maxHeight:s!=null&&s.isSkyFiAccount&&(B==null?void 0:B.length)>0?"444px":((B==null?void 0:B.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:(O=b==null?void 0:b.name)!=null?O:"",onChange:De}),(h==null?void 0:h.name)&&t.createElement("span",{className:"error-span"},h==null?void 0:h.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:(le=b==null?void 0:b.routingNumber)!=null?le:"",onChange:De}),(h==null?void 0:h.routingNumber)&&t.createElement("span",{className:"error-span"},h==null?void 0:h.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:(Me=b==null?void 0:b.accountNumber)!=null?Me:"",onChange:De}),(h==null?void 0:h.accountNumber)&&t.createElement("span",{className:"error-span"},h==null?void 0:h.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:(Ee=b==null?void 0:b.confirmAccountNumber)!=null?Ee:"",onChange:De}),(h==null?void 0:h.confirmAccountNumber)&&t.createElement("span",{className:"error-span"},h==null?void 0:h.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:(We=b==null?void 0:b.bankName)!=null?We:"",onChange:De}),(h==null?void 0:h.bankName)&&t.createElement("span",{className:"error-span"},h==null?void 0:h.bankName)),((b==null?void 0:b.accountType)==="business saving"||(b==null?void 0:b.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:(et=b==null?void 0:b.companyName)!=null?et:"",onChange:De}),(h==null?void 0:h.companyName)&&t.createElement("span",{className:"error-span"},h==null?void 0:h.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:(St=b==null?void 0:b.accountType)!=null?St:"",onChange:De},t.createElement("option",{value:""},"Select account"),Sn.map(d=>t.createElement("option",{key:d.value,value:d.value},d.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:z,onChange:d=>v(d.target.checked)}),t.createElement("label",{htmlFor:"saveACH"},"Save ACH")),z&&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"},D&&!Oe?pe((qe=Number(D))==null?void 0:qe.toFixed(2)):pe((Bt=Number(G))==null?void 0:Bt.toFixed(2))))))))))))))))}var rr=Ci(()=>import("./PayButtonWithForm-PQCLPHH7.mjs").then(e=>e.PaymentWidget),{ssr:!1});export{fi as AddCard,pi as CardOnFile,si as GetPaymentPage,vi as PartialPayment,rr as PaymentWidget,mi as PreAuthPayment,Rn as RequestPayment,ii as RequestPreAuthPayment};
|