@dekin_dev/react-checkout 0.1.0 → 0.2.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/README.md +25 -4
- package/dist/index.d.ts +34 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -245
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as i, jsxs as k, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as L, useEffect as b, useId as be, useState as g, useMemo as Z, useCallback as E } from "react";
|
|
3
|
+
import { createPortal as we } from "react-dom";
|
|
4
|
+
const ge = {
|
|
5
5
|
name: "hubtel",
|
|
6
6
|
defaultTitle: "Complete Payment",
|
|
7
7
|
supportsPostMessage: !1,
|
|
8
8
|
iframeAllow: "payment *"
|
|
9
|
-
},
|
|
9
|
+
}, Le = {
|
|
10
10
|
name: "moolre",
|
|
11
11
|
defaultTitle: "Complete Payment",
|
|
12
12
|
supportsPostMessage: !1,
|
|
13
13
|
iframeAllow: "payment *"
|
|
14
|
-
},
|
|
14
|
+
}, Te = {
|
|
15
15
|
name: "payswitch",
|
|
16
16
|
defaultTitle: "Complete Payment",
|
|
17
17
|
supportsPostMessage: !1,
|
|
18
18
|
iframeAllow: "payment *"
|
|
19
|
-
},
|
|
19
|
+
}, H = {
|
|
20
20
|
name: "custom",
|
|
21
21
|
defaultTitle: "Complete Payment",
|
|
22
22
|
supportsPostMessage: !1
|
|
23
|
-
},
|
|
24
|
-
hubtel:
|
|
25
|
-
moolre:
|
|
26
|
-
payswitch:
|
|
27
|
-
custom:
|
|
23
|
+
}, Re = {
|
|
24
|
+
hubtel: ge,
|
|
25
|
+
moolre: Le,
|
|
26
|
+
payswitch: Te,
|
|
27
|
+
custom: H
|
|
28
28
|
};
|
|
29
|
-
function
|
|
29
|
+
function Ee(e, r) {
|
|
30
30
|
let t;
|
|
31
|
-
return e ? typeof e == "string" ? t =
|
|
31
|
+
return e ? typeof e == "string" ? t = Re[e] ?? { ...H, name: e } : t = { ...H, ...e } : t = H, r ? { ...t, ...r } : t;
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
function
|
|
33
|
+
const Ne = /* @__PURE__ */ new Set(["javascript:", "data:", "vbscript:", "file:", "blob:"]);
|
|
34
|
+
function Pe(e, r = {}) {
|
|
35
35
|
if (!e || typeof e != "string")
|
|
36
36
|
return { valid: !1, reason: "A checkoutUrl is required." };
|
|
37
37
|
let t;
|
|
@@ -40,13 +40,13 @@ function Te(e, o = {}) {
|
|
|
40
40
|
} catch {
|
|
41
41
|
return { valid: !1, reason: `"${e}" is not a valid URL.` };
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return Ne.has(t.protocol) ? { valid: !1, reason: `Unsafe URL protocol "${t.protocol}" is not allowed.` } : t.protocol !== "https:" && t.protocol !== "http:" ? { valid: !1, reason: `Unsupported URL protocol "${t.protocol}".` } : t.protocol === "http:" && !r.allowInsecureHttp ? {
|
|
44
44
|
valid: !1,
|
|
45
45
|
reason: "checkoutUrl must use HTTPS. Pass allowInsecureHttp to override for local development only."
|
|
46
46
|
} : { valid: !0 };
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return !
|
|
48
|
+
function qe(e, r) {
|
|
49
|
+
return !r || r.length === 0 ? !1 : r.some((t) => {
|
|
50
50
|
try {
|
|
51
51
|
return new URL(t).origin === e;
|
|
52
52
|
} catch {
|
|
@@ -54,47 +54,47 @@ function Re(e, o) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
return function(
|
|
57
|
+
function Ae(e, r) {
|
|
58
|
+
return function(n) {
|
|
59
59
|
if (!!e.allowedOrigins && e.allowedOrigins.length > 0) {
|
|
60
|
-
if (!
|
|
60
|
+
if (!qe(n.origin, e.allowedOrigins)) return;
|
|
61
61
|
} else if (!e.supportsPostMessage)
|
|
62
62
|
return;
|
|
63
63
|
let a = null;
|
|
64
64
|
if (e.messageHandler)
|
|
65
65
|
try {
|
|
66
|
-
a = e.messageHandler(
|
|
66
|
+
a = e.messageHandler(n);
|
|
67
67
|
} catch {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
else if (
|
|
71
|
-
const
|
|
70
|
+
else if (n.data && typeof n.data == "object") {
|
|
71
|
+
const c = n.data;
|
|
72
72
|
a = {
|
|
73
|
-
type: typeof
|
|
73
|
+
type: typeof c.type == "string" ? c.type : "message",
|
|
74
74
|
provider: e.name,
|
|
75
|
-
payload:
|
|
76
|
-
origin:
|
|
75
|
+
payload: n.data,
|
|
76
|
+
origin: n.origin
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
a &&
|
|
79
|
+
a && r({ ...a, origin: n.origin, raw: n });
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
function
|
|
82
|
+
const X = typeof window < "u" && typeof document < "u";
|
|
83
|
+
function S(...e) {
|
|
84
84
|
return e.filter(Boolean).join(" ");
|
|
85
85
|
}
|
|
86
|
-
let
|
|
87
|
-
function
|
|
88
|
-
if (
|
|
89
|
-
if (
|
|
86
|
+
let P = 0, C = "", ee = "";
|
|
87
|
+
function xe() {
|
|
88
|
+
if (X) {
|
|
89
|
+
if (P === 0) {
|
|
90
90
|
const e = window.innerWidth - document.documentElement.clientWidth;
|
|
91
|
-
|
|
91
|
+
C = document.body.style.overflow, ee = document.body.style.paddingRight, document.body.style.overflow = "hidden", e > 0 && (document.body.style.paddingRight = `${e}px`);
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
P += 1;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
96
|
+
function Ie() {
|
|
97
|
+
X && (P = Math.max(0, P - 1), P === 0 && (document.body.style.overflow = C, document.body.style.paddingRight = ee));
|
|
98
98
|
}
|
|
99
99
|
const De = [
|
|
100
100
|
"a[href]",
|
|
@@ -105,102 +105,102 @@ const De = [
|
|
|
105
105
|
"iframe",
|
|
106
106
|
'[tabindex]:not([tabindex="-1"])'
|
|
107
107
|
].join(",");
|
|
108
|
-
function
|
|
108
|
+
function te(e) {
|
|
109
109
|
return Array.from(e.querySelectorAll(De));
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function Ue(e) {
|
|
112
112
|
return function(t) {
|
|
113
113
|
if (t.key !== "Tab") return;
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
114
|
+
const n = te(e);
|
|
115
|
+
if (n.length === 0) {
|
|
116
116
|
t.preventDefault();
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
const
|
|
120
|
-
t.shiftKey ? (
|
|
119
|
+
const o = n[0], a = n[n.length - 1], c = document.activeElement;
|
|
120
|
+
t.shiftKey ? (c === o || !e.contains(c)) && (t.preventDefault(), a.focus()) : (c === a || !e.contains(c)) && (t.preventDefault(), o.focus());
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function O(e) {
|
|
124
124
|
return typeof e == "number" ? `${e}px` : e;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Me({
|
|
127
127
|
id: e,
|
|
128
|
-
title:
|
|
128
|
+
title: r,
|
|
129
129
|
description: t,
|
|
130
|
-
showCloseButton:
|
|
131
|
-
closeOnOverlayClick:
|
|
130
|
+
showCloseButton: n,
|
|
131
|
+
closeOnOverlayClick: o,
|
|
132
132
|
closeOnEscape: a,
|
|
133
|
-
onClose:
|
|
134
|
-
width:
|
|
135
|
-
height:
|
|
136
|
-
maxWidth:
|
|
137
|
-
maxHeight:
|
|
138
|
-
className:
|
|
139
|
-
overlayClassName:
|
|
140
|
-
theme:
|
|
141
|
-
zIndex:
|
|
142
|
-
children:
|
|
133
|
+
onClose: c,
|
|
134
|
+
width: l,
|
|
135
|
+
height: f,
|
|
136
|
+
maxWidth: s,
|
|
137
|
+
maxHeight: y,
|
|
138
|
+
className: h,
|
|
139
|
+
overlayClassName: w,
|
|
140
|
+
theme: T,
|
|
141
|
+
zIndex: q,
|
|
142
|
+
children: $
|
|
143
143
|
}) {
|
|
144
|
-
const
|
|
144
|
+
const R = L(null), A = L(null);
|
|
145
145
|
b(() => {
|
|
146
|
-
|
|
147
|
-
const u =
|
|
148
|
-
return u && (
|
|
149
|
-
var
|
|
150
|
-
|
|
146
|
+
xe(), A.current = document.activeElement;
|
|
147
|
+
const u = R.current;
|
|
148
|
+
return u && (te(u)[0] ?? u).focus(), () => {
|
|
149
|
+
var m, D;
|
|
150
|
+
Ie(), (D = (m = A.current) == null ? void 0 : m.focus) == null || D.call(m);
|
|
151
151
|
};
|
|
152
152
|
}, []), b(() => {
|
|
153
153
|
if (!a) return;
|
|
154
|
-
function u(
|
|
155
|
-
|
|
154
|
+
function u(m) {
|
|
155
|
+
m.key === "Escape" && (m.stopPropagation(), c == null || c());
|
|
156
156
|
}
|
|
157
157
|
return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
|
|
158
|
-
}, [a,
|
|
159
|
-
function S(u) {
|
|
160
|
-
u.key === "Tab" && T.current && Ne(T.current)(u.nativeEvent);
|
|
161
|
-
}
|
|
158
|
+
}, [a, c]);
|
|
162
159
|
function W(u) {
|
|
163
|
-
|
|
160
|
+
u.key === "Tab" && R.current && Ue(R.current)(u.nativeEvent);
|
|
161
|
+
}
|
|
162
|
+
function B(u) {
|
|
163
|
+
o && u.target === u.currentTarget && (c == null || c());
|
|
164
164
|
}
|
|
165
|
-
const
|
|
166
|
-
return /* @__PURE__ */ i("div", { className: "vq-checkout-root", "data-theme":
|
|
165
|
+
const x = `${e}-title`, I = t ? `${e}-description` : void 0;
|
|
166
|
+
return /* @__PURE__ */ i("div", { className: "vq-checkout-root", "data-theme": T, children: /* @__PURE__ */ i(
|
|
167
167
|
"div",
|
|
168
168
|
{
|
|
169
|
-
className:
|
|
170
|
-
onMouseDown:
|
|
171
|
-
style:
|
|
172
|
-
children: /* @__PURE__ */
|
|
169
|
+
className: S("vq-checkout-overlay", w),
|
|
170
|
+
onMouseDown: B,
|
|
171
|
+
style: q !== void 0 ? { zIndex: q } : void 0,
|
|
172
|
+
children: /* @__PURE__ */ k(
|
|
173
173
|
"div",
|
|
174
174
|
{
|
|
175
|
-
ref:
|
|
175
|
+
ref: R,
|
|
176
176
|
id: e,
|
|
177
177
|
role: "dialog",
|
|
178
178
|
"aria-modal": "true",
|
|
179
|
-
"aria-labelledby":
|
|
180
|
-
"aria-label":
|
|
181
|
-
"aria-describedby":
|
|
182
|
-
className:
|
|
179
|
+
"aria-labelledby": r ? x : void 0,
|
|
180
|
+
"aria-label": r ? void 0 : "Checkout",
|
|
181
|
+
"aria-describedby": I,
|
|
182
|
+
className: S("vq-checkout-modal", h),
|
|
183
183
|
style: {
|
|
184
|
-
width:
|
|
185
|
-
height:
|
|
186
|
-
maxWidth:
|
|
187
|
-
maxHeight:
|
|
184
|
+
width: O(l),
|
|
185
|
+
height: O(f),
|
|
186
|
+
maxWidth: O(s),
|
|
187
|
+
maxHeight: O(y)
|
|
188
188
|
},
|
|
189
189
|
tabIndex: -1,
|
|
190
|
-
onKeyDown:
|
|
190
|
+
onKeyDown: W,
|
|
191
191
|
children: [
|
|
192
|
-
(
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
|
|
195
|
-
t && /* @__PURE__ */ i("p", { id:
|
|
192
|
+
(r || t || n) && /* @__PURE__ */ k("div", { className: "vq-checkout-header", children: [
|
|
193
|
+
/* @__PURE__ */ k("div", { className: "vq-checkout-heading", children: [
|
|
194
|
+
r && /* @__PURE__ */ i("h2", { id: x, className: "vq-checkout-title", children: r }),
|
|
195
|
+
t && /* @__PURE__ */ i("p", { id: I, className: "vq-checkout-description", children: t })
|
|
196
196
|
] }),
|
|
197
|
-
|
|
197
|
+
n && /* @__PURE__ */ i(
|
|
198
198
|
"button",
|
|
199
199
|
{
|
|
200
200
|
type: "button",
|
|
201
201
|
className: "vq-checkout-close",
|
|
202
202
|
"aria-label": "Close checkout",
|
|
203
|
-
onClick: () =>
|
|
203
|
+
onClick: () => c == null ? void 0 : c(),
|
|
204
204
|
children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ i(
|
|
205
205
|
"path",
|
|
206
206
|
{
|
|
@@ -213,235 +213,265 @@ function xe({
|
|
|
213
213
|
}
|
|
214
214
|
)
|
|
215
215
|
] }),
|
|
216
|
-
/* @__PURE__ */ i("div", { className: "vq-checkout-body", children:
|
|
216
|
+
/* @__PURE__ */ i("div", { className: "vq-checkout-body", children: $ })
|
|
217
217
|
]
|
|
218
218
|
}
|
|
219
219
|
)
|
|
220
220
|
}
|
|
221
221
|
) });
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function _e({
|
|
224
224
|
src: e,
|
|
225
|
-
title:
|
|
225
|
+
title: r,
|
|
226
226
|
className: t,
|
|
227
|
-
allow:
|
|
228
|
-
sandbox:
|
|
227
|
+
allow: n,
|
|
228
|
+
sandbox: o,
|
|
229
229
|
hidden: a,
|
|
230
|
-
onLoad:
|
|
231
|
-
onError:
|
|
230
|
+
onLoad: c,
|
|
231
|
+
onError: l
|
|
232
232
|
}) {
|
|
233
|
-
const
|
|
234
|
-
return
|
|
235
|
-
const
|
|
236
|
-
if (!
|
|
237
|
-
const
|
|
238
|
-
return
|
|
239
|
-
|
|
233
|
+
const f = L(null), s = L(c), y = L(l);
|
|
234
|
+
return s.current = c, y.current = l, b(() => {
|
|
235
|
+
const h = f.current;
|
|
236
|
+
if (!h) return;
|
|
237
|
+
const w = () => s.current(), T = () => y.current();
|
|
238
|
+
return h.addEventListener("load", w), h.addEventListener("error", T), () => {
|
|
239
|
+
h.removeEventListener("load", w), h.removeEventListener("error", T);
|
|
240
240
|
};
|
|
241
241
|
}, [e]), /* @__PURE__ */ i(
|
|
242
242
|
"iframe",
|
|
243
243
|
{
|
|
244
|
-
ref:
|
|
244
|
+
ref: f,
|
|
245
245
|
src: e,
|
|
246
|
-
title:
|
|
247
|
-
className:
|
|
248
|
-
allow:
|
|
249
|
-
sandbox:
|
|
246
|
+
title: r,
|
|
247
|
+
className: S("vq-checkout-iframe", t),
|
|
248
|
+
allow: n,
|
|
249
|
+
sandbox: o,
|
|
250
250
|
style: a ? { position: "absolute", width: 0, height: 0, opacity: 0 } : void 0
|
|
251
251
|
}
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
255
|
-
return /* @__PURE__ */
|
|
254
|
+
function Oe() {
|
|
255
|
+
return /* @__PURE__ */ k("div", { className: "vq-checkout-state", role: "status", "aria-live": "polite", children: [
|
|
256
256
|
/* @__PURE__ */ i("div", { className: "vq-checkout-spinner", "aria-hidden": "true" }),
|
|
257
257
|
/* @__PURE__ */ i("span", { children: "Loading secure checkout..." })
|
|
258
258
|
] });
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
return /* @__PURE__ */
|
|
260
|
+
function He({ error: e }) {
|
|
261
|
+
return /* @__PURE__ */ k("div", { className: "vq-checkout-state", role: "alert", children: [
|
|
262
262
|
/* @__PURE__ */ i("div", { className: "vq-checkout-error-icon", "aria-hidden": "true", children: "!" }),
|
|
263
263
|
/* @__PURE__ */ i("p", { className: "vq-checkout-error-message", children: e.message })
|
|
264
264
|
] });
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
266
|
+
const Se = {
|
|
267
|
+
success: { icon: "✓", title: "Payment successful", tone: "success" },
|
|
268
|
+
failure: { icon: "✕", title: "Payment failed", tone: "failure" },
|
|
269
|
+
cancel: { icon: "↩", title: "Checkout cancelled", tone: "cancel" }
|
|
270
|
+
};
|
|
271
|
+
function $e({ result: e, onClose: r }) {
|
|
272
|
+
const t = Se[e.type];
|
|
273
|
+
return /* @__PURE__ */ k(
|
|
274
|
+
"div",
|
|
275
|
+
{
|
|
276
|
+
className: "vq-checkout-state",
|
|
277
|
+
role: e.type === "failure" ? "alert" : "status",
|
|
278
|
+
"aria-live": "polite",
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ i("div", { className: `vq-checkout-result-icon vq-checkout-result-icon--${t.tone}`, "aria-hidden": "true", children: t.icon }),
|
|
281
|
+
/* @__PURE__ */ i("p", { className: "vq-checkout-error-message", children: t.title }),
|
|
282
|
+
/* @__PURE__ */ i("button", { type: "button", className: "vq-checkout-result-action", onClick: () => r == null ? void 0 : r(), children: "Close" })
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
const We = "min(95vw, 500px)", Be = "min(90vh, 750px)", Fe = "500px", je = "750px", Ke = "payment *";
|
|
288
|
+
function re({
|
|
268
289
|
open: e,
|
|
269
|
-
checkoutUrl:
|
|
290
|
+
checkoutUrl: r,
|
|
270
291
|
provider: t,
|
|
271
|
-
providerConfig:
|
|
272
|
-
onClose:
|
|
292
|
+
providerConfig: n,
|
|
293
|
+
onClose: o,
|
|
273
294
|
onOpen: a,
|
|
274
|
-
onLoad:
|
|
275
|
-
onError:
|
|
276
|
-
onMessage:
|
|
277
|
-
onSuccess:
|
|
278
|
-
onFailure:
|
|
279
|
-
onCancel:
|
|
280
|
-
title:
|
|
281
|
-
description:
|
|
282
|
-
showCloseButton:
|
|
283
|
-
closeOnOverlayClick:
|
|
284
|
-
closeOnEscape:
|
|
285
|
-
width:
|
|
286
|
-
height:
|
|
287
|
-
maxWidth:
|
|
288
|
-
maxHeight:
|
|
289
|
-
className:
|
|
295
|
+
onLoad: c,
|
|
296
|
+
onError: l,
|
|
297
|
+
onMessage: f,
|
|
298
|
+
onSuccess: s,
|
|
299
|
+
onFailure: y,
|
|
300
|
+
onCancel: h,
|
|
301
|
+
title: w,
|
|
302
|
+
description: T,
|
|
303
|
+
showCloseButton: q = !0,
|
|
304
|
+
closeOnOverlayClick: $ = !0,
|
|
305
|
+
closeOnEscape: R = !0,
|
|
306
|
+
width: A = We,
|
|
307
|
+
height: W = Be,
|
|
308
|
+
maxWidth: B = Fe,
|
|
309
|
+
maxHeight: x = je,
|
|
310
|
+
className: I,
|
|
290
311
|
iframeClassName: u,
|
|
291
|
-
overlayClassName:
|
|
292
|
-
theme:
|
|
293
|
-
zIndex:
|
|
294
|
-
allow:
|
|
295
|
-
sandbox:
|
|
296
|
-
loadingComponent:
|
|
297
|
-
errorComponent:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
312
|
+
overlayClassName: m,
|
|
313
|
+
theme: D = "light",
|
|
314
|
+
zIndex: ne,
|
|
315
|
+
allow: ce,
|
|
316
|
+
sandbox: ie,
|
|
317
|
+
loadingComponent: ae,
|
|
318
|
+
errorComponent: F,
|
|
319
|
+
resultComponent: j,
|
|
320
|
+
autoCloseDelay: K,
|
|
321
|
+
allowInsecureHttp: J,
|
|
322
|
+
id: oe,
|
|
323
|
+
children: le
|
|
301
324
|
}) {
|
|
302
|
-
const
|
|
303
|
-
() =>
|
|
325
|
+
const se = be(), ue = oe ?? `vq-checkout-${se}`, [de, fe] = g(!1), [U, M] = g("loading"), [V, G] = g(null), [N, _] = g(null), Y = L(!1), v = Z(
|
|
326
|
+
() => Ee(t, n),
|
|
304
327
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
305
|
-
[t, JSON.stringify(
|
|
328
|
+
[t, JSON.stringify(n ?? {})]
|
|
306
329
|
);
|
|
307
330
|
b(() => {
|
|
308
|
-
|
|
331
|
+
fe(!0);
|
|
309
332
|
}, []), b(() => {
|
|
310
|
-
e && !
|
|
333
|
+
e && !Y.current && (a == null || a()), Y.current = e;
|
|
311
334
|
}, [e]), b(() => {
|
|
312
335
|
if (!e) return;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
336
|
+
_(null);
|
|
337
|
+
const p = Pe(r, { allowInsecureHttp: J });
|
|
338
|
+
if (!p.valid) {
|
|
339
|
+
const d = {
|
|
316
340
|
code: "INVALID_URL",
|
|
317
|
-
message:
|
|
318
|
-
provider:
|
|
341
|
+
message: p.reason ?? "The provided checkoutUrl is invalid.",
|
|
342
|
+
provider: v.name
|
|
319
343
|
};
|
|
320
|
-
|
|
344
|
+
M("error"), G(d), l == null || l(d);
|
|
321
345
|
return;
|
|
322
346
|
}
|
|
323
|
-
|
|
324
|
-
}, [e,
|
|
325
|
-
if (!e || !
|
|
326
|
-
const
|
|
327
|
-
|
|
347
|
+
M("loading"), G(null);
|
|
348
|
+
}, [e, r, J]), b(() => {
|
|
349
|
+
if (!e || !X) return;
|
|
350
|
+
const p = Ae(v, (d) => {
|
|
351
|
+
f == null || f(d), d.type === "success" ? (_({ type: "success", message: d }), s == null || s(d)) : d.type === "failure" ? (_({ type: "failure", message: d }), y == null || y(d)) : d.type === "cancel" && (_({ type: "cancel", message: d }), h == null || h(d));
|
|
328
352
|
});
|
|
329
|
-
return window.addEventListener("message",
|
|
330
|
-
}, [e,
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
}, [
|
|
334
|
-
const
|
|
353
|
+
return window.addEventListener("message", p), () => window.removeEventListener("message", p);
|
|
354
|
+
}, [e, v, f, s, y, h]);
|
|
355
|
+
const he = E(() => {
|
|
356
|
+
M("loaded"), c == null || c();
|
|
357
|
+
}, [c]), me = E(() => {
|
|
358
|
+
const p = {
|
|
335
359
|
code: "IFRAME_LOAD_ERROR",
|
|
336
360
|
message: "The checkout page could not be loaded.",
|
|
337
|
-
provider:
|
|
361
|
+
provider: v.name
|
|
338
362
|
};
|
|
339
|
-
|
|
340
|
-
}, [
|
|
341
|
-
|
|
342
|
-
}, [
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
363
|
+
M("error"), G(p), l == null || l(p);
|
|
364
|
+
}, [l, v.name]), z = E(() => {
|
|
365
|
+
o == null || o();
|
|
366
|
+
}, [o]);
|
|
367
|
+
if (b(() => {
|
|
368
|
+
if (!N || K === void 0) return;
|
|
369
|
+
const p = setTimeout(() => o == null ? void 0 : o(), K);
|
|
370
|
+
return () => clearTimeout(p);
|
|
371
|
+
}, [N, K, o]), !e || !de) return null;
|
|
372
|
+
const pe = w ?? v.defaultTitle ?? "Checkout", ye = ce ?? v.iframeAllow ?? Ke, ve = ie ?? v.iframeSandbox, ke = /* @__PURE__ */ k(
|
|
373
|
+
Me,
|
|
346
374
|
{
|
|
347
|
-
id:
|
|
348
|
-
title:
|
|
349
|
-
description:
|
|
350
|
-
showCloseButton:
|
|
351
|
-
closeOnOverlayClick:
|
|
352
|
-
closeOnEscape:
|
|
353
|
-
onClose:
|
|
354
|
-
width:
|
|
355
|
-
height:
|
|
356
|
-
maxWidth:
|
|
357
|
-
maxHeight:
|
|
358
|
-
className:
|
|
359
|
-
overlayClassName:
|
|
360
|
-
theme:
|
|
361
|
-
zIndex:
|
|
375
|
+
id: ue,
|
|
376
|
+
title: w ?? v.defaultTitle,
|
|
377
|
+
description: T,
|
|
378
|
+
showCloseButton: q,
|
|
379
|
+
closeOnOverlayClick: $,
|
|
380
|
+
closeOnEscape: R,
|
|
381
|
+
onClose: z,
|
|
382
|
+
width: A,
|
|
383
|
+
height: W,
|
|
384
|
+
maxWidth: B,
|
|
385
|
+
maxHeight: x,
|
|
386
|
+
className: I,
|
|
387
|
+
overlayClassName: m,
|
|
388
|
+
theme: D,
|
|
389
|
+
zIndex: ne,
|
|
362
390
|
children: [
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
391
|
+
N ? typeof j == "function" ? j(N) : j ?? /* @__PURE__ */ i($e, { result: N, onClose: z }) : /* @__PURE__ */ k(Q, { children: [
|
|
392
|
+
U === "loading" && (ae ?? /* @__PURE__ */ i(Oe, {})),
|
|
393
|
+
U === "error" && V && (typeof F == "function" ? F(V) : F ?? /* @__PURE__ */ i(He, { error: V })),
|
|
394
|
+
U !== "error" && /* @__PURE__ */ i(
|
|
395
|
+
_e,
|
|
396
|
+
{
|
|
397
|
+
src: r,
|
|
398
|
+
title: pe,
|
|
399
|
+
className: u,
|
|
400
|
+
allow: ye,
|
|
401
|
+
sandbox: ve,
|
|
402
|
+
hidden: U === "loading",
|
|
403
|
+
onLoad: he,
|
|
404
|
+
onError: me
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
] }),
|
|
408
|
+
le
|
|
379
409
|
]
|
|
380
410
|
}
|
|
381
411
|
);
|
|
382
|
-
return
|
|
412
|
+
return we(ke, document.body);
|
|
383
413
|
}
|
|
384
|
-
function
|
|
414
|
+
function Je({
|
|
385
415
|
children: e,
|
|
386
|
-
buttonClassName:
|
|
416
|
+
buttonClassName: r,
|
|
387
417
|
buttonProps: t,
|
|
388
|
-
onClose:
|
|
389
|
-
...
|
|
418
|
+
onClose: n,
|
|
419
|
+
...o
|
|
390
420
|
}) {
|
|
391
|
-
const [a,
|
|
392
|
-
return /* @__PURE__ */
|
|
421
|
+
const [a, c] = g(!1);
|
|
422
|
+
return /* @__PURE__ */ k(Q, { children: [
|
|
393
423
|
/* @__PURE__ */ i(
|
|
394
424
|
"button",
|
|
395
425
|
{
|
|
396
426
|
type: "button",
|
|
397
|
-
className:
|
|
398
|
-
onClick: () =>
|
|
427
|
+
className: S("vq-checkout-trigger", r),
|
|
428
|
+
onClick: () => c(!0),
|
|
399
429
|
...t,
|
|
400
430
|
children: e
|
|
401
431
|
}
|
|
402
432
|
),
|
|
403
433
|
/* @__PURE__ */ i(
|
|
404
|
-
|
|
434
|
+
re,
|
|
405
435
|
{
|
|
406
|
-
...
|
|
436
|
+
...o,
|
|
407
437
|
open: a,
|
|
408
438
|
onClose: () => {
|
|
409
|
-
|
|
439
|
+
c(!1), n == null || n();
|
|
410
440
|
}
|
|
411
441
|
}
|
|
412
442
|
)
|
|
413
443
|
] });
|
|
414
444
|
}
|
|
415
|
-
function
|
|
416
|
-
const [
|
|
445
|
+
function Ye(e) {
|
|
446
|
+
const [r, t] = g(!1), [n, o] = g(null), a = L(e);
|
|
417
447
|
a.current = e;
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
}, []),
|
|
421
|
-
|
|
448
|
+
const c = E((s) => {
|
|
449
|
+
o({ ...a.current, ...s }), t(!0);
|
|
450
|
+
}, []), l = E(() => t(!1), []), f = E(() => n ? /* @__PURE__ */ i(
|
|
451
|
+
re,
|
|
422
452
|
{
|
|
423
|
-
...
|
|
424
|
-
open:
|
|
453
|
+
...n,
|
|
454
|
+
open: r,
|
|
425
455
|
onClose: () => {
|
|
426
|
-
var
|
|
427
|
-
(
|
|
456
|
+
var s;
|
|
457
|
+
(s = n.onClose) == null || s.call(n), t(!1);
|
|
428
458
|
}
|
|
429
459
|
}
|
|
430
|
-
) : null, [
|
|
431
|
-
return
|
|
432
|
-
() => ({ openCheckout:
|
|
433
|
-
[
|
|
460
|
+
) : null, [n, r]);
|
|
461
|
+
return Z(
|
|
462
|
+
() => ({ openCheckout: c, closeCheckout: l, isOpen: r, CheckoutModal: f }),
|
|
463
|
+
[c, l, r, f]
|
|
434
464
|
);
|
|
435
465
|
}
|
|
436
466
|
export {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
467
|
+
re as Checkout,
|
|
468
|
+
Je as CheckoutButton,
|
|
469
|
+
H as customProviderDefaults,
|
|
470
|
+
ge as hubtelProvider,
|
|
471
|
+
Le as moolreProvider,
|
|
472
|
+
Te as payswitchProvider,
|
|
473
|
+
Ee as resolveProviderConfig,
|
|
474
|
+
Ye as useCheckout,
|
|
475
|
+
Pe as validateCheckoutUrl
|
|
446
476
|
};
|
|
447
477
|
//# sourceMappingURL=index.mjs.map
|