@odus/checkout 0.5.7 → 0.5.9
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 +230 -248
- package/dist/index.css +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -10,17 +10,17 @@ class $ {
|
|
|
10
10
|
endpoint: e,
|
|
11
11
|
method: t = "POST",
|
|
12
12
|
body: a,
|
|
13
|
-
customHeaders:
|
|
13
|
+
customHeaders: r = {}
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
15
|
+
const i = {
|
|
16
16
|
Authorization: `Bearer ${this.apiKey}`,
|
|
17
17
|
"Content-Type": "application/json",
|
|
18
|
-
...
|
|
18
|
+
...r
|
|
19
19
|
};
|
|
20
20
|
try {
|
|
21
21
|
const n = await fetch(`${this.baseUrl}${e}`, {
|
|
22
22
|
method: t,
|
|
23
|
-
headers:
|
|
23
|
+
headers: i,
|
|
24
24
|
body: a ? JSON.stringify(a) : void 0
|
|
25
25
|
});
|
|
26
26
|
if (!n.ok) {
|
|
@@ -52,17 +52,17 @@ class $ {
|
|
|
52
52
|
paymentId: e,
|
|
53
53
|
checkoutKey: t,
|
|
54
54
|
formData: a,
|
|
55
|
-
token:
|
|
56
|
-
returnUrl:
|
|
55
|
+
token: r,
|
|
56
|
+
returnUrl: i
|
|
57
57
|
}) {
|
|
58
58
|
let n = {};
|
|
59
|
-
if (
|
|
59
|
+
if (r && 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: {
|
|
65
|
-
token:
|
|
65
|
+
token: r,
|
|
66
66
|
expMonth: l,
|
|
67
67
|
expYear: `20${c}`,
|
|
68
68
|
cardholderName: a.name
|
|
@@ -73,7 +73,7 @@ class $ {
|
|
|
73
73
|
name: a.name
|
|
74
74
|
},
|
|
75
75
|
context: {
|
|
76
|
-
returnUrl:
|
|
76
|
+
returnUrl: i,
|
|
77
77
|
browserInfo: this.browserInfo
|
|
78
78
|
}
|
|
79
79
|
};
|
|
@@ -83,7 +83,7 @@ class $ {
|
|
|
83
83
|
type: "paypal"
|
|
84
84
|
},
|
|
85
85
|
context: {
|
|
86
|
-
returnUrl:
|
|
86
|
+
returnUrl: i,
|
|
87
87
|
browserInfo: this.browserInfo
|
|
88
88
|
}
|
|
89
89
|
};
|
|
@@ -101,16 +101,16 @@ const R = async ({
|
|
|
101
101
|
apiKey: e,
|
|
102
102
|
environment: t
|
|
103
103
|
}) => {
|
|
104
|
-
const a = k(t),
|
|
104
|
+
const a = k(t), r = await fetch(`${a}/checkout-profiles/${s}`, {
|
|
105
105
|
method: "GET",
|
|
106
106
|
headers: {
|
|
107
107
|
"Content-Type": "application/json",
|
|
108
108
|
Authorization: `Bearer ${e}`
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
|
-
if (!
|
|
112
|
-
throw new Error(`HTTP error! Status: ${
|
|
113
|
-
return await
|
|
111
|
+
if (!r.ok)
|
|
112
|
+
throw new Error(`HTTP error! Status: ${r.status}`);
|
|
113
|
+
return await r.json();
|
|
114
114
|
};
|
|
115
115
|
class V {
|
|
116
116
|
events = /* @__PURE__ */ new Map();
|
|
@@ -133,7 +133,7 @@ class V {
|
|
|
133
133
|
*/
|
|
134
134
|
publish(e, t) {
|
|
135
135
|
const a = this.events.get(e);
|
|
136
|
-
a && a.forEach((
|
|
136
|
+
a && a.forEach((r) => r(t));
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Clear all event subscriptions
|
|
@@ -208,30 +208,30 @@ function H({
|
|
|
208
208
|
checkoutProfile: void 0,
|
|
209
209
|
isLoading: !0,
|
|
210
210
|
error: null
|
|
211
|
-
}),
|
|
211
|
+
}), r = async () => {
|
|
212
212
|
try {
|
|
213
213
|
a.setState({ isLoading: !0 });
|
|
214
|
-
const
|
|
214
|
+
const i = await R({
|
|
215
215
|
apiKey: s,
|
|
216
216
|
id: e,
|
|
217
217
|
environment: t
|
|
218
218
|
});
|
|
219
|
-
|
|
220
|
-
checkoutProfile:
|
|
219
|
+
i && a.setState({
|
|
220
|
+
checkoutProfile: i,
|
|
221
221
|
isLoading: !1,
|
|
222
222
|
error: null
|
|
223
223
|
});
|
|
224
|
-
} catch (
|
|
224
|
+
} catch (i) {
|
|
225
225
|
a.setState({
|
|
226
226
|
error: "Failed to load checkout profile",
|
|
227
227
|
isLoading: !1
|
|
228
|
-
}), console.error(
|
|
228
|
+
}), console.error(i);
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
return
|
|
231
|
+
return r(), {
|
|
232
232
|
getState: a.getState.bind(a),
|
|
233
233
|
subscribe: a.subscribe.bind(a),
|
|
234
|
-
reload:
|
|
234
|
+
reload: r
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
const z = {
|
|
@@ -328,29 +328,29 @@ const z = {
|
|
|
328
328
|
}, j = (s, e) => {
|
|
329
329
|
if (s.length === 0) return e.length;
|
|
330
330
|
if (e.length === 0) return s.length;
|
|
331
|
-
const t = e.length + 1, a = s.length + 1,
|
|
331
|
+
const t = e.length + 1, a = s.length + 1, r = Array.from(
|
|
332
332
|
{ length: t },
|
|
333
|
-
(
|
|
333
|
+
(i, n) => Array.from({ length: a }, (o, l) => n === 0 ? l : l === 0 ? n : 0)
|
|
334
334
|
);
|
|
335
|
-
for (let
|
|
335
|
+
for (let i = 1; i < t; i++)
|
|
336
336
|
for (let n = 1; n < a; n++) {
|
|
337
|
-
const o = s[n - 1] === e[
|
|
338
|
-
i
|
|
339
|
-
i
|
|
337
|
+
const o = s[n - 1] === e[i - 1] ? 0 : 1;
|
|
338
|
+
r[i][n] = Math.min(
|
|
339
|
+
r[i - 1][n] + 1,
|
|
340
340
|
// deletion
|
|
341
|
-
i
|
|
341
|
+
r[i][n - 1] + 1,
|
|
342
342
|
// insertion
|
|
343
|
-
i
|
|
343
|
+
r[i - 1][n - 1] + o
|
|
344
344
|
// substitution
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
|
-
return
|
|
347
|
+
return r[e.length][s.length];
|
|
348
348
|
}, U = (s) => {
|
|
349
349
|
let t = null, a = 3;
|
|
350
|
-
const
|
|
351
|
-
for (const
|
|
352
|
-
const n = j(
|
|
353
|
-
n <= 2 && n < a && (a = n, t =
|
|
350
|
+
const r = s.toLowerCase();
|
|
351
|
+
for (const i of Object.keys(D)) {
|
|
352
|
+
const n = j(r, i);
|
|
353
|
+
n <= 2 && n < a && (a = n, t = i);
|
|
354
354
|
}
|
|
355
355
|
return t;
|
|
356
356
|
}, _ = () => {
|
|
@@ -364,32 +364,32 @@ const z = {
|
|
|
364
364
|
message: s("validation.emailInvalid"),
|
|
365
365
|
suggestion: null
|
|
366
366
|
};
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
367
|
+
const r = t.indexOf("@");
|
|
368
|
+
if (r === -1)
|
|
369
369
|
return {
|
|
370
370
|
isValid: !1,
|
|
371
371
|
message: s("validation.emailInvalid"),
|
|
372
372
|
suggestion: null
|
|
373
373
|
};
|
|
374
|
-
const
|
|
374
|
+
const i = t.substring(0, r), n = t.substring(r + 1);
|
|
375
375
|
if (!n.includes(".")) {
|
|
376
376
|
const l = K(n);
|
|
377
377
|
if (l)
|
|
378
378
|
return {
|
|
379
379
|
isValid: !1,
|
|
380
380
|
message: s("validation.emailSuggestion", {
|
|
381
|
-
email: `${
|
|
381
|
+
email: `${i}@${l}`
|
|
382
382
|
}),
|
|
383
|
-
suggestion: `${
|
|
383
|
+
suggestion: `${i}@${l}`
|
|
384
384
|
};
|
|
385
385
|
for (const c of Object.keys(D))
|
|
386
386
|
if (c.replace(/\./g, "") === n)
|
|
387
387
|
return {
|
|
388
388
|
isValid: !1,
|
|
389
389
|
message: s("validation.emailSuggestion", {
|
|
390
|
-
email: `${
|
|
390
|
+
email: `${i}@${c}`
|
|
391
391
|
}),
|
|
392
|
-
suggestion: `${
|
|
392
|
+
suggestion: `${i}@${c}`
|
|
393
393
|
};
|
|
394
394
|
}
|
|
395
395
|
if (!a.test(t))
|
|
@@ -400,7 +400,7 @@ const z = {
|
|
|
400
400
|
};
|
|
401
401
|
const o = U(n);
|
|
402
402
|
if (o && o !== n) {
|
|
403
|
-
const l = `${
|
|
403
|
+
const l = `${i}@${o}`;
|
|
404
404
|
return {
|
|
405
405
|
isValid: !1,
|
|
406
406
|
message: s("validation.emailSuggestion", { email: l }),
|
|
@@ -426,10 +426,10 @@ const z = {
|
|
|
426
426
|
return s("validation.nameRequired");
|
|
427
427
|
},
|
|
428
428
|
cardExpiry: (t) => {
|
|
429
|
-
const a = t.replace(/\s/g, ""), [
|
|
430
|
-
if (!
|
|
429
|
+
const a = t.replace(/\s/g, ""), [r, i] = a.split("/").map((u) => u.trim());
|
|
430
|
+
if (!r || !i || r.length !== 2 || i.length !== 2)
|
|
431
431
|
return s("validation.cardExpiryFormat");
|
|
432
|
-
const n = /* @__PURE__ */ new Date(), o = n.getFullYear() % 100, l = n.getMonth() + 1, c = parseInt(
|
|
432
|
+
const n = /* @__PURE__ */ new Date(), o = n.getFullYear() % 100, l = n.getMonth() + 1, c = parseInt(r, 10), d = parseInt(i, 10);
|
|
433
433
|
if (c < 1 || c > 12)
|
|
434
434
|
return s("validation.cardExpiryFormat");
|
|
435
435
|
if (d < o || d === o && c < l)
|
|
@@ -459,34 +459,34 @@ const z = {
|
|
|
459
459
|
const u = t(d, l[d]);
|
|
460
460
|
u && (c[d] = u);
|
|
461
461
|
}), c;
|
|
462
|
-
},
|
|
462
|
+
}, r = (l) => {
|
|
463
463
|
const c = a(l);
|
|
464
464
|
return Object.keys(c).length === 0;
|
|
465
|
-
},
|
|
465
|
+
}, i = (l, c) => {
|
|
466
466
|
const d = e.getState();
|
|
467
467
|
let u = c;
|
|
468
468
|
l in z && (u = z[l](c));
|
|
469
469
|
const E = {
|
|
470
470
|
...d.formData,
|
|
471
471
|
[l]: u
|
|
472
|
-
},
|
|
472
|
+
}, f = { ...d.errors };
|
|
473
473
|
if (d.touched[l]) {
|
|
474
474
|
const m = t(l, u);
|
|
475
|
-
m ?
|
|
475
|
+
m ? f[l] = m : delete f[l];
|
|
476
476
|
}
|
|
477
477
|
e.setState({
|
|
478
478
|
formData: E,
|
|
479
|
-
errors:
|
|
480
|
-
isValid:
|
|
479
|
+
errors: f,
|
|
480
|
+
isValid: r(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), f = { ...d.errors };
|
|
487
|
+
E ? f[l] = E : delete f[l], e.setState({
|
|
488
488
|
touched: u,
|
|
489
|
-
errors:
|
|
489
|
+
errors: f
|
|
490
490
|
});
|
|
491
491
|
}, o = (l) => {
|
|
492
492
|
const d = {
|
|
@@ -495,13 +495,13 @@ const z = {
|
|
|
495
495
|
};
|
|
496
496
|
e.setState({
|
|
497
497
|
formData: d,
|
|
498
|
-
isValid:
|
|
498
|
+
isValid: r(d)
|
|
499
499
|
});
|
|
500
500
|
};
|
|
501
501
|
return {
|
|
502
502
|
getFormState: e.getState.bind(e),
|
|
503
503
|
subscribe: e.subscribe.bind(e),
|
|
504
|
-
handleChange:
|
|
504
|
+
handleChange: i,
|
|
505
505
|
handleBlur: n,
|
|
506
506
|
setFormData: o,
|
|
507
507
|
reset: e.resetState.bind(e)
|
|
@@ -511,7 +511,7 @@ const z = {
|
|
|
511
511
|
apiKey: e,
|
|
512
512
|
environment: t
|
|
513
513
|
}) => {
|
|
514
|
-
const a = k(t),
|
|
514
|
+
const a = k(t), r = await fetch(
|
|
515
515
|
`${a}/tokenization/generate-iframe-configuration`,
|
|
516
516
|
{
|
|
517
517
|
method: "POST",
|
|
@@ -522,9 +522,9 @@ const z = {
|
|
|
522
522
|
body: JSON.stringify(s)
|
|
523
523
|
}
|
|
524
524
|
);
|
|
525
|
-
if (!
|
|
526
|
-
throw new Error(`HTTP error! Status: ${
|
|
527
|
-
return await
|
|
525
|
+
if (!r.ok)
|
|
526
|
+
throw new Error(`HTTP error! Status: ${r.status}`);
|
|
527
|
+
return await r.json();
|
|
528
528
|
}, Z = 100, J = 2, W = 2e3, X = 5;
|
|
529
529
|
function Q({
|
|
530
530
|
apiKey: s,
|
|
@@ -532,9 +532,9 @@ function Q({
|
|
|
532
532
|
checkoutProfile: e,
|
|
533
533
|
inputStyles: t,
|
|
534
534
|
setFormData: a,
|
|
535
|
-
environment:
|
|
535
|
+
environment: r
|
|
536
536
|
}) {
|
|
537
|
-
const
|
|
537
|
+
const i = L({
|
|
538
538
|
iframeConfig: void 0,
|
|
539
539
|
loadingIframe: !0,
|
|
540
540
|
isCcValid: !1,
|
|
@@ -551,9 +551,9 @@ function Q({
|
|
|
551
551
|
allowedOrigins: [globalThis.location.origin]
|
|
552
552
|
},
|
|
553
553
|
apiKey: s,
|
|
554
|
-
environment:
|
|
554
|
+
environment: r
|
|
555
555
|
});
|
|
556
|
-
m && (
|
|
556
|
+
m && (i.setState({
|
|
557
557
|
iframeConfig: {
|
|
558
558
|
...m,
|
|
559
559
|
origin: globalThis.location.origin
|
|
@@ -563,17 +563,13 @@ function Q({
|
|
|
563
563
|
console.error("Failed to generate iframe config:", m);
|
|
564
564
|
}
|
|
565
565
|
}, l = () => {
|
|
566
|
-
const m =
|
|
566
|
+
const m = i.getState();
|
|
567
567
|
if (!m.iframeConfig || !e)
|
|
568
568
|
return;
|
|
569
|
-
const y = document.getElementById("card-element"),
|
|
570
|
-
if (!y || !
|
|
569
|
+
const y = document.getElementById("card-element"), v = document.getElementById("card-cvv-element");
|
|
570
|
+
if (!y || !v)
|
|
571
571
|
throw new Error("Card elements not found in DOM");
|
|
572
|
-
|
|
573
|
-
cardElementId: y.id,
|
|
574
|
-
cvvElementId: f.id,
|
|
575
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
576
|
-
}), n = new globalThis.TokenEx.Iframe("card-element", {
|
|
572
|
+
n = new globalThis.TokenEx.Iframe("card-element", {
|
|
577
573
|
...m.iframeConfig,
|
|
578
574
|
placeholder: "1234 1234 1234 1234",
|
|
579
575
|
cvvPlaceholder: "CVC",
|
|
@@ -598,7 +594,7 @@ function Q({
|
|
|
598
594
|
}
|
|
599
595
|
}
|
|
600
596
|
}), n.on("load", () => {
|
|
601
|
-
|
|
597
|
+
i.setState({ loadingIframe: !1 });
|
|
602
598
|
}), n.on("autoCompleteValues", function(p) {
|
|
603
599
|
const { nameOnCard: C, cardExp: b } = p;
|
|
604
600
|
a({
|
|
@@ -607,22 +603,22 @@ function Q({
|
|
|
607
603
|
});
|
|
608
604
|
}), n.on("validate", function(p) {
|
|
609
605
|
const { isValid: C, isCvvValid: b } = p;
|
|
610
|
-
|
|
606
|
+
i.setState({
|
|
611
607
|
isCcValid: C,
|
|
612
608
|
isCvvValid: b
|
|
613
609
|
});
|
|
614
610
|
}), n.on("focus", function() {
|
|
615
|
-
|
|
611
|
+
i.setState({ isFocused: !0 });
|
|
616
612
|
}), n.on("blur", function() {
|
|
617
|
-
|
|
613
|
+
i.setState({ isFocused: !1 });
|
|
618
614
|
}), n.on("cvvFocus", function() {
|
|
619
|
-
|
|
615
|
+
i.setState({ isCvvFocused: !0 });
|
|
620
616
|
}), n.on("cvvBlur", function() {
|
|
621
|
-
|
|
617
|
+
i.setState({ isCvvFocused: !1 });
|
|
622
618
|
}), n.on(
|
|
623
619
|
"cardTypeChange",
|
|
624
620
|
function({ possibleCardType: p }) {
|
|
625
|
-
|
|
621
|
+
i.setState({ possibleCardType: p });
|
|
626
622
|
}
|
|
627
623
|
), n.load();
|
|
628
624
|
}, c = () => {
|
|
@@ -631,7 +627,7 @@ function Q({
|
|
|
631
627
|
console.warn(
|
|
632
628
|
"Card elements not found in DOM, retrying iframe initialization..."
|
|
633
629
|
);
|
|
634
|
-
const
|
|
630
|
+
const v = () => {
|
|
635
631
|
if (m++, m > y) {
|
|
636
632
|
console.error("Failed to find card elements after maximum retries");
|
|
637
633
|
return;
|
|
@@ -645,22 +641,22 @@ function Q({
|
|
|
645
641
|
if (C && b)
|
|
646
642
|
try {
|
|
647
643
|
l();
|
|
648
|
-
} catch (
|
|
649
|
-
console.error("Failed to create TokenEx iframe:",
|
|
644
|
+
} catch (g) {
|
|
645
|
+
console.error("Failed to create TokenEx iframe:", g);
|
|
650
646
|
}
|
|
651
|
-
else m < y &&
|
|
647
|
+
else m < y && v();
|
|
652
648
|
}, p);
|
|
653
649
|
};
|
|
654
|
-
|
|
650
|
+
v();
|
|
655
651
|
}, d = () => {
|
|
656
|
-
if (!
|
|
652
|
+
if (!i.getState().iframeConfig || !e)
|
|
657
653
|
return;
|
|
658
654
|
if (!globalThis.TokenEx?.Iframe) {
|
|
659
655
|
console.error("TokenEx script not loaded correctly");
|
|
660
656
|
return;
|
|
661
657
|
}
|
|
662
|
-
const y = document.getElementById("card-element"),
|
|
663
|
-
if (!y || !
|
|
658
|
+
const y = document.getElementById("card-element"), v = document.getElementById("card-cvv-element");
|
|
659
|
+
if (!y || !v) {
|
|
664
660
|
c();
|
|
665
661
|
return;
|
|
666
662
|
}
|
|
@@ -673,25 +669,25 @@ function Q({
|
|
|
673
669
|
s && await o();
|
|
674
670
|
}, E = () => {
|
|
675
671
|
n && (n.remove(), n = null);
|
|
676
|
-
},
|
|
672
|
+
}, f = async (m) => {
|
|
677
673
|
n && (n.on("tokenize", async function(y) {
|
|
678
674
|
await m(y);
|
|
679
675
|
}), n.tokenize());
|
|
680
676
|
};
|
|
681
677
|
return {
|
|
682
|
-
getState:
|
|
683
|
-
subscribe:
|
|
684
|
-
tokenize:
|
|
678
|
+
getState: i.getState.bind(i),
|
|
679
|
+
subscribe: i.subscribe.bind(i),
|
|
680
|
+
tokenize: f,
|
|
685
681
|
cleanup: E,
|
|
686
682
|
initialize: u
|
|
687
683
|
};
|
|
688
684
|
}
|
|
689
|
-
const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten",
|
|
685
|
+
const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", re = "Vollständiger Name", ie = "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 = {
|
|
690
686
|
email: ee,
|
|
691
687
|
cardholderNameLabel: te,
|
|
692
688
|
cardInformation: ae,
|
|
693
|
-
cardholderNamePlaceholder:
|
|
694
|
-
cardExpiry:
|
|
689
|
+
cardholderNamePlaceholder: re,
|
|
690
|
+
cardExpiry: ie,
|
|
695
691
|
loading: ne,
|
|
696
692
|
buttonTexts: se,
|
|
697
693
|
validation: oe
|
|
@@ -740,12 +736,12 @@ const ee = "E-Mail", te = "Name des/der Karteninhaber/in", ae = "Kartendaten", i
|
|
|
740
736
|
loading: Je,
|
|
741
737
|
buttonTexts: We,
|
|
742
738
|
validation: Xe
|
|
743
|
-
}, et = "E-mail", tt = "Nome do titular do cartão", at = "Informações do cartão",
|
|
739
|
+
}, et = "E-mail", tt = "Nome do titular do cartão", at = "Informações do cartão", rt = "Nome completo no cartão", it = "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 = {
|
|
744
740
|
email: et,
|
|
745
741
|
cardholderNameLabel: tt,
|
|
746
742
|
cardInformation: at,
|
|
747
|
-
cardholderNamePlaceholder:
|
|
748
|
-
cardExpiry:
|
|
743
|
+
cardholderNamePlaceholder: rt,
|
|
744
|
+
cardExpiry: it,
|
|
749
745
|
loading: nt,
|
|
750
746
|
buttonTexts: st,
|
|
751
747
|
validation: ot
|
|
@@ -792,18 +788,18 @@ class vt {
|
|
|
792
788
|
}
|
|
793
789
|
findNestedValue(e, t) {
|
|
794
790
|
const a = t.split(".");
|
|
795
|
-
let
|
|
796
|
-
for (const
|
|
797
|
-
if (
|
|
791
|
+
let r = e;
|
|
792
|
+
for (const i of a) {
|
|
793
|
+
if (r == null || !Object.prototype.hasOwnProperty.call(r, i))
|
|
798
794
|
return;
|
|
799
|
-
|
|
795
|
+
r = r[i];
|
|
800
796
|
}
|
|
801
|
-
return typeof
|
|
797
|
+
return typeof r == "string" ? r : void 0;
|
|
802
798
|
}
|
|
803
799
|
interpolate(e, t) {
|
|
804
|
-
return e.replace(/{{(\w+)}}/g, (a,
|
|
805
|
-
const
|
|
806
|
-
return
|
|
800
|
+
return e.replace(/{{(\w+)}}/g, (a, r) => {
|
|
801
|
+
const i = t[r];
|
|
802
|
+
return i === void 0 ? a : String(i);
|
|
807
803
|
});
|
|
808
804
|
}
|
|
809
805
|
}
|
|
@@ -823,18 +819,18 @@ function bt(s) {
|
|
|
823
819
|
return A.includes(o) ? o : Et;
|
|
824
820
|
})();
|
|
825
821
|
e.setLocale(a);
|
|
826
|
-
const
|
|
822
|
+
const r = L({
|
|
827
823
|
locale: a,
|
|
828
824
|
translationService: e
|
|
829
825
|
});
|
|
830
826
|
return {
|
|
831
|
-
store:
|
|
832
|
-
translate: (o, l) =>
|
|
827
|
+
store: r,
|
|
828
|
+
translate: (o, l) => r.getState().translationService.translate(o, l),
|
|
833
829
|
setLocale: (o) => {
|
|
834
|
-
A.includes(o) && (
|
|
830
|
+
A.includes(o) && (r.getState().translationService.setLocale(o), r.setState({ locale: o }));
|
|
835
831
|
},
|
|
836
|
-
getLocale: () =>
|
|
837
|
-
subscribe:
|
|
832
|
+
getLocale: () => r.getValue("locale"),
|
|
833
|
+
subscribe: r.subscribe.bind(r)
|
|
838
834
|
};
|
|
839
835
|
}
|
|
840
836
|
const Ct = bt(), I = () => {
|
|
@@ -852,22 +848,22 @@ const Ct = bt(), I = () => {
|
|
|
852
848
|
} };
|
|
853
849
|
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(
|
|
854
850
|
(o) => o.href.includes("fonts.googleapis.com/css2") && o.rel === "stylesheet"
|
|
855
|
-
),
|
|
856
|
-
|
|
857
|
-
const
|
|
851
|
+
), r = document.createElement("link");
|
|
852
|
+
r.rel = "stylesheet", r.href = t;
|
|
853
|
+
const i = a.find(
|
|
858
854
|
(o) => o.href.includes(`family=${e}`)
|
|
859
855
|
);
|
|
860
|
-
if (
|
|
861
|
-
|
|
856
|
+
if (i)
|
|
857
|
+
i.href = t;
|
|
862
858
|
else if (a.length > 0) {
|
|
863
859
|
const o = a.at(
|
|
864
860
|
-1
|
|
865
861
|
);
|
|
866
|
-
o?.nextSibling ? document.head.insertBefore(
|
|
862
|
+
o?.nextSibling ? document.head.insertBefore(r, o.nextSibling) : document.head.appendChild(r);
|
|
867
863
|
} else
|
|
868
|
-
document.head.appendChild(
|
|
864
|
+
document.head.appendChild(r);
|
|
869
865
|
return { cleanup: () => {
|
|
870
|
-
document.head.contains(
|
|
866
|
+
document.head.contains(r) && document.head.removeChild(r);
|
|
871
867
|
} };
|
|
872
868
|
}, xt = ({
|
|
873
869
|
scriptSrc: s,
|
|
@@ -889,7 +885,7 @@ const Ct = bt(), I = () => {
|
|
|
889
885
|
};
|
|
890
886
|
const a = document.createElement("script");
|
|
891
887
|
a.src = s, a.async = e;
|
|
892
|
-
const
|
|
888
|
+
const r = new Promise((n, o) => {
|
|
893
889
|
a.onload = () => n(!0), a.onerror = () => {
|
|
894
890
|
console.error(`Failed to load script: ${s}`), o(new Error(`Failed to load script: ${s}`));
|
|
895
891
|
};
|
|
@@ -898,11 +894,11 @@ const Ct = bt(), I = () => {
|
|
|
898
894
|
cleanup: () => {
|
|
899
895
|
document.head.contains(a) && document.head.removeChild(a);
|
|
900
896
|
},
|
|
901
|
-
isLoaded:
|
|
897
|
+
isLoaded: r
|
|
902
898
|
};
|
|
903
899
|
}, w = (s) => Object.entries(s).map(([e, t]) => {
|
|
904
|
-
const a = e.replace(/([A-Z])/g, "-$1").toLowerCase(),
|
|
905
|
-
return `${a}: ${
|
|
900
|
+
const a = e.replace(/([A-Z])/g, "-$1").toLowerCase(), r = typeof t == "number" ? `${t}px` : t;
|
|
901
|
+
return `${a}: ${r}`;
|
|
906
902
|
}).join("; ");
|
|
907
903
|
function Ft(s) {
|
|
908
904
|
if (!s)
|
|
@@ -937,22 +933,22 @@ function Ft(s) {
|
|
|
937
933
|
fontFamily: `${s.styles.fontFamily}, sans-serif`
|
|
938
934
|
}, a = {
|
|
939
935
|
color: "#dc2727"
|
|
940
|
-
}, i = {
|
|
941
|
-
outline: 0
|
|
942
936
|
}, r = {
|
|
937
|
+
outline: 0
|
|
938
|
+
}, i = {
|
|
943
939
|
fontFamily: `${s.styles.fontFamily}, sans-serif`
|
|
944
940
|
}, n = {
|
|
945
941
|
base: w(e),
|
|
946
942
|
error: w(a),
|
|
947
|
-
focus: w(
|
|
943
|
+
focus: w(r),
|
|
948
944
|
placeholder: w(t)
|
|
949
945
|
};
|
|
950
946
|
return {
|
|
951
|
-
formContainerStyle:
|
|
947
|
+
formContainerStyle: i,
|
|
952
948
|
baseStyles: e,
|
|
953
949
|
placeholderStyles: t,
|
|
954
950
|
errorStyles: a,
|
|
955
|
-
focusStyles:
|
|
951
|
+
focusStyles: r,
|
|
956
952
|
inputStyles: n
|
|
957
953
|
};
|
|
958
954
|
}
|
|
@@ -967,8 +963,8 @@ class h {
|
|
|
967
963
|
* @param attributes Optional attributes to set on the element
|
|
968
964
|
*/
|
|
969
965
|
constructor(e, t = [], a = {}) {
|
|
970
|
-
this.element = document.createElement(e), t.length > 0 && this.addClass(...t), Object.entries(a).forEach(([
|
|
971
|
-
this.setAttribute(
|
|
966
|
+
this.element = document.createElement(e), t.length > 0 && this.addClass(...t), Object.entries(a).forEach(([r, i]) => {
|
|
967
|
+
this.setAttribute(r, i);
|
|
972
968
|
});
|
|
973
969
|
}
|
|
974
970
|
/**
|
|
@@ -1070,26 +1066,26 @@ class S {
|
|
|
1070
1066
|
* Create a button element
|
|
1071
1067
|
*/
|
|
1072
1068
|
static createButton(e, t = [], a = {}) {
|
|
1073
|
-
const
|
|
1074
|
-
return
|
|
1069
|
+
const r = new h("button", t, a);
|
|
1070
|
+
return r.setText(e), r;
|
|
1075
1071
|
}
|
|
1076
1072
|
/**
|
|
1077
1073
|
* Create an input element
|
|
1078
1074
|
*/
|
|
1079
1075
|
static createInput(e, t = [], a = {}) {
|
|
1080
|
-
const
|
|
1081
|
-
return new h("input", t,
|
|
1076
|
+
const r = { type: e, ...a };
|
|
1077
|
+
return new h("input", t, r);
|
|
1082
1078
|
}
|
|
1083
1079
|
/**
|
|
1084
1080
|
* Create a text input
|
|
1085
1081
|
*/
|
|
1086
1082
|
static createTextInput(e = "", t = [], a = {}) {
|
|
1087
|
-
const
|
|
1083
|
+
const r = {
|
|
1088
1084
|
type: "text",
|
|
1089
1085
|
placeholder: e,
|
|
1090
1086
|
...a
|
|
1091
1087
|
};
|
|
1092
|
-
return new h("input", t,
|
|
1088
|
+
return new h("input", t, r);
|
|
1093
1089
|
}
|
|
1094
1090
|
/**
|
|
1095
1091
|
* Create a form element
|
|
@@ -1100,26 +1096,26 @@ class S {
|
|
|
1100
1096
|
/**
|
|
1101
1097
|
* Create a label element
|
|
1102
1098
|
*/
|
|
1103
|
-
static createLabel(e, t = "", a = [],
|
|
1104
|
-
const
|
|
1099
|
+
static createLabel(e, t = "", a = [], r = {}) {
|
|
1100
|
+
const i = t ? { for: t, ...r } : r, n = new h("label", a, i);
|
|
1105
1101
|
return n.setText(e), n;
|
|
1106
1102
|
}
|
|
1107
1103
|
/**
|
|
1108
1104
|
* Create a select element
|
|
1109
1105
|
*/
|
|
1110
1106
|
static createSelect(e, t = [], a = {}) {
|
|
1111
|
-
const
|
|
1112
|
-
return e.forEach((
|
|
1107
|
+
const r = new h("select", t, a);
|
|
1108
|
+
return e.forEach((i) => {
|
|
1113
1109
|
const n = document.createElement("option");
|
|
1114
|
-
n.value =
|
|
1115
|
-
}),
|
|
1110
|
+
n.value = i.value, n.textContent = i.text, i.selected && (n.selected = !0), r.getElement().appendChild(n);
|
|
1111
|
+
}), r;
|
|
1116
1112
|
}
|
|
1117
1113
|
/**
|
|
1118
1114
|
* Create an image element
|
|
1119
1115
|
*/
|
|
1120
|
-
static createImage(e, t = "", a = [],
|
|
1121
|
-
const
|
|
1122
|
-
return new h("img", a,
|
|
1116
|
+
static createImage(e, t = "", a = [], r = {}) {
|
|
1117
|
+
const i = { src: e, alt: t, ...r };
|
|
1118
|
+
return new h("img", a, i);
|
|
1123
1119
|
}
|
|
1124
1120
|
}
|
|
1125
1121
|
class wt extends h {
|
|
@@ -1129,18 +1125,18 @@ class wt extends h {
|
|
|
1129
1125
|
const t = S.createDiv(["error-alert"], {
|
|
1130
1126
|
role: "alert",
|
|
1131
1127
|
"aria-live": "polite"
|
|
1132
|
-
}), a = S.createDiv(["error-alert-content"]),
|
|
1128
|
+
}), a = S.createDiv(["error-alert-content"]), r = S.createDiv([
|
|
1133
1129
|
"error-alert-icon-container"
|
|
1134
1130
|
]);
|
|
1135
|
-
|
|
1136
|
-
const
|
|
1131
|
+
r.getElement().innerHTML = this.createAlertCircleSVG();
|
|
1132
|
+
const i = S.createDiv([
|
|
1137
1133
|
"error-alert-text-container"
|
|
1138
1134
|
]), n = new h("h4", [
|
|
1139
1135
|
"error-alert-title"
|
|
1140
1136
|
]);
|
|
1141
1137
|
n.setText("Checkout Error"), this.messageComponent = new h("p", [
|
|
1142
1138
|
"error-alert-message"
|
|
1143
|
-
]), this.messageComponent.setText(e.message || "Bad request"),
|
|
1139
|
+
]), this.messageComponent.setText(e.message || "Bad request"), i.appendChild(n), i.appendChild(this.messageComponent), a.appendChild(r), a.appendChild(i), t.appendChild(a), this.appendChild(t);
|
|
1144
1140
|
}
|
|
1145
1141
|
createAlertCircleSVG() {
|
|
1146
1142
|
return `
|
|
@@ -1246,8 +1242,8 @@ class Mt {
|
|
|
1246
1242
|
const {
|
|
1247
1243
|
value: t,
|
|
1248
1244
|
onChange: a,
|
|
1249
|
-
onBlur:
|
|
1250
|
-
error:
|
|
1245
|
+
onBlur: r,
|
|
1246
|
+
error: i,
|
|
1251
1247
|
errorMsg: n,
|
|
1252
1248
|
checkoutProfile: o,
|
|
1253
1249
|
translationFunc: l,
|
|
@@ -1256,7 +1252,7 @@ class Mt {
|
|
|
1256
1252
|
this.input = new T({
|
|
1257
1253
|
name: "name",
|
|
1258
1254
|
label: l("cardholderNameLabel"),
|
|
1259
|
-
error:
|
|
1255
|
+
error: i,
|
|
1260
1256
|
errorMsg: n,
|
|
1261
1257
|
styles: {
|
|
1262
1258
|
color: o.styles.textColor,
|
|
@@ -1271,7 +1267,7 @@ class Mt {
|
|
|
1271
1267
|
this.trim(), a(d);
|
|
1272
1268
|
}
|
|
1273
1269
|
}), this.input.addEventListener("blur", (d) => {
|
|
1274
|
-
|
|
1270
|
+
r(d);
|
|
1275
1271
|
});
|
|
1276
1272
|
}
|
|
1277
1273
|
getValue() {
|
|
@@ -1337,18 +1333,18 @@ class At extends h {
|
|
|
1337
1333
|
t.setAttribute("for", "cardNumber"), t.textContent = e.label, t.style.color = e.styles.color, t.style.fontSize = `${e.styles.fontSize}px`, t.style.display = "block", t.style.marginBottom = "6px", this.getElement().appendChild(t);
|
|
1338
1334
|
const a = document.createElement("div");
|
|
1339
1335
|
a.className = e.isLoading ? "loading" : "", a.style.borderRadius = `${e.styles.borderRadius}px ${e.styles.borderRadius}px 0px 0px`;
|
|
1340
|
-
const i = document.createElement("div");
|
|
1341
|
-
i.id = "card-element", i.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, i.style.zIndex = e.isFocused ? "2" : "0";
|
|
1342
1336
|
const r = document.createElement("div");
|
|
1343
|
-
|
|
1337
|
+
r.id = "card-element", r.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, r.style.zIndex = e.isFocused ? "2" : "0";
|
|
1338
|
+
const i = document.createElement("div");
|
|
1339
|
+
if (i.className = "cards-position", e.cardType === "unknown")
|
|
1344
1340
|
F.forEach((n) => {
|
|
1345
|
-
|
|
1341
|
+
i.appendChild(this.createCardIcon(n));
|
|
1346
1342
|
});
|
|
1347
1343
|
else {
|
|
1348
1344
|
const n = F.find((o) => o.type === e.cardType);
|
|
1349
|
-
n &&
|
|
1345
|
+
n && i.appendChild(this.createCardIcon(n));
|
|
1350
1346
|
}
|
|
1351
|
-
|
|
1347
|
+
r.appendChild(i), a.appendChild(r), this.getElement().appendChild(a);
|
|
1352
1348
|
}
|
|
1353
1349
|
createCardIcon(e) {
|
|
1354
1350
|
const t = document.createElement("div");
|
|
@@ -1376,13 +1372,13 @@ class At extends h {
|
|
|
1376
1372
|
const a = this.getElement().querySelector(".cards-position");
|
|
1377
1373
|
if (a)
|
|
1378
1374
|
if (a.innerHTML = "", this.cardType === "unknown")
|
|
1379
|
-
F.forEach((
|
|
1380
|
-
a.appendChild(this.createCardIcon(
|
|
1375
|
+
F.forEach((r) => {
|
|
1376
|
+
a.appendChild(this.createCardIcon(r));
|
|
1381
1377
|
});
|
|
1382
1378
|
else {
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
a.appendChild(this.createCardIcon(
|
|
1379
|
+
const r = F.find((i) => i.type === this.cardType);
|
|
1380
|
+
r ? a.appendChild(this.createCardIcon(r)) : F.forEach((i) => {
|
|
1381
|
+
a.appendChild(this.createCardIcon(i));
|
|
1386
1382
|
});
|
|
1387
1383
|
}
|
|
1388
1384
|
return this;
|
|
@@ -1398,8 +1394,8 @@ class Pt extends h {
|
|
|
1398
1394
|
const {
|
|
1399
1395
|
checkoutProfile: t,
|
|
1400
1396
|
isLoading: a,
|
|
1401
|
-
isFocused:
|
|
1402
|
-
isCvvFocused:
|
|
1397
|
+
isFocused: r,
|
|
1398
|
+
isCvvFocused: i,
|
|
1403
1399
|
isCcValid: n,
|
|
1404
1400
|
isCvvValid: o,
|
|
1405
1401
|
cardType: l,
|
|
@@ -1407,11 +1403,11 @@ class Pt extends h {
|
|
|
1407
1403
|
cardExpiryError: d,
|
|
1408
1404
|
cardExpiryTouched: u,
|
|
1409
1405
|
onChange: E,
|
|
1410
|
-
onBlur:
|
|
1406
|
+
onBlur: f,
|
|
1411
1407
|
translationFunc: m,
|
|
1412
1408
|
cardExpiryAutocomplete: y = "cc-exp"
|
|
1413
|
-
} = e,
|
|
1414
|
-
|
|
1409
|
+
} = e, v = document.createElement("div");
|
|
1410
|
+
this.cardNumber = new At({
|
|
1415
1411
|
styles: {
|
|
1416
1412
|
color: t.styles.textColor,
|
|
1417
1413
|
fontSize: t.styles.fontSize,
|
|
@@ -1419,9 +1415,9 @@ class Pt extends h {
|
|
|
1419
1415
|
},
|
|
1420
1416
|
label: m("cardInformation"),
|
|
1421
1417
|
isLoading: a,
|
|
1422
|
-
isFocused:
|
|
1418
|
+
isFocused: r,
|
|
1423
1419
|
cardType: l
|
|
1424
|
-
}),
|
|
1420
|
+
}), v.appendChild(this.cardNumber.getElement());
|
|
1425
1421
|
const p = document.createElement("div");
|
|
1426
1422
|
p.className = "card-details", this.cardExpiry = new T({
|
|
1427
1423
|
name: "cardExpiry",
|
|
@@ -1430,8 +1426,8 @@ class Pt extends h {
|
|
|
1430
1426
|
errorMsg: d,
|
|
1431
1427
|
value: c,
|
|
1432
1428
|
autocomplete: y,
|
|
1433
|
-
onChange: (
|
|
1434
|
-
this.trimCardExpiry(), E(
|
|
1429
|
+
onChange: (g) => {
|
|
1430
|
+
this.trimCardExpiry(), E(g);
|
|
1435
1431
|
},
|
|
1436
1432
|
styles: {
|
|
1437
1433
|
color: t.styles.textColor,
|
|
@@ -1439,8 +1435,8 @@ class Pt extends h {
|
|
|
1439
1435
|
fontSize: t.styles.fontSize,
|
|
1440
1436
|
fontFamily: t.styles.fontFamily
|
|
1441
1437
|
}
|
|
1442
|
-
}), this.cardExpiry.addEventListener("blur",
|
|
1443
|
-
const M =
|
|
1438
|
+
}), this.cardExpiry.addEventListener("blur", f), this.cardExpiry.addEventListener("keydown", (g) => {
|
|
1439
|
+
const M = g;
|
|
1444
1440
|
![
|
|
1445
1441
|
"Backspace",
|
|
1446
1442
|
"Delete",
|
|
@@ -1457,18 +1453,18 @@ class Pt extends h {
|
|
|
1457
1453
|
borderRadius: typeof t.styles.borderRadius == "number" ? t.styles.borderRadius : 0
|
|
1458
1454
|
},
|
|
1459
1455
|
isLoading: a,
|
|
1460
|
-
isFocused:
|
|
1461
|
-
}), b.appendChild(this.cardCvv.getElement()), p.appendChild(this.cardExpiry.getElement()), p.appendChild(b),
|
|
1462
|
-
const
|
|
1456
|
+
isFocused: i
|
|
1457
|
+
}), b.appendChild(this.cardCvv.getElement()), p.appendChild(this.cardExpiry.getElement()), p.appendChild(b), v.appendChild(p), this.getElement().appendChild(v), r && !n) {
|
|
1458
|
+
const g = new x({
|
|
1463
1459
|
text: m("validation.cardNumberInvalid")
|
|
1464
1460
|
});
|
|
1465
|
-
this.validationMessages.set("cardNumber",
|
|
1461
|
+
this.validationMessages.set("cardNumber", g), this.appendChild(g);
|
|
1466
1462
|
}
|
|
1467
|
-
if (
|
|
1468
|
-
const
|
|
1463
|
+
if (i && !o) {
|
|
1464
|
+
const g = new x({
|
|
1469
1465
|
text: m("validation.cardSecurityFormat")
|
|
1470
1466
|
});
|
|
1471
|
-
this.validationMessages.set("cardCvv",
|
|
1467
|
+
this.validationMessages.set("cardCvv", g), this.appendChild(g);
|
|
1472
1468
|
}
|
|
1473
1469
|
}
|
|
1474
1470
|
updateCardType(e) {
|
|
@@ -1487,28 +1483,28 @@ class Pt extends h {
|
|
|
1487
1483
|
updateCardNumberValidation(e, t, a) {
|
|
1488
1484
|
if (this.cardNumber.setFocused(e), e && !t) {
|
|
1489
1485
|
if (!this.validationMessages.has("cardNumber")) {
|
|
1490
|
-
const
|
|
1486
|
+
const r = new x({
|
|
1491
1487
|
text: a("validation.cardNumberInvalid")
|
|
1492
1488
|
});
|
|
1493
|
-
this.validationMessages.set("cardNumber",
|
|
1489
|
+
this.validationMessages.set("cardNumber", r), this.appendChild(r);
|
|
1494
1490
|
}
|
|
1495
1491
|
} else {
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1492
|
+
const r = this.validationMessages.get("cardNumber");
|
|
1493
|
+
r && (r.getElement().remove(), this.validationMessages.delete("cardNumber"));
|
|
1498
1494
|
}
|
|
1499
1495
|
return this;
|
|
1500
1496
|
}
|
|
1501
1497
|
updateCardCvvValidation(e, t, a) {
|
|
1502
1498
|
if (this.cardCvv.setFocused(e), e && !t) {
|
|
1503
1499
|
if (!this.validationMessages.has("cardCvv")) {
|
|
1504
|
-
const
|
|
1500
|
+
const r = new x({
|
|
1505
1501
|
text: a("validation.cardSecurityFormat")
|
|
1506
1502
|
});
|
|
1507
|
-
this.validationMessages.set("cardCvv",
|
|
1503
|
+
this.validationMessages.set("cardCvv", r), this.appendChild(r);
|
|
1508
1504
|
}
|
|
1509
1505
|
} else {
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1506
|
+
const r = this.validationMessages.get("cardCvv");
|
|
1507
|
+
r && (r.getElement().remove(), this.validationMessages.delete("cardCvv"));
|
|
1512
1508
|
}
|
|
1513
1509
|
return this;
|
|
1514
1510
|
}
|
|
@@ -1522,8 +1518,8 @@ class Dt {
|
|
|
1522
1518
|
const {
|
|
1523
1519
|
value: t,
|
|
1524
1520
|
onChange: a,
|
|
1525
|
-
onBlur:
|
|
1526
|
-
error:
|
|
1521
|
+
onBlur: r,
|
|
1522
|
+
error: i,
|
|
1527
1523
|
errorMsg: n,
|
|
1528
1524
|
checkoutProfile: o,
|
|
1529
1525
|
translationFunc: l,
|
|
@@ -1532,7 +1528,7 @@ class Dt {
|
|
|
1532
1528
|
this.input = new T({
|
|
1533
1529
|
name: "email",
|
|
1534
1530
|
label: l("email"),
|
|
1535
|
-
error:
|
|
1531
|
+
error: i,
|
|
1536
1532
|
errorMsg: n,
|
|
1537
1533
|
styles: {
|
|
1538
1534
|
color: o.styles.textColor,
|
|
@@ -1548,7 +1544,7 @@ class Dt {
|
|
|
1548
1544
|
onChange: (d) => {
|
|
1549
1545
|
this.trim(), a(d);
|
|
1550
1546
|
}
|
|
1551
|
-
}), this.input.addEventListener("blur",
|
|
1547
|
+
}), this.input.addEventListener("blur", r);
|
|
1552
1548
|
}
|
|
1553
1549
|
getValue() {
|
|
1554
1550
|
return this.input.getValue();
|
|
@@ -1579,10 +1575,10 @@ class Rt extends h {
|
|
|
1579
1575
|
super("div", ["paypal"]);
|
|
1580
1576
|
const { formData: t, onSubmit: a } = e;
|
|
1581
1577
|
this.formData = t, this.onSubmit = a, this.getElement().style.cursor = a ? "pointer" : "default", this.getElement().style.opacity = "1";
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1578
|
+
const r = document.createElement("div");
|
|
1579
|
+
r.className = "paypal-icon-container";
|
|
1580
|
+
const i = document.createElement("img");
|
|
1581
|
+
i.src = $t, i.style.width = "69px", i.style.height = "22px", i.style.maxWidth = "100%", i.style.display = "block", i.style.height = "auto", r.appendChild(i), this.getElement().appendChild(r), a && this.getElement().addEventListener("click", () => this.handleSubmit());
|
|
1586
1582
|
}
|
|
1587
1583
|
async handleSubmit() {
|
|
1588
1584
|
if (!(!this.onSubmit || this.isSubmitting)) {
|
|
@@ -1606,26 +1602,26 @@ class Rt extends h {
|
|
|
1606
1602
|
class Vt extends h {
|
|
1607
1603
|
paymentMethods;
|
|
1608
1604
|
constructor(e) {
|
|
1609
|
-
const { checkoutProfile: t, formData: a, onPaypalSubmit:
|
|
1605
|
+
const { checkoutProfile: t, formData: a, onPaypalSubmit: r } = e;
|
|
1610
1606
|
if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
|
|
1611
1607
|
this.getElement().style.display = "none";
|
|
1612
1608
|
return;
|
|
1613
1609
|
}
|
|
1614
|
-
const
|
|
1610
|
+
const i = Object.entries(
|
|
1615
1611
|
t.additionalPaymentMethods
|
|
1616
1612
|
).filter(([, n]) => n.enabled).sort((n, o) => n[1].order - o[1].order);
|
|
1617
|
-
if (
|
|
1613
|
+
if (i.length === 0) {
|
|
1618
1614
|
this.getElement().style.display = "none";
|
|
1619
1615
|
return;
|
|
1620
1616
|
}
|
|
1621
|
-
for (const [n] of
|
|
1617
|
+
for (const [n] of i)
|
|
1622
1618
|
switch (n) {
|
|
1623
1619
|
case "paypal": {
|
|
1624
|
-
if (
|
|
1620
|
+
if (r) {
|
|
1625
1621
|
const o = new Rt({
|
|
1626
1622
|
checkoutProfile: t,
|
|
1627
1623
|
formData: a,
|
|
1628
|
-
onSubmit:
|
|
1624
|
+
onSubmit: r
|
|
1629
1625
|
});
|
|
1630
1626
|
this.paymentMethods.set("paypal", o), o.appendTo(this.getElement());
|
|
1631
1627
|
}
|
|
@@ -1668,9 +1664,9 @@ class Ot extends h {
|
|
|
1668
1664
|
class Ht {
|
|
1669
1665
|
button;
|
|
1670
1666
|
constructor(e) {
|
|
1671
|
-
const { disabled: t, checkoutProfile: a, translationFunc:
|
|
1667
|
+
const { disabled: t, checkoutProfile: a, translationFunc: r } = e;
|
|
1672
1668
|
this.button = new Ot({
|
|
1673
|
-
text:
|
|
1669
|
+
text: r(
|
|
1674
1670
|
`buttonTexts.${a?.layout.actionButton.translationKey}`
|
|
1675
1671
|
),
|
|
1676
1672
|
styles: {
|
|
@@ -1782,16 +1778,12 @@ class Ut extends h {
|
|
|
1782
1778
|
);
|
|
1783
1779
|
this.applyFormContainerStyles(a);
|
|
1784
1780
|
try {
|
|
1785
|
-
this.cardSection ||
|
|
1786
|
-
cardElementExists: !!document.getElementById("card-element"),
|
|
1787
|
-
cvvElementExists: !!document.getElementById("card-cvv-element"),
|
|
1788
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1789
|
-
}));
|
|
1781
|
+
this.cardSection || this.createCardSection(e.checkoutProfile);
|
|
1790
1782
|
} catch (n) {
|
|
1791
1783
|
console.error("Failed to create card section:", n);
|
|
1792
1784
|
}
|
|
1793
|
-
const
|
|
1794
|
-
if (!
|
|
1785
|
+
const r = document.getElementById("card-element"), i = document.getElementById("card-cvv-element");
|
|
1786
|
+
if (!r || !i) {
|
|
1795
1787
|
console.error(
|
|
1796
1788
|
"Card elements not found, cannot initialize TokenEx iframe"
|
|
1797
1789
|
);
|
|
@@ -1805,9 +1797,7 @@ class Ut extends h {
|
|
|
1805
1797
|
this.formManager.setFormData(n);
|
|
1806
1798
|
},
|
|
1807
1799
|
environment: this.options.environment
|
|
1808
|
-
}), this.iframeHook?.subscribe(this.handleIframeStateChange), await this.iframeHook?.initialize()
|
|
1809
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1810
|
-
});
|
|
1800
|
+
}), this.iframeHook?.subscribe(this.handleIframeStateChange), await this.iframeHook?.initialize();
|
|
1811
1801
|
} catch (t) {
|
|
1812
1802
|
throw console.error("Failed to initialize payment form:", t), t;
|
|
1813
1803
|
}
|
|
@@ -1826,8 +1816,8 @@ class Ut extends h {
|
|
|
1826
1816
|
createCardSection = (e) => {
|
|
1827
1817
|
if (!this.cardSection)
|
|
1828
1818
|
try {
|
|
1829
|
-
const { formData: t, errors: a, touched:
|
|
1830
|
-
let
|
|
1819
|
+
const { formData: t, errors: a, touched: r } = this._getFormStateData();
|
|
1820
|
+
let i = {
|
|
1831
1821
|
loadingIframe: !0,
|
|
1832
1822
|
isFocused: !1,
|
|
1833
1823
|
isCvvFocused: !1,
|
|
@@ -1835,17 +1825,17 @@ class Ut extends h {
|
|
|
1835
1825
|
isCvvValid: !1,
|
|
1836
1826
|
possibleCardType: "unknown"
|
|
1837
1827
|
};
|
|
1838
|
-
if (this.iframeHook && (
|
|
1828
|
+
if (this.iframeHook && (i = this.iframeHook.getState()), this.cardSection = new Pt({
|
|
1839
1829
|
checkoutProfile: e,
|
|
1840
|
-
isLoading:
|
|
1841
|
-
isFocused:
|
|
1842
|
-
isCvvFocused:
|
|
1843
|
-
isCcValid:
|
|
1844
|
-
isCvvValid:
|
|
1845
|
-
cardType:
|
|
1830
|
+
isLoading: i.loadingIframe,
|
|
1831
|
+
isFocused: i.isFocused,
|
|
1832
|
+
isCvvFocused: i.isCvvFocused,
|
|
1833
|
+
isCcValid: i.isCcValid,
|
|
1834
|
+
isCvvValid: i.isCvvValid,
|
|
1835
|
+
cardType: i.possibleCardType,
|
|
1846
1836
|
cardExpiry: t.cardExpiry,
|
|
1847
1837
|
cardExpiryError: a.cardExpiry,
|
|
1848
|
-
cardExpiryTouched: !!
|
|
1838
|
+
cardExpiryTouched: !!r.cardExpiry,
|
|
1849
1839
|
onChange: this.handleChange,
|
|
1850
1840
|
onBlur: this.handleBlur,
|
|
1851
1841
|
translationFunc: this.translation.t
|
|
@@ -1912,18 +1902,10 @@ class Ut extends h {
|
|
|
1912
1902
|
}
|
|
1913
1903
|
createPaymentMethods(e) {
|
|
1914
1904
|
try {
|
|
1915
|
-
if (!e?.additionalPaymentMethods
|
|
1916
|
-
console.log(
|
|
1917
|
-
"No additional payment methods configured, skipping component"
|
|
1918
|
-
);
|
|
1919
|
-
return;
|
|
1920
|
-
}
|
|
1921
|
-
if (Object.entries(
|
|
1905
|
+
if (!e?.additionalPaymentMethods || Object.entries(
|
|
1922
1906
|
e.additionalPaymentMethods
|
|
1923
|
-
).filter(([,
|
|
1924
|
-
console.log("No enabled payment methods found, skipping component");
|
|
1907
|
+
).filter(([, r]) => r.enabled).length === 0)
|
|
1925
1908
|
return;
|
|
1926
|
-
}
|
|
1927
1909
|
const { formData: a } = this._getFormStateData();
|
|
1928
1910
|
this.paymentMethods = new Vt({
|
|
1929
1911
|
checkoutProfile: e,
|
|
@@ -1938,12 +1920,12 @@ class Ut extends h {
|
|
|
1938
1920
|
}
|
|
1939
1921
|
createEmailField(e) {
|
|
1940
1922
|
try {
|
|
1941
|
-
const { formData: t, errors: a, touched:
|
|
1923
|
+
const { formData: t, errors: a, touched: r } = this._getFormStateData();
|
|
1942
1924
|
this.emailField = new Dt({
|
|
1943
1925
|
value: t.email,
|
|
1944
1926
|
onChange: this.handleChange,
|
|
1945
1927
|
onBlur: this.handleBlur,
|
|
1946
|
-
error: !!(a.email &&
|
|
1928
|
+
error: !!(a.email && r.email),
|
|
1947
1929
|
errorMsg: a.email,
|
|
1948
1930
|
checkoutProfile: e,
|
|
1949
1931
|
translationFunc: this.translation.t
|
|
@@ -1954,12 +1936,12 @@ class Ut extends h {
|
|
|
1954
1936
|
}
|
|
1955
1937
|
createCardholderSection(e) {
|
|
1956
1938
|
try {
|
|
1957
|
-
const { formData: t, errors: a, touched:
|
|
1939
|
+
const { formData: t, errors: a, touched: r } = this._getFormStateData();
|
|
1958
1940
|
this.cardholderSection = new Mt({
|
|
1959
1941
|
value: t.name,
|
|
1960
1942
|
onChange: this.handleChange,
|
|
1961
1943
|
onBlur: this.handleBlur,
|
|
1962
|
-
error: !!(a.name &&
|
|
1944
|
+
error: !!(a.name && r.name),
|
|
1963
1945
|
errorMsg: a.name,
|
|
1964
1946
|
checkoutProfile: e,
|
|
1965
1947
|
translationFunc: this.translation.t
|
|
@@ -1980,12 +1962,12 @@ class Ut extends h {
|
|
|
1980
1962
|
}
|
|
1981
1963
|
}
|
|
1982
1964
|
handleChange = (e) => {
|
|
1983
|
-
const t = e.target, { name: a, value:
|
|
1984
|
-
this.formManager.handleChange(a,
|
|
1965
|
+
const t = e.target, { name: a, value: r } = t;
|
|
1966
|
+
this.formManager.handleChange(a, r);
|
|
1985
1967
|
};
|
|
1986
1968
|
handleBlur = (e) => {
|
|
1987
|
-
const t = e.target, { name: a, value:
|
|
1988
|
-
this.formManager.handleBlur(a,
|
|
1969
|
+
const t = e.target, { name: a, value: r } = t;
|
|
1970
|
+
this.formManager.handleBlur(a, r);
|
|
1989
1971
|
};
|
|
1990
1972
|
updateFormUI() {
|
|
1991
1973
|
const e = this.formManager.getFormState();
|
|
@@ -2008,12 +1990,12 @@ class Ut extends h {
|
|
|
2008
1990
|
isCvvValid: !1
|
|
2009
1991
|
};
|
|
2010
1992
|
this.iframeHook && (t = this.iframeHook.getState());
|
|
2011
|
-
const a = Object.keys(e.errors).length > 0,
|
|
1993
|
+
const a = Object.keys(e.errors).length > 0, r = (
|
|
2012
1994
|
// Only require card validation if CardSection exists
|
|
2013
1995
|
(!this.cardSection || t.isCcValid && t.isCvvValid) && !!e.formData.email && !!e.formData.name && // Only require card expiry if CardSection exists
|
|
2014
1996
|
(!this.cardSection || !!e.formData.cardExpiry)
|
|
2015
1997
|
);
|
|
2016
|
-
return a || !
|
|
1998
|
+
return a || !r || this.isSubmitting;
|
|
2017
1999
|
}
|
|
2018
2000
|
setLoadingState(e) {
|
|
2019
2001
|
if (this.options.onLoadingStateChange) {
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.form-container{display:grid;gap:24px;padding:4px;position:relative;min-height:400px;max-width:100%;text-align:left}.form-container>*{font-family:inherit}.card-
|
|
1
|
+
.form-container{display:grid;gap:24px;padding:4px;position:relative;min-height:400px;max-width:100%;text-align:left}.form-container>*{font-family:inherit}.card-details{display:flex}@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.error-alert{background-color:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f;animation:slideIn .3s ease-out}.error-alert-content{display:flex;align-items:flex-start;gap:12px}.error-alert-icon-container{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:#fee2e2;border-radius:50%;color:#dc2626}.error-alert-icon{color:#dc2626}.error-alert-text-container{flex:1;min-width:0}.error-alert-title{margin:0 0 4px;font-size:14px;font-weight:600;color:#991b1b;line-height:1.4}.error-alert-message{margin:0;font-size:14px;color:#7f1d1d;line-height:1.5;word-break:break-word}.blur-bg{position:absolute;inset:0;height:100%;width:100%;background:transparent;display:flex;flex-direction:column;align-items:center;justify-content:center;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(3.5px);z-index:9999}.loader{width:64px;height:64px;border:6px solid transparent;border-top:6px solid #4f81ff;border-right:6px solid #36d1dc;border-radius:50%;animation:spin 1s ease-in-out infinite,glow 1.5s ease-in-out infinite alternate;box-shadow:0 0 #4f81ff00}@keyframes spin{to{transform:rotate(360deg)}}@keyframes glow{0%{box-shadow:0 0 #4f81ff00}to{box-shadow:0 0 20px #4f81ff99}}.title{margin-top:20px;font-size:18px;color:#4f4f4f;animation:fadeIn 1s ease-in-out}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.input-wrapper{display:flex;flex-direction:column;width:100%;min-width:0;flex-grow:1;flex-basis:0;box-sizing:border-box}.input-wrapper *{box-sizing:border-box}.form-input{opacity:1;font-weight:400;letter-spacing:.02em;transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;background:#fff;padding:8px 12px;border:none;outline:none;line-height:1.5;z-index:0;box-sizing:border-box}.form-input-error{color:#dc2727}.form-input::placeholder{color:#717173;opacity:.3}.form-input:focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;z-index:2}.form-helper-text{color:#dc2727;font-size:12px;font-weight:500;margin-top:4px}.input-label{margin-bottom:6px}.card-element{position:relative;height:38.5px;transition:box-shadow .1s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;padding:0;border:none;background:#fff;border-radius:inherit;box-sizing:border-box}.card-element iframe{width:100%;min-width:0;display:block}.card-element-focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}.card-icon{width:16px;transition:opacity .6s ease-in;opacity:1}.card-icon img{max-width:100%;display:block;height:auto}.cards-position{position:absolute;z-index:10;right:20px;top:8px;display:flex;align-items:center;gap:8px;pointer-events:none}.loading{position:relative}.loading:after{content:"";position:absolute;inset:0;height:100%;width:100%;backdrop-filter:blur(3px);border-radius:inherit}@media only screen and (min-width: 600px){.card-icon{width:20px}}.paypal{background-color:#ffc439;color:#253b80;font-weight:700;padding:8px 16px;box-shadow:0 2px 4px #0000001a;text-transform:none;cursor:pointer;border-radius:4px}.paypal:hover{background-color:#ffc439;filter:brightness(.95)}.paypal-icon-container{display:flex;align-items:center;justify-content:center}.paypal-icon-container img{width:69px;height:22px}.button{position:relative;display:inline-flex;align-items:center;justify-content:center;padding:8px 16px;font-size:14px;font-weight:500;line-height:1.5;text-align:center;cursor:pointer;transition:all .2s ease;font-weight:700;border:none;outline:none;white-space:nowrap;height:min-content;width:100%}.disabled{pointer-events:none}.valid{outline:none;overflow:hidden;transition:all .3s ease}.valid:before{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.4),transparent);transition:left .5s;animation:glowSlide 6s infinite}@keyframes glowSlide{0%{left:-100%}50%{left:100%}to{left:100%}}.valid:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,.1) 25%,rgba(255,255,255,.3) 50%,rgba(255,255,255,.1) 75%,transparent 100%);transform:translate(-100%);animation:smoothGlow 7s infinite}@keyframes smoothGlow{0%{transform:translate(-100%)}to{transform:translate(100%)}}
|
package/dist/package.json
CHANGED