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