@payconductor/react 1.0.12 → 1.1.1
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/README.md +253 -253
- package/dist/esm/three-ds.d.ts +1 -1
- package/dist/esm/tokenizer.d.ts +1 -1
- package/dist/index.cjs.js +49 -49
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.es.js +1318 -1308
- package/dist/index.es.js.map +1 -1
- package/dist/payconductor/constants.d.ts +31 -31
- package/dist/payconductor/hooks/index.d.ts +7 -7
- package/dist/payconductor/hooks/use-element.d.ts +30 -30
- package/dist/payconductor/hooks/use-payconductor.d.ts +6 -6
- package/dist/payconductor/hooks/use-three-ds.d.ts +13 -13
- package/dist/payconductor/hooks/use-tokenizer.d.ts +11 -11
- package/dist/payconductor/iframe/constants.d.ts +8 -8
- package/dist/payconductor/iframe/types.d.ts +464 -464
- package/dist/payconductor/internal.d.ts +11 -11
- package/dist/payconductor/loader.d.ts +1 -1
- package/dist/payconductor/payconductor-element.d.ts +5 -5
- package/dist/payconductor/payconductor-three-ds.d.ts +5 -5
- package/dist/payconductor/payconductor.d.ts +17 -17
- package/dist/payconductor/three-ds/api.d.ts +12 -12
- package/dist/payconductor/three-ds/browser.d.ts +13 -13
- package/dist/payconductor/three-ds/handler.d.ts +11 -11
- package/dist/payconductor/three-ds/index.d.ts +3 -1
- package/dist/payconductor/three-ds/providers/index.d.ts +6 -6
- package/dist/payconductor/three-ds/providers/mercado-pago.d.ts +9 -9
- package/dist/payconductor/three-ds/providers/pagarme.d.ts +9 -9
- package/dist/payconductor/three-ds/providers/pagseguro.d.ts +7 -7
- package/dist/payconductor/three-ds/providers/payconductor.d.ts +7 -7
- package/dist/payconductor/three-ds/types.d.ts +93 -78
- package/dist/payconductor/tokenizer/api.d.ts +26 -26
- package/dist/payconductor/tokenizer/handler.d.ts +9 -9
- package/dist/payconductor/tokenizer/index.d.ts +1 -1
- package/dist/payconductor/tokenizer/providers/index.d.ts +6 -6
- package/dist/payconductor/tokenizer/providers/mercado-pago.d.ts +6 -6
- package/dist/payconductor/tokenizer/types.d.ts +50 -50
- package/dist/payconductor/types.d.ts +42 -42
- package/dist/payconductor/utils.d.ts +6 -6
- package/package.json +58 -58
package/dist/index.es.js
CHANGED
|
@@ -1,1308 +1,1318 @@
|
|
|
1
|
-
var
|
|
2
|
-
var $ = (e, n, t) => n in e ?
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useState as
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
primaryColor: "#0066ff",
|
|
10
|
-
secondaryColor: "#5a6b7c",
|
|
11
|
-
backgroundColor: "transparent",
|
|
12
|
-
surfaceColor: "#f8fafc",
|
|
13
|
-
textColor: "#0f172a",
|
|
14
|
-
textSecondaryColor: "#64748b",
|
|
15
|
-
errorColor: "#ef4444",
|
|
16
|
-
successColor: "#22c55e",
|
|
17
|
-
warningColor: "#f59e0b",
|
|
18
|
-
borderColor: "#e2e8f0",
|
|
19
|
-
disabledColor: "#cbd5e1",
|
|
20
|
-
fontFamily: '"Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
21
|
-
fontSize: {
|
|
22
|
-
xs: "0.75rem",
|
|
23
|
-
sm: "0.875rem",
|
|
24
|
-
md: "1rem",
|
|
25
|
-
lg: "1.125rem",
|
|
26
|
-
xl: "1.25rem"
|
|
27
|
-
},
|
|
28
|
-
fontWeight: {
|
|
29
|
-
normal: 400,
|
|
30
|
-
medium: 500,
|
|
31
|
-
bold: 600
|
|
32
|
-
},
|
|
33
|
-
lineHeight: "1.5",
|
|
34
|
-
spacing: {
|
|
35
|
-
xs: "4px",
|
|
36
|
-
sm: "8px",
|
|
37
|
-
md: "16px",
|
|
38
|
-
lg: "24px",
|
|
39
|
-
xl: "32px"
|
|
40
|
-
},
|
|
41
|
-
borderRadius: "8px",
|
|
42
|
-
borderWidth: "1px",
|
|
43
|
-
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
44
|
-
boxShadowHover: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
|
|
45
|
-
inputBackground: "#ffffff",
|
|
46
|
-
inputBorderColor: "#cbd5e1",
|
|
47
|
-
inputBorderRadius: "8px",
|
|
48
|
-
inputHeight: "44px",
|
|
49
|
-
inputPadding: "12px 16px",
|
|
50
|
-
buttonHeight: "48px",
|
|
51
|
-
buttonPadding: "16px 24px",
|
|
52
|
-
buttonBorderRadius: "8px",
|
|
53
|
-
transitionDuration: "0.2s",
|
|
54
|
-
transitionTimingFunction: "ease"
|
|
55
|
-
},
|
|
56
|
-
INIT:
|
|
57
|
-
CONFIG:
|
|
58
|
-
UPDATE:
|
|
59
|
-
CONFIRM_PAYMENT:
|
|
60
|
-
VALIDATE:
|
|
61
|
-
RESET:
|
|
62
|
-
READY:
|
|
63
|
-
ERROR:
|
|
64
|
-
PAYMENT_COMPLETE:
|
|
65
|
-
PAYMENT_FAILED:
|
|
66
|
-
PAYMENT_PENDING:
|
|
67
|
-
VALIDATION_ERROR:
|
|
68
|
-
PAYMENT_METHOD_SELECTED:
|
|
69
|
-
RESIZE:
|
|
70
|
-
},
|
|
71
|
-
INVALID_CLIENT: "InvalidClient",
|
|
72
|
-
INVALID_TOKEN: "InvalidToken",
|
|
73
|
-
NETWORK_ERROR: "NetworkError",
|
|
74
|
-
IFRAME_NOT_READY: "IframeNotReady",
|
|
75
|
-
PAYMENT_DECLINED: "PaymentDeclined",
|
|
76
|
-
VALIDATION_ERROR: "ValidationError",
|
|
77
|
-
TIMEOUT: "Timeout"
|
|
78
|
-
},
|
|
79
|
-
@keyframes payconductor-shimmer {
|
|
80
|
-
0% { background-position: -200% 0; }
|
|
81
|
-
100% { background-position: 200% 0; }
|
|
82
|
-
}
|
|
83
|
-
.payconductor-skeleton {
|
|
84
|
-
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
85
|
-
background-size: 200% 100%;
|
|
86
|
-
animation: payconductor-shimmer 1.5s infinite linear;
|
|
87
|
-
border-radius: 4px;
|
|
88
|
-
width: 100%;
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
91
|
-
function
|
|
92
|
-
const n = new URLSearchParams({
|
|
93
|
-
publicKey: e.publicKey
|
|
94
|
-
});
|
|
95
|
-
return `${
|
|
96
|
-
}
|
|
97
|
-
function
|
|
98
|
-
return crypto.randomUUID();
|
|
99
|
-
}
|
|
100
|
-
function
|
|
101
|
-
return n.some((t) => {
|
|
102
|
-
try {
|
|
103
|
-
return new URL(t).origin === e;
|
|
104
|
-
} catch {
|
|
105
|
-
return t === e;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function
|
|
110
|
-
return /* @__PURE__ */ new Map();
|
|
111
|
-
}
|
|
112
|
-
function
|
|
113
|
-
return new Promise((
|
|
114
|
-
if (!e || !("contentWindow" in e)) {
|
|
115
|
-
o(new Error("Iframe not defined"));
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (!(e != null && e.contentWindow)) {
|
|
119
|
-
o(new Error("Iframe not ready"));
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (!n) {
|
|
123
|
-
o(new Error("Pending requests not initialized"));
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const d =
|
|
127
|
-
n.set(d, {
|
|
128
|
-
resolve:
|
|
129
|
-
reject: o
|
|
130
|
-
}), e.contentWindow.postMessage({
|
|
131
|
-
type: t,
|
|
132
|
-
data: a,
|
|
133
|
-
requestId: d
|
|
134
|
-
}, "*"), setTimeout(() => {
|
|
135
|
-
n != null && n.has(d) && (n.delete(d), o(new Error("Request timeout")));
|
|
136
|
-
}, he);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
async function
|
|
143
|
-
return await
|
|
144
|
-
orderId: t.orderId
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
function
|
|
160
|
-
const
|
|
161
|
-
requestId:
|
|
162
|
-
type:
|
|
163
|
-
data: E,
|
|
164
|
-
error:
|
|
165
|
-
} =
|
|
166
|
-
if (
|
|
167
|
-
if (a == null || a(),
|
|
168
|
-
const {
|
|
169
|
-
resolve:
|
|
170
|
-
} = n.get(
|
|
171
|
-
n.delete(
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
177
|
-
const {
|
|
178
|
-
resolve:
|
|
179
|
-
reject:
|
|
180
|
-
} = n.get(
|
|
181
|
-
n.delete(
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (
|
|
185
|
-
t((
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (
|
|
189
|
-
E && typeof E == "object" && "status" in E && (o == null || o(E));
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (
|
|
193
|
-
E && typeof E == "object" && "status" in E && (d == null || d(E));
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (
|
|
197
|
-
E && typeof E == "object" && "status" in E && (s == null || s(E));
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (
|
|
201
|
-
E && typeof E == "object" && "paymentMethod" in E && (
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (
|
|
210
|
-
g == null || g();
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (
|
|
214
|
-
w == null || w();
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function
|
|
221
|
-
const [n, t] =
|
|
222
|
-
() => !1
|
|
223
|
-
), [a,
|
|
224
|
-
() => ""
|
|
225
|
-
), [s,
|
|
226
|
-
return
|
|
227
|
-
const
|
|
228
|
-
e.debug && console.log("[PayConductor]", ...
|
|
229
|
-
}, g =
|
|
230
|
-
publicKey: e.publicKey
|
|
231
|
-
});
|
|
232
|
-
d(g), t(!0);
|
|
233
|
-
const w =
|
|
234
|
-
let
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
var
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
if (
|
|
241
|
-
if (typeof
|
|
242
|
-
const
|
|
243
|
-
if ("current" in
|
|
244
|
-
return
|
|
245
|
-
if ("value" in
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
return
|
|
249
|
-
}
|
|
250
|
-
return document.querySelector(
|
|
251
|
-
".payconductor-element iframe"
|
|
252
|
-
) ?? void 0;
|
|
253
|
-
},
|
|
254
|
-
get iframe() {
|
|
255
|
-
return document.querySelector(
|
|
256
|
-
".payconductor-element iframe"
|
|
257
|
-
) ?? null;
|
|
258
|
-
},
|
|
259
|
-
set iframe(
|
|
260
|
-
},
|
|
261
|
-
iframeUrl: g,
|
|
262
|
-
error: null
|
|
263
|
-
}, E = {
|
|
264
|
-
publicKey: e.publicKey,
|
|
265
|
-
theme: e.theme,
|
|
266
|
-
locale: e.locale,
|
|
267
|
-
paymentMethods: e.paymentMethods,
|
|
268
|
-
defaultPaymentMethod: e.defaultPaymentMethod
|
|
269
|
-
},
|
|
270
|
-
confirmPayment: (
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
orderId:
|
|
274
|
-
});
|
|
275
|
-
const
|
|
276
|
-
return
|
|
277
|
-
{
|
|
278
|
-
type: P.CONFIG,
|
|
279
|
-
data: {
|
|
280
|
-
publicKey: e.publicKey,
|
|
281
|
-
orderId:
|
|
282
|
-
theme: e.theme,
|
|
283
|
-
locale: e.locale,
|
|
284
|
-
paymentMethods: e.paymentMethods,
|
|
285
|
-
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
286
|
-
showPaymentButtons: e.showPaymentButtons,
|
|
287
|
-
nuPayConfig: e.nuPayConfig
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
"*"
|
|
291
|
-
), E.orderId =
|
|
292
|
-
},
|
|
293
|
-
validate: (
|
|
294
|
-
reset: () => (
|
|
295
|
-
getSelectedPaymentMethod: () => s
|
|
296
|
-
};
|
|
297
|
-
window.PayConductor = {
|
|
298
|
-
frame:
|
|
299
|
-
config: E,
|
|
300
|
-
api:
|
|
301
|
-
selectedPaymentMethod: s
|
|
302
|
-
},
|
|
303
|
-
new CustomEvent("payconductor:registered", {
|
|
304
|
-
detail: window.PayConductor
|
|
305
|
-
})
|
|
306
|
-
);
|
|
307
|
-
const
|
|
308
|
-
if (!
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
311
|
-
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
theme: e.theme,
|
|
316
|
-
locale: e.locale,
|
|
317
|
-
paymentMethods: e.paymentMethods,
|
|
318
|
-
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
319
|
-
showPaymentButtons: e.showPaymentButtons
|
|
320
|
-
}),
|
|
321
|
-
theme: e.theme,
|
|
322
|
-
locale: e.locale,
|
|
323
|
-
paymentMethods: e.paymentMethods,
|
|
324
|
-
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
325
|
-
showPaymentButtons: e.showPaymentButtons,
|
|
326
|
-
nuPayConfig: e.nuPayConfig
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
var
|
|
331
|
-
(
|
|
332
|
-
|
|
333
|
-
w,
|
|
334
|
-
(
|
|
335
|
-
var
|
|
336
|
-
|
|
337
|
-
},
|
|
338
|
-
() => {
|
|
339
|
-
var
|
|
340
|
-
(
|
|
341
|
-
},
|
|
342
|
-
(
|
|
343
|
-
var
|
|
344
|
-
(
|
|
345
|
-
},
|
|
346
|
-
(
|
|
347
|
-
var
|
|
348
|
-
(
|
|
349
|
-
},
|
|
350
|
-
(
|
|
351
|
-
var
|
|
352
|
-
(
|
|
353
|
-
},
|
|
354
|
-
(
|
|
355
|
-
var
|
|
356
|
-
(
|
|
357
|
-
},
|
|
358
|
-
(
|
|
359
|
-
var
|
|
360
|
-
|
|
361
|
-
},
|
|
362
|
-
() => {
|
|
363
|
-
var
|
|
364
|
-
(
|
|
365
|
-
},
|
|
366
|
-
() => {
|
|
367
|
-
var
|
|
368
|
-
(
|
|
369
|
-
},
|
|
370
|
-
() => {
|
|
371
|
-
var
|
|
372
|
-
(
|
|
373
|
-
}
|
|
374
|
-
);
|
|
375
|
-
};
|
|
376
|
-
window.addEventListener("message",
|
|
377
|
-
const V = () => {
|
|
378
|
-
var
|
|
379
|
-
const
|
|
380
|
-
if (!
|
|
381
|
-
try {
|
|
382
|
-
if ((((
|
|
383
|
-
return
|
|
384
|
-
} catch {
|
|
385
|
-
}
|
|
386
|
-
return !1;
|
|
387
|
-
},
|
|
388
|
-
if (V()) return;
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
once: !0
|
|
393
|
-
});
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
setTimeout(
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
}, []), /* @__PURE__ */
|
|
400
|
-
"div",
|
|
401
|
-
{
|
|
402
|
-
className: "payconductor",
|
|
403
|
-
id: "payconductor",
|
|
404
|
-
style: {
|
|
405
|
-
display: "contents"
|
|
406
|
-
},
|
|
407
|
-
children: e.children
|
|
408
|
-
}
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
function
|
|
412
|
-
const n =
|
|
413
|
-
return
|
|
414
|
-
if (typeof document < "u" && !document.getElementById(
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
PayConductor: window.PayConductor
|
|
421
|
-
}));
|
|
422
|
-
},
|
|
423
|
-
if (
|
|
424
|
-
|
|
425
|
-
else {
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
};
|
|
429
|
-
window.addEventListener("payconductor:registered",
|
|
430
|
-
}
|
|
431
|
-
let g = !1;
|
|
432
|
-
const w = (
|
|
433
|
-
var
|
|
434
|
-
if (((
|
|
435
|
-
g = !0;
|
|
436
|
-
const
|
|
437
|
-
".payconductor-element iframe"
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
{
|
|
441
|
-
type: P.CONFIG,
|
|
442
|
-
data: {
|
|
443
|
-
height: e.height
|
|
444
|
-
},
|
|
445
|
-
requestId: "element-height"
|
|
446
|
-
},
|
|
447
|
-
"*"
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
return window.addEventListener("message", w), () => window.removeEventListener("message", w);
|
|
452
|
-
}, []), /* @__PURE__ */
|
|
453
|
-
"div",
|
|
454
|
-
{
|
|
455
|
-
className: "payconductor-element",
|
|
456
|
-
style: {
|
|
457
|
-
width: "100%"
|
|
458
|
-
},
|
|
459
|
-
children: [
|
|
460
|
-
|
|
461
|
-
"div",
|
|
462
|
-
{
|
|
463
|
-
className: "payconductor-skeleton",
|
|
464
|
-
style: {
|
|
465
|
-
height: e.height ||
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
),
|
|
469
|
-
|
|
470
|
-
"iframe",
|
|
471
|
-
{
|
|
472
|
-
allow: "payment",
|
|
473
|
-
title: "PayConductor",
|
|
474
|
-
ref: n,
|
|
475
|
-
src: t,
|
|
476
|
-
style: {
|
|
477
|
-
width: "100%",
|
|
478
|
-
height: e.height || d ||
|
|
479
|
-
border: "none"
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
) : null
|
|
483
|
-
]
|
|
484
|
-
}
|
|
485
|
-
);
|
|
486
|
-
}
|
|
487
|
-
function
|
|
488
|
-
const [n, t] =
|
|
489
|
-
return
|
|
490
|
-
const a = () => {
|
|
491
|
-
t(!0);
|
|
492
|
-
},
|
|
493
|
-
t(!1);
|
|
494
|
-
};
|
|
495
|
-
return window.addEventListener("payconductor:3ds:show", a), window.addEventListener("payconductor:3ds:hide",
|
|
496
|
-
container: () => document.getElementById("payconductor-3ds-container"),
|
|
497
|
-
show: a,
|
|
498
|
-
hide:
|
|
499
|
-
}, window.dispatchEvent(new CustomEvent("payconductor:3ds:registered"))), () => {
|
|
500
|
-
window.removeEventListener("payconductor:3ds:show", a), window.removeEventListener("payconductor:3ds:hide",
|
|
501
|
-
};
|
|
502
|
-
}, []), /* @__PURE__ */
|
|
503
|
-
"div",
|
|
504
|
-
{
|
|
505
|
-
className: "payconductor-three-ds",
|
|
506
|
-
id: "payconductor-3ds-container",
|
|
507
|
-
style: {
|
|
508
|
-
width: "100%",
|
|
509
|
-
display: n ? "block" : "none",
|
|
510
|
-
minHeight: n ? e.height || "600px" : "0"
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
function
|
|
516
|
-
const e = typeof window < "u" ? window.PayConductor : null, n = e != null && e.config ? {
|
|
517
|
-
publicKey: e.config.publicKey,
|
|
518
|
-
orderId: e.config.orderId,
|
|
519
|
-
theme: e.config.theme,
|
|
520
|
-
locale: e.config.locale
|
|
521
|
-
} : {}, t = e != null && e.frame ? {
|
|
522
|
-
iframe: e.frame.iframe,
|
|
523
|
-
error: e.frame.error
|
|
524
|
-
} : {
|
|
525
|
-
iframe: null,
|
|
526
|
-
error: null
|
|
527
|
-
};
|
|
528
|
-
return {
|
|
529
|
-
...n,
|
|
530
|
-
...t
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
function L(e) {
|
|
534
|
-
var n;
|
|
535
|
-
if ((n = e == null ? void 0 : e.frame) != null && n.iframe) {
|
|
536
|
-
const t = e.frame.iframe;
|
|
537
|
-
if (t instanceof HTMLIFrameElement) return t;
|
|
538
|
-
if (t && typeof t == "object") {
|
|
539
|
-
if ("current" in t) {
|
|
540
|
-
const a = t.current;
|
|
541
|
-
if (a instanceof HTMLIFrameElement) return a;
|
|
542
|
-
}
|
|
543
|
-
if ("value" in t) {
|
|
544
|
-
const a = t.value;
|
|
545
|
-
if (a instanceof HTMLIFrameElement) return a;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
return document.querySelector(".payconductor-element iframe") ?? null;
|
|
550
|
-
}
|
|
551
|
-
function
|
|
552
|
-
const e = () => typeof window < "u" ? window.PayConductor : null, n = (t, a) => {
|
|
553
|
-
const
|
|
554
|
-
if (!
|
|
555
|
-
const o = L(
|
|
556
|
-
o != null && o.contentWindow && o.contentWindow.postMessage({
|
|
557
|
-
type: t,
|
|
558
|
-
data: a
|
|
559
|
-
}, "*");
|
|
560
|
-
};
|
|
561
|
-
return {
|
|
562
|
-
init: async (t) => {
|
|
563
|
-
const a = L(e()),
|
|
564
|
-
return
|
|
565
|
-
},
|
|
566
|
-
confirmPayment: async (t) => {
|
|
567
|
-
if (!t.orderId)
|
|
568
|
-
throw new Error("Order ID is required");
|
|
569
|
-
const a = e();
|
|
570
|
-
if (!(a != null && a.api)) throw new Error("PayConductor not initialized");
|
|
571
|
-
return a.api.confirmPayment(t);
|
|
572
|
-
},
|
|
573
|
-
validate: (t) => {
|
|
574
|
-
const a = e();
|
|
575
|
-
return a ? a.api.validate(t) : Promise.resolve(!1);
|
|
576
|
-
},
|
|
577
|
-
reset: () => {
|
|
578
|
-
const t = e();
|
|
579
|
-
return t ? t.api.reset() : Promise.resolve();
|
|
580
|
-
},
|
|
581
|
-
getSelectedPaymentMethod: () => {
|
|
582
|
-
var t;
|
|
583
|
-
return ((t = e()) == null ? void 0 : t.selectedPaymentMethod) ?? null;
|
|
584
|
-
},
|
|
585
|
-
updateConfig: (t) => {
|
|
586
|
-
var
|
|
587
|
-
const a = (
|
|
588
|
-
n(P.CONFIG, {
|
|
589
|
-
publicKey: a == null ? void 0 : a.publicKey,
|
|
590
|
-
orderId: a == null ? void 0 : a.orderId,
|
|
591
|
-
theme: t.theme ?? (a == null ? void 0 : a.theme),
|
|
592
|
-
locale: t.locale ?? (a == null ? void 0 : a.locale),
|
|
593
|
-
paymentMethods: t.paymentMethods ?? (a == null ? void 0 : a.paymentMethods)
|
|
594
|
-
});
|
|
595
|
-
},
|
|
596
|
-
updateOrderId: (t) => {
|
|
597
|
-
var
|
|
598
|
-
const a = (
|
|
599
|
-
n(P.CONFIG, {
|
|
600
|
-
publicKey: a == null ? void 0 : a.publicKey,
|
|
601
|
-
orderId: t,
|
|
602
|
-
theme: a == null ? void 0 : a.theme,
|
|
603
|
-
locale: a == null ? void 0 : a.locale,
|
|
604
|
-
paymentMethods: a == null ? void 0 : a.paymentMethods
|
|
605
|
-
});
|
|
606
|
-
},
|
|
607
|
-
update: (t) => {
|
|
608
|
-
n(P.UPDATE, t);
|
|
609
|
-
},
|
|
610
|
-
submit: async () => {
|
|
611
|
-
const t = L(e()), a =
|
|
612
|
-
try {
|
|
613
|
-
return await
|
|
614
|
-
paymentMethod: void 0
|
|
615
|
-
};
|
|
616
|
-
} catch (
|
|
617
|
-
return {
|
|
618
|
-
error: {
|
|
619
|
-
message:
|
|
620
|
-
code: "payment_error",
|
|
621
|
-
type: "payment_error"
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
var b = /* @__PURE__ */ ((e) => (e.Success = "Success", e.Failed = "Failed", e.Timeout = "Timeout", e))(b || {});
|
|
629
|
-
class
|
|
630
|
-
constructor(n, t) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
this.data = n, this.options = t;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
var
|
|
720
|
-
this.cleanup(), (
|
|
721
|
-
status: b.
|
|
722
|
-
});
|
|
723
|
-
}, this.
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
var s,
|
|
782
|
-
this.cleanup(), (
|
|
783
|
-
status: b.
|
|
784
|
-
});
|
|
785
|
-
})
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (
|
|
842
|
-
s(this.fail("3DS
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if (!
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
return
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
};
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
});
|
|
1143
|
-
return
|
|
1144
|
-
}
|
|
1145
|
-
async
|
|
1146
|
-
const
|
|
1147
|
-
method: "POST",
|
|
1148
|
-
headers: this.headers,
|
|
1149
|
-
body: JSON.stringify(n)
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
|
-
}
|
|
1153
|
-
async
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var $ = (e, n, t) => n in e ? q(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var S = (e, n, t) => $(e, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { jsx as D, jsxs as W } from "react/jsx-runtime";
|
|
5
|
+
import { useState as I, useEffect as K, useRef as J } from "react";
|
|
6
|
+
const Y = "https://iframe.payconductor.ai/v1", j = "http://localhost:5175/v1", X = 3e5, Z = "600px";
|
|
7
|
+
var Q = /* @__PURE__ */ ((e) => (e.Pix = "Pix", e.CreditCard = "CreditCard", e.DebitCard = "DebitCard", e.BankSlip = "BankSlip", e.Crypto = "Crypto", e.ApplePay = "ApplePay", e.NuPay = "NuPay", e.PicPay = "PicPay", e.AmazonPay = "AmazonPay", e.SepaDebit = "SepaDebit", e.GooglePay = "GooglePay", e))(Q || {}), ee = /* @__PURE__ */ ((e) => (e.Grid = "grid", e.Vertical = "vertical", e.Horizontal = "horizontal", e))(ee || {}), te = /* @__PURE__ */ ((e) => (e.Succeeded = "succeeded", e.Pending = "pending", e.Failed = "failed", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.ThreeDsAwaitingChallenge = "ThreeDsAwaitingChallenge", e))(ne || {}), ae = /* @__PURE__ */ ((e) => (e.Authenticated = "Authenticated", e.NotAuthenticated = "NotAuthenticated", e.NeedChallenge = "NeedChallenge", e))(ae || {}), ie = /* @__PURE__ */ ((e) => (e.Pending = "Pending", e.Authenticated = "Authenticated", e.Failed = "Failed", e.NotEnrolled = "NotEnrolled", e))(ie || {}), G = /* @__PURE__ */ ((e) => (e.Cpf = "Cpf", e.Cnpj = "Cnpj", e))(G || {}), M = /* @__PURE__ */ ((e) => (e.Asaas = "Asaas", e.Sandbox = "Sandbox", e.SandboxSplit = "SandboxSplit", e.MercadoPago = "MercadoPago", e.NuPay = "NuPay", e.PicPay = "PicPay", e.Woovi = "Woovi", e.EfiBank = "EfiBank", e.BrasPag = "BrasPag", e.PagarMe = "PagarMe", e.BancoDoBrasil = "BancoDoBrasil", e.PagSeguro = "PagSeguro", e.Ebanx = "Ebanx", e.OnlyUp = "OnlyUp", e.Barte = "Barte", e.BarteSplit = "BarteSplit", e.PagSmileA55 = "PagSmileA55", e.Avantti = "Avantti", e.MonsterGateway = "MonsterGateway", e.SAC = "SAC", e.Lyra = "Lyra", e))(M || {}), re = /* @__PURE__ */ ((e) => (e.Visa = "Visa", e.Mastercard = "Mastercard", e.AmericanExpress = "AmericanExpress", e.DinersClub = "DinersClub", e.Discover = "Discover", e.JCB = "JCB", e.UnionPay = "UnionPay", e.Maestro = "Maestro", e.Mir = "Mir", e.Elo = "Elo", e.Hiper = "Hiper", e.Hipercard = "Hipercard", e.Verve = "Verve", e.Unknown = "Unknown", e))(re || {}), N = /* @__PURE__ */ ((e) => (e.Production = "Production", e.Sandbox = "Sandbox", e))(N || {}), oe = /* @__PURE__ */ ((e) => (e.USD = "USD", e.EUR = "EUR", e.BRL = "BRL", e.ARS = "ARS", e.CAD = "CAD", e.COP = "COP", e.GBP = "GBP", e.JPY = "JPY", e.MXN = "MXN", e.MZN = "MZN", e.CNY = "CNY", e.SAR = "SAR", e.ETH = "ETH", e.BNB = "BNB", e.BTC = "BTC", e.USDT = "USDT", e.USDC = "USDC", e.DOGE = "DOGE", e.SOL = "SOL", e))(oe || {}), se = /* @__PURE__ */ ((e) => (e.Android = "android", e.IOS = "ios", e.Web = "web", e.Chrome = "chrome", e.Safari = "safari", e))(se || {}), de = /* @__PURE__ */ ((e) => (e.Padding = "padding", e.Radius = "radius", e.Color = "color", e.Background = "background", e.Shadow = "shadow", e))(de || {}), T = /* @__PURE__ */ ((e) => (e.Init = "Init", e.Config = "Config", e.Update = "Update", e.ConfirmPayment = "ConfirmPayment", e.Validate = "Validate", e.Reset = "Reset", e))(T || {}), A = /* @__PURE__ */ ((e) => (e.Ready = "Ready", e.Error = "Error", e.CheckoutSessionCreated = "CheckoutSessionCreated", e.PaymentComplete = "PaymentComplete", e.PaymentFailed = "PaymentFailed", e.PaymentPending = "PaymentPending", e.ValidationError = "ValidationError", e.PaymentMethodSelected = "PaymentMethodSelected", e.Resize = "Resize", e.ThreeDSChallenge = "ThreeDSChallenge", e.ThreeDSComplete = "ThreeDSComplete", e.ThreeDSFailed = "ThreeDSFailed", e))(A || {}), ce = /* @__PURE__ */ ((e) => (e.InvalidClient = "InvalidClient", e.InvalidToken = "InvalidToken", e.NetworkError = "NetworkError", e.IframeNotReady = "IframeNotReady", e.PaymentDeclined = "PaymentDeclined", e.ValidationError = "ValidationError", e.Timeout = "Timeout", e))(ce || {});
|
|
8
|
+
const Xe = {
|
|
9
|
+
primaryColor: "#0066ff",
|
|
10
|
+
secondaryColor: "#5a6b7c",
|
|
11
|
+
backgroundColor: "transparent",
|
|
12
|
+
surfaceColor: "#f8fafc",
|
|
13
|
+
textColor: "#0f172a",
|
|
14
|
+
textSecondaryColor: "#64748b",
|
|
15
|
+
errorColor: "#ef4444",
|
|
16
|
+
successColor: "#22c55e",
|
|
17
|
+
warningColor: "#f59e0b",
|
|
18
|
+
borderColor: "#e2e8f0",
|
|
19
|
+
disabledColor: "#cbd5e1",
|
|
20
|
+
fontFamily: '"Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
21
|
+
fontSize: {
|
|
22
|
+
xs: "0.75rem",
|
|
23
|
+
sm: "0.875rem",
|
|
24
|
+
md: "1rem",
|
|
25
|
+
lg: "1.125rem",
|
|
26
|
+
xl: "1.25rem"
|
|
27
|
+
},
|
|
28
|
+
fontWeight: {
|
|
29
|
+
normal: 400,
|
|
30
|
+
medium: 500,
|
|
31
|
+
bold: 600
|
|
32
|
+
},
|
|
33
|
+
lineHeight: "1.5",
|
|
34
|
+
spacing: {
|
|
35
|
+
xs: "4px",
|
|
36
|
+
sm: "8px",
|
|
37
|
+
md: "16px",
|
|
38
|
+
lg: "24px",
|
|
39
|
+
xl: "32px"
|
|
40
|
+
},
|
|
41
|
+
borderRadius: "8px",
|
|
42
|
+
borderWidth: "1px",
|
|
43
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
44
|
+
boxShadowHover: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
|
|
45
|
+
inputBackground: "#ffffff",
|
|
46
|
+
inputBorderColor: "#cbd5e1",
|
|
47
|
+
inputBorderRadius: "8px",
|
|
48
|
+
inputHeight: "44px",
|
|
49
|
+
inputPadding: "12px 16px",
|
|
50
|
+
buttonHeight: "48px",
|
|
51
|
+
buttonPadding: "16px 24px",
|
|
52
|
+
buttonBorderRadius: "8px",
|
|
53
|
+
transitionDuration: "0.2s",
|
|
54
|
+
transitionTimingFunction: "ease"
|
|
55
|
+
}, le = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") && !window.location.search.includes("production"), ue = le ? j : Y, me = [j, Y], z = Z, he = X, P = {
|
|
56
|
+
INIT: T.Init,
|
|
57
|
+
CONFIG: T.Config,
|
|
58
|
+
UPDATE: T.Update,
|
|
59
|
+
CONFIRM_PAYMENT: T.ConfirmPayment,
|
|
60
|
+
VALIDATE: T.Validate,
|
|
61
|
+
RESET: T.Reset,
|
|
62
|
+
READY: A.Ready,
|
|
63
|
+
ERROR: A.Error,
|
|
64
|
+
PAYMENT_COMPLETE: A.PaymentComplete,
|
|
65
|
+
PAYMENT_FAILED: A.PaymentFailed,
|
|
66
|
+
PAYMENT_PENDING: A.PaymentPending,
|
|
67
|
+
VALIDATION_ERROR: A.ValidationError,
|
|
68
|
+
PAYMENT_METHOD_SELECTED: A.PaymentMethodSelected,
|
|
69
|
+
RESIZE: A.Resize
|
|
70
|
+
}, Ze = {
|
|
71
|
+
INVALID_CLIENT: "InvalidClient",
|
|
72
|
+
INVALID_TOKEN: "InvalidToken",
|
|
73
|
+
NETWORK_ERROR: "NetworkError",
|
|
74
|
+
IFRAME_NOT_READY: "IframeNotReady",
|
|
75
|
+
PAYMENT_DECLINED: "PaymentDeclined",
|
|
76
|
+
VALIDATION_ERROR: "ValidationError",
|
|
77
|
+
TIMEOUT: "Timeout"
|
|
78
|
+
}, H = "payconductor-skeleton-style", fe = `
|
|
79
|
+
@keyframes payconductor-shimmer {
|
|
80
|
+
0% { background-position: -200% 0; }
|
|
81
|
+
100% { background-position: 200% 0; }
|
|
82
|
+
}
|
|
83
|
+
.payconductor-skeleton {
|
|
84
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
85
|
+
background-size: 200% 100%;
|
|
86
|
+
animation: payconductor-shimmer 1.5s infinite linear;
|
|
87
|
+
border-radius: 4px;
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
function ye(e) {
|
|
92
|
+
const n = new URLSearchParams({
|
|
93
|
+
publicKey: e.publicKey
|
|
94
|
+
});
|
|
95
|
+
return `${ue}?${n.toString()}`;
|
|
96
|
+
}
|
|
97
|
+
function we() {
|
|
98
|
+
return crypto.randomUUID();
|
|
99
|
+
}
|
|
100
|
+
function Ee(e, n) {
|
|
101
|
+
return n.some((t) => {
|
|
102
|
+
try {
|
|
103
|
+
return new URL(t).origin === e;
|
|
104
|
+
} catch {
|
|
105
|
+
return t === e;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function F() {
|
|
110
|
+
return /* @__PURE__ */ new Map();
|
|
111
|
+
}
|
|
112
|
+
function _(e, n, t, a) {
|
|
113
|
+
return new Promise((i, o) => {
|
|
114
|
+
if (!e || !("contentWindow" in e)) {
|
|
115
|
+
o(new Error("Iframe not defined"));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!(e != null && e.contentWindow)) {
|
|
119
|
+
o(new Error("Iframe not ready"));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!n) {
|
|
123
|
+
o(new Error("Pending requests not initialized"));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const d = we();
|
|
127
|
+
n.set(d, {
|
|
128
|
+
resolve: i,
|
|
129
|
+
reject: o
|
|
130
|
+
}), e.contentWindow.postMessage({
|
|
131
|
+
type: t,
|
|
132
|
+
data: a,
|
|
133
|
+
requestId: d
|
|
134
|
+
}, "*"), setTimeout(() => {
|
|
135
|
+
n != null && n.has(d) && (n.delete(d), o(new Error("Request timeout")));
|
|
136
|
+
}, he);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function ge(e, n, t) {
|
|
140
|
+
return _(e, n, P.CONFIRM_PAYMENT, t);
|
|
141
|
+
}
|
|
142
|
+
async function Pe(e, n, t) {
|
|
143
|
+
return await ge(e, n, {
|
|
144
|
+
orderId: t.orderId
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function Ce(e, n, t) {
|
|
148
|
+
return _(e, n, P.VALIDATE, t);
|
|
149
|
+
}
|
|
150
|
+
function be(e, n) {
|
|
151
|
+
return _(e, n, P.RESET);
|
|
152
|
+
}
|
|
153
|
+
function pe(e, n, t) {
|
|
154
|
+
return _(e, n, P.CONFIG, t);
|
|
155
|
+
}
|
|
156
|
+
function Se(e, n, t) {
|
|
157
|
+
return _(e, n, P.INIT, t);
|
|
158
|
+
}
|
|
159
|
+
function ve(e, n, t, a, i, o, d, s, r, c, g, w) {
|
|
160
|
+
const h = e.data, {
|
|
161
|
+
requestId: f,
|
|
162
|
+
type: u,
|
|
163
|
+
data: E,
|
|
164
|
+
error: p
|
|
165
|
+
} = h;
|
|
166
|
+
if (u === P.READY) {
|
|
167
|
+
if (a == null || a(), f && (n != null && n.has(f))) {
|
|
168
|
+
const {
|
|
169
|
+
resolve: v
|
|
170
|
+
} = n.get(f);
|
|
171
|
+
n.delete(f), v(E);
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (Ee(e.origin, me)) {
|
|
176
|
+
if (f && n && n.has(f)) {
|
|
177
|
+
const {
|
|
178
|
+
resolve: v,
|
|
179
|
+
reject: U
|
|
180
|
+
} = n.get(f);
|
|
181
|
+
n.delete(f), p ? U(new Error(String(p.message))) : v(E);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (u === P.ERROR) {
|
|
185
|
+
t((p == null ? void 0 : p.message) || "Unknown error"), i == null || i(new Error(String(p == null ? void 0 : p.message)));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (u === P.PAYMENT_COMPLETE) {
|
|
189
|
+
E && typeof E == "object" && "status" in E && (o == null || o(E));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (u === P.PAYMENT_FAILED) {
|
|
193
|
+
E && typeof E == "object" && "status" in E && (d == null || d(E));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (u === P.PAYMENT_PENDING) {
|
|
197
|
+
E && typeof E == "object" && "status" in E && (s == null || s(E));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (u === P.PAYMENT_METHOD_SELECTED) {
|
|
201
|
+
E && typeof E == "object" && "paymentMethod" in E && (r == null || r(E.paymentMethod));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (u !== P.RESIZE) {
|
|
205
|
+
if (u === A.ThreeDSChallenge) {
|
|
206
|
+
c == null || c();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (u === A.ThreeDSComplete) {
|
|
210
|
+
g == null || g();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (u === A.ThreeDSFailed) {
|
|
214
|
+
w == null || w();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function Qe(e) {
|
|
221
|
+
const [n, t] = I(
|
|
222
|
+
() => !1
|
|
223
|
+
), [a, i] = I(() => null), [o, d] = I(
|
|
224
|
+
() => ""
|
|
225
|
+
), [s, r] = I(() => null);
|
|
226
|
+
return K(() => {
|
|
227
|
+
const c = (...m) => {
|
|
228
|
+
e.debug && console.log("[PayConductor]", ...m);
|
|
229
|
+
}, g = ye({
|
|
230
|
+
publicKey: e.publicKey
|
|
231
|
+
});
|
|
232
|
+
d(g), t(!0);
|
|
233
|
+
const w = F();
|
|
234
|
+
let h = !1;
|
|
235
|
+
c("init", e.publicKey), c("iframeUrl", g);
|
|
236
|
+
const f = () => {
|
|
237
|
+
var C, l;
|
|
238
|
+
const m = (l = (C = window.PayConductor) == null ? void 0 : C.frame) == null ? void 0 : l.iframe;
|
|
239
|
+
if (m) {
|
|
240
|
+
if (m instanceof HTMLIFrameElement) return m;
|
|
241
|
+
if (typeof m == "object" && m !== null) {
|
|
242
|
+
const y = m;
|
|
243
|
+
if ("current" in y && y.current instanceof HTMLIFrameElement)
|
|
244
|
+
return y.current;
|
|
245
|
+
if ("value" in y && y.value instanceof HTMLIFrameElement)
|
|
246
|
+
return y.value;
|
|
247
|
+
}
|
|
248
|
+
return m;
|
|
249
|
+
}
|
|
250
|
+
return document.querySelector(
|
|
251
|
+
".payconductor-element iframe"
|
|
252
|
+
) ?? void 0;
|
|
253
|
+
}, u = {
|
|
254
|
+
get iframe() {
|
|
255
|
+
return document.querySelector(
|
|
256
|
+
".payconductor-element iframe"
|
|
257
|
+
) ?? null;
|
|
258
|
+
},
|
|
259
|
+
set iframe(m) {
|
|
260
|
+
},
|
|
261
|
+
iframeUrl: g,
|
|
262
|
+
error: null
|
|
263
|
+
}, E = {
|
|
264
|
+
publicKey: e.publicKey,
|
|
265
|
+
theme: e.theme,
|
|
266
|
+
locale: e.locale,
|
|
267
|
+
paymentMethods: e.paymentMethods,
|
|
268
|
+
defaultPaymentMethod: e.defaultPaymentMethod
|
|
269
|
+
}, p = {
|
|
270
|
+
confirmPayment: (m) => {
|
|
271
|
+
var l;
|
|
272
|
+
c("→ CONFIRM_PAYMENT", {
|
|
273
|
+
orderId: m.orderId
|
|
274
|
+
});
|
|
275
|
+
const C = f();
|
|
276
|
+
return C != null && C.contentWindow && C.contentWindow.postMessage(
|
|
277
|
+
{
|
|
278
|
+
type: P.CONFIG,
|
|
279
|
+
data: {
|
|
280
|
+
publicKey: e.publicKey,
|
|
281
|
+
orderId: m.orderId,
|
|
282
|
+
theme: e.theme,
|
|
283
|
+
locale: e.locale,
|
|
284
|
+
paymentMethods: e.paymentMethods,
|
|
285
|
+
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
286
|
+
showPaymentButtons: e.showPaymentButtons,
|
|
287
|
+
nuPayConfig: e.nuPayConfig
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
"*"
|
|
291
|
+
), E.orderId = m.orderId, (l = window.PayConductor) != null && l.config && (window.PayConductor.config.orderId = m.orderId), Pe(C, w, m);
|
|
292
|
+
},
|
|
293
|
+
validate: (m) => (c("→ VALIDATE", m), Ce(f(), w, m)),
|
|
294
|
+
reset: () => (c("→ RESET"), be(f(), w)),
|
|
295
|
+
getSelectedPaymentMethod: () => s
|
|
296
|
+
};
|
|
297
|
+
window.PayConductor = {
|
|
298
|
+
frame: u,
|
|
299
|
+
config: E,
|
|
300
|
+
api: p,
|
|
301
|
+
selectedPaymentMethod: s
|
|
302
|
+
}, c("registered"), window.dispatchEvent(
|
|
303
|
+
new CustomEvent("payconductor:registered", {
|
|
304
|
+
detail: window.PayConductor
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
const v = async () => {
|
|
308
|
+
if (!h) {
|
|
309
|
+
const m = f();
|
|
310
|
+
if (!m) {
|
|
311
|
+
c("→ CONFIG skipped: iframe not found");
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
h = !0, c("→ CONFIG", {
|
|
315
|
+
theme: e.theme,
|
|
316
|
+
locale: e.locale,
|
|
317
|
+
paymentMethods: e.paymentMethods,
|
|
318
|
+
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
319
|
+
showPaymentButtons: e.showPaymentButtons
|
|
320
|
+
}), pe(m, w, {
|
|
321
|
+
theme: e.theme,
|
|
322
|
+
locale: e.locale,
|
|
323
|
+
paymentMethods: e.paymentMethods,
|
|
324
|
+
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
325
|
+
showPaymentButtons: e.showPaymentButtons,
|
|
326
|
+
nuPayConfig: e.nuPayConfig
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}, U = (m) => {
|
|
330
|
+
var C;
|
|
331
|
+
(C = m.data) != null && C.type && c("←", m.data.type, m.data.data ?? ""), ve(
|
|
332
|
+
m,
|
|
333
|
+
w,
|
|
334
|
+
(l) => {
|
|
335
|
+
var y;
|
|
336
|
+
i(l), u.error = l, (y = window.PayConductor) != null && y.frame && (window.PayConductor.frame.error = l);
|
|
337
|
+
},
|
|
338
|
+
() => {
|
|
339
|
+
var l;
|
|
340
|
+
(l = e.onReady) == null || l.call(e), v();
|
|
341
|
+
},
|
|
342
|
+
(l) => {
|
|
343
|
+
var y;
|
|
344
|
+
(y = e.onError) == null || y.call(e, l);
|
|
345
|
+
},
|
|
346
|
+
(l) => {
|
|
347
|
+
var y;
|
|
348
|
+
(y = e.onPaymentComplete) == null || y.call(e, l);
|
|
349
|
+
},
|
|
350
|
+
(l) => {
|
|
351
|
+
var y;
|
|
352
|
+
(y = e.onPaymentFailed) == null || y.call(e, l);
|
|
353
|
+
},
|
|
354
|
+
(l) => {
|
|
355
|
+
var y;
|
|
356
|
+
(y = e.onPaymentPending) == null || y.call(e, l);
|
|
357
|
+
},
|
|
358
|
+
(l) => {
|
|
359
|
+
var y;
|
|
360
|
+
r(l), window.PayConductor && (window.PayConductor.selectedPaymentMethod = l), (y = e.onPaymentMethodSelected) == null || y.call(e, l);
|
|
361
|
+
},
|
|
362
|
+
() => {
|
|
363
|
+
var l;
|
|
364
|
+
(l = e.onThreeDSChallenge) == null || l.call(e);
|
|
365
|
+
},
|
|
366
|
+
() => {
|
|
367
|
+
var l;
|
|
368
|
+
(l = e.onThreeDSComplete) == null || l.call(e);
|
|
369
|
+
},
|
|
370
|
+
() => {
|
|
371
|
+
var l;
|
|
372
|
+
(l = e.onThreeDSFailed) == null || l.call(e);
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
};
|
|
376
|
+
window.addEventListener("message", U);
|
|
377
|
+
const V = () => {
|
|
378
|
+
var C, l, y;
|
|
379
|
+
const m = f();
|
|
380
|
+
if (!m) return !1;
|
|
381
|
+
try {
|
|
382
|
+
if ((((C = m.contentDocument) == null ? void 0 : C.readyState) ?? ((y = (l = m.contentWindow) == null ? void 0 : l.document) == null ? void 0 : y.readyState)) === "complete")
|
|
383
|
+
return v(), !0;
|
|
384
|
+
} catch {
|
|
385
|
+
}
|
|
386
|
+
return !1;
|
|
387
|
+
}, B = () => {
|
|
388
|
+
if (V()) return;
|
|
389
|
+
const m = f();
|
|
390
|
+
if (m) {
|
|
391
|
+
m.addEventListener("load", () => v(), {
|
|
392
|
+
once: !0
|
|
393
|
+
});
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
setTimeout(B, 50);
|
|
397
|
+
};
|
|
398
|
+
B();
|
|
399
|
+
}, []), /* @__PURE__ */ D(
|
|
400
|
+
"div",
|
|
401
|
+
{
|
|
402
|
+
className: "payconductor",
|
|
403
|
+
id: "payconductor",
|
|
404
|
+
style: {
|
|
405
|
+
display: "contents"
|
|
406
|
+
},
|
|
407
|
+
children: e.children
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function et(e) {
|
|
412
|
+
const n = J(null), [t, a] = I(() => ""), [i, o] = I(() => !1), [d, s] = I(() => "");
|
|
413
|
+
return K(() => {
|
|
414
|
+
if (typeof document < "u" && !document.getElementById(H)) {
|
|
415
|
+
const h = document.createElement("style");
|
|
416
|
+
h.id = H, h.textContent = fe, document.head.appendChild(h);
|
|
417
|
+
}
|
|
418
|
+
const r = (h) => {
|
|
419
|
+
h != null && h.frame && (a(h.frame.iframeUrl || ""), o(!0), console.log("init", {
|
|
420
|
+
PayConductor: window.PayConductor
|
|
421
|
+
}));
|
|
422
|
+
}, c = typeof window < "u" ? window.PayConductor : null;
|
|
423
|
+
if (c)
|
|
424
|
+
r(c);
|
|
425
|
+
else {
|
|
426
|
+
const h = (f) => {
|
|
427
|
+
r(f.detail), window.removeEventListener("payconductor:registered", h);
|
|
428
|
+
};
|
|
429
|
+
window.addEventListener("payconductor:registered", h);
|
|
430
|
+
}
|
|
431
|
+
let g = !1;
|
|
432
|
+
const w = (h) => {
|
|
433
|
+
var f, u, E, p;
|
|
434
|
+
if (((f = h.data) == null ? void 0 : f.type) === P.RESIZE && ((E = (u = h.data) == null ? void 0 : u.data) != null && E.height) && s(h.data.data.height + "px"), ((p = h.data) == null ? void 0 : p.type) === P.READY && e.height && !g) {
|
|
435
|
+
g = !0;
|
|
436
|
+
const v = document.querySelector(
|
|
437
|
+
".payconductor-element iframe"
|
|
438
|
+
);
|
|
439
|
+
v != null && v.contentWindow && v.contentWindow.postMessage(
|
|
440
|
+
{
|
|
441
|
+
type: P.CONFIG,
|
|
442
|
+
data: {
|
|
443
|
+
height: e.height
|
|
444
|
+
},
|
|
445
|
+
requestId: "element-height"
|
|
446
|
+
},
|
|
447
|
+
"*"
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
return window.addEventListener("message", w), () => window.removeEventListener("message", w);
|
|
452
|
+
}, []), /* @__PURE__ */ W(
|
|
453
|
+
"div",
|
|
454
|
+
{
|
|
455
|
+
className: "payconductor-element",
|
|
456
|
+
style: {
|
|
457
|
+
width: "100%"
|
|
458
|
+
},
|
|
459
|
+
children: [
|
|
460
|
+
i ? null : /* @__PURE__ */ D(
|
|
461
|
+
"div",
|
|
462
|
+
{
|
|
463
|
+
className: "payconductor-skeleton",
|
|
464
|
+
style: {
|
|
465
|
+
height: e.height || z
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
),
|
|
469
|
+
i && t ? /* @__PURE__ */ D(
|
|
470
|
+
"iframe",
|
|
471
|
+
{
|
|
472
|
+
allow: "payment",
|
|
473
|
+
title: "PayConductor",
|
|
474
|
+
ref: n,
|
|
475
|
+
src: t,
|
|
476
|
+
style: {
|
|
477
|
+
width: "100%",
|
|
478
|
+
height: e.height || d || z,
|
|
479
|
+
border: "none"
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
) : null
|
|
483
|
+
]
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
function tt(e) {
|
|
488
|
+
const [n, t] = I(() => !1);
|
|
489
|
+
return K(() => {
|
|
490
|
+
const a = () => {
|
|
491
|
+
t(!0);
|
|
492
|
+
}, i = () => {
|
|
493
|
+
t(!1);
|
|
494
|
+
};
|
|
495
|
+
return window.addEventListener("payconductor:3ds:show", a), window.addEventListener("payconductor:3ds:hide", i), typeof window < "u" && (window.PayConductor3DS = {
|
|
496
|
+
container: () => document.getElementById("payconductor-3ds-container"),
|
|
497
|
+
show: a,
|
|
498
|
+
hide: i
|
|
499
|
+
}, window.dispatchEvent(new CustomEvent("payconductor:3ds:registered"))), () => {
|
|
500
|
+
window.removeEventListener("payconductor:3ds:show", a), window.removeEventListener("payconductor:3ds:hide", i), window.PayConductor3DS = null;
|
|
501
|
+
};
|
|
502
|
+
}, []), /* @__PURE__ */ D(
|
|
503
|
+
"div",
|
|
504
|
+
{
|
|
505
|
+
className: "payconductor-three-ds",
|
|
506
|
+
id: "payconductor-3ds-container",
|
|
507
|
+
style: {
|
|
508
|
+
width: "100%",
|
|
509
|
+
display: n ? "block" : "none",
|
|
510
|
+
minHeight: n ? e.height || "600px" : "0"
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
function nt() {
|
|
516
|
+
const e = typeof window < "u" ? window.PayConductor : null, n = e != null && e.config ? {
|
|
517
|
+
publicKey: e.config.publicKey,
|
|
518
|
+
orderId: e.config.orderId,
|
|
519
|
+
theme: e.config.theme,
|
|
520
|
+
locale: e.config.locale
|
|
521
|
+
} : {}, t = e != null && e.frame ? {
|
|
522
|
+
iframe: e.frame.iframe,
|
|
523
|
+
error: e.frame.error
|
|
524
|
+
} : {
|
|
525
|
+
iframe: null,
|
|
526
|
+
error: null
|
|
527
|
+
};
|
|
528
|
+
return {
|
|
529
|
+
...n,
|
|
530
|
+
...t
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function L(e) {
|
|
534
|
+
var n;
|
|
535
|
+
if ((n = e == null ? void 0 : e.frame) != null && n.iframe) {
|
|
536
|
+
const t = e.frame.iframe;
|
|
537
|
+
if (t instanceof HTMLIFrameElement) return t;
|
|
538
|
+
if (t && typeof t == "object") {
|
|
539
|
+
if ("current" in t) {
|
|
540
|
+
const a = t.current;
|
|
541
|
+
if (a instanceof HTMLIFrameElement) return a;
|
|
542
|
+
}
|
|
543
|
+
if ("value" in t) {
|
|
544
|
+
const a = t.value;
|
|
545
|
+
if (a instanceof HTMLIFrameElement) return a;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return document.querySelector(".payconductor-element iframe") ?? null;
|
|
550
|
+
}
|
|
551
|
+
function at() {
|
|
552
|
+
const e = () => typeof window < "u" ? window.PayConductor : null, n = (t, a) => {
|
|
553
|
+
const i = e();
|
|
554
|
+
if (!i) return;
|
|
555
|
+
const o = L(i);
|
|
556
|
+
o != null && o.contentWindow && o.contentWindow.postMessage({
|
|
557
|
+
type: t,
|
|
558
|
+
data: a
|
|
559
|
+
}, "*");
|
|
560
|
+
};
|
|
561
|
+
return {
|
|
562
|
+
init: async (t) => {
|
|
563
|
+
const a = L(e()), i = F();
|
|
564
|
+
return Se(a || void 0, i, t);
|
|
565
|
+
},
|
|
566
|
+
confirmPayment: async (t) => {
|
|
567
|
+
if (!t.orderId)
|
|
568
|
+
throw new Error("Order ID is required");
|
|
569
|
+
const a = e();
|
|
570
|
+
if (!(a != null && a.api)) throw new Error("PayConductor not initialized");
|
|
571
|
+
return a.api.confirmPayment(t);
|
|
572
|
+
},
|
|
573
|
+
validate: (t) => {
|
|
574
|
+
const a = e();
|
|
575
|
+
return a ? a.api.validate(t) : Promise.resolve(!1);
|
|
576
|
+
},
|
|
577
|
+
reset: () => {
|
|
578
|
+
const t = e();
|
|
579
|
+
return t ? t.api.reset() : Promise.resolve();
|
|
580
|
+
},
|
|
581
|
+
getSelectedPaymentMethod: () => {
|
|
582
|
+
var t;
|
|
583
|
+
return ((t = e()) == null ? void 0 : t.selectedPaymentMethod) ?? null;
|
|
584
|
+
},
|
|
585
|
+
updateConfig: (t) => {
|
|
586
|
+
var i;
|
|
587
|
+
const a = (i = e()) == null ? void 0 : i.config;
|
|
588
|
+
n(P.CONFIG, {
|
|
589
|
+
publicKey: a == null ? void 0 : a.publicKey,
|
|
590
|
+
orderId: a == null ? void 0 : a.orderId,
|
|
591
|
+
theme: t.theme ?? (a == null ? void 0 : a.theme),
|
|
592
|
+
locale: t.locale ?? (a == null ? void 0 : a.locale),
|
|
593
|
+
paymentMethods: t.paymentMethods ?? (a == null ? void 0 : a.paymentMethods)
|
|
594
|
+
});
|
|
595
|
+
},
|
|
596
|
+
updateOrderId: (t) => {
|
|
597
|
+
var i;
|
|
598
|
+
const a = (i = e()) == null ? void 0 : i.config;
|
|
599
|
+
n(P.CONFIG, {
|
|
600
|
+
publicKey: a == null ? void 0 : a.publicKey,
|
|
601
|
+
orderId: t,
|
|
602
|
+
theme: a == null ? void 0 : a.theme,
|
|
603
|
+
locale: a == null ? void 0 : a.locale,
|
|
604
|
+
paymentMethods: a == null ? void 0 : a.paymentMethods
|
|
605
|
+
});
|
|
606
|
+
},
|
|
607
|
+
update: (t) => {
|
|
608
|
+
n(P.UPDATE, t);
|
|
609
|
+
},
|
|
610
|
+
submit: async () => {
|
|
611
|
+
const t = L(e()), a = F();
|
|
612
|
+
try {
|
|
613
|
+
return await _(t || void 0, a, P.CONFIRM_PAYMENT, {}), {
|
|
614
|
+
paymentMethod: void 0
|
|
615
|
+
};
|
|
616
|
+
} catch (i) {
|
|
617
|
+
return {
|
|
618
|
+
error: {
|
|
619
|
+
message: i instanceof Error ? i.message : "Payment failed",
|
|
620
|
+
code: "payment_error",
|
|
621
|
+
type: "payment_error"
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
var b = /* @__PURE__ */ ((e) => (e.Success = "Success", e.Failed = "Failed", e.Timeout = "Timeout", e))(b || {}), R = /* @__PURE__ */ ((e) => (e.Authenticated = "Y", e.Attempted = "A", e.ChallengeRequired = "C", e.NotAuthenticated = "N", e.Unavailable = "U", e.Rejected = "R", e.InformationOnly = "I", e))(R || {});
|
|
629
|
+
class k {
|
|
630
|
+
constructor(n, t) {
|
|
631
|
+
S(this, "overlay", null);
|
|
632
|
+
S(this, "modalContent", null);
|
|
633
|
+
this.data = n, this.options = t;
|
|
634
|
+
}
|
|
635
|
+
/** Os SDKs de 3DS dos provedores (Pagar.me, PagSeguro) esperam o valor em centavos. */
|
|
636
|
+
get amountInCents() {
|
|
637
|
+
return this.data.amount === void 0 ? void 0 : Math.round(this.data.amount * 100);
|
|
638
|
+
}
|
|
639
|
+
fail(n, t = {}) {
|
|
640
|
+
var i, o;
|
|
641
|
+
const a = new Error(n);
|
|
642
|
+
return (o = (i = this.options).onError) == null || o.call(i, a), {
|
|
643
|
+
...t,
|
|
644
|
+
status: "Failed",
|
|
645
|
+
error: a
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
//#region Modal
|
|
649
|
+
showModal() {
|
|
650
|
+
return this.injectStyles(), this.overlay = document.createElement("div"), this.overlay.id = "payconductor-3ds-overlay", this.modalContent = document.createElement("div"), this.modalContent.id = "payconductor-3ds-modal", this.overlay.appendChild(this.modalContent), document.body.appendChild(this.overlay), this.modalContent;
|
|
651
|
+
}
|
|
652
|
+
closeModal() {
|
|
653
|
+
this.overlay && (this.overlay.remove(), this.overlay = null, this.modalContent = null);
|
|
654
|
+
}
|
|
655
|
+
resolveContainer() {
|
|
656
|
+
return this.modalContent ?? this.showModal();
|
|
657
|
+
}
|
|
658
|
+
injectStyles() {
|
|
659
|
+
if (document.getElementById("payconductor-3ds-styles")) return;
|
|
660
|
+
const n = document.createElement("style");
|
|
661
|
+
n.id = "payconductor-3ds-styles", n.textContent = `
|
|
662
|
+
#payconductor-3ds-overlay {
|
|
663
|
+
position: fixed;
|
|
664
|
+
inset: 0;
|
|
665
|
+
z-index: 99999;
|
|
666
|
+
display: flex;
|
|
667
|
+
align-items: center;
|
|
668
|
+
justify-content: center;
|
|
669
|
+
background: rgba(0, 0, 0, 0.6);
|
|
670
|
+
}
|
|
671
|
+
#payconductor-3ds-modal {
|
|
672
|
+
width: 500px;
|
|
673
|
+
max-width: 95vw;
|
|
674
|
+
min-height: 600px;
|
|
675
|
+
border-radius: 8px;
|
|
676
|
+
overflow: hidden;
|
|
677
|
+
background: #fff;
|
|
678
|
+
}
|
|
679
|
+
#payconductor-3ds-modal iframe {
|
|
680
|
+
width: 100%;
|
|
681
|
+
height: 600px;
|
|
682
|
+
border: none;
|
|
683
|
+
display: block;
|
|
684
|
+
}
|
|
685
|
+
@media only screen and (max-width: 600px) {
|
|
686
|
+
#payconductor-3ds-modal {
|
|
687
|
+
width: 100vw;
|
|
688
|
+
max-width: 100vw;
|
|
689
|
+
min-height: 440px;
|
|
690
|
+
border-radius: 0;
|
|
691
|
+
}
|
|
692
|
+
#payconductor-3ds-modal iframe {
|
|
693
|
+
height: 440px;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
`, document.head.appendChild(n);
|
|
697
|
+
}
|
|
698
|
+
//#endregion
|
|
699
|
+
}
|
|
700
|
+
const Ae = 5 * 60 * 1e3;
|
|
701
|
+
class Ie extends k {
|
|
702
|
+
constructor() {
|
|
703
|
+
super(...arguments);
|
|
704
|
+
S(this, "iframe", null);
|
|
705
|
+
S(this, "messageListener", null);
|
|
706
|
+
S(this, "timeoutId", null);
|
|
707
|
+
}
|
|
708
|
+
async authenticate() {
|
|
709
|
+
const {
|
|
710
|
+
threeDsUrl: t,
|
|
711
|
+
creq: a
|
|
712
|
+
} = this.data;
|
|
713
|
+
if (!t || !a)
|
|
714
|
+
return this.fail("Missing threeDsUrl or creq");
|
|
715
|
+
const i = this.resolveContainer();
|
|
716
|
+
return new Promise((o) => {
|
|
717
|
+
var c;
|
|
718
|
+
this.iframe = document.createElement("iframe"), this.iframe.name = "payconductor-3ds-challenge", this.iframe.id = "payconductor-3ds-challenge", i.appendChild(this.iframe), this.messageListener = (g) => {
|
|
719
|
+
var w, h, f;
|
|
720
|
+
((w = g.data) == null ? void 0 : w.status) === "COMPLETE" && (this.cleanup(), (f = (h = this.options).onComplete) == null || f.call(h), o({
|
|
721
|
+
status: b.Success
|
|
722
|
+
}));
|
|
723
|
+
}, window.addEventListener("message", this.messageListener), this.timeoutId = setTimeout(() => {
|
|
724
|
+
var g, w;
|
|
725
|
+
this.cleanup(), (w = (g = this.options).onTimeout) == null || w.call(g), o({
|
|
726
|
+
status: b.Timeout
|
|
727
|
+
});
|
|
728
|
+
}, this.options.timeoutMs ?? Ae);
|
|
729
|
+
const d = (c = this.iframe.contentWindow) == null ? void 0 : c.document;
|
|
730
|
+
if (!d) {
|
|
731
|
+
this.cleanup(), o(this.fail("Cannot access iframe document"));
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
const s = d.createElement("form");
|
|
735
|
+
s.name = "threeDsChallengeForm", s.setAttribute("target", "payconductor-3ds-challenge"), s.setAttribute("method", "post"), s.setAttribute("action", t);
|
|
736
|
+
const r = d.createElement("input");
|
|
737
|
+
r.setAttribute("type", "hidden"), r.setAttribute("name", "creq"), r.setAttribute("value", a), s.appendChild(r), this.iframe.appendChild(s), s.submit();
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
cleanup() {
|
|
741
|
+
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null), this.messageListener && (window.removeEventListener("message", this.messageListener), this.messageListener = null), this.iframe && (this.iframe.remove(), this.iframe = null), this.closeModal();
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
const O = /* @__PURE__ */ new Map();
|
|
745
|
+
function x(e) {
|
|
746
|
+
const n = O.get(e);
|
|
747
|
+
if (n) return n;
|
|
748
|
+
const t = new Promise((a, i) => {
|
|
749
|
+
if (document.querySelector(`script[src="${e}"]`)) {
|
|
750
|
+
a();
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
const o = document.createElement("script");
|
|
754
|
+
o.src = e, o.async = !0, o.onload = () => a(), o.onerror = () => {
|
|
755
|
+
O.delete(e), i(new Error(`Failed to load script: ${e}`));
|
|
756
|
+
}, (document.head || document.body).appendChild(o);
|
|
757
|
+
});
|
|
758
|
+
return O.set(e, t), t;
|
|
759
|
+
}
|
|
760
|
+
const Te = "https://static.payzen.lat/static/js/authenticate-client/V1.0/kr-authenticate.umd.js", Me = 10 * 60 * 1e3;
|
|
761
|
+
class _e extends k {
|
|
762
|
+
constructor() {
|
|
763
|
+
super(...arguments);
|
|
764
|
+
S(this, "timeoutId", null);
|
|
765
|
+
}
|
|
766
|
+
async authenticate() {
|
|
767
|
+
const {
|
|
768
|
+
operationUrl: t,
|
|
769
|
+
publicKey: a
|
|
770
|
+
} = this.data;
|
|
771
|
+
if (!t || !a)
|
|
772
|
+
return this.fail("Missing operationUrl or publicKey");
|
|
773
|
+
try {
|
|
774
|
+
await x(Te);
|
|
775
|
+
} catch {
|
|
776
|
+
return this.fail("Failed to load 3DS SDK");
|
|
777
|
+
}
|
|
778
|
+
const i = window.KrAuthenticate;
|
|
779
|
+
return i ? new Promise((o) => {
|
|
780
|
+
this.timeoutId = setTimeout(() => {
|
|
781
|
+
var s, r;
|
|
782
|
+
this.cleanup(), (r = (s = this.options).onTimeout) == null || r.call(s), o({
|
|
783
|
+
status: b.Timeout
|
|
784
|
+
});
|
|
785
|
+
}, this.options.timeoutMs ?? Me), new i(a).authenticate(t, () => {
|
|
786
|
+
var s, r;
|
|
787
|
+
this.cleanup(), (r = (s = this.options).onComplete) == null || r.call(s), o({
|
|
788
|
+
status: b.Success
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
}) : this.fail("KrAuthenticate not available");
|
|
792
|
+
}
|
|
793
|
+
cleanup() {
|
|
794
|
+
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
const Ne = {
|
|
798
|
+
[N.Production]: "https://3ds-nx-js.stone.com.br/live/v2/3ds2.min.js",
|
|
799
|
+
[N.Sandbox]: "https://3ds-nx-js.stone.com.br/test/v2/3ds2.min.js"
|
|
800
|
+
}, Re = 5 * 60 * 1e3;
|
|
801
|
+
function De() {
|
|
802
|
+
const e = window.innerWidth;
|
|
803
|
+
return e <= 480 ? "01" : e <= 768 ? "02" : e <= 1024 ? "03" : "04";
|
|
804
|
+
}
|
|
805
|
+
class ke extends k {
|
|
806
|
+
constructor() {
|
|
807
|
+
super(...arguments);
|
|
808
|
+
S(this, "timeoutId", null);
|
|
809
|
+
S(this, "methodContainer", null);
|
|
810
|
+
}
|
|
811
|
+
async authenticate() {
|
|
812
|
+
const {
|
|
813
|
+
authToken: t,
|
|
814
|
+
card: a
|
|
815
|
+
} = this.data;
|
|
816
|
+
if (!t) return this.fail("Missing authToken for PagarMe 3DS");
|
|
817
|
+
if (!a) return this.fail("Missing card data for PagarMe 3DS");
|
|
818
|
+
const i = this.data.environment ?? N.Production;
|
|
819
|
+
try {
|
|
820
|
+
await x(Ne[i]);
|
|
821
|
+
} catch {
|
|
822
|
+
return this.fail("Failed to load Stone 3DS SDK");
|
|
823
|
+
}
|
|
824
|
+
const o = window.TDS;
|
|
825
|
+
if (!o) return this.fail("Stone TDS SDK not available");
|
|
826
|
+
const d = this.resolveContainer();
|
|
827
|
+
return this.methodContainer = document.createElement("div"), this.methodContainer.style.display = "none", document.body.appendChild(this.methodContainer), new Promise((s) => {
|
|
828
|
+
this.timeoutId = setTimeout(() => {
|
|
829
|
+
var r, c;
|
|
830
|
+
this.cleanup(), (c = (r = this.options).onTimeout) == null || c.call(r), s({
|
|
831
|
+
status: b.Timeout
|
|
832
|
+
});
|
|
833
|
+
}, this.options.timeoutMs ?? Re), o.init({
|
|
834
|
+
token: t,
|
|
835
|
+
tds_method_container_element: this.methodContainer,
|
|
836
|
+
challenge_container_element: d,
|
|
837
|
+
use_default_challenge_iframe_style: !0,
|
|
838
|
+
challenge_window_size: De()
|
|
839
|
+
}, this.buildOrderData()).then((r) => {
|
|
840
|
+
var h, f;
|
|
841
|
+
if (this.cleanup(), !(r != null && r.length)) {
|
|
842
|
+
s(this.fail("PagarMe 3DS returned no response"));
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const c = r[0], g = Object.values(R).find((u) => u === c.trans_status), w = {
|
|
846
|
+
transStatus: g,
|
|
847
|
+
providerTransactionId: c.tds_server_trans_id,
|
|
848
|
+
challengeCanceled: c.challenge_canceled
|
|
849
|
+
};
|
|
850
|
+
if (c.challenge_canceled) {
|
|
851
|
+
s(this.fail("3DS challenge canceled by user", w));
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
g === R.Authenticated || g === R.Attempted ? ((f = (h = this.options).onComplete) == null || f.call(h), s({
|
|
855
|
+
...w,
|
|
856
|
+
status: b.Success,
|
|
857
|
+
dsTransactionId: c.tds_server_trans_id
|
|
858
|
+
})) : s(this.fail(`3DS failed with status: ${c.trans_status}`, w));
|
|
859
|
+
}).catch((r) => {
|
|
860
|
+
this.cleanup(), s(this.fail(r instanceof Error ? r.message : "PagarMe 3DS failed"));
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
cleanup() {
|
|
865
|
+
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null), this.methodContainer && (this.methodContainer.remove(), this.methodContainer = null), this.closeModal();
|
|
866
|
+
}
|
|
867
|
+
buildOrderData() {
|
|
868
|
+
var o;
|
|
869
|
+
const {
|
|
870
|
+
card: t,
|
|
871
|
+
customer: a,
|
|
872
|
+
billingAddress: i
|
|
873
|
+
} = this.data;
|
|
874
|
+
return {
|
|
875
|
+
payments: [{
|
|
876
|
+
payment_method: "credit_card",
|
|
877
|
+
credit_card: {
|
|
878
|
+
card: {
|
|
879
|
+
number: t == null ? void 0 : t.number,
|
|
880
|
+
holder_name: t == null ? void 0 : t.holderName,
|
|
881
|
+
exp_month: Number(t == null ? void 0 : t.expMonth),
|
|
882
|
+
exp_year: Number(t == null ? void 0 : t.expYear),
|
|
883
|
+
billing_address: i ? {
|
|
884
|
+
country: i.country,
|
|
885
|
+
state: i.state,
|
|
886
|
+
city: i.city,
|
|
887
|
+
zip_code: i.zipCode,
|
|
888
|
+
line_1: `${i.number}, ${i.street}${i.district ? `, ${i.district}` : ""}`,
|
|
889
|
+
line_2: i.complement ?? ""
|
|
890
|
+
} : void 0
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
amount: this.amountInCents
|
|
894
|
+
}],
|
|
895
|
+
...a ? {
|
|
896
|
+
customer: {
|
|
897
|
+
name: a.name,
|
|
898
|
+
email: a.email,
|
|
899
|
+
...a.document ? {
|
|
900
|
+
document: a.document
|
|
901
|
+
} : {},
|
|
902
|
+
...(o = a.phones) != null && o.length ? {
|
|
903
|
+
phones: Object.fromEntries(a.phones.map((d) => [d.type === "HOME" ? "home_phone" : "mobile_phone", {
|
|
904
|
+
country_code: d.countryCode,
|
|
905
|
+
area_code: d.areaCode,
|
|
906
|
+
number: d.number
|
|
907
|
+
}]))
|
|
908
|
+
} : {}
|
|
909
|
+
}
|
|
910
|
+
} : {}
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
const xe = "https://assets.pagseguro.com.br/checkout-sdk-js/rc/dist/browser/pagseguro.min.js";
|
|
915
|
+
class Ue extends k {
|
|
916
|
+
async authenticate() {
|
|
917
|
+
var w, h, f;
|
|
918
|
+
const {
|
|
919
|
+
authToken: n,
|
|
920
|
+
card: t,
|
|
921
|
+
customer: a,
|
|
922
|
+
currency: i,
|
|
923
|
+
billingAddress: o
|
|
924
|
+
} = this.data, d = this.amountInCents;
|
|
925
|
+
if (!n) return this.fail("Missing authToken (session) for PagSeguro 3DS");
|
|
926
|
+
if (!t) return this.fail("Missing card data for PagSeguro 3DS");
|
|
927
|
+
if (!a) return this.fail("Missing customer data for PagSeguro 3DS");
|
|
928
|
+
if (!d) return this.fail("Missing amount for PagSeguro 3DS");
|
|
929
|
+
if (!o) return this.fail("Missing billingAddress for PagSeguro 3DS");
|
|
930
|
+
const s = this.data.environment === N.Sandbox ? "SANDBOX" : "PROD";
|
|
931
|
+
try {
|
|
932
|
+
await x(xe);
|
|
933
|
+
} catch {
|
|
934
|
+
return this.fail("Failed to load PagSeguro SDK");
|
|
935
|
+
}
|
|
936
|
+
const r = window.PagSeguro;
|
|
937
|
+
if (!r) return this.fail("PagSeguro SDK not available");
|
|
938
|
+
r.setUp({
|
|
939
|
+
session: n,
|
|
940
|
+
env: s
|
|
941
|
+
});
|
|
942
|
+
const c = ((w = a.phones) == null ? void 0 : w.map((u) => ({
|
|
943
|
+
country: u.countryCode,
|
|
944
|
+
area: u.areaCode,
|
|
945
|
+
number: u.number,
|
|
946
|
+
type: u.type ?? "MOBILE"
|
|
947
|
+
}))) ?? [{
|
|
948
|
+
country: "55",
|
|
949
|
+
area: "11",
|
|
950
|
+
number: "999999999",
|
|
951
|
+
type: "MOBILE"
|
|
952
|
+
}];
|
|
953
|
+
c.some((u) => u.type === "MOBILE") || (c[0].type = "MOBILE");
|
|
954
|
+
try {
|
|
955
|
+
const u = await r.authenticate3DS({
|
|
956
|
+
data: {
|
|
957
|
+
customer: {
|
|
958
|
+
name: a.name,
|
|
959
|
+
email: a.email,
|
|
960
|
+
phones: c
|
|
961
|
+
},
|
|
962
|
+
paymentMethod: {
|
|
963
|
+
type: this.data.installments === 0 ? "DEBIT_CARD" : "CREDIT_CARD",
|
|
964
|
+
installments: this.data.installments ?? 1,
|
|
965
|
+
card: {
|
|
966
|
+
number: t.number,
|
|
967
|
+
expMonth: t.expMonth,
|
|
968
|
+
expYear: t.expYear,
|
|
969
|
+
holder: {
|
|
970
|
+
name: t.holderName
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
amount: {
|
|
975
|
+
value: d,
|
|
976
|
+
currency: i ?? "BRL"
|
|
977
|
+
},
|
|
978
|
+
billingAddress: {
|
|
979
|
+
street: o.street,
|
|
980
|
+
number: o.number,
|
|
981
|
+
complement: o.complement,
|
|
982
|
+
regionCode: o.state,
|
|
983
|
+
country: o.country.length === 2 ? this.toAlpha3(o.country) : o.country,
|
|
984
|
+
city: o.city,
|
|
985
|
+
postalCode: o.zipCode.replace(/\D/g, "")
|
|
986
|
+
},
|
|
987
|
+
dataOnly: !1
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
return u.status === "AUTH_FLOW_COMPLETED" || u.status === "AUTH_NOT_SUPPORTED" ? ((f = (h = this.options).onComplete) == null || f.call(h), {
|
|
991
|
+
status: b.Success,
|
|
992
|
+
dsTransactionId: u.id
|
|
993
|
+
}) : u.status === "CHANGE_PAYMENT_METHOD" ? this.fail("PagSeguro requires a different payment method") : {
|
|
994
|
+
status: b.Success,
|
|
995
|
+
dsTransactionId: u.id
|
|
996
|
+
};
|
|
997
|
+
} catch (u) {
|
|
998
|
+
return this.fail(u instanceof Error ? u.message : "PagSeguro 3DS failed");
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
cleanup() {
|
|
1002
|
+
}
|
|
1003
|
+
toAlpha3(n) {
|
|
1004
|
+
return {
|
|
1005
|
+
BR: "BRA",
|
|
1006
|
+
US: "USA",
|
|
1007
|
+
AR: "ARG",
|
|
1008
|
+
CL: "CHL",
|
|
1009
|
+
CO: "COL",
|
|
1010
|
+
MX: "MEX",
|
|
1011
|
+
PE: "PER",
|
|
1012
|
+
UY: "URY"
|
|
1013
|
+
}[n.toUpperCase()] ?? n;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
const Le = {
|
|
1017
|
+
// Agnostic providers
|
|
1018
|
+
[M.Lyra]: _e,
|
|
1019
|
+
// Acquirer-specific providers
|
|
1020
|
+
[M.MercadoPago]: Ie,
|
|
1021
|
+
[M.PagarMe]: ke,
|
|
1022
|
+
[M.PagSeguro]: Ue
|
|
1023
|
+
};
|
|
1024
|
+
class Oe extends Error {
|
|
1025
|
+
constructor(n, t) {
|
|
1026
|
+
super(n), this.title = t, this.name = "PayConductorThreeDSApiError";
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
class Fe {
|
|
1030
|
+
constructor(n) {
|
|
1031
|
+
this.publicKey = n;
|
|
1032
|
+
}
|
|
1033
|
+
async completeManualChallenge(n, t) {
|
|
1034
|
+
const a = await fetch(`${this.baseUrl}/three-ds/complete/${n}`, {
|
|
1035
|
+
method: "POST",
|
|
1036
|
+
headers: this.headers,
|
|
1037
|
+
body: JSON.stringify({
|
|
1038
|
+
providerTransactionId: t
|
|
1039
|
+
})
|
|
1040
|
+
});
|
|
1041
|
+
a.ok || await this.parseResponseError("Failed to complete native 3DS challenge", a);
|
|
1042
|
+
}
|
|
1043
|
+
async parseResponseError(n, t) {
|
|
1044
|
+
var i, o, d, s;
|
|
1045
|
+
let a = "";
|
|
1046
|
+
try {
|
|
1047
|
+
const r = await t.json();
|
|
1048
|
+
r != null && r.message ? a = r.message : (i = r == null ? void 0 : r.error) != null && i.message ? a = r.error : (d = (o = r == null ? void 0 : r.error) == null ? void 0 : o.value) != null && d.message ? a = r.error.value.message : (s = r == null ? void 0 : r.value) != null && s.message ? a = r.value.message : a = JSON.stringify(r);
|
|
1049
|
+
} catch {
|
|
1050
|
+
}
|
|
1051
|
+
throw new Oe(a, n);
|
|
1052
|
+
}
|
|
1053
|
+
get baseUrl() {
|
|
1054
|
+
return typeof window < "u" && window.location.href.includes("localhost") ? "http://localhost:3000/api/v1/sdk" : "https://payconductor.ai/api/v1/sdk";
|
|
1055
|
+
}
|
|
1056
|
+
get headers() {
|
|
1057
|
+
return {
|
|
1058
|
+
Authorization: `Basic ${btoa(`${this.publicKey}:x`)}`,
|
|
1059
|
+
"Content-Type": "application/json"
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
const Ke = [M.PagSeguro];
|
|
1064
|
+
class Be {
|
|
1065
|
+
constructor(n) {
|
|
1066
|
+
S(this, "data");
|
|
1067
|
+
S(this, "provider", null);
|
|
1068
|
+
this.data = n;
|
|
1069
|
+
}
|
|
1070
|
+
get needsChallenge() {
|
|
1071
|
+
return this.data.status === "NeedChallenge" || this.data.statusDetail === "ThreeDsAwaitingChallenge";
|
|
1072
|
+
}
|
|
1073
|
+
get acquirer() {
|
|
1074
|
+
return this.data.acquirer;
|
|
1075
|
+
}
|
|
1076
|
+
async authenticate(n) {
|
|
1077
|
+
if (!this.needsChallenge)
|
|
1078
|
+
return {
|
|
1079
|
+
status: b.Success
|
|
1080
|
+
};
|
|
1081
|
+
const {
|
|
1082
|
+
acquirer: t
|
|
1083
|
+
} = this.data;
|
|
1084
|
+
if (!t)
|
|
1085
|
+
return {
|
|
1086
|
+
status: b.Failed,
|
|
1087
|
+
error: new Error("Missing 3DS acquirer")
|
|
1088
|
+
};
|
|
1089
|
+
const a = Le[t];
|
|
1090
|
+
if (!a)
|
|
1091
|
+
return {
|
|
1092
|
+
status: b.Failed,
|
|
1093
|
+
error: new Error(`Unsupported 3DS provider: ${t}`)
|
|
1094
|
+
};
|
|
1095
|
+
const i = {
|
|
1096
|
+
...n,
|
|
1097
|
+
threeDSecure: this.data
|
|
1098
|
+
};
|
|
1099
|
+
this.provider = new a(this.data, i);
|
|
1100
|
+
const o = await this.provider.authenticate();
|
|
1101
|
+
return o.status === b.Success && o.dsTransactionId && Ke.includes(t) && this.data.orderId && this.data.publicKey && await new Fe(this.data.publicKey).completeManualChallenge(this.data.orderId, o.dsTransactionId), o;
|
|
1102
|
+
}
|
|
1103
|
+
destroy() {
|
|
1104
|
+
this.provider && (this.provider.cleanup(), this.provider = null);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function it(e) {
|
|
1108
|
+
let n = null;
|
|
1109
|
+
return {
|
|
1110
|
+
handleChallenge: async (i) => {
|
|
1111
|
+
var s;
|
|
1112
|
+
if (!(i.status === "NeedChallenge" || i.statusDetail === "ThreeDsAwaitingChallenge"))
|
|
1113
|
+
return {
|
|
1114
|
+
status: b.Success
|
|
1115
|
+
};
|
|
1116
|
+
(s = e == null ? void 0 : e.onChallenge) == null || s.call(e), n = new Be(i);
|
|
1117
|
+
const d = await n.authenticate({
|
|
1118
|
+
onComplete: e == null ? void 0 : e.onComplete,
|
|
1119
|
+
onError: e == null ? void 0 : e.onError,
|
|
1120
|
+
onTimeout: e == null ? void 0 : e.onTimeout
|
|
1121
|
+
});
|
|
1122
|
+
return n.destroy(), n = null, d;
|
|
1123
|
+
},
|
|
1124
|
+
destroy: () => {
|
|
1125
|
+
n == null || n.destroy(), n = null;
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
class ze extends Error {
|
|
1130
|
+
constructor(n, t) {
|
|
1131
|
+
super(n), this.title = t, this.name = "PayConductorTokenizerApiError";
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
class He {
|
|
1135
|
+
constructor(n) {
|
|
1136
|
+
this.publicKey = n;
|
|
1137
|
+
}
|
|
1138
|
+
async getSettings() {
|
|
1139
|
+
const n = await fetch(`${this.baseUrl}/card-tokenization/settings`, {
|
|
1140
|
+
method: "GET",
|
|
1141
|
+
headers: this.headers
|
|
1142
|
+
});
|
|
1143
|
+
return n.ok || await this.parseResponseError("Failed to fetch settings", n), await n.json();
|
|
1144
|
+
}
|
|
1145
|
+
async createToken(n) {
|
|
1146
|
+
const t = await fetch(`${this.baseUrl}/card-tokenization/tokenize`, {
|
|
1147
|
+
method: "POST",
|
|
1148
|
+
headers: this.headers,
|
|
1149
|
+
body: JSON.stringify(n)
|
|
1150
|
+
});
|
|
1151
|
+
return t.ok || await this.parseResponseError("Failed to generate token", t), await t.json();
|
|
1152
|
+
}
|
|
1153
|
+
async saveTokens(n, t, a) {
|
|
1154
|
+
const i = await fetch(`${this.baseUrl}/card-tokenization/save-tokens/${t}/${a}`, {
|
|
1155
|
+
method: "POST",
|
|
1156
|
+
headers: this.headers,
|
|
1157
|
+
body: JSON.stringify(n)
|
|
1158
|
+
});
|
|
1159
|
+
i.ok || await this.parseResponseError("Failed to save tokens", i);
|
|
1160
|
+
}
|
|
1161
|
+
async parseResponseError(n, t) {
|
|
1162
|
+
var i, o, d, s;
|
|
1163
|
+
let a = "";
|
|
1164
|
+
try {
|
|
1165
|
+
const r = await t.json();
|
|
1166
|
+
r != null && r.message ? a = r.message : (i = r == null ? void 0 : r.error) != null && i.message ? a = r.error : (d = (o = r == null ? void 0 : r.error) == null ? void 0 : o.value) != null && d.message ? a = r.error.value.message : (s = r == null ? void 0 : r.value) != null && s.message ? a = r.value.message : a = JSON.stringify(r);
|
|
1167
|
+
} catch {
|
|
1168
|
+
}
|
|
1169
|
+
throw new ze(a, n);
|
|
1170
|
+
}
|
|
1171
|
+
get baseUrl() {
|
|
1172
|
+
return typeof window < "u" && window.location.href.includes("localhost") ? "http://localhost:3000/api/v1/sdk" : "https://payconductor.ai/api/v1/sdk";
|
|
1173
|
+
}
|
|
1174
|
+
get headers() {
|
|
1175
|
+
return {
|
|
1176
|
+
Authorization: `Basic ${btoa(`${this.publicKey}:x`)}`,
|
|
1177
|
+
"Content-Type": "application/json"
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
class Ye {
|
|
1182
|
+
constructor(n) {
|
|
1183
|
+
this.input = n;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
class je extends Ye {
|
|
1187
|
+
constructor() {
|
|
1188
|
+
super(...arguments);
|
|
1189
|
+
S(this, "scriptUrl", "https://sdk.mercadopago.com/js/v2");
|
|
1190
|
+
}
|
|
1191
|
+
async tokenize() {
|
|
1192
|
+
if (!("publicKey" in this.input.setting))
|
|
1193
|
+
throw new Error("MercadoPago public key is missing in settings");
|
|
1194
|
+
if (!this.input.customer.documentNumber)
|
|
1195
|
+
throw new Error("Customer document number is required for tokenization");
|
|
1196
|
+
const t = window.MercadoPago;
|
|
1197
|
+
if (!t) throw new Error("MercadoPago SDK not available");
|
|
1198
|
+
const a = new t(this.input.setting.publicKey), {
|
|
1199
|
+
expiration: i,
|
|
1200
|
+
cvv: o,
|
|
1201
|
+
number: d,
|
|
1202
|
+
holderName: s
|
|
1203
|
+
} = this.input.card;
|
|
1204
|
+
return (await a.createCardToken({
|
|
1205
|
+
cardExpirationMonth: String(i.month),
|
|
1206
|
+
cardExpirationYear: String(i.year),
|
|
1207
|
+
cardholderName: s,
|
|
1208
|
+
cardNumber: d,
|
|
1209
|
+
securityCode: o,
|
|
1210
|
+
identificationType: this.input.customer.documentType === G.Cpf ? "CPF" : "CNPJ",
|
|
1211
|
+
identificationNumber: this.input.customer.documentNumber
|
|
1212
|
+
})).id;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
const Ge = {
|
|
1216
|
+
[M.MercadoPago]: je
|
|
1217
|
+
};
|
|
1218
|
+
class Ve {
|
|
1219
|
+
constructor(n) {
|
|
1220
|
+
S(this, "api");
|
|
1221
|
+
this.publicKey = n, this.api = new He(this.publicKey);
|
|
1222
|
+
}
|
|
1223
|
+
async tokenizeCard(n) {
|
|
1224
|
+
this.validateCard(n);
|
|
1225
|
+
const {
|
|
1226
|
+
customerId: t,
|
|
1227
|
+
token: a
|
|
1228
|
+
} = await this.api.createToken({
|
|
1229
|
+
card: n.card,
|
|
1230
|
+
customer: n.customer,
|
|
1231
|
+
saveCard: !1
|
|
1232
|
+
}), {
|
|
1233
|
+
settings: i
|
|
1234
|
+
} = await this.api.getSettings(), d = (await Promise.all(i.map(async (s) => {
|
|
1235
|
+
const r = Ge[s.key];
|
|
1236
|
+
if (!r) return null;
|
|
1237
|
+
const c = new r({
|
|
1238
|
+
...n,
|
|
1239
|
+
setting: s.settings
|
|
1240
|
+
});
|
|
1241
|
+
return await x(c.scriptUrl), {
|
|
1242
|
+
token: await c.tokenize(),
|
|
1243
|
+
integrationId: s.integrationId,
|
|
1244
|
+
providerKey: s.key
|
|
1245
|
+
};
|
|
1246
|
+
}))).filter((s) => s !== null);
|
|
1247
|
+
return d.length > 0 && await this.api.saveTokens(d, t, a), a;
|
|
1248
|
+
}
|
|
1249
|
+
validateCard(n) {
|
|
1250
|
+
const {
|
|
1251
|
+
number: t,
|
|
1252
|
+
cvv: a,
|
|
1253
|
+
expiration: i,
|
|
1254
|
+
holderName: o
|
|
1255
|
+
} = n.card;
|
|
1256
|
+
if (!t || !a || !(i != null && i.month) || !(i != null && i.year) || !o)
|
|
1257
|
+
throw new Error("Invalid card data");
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
function rt(e) {
|
|
1261
|
+
const n = new Ve(e.publicKey);
|
|
1262
|
+
return {
|
|
1263
|
+
tokenizeCard: async (a) => {
|
|
1264
|
+
var i, o;
|
|
1265
|
+
try {
|
|
1266
|
+
const d = await n.tokenizeCard(a);
|
|
1267
|
+
return (i = e.onSuccess) == null || i.call(e, d), d;
|
|
1268
|
+
} catch (d) {
|
|
1269
|
+
const s = d instanceof Error ? d : new Error("Tokenization failed");
|
|
1270
|
+
return (o = e.onError) == null || o.call(e, s), null;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
export {
|
|
1276
|
+
me as ALLOWED_ORIGINS,
|
|
1277
|
+
re as CardBrand,
|
|
1278
|
+
ne as ChargeStatusDetail,
|
|
1279
|
+
oe as CurrencyType,
|
|
1280
|
+
se as DeviceType,
|
|
1281
|
+
G as DocumentType,
|
|
1282
|
+
Ze as ERROR_CODES,
|
|
1283
|
+
ce as ErrorCode,
|
|
1284
|
+
ue as IFRAME_BASE_URL,
|
|
1285
|
+
z as IFRAME_DEFAULT_HEIGHT_VALUE,
|
|
1286
|
+
A as IncomingMessage,
|
|
1287
|
+
de as InputStyleKey,
|
|
1288
|
+
M as IntegrationProvider,
|
|
1289
|
+
N as OrganizationEnvironment,
|
|
1290
|
+
T as OutgoingMessage,
|
|
1291
|
+
P as POST_MESSAGES,
|
|
1292
|
+
Qe as PayConductor,
|
|
1293
|
+
Be as PayConductor3DSSDK,
|
|
1294
|
+
et as PayConductorCheckoutElement,
|
|
1295
|
+
tt as PayConductorThreeDSElement,
|
|
1296
|
+
Ve as PayConductorTokenizerSDK,
|
|
1297
|
+
Q as PaymentMethod,
|
|
1298
|
+
ee as PaymentMethodLayout,
|
|
1299
|
+
te as PaymentStatus,
|
|
1300
|
+
he as REQUEST_TIMEOUT,
|
|
1301
|
+
fe as SKELETON_CSS,
|
|
1302
|
+
H as SKELETON_STYLE_ID,
|
|
1303
|
+
ie as ThreeDSResultStatus,
|
|
1304
|
+
R as ThreeDSTransStatus,
|
|
1305
|
+
b as ThreeDSecureResultStatus,
|
|
1306
|
+
ae as ThreeDsAuthenticationStatus,
|
|
1307
|
+
ye as buildIframeUrl,
|
|
1308
|
+
Qe as default,
|
|
1309
|
+
Xe as defaultTheme,
|
|
1310
|
+
we as generateRequestId,
|
|
1311
|
+
Ee as isValidOrigin,
|
|
1312
|
+
x as loadScript,
|
|
1313
|
+
nt as usePayConductor,
|
|
1314
|
+
at as usePayconductorElement,
|
|
1315
|
+
it as useThreeDS,
|
|
1316
|
+
rt as useTokenizer
|
|
1317
|
+
};
|
|
1318
|
+
//# sourceMappingURL=index.es.js.map
|