@payconductor/react 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/three-ds.d.ts +1 -0
- package/dist/esm/tokenize.d.ts +1 -0
- package/dist/index.cjs.js +37 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +1008 -306
- package/dist/index.es.js.map +1 -1
- package/dist/payconductor/constants.d.ts +1 -1
- package/dist/payconductor/hooks/index.d.ts +4 -0
- package/dist/payconductor/hooks/use-three-ds.d.ts +13 -0
- package/dist/payconductor/hooks/use-tokenize.d.ts +11 -0
- package/dist/payconductor/iframe/constants.d.ts +1 -1
- package/dist/payconductor/iframe/types.d.ts +133 -2
- package/dist/payconductor/internal.d.ts +1 -1
- package/dist/payconductor/loader.d.ts +1 -0
- package/dist/payconductor/payconductor-three-ds.d.ts +5 -0
- package/dist/payconductor/payconductor.d.ts +3 -0
- package/dist/payconductor/three-ds/api.d.ts +12 -0
- package/dist/payconductor/three-ds/browser.d.ts +13 -0
- package/dist/payconductor/three-ds/handler.d.ts +12 -0
- package/dist/payconductor/three-ds/index.d.ts +1 -0
- package/dist/payconductor/three-ds/providers/index.d.ts +6 -0
- package/dist/payconductor/three-ds/providers/mercado-pago.d.ts +9 -0
- package/dist/payconductor/three-ds/providers/pagarme.d.ts +9 -0
- package/dist/payconductor/three-ds/providers/pagseguro.d.ts +7 -0
- package/dist/payconductor/three-ds/providers/payconductor.d.ts +7 -0
- package/dist/payconductor/three-ds/types.d.ts +78 -0
- package/dist/payconductor/tokenize/api.d.ts +26 -0
- package/dist/payconductor/tokenize/index.d.ts +1 -0
- package/dist/payconductor/tokenize/providers/index.d.ts +6 -0
- package/dist/payconductor/tokenize/providers/mercado-pago.d.ts +6 -0
- package/dist/payconductor/tokenize/tokenize.d.ts +9 -0
- package/dist/payconductor/tokenize/types.d.ts +50 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.Shield = "Shield", e.Hopy = "Hopy", 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 = {
|
|
6
9
|
primaryColor: "#0066ff",
|
|
7
10
|
secondaryColor: "#5a6b7c",
|
|
8
11
|
backgroundColor: "transparent",
|
|
@@ -49,22 +52,22 @@ const se = {
|
|
|
49
52
|
buttonBorderRadius: "8px",
|
|
50
53
|
transitionDuration: "0.2s",
|
|
51
54
|
transitionTimingFunction: "ease"
|
|
52
|
-
},
|
|
53
|
-
INIT:
|
|
54
|
-
CONFIG:
|
|
55
|
-
UPDATE:
|
|
56
|
-
CONFIRM_PAYMENT:
|
|
57
|
-
VALIDATE:
|
|
58
|
-
RESET:
|
|
59
|
-
READY:
|
|
60
|
-
ERROR:
|
|
61
|
-
PAYMENT_COMPLETE:
|
|
62
|
-
PAYMENT_FAILED:
|
|
63
|
-
PAYMENT_PENDING:
|
|
64
|
-
VALIDATION_ERROR:
|
|
65
|
-
PAYMENT_METHOD_SELECTED:
|
|
66
|
-
RESIZE:
|
|
67
|
-
},
|
|
55
|
+
}, 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, he = 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 = {
|
|
68
71
|
INVALID_CLIENT: "InvalidClient",
|
|
69
72
|
INVALID_TOKEN: "InvalidToken",
|
|
70
73
|
NETWORK_ERROR: "NetworkError",
|
|
@@ -72,7 +75,7 @@ const se = {
|
|
|
72
75
|
PAYMENT_DECLINED: "PaymentDeclined",
|
|
73
76
|
VALIDATION_ERROR: "ValidationError",
|
|
74
77
|
TIMEOUT: "Timeout"
|
|
75
|
-
},
|
|
78
|
+
}, z = "payconductor-skeleton-style", me = `
|
|
76
79
|
@keyframes payconductor-shimmer {
|
|
77
80
|
0% { background-position: -200% 0; }
|
|
78
81
|
100% { background-position: 200% 0; }
|
|
@@ -85,182 +88,197 @@ const se = {
|
|
|
85
88
|
width: 100%;
|
|
86
89
|
}
|
|
87
90
|
`;
|
|
88
|
-
function
|
|
89
|
-
const
|
|
91
|
+
function fe(e) {
|
|
92
|
+
const n = new URLSearchParams({
|
|
90
93
|
publicKey: e.publicKey
|
|
91
94
|
});
|
|
92
|
-
return `${
|
|
95
|
+
return `${le}?${n.toString()}`;
|
|
93
96
|
}
|
|
94
|
-
function
|
|
97
|
+
function ye() {
|
|
95
98
|
return crypto.randomUUID();
|
|
96
99
|
}
|
|
97
|
-
function
|
|
98
|
-
return
|
|
100
|
+
function we(e, n) {
|
|
101
|
+
return n.some((t) => {
|
|
99
102
|
try {
|
|
100
|
-
return new URL(
|
|
103
|
+
return new URL(t).origin === e;
|
|
101
104
|
} catch {
|
|
102
|
-
return
|
|
105
|
+
return t === e;
|
|
103
106
|
}
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
|
-
function
|
|
109
|
+
function O() {
|
|
107
110
|
return /* @__PURE__ */ new Map();
|
|
108
111
|
}
|
|
109
|
-
function
|
|
110
|
-
return new Promise((
|
|
112
|
+
function D(e, n, t, a) {
|
|
113
|
+
return new Promise((i, o) => {
|
|
111
114
|
if (!e || !("contentWindow" in e)) {
|
|
112
|
-
|
|
115
|
+
o(new Error("Iframe not defined"));
|
|
113
116
|
return;
|
|
114
117
|
}
|
|
115
118
|
if (!(e != null && e.contentWindow)) {
|
|
116
|
-
|
|
119
|
+
o(new Error("Iframe not ready"));
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
|
-
if (!
|
|
120
|
-
|
|
122
|
+
if (!n) {
|
|
123
|
+
o(new Error("Pending requests not initialized"));
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
resolve:
|
|
126
|
-
reject:
|
|
126
|
+
const d = ye();
|
|
127
|
+
n.set(d, {
|
|
128
|
+
resolve: i,
|
|
129
|
+
reject: o
|
|
127
130
|
}), e.contentWindow.postMessage({
|
|
128
|
-
type:
|
|
129
|
-
data:
|
|
130
|
-
requestId:
|
|
131
|
+
type: t,
|
|
132
|
+
data: a,
|
|
133
|
+
requestId: d
|
|
131
134
|
}, "*"), setTimeout(() => {
|
|
132
|
-
|
|
133
|
-
},
|
|
135
|
+
n != null && n.has(d) && (n.delete(d), o(new Error("Request timeout")));
|
|
136
|
+
}, he);
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
+
function Ee(e, n, t) {
|
|
140
|
+
return D(e, n, P.CONFIRM_PAYMENT, t);
|
|
141
|
+
}
|
|
142
|
+
async function ge(e, n, t) {
|
|
143
|
+
return await Ee(e, n, {
|
|
144
|
+
orderId: t.orderId
|
|
139
145
|
});
|
|
140
146
|
}
|
|
141
|
-
function
|
|
142
|
-
return
|
|
147
|
+
function Pe(e, n, t) {
|
|
148
|
+
return D(e, n, P.VALIDATE, t);
|
|
143
149
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
150
|
+
function Se(e, n) {
|
|
151
|
+
return D(e, n, P.RESET);
|
|
146
152
|
}
|
|
147
|
-
function
|
|
148
|
-
return
|
|
153
|
+
function pe(e, n, t) {
|
|
154
|
+
return D(e, n, P.CONFIG, t);
|
|
149
155
|
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
156
|
+
function be(e, n, t) {
|
|
157
|
+
return D(e, n, P.INIT, t);
|
|
152
158
|
}
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
requestId:
|
|
156
|
-
type:
|
|
157
|
-
data:
|
|
158
|
-
error:
|
|
159
|
-
} =
|
|
160
|
-
if (
|
|
161
|
-
if (
|
|
159
|
+
function Ce(e, n, t, a, i, o, d, s, r, l, g, w) {
|
|
160
|
+
const m = e.data, {
|
|
161
|
+
requestId: y,
|
|
162
|
+
type: h,
|
|
163
|
+
data: E,
|
|
164
|
+
error: b
|
|
165
|
+
} = m;
|
|
166
|
+
if (h === P.READY) {
|
|
167
|
+
if (a == null || a(), y && (n != null && n.has(y))) {
|
|
162
168
|
const {
|
|
163
|
-
resolve:
|
|
164
|
-
} =
|
|
165
|
-
|
|
169
|
+
resolve: T
|
|
170
|
+
} = n.get(y);
|
|
171
|
+
n.delete(y), T(E);
|
|
166
172
|
}
|
|
167
173
|
return;
|
|
168
174
|
}
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
175
|
+
if (we(e.origin, ue)) {
|
|
176
|
+
if (y && n && n.has(y)) {
|
|
171
177
|
const {
|
|
172
|
-
resolve:
|
|
173
|
-
reject:
|
|
174
|
-
} =
|
|
175
|
-
|
|
178
|
+
resolve: T,
|
|
179
|
+
reject: x
|
|
180
|
+
} = n.get(y);
|
|
181
|
+
n.delete(y), b ? x(new Error(String(b.message))) : T(E);
|
|
176
182
|
return;
|
|
177
183
|
}
|
|
178
|
-
if (
|
|
179
|
-
|
|
184
|
+
if (h === P.ERROR) {
|
|
185
|
+
t((b == null ? void 0 : b.message) || "Unknown error"), i == null || i(new Error(String(b == null ? void 0 : b.message)));
|
|
180
186
|
return;
|
|
181
187
|
}
|
|
182
|
-
if (
|
|
183
|
-
|
|
188
|
+
if (h === P.PAYMENT_COMPLETE) {
|
|
189
|
+
E && typeof E == "object" && "status" in E && (o == null || o(E));
|
|
184
190
|
return;
|
|
185
191
|
}
|
|
186
|
-
if (
|
|
187
|
-
|
|
192
|
+
if (h === P.PAYMENT_FAILED) {
|
|
193
|
+
E && typeof E == "object" && "status" in E && (d == null || d(E));
|
|
188
194
|
return;
|
|
189
195
|
}
|
|
190
|
-
if (
|
|
191
|
-
|
|
196
|
+
if (h === P.PAYMENT_PENDING) {
|
|
197
|
+
E && typeof E == "object" && "status" in E && (s == null || s(E));
|
|
192
198
|
return;
|
|
193
199
|
}
|
|
194
|
-
if (
|
|
195
|
-
|
|
200
|
+
if (h === P.PAYMENT_METHOD_SELECTED) {
|
|
201
|
+
E && typeof E == "object" && "paymentMethod" in E && (r == null || r(E.paymentMethod));
|
|
196
202
|
return;
|
|
197
203
|
}
|
|
198
|
-
|
|
204
|
+
if (h !== P.RESIZE) {
|
|
205
|
+
if (h === v.ThreeDSChallenge) {
|
|
206
|
+
l == null || l();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (h === v.ThreeDSComplete) {
|
|
210
|
+
g == null || g();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (h === v.ThreeDSFailed) {
|
|
214
|
+
w == null || w();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
199
218
|
}
|
|
200
219
|
}
|
|
201
|
-
function
|
|
202
|
-
const [
|
|
220
|
+
function Ze(e) {
|
|
221
|
+
const [n, t] = A(
|
|
203
222
|
() => !1
|
|
204
|
-
), [
|
|
223
|
+
), [a, i] = A(() => null), [o, d] = A(
|
|
205
224
|
() => ""
|
|
206
|
-
), [
|
|
207
|
-
return
|
|
208
|
-
const
|
|
209
|
-
e.debug && console.log("[PayConductor]", ...
|
|
210
|
-
},
|
|
225
|
+
), [s, r] = A(() => null);
|
|
226
|
+
return F(() => {
|
|
227
|
+
const l = (...u) => {
|
|
228
|
+
e.debug && console.log("[PayConductor]", ...u);
|
|
229
|
+
}, g = fe({
|
|
211
230
|
publicKey: e.publicKey
|
|
212
231
|
});
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
let
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
var
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return d.value;
|
|
232
|
+
d(g), t(!0);
|
|
233
|
+
const w = O();
|
|
234
|
+
let m = !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;
|
|
229
247
|
}
|
|
230
|
-
return
|
|
248
|
+
return u;
|
|
231
249
|
}
|
|
232
250
|
return document.querySelector(
|
|
233
251
|
".payconductor-element iframe"
|
|
234
252
|
) ?? void 0;
|
|
235
|
-
},
|
|
253
|
+
}, h = {
|
|
236
254
|
get iframe() {
|
|
237
255
|
return document.querySelector(
|
|
238
256
|
".payconductor-element iframe"
|
|
239
257
|
) ?? null;
|
|
240
258
|
},
|
|
241
|
-
set iframe(
|
|
259
|
+
set iframe(u) {
|
|
242
260
|
},
|
|
243
|
-
iframeUrl:
|
|
261
|
+
iframeUrl: g,
|
|
244
262
|
error: null
|
|
245
|
-
},
|
|
263
|
+
}, E = {
|
|
246
264
|
publicKey: e.publicKey,
|
|
247
265
|
theme: e.theme,
|
|
248
266
|
locale: e.locale,
|
|
249
267
|
paymentMethods: e.paymentMethods,
|
|
250
268
|
defaultPaymentMethod: e.defaultPaymentMethod
|
|
251
|
-
},
|
|
252
|
-
confirmPayment: (
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
orderId:
|
|
269
|
+
}, b = {
|
|
270
|
+
confirmPayment: (u) => {
|
|
271
|
+
var c;
|
|
272
|
+
l("→ CONFIRM_PAYMENT", {
|
|
273
|
+
orderId: u.orderId
|
|
256
274
|
});
|
|
257
|
-
const
|
|
258
|
-
return
|
|
275
|
+
const S = y();
|
|
276
|
+
return S != null && S.contentWindow && S.contentWindow.postMessage(
|
|
259
277
|
{
|
|
260
|
-
type:
|
|
278
|
+
type: P.CONFIG,
|
|
261
279
|
data: {
|
|
262
280
|
publicKey: e.publicKey,
|
|
263
|
-
orderId:
|
|
281
|
+
orderId: u.orderId,
|
|
264
282
|
theme: e.theme,
|
|
265
283
|
locale: e.locale,
|
|
266
284
|
paymentMethods: e.paymentMethods,
|
|
@@ -270,36 +288,36 @@ function me(e) {
|
|
|
270
288
|
}
|
|
271
289
|
},
|
|
272
290
|
"*"
|
|
273
|
-
),
|
|
291
|
+
), E.orderId = u.orderId, (c = window.PayConductor) != null && c.config && (window.PayConductor.config.orderId = u.orderId), ge(S, w, u);
|
|
274
292
|
},
|
|
275
|
-
validate: (
|
|
276
|
-
reset: () => (
|
|
277
|
-
getSelectedPaymentMethod: () =>
|
|
293
|
+
validate: (u) => (l("→ VALIDATE", u), Pe(y(), w, u)),
|
|
294
|
+
reset: () => (l("→ RESET"), Se(y(), w)),
|
|
295
|
+
getSelectedPaymentMethod: () => s
|
|
278
296
|
};
|
|
279
297
|
window.PayConductor = {
|
|
280
|
-
frame:
|
|
281
|
-
config:
|
|
282
|
-
api:
|
|
283
|
-
selectedPaymentMethod:
|
|
284
|
-
},
|
|
298
|
+
frame: h,
|
|
299
|
+
config: E,
|
|
300
|
+
api: b,
|
|
301
|
+
selectedPaymentMethod: s
|
|
302
|
+
}, l("registered"), window.dispatchEvent(
|
|
285
303
|
new CustomEvent("payconductor:registered", {
|
|
286
304
|
detail: window.PayConductor
|
|
287
305
|
})
|
|
288
306
|
);
|
|
289
|
-
const
|
|
290
|
-
if (!
|
|
291
|
-
const
|
|
292
|
-
if (!
|
|
293
|
-
|
|
307
|
+
const T = async () => {
|
|
308
|
+
if (!m) {
|
|
309
|
+
const u = y();
|
|
310
|
+
if (!u) {
|
|
311
|
+
l("→ CONFIG skipped: iframe not found");
|
|
294
312
|
return;
|
|
295
313
|
}
|
|
296
|
-
|
|
314
|
+
m = !0, l("→ CONFIG", {
|
|
297
315
|
theme: e.theme,
|
|
298
316
|
locale: e.locale,
|
|
299
317
|
paymentMethods: e.paymentMethods,
|
|
300
318
|
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
301
319
|
showPaymentButtons: e.showPaymentButtons
|
|
302
|
-
}),
|
|
320
|
+
}), pe(u, w, {
|
|
303
321
|
theme: e.theme,
|
|
304
322
|
locale: e.locale,
|
|
305
323
|
paymentMethods: e.paymentMethods,
|
|
@@ -308,67 +326,77 @@ function me(e) {
|
|
|
308
326
|
nuPayConfig: e.nuPayConfig
|
|
309
327
|
});
|
|
310
328
|
}
|
|
311
|
-
},
|
|
312
|
-
var
|
|
313
|
-
(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
(
|
|
317
|
-
var
|
|
318
|
-
c
|
|
329
|
+
}, x = (u) => {
|
|
330
|
+
var S;
|
|
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), h.error = c, (f = window.PayConductor) != null && f.frame && (window.PayConductor.frame.error = c);
|
|
319
337
|
},
|
|
320
338
|
() => {
|
|
321
|
-
var
|
|
322
|
-
(
|
|
339
|
+
var c;
|
|
340
|
+
(c = e.onReady) == null || c.call(e), T();
|
|
323
341
|
},
|
|
324
|
-
(
|
|
325
|
-
var
|
|
326
|
-
(
|
|
342
|
+
(c) => {
|
|
343
|
+
var f;
|
|
344
|
+
(f = e.onError) == null || f.call(e, c);
|
|
327
345
|
},
|
|
328
|
-
(
|
|
329
|
-
var
|
|
330
|
-
(
|
|
346
|
+
(c) => {
|
|
347
|
+
var f;
|
|
348
|
+
(f = e.onPaymentComplete) == null || f.call(e, c);
|
|
331
349
|
},
|
|
332
|
-
(
|
|
333
|
-
var
|
|
334
|
-
(
|
|
350
|
+
(c) => {
|
|
351
|
+
var f;
|
|
352
|
+
(f = e.onPaymentFailed) == null || f.call(e, c);
|
|
335
353
|
},
|
|
336
|
-
(
|
|
337
|
-
var
|
|
338
|
-
(
|
|
354
|
+
(c) => {
|
|
355
|
+
var f;
|
|
356
|
+
(f = e.onPaymentPending) == null || f.call(e, c);
|
|
339
357
|
},
|
|
340
|
-
(
|
|
341
|
-
var
|
|
342
|
-
|
|
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);
|
|
365
|
+
},
|
|
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);
|
|
343
373
|
}
|
|
344
374
|
);
|
|
345
375
|
};
|
|
346
|
-
window.addEventListener("message",
|
|
347
|
-
const
|
|
348
|
-
var
|
|
349
|
-
const
|
|
350
|
-
if (!
|
|
351
|
-
return !1;
|
|
376
|
+
window.addEventListener("message", x);
|
|
377
|
+
const V = () => {
|
|
378
|
+
var S, c, f;
|
|
379
|
+
const u = y();
|
|
380
|
+
if (!u) return !1;
|
|
352
381
|
try {
|
|
353
|
-
if ((((
|
|
354
|
-
return
|
|
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")
|
|
383
|
+
return T(), !0;
|
|
355
384
|
} catch {
|
|
356
385
|
}
|
|
357
386
|
return !1;
|
|
358
|
-
},
|
|
359
|
-
if (
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
a.addEventListener("load", () => R(), {
|
|
387
|
+
}, K = () => {
|
|
388
|
+
if (V()) return;
|
|
389
|
+
const u = y();
|
|
390
|
+
if (u) {
|
|
391
|
+
u.addEventListener("load", () => T(), {
|
|
364
392
|
once: !0
|
|
365
393
|
});
|
|
366
394
|
return;
|
|
367
395
|
}
|
|
368
|
-
setTimeout(
|
|
396
|
+
setTimeout(K, 50);
|
|
369
397
|
};
|
|
370
|
-
|
|
371
|
-
}, []), /* @__PURE__ */
|
|
398
|
+
K();
|
|
399
|
+
}, []), /* @__PURE__ */ N(
|
|
372
400
|
"div",
|
|
373
401
|
{
|
|
374
402
|
className: "payconductor",
|
|
@@ -380,37 +408,37 @@ function me(e) {
|
|
|
380
408
|
}
|
|
381
409
|
);
|
|
382
410
|
}
|
|
383
|
-
function
|
|
384
|
-
const
|
|
385
|
-
return
|
|
386
|
-
if (typeof document < "u" && !document.getElementById(
|
|
387
|
-
const
|
|
388
|
-
|
|
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 m = document.createElement("style");
|
|
416
|
+
m.id = z, m.textContent = me, document.head.appendChild(m);
|
|
389
417
|
}
|
|
390
|
-
const
|
|
391
|
-
|
|
418
|
+
const r = (m) => {
|
|
419
|
+
m != null && m.frame && (a(m.frame.iframeUrl || ""), o(!0), console.log("init", {
|
|
392
420
|
PayConductor: window.PayConductor
|
|
393
421
|
}));
|
|
394
|
-
},
|
|
395
|
-
if (
|
|
396
|
-
|
|
422
|
+
}, l = typeof window < "u" ? window.PayConductor : null;
|
|
423
|
+
if (l)
|
|
424
|
+
r(l);
|
|
397
425
|
else {
|
|
398
|
-
const
|
|
399
|
-
|
|
426
|
+
const m = (y) => {
|
|
427
|
+
r(y.detail), window.removeEventListener("payconductor:registered", m);
|
|
400
428
|
};
|
|
401
|
-
window.addEventListener("payconductor:registered",
|
|
429
|
+
window.addEventListener("payconductor:registered", m);
|
|
402
430
|
}
|
|
403
|
-
let
|
|
404
|
-
const
|
|
405
|
-
var
|
|
406
|
-
if (((
|
|
407
|
-
|
|
408
|
-
const
|
|
431
|
+
let g = !1;
|
|
432
|
+
const w = (m) => {
|
|
433
|
+
var y, h, E, b;
|
|
434
|
+
if (((y = m.data) == null ? void 0 : y.type) === P.RESIZE && ((E = (h = m.data) == null ? void 0 : h.data) != null && E.height) && s(m.data.data.height + "px"), ((b = m.data) == null ? void 0 : b.type) === P.READY && e.height && !g) {
|
|
435
|
+
g = !0;
|
|
436
|
+
const T = document.querySelector(
|
|
409
437
|
".payconductor-element iframe"
|
|
410
438
|
);
|
|
411
|
-
|
|
439
|
+
T != null && T.contentWindow && T.contentWindow.postMessage(
|
|
412
440
|
{
|
|
413
|
-
type:
|
|
441
|
+
type: P.CONFIG,
|
|
414
442
|
data: {
|
|
415
443
|
height: e.height
|
|
416
444
|
},
|
|
@@ -420,8 +448,8 @@ function ye(e) {
|
|
|
420
448
|
);
|
|
421
449
|
}
|
|
422
450
|
};
|
|
423
|
-
return window.addEventListener("message",
|
|
424
|
-
}, []), /* @__PURE__ */
|
|
451
|
+
return window.addEventListener("message", w), () => window.removeEventListener("message", w);
|
|
452
|
+
}, []), /* @__PURE__ */ q(
|
|
425
453
|
"div",
|
|
426
454
|
{
|
|
427
455
|
className: "payconductor-element",
|
|
@@ -429,25 +457,25 @@ function ye(e) {
|
|
|
429
457
|
width: "100%"
|
|
430
458
|
},
|
|
431
459
|
children: [
|
|
432
|
-
|
|
460
|
+
i ? null : /* @__PURE__ */ N(
|
|
433
461
|
"div",
|
|
434
462
|
{
|
|
435
463
|
className: "payconductor-skeleton",
|
|
436
464
|
style: {
|
|
437
|
-
height: e.height ||
|
|
465
|
+
height: e.height || B
|
|
438
466
|
}
|
|
439
467
|
}
|
|
440
468
|
),
|
|
441
|
-
|
|
469
|
+
i && t ? /* @__PURE__ */ N(
|
|
442
470
|
"iframe",
|
|
443
471
|
{
|
|
444
472
|
allow: "payment",
|
|
445
473
|
title: "PayConductor",
|
|
446
|
-
ref:
|
|
447
|
-
src:
|
|
474
|
+
ref: n,
|
|
475
|
+
src: t,
|
|
448
476
|
style: {
|
|
449
477
|
width: "100%",
|
|
450
|
-
height: e.height ||
|
|
478
|
+
height: e.height || d || B,
|
|
451
479
|
border: "none"
|
|
452
480
|
}
|
|
453
481
|
}
|
|
@@ -456,13 +484,41 @@ function ye(e) {
|
|
|
456
484
|
}
|
|
457
485
|
);
|
|
458
486
|
}
|
|
459
|
-
function
|
|
460
|
-
const
|
|
487
|
+
function et(e) {
|
|
488
|
+
const [n, t] = A(() => !1);
|
|
489
|
+
return F(() => {
|
|
490
|
+
const a = () => {
|
|
491
|
+
t(!0);
|
|
492
|
+
}, i = () => {
|
|
493
|
+
t(!1);
|
|
494
|
+
};
|
|
495
|
+
return window.addEventListener("payconductor:3ds:show", a), window.addEventListener("payconductor:3ds:hide", i), typeof window < "u" && (window.PayConductor3DS = {
|
|
496
|
+
container: () => document.getElementById("payconductor-3ds-container"),
|
|
497
|
+
show: a,
|
|
498
|
+
hide: i
|
|
499
|
+
}, window.dispatchEvent(new CustomEvent("payconductor:3ds:registered"))), () => {
|
|
500
|
+
window.removeEventListener("payconductor:3ds:show", a), window.removeEventListener("payconductor:3ds:hide", i), window.PayConductor3DS = null;
|
|
501
|
+
};
|
|
502
|
+
}, []), /* @__PURE__ */ N(
|
|
503
|
+
"div",
|
|
504
|
+
{
|
|
505
|
+
className: "payconductor-three-ds",
|
|
506
|
+
id: "payconductor-3ds-container",
|
|
507
|
+
style: {
|
|
508
|
+
width: "100%",
|
|
509
|
+
display: n ? "block" : "none",
|
|
510
|
+
minHeight: n ? e.height || "600px" : "0"
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
function tt() {
|
|
516
|
+
const e = typeof window < "u" ? window.PayConductor : null, n = e != null && e.config ? {
|
|
461
517
|
publicKey: e.config.publicKey,
|
|
462
518
|
orderId: e.config.orderId,
|
|
463
519
|
theme: e.config.theme,
|
|
464
520
|
locale: e.config.locale
|
|
465
|
-
} : {},
|
|
521
|
+
} : {}, t = e != null && e.frame ? {
|
|
466
522
|
iframe: e.frame.iframe,
|
|
467
523
|
error: e.frame.error
|
|
468
524
|
} : {
|
|
@@ -470,102 +526,97 @@ function Ee() {
|
|
|
470
526
|
error: null
|
|
471
527
|
};
|
|
472
528
|
return {
|
|
473
|
-
...
|
|
474
|
-
...
|
|
529
|
+
...n,
|
|
530
|
+
...t
|
|
475
531
|
};
|
|
476
532
|
}
|
|
477
|
-
function
|
|
478
|
-
var
|
|
479
|
-
if ((
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (t instanceof HTMLIFrameElement)
|
|
487
|
-
return t;
|
|
533
|
+
function U(e) {
|
|
534
|
+
var n;
|
|
535
|
+
if ((n = e == null ? void 0 : e.frame) != null && n.iframe) {
|
|
536
|
+
const t = e.frame.iframe;
|
|
537
|
+
if (t instanceof HTMLIFrameElement) return t;
|
|
538
|
+
if (t && typeof t == "object") {
|
|
539
|
+
if ("current" in t) {
|
|
540
|
+
const a = t.current;
|
|
541
|
+
if (a instanceof HTMLIFrameElement) return a;
|
|
488
542
|
}
|
|
489
|
-
if ("value" in
|
|
490
|
-
const
|
|
491
|
-
if (
|
|
492
|
-
return t;
|
|
543
|
+
if ("value" in t) {
|
|
544
|
+
const a = t.value;
|
|
545
|
+
if (a instanceof HTMLIFrameElement) return a;
|
|
493
546
|
}
|
|
494
547
|
}
|
|
495
548
|
}
|
|
496
549
|
return document.querySelector(".payconductor-element iframe") ?? null;
|
|
497
550
|
}
|
|
498
|
-
function
|
|
499
|
-
const e = () => typeof window < "u" ? window.PayConductor : null,
|
|
500
|
-
const
|
|
501
|
-
if (!
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
data: t
|
|
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);
|
|
556
|
+
o != null && o.contentWindow && o.contentWindow.postMessage({
|
|
557
|
+
type: t,
|
|
558
|
+
data: a
|
|
507
559
|
}, "*");
|
|
508
560
|
};
|
|
509
561
|
return {
|
|
510
|
-
init: async (
|
|
511
|
-
const
|
|
512
|
-
return
|
|
562
|
+
init: async (t) => {
|
|
563
|
+
const a = U(e()), i = O();
|
|
564
|
+
return be(a || void 0, i, t);
|
|
513
565
|
},
|
|
514
|
-
confirmPayment: async (
|
|
515
|
-
if (!
|
|
566
|
+
confirmPayment: async (t) => {
|
|
567
|
+
if (!t.orderId)
|
|
516
568
|
throw new Error("Order ID is required");
|
|
517
|
-
const
|
|
518
|
-
if (!(
|
|
519
|
-
|
|
520
|
-
return t.api.confirmPayment(n);
|
|
569
|
+
const a = e();
|
|
570
|
+
if (!(a != null && a.api)) throw new Error("PayConductor not initialized");
|
|
571
|
+
return a.api.confirmPayment(t);
|
|
521
572
|
},
|
|
522
|
-
validate: (
|
|
523
|
-
const
|
|
524
|
-
return
|
|
573
|
+
validate: (t) => {
|
|
574
|
+
const a = e();
|
|
575
|
+
return a ? a.api.validate(t) : Promise.resolve(!1);
|
|
525
576
|
},
|
|
526
577
|
reset: () => {
|
|
527
|
-
const
|
|
528
|
-
return
|
|
578
|
+
const t = e();
|
|
579
|
+
return t ? t.api.reset() : Promise.resolve();
|
|
529
580
|
},
|
|
530
581
|
getSelectedPaymentMethod: () => {
|
|
531
|
-
var
|
|
532
|
-
return ((
|
|
582
|
+
var t;
|
|
583
|
+
return ((t = e()) == null ? void 0 : t.selectedPaymentMethod) ?? null;
|
|
533
584
|
},
|
|
534
|
-
updateConfig: (
|
|
535
|
-
var
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
publicKey:
|
|
539
|
-
orderId:
|
|
540
|
-
theme:
|
|
541
|
-
locale:
|
|
542
|
-
paymentMethods:
|
|
585
|
+
updateConfig: (t) => {
|
|
586
|
+
var i;
|
|
587
|
+
const a = (i = e()) == null ? void 0 : i.config;
|
|
588
|
+
n(P.CONFIG, {
|
|
589
|
+
publicKey: a == null ? void 0 : a.publicKey,
|
|
590
|
+
orderId: a == null ? void 0 : a.orderId,
|
|
591
|
+
theme: t.theme ?? (a == null ? void 0 : a.theme),
|
|
592
|
+
locale: t.locale ?? (a == null ? void 0 : a.locale),
|
|
593
|
+
paymentMethods: t.paymentMethods ?? (a == null ? void 0 : a.paymentMethods)
|
|
543
594
|
});
|
|
544
595
|
},
|
|
545
|
-
updateOrderId: (
|
|
546
|
-
var
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
publicKey:
|
|
550
|
-
orderId:
|
|
551
|
-
theme:
|
|
552
|
-
locale:
|
|
553
|
-
paymentMethods:
|
|
596
|
+
updateOrderId: (t) => {
|
|
597
|
+
var i;
|
|
598
|
+
const a = (i = e()) == null ? void 0 : i.config;
|
|
599
|
+
n(P.CONFIG, {
|
|
600
|
+
publicKey: a == null ? void 0 : a.publicKey,
|
|
601
|
+
orderId: t,
|
|
602
|
+
theme: a == null ? void 0 : a.theme,
|
|
603
|
+
locale: a == null ? void 0 : a.locale,
|
|
604
|
+
paymentMethods: a == null ? void 0 : a.paymentMethods
|
|
554
605
|
});
|
|
555
606
|
},
|
|
556
|
-
update: (
|
|
557
|
-
|
|
607
|
+
update: (t) => {
|
|
608
|
+
n(P.UPDATE, t);
|
|
558
609
|
},
|
|
559
610
|
submit: async () => {
|
|
560
|
-
const
|
|
611
|
+
const t = U(e()), a = O();
|
|
561
612
|
try {
|
|
562
|
-
return await
|
|
613
|
+
return await D(t || void 0, a, P.CONFIRM_PAYMENT, {}), {
|
|
563
614
|
paymentMethod: void 0
|
|
564
615
|
};
|
|
565
|
-
} catch (
|
|
616
|
+
} catch (i) {
|
|
566
617
|
return {
|
|
567
618
|
error: {
|
|
568
|
-
message:
|
|
619
|
+
message: i instanceof Error ? i.message : "Payment failed",
|
|
569
620
|
code: "payment_error",
|
|
570
621
|
type: "payment_error"
|
|
571
622
|
}
|
|
@@ -574,31 +625,682 @@ function he() {
|
|
|
574
625
|
}
|
|
575
626
|
};
|
|
576
627
|
}
|
|
628
|
+
var p = /* @__PURE__ */ ((e) => (e.Success = "Success", e.Failed = "Failed", e.Timeout = "Timeout", e))(p || {});
|
|
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, m, y;
|
|
715
|
+
((w = g.data) == null ? void 0 : w.status) === "COMPLETE" && (this.cleanup(), (y = (m = this.options).onComplete) == null || y.call(m), o({
|
|
716
|
+
status: p.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: p.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: p.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: p.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: p.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: p.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, m, 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((h) => ({
|
|
935
|
+
country: h.countryCode,
|
|
936
|
+
area: h.areaCode,
|
|
937
|
+
number: h.number,
|
|
938
|
+
type: h.type ?? "MOBILE"
|
|
939
|
+
}))) ?? [{
|
|
940
|
+
country: "55",
|
|
941
|
+
area: "11",
|
|
942
|
+
number: "999999999",
|
|
943
|
+
type: "MOBILE"
|
|
944
|
+
}];
|
|
945
|
+
l.some((h) => h.type === "MOBILE") || (l[0].type = "MOBILE");
|
|
946
|
+
try {
|
|
947
|
+
const h = 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 h.status === "AUTH_FLOW_COMPLETED" || h.status === "AUTH_NOT_SUPPORTED" ? ((y = (m = this.options).onComplete) == null || y.call(m), {
|
|
983
|
+
status: p.Success,
|
|
984
|
+
dsTransactionId: h.id
|
|
985
|
+
}) : h.status === "CHANGE_PAYMENT_METHOD" ? this.fail("PagSeguro requires a different payment method") : {
|
|
986
|
+
status: p.Success,
|
|
987
|
+
dsTransactionId: h.id
|
|
988
|
+
};
|
|
989
|
+
} catch (h) {
|
|
990
|
+
return this.fail(h instanceof Error ? h.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: p.Success
|
|
1070
|
+
};
|
|
1071
|
+
const {
|
|
1072
|
+
acquirer: t
|
|
1073
|
+
} = this.data;
|
|
1074
|
+
if (!t)
|
|
1075
|
+
return {
|
|
1076
|
+
status: p.Failed,
|
|
1077
|
+
error: new Error("Missing 3DS acquirer")
|
|
1078
|
+
};
|
|
1079
|
+
const a = Ue[t];
|
|
1080
|
+
if (!a)
|
|
1081
|
+
return {
|
|
1082
|
+
status: p.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 === p.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;
|
|
1099
|
+
return {
|
|
1100
|
+
handleChallenge: async (i) => {
|
|
1101
|
+
var s;
|
|
1102
|
+
if (!(i.status === "NeedChallenge" || i.statusDetail === "ThreeDsAwaitingChallenge"))
|
|
1103
|
+
return {
|
|
1104
|
+
status: p.Success
|
|
1105
|
+
};
|
|
1106
|
+
(s = e == null ? void 0 : e.onChallenge) == null || s.call(e), n = new Ke(i);
|
|
1107
|
+
const d = await n.authenticate({
|
|
1108
|
+
onComplete: e == null ? void 0 : e.onComplete,
|
|
1109
|
+
onError: e == null ? void 0 : e.onError,
|
|
1110
|
+
onTimeout: e == null ? void 0 : e.onTimeout
|
|
1111
|
+
});
|
|
1112
|
+
return n.destroy(), n = null, d;
|
|
1113
|
+
},
|
|
1114
|
+
destroy: () => {
|
|
1115
|
+
n == null || n.destroy(), n = null;
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
class Be extends Error {
|
|
1120
|
+
constructor(n, t) {
|
|
1121
|
+
super(n), this.title = t, this.name = "PayConductorTokenizeApiError";
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
class ze {
|
|
1125
|
+
constructor(n) {
|
|
1126
|
+
this.publicKey = n;
|
|
1127
|
+
}
|
|
1128
|
+
async getSettings() {
|
|
1129
|
+
const n = await fetch(`${this.baseUrl}/card-tokenization/settings`, {
|
|
1130
|
+
method: "GET",
|
|
1131
|
+
headers: this.headers
|
|
1132
|
+
});
|
|
1133
|
+
return n.ok || await this.parseResponseError("Failed to fetch settings", n), await n.json();
|
|
1134
|
+
}
|
|
1135
|
+
async createToken(n) {
|
|
1136
|
+
const t = await fetch(`${this.baseUrl}/card-tokenization/tokenize`, {
|
|
1137
|
+
method: "POST",
|
|
1138
|
+
headers: this.headers,
|
|
1139
|
+
body: JSON.stringify(n)
|
|
1140
|
+
});
|
|
1141
|
+
return t.ok || await this.parseResponseError("Failed to generate token", t), await t.json();
|
|
1142
|
+
}
|
|
1143
|
+
async saveTokens(n, t, a) {
|
|
1144
|
+
const i = await fetch(`${this.baseUrl}/card-tokenization/save-tokens/${t}/${a}`, {
|
|
1145
|
+
method: "POST",
|
|
1146
|
+
headers: this.headers,
|
|
1147
|
+
body: JSON.stringify(n)
|
|
1148
|
+
});
|
|
1149
|
+
i.ok || await this.parseResponseError("Failed to save tokens", i);
|
|
1150
|
+
}
|
|
1151
|
+
async parseResponseError(n, t) {
|
|
1152
|
+
var i, o, d, s;
|
|
1153
|
+
let a = "";
|
|
1154
|
+
try {
|
|
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);
|
|
1157
|
+
} catch {
|
|
1158
|
+
}
|
|
1159
|
+
throw new Be(a, n);
|
|
1160
|
+
}
|
|
1161
|
+
get baseUrl() {
|
|
1162
|
+
return typeof window < "u" && window.location.href.includes("localhost") ? "http://localhost:3000/api/v1/sdk" : "https://payconductor.ai/api/v1/sdk";
|
|
1163
|
+
}
|
|
1164
|
+
get headers() {
|
|
1165
|
+
return {
|
|
1166
|
+
Authorization: `Basic ${btoa(`${this.publicKey}:x`)}`,
|
|
1167
|
+
"Content-Type": "application/json"
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
class He {
|
|
1172
|
+
constructor(n) {
|
|
1173
|
+
this.input = n;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
class Ye extends He {
|
|
1177
|
+
constructor() {
|
|
1178
|
+
super(...arguments);
|
|
1179
|
+
C(this, "scriptUrl", "https://sdk.mercadopago.com/js/v2");
|
|
1180
|
+
}
|
|
1181
|
+
async tokenize() {
|
|
1182
|
+
if (!("publicKey" in this.input.setting))
|
|
1183
|
+
throw new Error("MercadoPago public key is missing in settings");
|
|
1184
|
+
if (!this.input.customer.documentNumber)
|
|
1185
|
+
throw new Error("Customer document number is required for tokenization");
|
|
1186
|
+
const t = window.MercadoPago;
|
|
1187
|
+
if (!t) throw new Error("MercadoPago SDK not available");
|
|
1188
|
+
const a = new t(this.input.setting.publicKey), {
|
|
1189
|
+
expiration: i,
|
|
1190
|
+
cvv: o,
|
|
1191
|
+
number: d,
|
|
1192
|
+
holderName: s
|
|
1193
|
+
} = this.input.card;
|
|
1194
|
+
return (await a.createCardToken({
|
|
1195
|
+
cardExpirationMonth: String(i.month),
|
|
1196
|
+
cardExpirationYear: String(i.year),
|
|
1197
|
+
cardholderName: s,
|
|
1198
|
+
cardNumber: d,
|
|
1199
|
+
securityCode: o,
|
|
1200
|
+
identificationType: this.input.customer.documentType === G.Cpf ? "CPF" : "CNPJ",
|
|
1201
|
+
identificationNumber: this.input.customer.documentNumber
|
|
1202
|
+
})).id;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
const Ge = {
|
|
1206
|
+
[I.MercadoPago]: Ye
|
|
1207
|
+
};
|
|
1208
|
+
class Ve {
|
|
1209
|
+
constructor(n) {
|
|
1210
|
+
C(this, "api");
|
|
1211
|
+
this.publicKey = n, this.api = new ze(this.publicKey);
|
|
1212
|
+
}
|
|
1213
|
+
async tokenizeCard(n) {
|
|
1214
|
+
this.validateCard(n);
|
|
1215
|
+
const {
|
|
1216
|
+
customerId: t,
|
|
1217
|
+
token: a
|
|
1218
|
+
} = await this.api.createToken({
|
|
1219
|
+
card: n.card,
|
|
1220
|
+
customer: n.customer,
|
|
1221
|
+
saveCard: !1
|
|
1222
|
+
}), {
|
|
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,
|
|
1229
|
+
setting: s.settings
|
|
1230
|
+
});
|
|
1231
|
+
return await k(l.scriptUrl), {
|
|
1232
|
+
token: await l.tokenize(),
|
|
1233
|
+
integrationId: s.integrationId,
|
|
1234
|
+
providerKey: s.key
|
|
1235
|
+
};
|
|
1236
|
+
}))).filter((s) => s !== null);
|
|
1237
|
+
return d.length > 0 && await this.api.saveTokens(d, t, a), a;
|
|
1238
|
+
}
|
|
1239
|
+
validateCard(n) {
|
|
1240
|
+
const {
|
|
1241
|
+
number: t,
|
|
1242
|
+
cvv: a,
|
|
1243
|
+
expiration: i,
|
|
1244
|
+
holderName: o
|
|
1245
|
+
} = n.card;
|
|
1246
|
+
if (!t || !a || !(i != null && i.month) || !(i != null && i.year) || !o)
|
|
1247
|
+
throw new Error("Invalid card data");
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function it(e) {
|
|
1251
|
+
const n = new Ve(e.publicKey);
|
|
1252
|
+
return {
|
|
1253
|
+
tokenizeCard: async (a) => {
|
|
1254
|
+
var i, o;
|
|
1255
|
+
try {
|
|
1256
|
+
const d = await n.tokenizeCard(a);
|
|
1257
|
+
return (i = e.onSuccess) == null || i.call(e, d), d;
|
|
1258
|
+
} catch (d) {
|
|
1259
|
+
const s = d instanceof Error ? d : new Error("Tokenization failed");
|
|
1260
|
+
return (o = e.onError) == null || o.call(e, s), null;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
577
1265
|
export {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
+
he as REQUEST_TIMEOUT,
|
|
1290
|
+
me 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
|
|
603
1305
|
};
|
|
604
1306
|
//# sourceMappingURL=index.es.js.map
|