@payconductor/react 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.cjs.js +13 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +392 -264
- package/dist/index.es.js.map +1 -1
- package/dist/payconductor/constants.d.ts +1 -0
- package/dist/payconductor/hooks/use-element.d.ts +1 -1
- package/dist/payconductor/iframe/types.d.ts +3 -1
- package/dist/payconductor/internal.d.ts +1 -1
- package/dist/payconductor/types.d.ts +1 -3
- package/dist/payconductor/utils.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,22 +1,70 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
4
|
-
var
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsx as _, jsxs as H } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useEffect as O, useRef as V } from "react";
|
|
3
|
+
const x = "https://iframe.payconductor.ai/v1", F = "http://localhost:5175/v1", B = 3e4, Y = "600px";
|
|
4
|
+
var G = /* @__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))(G || {}), K = /* @__PURE__ */ ((e) => (e.Grid = "grid", e.Vertical = "vertical", e.Horizontal = "horizontal", e))(K || {}), W = /* @__PURE__ */ ((e) => (e.Succeeded = "succeeded", e.Pending = "pending", e.Failed = "failed", e))(W || {}), q = /* @__PURE__ */ ((e) => (e.Android = "android", e.IOS = "ios", e.Web = "web", e))(q || {}), z = /* @__PURE__ */ ((e) => (e.Padding = "padding", e.Radius = "radius", e.Color = "color", e.Background = "background", e.Shadow = "shadow", e))(z || {}), b = /* @__PURE__ */ ((e) => (e.Init = "Init", e.Config = "Config", e.Update = "Update", e.ConfirmPayment = "ConfirmPayment", e.Validate = "Validate", e.Reset = "Reset", e))(b || {}), I = /* @__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))(I || {}), j = /* @__PURE__ */ ((e) => (e.InvalidClient = "InvalidClient", e.InvalidToken = "InvalidToken", e.NetworkError = "NetworkError", e.IframeNotReady = "IframeNotReady", e.PaymentDeclined = "PaymentDeclined", e.ValidationError = "ValidationError", e.Timeout = "Timeout", e))(j || {});
|
|
5
|
+
const se = {
|
|
6
|
+
primaryColor: "#0066ff",
|
|
7
|
+
secondaryColor: "#5a6b7c",
|
|
8
|
+
backgroundColor: "transparent",
|
|
9
|
+
surfaceColor: "#f8fafc",
|
|
10
|
+
textColor: "#0f172a",
|
|
11
|
+
textSecondaryColor: "#64748b",
|
|
12
|
+
errorColor: "#ef4444",
|
|
13
|
+
successColor: "#22c55e",
|
|
14
|
+
warningColor: "#f59e0b",
|
|
15
|
+
borderColor: "#e2e8f0",
|
|
16
|
+
disabledColor: "#cbd5e1",
|
|
17
|
+
fontFamily: '"Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
18
|
+
fontSize: {
|
|
19
|
+
xs: "0.75rem",
|
|
20
|
+
sm: "0.875rem",
|
|
21
|
+
md: "1rem",
|
|
22
|
+
lg: "1.125rem",
|
|
23
|
+
xl: "1.25rem"
|
|
24
|
+
},
|
|
25
|
+
fontWeight: {
|
|
26
|
+
normal: 400,
|
|
27
|
+
medium: 500,
|
|
28
|
+
bold: 600
|
|
29
|
+
},
|
|
30
|
+
lineHeight: "1.5",
|
|
31
|
+
spacing: {
|
|
32
|
+
xs: "4px",
|
|
33
|
+
sm: "8px",
|
|
34
|
+
md: "16px",
|
|
35
|
+
lg: "24px",
|
|
36
|
+
xl: "32px"
|
|
37
|
+
},
|
|
38
|
+
borderRadius: "8px",
|
|
39
|
+
borderWidth: "1px",
|
|
40
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
41
|
+
boxShadowHover: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
|
|
42
|
+
inputBackground: "#ffffff",
|
|
43
|
+
inputBorderColor: "#cbd5e1",
|
|
44
|
+
inputBorderRadius: "8px",
|
|
45
|
+
inputHeight: "44px",
|
|
46
|
+
inputPadding: "12px 16px",
|
|
47
|
+
buttonHeight: "48px",
|
|
48
|
+
buttonPadding: "16px 24px",
|
|
49
|
+
buttonBorderRadius: "8px",
|
|
50
|
+
transitionDuration: "0.2s",
|
|
51
|
+
transitionTimingFunction: "ease"
|
|
52
|
+
}, Z = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") && !window.location.search.includes("production"), Q = Z ? F : x, $ = [F, x], D = Y, p = B, u = {
|
|
53
|
+
INIT: b.Init,
|
|
54
|
+
CONFIG: b.Config,
|
|
55
|
+
UPDATE: b.Update,
|
|
56
|
+
CONFIRM_PAYMENT: b.ConfirmPayment,
|
|
57
|
+
VALIDATE: b.Validate,
|
|
58
|
+
RESET: b.Reset,
|
|
59
|
+
READY: I.Ready,
|
|
60
|
+
ERROR: I.Error,
|
|
61
|
+
PAYMENT_COMPLETE: I.PaymentComplete,
|
|
62
|
+
PAYMENT_FAILED: I.PaymentFailed,
|
|
63
|
+
PAYMENT_PENDING: I.PaymentPending,
|
|
64
|
+
VALIDATION_ERROR: I.ValidationError,
|
|
65
|
+
PAYMENT_METHOD_SELECTED: I.PaymentMethodSelected,
|
|
66
|
+
RESIZE: I.Resize
|
|
67
|
+
}, fe = {
|
|
20
68
|
INVALID_CLIENT: "InvalidClient",
|
|
21
69
|
INVALID_TOKEN: "InvalidToken",
|
|
22
70
|
NETWORK_ERROR: "NetworkError",
|
|
@@ -24,203 +72,234 @@ const B = typeof window < "u" && (window.location.hostname === "localhost" || wi
|
|
|
24
72
|
PAYMENT_DECLINED: "PaymentDeclined",
|
|
25
73
|
VALIDATION_ERROR: "ValidationError",
|
|
26
74
|
TIMEOUT: "Timeout"
|
|
27
|
-
}
|
|
28
|
-
|
|
75
|
+
}, M = "payconductor-skeleton-style", J = `
|
|
76
|
+
@keyframes payconductor-shimmer {
|
|
77
|
+
0% { background-position: -200% 0; }
|
|
78
|
+
100% { background-position: 200% 0; }
|
|
79
|
+
}
|
|
80
|
+
.payconductor-skeleton {
|
|
81
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
82
|
+
background-size: 200% 100%;
|
|
83
|
+
animation: payconductor-shimmer 1.5s infinite linear;
|
|
84
|
+
border-radius: 4px;
|
|
85
|
+
width: 100%;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
function X(e) {
|
|
29
89
|
const r = new URLSearchParams({
|
|
30
90
|
publicKey: e.publicKey
|
|
31
91
|
});
|
|
32
|
-
return `${
|
|
92
|
+
return `${Q}?${r.toString()}`;
|
|
33
93
|
}
|
|
34
|
-
function
|
|
94
|
+
function ee() {
|
|
35
95
|
return crypto.randomUUID();
|
|
36
96
|
}
|
|
37
|
-
function
|
|
38
|
-
return r.some((
|
|
97
|
+
function te(e, r) {
|
|
98
|
+
return r.some((n) => {
|
|
39
99
|
try {
|
|
40
|
-
return new URL(
|
|
100
|
+
return new URL(n).origin === e;
|
|
41
101
|
} catch {
|
|
42
|
-
return
|
|
102
|
+
return n === e;
|
|
43
103
|
}
|
|
44
104
|
});
|
|
45
105
|
}
|
|
46
|
-
function
|
|
106
|
+
function L() {
|
|
47
107
|
return /* @__PURE__ */ new Map();
|
|
48
108
|
}
|
|
49
|
-
function
|
|
50
|
-
return new Promise((
|
|
109
|
+
function A(e, r, n, t) {
|
|
110
|
+
return new Promise((c, s) => {
|
|
51
111
|
if (!e || !("contentWindow" in e)) {
|
|
52
|
-
|
|
112
|
+
s(new Error("Iframe not defined"));
|
|
53
113
|
return;
|
|
54
114
|
}
|
|
55
115
|
if (!(e != null && e.contentWindow)) {
|
|
56
|
-
|
|
116
|
+
s(new Error("Iframe not ready"));
|
|
57
117
|
return;
|
|
58
118
|
}
|
|
59
119
|
if (!r) {
|
|
60
|
-
|
|
120
|
+
s(new Error("Pending requests not initialized"));
|
|
61
121
|
return;
|
|
62
122
|
}
|
|
63
|
-
const
|
|
64
|
-
r.set(
|
|
65
|
-
resolve:
|
|
66
|
-
reject:
|
|
123
|
+
const h = ee();
|
|
124
|
+
r.set(h, {
|
|
125
|
+
resolve: c,
|
|
126
|
+
reject: s
|
|
67
127
|
}), e.contentWindow.postMessage({
|
|
68
|
-
type:
|
|
69
|
-
data:
|
|
70
|
-
requestId:
|
|
128
|
+
type: n,
|
|
129
|
+
data: t,
|
|
130
|
+
requestId: h
|
|
71
131
|
}, "*"), setTimeout(() => {
|
|
72
|
-
r != null && r.has(
|
|
73
|
-
},
|
|
132
|
+
r != null && r.has(h) && (r.delete(h), s(new Error("Request timeout")));
|
|
133
|
+
}, p);
|
|
74
134
|
});
|
|
75
135
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
78
|
-
orderId:
|
|
136
|
+
function ne(e, r, n) {
|
|
137
|
+
return A(e, r, u.CONFIRM_PAYMENT, {
|
|
138
|
+
orderId: n.orderId
|
|
79
139
|
});
|
|
80
140
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
141
|
+
function re(e, r, n) {
|
|
142
|
+
return A(e, r, u.VALIDATE, n);
|
|
83
143
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
144
|
+
function oe(e, r) {
|
|
145
|
+
return A(e, r, u.RESET);
|
|
86
146
|
}
|
|
87
|
-
function
|
|
88
|
-
return
|
|
147
|
+
function ae(e, r, n) {
|
|
148
|
+
return A(e, r, u.CONFIG, n);
|
|
89
149
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
150
|
+
function ie(e, r, n) {
|
|
151
|
+
return A(e, r, u.INIT, n);
|
|
92
152
|
}
|
|
93
|
-
function
|
|
94
|
-
const
|
|
95
|
-
requestId:
|
|
96
|
-
type:
|
|
97
|
-
data:
|
|
98
|
-
error:
|
|
99
|
-
} =
|
|
100
|
-
if (
|
|
101
|
-
if (t
|
|
153
|
+
function de(e, r, n, t, c, s, h, P, T) {
|
|
154
|
+
const y = e.data, {
|
|
155
|
+
requestId: m,
|
|
156
|
+
type: f,
|
|
157
|
+
data: o,
|
|
158
|
+
error: l
|
|
159
|
+
} = y;
|
|
160
|
+
if (f === u.READY) {
|
|
161
|
+
if (t == null || t(), m && (r != null && r.has(m))) {
|
|
102
162
|
const {
|
|
103
163
|
resolve: w
|
|
104
|
-
} = r.get(
|
|
105
|
-
r.delete(
|
|
164
|
+
} = r.get(m);
|
|
165
|
+
r.delete(m), w(o);
|
|
106
166
|
}
|
|
107
167
|
return;
|
|
108
168
|
}
|
|
109
|
-
if (
|
|
110
|
-
if (
|
|
169
|
+
if (te(e.origin, $)) {
|
|
170
|
+
if (m && r && r.has(m)) {
|
|
111
171
|
const {
|
|
112
172
|
resolve: w,
|
|
113
|
-
reject:
|
|
114
|
-
} = r.get(
|
|
115
|
-
r.delete(
|
|
173
|
+
reject: C
|
|
174
|
+
} = r.get(m);
|
|
175
|
+
r.delete(m), l ? C(new Error(String(l.message))) : w(o);
|
|
116
176
|
return;
|
|
117
177
|
}
|
|
118
|
-
if (
|
|
119
|
-
n((
|
|
178
|
+
if (f === u.ERROR) {
|
|
179
|
+
n((l == null ? void 0 : l.message) || "Unknown error"), c == null || c(new Error(String(l == null ? void 0 : l.message)));
|
|
120
180
|
return;
|
|
121
181
|
}
|
|
122
|
-
if (
|
|
123
|
-
|
|
182
|
+
if (f === u.PAYMENT_COMPLETE) {
|
|
183
|
+
o && typeof o == "object" && "status" in o && (s == null || s(o));
|
|
124
184
|
return;
|
|
125
185
|
}
|
|
126
|
-
if (
|
|
127
|
-
|
|
186
|
+
if (f === u.PAYMENT_FAILED) {
|
|
187
|
+
o && typeof o == "object" && "status" in o && (h == null || h(o));
|
|
128
188
|
return;
|
|
129
189
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
190
|
+
if (f === u.PAYMENT_PENDING) {
|
|
191
|
+
o && typeof o == "object" && "status" in o && (P == null || P(o));
|
|
132
192
|
return;
|
|
133
193
|
}
|
|
134
|
-
if (
|
|
135
|
-
|
|
194
|
+
if (f === u.PAYMENT_METHOD_SELECTED) {
|
|
195
|
+
o && typeof o == "object" && "paymentMethod" in o && (T == null || T(o.paymentMethod));
|
|
136
196
|
return;
|
|
137
197
|
}
|
|
198
|
+
u.RESIZE;
|
|
138
199
|
}
|
|
139
200
|
}
|
|
140
|
-
function
|
|
141
|
-
const [r,
|
|
142
|
-
() => !1
|
|
143
|
-
), [n, d] = A(
|
|
201
|
+
function me(e) {
|
|
202
|
+
const [r, n] = N(
|
|
144
203
|
() => !1
|
|
145
|
-
), [
|
|
204
|
+
), [t, c] = N(() => null), [s, h] = N(
|
|
146
205
|
() => ""
|
|
147
|
-
), [P,
|
|
148
|
-
return
|
|
149
|
-
const
|
|
150
|
-
e.debug && console.log("[PayConductor]", ...
|
|
151
|
-
},
|
|
206
|
+
), [P, T] = N(() => null);
|
|
207
|
+
return O(() => {
|
|
208
|
+
const y = (...a) => {
|
|
209
|
+
e.debug && console.log("[PayConductor]", ...a);
|
|
210
|
+
}, m = X({
|
|
152
211
|
publicKey: e.publicKey
|
|
153
212
|
});
|
|
154
|
-
m
|
|
155
|
-
const
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
var
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
213
|
+
h(m), n(!0);
|
|
214
|
+
const f = L();
|
|
215
|
+
let o = !1;
|
|
216
|
+
y("init", e.publicKey), y("iframeUrl", m);
|
|
217
|
+
const l = () => {
|
|
218
|
+
var E, i;
|
|
219
|
+
const a = (i = (E = window.PayConductor) == null ? void 0 : E.frame) == null ? void 0 : i.iframe;
|
|
220
|
+
if (a) {
|
|
221
|
+
if (a instanceof HTMLIFrameElement)
|
|
222
|
+
return a;
|
|
223
|
+
if (typeof a == "object" && a !== null) {
|
|
224
|
+
const d = a;
|
|
225
|
+
if ("current" in d && d.current instanceof HTMLIFrameElement)
|
|
226
|
+
return d.current;
|
|
227
|
+
if ("value" in d && d.value instanceof HTMLIFrameElement)
|
|
228
|
+
return d.value;
|
|
169
229
|
}
|
|
170
|
-
return
|
|
230
|
+
return a;
|
|
171
231
|
}
|
|
172
232
|
return document.querySelector(
|
|
173
233
|
".payconductor-element iframe"
|
|
174
234
|
) ?? void 0;
|
|
175
|
-
},
|
|
235
|
+
}, w = {
|
|
176
236
|
get iframe() {
|
|
177
237
|
return document.querySelector(
|
|
178
238
|
".payconductor-element iframe"
|
|
179
239
|
) ?? null;
|
|
180
240
|
},
|
|
181
|
-
set iframe(
|
|
241
|
+
set iframe(a) {
|
|
182
242
|
},
|
|
183
|
-
iframeUrl:
|
|
184
|
-
isReady: window.PayConductor && window.PayConductor.frame ? window.PayConductor.frame.isReady : !1,
|
|
243
|
+
iframeUrl: m,
|
|
185
244
|
error: null
|
|
186
|
-
},
|
|
245
|
+
}, C = {
|
|
187
246
|
publicKey: e.publicKey,
|
|
188
247
|
theme: e.theme,
|
|
189
248
|
locale: e.locale,
|
|
190
249
|
paymentMethods: e.paymentMethods,
|
|
191
250
|
defaultPaymentMethod: e.defaultPaymentMethod
|
|
192
|
-
},
|
|
193
|
-
confirmPayment: (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
251
|
+
}, S = {
|
|
252
|
+
confirmPayment: (a) => {
|
|
253
|
+
var i;
|
|
254
|
+
y("→ CONFIRM_PAYMENT", {
|
|
255
|
+
orderId: a.orderId
|
|
256
|
+
});
|
|
257
|
+
const E = l();
|
|
258
|
+
return E != null && E.contentWindow && E.contentWindow.postMessage(
|
|
259
|
+
{
|
|
260
|
+
type: u.CONFIG,
|
|
261
|
+
data: {
|
|
262
|
+
publicKey: e.publicKey,
|
|
263
|
+
orderId: a.orderId,
|
|
264
|
+
theme: e.theme,
|
|
265
|
+
locale: e.locale,
|
|
266
|
+
paymentMethods: e.paymentMethods,
|
|
267
|
+
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
268
|
+
showPaymentButtons: e.showPaymentButtons,
|
|
269
|
+
nuPayConfig: e.nuPayConfig
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"*"
|
|
273
|
+
), C.orderId = a.orderId, (i = window.PayConductor) != null && i.config && (window.PayConductor.config.orderId = a.orderId), ne(E, f, a);
|
|
274
|
+
},
|
|
275
|
+
validate: (a) => (y("→ VALIDATE", a), re(l(), f, a)),
|
|
276
|
+
reset: () => (y("→ RESET"), oe(l(), f)),
|
|
198
277
|
getSelectedPaymentMethod: () => P
|
|
199
278
|
};
|
|
200
279
|
window.PayConductor = {
|
|
201
|
-
frame:
|
|
202
|
-
config:
|
|
203
|
-
api:
|
|
280
|
+
frame: w,
|
|
281
|
+
config: C,
|
|
282
|
+
api: S,
|
|
204
283
|
selectedPaymentMethod: P
|
|
205
|
-
},
|
|
284
|
+
}, y("registered"), window.dispatchEvent(
|
|
206
285
|
new CustomEvent("payconductor:registered", {
|
|
207
286
|
detail: window.PayConductor
|
|
208
287
|
})
|
|
209
288
|
);
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
212
|
-
const
|
|
213
|
-
if (!
|
|
214
|
-
|
|
289
|
+
const R = async () => {
|
|
290
|
+
if (!o) {
|
|
291
|
+
const a = l();
|
|
292
|
+
if (!a) {
|
|
293
|
+
y("→ CONFIG skipped: iframe not found");
|
|
215
294
|
return;
|
|
216
295
|
}
|
|
217
|
-
|
|
296
|
+
o = !0, y("→ CONFIG", {
|
|
218
297
|
theme: e.theme,
|
|
219
298
|
locale: e.locale,
|
|
220
299
|
paymentMethods: e.paymentMethods,
|
|
221
300
|
defaultPaymentMethod: e.defaultPaymentMethod,
|
|
222
301
|
showPaymentButtons: e.showPaymentButtons
|
|
223
|
-
}),
|
|
302
|
+
}), ae(a, f, {
|
|
224
303
|
theme: e.theme,
|
|
225
304
|
locale: e.locale,
|
|
226
305
|
paymentMethods: e.paymentMethods,
|
|
@@ -229,69 +308,67 @@ function ae(e) {
|
|
|
229
308
|
nuPayConfig: e.nuPayConfig
|
|
230
309
|
});
|
|
231
310
|
}
|
|
232
|
-
},
|
|
233
|
-
var
|
|
234
|
-
(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
(i) => {
|
|
238
|
-
var a;
|
|
239
|
-
d(i), M.isReady = i, (a = window.PayConductor) != null && a.frame && (window.PayConductor.frame.isReady = i), i && S();
|
|
240
|
-
},
|
|
311
|
+
}, U = (a) => {
|
|
312
|
+
var E;
|
|
313
|
+
(E = a.data) != null && E.type && y("←", a.data.type, a.data.data ?? ""), de(
|
|
314
|
+
a,
|
|
315
|
+
f,
|
|
241
316
|
(i) => {
|
|
242
|
-
var
|
|
243
|
-
|
|
317
|
+
var d;
|
|
318
|
+
c(i), w.error = i, (d = window.PayConductor) != null && d.frame && (window.PayConductor.frame.error = i);
|
|
244
319
|
},
|
|
245
320
|
() => {
|
|
246
321
|
var i;
|
|
247
|
-
(i = e.onReady) == null || i.call(e);
|
|
322
|
+
(i = e.onReady) == null || i.call(e), R();
|
|
248
323
|
},
|
|
249
324
|
(i) => {
|
|
250
|
-
var
|
|
251
|
-
(
|
|
325
|
+
var d;
|
|
326
|
+
(d = e.onError) == null || d.call(e, i);
|
|
252
327
|
},
|
|
253
328
|
(i) => {
|
|
254
|
-
var
|
|
255
|
-
(
|
|
329
|
+
var d;
|
|
330
|
+
(d = e.onPaymentComplete) == null || d.call(e, i);
|
|
256
331
|
},
|
|
257
332
|
(i) => {
|
|
258
|
-
var
|
|
259
|
-
(
|
|
333
|
+
var d;
|
|
334
|
+
(d = e.onPaymentFailed) == null || d.call(e, i);
|
|
260
335
|
},
|
|
261
336
|
(i) => {
|
|
262
|
-
var
|
|
263
|
-
(
|
|
337
|
+
var d;
|
|
338
|
+
(d = e.onPaymentPending) == null || d.call(e, i);
|
|
264
339
|
},
|
|
265
340
|
(i) => {
|
|
266
|
-
var
|
|
267
|
-
|
|
341
|
+
var d;
|
|
342
|
+
T(i), window.PayConductor && (window.PayConductor.selectedPaymentMethod = i), (d = e.onPaymentMethodSelected) == null || d.call(e, i);
|
|
268
343
|
}
|
|
269
344
|
);
|
|
270
345
|
};
|
|
271
|
-
window.addEventListener("message",
|
|
272
|
-
const
|
|
273
|
-
var
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
346
|
+
window.addEventListener("message", U);
|
|
347
|
+
const k = () => {
|
|
348
|
+
var E, i, d;
|
|
349
|
+
const a = l();
|
|
350
|
+
if (!a)
|
|
351
|
+
return !1;
|
|
276
352
|
try {
|
|
277
|
-
if ((((
|
|
278
|
-
return
|
|
353
|
+
if ((((E = a.contentDocument) == null ? void 0 : E.readyState) ?? ((d = (i = a.contentWindow) == null ? void 0 : i.document) == null ? void 0 : d.readyState)) === "complete")
|
|
354
|
+
return R(), !0;
|
|
279
355
|
} catch {
|
|
280
356
|
}
|
|
281
357
|
return !1;
|
|
282
|
-
},
|
|
283
|
-
if (
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
358
|
+
}, v = () => {
|
|
359
|
+
if (k())
|
|
360
|
+
return;
|
|
361
|
+
const a = l();
|
|
362
|
+
if (a) {
|
|
363
|
+
a.addEventListener("load", () => R(), {
|
|
287
364
|
once: !0
|
|
288
365
|
});
|
|
289
366
|
return;
|
|
290
367
|
}
|
|
291
|
-
setTimeout(
|
|
368
|
+
setTimeout(v, 50);
|
|
292
369
|
};
|
|
293
|
-
|
|
294
|
-
}, []), /* @__PURE__ */
|
|
370
|
+
v();
|
|
371
|
+
}, []), /* @__PURE__ */ _(
|
|
295
372
|
"div",
|
|
296
373
|
{
|
|
297
374
|
className: "payconductor",
|
|
@@ -303,152 +380,192 @@ function ae(e) {
|
|
|
303
380
|
}
|
|
304
381
|
);
|
|
305
382
|
}
|
|
306
|
-
function
|
|
307
|
-
const r =
|
|
308
|
-
return
|
|
309
|
-
|
|
310
|
-
|
|
383
|
+
function ye(e) {
|
|
384
|
+
const r = V(null), [n, t] = N(() => ""), [c, s] = N(() => !1), [h, P] = N(() => "");
|
|
385
|
+
return O(() => {
|
|
386
|
+
if (typeof document < "u" && !document.getElementById(M)) {
|
|
387
|
+
const o = document.createElement("style");
|
|
388
|
+
o.id = M, o.textContent = J, document.head.appendChild(o);
|
|
389
|
+
}
|
|
390
|
+
const T = (o) => {
|
|
391
|
+
o != null && o.frame && (t(o.frame.iframeUrl || ""), s(!0), console.log("init", {
|
|
311
392
|
PayConductor: window.PayConductor
|
|
312
393
|
}));
|
|
313
|
-
},
|
|
314
|
-
if (
|
|
315
|
-
|
|
394
|
+
}, y = typeof window < "u" ? window.PayConductor : null;
|
|
395
|
+
if (y)
|
|
396
|
+
T(y);
|
|
316
397
|
else {
|
|
317
|
-
const
|
|
318
|
-
|
|
398
|
+
const o = (l) => {
|
|
399
|
+
T(l.detail), window.removeEventListener("payconductor:registered", o);
|
|
319
400
|
};
|
|
320
|
-
window.addEventListener("payconductor:registered",
|
|
401
|
+
window.addEventListener("payconductor:registered", o);
|
|
321
402
|
}
|
|
322
|
-
|
|
403
|
+
let m = !1;
|
|
404
|
+
const f = (o) => {
|
|
405
|
+
var l, w, C, S;
|
|
406
|
+
if (((l = o.data) == null ? void 0 : l.type) === u.RESIZE && ((C = (w = o.data) == null ? void 0 : w.data) != null && C.height) && P(o.data.data.height + "px"), ((S = o.data) == null ? void 0 : S.type) === u.READY && e.height && !m) {
|
|
407
|
+
m = !0;
|
|
408
|
+
const R = document.querySelector(
|
|
409
|
+
".payconductor-element iframe"
|
|
410
|
+
);
|
|
411
|
+
R != null && R.contentWindow && R.contentWindow.postMessage(
|
|
412
|
+
{
|
|
413
|
+
type: u.CONFIG,
|
|
414
|
+
data: {
|
|
415
|
+
height: e.height
|
|
416
|
+
},
|
|
417
|
+
requestId: "element-height"
|
|
418
|
+
},
|
|
419
|
+
"*"
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
return window.addEventListener("message", f), () => window.removeEventListener("message", f);
|
|
424
|
+
}, []), /* @__PURE__ */ H(
|
|
323
425
|
"div",
|
|
324
426
|
{
|
|
325
427
|
className: "payconductor-element",
|
|
326
428
|
style: {
|
|
327
429
|
width: "100%"
|
|
328
430
|
},
|
|
329
|
-
children:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
width: "100%",
|
|
338
|
-
height: e.height || Q,
|
|
339
|
-
border: "none"
|
|
431
|
+
children: [
|
|
432
|
+
c ? null : /* @__PURE__ */ _(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
className: "payconductor-skeleton",
|
|
436
|
+
style: {
|
|
437
|
+
height: e.height || D
|
|
438
|
+
}
|
|
340
439
|
}
|
|
341
|
-
|
|
342
|
-
|
|
440
|
+
),
|
|
441
|
+
c && n ? /* @__PURE__ */ _(
|
|
442
|
+
"iframe",
|
|
443
|
+
{
|
|
444
|
+
allow: "payment",
|
|
445
|
+
title: "PayConductor",
|
|
446
|
+
ref: r,
|
|
447
|
+
src: n,
|
|
448
|
+
style: {
|
|
449
|
+
width: "100%",
|
|
450
|
+
height: e.height || h || D,
|
|
451
|
+
border: "none"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
) : null
|
|
455
|
+
]
|
|
343
456
|
}
|
|
344
457
|
);
|
|
345
458
|
}
|
|
346
|
-
function
|
|
459
|
+
function Ee() {
|
|
347
460
|
const e = typeof window < "u" ? window.PayConductor : null, r = e != null && e.config ? {
|
|
348
461
|
publicKey: e.config.publicKey,
|
|
349
462
|
orderId: e.config.orderId,
|
|
350
463
|
theme: e.config.theme,
|
|
351
464
|
locale: e.config.locale
|
|
352
|
-
} : {},
|
|
465
|
+
} : {}, n = e != null && e.frame ? {
|
|
353
466
|
iframe: e.frame.iframe,
|
|
354
|
-
isReady: e.frame.isReady,
|
|
355
467
|
error: e.frame.error
|
|
356
468
|
} : {
|
|
357
469
|
iframe: null,
|
|
358
|
-
isReady: !1,
|
|
359
470
|
error: null
|
|
360
471
|
};
|
|
361
472
|
return {
|
|
362
473
|
...r,
|
|
363
|
-
...
|
|
474
|
+
...n
|
|
364
475
|
};
|
|
365
476
|
}
|
|
366
|
-
function
|
|
477
|
+
function g(e) {
|
|
367
478
|
var r;
|
|
368
479
|
if ((r = e == null ? void 0 : e.frame) != null && r.iframe) {
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
480
|
+
const n = e.frame.iframe;
|
|
481
|
+
if (n instanceof HTMLIFrameElement)
|
|
482
|
+
return n;
|
|
483
|
+
if (n && typeof n == "object") {
|
|
484
|
+
if ("current" in n) {
|
|
485
|
+
const t = n.current;
|
|
486
|
+
if (t instanceof HTMLIFrameElement)
|
|
487
|
+
return t;
|
|
375
488
|
}
|
|
376
|
-
if ("value" in
|
|
377
|
-
const
|
|
378
|
-
if (
|
|
489
|
+
if ("value" in n) {
|
|
490
|
+
const t = n.value;
|
|
491
|
+
if (t instanceof HTMLIFrameElement)
|
|
492
|
+
return t;
|
|
379
493
|
}
|
|
380
494
|
}
|
|
381
495
|
}
|
|
382
496
|
return document.querySelector(".payconductor-element iframe") ?? null;
|
|
383
497
|
}
|
|
384
|
-
function
|
|
385
|
-
const e = () => typeof window < "u" ? window.PayConductor : null, r = (
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
498
|
+
function he() {
|
|
499
|
+
const e = () => typeof window < "u" ? window.PayConductor : null, r = (n, t) => {
|
|
500
|
+
const c = e();
|
|
501
|
+
if (!c)
|
|
502
|
+
return;
|
|
503
|
+
const s = g(c);
|
|
504
|
+
s != null && s.contentWindow && s.contentWindow.postMessage({
|
|
505
|
+
type: n,
|
|
506
|
+
data: t
|
|
392
507
|
}, "*");
|
|
393
508
|
};
|
|
394
509
|
return {
|
|
395
|
-
init: async (
|
|
396
|
-
const
|
|
397
|
-
return
|
|
510
|
+
init: async (n) => {
|
|
511
|
+
const t = g(e()), c = L();
|
|
512
|
+
return ie(t || void 0, c, n);
|
|
398
513
|
},
|
|
399
|
-
confirmPayment: async (
|
|
400
|
-
|
|
401
|
-
if (!t.orderId)
|
|
514
|
+
confirmPayment: async (n) => {
|
|
515
|
+
if (!n.orderId)
|
|
402
516
|
throw new Error("Order ID is required");
|
|
403
|
-
|
|
517
|
+
const t = e();
|
|
518
|
+
if (!(t != null && t.api))
|
|
519
|
+
throw new Error("PayConductor not initialized");
|
|
520
|
+
return t.api.confirmPayment(n);
|
|
404
521
|
},
|
|
405
|
-
validate: (
|
|
406
|
-
const
|
|
407
|
-
return
|
|
522
|
+
validate: (n) => {
|
|
523
|
+
const t = e();
|
|
524
|
+
return t ? t.api.validate(n) : Promise.resolve(!1);
|
|
408
525
|
},
|
|
409
526
|
reset: () => {
|
|
410
|
-
const
|
|
411
|
-
return
|
|
527
|
+
const n = e();
|
|
528
|
+
return n ? n.api.reset() : Promise.resolve();
|
|
412
529
|
},
|
|
413
530
|
getSelectedPaymentMethod: () => {
|
|
414
|
-
var
|
|
415
|
-
return ((
|
|
531
|
+
var n;
|
|
532
|
+
return ((n = e()) == null ? void 0 : n.selectedPaymentMethod) ?? null;
|
|
416
533
|
},
|
|
417
|
-
updateConfig: (
|
|
418
|
-
var
|
|
419
|
-
const
|
|
420
|
-
r(
|
|
421
|
-
publicKey:
|
|
422
|
-
orderId:
|
|
423
|
-
theme:
|
|
424
|
-
locale:
|
|
425
|
-
paymentMethods:
|
|
534
|
+
updateConfig: (n) => {
|
|
535
|
+
var c;
|
|
536
|
+
const t = (c = e()) == null ? void 0 : c.config;
|
|
537
|
+
r(u.CONFIG, {
|
|
538
|
+
publicKey: t == null ? void 0 : t.publicKey,
|
|
539
|
+
orderId: t == null ? void 0 : t.orderId,
|
|
540
|
+
theme: n.theme ?? (t == null ? void 0 : t.theme),
|
|
541
|
+
locale: n.locale ?? (t == null ? void 0 : t.locale),
|
|
542
|
+
paymentMethods: n.paymentMethods ?? (t == null ? void 0 : t.paymentMethods)
|
|
426
543
|
});
|
|
427
544
|
},
|
|
428
|
-
|
|
429
|
-
var
|
|
430
|
-
const
|
|
431
|
-
r(
|
|
432
|
-
publicKey:
|
|
433
|
-
orderId:
|
|
434
|
-
theme:
|
|
435
|
-
locale:
|
|
436
|
-
paymentMethods:
|
|
545
|
+
updateOrderId: (n) => {
|
|
546
|
+
var c;
|
|
547
|
+
const t = (c = e()) == null ? void 0 : c.config;
|
|
548
|
+
r(u.CONFIG, {
|
|
549
|
+
publicKey: t == null ? void 0 : t.publicKey,
|
|
550
|
+
orderId: n,
|
|
551
|
+
theme: t == null ? void 0 : t.theme,
|
|
552
|
+
locale: t == null ? void 0 : t.locale,
|
|
553
|
+
paymentMethods: t == null ? void 0 : t.paymentMethods
|
|
437
554
|
});
|
|
438
555
|
},
|
|
439
|
-
update: (
|
|
440
|
-
r(
|
|
556
|
+
update: (n) => {
|
|
557
|
+
r(u.UPDATE, n);
|
|
441
558
|
},
|
|
442
559
|
submit: async () => {
|
|
443
|
-
const
|
|
560
|
+
const n = g(e()), t = L();
|
|
444
561
|
try {
|
|
445
|
-
return await
|
|
562
|
+
return await A(n || void 0, t, u.CONFIRM_PAYMENT, {}), {
|
|
446
563
|
paymentMethod: void 0
|
|
447
564
|
};
|
|
448
|
-
} catch (
|
|
565
|
+
} catch (c) {
|
|
449
566
|
return {
|
|
450
567
|
error: {
|
|
451
|
-
message:
|
|
568
|
+
message: c instanceof Error ? c.message : "Payment failed",
|
|
452
569
|
code: "payment_error",
|
|
453
570
|
type: "payment_error"
|
|
454
571
|
}
|
|
@@ -458,19 +575,30 @@ function ce() {
|
|
|
458
575
|
};
|
|
459
576
|
}
|
|
460
577
|
export {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
578
|
+
$ as ALLOWED_ORIGINS,
|
|
579
|
+
q as DeviceType,
|
|
580
|
+
fe as ERROR_CODES,
|
|
581
|
+
j as ErrorCode,
|
|
582
|
+
Q as IFRAME_BASE_URL,
|
|
583
|
+
D as IFRAME_DEFAULT_HEIGHT_VALUE,
|
|
584
|
+
I as IncomingMessage,
|
|
585
|
+
z as InputStyleKey,
|
|
586
|
+
b as OutgoingMessage,
|
|
587
|
+
u as POST_MESSAGES,
|
|
588
|
+
me as PayConductor,
|
|
589
|
+
ye as PayConductorCheckoutElement,
|
|
590
|
+
G as PaymentMethod,
|
|
591
|
+
K as PaymentMethodLayout,
|
|
592
|
+
W as PaymentStatus,
|
|
593
|
+
p as REQUEST_TIMEOUT,
|
|
594
|
+
J as SKELETON_CSS,
|
|
595
|
+
M as SKELETON_STYLE_ID,
|
|
596
|
+
X as buildIframeUrl,
|
|
597
|
+
me as default,
|
|
598
|
+
se as defaultTheme,
|
|
599
|
+
ee as generateRequestId,
|
|
600
|
+
te as isValidOrigin,
|
|
601
|
+
Ee as usePayConductor,
|
|
602
|
+
he as usePayconductorElement
|
|
475
603
|
};
|
|
476
604
|
//# sourceMappingURL=index.es.js.map
|