@odus/checkout 0.5.3 → 0.5.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/checkout.es.js +345 -257
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const k = (
|
|
1
|
+
const k = (s) => s === "test" ? "https://sandbox-api.odus.com" : s === "live" ? "https://api.odus.com" : "http://localhost:3000";
|
|
2
2
|
class $ {
|
|
3
3
|
apiKey;
|
|
4
4
|
baseUrl;
|
|
@@ -18,34 +18,34 @@ class $ {
|
|
|
18
18
|
...i
|
|
19
19
|
};
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
21
|
+
const n = await fetch(`${this.baseUrl}${e}`, {
|
|
22
22
|
method: t,
|
|
23
23
|
headers: r,
|
|
24
24
|
body: a ? JSON.stringify(a) : void 0
|
|
25
25
|
});
|
|
26
|
-
if (!
|
|
26
|
+
if (!n.ok) {
|
|
27
27
|
let o;
|
|
28
28
|
try {
|
|
29
|
-
o = await
|
|
29
|
+
o = await n.json();
|
|
30
30
|
} catch (c) {
|
|
31
31
|
console.log("error", c);
|
|
32
32
|
}
|
|
33
33
|
throw {
|
|
34
|
-
message: o?.message[0] || `API request failed: ${
|
|
35
|
-
status:
|
|
36
|
-
statusText:
|
|
34
|
+
message: o?.message[0] || `API request failed: ${n.status} ${n.statusText}`,
|
|
35
|
+
status: n.status,
|
|
36
|
+
statusText: n.statusText,
|
|
37
37
|
details: o
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
return
|
|
41
|
-
} catch (
|
|
42
|
-
throw
|
|
43
|
-
message:
|
|
40
|
+
return n.json();
|
|
41
|
+
} catch (n) {
|
|
42
|
+
throw n instanceof Error ? {
|
|
43
|
+
message: n.message,
|
|
44
44
|
status: 0,
|
|
45
45
|
// Use 0 for network/client errors
|
|
46
46
|
statusText: "Network Error",
|
|
47
|
-
details: { message:
|
|
48
|
-
} :
|
|
47
|
+
details: { message: n.message }
|
|
48
|
+
} : n;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
async authorizePayment({
|
|
@@ -55,10 +55,10 @@ class $ {
|
|
|
55
55
|
token: i,
|
|
56
56
|
returnUrl: r
|
|
57
57
|
}) {
|
|
58
|
-
let
|
|
58
|
+
let n = {};
|
|
59
59
|
if (i && a) {
|
|
60
60
|
const o = a.cardExpiry.replace(/\s+/g, "").split("/"), l = o[0], c = o[1];
|
|
61
|
-
|
|
61
|
+
n = {
|
|
62
62
|
paymentMethodData: {
|
|
63
63
|
type: "card",
|
|
64
64
|
card: {
|
|
@@ -78,7 +78,7 @@ class $ {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
} else
|
|
81
|
-
|
|
81
|
+
n = {
|
|
82
82
|
paymentMethodData: {
|
|
83
83
|
type: "paypal"
|
|
84
84
|
},
|
|
@@ -92,16 +92,16 @@ class $ {
|
|
|
92
92
|
customHeaders: {
|
|
93
93
|
Authorization: `Bearer ${t}`
|
|
94
94
|
},
|
|
95
|
-
body:
|
|
95
|
+
body: n
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
const R = async ({
|
|
100
|
-
id:
|
|
100
|
+
id: s,
|
|
101
101
|
apiKey: e,
|
|
102
102
|
environment: t
|
|
103
103
|
}) => {
|
|
104
|
-
const a = k(t), i = await fetch(`${a}/checkout-profiles/${
|
|
104
|
+
const a = k(t), i = await fetch(`${a}/checkout-profiles/${s}`, {
|
|
105
105
|
method: "GET",
|
|
106
106
|
headers: {
|
|
107
107
|
"Content-Type": "application/json",
|
|
@@ -196,11 +196,11 @@ class O {
|
|
|
196
196
|
return this.state[e];
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function L(
|
|
200
|
-
return new O(
|
|
199
|
+
function L(s) {
|
|
200
|
+
return new O(s);
|
|
201
201
|
}
|
|
202
202
|
function H({
|
|
203
|
-
apiKey:
|
|
203
|
+
apiKey: s,
|
|
204
204
|
profileId: e,
|
|
205
205
|
environment: t
|
|
206
206
|
}) {
|
|
@@ -212,7 +212,7 @@ function H({
|
|
|
212
212
|
try {
|
|
213
213
|
a.setState({ isLoading: !0 });
|
|
214
214
|
const r = await R({
|
|
215
|
-
apiKey:
|
|
215
|
+
apiKey: s,
|
|
216
216
|
id: e,
|
|
217
217
|
environment: t
|
|
218
218
|
});
|
|
@@ -235,9 +235,9 @@ function H({
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
const z = {
|
|
238
|
-
cardNumber: (
|
|
239
|
-
cardExpiry: (
|
|
240
|
-
const t =
|
|
238
|
+
cardNumber: (s) => (s.replace(/\s/g, "").match(/.{1,4}/g) || []).join(" "),
|
|
239
|
+
cardExpiry: (s) => {
|
|
240
|
+
const t = s.replace(/\D/g, "").slice(0, 4);
|
|
241
241
|
return t.length > 2 ? `${t.slice(0, 2)} / ${t.slice(2)}` : t;
|
|
242
242
|
}
|
|
243
243
|
}, D = {
|
|
@@ -312,81 +312,81 @@ const z = {
|
|
|
312
312
|
"comcast.net": ["comcast.com", "comcat.net", "comcst.net", "comcastnet", "comcast.nt", "comcas.net"],
|
|
313
313
|
"verizon.net": ["verizon.com", "verizon.nt", "verizonnet", "verizn.net", "verizon.ne", "verzon.net"],
|
|
314
314
|
"att.net": ["att.com", "at.net", "att.nt", "attnet", "att.ne", "attt.net"]
|
|
315
|
-
}, K = (
|
|
316
|
-
if (!
|
|
315
|
+
}, K = (s) => {
|
|
316
|
+
if (!s || s.includes("."))
|
|
317
317
|
return null;
|
|
318
318
|
const e = ["com", "net", "org", "edu", "gov", "io", "co"];
|
|
319
319
|
for (const t of e) {
|
|
320
|
-
if (
|
|
320
|
+
if (s === "companycok" && t === "co")
|
|
321
321
|
return "company.co";
|
|
322
|
-
if (
|
|
323
|
-
const a =
|
|
324
|
-
return `${
|
|
322
|
+
if (s.endsWith(t) && !s.includes(".")) {
|
|
323
|
+
const a = s.length - t.length;
|
|
324
|
+
return `${s.substring(0, a)}.${t}`;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
return null;
|
|
328
|
-
}, j = (
|
|
329
|
-
if (
|
|
330
|
-
if (e.length === 0) return
|
|
331
|
-
const t = e.length + 1, a =
|
|
328
|
+
}, j = (s, e) => {
|
|
329
|
+
if (s.length === 0) return e.length;
|
|
330
|
+
if (e.length === 0) return s.length;
|
|
331
|
+
const t = e.length + 1, a = s.length + 1, i = Array.from(
|
|
332
332
|
{ length: t },
|
|
333
|
-
(r,
|
|
333
|
+
(r, n) => Array.from({ length: a }, (o, l) => n === 0 ? l : l === 0 ? n : 0)
|
|
334
334
|
);
|
|
335
335
|
for (let r = 1; r < t; r++)
|
|
336
|
-
for (let
|
|
337
|
-
const o = n
|
|
338
|
-
i[r][
|
|
339
|
-
i[r - 1][
|
|
336
|
+
for (let n = 1; n < a; n++) {
|
|
337
|
+
const o = s[n - 1] === e[r - 1] ? 0 : 1;
|
|
338
|
+
i[r][n] = Math.min(
|
|
339
|
+
i[r - 1][n] + 1,
|
|
340
340
|
// deletion
|
|
341
|
-
i[r][
|
|
341
|
+
i[r][n - 1] + 1,
|
|
342
342
|
// insertion
|
|
343
|
-
i[r - 1][
|
|
343
|
+
i[r - 1][n - 1] + o
|
|
344
344
|
// substitution
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
|
-
return i[e.length][
|
|
348
|
-
}, U = (
|
|
347
|
+
return i[e.length][s.length];
|
|
348
|
+
}, U = (s) => {
|
|
349
349
|
let t = null, a = 3;
|
|
350
|
-
const i =
|
|
350
|
+
const i = s.toLowerCase();
|
|
351
351
|
for (const r of Object.keys(D)) {
|
|
352
|
-
const
|
|
353
|
-
|
|
352
|
+
const n = j(i, r);
|
|
353
|
+
n <= 2 && n < a && (a = n, t = r);
|
|
354
354
|
}
|
|
355
355
|
return t;
|
|
356
356
|
}, _ = () => {
|
|
357
|
-
const { t:
|
|
357
|
+
const { t: s } = I();
|
|
358
358
|
return {
|
|
359
359
|
validateEmail: (t) => {
|
|
360
360
|
const a = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
361
361
|
if (!t)
|
|
362
362
|
return {
|
|
363
363
|
isValid: !1,
|
|
364
|
-
message:
|
|
364
|
+
message: s("validation.emailInvalid"),
|
|
365
365
|
suggestion: null
|
|
366
366
|
};
|
|
367
367
|
const i = t.indexOf("@");
|
|
368
368
|
if (i === -1)
|
|
369
369
|
return {
|
|
370
370
|
isValid: !1,
|
|
371
|
-
message:
|
|
371
|
+
message: s("validation.emailInvalid"),
|
|
372
372
|
suggestion: null
|
|
373
373
|
};
|
|
374
|
-
const r = t.substring(0, i),
|
|
375
|
-
if (!
|
|
376
|
-
const l = K(
|
|
374
|
+
const r = t.substring(0, i), n = t.substring(i + 1);
|
|
375
|
+
if (!n.includes(".")) {
|
|
376
|
+
const l = K(n);
|
|
377
377
|
if (l)
|
|
378
378
|
return {
|
|
379
379
|
isValid: !1,
|
|
380
|
-
message:
|
|
380
|
+
message: s("validation.emailSuggestion", {
|
|
381
381
|
email: `${r}@${l}`
|
|
382
382
|
}),
|
|
383
383
|
suggestion: `${r}@${l}`
|
|
384
384
|
};
|
|
385
385
|
for (const c of Object.keys(D))
|
|
386
|
-
if (c.replace(/\./g, "") ===
|
|
386
|
+
if (c.replace(/\./g, "") === n)
|
|
387
387
|
return {
|
|
388
388
|
isValid: !1,
|
|
389
|
-
message:
|
|
389
|
+
message: s("validation.emailSuggestion", {
|
|
390
390
|
email: `${r}@${c}`
|
|
391
391
|
}),
|
|
392
392
|
suggestion: `${r}@${c}`
|
|
@@ -395,15 +395,15 @@ const z = {
|
|
|
395
395
|
if (!a.test(t))
|
|
396
396
|
return {
|
|
397
397
|
isValid: !1,
|
|
398
|
-
message:
|
|
398
|
+
message: s("validation.emailInvalid"),
|
|
399
399
|
suggestion: null
|
|
400
400
|
};
|
|
401
|
-
const o = U(
|
|
402
|
-
if (o && o !==
|
|
401
|
+
const o = U(n);
|
|
402
|
+
if (o && o !== n) {
|
|
403
403
|
const l = `${r}@${o}`;
|
|
404
404
|
return {
|
|
405
405
|
isValid: !1,
|
|
406
|
-
message:
|
|
406
|
+
message: s("validation.emailSuggestion", { email: l }),
|
|
407
407
|
suggestion: l
|
|
408
408
|
};
|
|
409
409
|
}
|
|
@@ -415,7 +415,7 @@ const z = {
|
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
417
|
}, q = () => {
|
|
418
|
-
const { t:
|
|
418
|
+
const { t: s } = I(), { validateEmail: e } = _();
|
|
419
419
|
return {
|
|
420
420
|
email: (t) => {
|
|
421
421
|
const a = e(t);
|
|
@@ -423,21 +423,21 @@ const z = {
|
|
|
423
423
|
},
|
|
424
424
|
name: (t) => {
|
|
425
425
|
if (!t.trim())
|
|
426
|
-
return
|
|
426
|
+
return s("validation.nameRequired");
|
|
427
427
|
},
|
|
428
428
|
cardExpiry: (t) => {
|
|
429
429
|
const a = t.replace(/\s/g, ""), [i, r] = a.split("/").map((u) => u.trim());
|
|
430
430
|
if (!i || !r || i.length !== 2 || r.length !== 2)
|
|
431
|
-
return
|
|
432
|
-
const
|
|
431
|
+
return s("validation.cardExpiryFormat");
|
|
432
|
+
const n = /* @__PURE__ */ new Date(), o = n.getFullYear() % 100, l = n.getMonth() + 1, c = parseInt(i, 10), d = parseInt(r, 10);
|
|
433
433
|
if (c < 1 || c > 12)
|
|
434
|
-
return
|
|
434
|
+
return s("validation.cardExpiryFormat");
|
|
435
435
|
if (d < o || d === o && c < l)
|
|
436
|
-
return
|
|
436
|
+
return s("validation.cardExpiryInvalid");
|
|
437
437
|
}
|
|
438
438
|
};
|
|
439
439
|
}, Y = () => {
|
|
440
|
-
const
|
|
440
|
+
const s = q(), e = L({
|
|
441
441
|
formData: {
|
|
442
442
|
name: "",
|
|
443
443
|
email: "",
|
|
@@ -451,7 +451,7 @@ const z = {
|
|
|
451
451
|
},
|
|
452
452
|
isValid: !1
|
|
453
453
|
}), t = (l, c) => {
|
|
454
|
-
const d =
|
|
454
|
+
const d = s[l];
|
|
455
455
|
return d?.(c);
|
|
456
456
|
}, a = (l) => {
|
|
457
457
|
const c = {};
|
|
@@ -469,24 +469,24 @@ const z = {
|
|
|
469
469
|
const E = {
|
|
470
470
|
...d.formData,
|
|
471
471
|
[l]: u
|
|
472
|
-
},
|
|
472
|
+
}, y = { ...d.errors };
|
|
473
473
|
if (d.touched[l]) {
|
|
474
474
|
const m = t(l, u);
|
|
475
|
-
m ?
|
|
475
|
+
m ? y[l] = m : delete y[l];
|
|
476
476
|
}
|
|
477
477
|
e.setState({
|
|
478
478
|
formData: E,
|
|
479
|
-
errors:
|
|
479
|
+
errors: y,
|
|
480
480
|
isValid: i(E)
|
|
481
481
|
});
|
|
482
|
-
},
|
|
482
|
+
}, n = (l, c) => {
|
|
483
483
|
const d = e.getState(), u = {
|
|
484
484
|
...d.touched,
|
|
485
485
|
[l]: !0
|
|
486
|
-
}, E = t(l, c),
|
|
487
|
-
E ?
|
|
486
|
+
}, E = t(l, c), y = { ...d.errors };
|
|
487
|
+
E ? y[l] = E : delete y[l], e.setState({
|
|
488
488
|
touched: u,
|
|
489
|
-
errors:
|
|
489
|
+
errors: y
|
|
490
490
|
});
|
|
491
491
|
}, o = (l) => {
|
|
492
492
|
const d = {
|
|
@@ -502,12 +502,12 @@ const z = {
|
|
|
502
502
|
getFormState: e.getState.bind(e),
|
|
503
503
|
subscribe: e.subscribe.bind(e),
|
|
504
504
|
handleChange: r,
|
|
505
|
-
handleBlur:
|
|
505
|
+
handleBlur: n,
|
|
506
506
|
setFormData: o,
|
|
507
507
|
reset: e.resetState.bind(e)
|
|
508
508
|
};
|
|
509
509
|
}, G = async ({
|
|
510
|
-
props:
|
|
510
|
+
props: s,
|
|
511
511
|
apiKey: e,
|
|
512
512
|
environment: t
|
|
513
513
|
}) => {
|
|
@@ -519,7 +519,7 @@ const z = {
|
|
|
519
519
|
"Content-Type": "application/json",
|
|
520
520
|
Authorization: `Bearer ${e}`
|
|
521
521
|
},
|
|
522
|
-
body: JSON.stringify(
|
|
522
|
+
body: JSON.stringify(s)
|
|
523
523
|
}
|
|
524
524
|
);
|
|
525
525
|
if (!i.ok)
|
|
@@ -527,7 +527,7 @@ const z = {
|
|
|
527
527
|
return await i.json();
|
|
528
528
|
}, Z = 100, J = 2, W = 2e3, X = 5;
|
|
529
529
|
function Q({
|
|
530
|
-
apiKey:
|
|
530
|
+
apiKey: s,
|
|
531
531
|
// scriptLoaded,
|
|
532
532
|
checkoutProfile: e,
|
|
533
533
|
inputStyles: t,
|
|
@@ -543,14 +543,14 @@ function Q({
|
|
|
543
543
|
isCvvFocused: !1,
|
|
544
544
|
possibleCardType: "unknown"
|
|
545
545
|
});
|
|
546
|
-
let
|
|
546
|
+
let n = null;
|
|
547
547
|
const o = async () => {
|
|
548
548
|
try {
|
|
549
549
|
const m = await G({
|
|
550
550
|
props: {
|
|
551
551
|
allowedOrigins: [globalThis.location.origin]
|
|
552
552
|
},
|
|
553
|
-
apiKey:
|
|
553
|
+
apiKey: s,
|
|
554
554
|
environment: i
|
|
555
555
|
});
|
|
556
556
|
m && (r.setState({
|
|
@@ -573,7 +573,7 @@ function Q({
|
|
|
573
573
|
cardElementId: g.id,
|
|
574
574
|
cvvElementId: f.id,
|
|
575
575
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
576
|
-
}),
|
|
576
|
+
}), n = new globalThis.TokenEx.Iframe("card-element", {
|
|
577
577
|
...m.iframeConfig,
|
|
578
578
|
placeholder: "1234 1234 1234 1234",
|
|
579
579
|
cvvPlaceholder: "CVC",
|
|
@@ -597,34 +597,34 @@ function Q({
|
|
|
597
597
|
base: `${t.base}; border-radius: 0px 0px ${e.styles.borderRadius}px 0px`
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
}),
|
|
600
|
+
}), n.on("load", () => {
|
|
601
601
|
r.setState({ loadingIframe: !1 });
|
|
602
|
-
}),
|
|
602
|
+
}), n.on("autoCompleteValues", function(p) {
|
|
603
603
|
const { nameOnCard: C, cardExp: b } = p;
|
|
604
604
|
a({
|
|
605
605
|
name: C,
|
|
606
606
|
cardExpiry: b
|
|
607
607
|
});
|
|
608
|
-
}),
|
|
608
|
+
}), n.on("validate", function(p) {
|
|
609
609
|
const { isValid: C, isCvvValid: b } = p;
|
|
610
610
|
r.setState({
|
|
611
611
|
isCcValid: C,
|
|
612
612
|
isCvvValid: b
|
|
613
613
|
});
|
|
614
|
-
}),
|
|
614
|
+
}), n.on("focus", function() {
|
|
615
615
|
r.setState({ isFocused: !0 });
|
|
616
|
-
}),
|
|
616
|
+
}), n.on("blur", function() {
|
|
617
617
|
r.setState({ isFocused: !1 });
|
|
618
|
-
}),
|
|
618
|
+
}), n.on("cvvFocus", function() {
|
|
619
619
|
r.setState({ isCvvFocused: !0 });
|
|
620
|
-
}),
|
|
620
|
+
}), n.on("cvvBlur", function() {
|
|
621
621
|
r.setState({ isCvvFocused: !1 });
|
|
622
|
-
}),
|
|
622
|
+
}), n.on(
|
|
623
623
|
"cardTypeChange",
|
|
624
624
|
function({ possibleCardType: p }) {
|
|
625
625
|
r.setState({ possibleCardType: p });
|
|
626
626
|
}
|
|
627
|
-
),
|
|
627
|
+
), n.load();
|
|
628
628
|
}, c = () => {
|
|
629
629
|
let m = 0;
|
|
630
630
|
const g = X;
|
|
@@ -645,8 +645,8 @@ function Q({
|
|
|
645
645
|
if (C && b)
|
|
646
646
|
try {
|
|
647
647
|
l();
|
|
648
|
-
} catch (
|
|
649
|
-
console.error("Failed to create TokenEx iframe:",
|
|
648
|
+
} catch (v) {
|
|
649
|
+
console.error("Failed to create TokenEx iframe:", v);
|
|
650
650
|
}
|
|
651
651
|
else m < g && f();
|
|
652
652
|
}, p);
|
|
@@ -674,32 +674,32 @@ function Q({
|
|
|
674
674
|
console.error("Failed to create TokenEx iframe:", p);
|
|
675
675
|
}
|
|
676
676
|
}, u = async () => {
|
|
677
|
-
|
|
677
|
+
s && await o();
|
|
678
678
|
}, E = () => {
|
|
679
|
-
|
|
680
|
-
},
|
|
681
|
-
|
|
679
|
+
n && (n.remove(), n = null);
|
|
680
|
+
}, y = async (m) => {
|
|
681
|
+
n && (n.on("tokenize", async function(g) {
|
|
682
682
|
await m(g);
|
|
683
|
-
}),
|
|
683
|
+
}), n.tokenize());
|
|
684
684
|
};
|
|
685
685
|
return {
|
|
686
686
|
getState: r.getState.bind(r),
|
|
687
687
|
subscribe: r.subscribe.bind(r),
|
|
688
|
-
tokenize:
|
|
688
|
+
tokenize: y,
|
|
689
689
|
cleanup: E,
|
|
690
690
|
initialize: u
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
|
-
const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", ie = "Vollständiger Name", re = "MM / JJ",
|
|
693
|
+
const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", ie = "Vollständiger Name", re = "MM / JJ", ne = "Das Fenster nicht schließen", se = { pay: "ZAHLEN", submit: "ABSENDEN", getPlan: "MEINEN PLAN ERHALTEN", donate: "spenden", book: "jetzt buchen", order: "jetzt bestellen" }, oe = { emailSuggestion: "Meinten Sie {{email}}?", emailInvalid: "Ihre E-Mail-Adresse ist nicht korrekt", cardExpiryInvalid: "Das Ablaufdatum Ihrer Karte liegt in der Vergangenheit", cardExpiryFormat: "Das Ablaufdatum Ihrer Karte ist unvollständig", cardSecurityFormat: "Der Sicherheitscode Ihrer Karte ist unvollständig", nameRequired: "Gib deinen Namen genau so ein, wie er auf deiner Karte steht", cardNumberInvalid: "Die Kartennummer ist unvollständig" }, le = {
|
|
694
694
|
email: ee,
|
|
695
695
|
cardholderNameLabel: te,
|
|
696
696
|
cardInformation: ae,
|
|
697
697
|
cardholderNamePlaceholder: ie,
|
|
698
698
|
cardExpiry: re,
|
|
699
|
-
loading:
|
|
700
|
-
buttonTexts:
|
|
699
|
+
loading: ne,
|
|
700
|
+
buttonTexts: se,
|
|
701
701
|
validation: oe
|
|
702
|
-
}, ce = "Email", de = "Cardholder name", he = "Card information", me = "Full name on card", ue = "MM / YY", pe = "Do not close the window", fe = { pay: "PAY", submit: "SUBMIT", getPlan: "GET MY PLAN", donate: "DONATE", book: "BOOK NOW", order: "ORDER NOW" }, ge = { emailSuggestion: "Did you mean {{email}}?", emailInvalid: "Your email is not correct", cardExpiryInvalid: "Your card's expiration date is in the past", cardExpiryFormat: "Your card’s expiration date is incomplete", cardSecurityFormat: "Your card’s security code is incomplete", nameRequired: "Please enter the name as it appears on your card", cardNumberInvalid: "Your card number is invalid" },
|
|
702
|
+
}, ce = "Email", de = "Cardholder name", he = "Card information", me = "Full name on card", ue = "MM / YY", pe = "Do not close the window", fe = { pay: "PAY", submit: "SUBMIT", getPlan: "GET MY PLAN", donate: "DONATE", book: "BOOK NOW", order: "ORDER NOW" }, ge = { emailSuggestion: "Did you mean {{email}}?", emailInvalid: "Your email is not correct", cardExpiryInvalid: "Your card's expiration date is in the past", cardExpiryFormat: "Your card’s expiration date is incomplete", cardSecurityFormat: "Your card’s security code is incomplete", nameRequired: "Please enter the name as it appears on your card", cardNumberInvalid: "Your card number is invalid" }, ye = {
|
|
703
703
|
email: ce,
|
|
704
704
|
cardholderNameLabel: de,
|
|
705
705
|
cardInformation: he,
|
|
@@ -708,8 +708,8 @@ const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", i
|
|
|
708
708
|
loading: pe,
|
|
709
709
|
buttonTexts: fe,
|
|
710
710
|
validation: ge
|
|
711
|
-
},
|
|
712
|
-
email:
|
|
711
|
+
}, ve = "Correo electrónico", Ee = "Nombre del titular de la tarjeta", be = "Información de la tarjeta", Ce = "Nombre completo en la tarjeta", Se = "MM / AA", xe = "Por favor, no cierre esta ventana", Fe = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTENER MI PLAN", donate: "DONAR", book: "RESERVAR AHORA", order: "ORDENAR AHORA" }, we = { emailSuggestion: "¿Quisiste decir {{email}}?", emailInvalid: "Su correo electrónico no es válido", cardExpiryInvalid: "La fecha de vencimiento de la tarjeta ya pasó", cardExpiryFormat: "La fecha de vencimiento de su tarjeta está incompleta", cardSecurityFormat: "El código de seguridad de su tarjeta está incompleto", nameRequired: "Por favor, ingrese el nombre tal como aparece en su tarjeta", cardNumberInvalid: "Su número de tarjeta no es válido" }, Le = {
|
|
712
|
+
email: ve,
|
|
713
713
|
cardholderNameLabel: Ee,
|
|
714
714
|
cardInformation: be,
|
|
715
715
|
cardholderNamePlaceholder: Ce,
|
|
@@ -744,16 +744,16 @@ const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", i
|
|
|
744
744
|
loading: Je,
|
|
745
745
|
buttonTexts: We,
|
|
746
746
|
validation: Xe
|
|
747
|
-
}, et = "E-mail", tt = "Nome do titular do cartão", at = "Informações do cartão", it = "Nome completo no cartão", rt = "MM / AA",
|
|
747
|
+
}, et = "E-mail", tt = "Nome do titular do cartão", at = "Informações do cartão", it = "Nome completo no cartão", rt = "MM / AA", nt = "Por favor, não feche esta janela", st = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTER MEU PLANO", donate: "DOAR", book: "RESERVAR AGORA", order: "FAZER PEDIDO" }, ot = { emailSuggestion: "Você quis dizer {{email}}?", emailInvalid: "O seu endereço de e-mail não é válido", cardExpiryInvalid: "A data de validade do seu cartão está no passado", cardExpiryFormat: "A data de validade do seu cartão está incompleta", cardSecurityFormat: "O código de segurança do seu cartão está incompleto", nameRequired: "Por favor, insira o nome conforme aparece no cartão", cardNumberInvalid: "O número do seu cartão é inválido" }, lt = {
|
|
748
748
|
email: et,
|
|
749
749
|
cardholderNameLabel: tt,
|
|
750
750
|
cardInformation: at,
|
|
751
751
|
cardholderNamePlaceholder: it,
|
|
752
752
|
cardExpiry: rt,
|
|
753
|
-
loading:
|
|
754
|
-
buttonTexts:
|
|
753
|
+
loading: nt,
|
|
754
|
+
buttonTexts: st,
|
|
755
755
|
validation: ot
|
|
756
|
-
}, ct = "E-posta", dt = "Kart sahibinin adı", ht = "Kart bilgileri", mt = "Kart üzerindeki tam ad", ut = "AA / YY", pt = "Lütfen pencereyi kapatmayın", ft = { pay: "ÖDE", submit: "GÖNDER", getPlan: "PLANIMI AL", donate: "BAĞIŞ YAP", book: "ŞİMDİ REZERVASYON YAP", order: "ŞİMDİ SİPARİŞ VER" }, gt = { emailSuggestion: "{{email}} demek mi istediniz?", emailInvalid: "E-posta adresiniz geçerli değil", cardExpiryInvalid: "Kartınızın son kullanma tarihi geçmiş", cardExpiryFormat: "Kartınızın son kullanma tarihi eksik", cardSecurityFormat: "Kartınızın güvenlik kodu eksik", nameRequired: "Lütfen kart üzerindeki ismi girin", cardNumberInvalid: "Kart numaranız geçersiz" },
|
|
756
|
+
}, ct = "E-posta", dt = "Kart sahibinin adı", ht = "Kart bilgileri", mt = "Kart üzerindeki tam ad", ut = "AA / YY", pt = "Lütfen pencereyi kapatmayın", ft = { pay: "ÖDE", submit: "GÖNDER", getPlan: "PLANIMI AL", donate: "BAĞIŞ YAP", book: "ŞİMDİ REZERVASYON YAP", order: "ŞİMDİ SİPARİŞ VER" }, gt = { emailSuggestion: "{{email}} demek mi istediniz?", emailInvalid: "E-posta adresiniz geçerli değil", cardExpiryInvalid: "Kartınızın son kullanma tarihi geçmiş", cardExpiryFormat: "Kartınızın son kullanma tarihi eksik", cardSecurityFormat: "Kartınızın güvenlik kodu eksik", nameRequired: "Lütfen kart üzerindeki ismi girin", cardNumberInvalid: "Kart numaranız geçersiz" }, yt = {
|
|
757
757
|
email: ct,
|
|
758
758
|
cardholderNameLabel: dt,
|
|
759
759
|
cardInformation: ht,
|
|
@@ -763,17 +763,17 @@ const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", i
|
|
|
763
763
|
buttonTexts: ft,
|
|
764
764
|
validation: gt
|
|
765
765
|
}, N = {
|
|
766
|
-
en:
|
|
766
|
+
en: ye,
|
|
767
767
|
de: le,
|
|
768
768
|
es: Le,
|
|
769
769
|
fr: De,
|
|
770
770
|
pl: Qe,
|
|
771
771
|
pt: lt,
|
|
772
|
-
tr:
|
|
772
|
+
tr: yt,
|
|
773
773
|
it: Ue
|
|
774
774
|
// Add other locales here
|
|
775
775
|
};
|
|
776
|
-
class
|
|
776
|
+
class vt {
|
|
777
777
|
locale;
|
|
778
778
|
loadedLocales = /* @__PURE__ */ new Set();
|
|
779
779
|
constructor(e = "en") {
|
|
@@ -821,8 +821,8 @@ const A = [
|
|
|
821
821
|
"it",
|
|
822
822
|
"tr"
|
|
823
823
|
], Et = "en";
|
|
824
|
-
function bt(
|
|
825
|
-
const e = new
|
|
824
|
+
function bt(s) {
|
|
825
|
+
const e = new vt(), a = (() => {
|
|
826
826
|
const o = navigator?.language?.split("-")[0]?.toLowerCase();
|
|
827
827
|
return A.includes(o) ? o : Et;
|
|
828
828
|
})();
|
|
@@ -842,19 +842,19 @@ function bt(n) {
|
|
|
842
842
|
};
|
|
843
843
|
}
|
|
844
844
|
const Ct = bt(), I = () => {
|
|
845
|
-
const { translate:
|
|
845
|
+
const { translate: s, getLocale: e, setLocale: t, subscribe: a } = Ct;
|
|
846
846
|
return {
|
|
847
|
-
t:
|
|
848
|
-
translate:
|
|
847
|
+
t: s,
|
|
848
|
+
translate: s,
|
|
849
849
|
locale: e(),
|
|
850
850
|
setLocale: t,
|
|
851
851
|
subscribe: a
|
|
852
852
|
};
|
|
853
|
-
}, St = ({ fontFamily:
|
|
854
|
-
if (!
|
|
853
|
+
}, St = ({ fontFamily: s }) => {
|
|
854
|
+
if (!s)
|
|
855
855
|
return { cleanup: () => {
|
|
856
856
|
} };
|
|
857
|
-
const e =
|
|
857
|
+
const e = s.replace(/\s+/g, "+"), t = `https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`, a = [...document.head.querySelectorAll("link")].filter(
|
|
858
858
|
(o) => o.href.includes("fonts.googleapis.com/css2") && o.rel === "stylesheet"
|
|
859
859
|
), i = document.createElement("link");
|
|
860
860
|
i.rel = "stylesheet", i.href = t;
|
|
@@ -874,17 +874,17 @@ const Ct = bt(), I = () => {
|
|
|
874
874
|
document.head.contains(i) && document.head.removeChild(i);
|
|
875
875
|
} };
|
|
876
876
|
}, xt = ({
|
|
877
|
-
scriptSrc:
|
|
877
|
+
scriptSrc: s,
|
|
878
878
|
async: e = !1
|
|
879
879
|
}) => {
|
|
880
|
-
if (!
|
|
880
|
+
if (!s)
|
|
881
881
|
return {
|
|
882
882
|
cleanup: () => {
|
|
883
883
|
},
|
|
884
884
|
isLoaded: Promise.resolve(!1)
|
|
885
885
|
};
|
|
886
886
|
if ([...document.head.querySelectorAll("script")].filter(
|
|
887
|
-
(
|
|
887
|
+
(n) => n.src === s
|
|
888
888
|
).length > 0)
|
|
889
889
|
return {
|
|
890
890
|
cleanup: () => {
|
|
@@ -892,10 +892,10 @@ const Ct = bt(), I = () => {
|
|
|
892
892
|
isLoaded: Promise.resolve(!0)
|
|
893
893
|
};
|
|
894
894
|
const a = document.createElement("script");
|
|
895
|
-
a.src =
|
|
896
|
-
const i = new Promise((
|
|
897
|
-
a.onload = () =>
|
|
898
|
-
console.error(`Failed to load script: ${
|
|
895
|
+
a.src = s, a.async = e;
|
|
896
|
+
const i = new Promise((n, o) => {
|
|
897
|
+
a.onload = () => n(!0), a.onerror = () => {
|
|
898
|
+
console.error(`Failed to load script: ${s}`), o(new Error(`Failed to load script: ${s}`));
|
|
899
899
|
};
|
|
900
900
|
});
|
|
901
901
|
return document.head.appendChild(a), {
|
|
@@ -904,12 +904,12 @@ const Ct = bt(), I = () => {
|
|
|
904
904
|
},
|
|
905
905
|
isLoaded: i
|
|
906
906
|
};
|
|
907
|
-
}, w = (
|
|
907
|
+
}, w = (s) => Object.entries(s).map(([e, t]) => {
|
|
908
908
|
const a = e.replace(/([A-Z])/g, "-$1").toLowerCase(), i = typeof t == "number" ? `${t}px` : t;
|
|
909
909
|
return `${a}: ${i}`;
|
|
910
910
|
}).join("; ");
|
|
911
|
-
function Ft(
|
|
912
|
-
if (!
|
|
911
|
+
function Ft(s) {
|
|
912
|
+
if (!s)
|
|
913
913
|
return {
|
|
914
914
|
formContainerStyle: {},
|
|
915
915
|
baseStyles: {},
|
|
@@ -928,24 +928,24 @@ function Ft(n) {
|
|
|
928
928
|
background: "#fff",
|
|
929
929
|
border: "none",
|
|
930
930
|
outline: "none",
|
|
931
|
-
fontSize: `${
|
|
931
|
+
fontSize: `${s.styles.fontSize}px`,
|
|
932
932
|
lineHeight: 30,
|
|
933
933
|
boxSizing: "border-box",
|
|
934
934
|
padding: "0px 12px",
|
|
935
935
|
height: 36,
|
|
936
936
|
width: "100%",
|
|
937
|
-
fontFamily: `${
|
|
937
|
+
fontFamily: `${s.styles.fontFamily}, sans-serif`
|
|
938
938
|
}, t = {
|
|
939
939
|
color: "#717173",
|
|
940
940
|
opacity: "0.3",
|
|
941
|
-
fontFamily: `${
|
|
941
|
+
fontFamily: `${s.styles.fontFamily}, sans-serif`
|
|
942
942
|
}, a = {
|
|
943
943
|
color: "#dc2727"
|
|
944
944
|
}, i = {
|
|
945
945
|
outline: 0
|
|
946
946
|
}, r = {
|
|
947
|
-
fontFamily: `${
|
|
948
|
-
},
|
|
947
|
+
fontFamily: `${s.styles.fontFamily}, sans-serif`
|
|
948
|
+
}, n = {
|
|
949
949
|
base: w(e),
|
|
950
950
|
error: w(a),
|
|
951
951
|
focus: w(i),
|
|
@@ -957,7 +957,7 @@ function Ft(n) {
|
|
|
957
957
|
placeholderStyles: t,
|
|
958
958
|
errorStyles: a,
|
|
959
959
|
focusStyles: i,
|
|
960
|
-
inputStyles:
|
|
960
|
+
inputStyles: n
|
|
961
961
|
};
|
|
962
962
|
}
|
|
963
963
|
class h {
|
|
@@ -1105,8 +1105,8 @@ class S {
|
|
|
1105
1105
|
* Create a label element
|
|
1106
1106
|
*/
|
|
1107
1107
|
static createLabel(e, t = "", a = [], i = {}) {
|
|
1108
|
-
const r = t ? { for: t, ...i } : i,
|
|
1109
|
-
return
|
|
1108
|
+
const r = t ? { for: t, ...i } : i, n = new h("label", a, r);
|
|
1109
|
+
return n.setText(e), n;
|
|
1110
1110
|
}
|
|
1111
1111
|
/**
|
|
1112
1112
|
* Create a select element
|
|
@@ -1114,8 +1114,8 @@ class S {
|
|
|
1114
1114
|
static createSelect(e, t = [], a = {}) {
|
|
1115
1115
|
const i = new h("select", t, a);
|
|
1116
1116
|
return e.forEach((r) => {
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1117
|
+
const n = document.createElement("option");
|
|
1118
|
+
n.value = r.value, n.textContent = r.text, r.selected && (n.selected = !0), i.getElement().appendChild(n);
|
|
1119
1119
|
}), i;
|
|
1120
1120
|
}
|
|
1121
1121
|
/**
|
|
@@ -1139,12 +1139,12 @@ class wt extends h {
|
|
|
1139
1139
|
i.getElement().innerHTML = this.createAlertCircleSVG();
|
|
1140
1140
|
const r = S.createDiv([
|
|
1141
1141
|
"error-alert-text-container"
|
|
1142
|
-
]),
|
|
1142
|
+
]), n = new h("h4", [
|
|
1143
1143
|
"error-alert-title"
|
|
1144
1144
|
]);
|
|
1145
|
-
|
|
1145
|
+
n.setText("Checkout Error"), this.messageComponent = new h("p", [
|
|
1146
1146
|
"error-alert-message"
|
|
1147
|
-
]), this.messageComponent.setText(e.message || "Bad request"), r.appendChild(
|
|
1147
|
+
]), this.messageComponent.setText(e.message || "Bad request"), r.appendChild(n), r.appendChild(this.messageComponent), a.appendChild(i), a.appendChild(r), t.appendChild(a), this.appendChild(t);
|
|
1148
1148
|
}
|
|
1149
1149
|
createAlertCircleSVG() {
|
|
1150
1150
|
return `
|
|
@@ -1252,7 +1252,7 @@ class Mt {
|
|
|
1252
1252
|
onChange: a,
|
|
1253
1253
|
onBlur: i,
|
|
1254
1254
|
error: r,
|
|
1255
|
-
errorMsg:
|
|
1255
|
+
errorMsg: n,
|
|
1256
1256
|
checkoutProfile: o,
|
|
1257
1257
|
translationFunc: l,
|
|
1258
1258
|
autocomplete: c = "cc-name"
|
|
@@ -1261,7 +1261,7 @@ class Mt {
|
|
|
1261
1261
|
name: "name",
|
|
1262
1262
|
label: l("cardholderNameLabel"),
|
|
1263
1263
|
error: r,
|
|
1264
|
-
errorMsg:
|
|
1264
|
+
errorMsg: n,
|
|
1265
1265
|
styles: {
|
|
1266
1266
|
color: o.styles.textColor,
|
|
1267
1267
|
borderRadius: `${o.styles.borderRadius}px`,
|
|
@@ -1345,12 +1345,12 @@ class At extends h {
|
|
|
1345
1345
|
i.id = "card-element", i.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, i.style.zIndex = e.isFocused ? "2" : "0";
|
|
1346
1346
|
const r = document.createElement("div");
|
|
1347
1347
|
if (r.className = "cards-position", e.cardType === "unknown")
|
|
1348
|
-
F.forEach((
|
|
1349
|
-
r.appendChild(this.createCardIcon(
|
|
1348
|
+
F.forEach((n) => {
|
|
1349
|
+
r.appendChild(this.createCardIcon(n));
|
|
1350
1350
|
});
|
|
1351
1351
|
else {
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1352
|
+
const n = F.find((o) => o.type === e.cardType);
|
|
1353
|
+
n && r.appendChild(this.createCardIcon(n));
|
|
1354
1354
|
}
|
|
1355
1355
|
i.appendChild(r), a.appendChild(i), this.getElement().appendChild(a);
|
|
1356
1356
|
}
|
|
@@ -1404,14 +1404,14 @@ class Pt extends h {
|
|
|
1404
1404
|
isLoading: a,
|
|
1405
1405
|
isFocused: i,
|
|
1406
1406
|
isCvvFocused: r,
|
|
1407
|
-
isCcValid:
|
|
1407
|
+
isCcValid: n,
|
|
1408
1408
|
isCvvValid: o,
|
|
1409
1409
|
cardType: l,
|
|
1410
1410
|
cardExpiry: c,
|
|
1411
1411
|
cardExpiryError: d,
|
|
1412
1412
|
cardExpiryTouched: u,
|
|
1413
1413
|
onChange: E,
|
|
1414
|
-
onBlur:
|
|
1414
|
+
onBlur: y,
|
|
1415
1415
|
translationFunc: m,
|
|
1416
1416
|
cardExpiryAutocomplete: g = "cc-exp"
|
|
1417
1417
|
} = e, f = document.createElement("div");
|
|
@@ -1434,8 +1434,8 @@ class Pt extends h {
|
|
|
1434
1434
|
errorMsg: d,
|
|
1435
1435
|
value: c,
|
|
1436
1436
|
autocomplete: g,
|
|
1437
|
-
onChange: (
|
|
1438
|
-
this.trimCardExpiry(), E(
|
|
1437
|
+
onChange: (v) => {
|
|
1438
|
+
this.trimCardExpiry(), E(v);
|
|
1439
1439
|
},
|
|
1440
1440
|
styles: {
|
|
1441
1441
|
color: t.styles.textColor,
|
|
@@ -1443,8 +1443,8 @@ class Pt extends h {
|
|
|
1443
1443
|
fontSize: t.styles.fontSize,
|
|
1444
1444
|
fontFamily: t.styles.fontFamily
|
|
1445
1445
|
}
|
|
1446
|
-
}), this.cardExpiry.addEventListener("blur",
|
|
1447
|
-
const M =
|
|
1446
|
+
}), this.cardExpiry.addEventListener("blur", y), this.cardExpiry.addEventListener("keydown", (v) => {
|
|
1447
|
+
const M = v;
|
|
1448
1448
|
![
|
|
1449
1449
|
"Backspace",
|
|
1450
1450
|
"Delete",
|
|
@@ -1462,17 +1462,17 @@ class Pt extends h {
|
|
|
1462
1462
|
},
|
|
1463
1463
|
isLoading: a,
|
|
1464
1464
|
isFocused: r
|
|
1465
|
-
}), b.appendChild(this.cardCvv.getElement()), p.appendChild(this.cardExpiry.getElement()), p.appendChild(b), f.appendChild(p), this.getElement().appendChild(f), i && !
|
|
1466
|
-
const
|
|
1465
|
+
}), b.appendChild(this.cardCvv.getElement()), p.appendChild(this.cardExpiry.getElement()), p.appendChild(b), f.appendChild(p), this.getElement().appendChild(f), i && !n) {
|
|
1466
|
+
const v = new x({
|
|
1467
1467
|
text: m("validation.cardNumberInvalid")
|
|
1468
1468
|
});
|
|
1469
|
-
this.validationMessages.set("cardNumber",
|
|
1469
|
+
this.validationMessages.set("cardNumber", v), this.appendChild(v);
|
|
1470
1470
|
}
|
|
1471
1471
|
if (r && !o) {
|
|
1472
|
-
const
|
|
1472
|
+
const v = new x({
|
|
1473
1473
|
text: m("validation.cardSecurityFormat")
|
|
1474
1474
|
});
|
|
1475
|
-
this.validationMessages.set("cardCvv",
|
|
1475
|
+
this.validationMessages.set("cardCvv", v), this.appendChild(v);
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
1478
|
updateCardType(e) {
|
|
@@ -1528,7 +1528,7 @@ class Dt {
|
|
|
1528
1528
|
onChange: a,
|
|
1529
1529
|
onBlur: i,
|
|
1530
1530
|
error: r,
|
|
1531
|
-
errorMsg:
|
|
1531
|
+
errorMsg: n,
|
|
1532
1532
|
checkoutProfile: o,
|
|
1533
1533
|
translationFunc: l,
|
|
1534
1534
|
autocomplete: c = "email"
|
|
@@ -1537,7 +1537,7 @@ class Dt {
|
|
|
1537
1537
|
name: "email",
|
|
1538
1538
|
label: l("email"),
|
|
1539
1539
|
error: r,
|
|
1540
|
-
errorMsg:
|
|
1540
|
+
errorMsg: n,
|
|
1541
1541
|
styles: {
|
|
1542
1542
|
color: o.styles.textColor,
|
|
1543
1543
|
borderRadius: `${o.styles.borderRadius}px`,
|
|
@@ -1617,14 +1617,14 @@ class Vt extends h {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
const r = Object.entries(
|
|
1619
1619
|
t.additionalPaymentMethods
|
|
1620
|
-
).filter(([,
|
|
1620
|
+
).filter(([, n]) => n.enabled).sort((n, o) => n[1].order - o[1].order);
|
|
1621
1621
|
if (r.length === 0) {
|
|
1622
1622
|
super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), this.getElement().style.display = "none";
|
|
1623
1623
|
return;
|
|
1624
1624
|
}
|
|
1625
1625
|
super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map();
|
|
1626
|
-
for (const [
|
|
1627
|
-
switch (
|
|
1626
|
+
for (const [n] of r)
|
|
1627
|
+
switch (n) {
|
|
1628
1628
|
case "paypal": {
|
|
1629
1629
|
if (i) {
|
|
1630
1630
|
const o = new Rt({
|
|
@@ -1746,18 +1746,22 @@ class Ut extends h {
|
|
|
1746
1746
|
if (!e.isLoading)
|
|
1747
1747
|
if (this.setLoadingState(!1), e.checkoutProfile)
|
|
1748
1748
|
try {
|
|
1749
|
-
if (e.checkoutProfile.styles?.fontFamily)
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1749
|
+
if (e.checkoutProfile.styles?.fontFamily)
|
|
1750
|
+
try {
|
|
1751
|
+
const { cleanup: t } = St({
|
|
1752
|
+
fontFamily: e.checkoutProfile.styles.fontFamily
|
|
1753
|
+
});
|
|
1754
|
+
this.fontCleanup = t;
|
|
1755
|
+
} catch (t) {
|
|
1756
|
+
console.error("Error loading Google Font:", t);
|
|
1757
|
+
}
|
|
1755
1758
|
this.renderFormComponents(), this.initializeTokenExIframe().catch((t) => {
|
|
1756
|
-
console.error("Error initializing TokenEx iframe:", t)
|
|
1759
|
+
console.error("Error initializing TokenEx iframe:", t);
|
|
1757
1760
|
});
|
|
1758
|
-
} catch {
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
+
} catch (t) {
|
|
1762
|
+
console.error("Error in profile state change:", t);
|
|
1763
|
+
const a = e.error || "Failed to load checkout profile data";
|
|
1764
|
+
this.setErrorMessage(a);
|
|
1761
1765
|
}
|
|
1762
1766
|
else e.error && (console.error("NO profile found", e.error), this.setErrorMessage(e.error));
|
|
1763
1767
|
};
|
|
@@ -1766,30 +1770,55 @@ class Ut extends h {
|
|
|
1766
1770
|
}
|
|
1767
1771
|
initializeTokenExIframe = async () => {
|
|
1768
1772
|
const e = this.checkoutProfile.getState();
|
|
1769
|
-
if (e.checkoutProfile
|
|
1773
|
+
if (!e.checkoutProfile) {
|
|
1774
|
+
console.error("Cannot initialize iframe: No checkout profile available");
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
if (this.iframeHook) {
|
|
1778
|
+
console.log("TokenEx iframe already initialized, skipping");
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
try {
|
|
1782
|
+
if (!("TokenEx" in globalThis))
|
|
1783
|
+
return console.log("TokenEx not available yet, retrying..."), new Promise((n) => {
|
|
1784
|
+
setTimeout(() => {
|
|
1785
|
+
this.initializeTokenExIframe().then(n);
|
|
1786
|
+
}, 500);
|
|
1787
|
+
});
|
|
1788
|
+
const { inputStyles: t, formContainerStyle: a } = Ft(
|
|
1789
|
+
e.checkoutProfile
|
|
1790
|
+
);
|
|
1791
|
+
this.applyFormContainerStyles(a);
|
|
1770
1792
|
try {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1793
|
+
this.cardSection || (this.createCardSection(e.checkoutProfile), console.log("✅ Card element check before iframe initialization:", {
|
|
1794
|
+
cardElementExists: !!document.getElementById("card-element"),
|
|
1795
|
+
cvvElementExists: !!document.getElementById("card-cvv-element"),
|
|
1796
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1797
|
+
}));
|
|
1798
|
+
} catch (n) {
|
|
1799
|
+
console.error("Failed to create card section:", n);
|
|
1800
|
+
}
|
|
1801
|
+
const i = document.getElementById("card-element"), r = document.getElementById("card-cvv-element");
|
|
1802
|
+
if (!i || !r) {
|
|
1803
|
+
console.error(
|
|
1804
|
+
"Card elements not found, cannot initialize TokenEx iframe"
|
|
1777
1805
|
);
|
|
1778
|
-
|
|
1779
|
-
apiKey: this.options.apiKey,
|
|
1780
|
-
checkoutProfile: e.checkoutProfile,
|
|
1781
|
-
inputStyles: t,
|
|
1782
|
-
setFormData: (i) => {
|
|
1783
|
-
this.formManager.setFormData(i);
|
|
1784
|
-
},
|
|
1785
|
-
environment: this.options.environment
|
|
1786
|
-
}), this.iframeHook?.subscribe(this.handleIframeStateChange), await this.iframeHook?.initialize();
|
|
1787
|
-
} catch {
|
|
1788
|
-
this.setErrorMessage("Failed to initialize payment form");
|
|
1806
|
+
return;
|
|
1789
1807
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1808
|
+
this.iframeHook = Q({
|
|
1809
|
+
apiKey: this.options.apiKey,
|
|
1810
|
+
checkoutProfile: e.checkoutProfile,
|
|
1811
|
+
inputStyles: t,
|
|
1812
|
+
setFormData: (n) => {
|
|
1813
|
+
this.formManager.setFormData(n);
|
|
1814
|
+
},
|
|
1815
|
+
environment: this.options.environment
|
|
1816
|
+
}), this.iframeHook?.subscribe(this.handleIframeStateChange), await this.iframeHook?.initialize(), console.log("✅ TokenEx iframe initialized successfully:", {
|
|
1817
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1818
|
+
});
|
|
1819
|
+
} catch (t) {
|
|
1820
|
+
throw console.error("Failed to initialize payment form:", t), t;
|
|
1821
|
+
}
|
|
1793
1822
|
};
|
|
1794
1823
|
handleIframeStateChange = (e) => {
|
|
1795
1824
|
this.cardSection && (this.cardSection.updateCardNumberValidation(
|
|
@@ -1814,7 +1843,7 @@ class Ut extends h {
|
|
|
1814
1843
|
isCvvValid: !1,
|
|
1815
1844
|
possibleCardType: "unknown"
|
|
1816
1845
|
};
|
|
1817
|
-
this.iframeHook && (r = this.iframeHook.getState()), this.cardSection = new Pt({
|
|
1846
|
+
if (this.iframeHook && (r = this.iframeHook.getState()), this.cardSection = new Pt({
|
|
1818
1847
|
checkoutProfile: e,
|
|
1819
1848
|
isLoading: r.loadingIframe,
|
|
1820
1849
|
isFocused: r.isFocused,
|
|
@@ -1828,9 +1857,24 @@ class Ut extends h {
|
|
|
1828
1857
|
onChange: this.handleChange,
|
|
1829
1858
|
onBlur: this.handleBlur,
|
|
1830
1859
|
translationFunc: this.translation.t
|
|
1831
|
-
}), this.
|
|
1832
|
-
|
|
1833
|
-
|
|
1860
|
+
}), this.emailField && this.cardholderSection)
|
|
1861
|
+
this.element.insertBefore(
|
|
1862
|
+
this.cardSection.getElement(),
|
|
1863
|
+
this.cardholderSection.getElement()
|
|
1864
|
+
);
|
|
1865
|
+
else if (this.emailField) {
|
|
1866
|
+
const n = this.emailField.getElement().nextSibling;
|
|
1867
|
+
n ? this.element.insertBefore(
|
|
1868
|
+
this.cardSection.getElement(),
|
|
1869
|
+
n
|
|
1870
|
+
) : this.element.appendChild(this.cardSection.getElement());
|
|
1871
|
+
} else
|
|
1872
|
+
this.element.appendChild(this.cardSection.getElement()), console.warn(
|
|
1873
|
+
"Card section inserted at end of form - component order may be incorrect"
|
|
1874
|
+
);
|
|
1875
|
+
this.updateFormUI(), this.cardSection && this.emailField && this.cardholderSection && this.submitButton;
|
|
1876
|
+
} catch (t) {
|
|
1877
|
+
console.error("Error creating card section:", t), this.setErrorMessage("Card section temporarily unavailable");
|
|
1834
1878
|
}
|
|
1835
1879
|
};
|
|
1836
1880
|
initializeForm() {
|
|
@@ -1846,70 +1890,114 @@ class Ut extends h {
|
|
|
1846
1890
|
});
|
|
1847
1891
|
}
|
|
1848
1892
|
renderFormComponents() {
|
|
1849
|
-
if (
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
});
|
|
1864
|
-
} catch {
|
|
1865
|
-
this.setErrorMessage("Failed to render checkout form components");
|
|
1866
|
-
}
|
|
1893
|
+
if (this.emailField)
|
|
1894
|
+
return;
|
|
1895
|
+
console.log("🏗️ Starting form components rendering:", {
|
|
1896
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1897
|
+
});
|
|
1898
|
+
const e = this.checkoutProfile.getState();
|
|
1899
|
+
if (!e.checkoutProfile) {
|
|
1900
|
+
this.setErrorMessage("Failed to load checkout configuration");
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
try {
|
|
1904
|
+
this.createPaymentMethods(e.checkoutProfile);
|
|
1905
|
+
} catch (t) {
|
|
1906
|
+
console.error("Failed to create payment methods:", t);
|
|
1867
1907
|
}
|
|
1908
|
+
try {
|
|
1909
|
+
this.createEmailField(e.checkoutProfile);
|
|
1910
|
+
} catch (t) {
|
|
1911
|
+
console.error("Failed to create email field:", t);
|
|
1912
|
+
}
|
|
1913
|
+
try {
|
|
1914
|
+
this.createCardholderSection(e.checkoutProfile);
|
|
1915
|
+
} catch (t) {
|
|
1916
|
+
console.error("Failed to create cardholder section:", t);
|
|
1917
|
+
}
|
|
1918
|
+
try {
|
|
1919
|
+
this.createSubmitButton(e.checkoutProfile);
|
|
1920
|
+
} catch (t) {
|
|
1921
|
+
console.error("Failed to create submit button:", t);
|
|
1922
|
+
}
|
|
1923
|
+
console.log("✅ Form components rendered successfully:", {
|
|
1924
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1925
|
+
components: {
|
|
1926
|
+
paymentMethods: !!this.paymentMethods,
|
|
1927
|
+
emailField: !!this.emailField,
|
|
1928
|
+
cardholderSection: !!this.cardholderSection,
|
|
1929
|
+
submitButton: !!this.submitButton
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1868
1932
|
}
|
|
1869
1933
|
createPaymentMethods(e) {
|
|
1870
|
-
|
|
1871
|
-
e
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1934
|
+
try {
|
|
1935
|
+
if (!e?.additionalPaymentMethods) {
|
|
1936
|
+
console.log(
|
|
1937
|
+
"No additional payment methods configured, skipping component"
|
|
1938
|
+
);
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
if (Object.entries(
|
|
1942
|
+
e.additionalPaymentMethods
|
|
1943
|
+
).filter(([, i]) => i.enabled).length === 0) {
|
|
1944
|
+
console.log("No enabled payment methods found, skipping component");
|
|
1945
|
+
return;
|
|
1880
1946
|
}
|
|
1881
|
-
|
|
1947
|
+
const { formData: a } = this._getFormStateData();
|
|
1948
|
+
this.paymentMethods = new Vt({
|
|
1949
|
+
checkoutProfile: e,
|
|
1950
|
+
formData: a,
|
|
1951
|
+
onPaypalSubmit: async () => {
|
|
1952
|
+
await this.handlePaypalSubmit();
|
|
1953
|
+
}
|
|
1954
|
+
}), this.appendChild(this.paymentMethods), console.log("✅ Payment methods created successfully");
|
|
1955
|
+
} catch (t) {
|
|
1956
|
+
throw console.error("Error creating payment methods:", t), t;
|
|
1957
|
+
}
|
|
1882
1958
|
}
|
|
1883
1959
|
createEmailField(e) {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1960
|
+
try {
|
|
1961
|
+
const { formData: t, errors: a, touched: i } = this._getFormStateData();
|
|
1962
|
+
this.emailField = new Dt({
|
|
1963
|
+
value: t.email,
|
|
1964
|
+
onChange: this.handleChange,
|
|
1965
|
+
onBlur: this.handleBlur,
|
|
1966
|
+
error: !!(a.email && i.email),
|
|
1967
|
+
errorMsg: a.email,
|
|
1968
|
+
checkoutProfile: e,
|
|
1969
|
+
translationFunc: this.translation.t
|
|
1970
|
+
}), this.element.appendChild(this.emailField.getElement()), console.log("✅ Email field created successfully");
|
|
1971
|
+
} catch (t) {
|
|
1972
|
+
throw console.error("Error creating email field:", t), t;
|
|
1973
|
+
}
|
|
1894
1974
|
}
|
|
1895
1975
|
createCardholderSection(e) {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1976
|
+
try {
|
|
1977
|
+
const { formData: t, errors: a, touched: i } = this._getFormStateData();
|
|
1978
|
+
this.cardholderSection = new Mt({
|
|
1979
|
+
value: t.name,
|
|
1980
|
+
onChange: this.handleChange,
|
|
1981
|
+
onBlur: this.handleBlur,
|
|
1982
|
+
error: !!(a.name && i.name),
|
|
1983
|
+
errorMsg: a.name,
|
|
1984
|
+
checkoutProfile: e,
|
|
1985
|
+
translationFunc: this.translation.t
|
|
1986
|
+
}), this.element.appendChild(this.cardholderSection.getElement()), console.log("✅ Cardholder section created successfully");
|
|
1987
|
+
} catch (t) {
|
|
1988
|
+
throw console.error("Error creating cardholder section:", t), t;
|
|
1989
|
+
}
|
|
1906
1990
|
}
|
|
1907
1991
|
createSubmitButton(e) {
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1992
|
+
try {
|
|
1993
|
+
this.submitButton = new Ht({
|
|
1994
|
+
disabled: this.isFormDisabled(),
|
|
1995
|
+
checkoutProfile: e,
|
|
1996
|
+
translationFunc: this.translation.t
|
|
1997
|
+
}), this.element.appendChild(this.submitButton.getElement()), console.log("✅ Submit button created successfully");
|
|
1998
|
+
} catch (t) {
|
|
1999
|
+
throw console.error("Error creating submit button:", t), t;
|
|
2000
|
+
}
|
|
1913
2001
|
}
|
|
1914
2002
|
handleChange = (e) => {
|
|
1915
2003
|
const t = e.target, { name: a, value: i } = t;
|
|
@@ -2170,11 +2258,11 @@ typeof globalThis < "u" && (globalThis.OdusCheckout = Yt);
|
|
|
2170
2258
|
export {
|
|
2171
2259
|
Yt as OdusCheckout,
|
|
2172
2260
|
le as deLocale,
|
|
2173
|
-
|
|
2261
|
+
ye as enLocale,
|
|
2174
2262
|
Le as esLocale,
|
|
2175
2263
|
De as frLocale,
|
|
2176
2264
|
Ue as itLocale,
|
|
2177
2265
|
Qe as plLocale,
|
|
2178
2266
|
lt as ptLocale,
|
|
2179
|
-
|
|
2267
|
+
yt as trLocale
|
|
2180
2268
|
};
|
package/dist/package.json
CHANGED