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