@payconductor/react 1.2.6 → 1.3.0
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 +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +618 -487
- package/dist/index.es.js.map +1 -1
- package/dist/payconductor/hooks/use-three-ds.d.ts +6 -3
- package/dist/payconductor/three-ds/api.d.ts +14 -2
- package/dist/payconductor/three-ds/handler.d.ts +26 -0
- package/dist/payconductor/three-ds/index.d.ts +2 -2
- package/dist/payconductor/three-ds/types.d.ts +56 -15
- 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 I, useEffect as
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
const
|
|
1
|
+
var te = Object.defineProperty;
|
|
2
|
+
var ae = (e, a, t) => a in e ? te(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
|
+
var P = (e, a, t) => ae(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { jsx as O, jsxs as ne } from "react/jsx-runtime";
|
|
5
|
+
import { useState as I, useEffect as K, useRef as re } from "react";
|
|
6
|
+
const ie = "https://app.payconductor.ai", oe = "http://localhost:3000", W = "https://iframe.payconductor.ai/v1", J = "http://localhost:5175/v1", se = 3e5, de = "600px";
|
|
7
|
+
var ce = /* @__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))(ce || {}), le = /* @__PURE__ */ ((e) => (e.Grid = "grid", e.Vertical = "vertical", e.Horizontal = "horizontal", e))(le || {}), R = /* @__PURE__ */ ((e) => (e.Succeeded = "succeeded", e.Pending = "pending", e.Failed = "failed", e))(R || {}), j = /* @__PURE__ */ ((e) => (e.ThreeDsAwaitingChallenge = "ThreeDsAwaitingChallenge", e))(j || {}), ue = /* @__PURE__ */ ((e) => (e.Authenticated = "Authenticated", e.NotAuthenticated = "NotAuthenticated", e.NeedChallenge = "NeedChallenge", e))(ue || {}), he = /* @__PURE__ */ ((e) => (e.Pending = "Pending", e.Authenticated = "Authenticated", e.Failed = "Failed", e.NotEnrolled = "NotEnrolled", e))(he || {}), X = /* @__PURE__ */ ((e) => (e.Cpf = "Cpf", e.Cnpj = "Cnpj", e))(X || {}), T = /* @__PURE__ */ ((e) => (e.Asaas = "Asaas", e.Sandbox = "Sandbox", e.SandboxSplit = "SandboxSplit", e.MercadoPago = "MercadoPago", e.NuPay = "NuPay", e.PicPay = "PicPay", e.Woovi = "Woovi", e.EfiBank = "EfiBank", e.BrasPag = "BrasPag", e.PagarMe = "PagarMe", e.BancoDoBrasil = "BancoDoBrasil", e.PagSeguro = "PagSeguro", e.Ebanx = "Ebanx", e.OnlyUp = "OnlyUp", e.Barte = "Barte", e.BarteSplit = "BarteSplit", e.PagSmileA55 = "PagSmileA55", e.Avantti = "Avantti", e.MonsterGateway = "MonsterGateway", e.SAC = "SAC", e.Lyra = "Lyra", e))(T || {}), me = /* @__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))(me || {}), k = /* @__PURE__ */ ((e) => (e.Production = "Production", e.Sandbox = "Sandbox", e))(k || {}), fe = /* @__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))(fe || {}), ye = /* @__PURE__ */ ((e) => (e.Android = "android", e.IOS = "ios", e.Web = "web", e.Chrome = "chrome", e.Safari = "safari", e))(ye || {}), ge = /* @__PURE__ */ ((e) => (e.Padding = "padding", e.Radius = "radius", e.Color = "color", e.Background = "background", e.Shadow = "shadow", e))(ge || {}), D = /* @__PURE__ */ ((e) => (e.Init = "Init", e.Config = "Config", e.Update = "Update", e.ConfirmPayment = "ConfirmPayment", e.Validate = "Validate", e.Reset = "Reset", e))(D || {}), v = /* @__PURE__ */ ((e) => (e.Ready = "Ready", e.Error = "Error", e.CheckoutSessionCreated = "CheckoutSessionCreated", e.PaymentComplete = "PaymentComplete", e.PaymentFailed = "PaymentFailed", e.PaymentPending = "PaymentPending", e.ValidationError = "ValidationError", e.PaymentMethodSelected = "PaymentMethodSelected", e.Resize = "Resize", e.ThreeDSChallenge = "ThreeDSChallenge", e.ThreeDSComplete = "ThreeDSComplete", e.ThreeDSFailed = "ThreeDSFailed", e))(v || {}), Ee = /* @__PURE__ */ ((e) => (e.InvalidClient = "InvalidClient", e.InvalidToken = "InvalidToken", e.NetworkError = "NetworkError", e.IframeNotReady = "IframeNotReady", e.PaymentDeclined = "PaymentDeclined", e.ValidationError = "ValidationError", e.Timeout = "Timeout", e))(Ee || {});
|
|
8
|
+
const ot = {
|
|
9
9
|
primaryColor: "#0066ff",
|
|
10
10
|
secondaryColor: "#5a6b7c",
|
|
11
11
|
backgroundColor: "transparent",
|
|
@@ -52,22 +52,22 @@ const at = {
|
|
|
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
|
+
}, Z = window.location.search.includes("development"), we = Z ? J : W, M = `${Z ? oe : ie}/api/v1/sdk`, Se = [J, W], G = de, be = se, w = {
|
|
56
|
+
INIT: D.Init,
|
|
57
|
+
CONFIG: D.Config,
|
|
58
|
+
UPDATE: D.Update,
|
|
59
|
+
CONFIRM_PAYMENT: D.ConfirmPayment,
|
|
60
|
+
VALIDATE: D.Validate,
|
|
61
|
+
RESET: D.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
|
+
}, st = {
|
|
71
71
|
INVALID_CLIENT: "InvalidClient",
|
|
72
72
|
INVALID_TOKEN: "InvalidToken",
|
|
73
73
|
NETWORK_ERROR: "NetworkError",
|
|
@@ -75,7 +75,7 @@ const at = {
|
|
|
75
75
|
PAYMENT_DECLINED: "PaymentDeclined",
|
|
76
76
|
VALIDATION_ERROR: "ValidationError",
|
|
77
77
|
TIMEOUT: "Timeout"
|
|
78
|
-
},
|
|
78
|
+
}, Y = "payconductor-skeleton-style", Pe = `
|
|
79
79
|
@keyframes payconductor-shimmer {
|
|
80
80
|
0% { background-position: -200% 0; }
|
|
81
81
|
100% { background-position: 200% 0; }
|
|
@@ -88,16 +88,16 @@ const at = {
|
|
|
88
88
|
width: 100%;
|
|
89
89
|
}
|
|
90
90
|
`;
|
|
91
|
-
function
|
|
91
|
+
function Ce(e) {
|
|
92
92
|
const a = new URLSearchParams({
|
|
93
93
|
publicKey: e.publicKey
|
|
94
94
|
});
|
|
95
|
-
return `${
|
|
95
|
+
return `${we}?${a.toString()}`;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function pe() {
|
|
98
98
|
return crypto.randomUUID();
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function Ae(e, a) {
|
|
101
101
|
return a.some((t) => {
|
|
102
102
|
try {
|
|
103
103
|
return new URL(t).origin === e;
|
|
@@ -106,151 +106,151 @@ function Se(e, a) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function z() {
|
|
110
110
|
return /* @__PURE__ */ new Map();
|
|
111
111
|
}
|
|
112
112
|
function x(e, a, t, n) {
|
|
113
|
-
return new Promise((
|
|
113
|
+
return new Promise((r, i) => {
|
|
114
114
|
if (!e || !("contentWindow" in e)) {
|
|
115
|
-
|
|
115
|
+
i(new Error("Iframe not defined"));
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
if (!(e != null && e.contentWindow)) {
|
|
119
|
-
|
|
119
|
+
i(new Error("Iframe not ready"));
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
if (!a) {
|
|
123
|
-
|
|
123
|
+
i(new Error("Pending requests not initialized"));
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
const s =
|
|
126
|
+
const s = pe();
|
|
127
127
|
a.set(s, {
|
|
128
|
-
resolve:
|
|
129
|
-
reject:
|
|
128
|
+
resolve: r,
|
|
129
|
+
reject: i
|
|
130
130
|
}), e.contentWindow.postMessage({
|
|
131
131
|
type: t,
|
|
132
132
|
data: n,
|
|
133
133
|
requestId: s
|
|
134
134
|
}, "*"), setTimeout(() => {
|
|
135
|
-
a != null && a.has(s) && (a.delete(s),
|
|
136
|
-
},
|
|
135
|
+
a != null && a.has(s) && (a.delete(s), i(new Error("Request timeout")));
|
|
136
|
+
}, be);
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
return x(e, a,
|
|
139
|
+
function ve(e, a, t) {
|
|
140
|
+
return x(e, a, w.CONFIRM_PAYMENT, t);
|
|
141
141
|
}
|
|
142
|
-
async function
|
|
143
|
-
return await
|
|
142
|
+
async function Te(e, a, t) {
|
|
143
|
+
return await ve(e, a, {
|
|
144
144
|
orderId: t.orderId
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function Te(e, a, t) {
|
|
148
|
-
return x(e, a, p.VALIDATE, t);
|
|
149
|
-
}
|
|
150
|
-
function ve(e, a) {
|
|
151
|
-
return x(e, a, p.RESET);
|
|
152
|
-
}
|
|
153
147
|
function Ie(e, a, t) {
|
|
154
|
-
return x(e, a,
|
|
148
|
+
return x(e, a, w.VALIDATE, t);
|
|
149
|
+
}
|
|
150
|
+
function De(e, a) {
|
|
151
|
+
return x(e, a, w.RESET);
|
|
155
152
|
}
|
|
156
153
|
function Me(e, a, t) {
|
|
157
|
-
return x(e, a,
|
|
154
|
+
return x(e, a, w.CONFIG, t);
|
|
158
155
|
}
|
|
159
|
-
function xe(e, a, t
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
function xe(e, a, t) {
|
|
157
|
+
return x(e, a, w.INIT, t);
|
|
158
|
+
}
|
|
159
|
+
function Re(e, a, t, n, r, i, s, d, o, l, y, E) {
|
|
160
|
+
const c = e.data, {
|
|
161
|
+
requestId: m,
|
|
162
|
+
type: b,
|
|
163
163
|
data: g,
|
|
164
|
-
error:
|
|
165
|
-
} =
|
|
166
|
-
if (
|
|
167
|
-
if (n == null || n(),
|
|
164
|
+
error: p
|
|
165
|
+
} = c;
|
|
166
|
+
if (b === w.READY) {
|
|
167
|
+
if (n == null || n(), m && (a != null && a.has(m))) {
|
|
168
168
|
const {
|
|
169
169
|
resolve: A
|
|
170
|
-
} = a.get(
|
|
171
|
-
a.delete(
|
|
170
|
+
} = a.get(m);
|
|
171
|
+
a.delete(m), A(g);
|
|
172
172
|
}
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
175
|
+
if (Ae(e.origin, Se)) {
|
|
176
|
+
if (m && a && a.has(m)) {
|
|
177
177
|
const {
|
|
178
178
|
resolve: A,
|
|
179
|
-
reject:
|
|
180
|
-
} = a.get(
|
|
181
|
-
a.delete(
|
|
179
|
+
reject: U
|
|
180
|
+
} = a.get(m);
|
|
181
|
+
a.delete(m), p ? U(new Error(String(p.message))) : A(g);
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
if (
|
|
185
|
-
t((
|
|
184
|
+
if (b === w.ERROR) {
|
|
185
|
+
t((p == null ? void 0 : p.message) || "Unknown error"), r == null || r(new Error(String(p == null ? void 0 : p.message)));
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
|
-
if (
|
|
189
|
-
g && typeof g == "object" && "status" in g && (
|
|
188
|
+
if (b === w.PAYMENT_COMPLETE) {
|
|
189
|
+
g && typeof g == "object" && "status" in g && (i == null || i(g));
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
-
if (
|
|
192
|
+
if (b === w.PAYMENT_FAILED) {
|
|
193
193
|
g && typeof g == "object" && "status" in g && (s == null || s(g));
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
|
-
if (
|
|
196
|
+
if (b === w.PAYMENT_PENDING) {
|
|
197
197
|
g && typeof g == "object" && "status" in g && (d == null || d(g));
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
200
|
+
if (b === w.PAYMENT_METHOD_SELECTED) {
|
|
201
201
|
g && typeof g == "object" && "paymentMethod" in g && (o == null || o(g.paymentMethod));
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
-
if (
|
|
205
|
-
if (
|
|
206
|
-
|
|
204
|
+
if (b !== w.RESIZE) {
|
|
205
|
+
if (b === v.ThreeDSChallenge) {
|
|
206
|
+
l == null || l();
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
if (
|
|
210
|
-
|
|
209
|
+
if (b === v.ThreeDSComplete) {
|
|
210
|
+
y == null || y();
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
213
|
+
if (b === v.ThreeDSFailed) {
|
|
214
214
|
E == null || E();
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function dt(e) {
|
|
221
221
|
const [a, t] = I(
|
|
222
222
|
() => !1
|
|
223
|
-
), [n,
|
|
223
|
+
), [n, r] = I(() => null), [i, s] = I(
|
|
224
224
|
() => ""
|
|
225
225
|
), [d, o] = I(() => null);
|
|
226
|
-
return
|
|
227
|
-
const
|
|
226
|
+
return K(() => {
|
|
227
|
+
const l = (...h) => {
|
|
228
228
|
e.debug && console.log("[PayConductor]", ...h);
|
|
229
|
-
},
|
|
229
|
+
}, y = Ce({
|
|
230
230
|
publicKey: e.publicKey
|
|
231
231
|
});
|
|
232
|
-
s(
|
|
233
|
-
const E =
|
|
234
|
-
let
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
var
|
|
238
|
-
const h = (
|
|
232
|
+
s(y), t(!0);
|
|
233
|
+
const E = z();
|
|
234
|
+
let c = !1;
|
|
235
|
+
l("init", e.publicKey), l("iframeUrl", y);
|
|
236
|
+
const m = () => {
|
|
237
|
+
var C, u;
|
|
238
|
+
const h = (u = (C = window.PayConductor) == null ? void 0 : C.frame) == null ? void 0 : u.iframe;
|
|
239
239
|
if (h) {
|
|
240
240
|
if (h instanceof HTMLIFrameElement) return h;
|
|
241
241
|
if (typeof h == "object" && h !== null) {
|
|
242
|
-
const
|
|
243
|
-
if ("current" in
|
|
244
|
-
return
|
|
245
|
-
if ("value" in
|
|
246
|
-
return
|
|
242
|
+
const f = h;
|
|
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;
|
|
247
247
|
}
|
|
248
248
|
return h;
|
|
249
249
|
}
|
|
250
250
|
return document.querySelector(
|
|
251
251
|
".payconductor-element iframe"
|
|
252
252
|
) ?? void 0;
|
|
253
|
-
},
|
|
253
|
+
}, b = {
|
|
254
254
|
get iframe() {
|
|
255
255
|
return document.querySelector(
|
|
256
256
|
".payconductor-element iframe"
|
|
@@ -258,7 +258,7 @@ function rt(e) {
|
|
|
258
258
|
},
|
|
259
259
|
set iframe(h) {
|
|
260
260
|
},
|
|
261
|
-
iframeUrl:
|
|
261
|
+
iframeUrl: y,
|
|
262
262
|
error: null
|
|
263
263
|
}, g = {
|
|
264
264
|
publicKey: e.publicKey,
|
|
@@ -266,16 +266,16 @@ function rt(e) {
|
|
|
266
266
|
locale: e.locale,
|
|
267
267
|
paymentMethods: e.paymentMethods,
|
|
268
268
|
defaultPaymentMethod: e.defaultPaymentMethod
|
|
269
|
-
},
|
|
269
|
+
}, p = {
|
|
270
270
|
confirmPayment: (h) => {
|
|
271
|
-
var
|
|
272
|
-
|
|
271
|
+
var u;
|
|
272
|
+
l("→ CONFIRM_PAYMENT", {
|
|
273
273
|
orderId: h.orderId
|
|
274
274
|
});
|
|
275
|
-
const
|
|
276
|
-
return
|
|
275
|
+
const C = m();
|
|
276
|
+
return C != null && C.contentWindow && C.contentWindow.postMessage(
|
|
277
277
|
{
|
|
278
|
-
type:
|
|
278
|
+
type: w.CONFIG,
|
|
279
279
|
data: {
|
|
280
280
|
publicKey: e.publicKey,
|
|
281
281
|
orderId: h.orderId,
|
|
@@ -288,36 +288,36 @@ function rt(e) {
|
|
|
288
288
|
}
|
|
289
289
|
},
|
|
290
290
|
"*"
|
|
291
|
-
), g.orderId = h.orderId, (
|
|
291
|
+
), g.orderId = h.orderId, (u = window.PayConductor) != null && u.config && (window.PayConductor.config.orderId = h.orderId), Te(C, E, h);
|
|
292
292
|
},
|
|
293
|
-
validate: (h) => (
|
|
294
|
-
reset: () => (
|
|
293
|
+
validate: (h) => (l("→ VALIDATE", h), Ie(m(), E, h)),
|
|
294
|
+
reset: () => (l("→ RESET"), De(m(), E)),
|
|
295
295
|
getSelectedPaymentMethod: () => d
|
|
296
296
|
};
|
|
297
297
|
window.PayConductor = {
|
|
298
|
-
frame:
|
|
298
|
+
frame: b,
|
|
299
299
|
config: g,
|
|
300
|
-
api:
|
|
300
|
+
api: p,
|
|
301
301
|
selectedPaymentMethod: d
|
|
302
|
-
},
|
|
302
|
+
}, l("registered"), window.dispatchEvent(
|
|
303
303
|
new CustomEvent("payconductor:registered", {
|
|
304
304
|
detail: window.PayConductor
|
|
305
305
|
})
|
|
306
306
|
);
|
|
307
307
|
const A = async () => {
|
|
308
|
-
if (!
|
|
309
|
-
const h =
|
|
308
|
+
if (!c) {
|
|
309
|
+
const h = m();
|
|
310
310
|
if (!h) {
|
|
311
|
-
|
|
311
|
+
l("→ CONFIG skipped: iframe not found");
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
|
|
314
|
+
c = !0, l("→ CONFIG", {
|
|
315
315
|
theme: e.theme,
|
|
316
316
|
locale: e.locale,
|
|
317
317
|
paymentMethods: e.paymentMethods,
|
|
318
318
|
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
319
319
|
showPaymentButtons: e.showPaymentButtons
|
|
320
|
-
}),
|
|
320
|
+
}), Me(h, E, {
|
|
321
321
|
theme: e.theme,
|
|
322
322
|
locale: e.locale,
|
|
323
323
|
paymentMethods: e.paymentMethods,
|
|
@@ -326,77 +326,77 @@ function rt(e) {
|
|
|
326
326
|
nuPayConfig: e.nuPayConfig
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
-
},
|
|
330
|
-
var
|
|
331
|
-
(
|
|
329
|
+
}, U = (h) => {
|
|
330
|
+
var C;
|
|
331
|
+
(C = h.data) != null && C.type && l("←", h.data.type, h.data.data ?? ""), Re(
|
|
332
332
|
h,
|
|
333
333
|
E,
|
|
334
|
-
(
|
|
335
|
-
var
|
|
336
|
-
|
|
334
|
+
(u) => {
|
|
335
|
+
var f;
|
|
336
|
+
r(u), b.error = u, (f = window.PayConductor) != null && f.frame && (window.PayConductor.frame.error = u);
|
|
337
337
|
},
|
|
338
338
|
() => {
|
|
339
|
-
var
|
|
340
|
-
(
|
|
339
|
+
var u;
|
|
340
|
+
(u = e.onReady) == null || u.call(e), A();
|
|
341
341
|
},
|
|
342
|
-
(
|
|
343
|
-
var
|
|
344
|
-
(
|
|
342
|
+
(u) => {
|
|
343
|
+
var f;
|
|
344
|
+
(f = e.onError) == null || f.call(e, u);
|
|
345
345
|
},
|
|
346
|
-
(
|
|
347
|
-
var
|
|
348
|
-
(
|
|
346
|
+
(u) => {
|
|
347
|
+
var f;
|
|
348
|
+
(f = e.onPaymentComplete) == null || f.call(e, u);
|
|
349
349
|
},
|
|
350
|
-
(
|
|
351
|
-
var
|
|
352
|
-
(
|
|
350
|
+
(u) => {
|
|
351
|
+
var f;
|
|
352
|
+
(f = e.onPaymentFailed) == null || f.call(e, u);
|
|
353
353
|
},
|
|
354
|
-
(
|
|
355
|
-
var
|
|
356
|
-
(
|
|
354
|
+
(u) => {
|
|
355
|
+
var f;
|
|
356
|
+
(f = e.onPaymentPending) == null || f.call(e, u);
|
|
357
357
|
},
|
|
358
|
-
(
|
|
359
|
-
var
|
|
360
|
-
o(
|
|
358
|
+
(u) => {
|
|
359
|
+
var f;
|
|
360
|
+
o(u), window.PayConductor && (window.PayConductor.selectedPaymentMethod = u), (f = e.onPaymentMethodSelected) == null || f.call(e, u);
|
|
361
361
|
},
|
|
362
362
|
() => {
|
|
363
|
-
var
|
|
364
|
-
(
|
|
363
|
+
var u;
|
|
364
|
+
(u = e.onThreeDSChallenge) == null || u.call(e);
|
|
365
365
|
},
|
|
366
366
|
() => {
|
|
367
|
-
var
|
|
368
|
-
(
|
|
367
|
+
var u;
|
|
368
|
+
(u = e.onThreeDSComplete) == null || u.call(e);
|
|
369
369
|
},
|
|
370
370
|
() => {
|
|
371
|
-
var
|
|
372
|
-
(
|
|
371
|
+
var u;
|
|
372
|
+
(u = e.onThreeDSFailed) == null || u.call(e);
|
|
373
373
|
}
|
|
374
374
|
);
|
|
375
375
|
};
|
|
376
|
-
window.addEventListener("message",
|
|
377
|
-
const
|
|
378
|
-
var
|
|
379
|
-
const h =
|
|
376
|
+
window.addEventListener("message", U);
|
|
377
|
+
const ee = () => {
|
|
378
|
+
var C, u, f;
|
|
379
|
+
const h = m();
|
|
380
380
|
if (!h) return !1;
|
|
381
381
|
try {
|
|
382
|
-
if ((((
|
|
382
|
+
if ((((C = h.contentDocument) == null ? void 0 : C.readyState) ?? ((f = (u = h.contentWindow) == null ? void 0 : u.document) == null ? void 0 : f.readyState)) === "complete")
|
|
383
383
|
return A(), !0;
|
|
384
384
|
} catch {
|
|
385
385
|
}
|
|
386
386
|
return !1;
|
|
387
|
-
},
|
|
388
|
-
if (
|
|
389
|
-
const h =
|
|
387
|
+
}, $ = () => {
|
|
388
|
+
if (ee()) return;
|
|
389
|
+
const h = m();
|
|
390
390
|
if (h) {
|
|
391
391
|
h.addEventListener("load", () => A(), {
|
|
392
392
|
once: !0
|
|
393
393
|
});
|
|
394
394
|
return;
|
|
395
395
|
}
|
|
396
|
-
setTimeout(
|
|
396
|
+
setTimeout($, 50);
|
|
397
397
|
};
|
|
398
|
-
|
|
399
|
-
}, []), /* @__PURE__ */
|
|
398
|
+
$();
|
|
399
|
+
}, []), /* @__PURE__ */ O(
|
|
400
400
|
"div",
|
|
401
401
|
{
|
|
402
402
|
className: "payconductor",
|
|
@@ -408,37 +408,37 @@ function rt(e) {
|
|
|
408
408
|
}
|
|
409
409
|
);
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
const a =
|
|
413
|
-
return
|
|
414
|
-
if (typeof document < "u" && !document.getElementById(
|
|
415
|
-
const
|
|
416
|
-
|
|
411
|
+
function ct(e) {
|
|
412
|
+
const a = re(null), [t, n] = I(() => ""), [r, i] = I(() => !1), [s, d] = I(() => "");
|
|
413
|
+
return K(() => {
|
|
414
|
+
if (typeof document < "u" && !document.getElementById(Y)) {
|
|
415
|
+
const c = document.createElement("style");
|
|
416
|
+
c.id = Y, c.textContent = Pe, document.head.appendChild(c);
|
|
417
417
|
}
|
|
418
|
-
const o = (
|
|
419
|
-
|
|
418
|
+
const o = (c) => {
|
|
419
|
+
c != null && c.frame && (n(c.frame.iframeUrl || ""), i(!0), console.log("init", {
|
|
420
420
|
PayConductor: window.PayConductor
|
|
421
421
|
}));
|
|
422
|
-
},
|
|
423
|
-
if (
|
|
424
|
-
o(
|
|
422
|
+
}, l = typeof window < "u" ? window.PayConductor : null;
|
|
423
|
+
if (l)
|
|
424
|
+
o(l);
|
|
425
425
|
else {
|
|
426
|
-
const
|
|
427
|
-
o(
|
|
426
|
+
const c = (m) => {
|
|
427
|
+
o(m.detail), window.removeEventListener("payconductor:registered", c);
|
|
428
428
|
};
|
|
429
|
-
window.addEventListener("payconductor:registered",
|
|
429
|
+
window.addEventListener("payconductor:registered", c);
|
|
430
430
|
}
|
|
431
|
-
let
|
|
432
|
-
const E = (
|
|
433
|
-
var
|
|
434
|
-
if (((
|
|
435
|
-
|
|
431
|
+
let y = !1;
|
|
432
|
+
const E = (c) => {
|
|
433
|
+
var m, b, g, p;
|
|
434
|
+
if (((m = c.data) == null ? void 0 : m.type) === w.RESIZE && ((g = (b = c.data) == null ? void 0 : b.data) != null && g.height) && d(c.data.data.height + "px"), ((p = c.data) == null ? void 0 : p.type) === w.READY && e.height && !y) {
|
|
435
|
+
y = !0;
|
|
436
436
|
const A = document.querySelector(
|
|
437
437
|
".payconductor-element iframe"
|
|
438
438
|
);
|
|
439
439
|
A != null && A.contentWindow && A.contentWindow.postMessage(
|
|
440
440
|
{
|
|
441
|
-
type:
|
|
441
|
+
type: w.CONFIG,
|
|
442
442
|
data: {
|
|
443
443
|
height: e.height
|
|
444
444
|
},
|
|
@@ -449,7 +449,7 @@ function ot(e) {
|
|
|
449
449
|
}
|
|
450
450
|
};
|
|
451
451
|
return window.addEventListener("message", E), () => window.removeEventListener("message", E);
|
|
452
|
-
}, []), /* @__PURE__ */
|
|
452
|
+
}, []), /* @__PURE__ */ ne(
|
|
453
453
|
"div",
|
|
454
454
|
{
|
|
455
455
|
className: "payconductor-element",
|
|
@@ -457,16 +457,16 @@ function ot(e) {
|
|
|
457
457
|
width: "100%"
|
|
458
458
|
},
|
|
459
459
|
children: [
|
|
460
|
-
|
|
460
|
+
r ? null : /* @__PURE__ */ O(
|
|
461
461
|
"div",
|
|
462
462
|
{
|
|
463
463
|
className: "payconductor-skeleton",
|
|
464
464
|
style: {
|
|
465
|
-
height: e.height ||
|
|
465
|
+
height: e.height || G
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
),
|
|
469
|
-
|
|
469
|
+
r && t ? /* @__PURE__ */ O(
|
|
470
470
|
"iframe",
|
|
471
471
|
{
|
|
472
472
|
allow: "payment",
|
|
@@ -475,7 +475,7 @@ function ot(e) {
|
|
|
475
475
|
src: t,
|
|
476
476
|
style: {
|
|
477
477
|
width: "100%",
|
|
478
|
-
height: e.height || s ||
|
|
478
|
+
height: e.height || s || G,
|
|
479
479
|
border: "none"
|
|
480
480
|
}
|
|
481
481
|
}
|
|
@@ -484,22 +484,22 @@ function ot(e) {
|
|
|
484
484
|
}
|
|
485
485
|
);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function lt(e) {
|
|
488
488
|
const [a, t] = I(() => !1);
|
|
489
|
-
return
|
|
489
|
+
return K(() => {
|
|
490
490
|
const n = () => {
|
|
491
491
|
t(!0);
|
|
492
|
-
},
|
|
492
|
+
}, r = () => {
|
|
493
493
|
t(!1);
|
|
494
494
|
};
|
|
495
|
-
return window.addEventListener("payconductor:3ds:show", n), window.addEventListener("payconductor:3ds:hide",
|
|
495
|
+
return window.addEventListener("payconductor:3ds:show", n), window.addEventListener("payconductor:3ds:hide", r), typeof window < "u" && (window.PayConductor3DS = {
|
|
496
496
|
container: () => document.getElementById("payconductor-3ds-container"),
|
|
497
497
|
show: n,
|
|
498
|
-
hide:
|
|
498
|
+
hide: r
|
|
499
499
|
}, window.dispatchEvent(new CustomEvent("payconductor:3ds:registered"))), () => {
|
|
500
|
-
window.removeEventListener("payconductor:3ds:show", n), window.removeEventListener("payconductor:3ds:hide",
|
|
500
|
+
window.removeEventListener("payconductor:3ds:show", n), window.removeEventListener("payconductor:3ds:hide", r), window.PayConductor3DS = null;
|
|
501
501
|
};
|
|
502
|
-
}, []), /* @__PURE__ */
|
|
502
|
+
}, []), /* @__PURE__ */ O(
|
|
503
503
|
"div",
|
|
504
504
|
{
|
|
505
505
|
className: "payconductor-three-ds",
|
|
@@ -512,7 +512,7 @@ function st(e) {
|
|
|
512
512
|
}
|
|
513
513
|
);
|
|
514
514
|
}
|
|
515
|
-
function
|
|
515
|
+
function ut() {
|
|
516
516
|
const e = typeof window < "u" ? window.PayConductor : null, a = e != null && e.config ? {
|
|
517
517
|
publicKey: e.config.publicKey,
|
|
518
518
|
orderId: e.config.orderId,
|
|
@@ -530,7 +530,7 @@ function dt() {
|
|
|
530
530
|
...t
|
|
531
531
|
};
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function F(e) {
|
|
534
534
|
var a;
|
|
535
535
|
if ((a = e == null ? void 0 : e.frame) != null && a.iframe) {
|
|
536
536
|
const t = e.frame.iframe;
|
|
@@ -548,20 +548,20 @@ function U(e) {
|
|
|
548
548
|
}
|
|
549
549
|
return document.querySelector(".payconductor-element iframe") ?? null;
|
|
550
550
|
}
|
|
551
|
-
function
|
|
551
|
+
function ht() {
|
|
552
552
|
const e = () => typeof window < "u" ? window.PayConductor : null, a = (t, n) => {
|
|
553
|
-
const
|
|
554
|
-
if (!
|
|
555
|
-
const
|
|
556
|
-
|
|
553
|
+
const r = e();
|
|
554
|
+
if (!r) return;
|
|
555
|
+
const i = F(r);
|
|
556
|
+
i != null && i.contentWindow && i.contentWindow.postMessage({
|
|
557
557
|
type: t,
|
|
558
558
|
data: n
|
|
559
559
|
}, "*");
|
|
560
560
|
};
|
|
561
561
|
return {
|
|
562
562
|
init: async (t) => {
|
|
563
|
-
const n =
|
|
564
|
-
return
|
|
563
|
+
const n = F(e()), r = z();
|
|
564
|
+
return xe(n || void 0, r, t);
|
|
565
565
|
},
|
|
566
566
|
confirmPayment: async (t) => {
|
|
567
567
|
if (!t.orderId)
|
|
@@ -583,9 +583,9 @@ function ct() {
|
|
|
583
583
|
return ((t = e()) == null ? void 0 : t.selectedPaymentMethod) ?? null;
|
|
584
584
|
},
|
|
585
585
|
updateConfig: (t) => {
|
|
586
|
-
var
|
|
587
|
-
const n = (
|
|
588
|
-
a(
|
|
586
|
+
var r;
|
|
587
|
+
const n = (r = e()) == null ? void 0 : r.config;
|
|
588
|
+
a(w.CONFIG, {
|
|
589
589
|
publicKey: n == null ? void 0 : n.publicKey,
|
|
590
590
|
orderId: n == null ? void 0 : n.orderId,
|
|
591
591
|
theme: t.theme ?? (n == null ? void 0 : n.theme),
|
|
@@ -594,9 +594,9 @@ function ct() {
|
|
|
594
594
|
});
|
|
595
595
|
},
|
|
596
596
|
updateOrderId: (t) => {
|
|
597
|
-
var
|
|
598
|
-
const n = (
|
|
599
|
-
a(
|
|
597
|
+
var r;
|
|
598
|
+
const n = (r = e()) == null ? void 0 : r.config;
|
|
599
|
+
a(w.CONFIG, {
|
|
600
600
|
publicKey: n == null ? void 0 : n.publicKey,
|
|
601
601
|
orderId: t,
|
|
602
602
|
theme: n == null ? void 0 : n.theme,
|
|
@@ -605,18 +605,18 @@ function ct() {
|
|
|
605
605
|
});
|
|
606
606
|
},
|
|
607
607
|
update: (t) => {
|
|
608
|
-
a(
|
|
608
|
+
a(w.UPDATE, t);
|
|
609
609
|
},
|
|
610
610
|
submit: async () => {
|
|
611
|
-
const t =
|
|
611
|
+
const t = F(e()), n = z();
|
|
612
612
|
try {
|
|
613
|
-
return await x(t || void 0, n,
|
|
613
|
+
return await x(t || void 0, n, w.CONFIRM_PAYMENT, {}), {
|
|
614
614
|
paymentMethod: void 0
|
|
615
615
|
};
|
|
616
|
-
} catch (
|
|
616
|
+
} catch (r) {
|
|
617
617
|
return {
|
|
618
618
|
error: {
|
|
619
|
-
message:
|
|
619
|
+
message: r instanceof Error ? r.message : "Payment failed",
|
|
620
620
|
code: "payment_error",
|
|
621
621
|
type: "payment_error"
|
|
622
622
|
}
|
|
@@ -625,11 +625,11 @@ function ct() {
|
|
|
625
625
|
}
|
|
626
626
|
};
|
|
627
627
|
}
|
|
628
|
-
var
|
|
629
|
-
class
|
|
628
|
+
var H = /* @__PURE__ */ ((e) => (e.Auto = "Auto", e.Manual = "Manual", e.Agnostic = "Agnostic", e))(H || {}), S = /* @__PURE__ */ ((e) => (e.Success = "Success", e.Failed = "Failed", e.Timeout = "Timeout", e))(S || {}), _ = /* @__PURE__ */ ((e) => (e.Authenticated = "Y", e.Attempted = "A", e.ChallengeRequired = "C", e.NotAuthenticated = "N", e.Unavailable = "U", e.Rejected = "R", e.InformationOnly = "I", e))(_ || {});
|
|
629
|
+
class N {
|
|
630
630
|
constructor(a, t) {
|
|
631
|
-
|
|
632
|
-
|
|
631
|
+
P(this, "overlay", null);
|
|
632
|
+
P(this, "modalContent", null);
|
|
633
633
|
this.data = a, this.options = t;
|
|
634
634
|
}
|
|
635
635
|
/** Os SDKs de 3DS dos provedores (Pagar.me, PagSeguro) esperam o valor em centavos. */
|
|
@@ -637,9 +637,8 @@ class k {
|
|
|
637
637
|
return this.data.amount === void 0 ? void 0 : Math.round(this.data.amount * 100);
|
|
638
638
|
}
|
|
639
639
|
fail(a, t = {}) {
|
|
640
|
-
var i, r;
|
|
641
640
|
const n = new Error(a);
|
|
642
|
-
return
|
|
641
|
+
return {
|
|
643
642
|
...t,
|
|
644
643
|
status: "Failed",
|
|
645
644
|
error: n
|
|
@@ -698,12 +697,12 @@ class k {
|
|
|
698
697
|
//#endregion
|
|
699
698
|
}
|
|
700
699
|
const _e = 5 * 60 * 1e3;
|
|
701
|
-
class
|
|
700
|
+
class ke extends N {
|
|
702
701
|
constructor() {
|
|
703
702
|
super(...arguments);
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
703
|
+
P(this, "iframe", null);
|
|
704
|
+
P(this, "messageListener", null);
|
|
705
|
+
P(this, "timeoutId", null);
|
|
707
706
|
}
|
|
708
707
|
async authenticate() {
|
|
709
708
|
const {
|
|
@@ -712,23 +711,22 @@ class De extends k {
|
|
|
712
711
|
} = this.data;
|
|
713
712
|
if (!t || !n)
|
|
714
713
|
return this.fail("Missing threeDsUrl or creq");
|
|
715
|
-
const
|
|
716
|
-
return new Promise((
|
|
717
|
-
var
|
|
718
|
-
this.iframe = document.createElement("iframe"), this.iframe.name = "payconductor-3ds-challenge", this.iframe.id = "payconductor-3ds-challenge",
|
|
719
|
-
var E
|
|
720
|
-
((E =
|
|
721
|
-
status:
|
|
714
|
+
const r = this.resolveContainer();
|
|
715
|
+
return new Promise((i) => {
|
|
716
|
+
var l;
|
|
717
|
+
this.iframe = document.createElement("iframe"), this.iframe.name = "payconductor-3ds-challenge", this.iframe.id = "payconductor-3ds-challenge", r.appendChild(this.iframe), this.messageListener = (y) => {
|
|
718
|
+
var E;
|
|
719
|
+
((E = y.data) == null ? void 0 : E.status) === "COMPLETE" && (this.cleanup(), i({
|
|
720
|
+
status: S.Success
|
|
722
721
|
}));
|
|
723
722
|
}, window.addEventListener("message", this.messageListener), this.timeoutId = setTimeout(() => {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
status: P.Timeout
|
|
723
|
+
this.cleanup(), i({
|
|
724
|
+
status: S.Timeout
|
|
727
725
|
});
|
|
728
726
|
}, this.options.timeoutMs ?? _e);
|
|
729
|
-
const s = (
|
|
727
|
+
const s = (l = this.iframe.contentWindow) == null ? void 0 : l.document;
|
|
730
728
|
if (!s) {
|
|
731
|
-
this.cleanup(),
|
|
729
|
+
this.cleanup(), i(this.fail("Cannot access iframe document"));
|
|
732
730
|
return;
|
|
733
731
|
}
|
|
734
732
|
const d = s.createElement("form");
|
|
@@ -741,27 +739,27 @@ class De extends k {
|
|
|
741
739
|
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null), this.messageListener && (window.removeEventListener("message", this.messageListener), this.messageListener = null), this.iframe && (this.iframe.remove(), this.iframe = null), this.closeModal();
|
|
742
740
|
}
|
|
743
741
|
}
|
|
744
|
-
const
|
|
742
|
+
const B = /* @__PURE__ */ new Map();
|
|
745
743
|
function L(e) {
|
|
746
|
-
const a =
|
|
744
|
+
const a = B.get(e);
|
|
747
745
|
if (a) return a;
|
|
748
|
-
const t = new Promise((n,
|
|
746
|
+
const t = new Promise((n, r) => {
|
|
749
747
|
if (document.querySelector(`script[src="${e}"]`)) {
|
|
750
748
|
n();
|
|
751
749
|
return;
|
|
752
750
|
}
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}, (document.head || document.body).appendChild(
|
|
751
|
+
const i = document.createElement("script");
|
|
752
|
+
i.src = e, i.async = !0, i.onload = () => n(), i.onerror = () => {
|
|
753
|
+
B.delete(e), r(new Error(`Failed to load script: ${e}`));
|
|
754
|
+
}, (document.head || document.body).appendChild(i);
|
|
757
755
|
});
|
|
758
|
-
return
|
|
756
|
+
return B.set(e, t), t;
|
|
759
757
|
}
|
|
760
|
-
const
|
|
761
|
-
class
|
|
758
|
+
const Ne = "https://static.payzen.lat/static/js/authenticate-client/V1.0/kr-authenticate.umd.js", Oe = 10 * 60 * 1e3;
|
|
759
|
+
class Le extends N {
|
|
762
760
|
constructor() {
|
|
763
761
|
super(...arguments);
|
|
764
|
-
|
|
762
|
+
P(this, "timeoutId", null);
|
|
765
763
|
}
|
|
766
764
|
async authenticate() {
|
|
767
765
|
const {
|
|
@@ -771,21 +769,19 @@ class Ne extends k {
|
|
|
771
769
|
if (!t || !n)
|
|
772
770
|
return this.fail("Missing operationUrl or publicKey");
|
|
773
771
|
try {
|
|
774
|
-
await L(
|
|
772
|
+
await L(Ne);
|
|
775
773
|
} catch {
|
|
776
774
|
return this.fail("Failed to load 3DS SDK");
|
|
777
775
|
}
|
|
778
|
-
const
|
|
779
|
-
return
|
|
776
|
+
const r = window.KrAuthenticate;
|
|
777
|
+
return r ? new Promise((i) => {
|
|
780
778
|
this.timeoutId = setTimeout(() => {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
status: P.Timeout
|
|
779
|
+
this.cleanup(), i({
|
|
780
|
+
status: S.Timeout
|
|
784
781
|
});
|
|
785
|
-
}, this.options.timeoutMs ??
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
status: P.Success
|
|
782
|
+
}, this.options.timeoutMs ?? Oe), new r(n).authenticate(t, () => {
|
|
783
|
+
this.cleanup(), i({
|
|
784
|
+
status: S.Success
|
|
789
785
|
});
|
|
790
786
|
});
|
|
791
787
|
}) : this.fail("KrAuthenticate not available");
|
|
@@ -794,19 +790,19 @@ class Ne extends k {
|
|
|
794
790
|
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null);
|
|
795
791
|
}
|
|
796
792
|
}
|
|
797
|
-
const
|
|
798
|
-
[
|
|
799
|
-
[
|
|
800
|
-
},
|
|
801
|
-
function
|
|
793
|
+
const Ue = {
|
|
794
|
+
[k.Production]: "https://3ds-nx-js.stone.com.br/live/v2/3ds2.min.js",
|
|
795
|
+
[k.Sandbox]: "https://3ds-nx-js.stone.com.br/test/v2/3ds2.min.js"
|
|
796
|
+
}, Fe = 5 * 60 * 1e3;
|
|
797
|
+
function Be() {
|
|
802
798
|
const e = window.innerWidth;
|
|
803
799
|
return e <= 480 ? "01" : e <= 768 ? "02" : e <= 1024 ? "03" : "04";
|
|
804
800
|
}
|
|
805
|
-
class
|
|
801
|
+
class ze extends N {
|
|
806
802
|
constructor() {
|
|
807
803
|
super(...arguments);
|
|
808
|
-
|
|
809
|
-
|
|
804
|
+
P(this, "timeoutId", null);
|
|
805
|
+
P(this, "methodContainer", null);
|
|
810
806
|
}
|
|
811
807
|
async authenticate() {
|
|
812
808
|
const {
|
|
@@ -815,47 +811,45 @@ class Fe extends k {
|
|
|
815
811
|
} = this.data;
|
|
816
812
|
if (!t) return this.fail("Missing authToken for PagarMe 3DS");
|
|
817
813
|
if (!n) return this.fail("Missing card data for PagarMe 3DS");
|
|
818
|
-
const
|
|
814
|
+
const r = this.data.environment ?? k.Production;
|
|
819
815
|
try {
|
|
820
|
-
await L(
|
|
816
|
+
await L(Ue[r]);
|
|
821
817
|
} catch {
|
|
822
818
|
return this.fail("Failed to load Stone 3DS SDK");
|
|
823
819
|
}
|
|
824
|
-
const
|
|
825
|
-
if (!
|
|
820
|
+
const i = window.TDS;
|
|
821
|
+
if (!i) return this.fail("Stone TDS SDK not available");
|
|
826
822
|
const s = this.resolveContainer();
|
|
827
823
|
return this.methodContainer = document.createElement("div"), this.methodContainer.style.display = "none", document.body.appendChild(this.methodContainer), new Promise((d) => {
|
|
828
824
|
this.timeoutId = setTimeout(() => {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
status: P.Timeout
|
|
825
|
+
this.cleanup(), d({
|
|
826
|
+
status: S.Timeout
|
|
832
827
|
});
|
|
833
|
-
}, this.options.timeoutMs ??
|
|
828
|
+
}, this.options.timeoutMs ?? Fe), i.init({
|
|
834
829
|
token: t,
|
|
835
830
|
tds_method_container_element: this.methodContainer,
|
|
836
831
|
challenge_container_element: s,
|
|
837
832
|
use_default_challenge_iframe_style: !0,
|
|
838
|
-
challenge_window_size:
|
|
833
|
+
challenge_window_size: Be()
|
|
839
834
|
}, this.buildOrderData()).then((o) => {
|
|
840
|
-
var m, f;
|
|
841
835
|
if (this.cleanup(), !(o != null && o.length)) {
|
|
842
836
|
d(this.fail("PagarMe 3DS returned no response"));
|
|
843
837
|
return;
|
|
844
838
|
}
|
|
845
|
-
const
|
|
846
|
-
transStatus:
|
|
847
|
-
providerTransactionId:
|
|
848
|
-
challengeCanceled:
|
|
839
|
+
const l = o[0], y = Object.values(_).find((c) => c === l.trans_status), E = {
|
|
840
|
+
transStatus: y,
|
|
841
|
+
providerTransactionId: l.tds_server_trans_id,
|
|
842
|
+
challengeCanceled: l.challenge_canceled
|
|
849
843
|
};
|
|
850
|
-
if (
|
|
844
|
+
if (l.challenge_canceled) {
|
|
851
845
|
d(this.fail("3DS challenge canceled by user", E));
|
|
852
846
|
return;
|
|
853
847
|
}
|
|
854
|
-
|
|
848
|
+
y === _.Authenticated || y === _.Attempted ? d({
|
|
855
849
|
...E,
|
|
856
|
-
status:
|
|
857
|
-
dsTransactionId:
|
|
858
|
-
})
|
|
850
|
+
status: S.Success,
|
|
851
|
+
dsTransactionId: l.tds_server_trans_id
|
|
852
|
+
}) : d(this.fail(`3DS failed with status: ${l.trans_status}`, E));
|
|
859
853
|
}).catch((o) => {
|
|
860
854
|
this.cleanup(), d(this.fail(o instanceof Error ? o.message : "PagarMe 3DS failed"));
|
|
861
855
|
});
|
|
@@ -865,11 +859,11 @@ class Fe extends k {
|
|
|
865
859
|
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null), this.methodContainer && (this.methodContainer.remove(), this.methodContainer = null), this.closeModal();
|
|
866
860
|
}
|
|
867
861
|
buildOrderData() {
|
|
868
|
-
var
|
|
862
|
+
var i;
|
|
869
863
|
const {
|
|
870
864
|
card: t,
|
|
871
865
|
customer: n,
|
|
872
|
-
billingAddress:
|
|
866
|
+
billingAddress: r
|
|
873
867
|
} = this.data;
|
|
874
868
|
return {
|
|
875
869
|
payments: [{
|
|
@@ -878,15 +872,15 @@ class Fe extends k {
|
|
|
878
872
|
card: {
|
|
879
873
|
number: t == null ? void 0 : t.number,
|
|
880
874
|
holder_name: t == null ? void 0 : t.holderName,
|
|
881
|
-
exp_month: Number(t == null ? void 0 : t.
|
|
882
|
-
exp_year: Number(t == null ? void 0 : t.
|
|
883
|
-
billing_address:
|
|
884
|
-
country:
|
|
885
|
-
state:
|
|
886
|
-
city:
|
|
887
|
-
zip_code:
|
|
888
|
-
line_1: `${
|
|
889
|
-
line_2:
|
|
875
|
+
exp_month: Number(t == null ? void 0 : t.expiration.month),
|
|
876
|
+
exp_year: Number(t == null ? void 0 : t.expiration.year),
|
|
877
|
+
billing_address: r ? {
|
|
878
|
+
country: r.country,
|
|
879
|
+
state: r.state,
|
|
880
|
+
city: r.city,
|
|
881
|
+
zip_code: r.zipCode,
|
|
882
|
+
line_1: `${r.number}, ${r.street}${r.district ? `, ${r.district}` : ""}`,
|
|
883
|
+
line_2: r.complement ?? ""
|
|
890
884
|
} : void 0
|
|
891
885
|
}
|
|
892
886
|
},
|
|
@@ -899,7 +893,7 @@ class Fe extends k {
|
|
|
899
893
|
...n.document ? {
|
|
900
894
|
document: n.document
|
|
901
895
|
} : {},
|
|
902
|
-
...(
|
|
896
|
+
...(i = n.phones) != null && i.length ? {
|
|
903
897
|
phones: Object.fromEntries(n.phones.map((s) => [s.type === "HOME" ? "home_phone" : "mobile_phone", {
|
|
904
898
|
country_code: s.countryCode,
|
|
905
899
|
area_code: s.areaCode,
|
|
@@ -911,25 +905,25 @@ class Fe extends k {
|
|
|
911
905
|
};
|
|
912
906
|
}
|
|
913
907
|
}
|
|
914
|
-
const
|
|
915
|
-
class
|
|
908
|
+
const Ke = "https://assets.pagseguro.com.br/checkout-sdk-js/rc/dist/browser/pagseguro.min.js";
|
|
909
|
+
class je extends N {
|
|
916
910
|
async authenticate() {
|
|
917
|
-
var E
|
|
911
|
+
var E;
|
|
918
912
|
const {
|
|
919
913
|
authToken: a,
|
|
920
914
|
card: t,
|
|
921
915
|
customer: n,
|
|
922
|
-
currency:
|
|
923
|
-
billingAddress:
|
|
916
|
+
currency: r,
|
|
917
|
+
billingAddress: i
|
|
924
918
|
} = this.data, s = this.amountInCents;
|
|
925
919
|
if (!a) return this.fail("Missing authToken (session) for PagSeguro 3DS");
|
|
926
920
|
if (!t) return this.fail("Missing card data for PagSeguro 3DS");
|
|
927
921
|
if (!n) return this.fail("Missing customer data for PagSeguro 3DS");
|
|
928
922
|
if (!s) return this.fail("Missing amount for PagSeguro 3DS");
|
|
929
|
-
if (!
|
|
930
|
-
const d = this.data.environment ===
|
|
923
|
+
if (!i) return this.fail("Missing billingAddress for PagSeguro 3DS");
|
|
924
|
+
const d = this.data.environment === k.Sandbox ? "SANDBOX" : "PROD";
|
|
931
925
|
try {
|
|
932
|
-
await L(
|
|
926
|
+
await L(Ke);
|
|
933
927
|
} catch {
|
|
934
928
|
return this.fail("Failed to load PagSeguro SDK");
|
|
935
929
|
}
|
|
@@ -939,33 +933,33 @@ class ze extends k {
|
|
|
939
933
|
session: a,
|
|
940
934
|
env: d
|
|
941
935
|
});
|
|
942
|
-
const
|
|
943
|
-
country:
|
|
944
|
-
area:
|
|
945
|
-
number:
|
|
946
|
-
type:
|
|
936
|
+
const l = ((E = n.phones) == null ? void 0 : E.map((c) => ({
|
|
937
|
+
country: c.countryCode,
|
|
938
|
+
area: c.areaCode,
|
|
939
|
+
number: c.number,
|
|
940
|
+
type: c.type ?? "MOBILE"
|
|
947
941
|
}))) ?? [{
|
|
948
942
|
country: "55",
|
|
949
943
|
area: "11",
|
|
950
944
|
number: "999999999",
|
|
951
945
|
type: "MOBILE"
|
|
952
946
|
}];
|
|
953
|
-
|
|
947
|
+
l.some((c) => c.type === "MOBILE") || (l[0].type = "MOBILE");
|
|
954
948
|
try {
|
|
955
|
-
const
|
|
949
|
+
const c = await o.authenticate3DS({
|
|
956
950
|
data: {
|
|
957
951
|
customer: {
|
|
958
952
|
name: n.name,
|
|
959
953
|
email: n.email,
|
|
960
|
-
phones:
|
|
954
|
+
phones: l
|
|
961
955
|
},
|
|
962
956
|
paymentMethod: {
|
|
963
957
|
type: this.data.installments === 0 ? "DEBIT_CARD" : "CREDIT_CARD",
|
|
964
958
|
installments: this.data.installments ?? 1,
|
|
965
959
|
card: {
|
|
966
960
|
number: t.number,
|
|
967
|
-
expMonth: t.
|
|
968
|
-
expYear: t.
|
|
961
|
+
expMonth: t.expiration.month,
|
|
962
|
+
expYear: t.expiration.year,
|
|
969
963
|
holder: {
|
|
970
964
|
name: t.holderName
|
|
971
965
|
}
|
|
@@ -973,29 +967,29 @@ class ze extends k {
|
|
|
973
967
|
},
|
|
974
968
|
amount: {
|
|
975
969
|
value: s,
|
|
976
|
-
currency:
|
|
970
|
+
currency: r ?? "BRL"
|
|
977
971
|
},
|
|
978
972
|
billingAddress: {
|
|
979
|
-
street:
|
|
980
|
-
number:
|
|
981
|
-
complement:
|
|
982
|
-
regionCode:
|
|
983
|
-
country:
|
|
984
|
-
city:
|
|
985
|
-
postalCode:
|
|
973
|
+
street: i.street,
|
|
974
|
+
number: i.number,
|
|
975
|
+
complement: i.complement,
|
|
976
|
+
regionCode: i.state,
|
|
977
|
+
country: i.country.length === 2 ? this.toAlpha3(i.country) : i.country,
|
|
978
|
+
city: i.city,
|
|
979
|
+
postalCode: i.zipCode.replace(/\D/g, "")
|
|
986
980
|
},
|
|
987
981
|
dataOnly: !1
|
|
988
982
|
}
|
|
989
983
|
});
|
|
990
|
-
return
|
|
991
|
-
status:
|
|
992
|
-
dsTransactionId:
|
|
993
|
-
}
|
|
994
|
-
status:
|
|
995
|
-
dsTransactionId:
|
|
984
|
+
return c.status === "AUTH_FLOW_COMPLETED" || c.status === "AUTH_NOT_SUPPORTED" ? {
|
|
985
|
+
status: S.Success,
|
|
986
|
+
dsTransactionId: c.id
|
|
987
|
+
} : c.status === "CHANGE_PAYMENT_METHOD" ? this.fail("PagSeguro requires a different payment method") : {
|
|
988
|
+
status: S.Success,
|
|
989
|
+
dsTransactionId: c.id
|
|
996
990
|
};
|
|
997
|
-
} catch (
|
|
998
|
-
return this.fail(
|
|
991
|
+
} catch (c) {
|
|
992
|
+
return this.fail(c instanceof Error ? c.message : "PagSeguro 3DS failed");
|
|
999
993
|
}
|
|
1000
994
|
}
|
|
1001
995
|
cleanup() {
|
|
@@ -1013,11 +1007,11 @@ class ze extends k {
|
|
|
1013
1007
|
}[a.toUpperCase()] ?? a;
|
|
1014
1008
|
}
|
|
1015
1009
|
}
|
|
1016
|
-
const
|
|
1017
|
-
class
|
|
1010
|
+
const He = 5 * 60 * 1e3, V = "payconductor-3ds-sandbox-title";
|
|
1011
|
+
class q extends N {
|
|
1018
1012
|
constructor() {
|
|
1019
1013
|
super(...arguments);
|
|
1020
|
-
|
|
1014
|
+
P(this, "timeoutId", null);
|
|
1021
1015
|
}
|
|
1022
1016
|
async authenticate() {
|
|
1023
1017
|
const {
|
|
@@ -1025,23 +1019,21 @@ class $ extends k {
|
|
|
1025
1019
|
} = this.data;
|
|
1026
1020
|
if (!t) return this.fail("Missing authToken for 3DS challenge");
|
|
1027
1021
|
const n = this.resolveContainer();
|
|
1028
|
-
return new Promise((
|
|
1022
|
+
return new Promise((r) => {
|
|
1029
1023
|
this.timeoutId = setTimeout(() => {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
status: P.Timeout
|
|
1024
|
+
this.cleanup(), r({
|
|
1025
|
+
status: S.Timeout
|
|
1033
1026
|
});
|
|
1034
|
-
}, this.options.timeoutMs ??
|
|
1027
|
+
}, this.options.timeoutMs ?? He), this.renderChallenge(n, {
|
|
1035
1028
|
onConfirm: () => {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
transStatus: D.Authenticated,
|
|
1029
|
+
this.cleanup(), r({
|
|
1030
|
+
status: S.Success,
|
|
1031
|
+
transStatus: _.Authenticated,
|
|
1040
1032
|
providerTransactionId: t
|
|
1041
1033
|
});
|
|
1042
1034
|
},
|
|
1043
1035
|
onCancel: () => {
|
|
1044
|
-
this.cleanup(),
|
|
1036
|
+
this.cleanup(), r(this.fail("3DS challenge canceled by user", {
|
|
1045
1037
|
challengeCanceled: !0
|
|
1046
1038
|
}));
|
|
1047
1039
|
}
|
|
@@ -1052,31 +1044,31 @@ class $ extends k {
|
|
|
1052
1044
|
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = null), this.closeModal();
|
|
1053
1045
|
}
|
|
1054
1046
|
renderChallenge(t, n) {
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1047
|
+
const r = document.createElement("div");
|
|
1048
|
+
r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-labelledby", V), r.style.cssText = "min-height:inherit;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:32px;font-family:system-ui,-apple-system,sans-serif;text-align:center;color:#111827";
|
|
1049
|
+
const i = document.createElement("h2");
|
|
1050
|
+
i.id = V, i.textContent = "Autenticação 3DS (sandbox)", i.style.cssText = "margin:0;font-size:20px";
|
|
1059
1051
|
const s = document.createElement("p");
|
|
1060
1052
|
s.textContent = "Simulação do desafio do banco emissor. Confirme para aprovar a autenticação ou cancele para simular a desistência do comprador.", s.style.cssText = "margin:0 0 8px;max-width:360px;font-size:14px;line-height:1.5;color:#4b5563";
|
|
1061
1053
|
const d = this.createButton("Confirmar autenticação", "background:#111827;color:#fff;border-color:#111827", n.onConfirm), o = this.createButton("Cancelar", "background:#fff;color:#111827;border-color:#d1d5db", n.onCancel);
|
|
1062
|
-
|
|
1054
|
+
r.append(i, s, d, o), t.appendChild(r), d.focus();
|
|
1063
1055
|
}
|
|
1064
|
-
createButton(t, n,
|
|
1065
|
-
const
|
|
1066
|
-
return
|
|
1056
|
+
createButton(t, n, r) {
|
|
1057
|
+
const i = document.createElement("button");
|
|
1058
|
+
return i.type = "button", i.textContent = t, i.style.cssText = `width:100%;max-width:320px;padding:12px 16px;border:1px solid;border-radius:6px;font:inherit;font-size:14px;font-weight:600;cursor:pointer;${n}`, i.addEventListener("click", r), i;
|
|
1067
1059
|
}
|
|
1068
1060
|
}
|
|
1069
|
-
const
|
|
1061
|
+
const $e = {
|
|
1070
1062
|
// Agnostic providers
|
|
1071
|
-
[
|
|
1063
|
+
[T.Lyra]: Le,
|
|
1072
1064
|
// Acquirer-specific providers
|
|
1073
|
-
[
|
|
1074
|
-
[
|
|
1075
|
-
[
|
|
1076
|
-
[
|
|
1077
|
-
[
|
|
1078
|
-
};
|
|
1079
|
-
class
|
|
1065
|
+
[T.MercadoPago]: ke,
|
|
1066
|
+
[T.PagarMe]: ze,
|
|
1067
|
+
[T.PagSeguro]: je,
|
|
1068
|
+
[T.Sandbox]: q,
|
|
1069
|
+
[T.SandboxSplit]: q
|
|
1070
|
+
}, Ge = M.replace(/\/sdk\/?$/, "");
|
|
1071
|
+
class Q extends Error {
|
|
1080
1072
|
constructor(a, t) {
|
|
1081
1073
|
super(a), this.title = t, this.name = "PayConductorThreeDSApiError";
|
|
1082
1074
|
}
|
|
@@ -1085,34 +1077,67 @@ class Ye {
|
|
|
1085
1077
|
constructor(a) {
|
|
1086
1078
|
this.publicKey = a;
|
|
1087
1079
|
}
|
|
1088
|
-
async
|
|
1089
|
-
const n = await fetch(`${
|
|
1080
|
+
async completeChallenge(a, t) {
|
|
1081
|
+
const n = await fetch(`${M}/three-ds/complete/${a}`, {
|
|
1090
1082
|
method: "POST",
|
|
1091
1083
|
headers: this.headers,
|
|
1092
|
-
body: JSON.stringify(
|
|
1093
|
-
|
|
1094
|
-
|
|
1084
|
+
body: JSON.stringify(t)
|
|
1085
|
+
});
|
|
1086
|
+
n.ok || await this.parseResponseError("Falha ao concluir a autenticação 3DS", n);
|
|
1087
|
+
}
|
|
1088
|
+
async getOrderStatus(a) {
|
|
1089
|
+
const t = await fetch(`${Ge}/orders/${a}/status`, {
|
|
1090
|
+
method: "GET",
|
|
1091
|
+
headers: this.headers
|
|
1095
1092
|
});
|
|
1096
|
-
|
|
1093
|
+
return t.ok || await this.parseResponseError("Falha ao consultar o status do pedido", t), qe(await t.json());
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Aguarda o pedido sair de `ThreeDsAwaitingChallenge`.
|
|
1097
|
+
* No modo `Auto` não existe `statusDetail`; a espera é enquanto o pedido seguir `Pending`.
|
|
1098
|
+
*/
|
|
1099
|
+
async pollOrderStatus(a, {
|
|
1100
|
+
maxAttempts: t = 30,
|
|
1101
|
+
intervalMs: n = 2e3,
|
|
1102
|
+
mode: r
|
|
1103
|
+
} = {}) {
|
|
1104
|
+
let i = null;
|
|
1105
|
+
for (let s = 0; s < t; s++) {
|
|
1106
|
+
if (i = await this.getOrderStatus(a), !(i.status === R.Pending && (i.statusDetail === j.ThreeDsAwaitingChallenge || r === H.Auto))) return {
|
|
1107
|
+
order: i,
|
|
1108
|
+
timedOut: !1
|
|
1109
|
+
};
|
|
1110
|
+
await new Promise((o) => setTimeout(o, n));
|
|
1111
|
+
}
|
|
1112
|
+
return {
|
|
1113
|
+
order: i,
|
|
1114
|
+
timedOut: !0
|
|
1115
|
+
};
|
|
1097
1116
|
}
|
|
1098
1117
|
async getThreeDSecureData(a) {
|
|
1099
|
-
const t = await fetch(`${
|
|
1118
|
+
const t = await fetch(`${M}/three-ds/challenge/${a}`, {
|
|
1100
1119
|
method: "GET",
|
|
1101
1120
|
headers: this.headers
|
|
1102
1121
|
});
|
|
1103
|
-
t.ok || await this.parseResponseError("
|
|
1104
|
-
const n = await t.json();
|
|
1105
|
-
return
|
|
1122
|
+
t.ok || await this.parseResponseError("Falha ao buscar dados 3DS", t);
|
|
1123
|
+
const n = await t.json(), r = Object.fromEntries(Object.entries(n.threeDSecure ?? {}).filter(([, i]) => i != null));
|
|
1124
|
+
return {
|
|
1125
|
+
...r,
|
|
1126
|
+
...n.mode ? {
|
|
1127
|
+
mode: n.mode
|
|
1128
|
+
} : {},
|
|
1129
|
+
statusDetail: r.statusDetail ?? n.statusDetail ?? void 0
|
|
1130
|
+
};
|
|
1106
1131
|
}
|
|
1107
1132
|
async parseResponseError(a, t) {
|
|
1108
|
-
var
|
|
1133
|
+
var r, i, s, d;
|
|
1109
1134
|
let n = "";
|
|
1110
1135
|
try {
|
|
1111
1136
|
const o = await t.json();
|
|
1112
|
-
o != null && o.message ? n = o.message : (
|
|
1137
|
+
o != null && o.message ? n = o.message : (r = o == null ? void 0 : o.error) != null && r.message ? n = o.error : (s = (i = o == null ? void 0 : o.error) == null ? void 0 : i.value) != null && s.message ? n = o.error.value.message : (d = o == null ? void 0 : o.value) != null && d.message ? n = o.value.message : n = JSON.stringify(o);
|
|
1113
1138
|
} catch {
|
|
1114
1139
|
}
|
|
1115
|
-
throw new
|
|
1140
|
+
throw new Q(n, a);
|
|
1116
1141
|
}
|
|
1117
1142
|
get headers() {
|
|
1118
1143
|
return {
|
|
@@ -1121,12 +1146,36 @@ class Ye {
|
|
|
1121
1146
|
};
|
|
1122
1147
|
}
|
|
1123
1148
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1149
|
+
function Ve(e) {
|
|
1150
|
+
switch (e) {
|
|
1151
|
+
case "Completed":
|
|
1152
|
+
return R.Succeeded;
|
|
1153
|
+
case "Pending":
|
|
1154
|
+
case "Generating":
|
|
1155
|
+
return R.Pending;
|
|
1156
|
+
default:
|
|
1157
|
+
return R.Failed;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function qe(e) {
|
|
1161
|
+
const a = e ?? {};
|
|
1162
|
+
return {
|
|
1163
|
+
...a,
|
|
1164
|
+
orderId: a.id ?? "",
|
|
1165
|
+
status: Ve(a.status),
|
|
1166
|
+
statusDetail: a.statusDetail ?? void 0,
|
|
1167
|
+
amount: a.amount ?? 0,
|
|
1168
|
+
currency: a.currency ?? "BRL",
|
|
1169
|
+
errorCode: a.errorCode ?? void 0,
|
|
1170
|
+
errorMessage: a.errorMessage ?? void 0,
|
|
1171
|
+
message: a.errorMessage ?? void 0
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
class We {
|
|
1126
1175
|
constructor(a) {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1176
|
+
P(this, "data");
|
|
1177
|
+
P(this, "provider", null);
|
|
1178
|
+
P(this, "api");
|
|
1130
1179
|
this.data = a, this.api = new Ye(this.data.publicKey);
|
|
1131
1180
|
}
|
|
1132
1181
|
get needsChallenge() {
|
|
@@ -1135,58 +1184,139 @@ class Ge {
|
|
|
1135
1184
|
get acquirer() {
|
|
1136
1185
|
return this.data.acquirer;
|
|
1137
1186
|
}
|
|
1187
|
+
/** Indica se o pedido precisa de autenticação 3DS. */
|
|
1188
|
+
static requiresChallenge(a) {
|
|
1189
|
+
var t, n, r;
|
|
1190
|
+
return a.statusDetail === "ThreeDsAwaitingChallenge" || ((t = a.threeDSecure) == null ? void 0 : t.status) === "NeedChallenge" || ((r = (n = a.creditCard) == null ? void 0 : n.threeDSecure) == null ? void 0 : r.status) === "NeedChallenge";
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Executa o fluxo completo de 3DS: carrega os dados, resolve o provedor,
|
|
1194
|
+
* conduz o desafio, envia o `complete` (só no modo `Manual`) e faz o polling
|
|
1195
|
+
* do pedido. O integrador não precisa ramificar por modo.
|
|
1196
|
+
*/
|
|
1138
1197
|
async authenticate(a) {
|
|
1139
|
-
var
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1198
|
+
var c;
|
|
1199
|
+
try {
|
|
1200
|
+
const m = await this.api.getThreeDSecureData(this.data.orderId);
|
|
1201
|
+
this.data = {
|
|
1202
|
+
...this.data,
|
|
1203
|
+
...m
|
|
1204
|
+
};
|
|
1205
|
+
} catch (m) {
|
|
1206
|
+
if (m instanceof Q)
|
|
1207
|
+
return {
|
|
1208
|
+
status: S.Failed,
|
|
1209
|
+
error: m
|
|
1210
|
+
};
|
|
1211
|
+
throw m;
|
|
1212
|
+
}
|
|
1213
|
+
if (!this.needsChallenge)
|
|
1145
1214
|
return {
|
|
1146
|
-
status:
|
|
1215
|
+
status: S.Success
|
|
1147
1216
|
};
|
|
1148
1217
|
const {
|
|
1149
|
-
acquirer:
|
|
1218
|
+
acquirer: t,
|
|
1219
|
+
mode: n
|
|
1150
1220
|
} = this.data;
|
|
1151
|
-
if (!
|
|
1152
|
-
return {
|
|
1153
|
-
status:
|
|
1154
|
-
error: new Error("
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1221
|
+
if (!t)
|
|
1222
|
+
return this.finish({
|
|
1223
|
+
status: S.Failed,
|
|
1224
|
+
error: new Error("Adquirente 3DS não informada na cobrança"),
|
|
1225
|
+
failureReason: "Adquirente 3DS não informada na cobrança"
|
|
1226
|
+
}, a);
|
|
1227
|
+
const r = $e[t];
|
|
1228
|
+
if (!r) {
|
|
1229
|
+
const m = `Provedor 3DS não suportado: ${t}`;
|
|
1230
|
+
return this.finish({
|
|
1231
|
+
status: S.Failed,
|
|
1232
|
+
error: new Error(m),
|
|
1233
|
+
failureReason: m
|
|
1234
|
+
}, a);
|
|
1235
|
+
}
|
|
1236
|
+
(c = a == null ? void 0 : a.onChallenge) == null || c.call(a);
|
|
1237
|
+
const i = new r(this.data, {
|
|
1238
|
+
threeDSecure: this.data,
|
|
1239
|
+
timeoutMs: a == null ? void 0 : a.timeoutMs
|
|
1240
|
+
});
|
|
1241
|
+
this.provider = i;
|
|
1242
|
+
let s;
|
|
1243
|
+
try {
|
|
1244
|
+
s = await i.authenticate();
|
|
1245
|
+
} finally {
|
|
1246
|
+
i.cleanup(), this.provider = null;
|
|
1247
|
+
}
|
|
1248
|
+
const d = {
|
|
1249
|
+
...s
|
|
1250
|
+
}, o = this.deriveFailureReason(s);
|
|
1251
|
+
d.failureReason = o;
|
|
1252
|
+
const l = n ? n === H.Manual : this.data.statusDetail === j.ThreeDsAwaitingChallenge;
|
|
1253
|
+
let y;
|
|
1254
|
+
if (l && (a == null ? void 0 : a.complete) !== !1)
|
|
1255
|
+
try {
|
|
1256
|
+
await this.api.completeChallenge(this.data.orderId, this.buildCompletionPayload(s, o));
|
|
1257
|
+
} catch (m) {
|
|
1258
|
+
y = m;
|
|
1259
|
+
}
|
|
1260
|
+
if ((a == null ? void 0 : a.poll) !== !1 && s.status === S.Success) {
|
|
1261
|
+
const {
|
|
1262
|
+
order: m,
|
|
1263
|
+
timedOut: b
|
|
1264
|
+
} = await this.api.pollOrderStatus(this.data.orderId, {
|
|
1265
|
+
...a == null ? void 0 : a.polling,
|
|
1266
|
+
mode: n
|
|
1267
|
+
});
|
|
1268
|
+
d.order = m ?? void 0, d.timedOut = b;
|
|
1269
|
+
} else y && !d.error && (d.error = this.toError(y));
|
|
1270
|
+
return this.finish(d, a);
|
|
1170
1271
|
}
|
|
1171
1272
|
destroy() {
|
|
1172
1273
|
this.provider && (this.provider.cleanup(), this.provider = null);
|
|
1173
1274
|
}
|
|
1275
|
+
/** Mensagem amigável da falha do desafio (pt-BR). */
|
|
1276
|
+
deriveFailureReason(a) {
|
|
1277
|
+
var t;
|
|
1278
|
+
if (a.status !== S.Success)
|
|
1279
|
+
return a.status === S.Timeout ? "Tempo da autenticação 3DS esgotado" : ((t = a.error) == null ? void 0 : t.message) || "Falha na autenticação 3DS";
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Payload do `complete`. `failureReason` só vai quando é falha técnica
|
|
1283
|
+
* (sem `transStatus` do emissor nem cancelamento) — string vazia quebra o backend.
|
|
1284
|
+
*/
|
|
1285
|
+
buildCompletionPayload(a, t) {
|
|
1286
|
+
const n = a.challengeCanceled === !0, r = a.transStatus;
|
|
1287
|
+
return {
|
|
1288
|
+
providerTransactionId: a.providerTransactionId ?? a.dsTransactionId,
|
|
1289
|
+
transStatus: r,
|
|
1290
|
+
challengeCanceled: n,
|
|
1291
|
+
failureReason: !!t && !r && !n ? t : void 0
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
finish(a, t) {
|
|
1295
|
+
var n, r, i;
|
|
1296
|
+
return (n = t == null ? void 0 : t.onComplete) == null || n.call(t, a), a.failureReason && ((r = t == null ? void 0 : t.onError) == null || r.call(t, new Error(a.failureReason))), (a.status === S.Timeout || a.timedOut) && ((i = t == null ? void 0 : t.onTimeout) == null || i.call(t)), a;
|
|
1297
|
+
}
|
|
1298
|
+
toError(a) {
|
|
1299
|
+
return a instanceof Error ? a : new Error("Falha ao concluir a autenticação 3DS");
|
|
1300
|
+
}
|
|
1174
1301
|
}
|
|
1175
|
-
function
|
|
1302
|
+
function mt(e) {
|
|
1176
1303
|
let a = null;
|
|
1177
1304
|
return {
|
|
1178
|
-
|
|
1179
|
-
const
|
|
1180
|
-
a =
|
|
1305
|
+
authenticate: async (r) => {
|
|
1306
|
+
const i = new We(r);
|
|
1307
|
+
a = i;
|
|
1181
1308
|
try {
|
|
1182
|
-
return await
|
|
1309
|
+
return await i.authenticate({
|
|
1183
1310
|
onChallenge: e == null ? void 0 : e.onChallenge,
|
|
1184
1311
|
onComplete: e == null ? void 0 : e.onComplete,
|
|
1185
1312
|
onError: e == null ? void 0 : e.onError,
|
|
1186
|
-
onTimeout: e == null ? void 0 : e.onTimeout
|
|
1313
|
+
onTimeout: e == null ? void 0 : e.onTimeout,
|
|
1314
|
+
complete: e == null ? void 0 : e.complete,
|
|
1315
|
+
poll: e == null ? void 0 : e.poll,
|
|
1316
|
+
polling: e == null ? void 0 : e.polling
|
|
1187
1317
|
});
|
|
1188
1318
|
} finally {
|
|
1189
|
-
|
|
1319
|
+
i.destroy(), a = null;
|
|
1190
1320
|
}
|
|
1191
1321
|
},
|
|
1192
1322
|
destroy: () => {
|
|
@@ -1194,24 +1324,24 @@ function lt(e) {
|
|
|
1194
1324
|
}
|
|
1195
1325
|
};
|
|
1196
1326
|
}
|
|
1197
|
-
class
|
|
1327
|
+
class Je extends Error {
|
|
1198
1328
|
constructor(a, t) {
|
|
1199
1329
|
super(a), this.title = t, this.name = "PayConductorTokenizerApiError";
|
|
1200
1330
|
}
|
|
1201
1331
|
}
|
|
1202
|
-
class
|
|
1332
|
+
class Xe {
|
|
1203
1333
|
constructor(a) {
|
|
1204
1334
|
this.publicKey = a;
|
|
1205
1335
|
}
|
|
1206
1336
|
async getSettings() {
|
|
1207
|
-
const a = await fetch(`${
|
|
1337
|
+
const a = await fetch(`${M}/card-tokenization/settings`, {
|
|
1208
1338
|
method: "GET",
|
|
1209
1339
|
headers: this.headers
|
|
1210
1340
|
});
|
|
1211
1341
|
return a.ok || await this.parseResponseError("Failed to fetch settings", a), await a.json();
|
|
1212
1342
|
}
|
|
1213
1343
|
async createToken(a) {
|
|
1214
|
-
const t = await fetch(`${
|
|
1344
|
+
const t = await fetch(`${M}/card-tokenization/tokenize`, {
|
|
1215
1345
|
method: "POST",
|
|
1216
1346
|
headers: this.headers,
|
|
1217
1347
|
body: JSON.stringify(a)
|
|
@@ -1219,22 +1349,22 @@ class qe {
|
|
|
1219
1349
|
return t.ok || await this.parseResponseError("Failed to generate token", t), await t.json();
|
|
1220
1350
|
}
|
|
1221
1351
|
async saveTokens(a, t, n) {
|
|
1222
|
-
const
|
|
1352
|
+
const r = await fetch(`${M}/card-tokenization/save-tokens/${t}/${n}`, {
|
|
1223
1353
|
method: "POST",
|
|
1224
1354
|
headers: this.headers,
|
|
1225
1355
|
body: JSON.stringify(a)
|
|
1226
1356
|
});
|
|
1227
|
-
|
|
1357
|
+
r.ok || await this.parseResponseError("Failed to save tokens", r);
|
|
1228
1358
|
}
|
|
1229
1359
|
async parseResponseError(a, t) {
|
|
1230
|
-
var
|
|
1360
|
+
var r, i, s, d;
|
|
1231
1361
|
let n = "";
|
|
1232
1362
|
try {
|
|
1233
1363
|
const o = await t.json();
|
|
1234
|
-
o != null && o.message ? n = o.message : (
|
|
1364
|
+
o != null && o.message ? n = o.message : (r = o == null ? void 0 : o.error) != null && r.message ? n = o.error : (s = (i = o == null ? void 0 : o.error) == null ? void 0 : i.value) != null && s.message ? n = o.error.value.message : (d = o == null ? void 0 : o.value) != null && d.message ? n = o.value.message : n = JSON.stringify(o);
|
|
1235
1365
|
} catch {
|
|
1236
1366
|
}
|
|
1237
|
-
throw new
|
|
1367
|
+
throw new Je(n, a);
|
|
1238
1368
|
}
|
|
1239
1369
|
get headers() {
|
|
1240
1370
|
return {
|
|
@@ -1243,15 +1373,15 @@ class qe {
|
|
|
1243
1373
|
};
|
|
1244
1374
|
}
|
|
1245
1375
|
}
|
|
1246
|
-
class
|
|
1376
|
+
class Ze {
|
|
1247
1377
|
constructor(a) {
|
|
1248
1378
|
this.input = a;
|
|
1249
1379
|
}
|
|
1250
1380
|
}
|
|
1251
|
-
class
|
|
1381
|
+
class Qe extends Ze {
|
|
1252
1382
|
constructor() {
|
|
1253
1383
|
super(...arguments);
|
|
1254
|
-
|
|
1384
|
+
P(this, "scriptUrl", "https://sdk.mercadopago.com/js/v2");
|
|
1255
1385
|
}
|
|
1256
1386
|
async tokenize() {
|
|
1257
1387
|
const {
|
|
@@ -1263,24 +1393,24 @@ class Je extends We {
|
|
|
1263
1393
|
throw new Error("Customer document number is required for tokenization");
|
|
1264
1394
|
const n = window.MercadoPago;
|
|
1265
1395
|
if (!n) throw new Error("MercadoPago SDK not available");
|
|
1266
|
-
const
|
|
1267
|
-
expiration:
|
|
1396
|
+
const r = new n(t.trim()), {
|
|
1397
|
+
expiration: i,
|
|
1268
1398
|
cvv: s,
|
|
1269
1399
|
number: d,
|
|
1270
1400
|
holderName: o
|
|
1271
|
-
} = this.input.card,
|
|
1272
|
-
cardExpirationMonth: String(
|
|
1273
|
-
cardExpirationYear: String(
|
|
1401
|
+
} = this.input.card, l = await r.createCardToken({
|
|
1402
|
+
cardExpirationMonth: String(i.month).padStart(2, "0"),
|
|
1403
|
+
cardExpirationYear: String(i.year),
|
|
1274
1404
|
cardholderName: o,
|
|
1275
1405
|
cardNumber: d,
|
|
1276
1406
|
securityCode: s,
|
|
1277
|
-
identificationType: this.input.customer.documentType ===
|
|
1407
|
+
identificationType: this.input.customer.documentType === X.Cpf ? "CPF" : "CNPJ",
|
|
1278
1408
|
identificationNumber: this.input.customer.documentNumber
|
|
1279
|
-
}).catch((
|
|
1280
|
-
throw new Error(this.describeMercadoPagoError(
|
|
1409
|
+
}).catch((y) => {
|
|
1410
|
+
throw new Error(this.describeMercadoPagoError(y));
|
|
1281
1411
|
});
|
|
1282
|
-
if ("id" in
|
|
1283
|
-
throw new Error(this.describeMercadoPagoError(
|
|
1412
|
+
if ("id" in l && l.id) return l.id;
|
|
1413
|
+
throw new Error(this.describeMercadoPagoError(l));
|
|
1284
1414
|
}
|
|
1285
1415
|
describeMercadoPagoError(t) {
|
|
1286
1416
|
if (typeof t == "string") return t;
|
|
@@ -1294,13 +1424,13 @@ class Je extends We {
|
|
|
1294
1424
|
return "Failed to tokenize card";
|
|
1295
1425
|
}
|
|
1296
1426
|
}
|
|
1297
|
-
const
|
|
1298
|
-
[
|
|
1427
|
+
const et = {
|
|
1428
|
+
[T.MercadoPago]: Qe
|
|
1299
1429
|
};
|
|
1300
|
-
class
|
|
1430
|
+
class tt {
|
|
1301
1431
|
constructor(a) {
|
|
1302
|
-
|
|
1303
|
-
this.publicKey = a, this.api = new
|
|
1432
|
+
P(this, "api");
|
|
1433
|
+
this.publicKey = a, this.api = new Xe(this.publicKey);
|
|
1304
1434
|
}
|
|
1305
1435
|
async tokenizeCard(a) {
|
|
1306
1436
|
this.validateCard(a);
|
|
@@ -1312,16 +1442,16 @@ class Ze {
|
|
|
1312
1442
|
customer: a.customer,
|
|
1313
1443
|
saveCard: !1
|
|
1314
1444
|
}), {
|
|
1315
|
-
settings:
|
|
1316
|
-
} = await this.api.getSettings(), s = (await Promise.all(
|
|
1317
|
-
const o =
|
|
1445
|
+
settings: r
|
|
1446
|
+
} = await this.api.getSettings(), s = (await Promise.all(r.map(async (d) => {
|
|
1447
|
+
const o = et[d.key];
|
|
1318
1448
|
if (!o) return null;
|
|
1319
|
-
const
|
|
1449
|
+
const l = new o({
|
|
1320
1450
|
...a,
|
|
1321
1451
|
setting: d.settings
|
|
1322
1452
|
});
|
|
1323
|
-
return await L(
|
|
1324
|
-
token: await
|
|
1453
|
+
return await L(l.scriptUrl), {
|
|
1454
|
+
token: await l.tokenize(),
|
|
1325
1455
|
integrationId: d.integrationId,
|
|
1326
1456
|
providerKey: d.key
|
|
1327
1457
|
};
|
|
@@ -1332,70 +1462,71 @@ class Ze {
|
|
|
1332
1462
|
const {
|
|
1333
1463
|
number: t,
|
|
1334
1464
|
cvv: n,
|
|
1335
|
-
expiration:
|
|
1336
|
-
holderName:
|
|
1465
|
+
expiration: r,
|
|
1466
|
+
holderName: i
|
|
1337
1467
|
} = a.card;
|
|
1338
|
-
if (!t || !n || !(
|
|
1468
|
+
if (!t || !n || !(r != null && r.month) || !(r != null && r.year) || !i)
|
|
1339
1469
|
throw new Error("Invalid card data");
|
|
1340
1470
|
}
|
|
1341
1471
|
}
|
|
1342
|
-
function
|
|
1343
|
-
const a = new
|
|
1472
|
+
function ft(e) {
|
|
1473
|
+
const a = new tt(e.publicKey);
|
|
1344
1474
|
return {
|
|
1345
1475
|
tokenizeCard: async (n) => {
|
|
1346
|
-
var
|
|
1476
|
+
var r, i;
|
|
1347
1477
|
try {
|
|
1348
1478
|
const s = await a.tokenizeCard(n);
|
|
1349
|
-
return (
|
|
1479
|
+
return (r = e.onSuccess) == null || r.call(e, s), s;
|
|
1350
1480
|
} catch (s) {
|
|
1351
1481
|
const d = s instanceof Error ? s : new Error("Tokenization failed");
|
|
1352
|
-
return (
|
|
1482
|
+
return (i = e.onError) == null || i.call(e, d), null;
|
|
1353
1483
|
}
|
|
1354
1484
|
}
|
|
1355
1485
|
};
|
|
1356
1486
|
}
|
|
1357
1487
|
export {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1488
|
+
Se as ALLOWED_ORIGINS,
|
|
1489
|
+
me as CardBrand,
|
|
1490
|
+
j as ChargeStatusDetail,
|
|
1491
|
+
fe as CurrencyType,
|
|
1492
|
+
ye as DeviceType,
|
|
1493
|
+
X as DocumentType,
|
|
1494
|
+
st as ERROR_CODES,
|
|
1495
|
+
Ee as ErrorCode,
|
|
1496
|
+
we as IFRAME_BASE_URL,
|
|
1497
|
+
G as IFRAME_DEFAULT_HEIGHT_VALUE,
|
|
1498
|
+
v as IncomingMessage,
|
|
1499
|
+
ge as InputStyleKey,
|
|
1500
|
+
T as IntegrationProvider,
|
|
1501
|
+
k as OrganizationEnvironment,
|
|
1502
|
+
D as OutgoingMessage,
|
|
1503
|
+
w as POST_MESSAGES,
|
|
1504
|
+
dt as PayConductor,
|
|
1505
|
+
We as PayConductor3DSSDK,
|
|
1506
|
+
ct as PayConductorCheckoutElement,
|
|
1507
|
+
lt as PayConductorThreeDSElement,
|
|
1508
|
+
tt as PayConductorTokenizerSDK,
|
|
1509
|
+
ce as PaymentMethod,
|
|
1510
|
+
le as PaymentMethodLayout,
|
|
1511
|
+
R as PaymentStatus,
|
|
1512
|
+
be as REQUEST_TIMEOUT,
|
|
1513
|
+
M as SDK_API_BASE_URL,
|
|
1514
|
+
Pe as SKELETON_CSS,
|
|
1515
|
+
Y as SKELETON_STYLE_ID,
|
|
1516
|
+
H as ThreeDSMode,
|
|
1517
|
+
he as ThreeDSResultStatus,
|
|
1518
|
+
_ as ThreeDSTransStatus,
|
|
1519
|
+
S as ThreeDSecureResultStatus,
|
|
1520
|
+
ue as ThreeDsAuthenticationStatus,
|
|
1521
|
+
Ce as buildIframeUrl,
|
|
1522
|
+
dt as default,
|
|
1523
|
+
ot as defaultTheme,
|
|
1524
|
+
pe as generateRequestId,
|
|
1525
|
+
Ae as isValidOrigin,
|
|
1395
1526
|
L as loadScript,
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1527
|
+
ut as usePayConductor,
|
|
1528
|
+
ht as usePayconductorElement,
|
|
1529
|
+
mt as useThreeDS,
|
|
1530
|
+
ft as useTokenizer
|
|
1400
1531
|
};
|
|
1401
1532
|
//# sourceMappingURL=index.es.js.map
|