@odus/checkout 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -5
- package/dist/checkout.d.ts +1 -0
- package/dist/checkout.es.js +378 -376
- package/dist/checkout.es.js.map +1 -1
- package/dist/checkout.umd.js +3 -3
- package/dist/checkout.umd.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const
|
|
2
|
-
const [e, ...t] = n?.split(" ") || [], [
|
|
3
|
-
return { firstName: e, lastName:
|
|
1
|
+
const L = (n) => n === "test" ? "https://sandbox-api.odus.com" : n === "live" ? "https://api.odus.com" : "http://localhost:3000", A = ({ name: n }) => {
|
|
2
|
+
const [e, ...t] = n?.split(" ") || [], [a] = t.reverse();
|
|
3
|
+
return { firstName: e, lastName: a };
|
|
4
4
|
};
|
|
5
5
|
class V {
|
|
6
6
|
apiKey;
|
|
7
7
|
baseUrl;
|
|
8
8
|
browserInfo;
|
|
9
|
-
constructor(e, t,
|
|
10
|
-
this.apiKey = e, this.baseUrl =
|
|
9
|
+
constructor(e, t, a) {
|
|
10
|
+
this.apiKey = e, this.baseUrl = L(t), this.browserInfo = a || { userAgent: navigator.userAgent };
|
|
11
11
|
}
|
|
12
12
|
async fetchApi({
|
|
13
13
|
endpoint: e,
|
|
14
14
|
method: t = "POST",
|
|
15
|
-
body:
|
|
16
|
-
customHeaders:
|
|
15
|
+
body: a,
|
|
16
|
+
customHeaders: i = {}
|
|
17
17
|
}) {
|
|
18
18
|
const s = {
|
|
19
19
|
Authorization: `Bearer ${this.apiKey}`,
|
|
20
20
|
"Content-Type": "application/json",
|
|
21
|
-
...
|
|
21
|
+
...i
|
|
22
22
|
};
|
|
23
23
|
try {
|
|
24
24
|
const r = await fetch(`${this.baseUrl}${e}`, {
|
|
25
25
|
method: t,
|
|
26
26
|
headers: s,
|
|
27
|
-
body:
|
|
27
|
+
body: a ? JSON.stringify(a) : void 0
|
|
28
28
|
});
|
|
29
29
|
if (!r.ok) {
|
|
30
30
|
let o;
|
|
@@ -54,25 +54,25 @@ class V {
|
|
|
54
54
|
async authorizePayment({
|
|
55
55
|
paymentId: e,
|
|
56
56
|
checkoutKey: t,
|
|
57
|
-
formData:
|
|
58
|
-
token:
|
|
57
|
+
formData: a,
|
|
58
|
+
token: i,
|
|
59
59
|
returnUrl: s
|
|
60
60
|
}) {
|
|
61
61
|
let r = {};
|
|
62
|
-
if (
|
|
63
|
-
const o =
|
|
62
|
+
if (i && a) {
|
|
63
|
+
const o = a.cardExpiry.replace(/\s+/g, "").split("/"), l = o[0], c = o[1], { firstName: h, lastName: m } = A({ name: a.name });
|
|
64
64
|
r = {
|
|
65
65
|
paymentMethodData: {
|
|
66
66
|
type: "card",
|
|
67
67
|
card: {
|
|
68
|
-
token:
|
|
68
|
+
token: i,
|
|
69
69
|
expMonth: l,
|
|
70
70
|
expYear: `20${c}`,
|
|
71
|
-
cardholderName:
|
|
71
|
+
cardholderName: a.name
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
customerData: {
|
|
75
|
-
email:
|
|
75
|
+
email: a.email,
|
|
76
76
|
firstName: h,
|
|
77
77
|
lastName: m
|
|
78
78
|
},
|
|
@@ -100,23 +100,23 @@ class V {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
const
|
|
103
|
+
const $ = async ({
|
|
104
104
|
id: n,
|
|
105
105
|
apiKey: e,
|
|
106
106
|
environment: t
|
|
107
107
|
}) => {
|
|
108
|
-
const
|
|
108
|
+
const a = L(t), i = await fetch(`${a}/checkout-profiles/${n}`, {
|
|
109
109
|
method: "GET",
|
|
110
110
|
headers: {
|
|
111
111
|
"Content-Type": "application/json",
|
|
112
112
|
Authorization: `Bearer ${e}`
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
|
-
if (!
|
|
116
|
-
throw new Error(`HTTP error! Status: ${
|
|
117
|
-
return await
|
|
115
|
+
if (!i.ok)
|
|
116
|
+
throw new Error(`HTTP error! Status: ${i.status}`);
|
|
117
|
+
return await i.json();
|
|
118
118
|
};
|
|
119
|
-
class
|
|
119
|
+
class R {
|
|
120
120
|
events = /* @__PURE__ */ new Map();
|
|
121
121
|
/**
|
|
122
122
|
* Subscribe to an event
|
|
@@ -126,8 +126,8 @@ class $ {
|
|
|
126
126
|
*/
|
|
127
127
|
subscribe(e, t) {
|
|
128
128
|
return this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e)?.add(t), () => {
|
|
129
|
-
const
|
|
130
|
-
|
|
129
|
+
const a = this.events.get(e);
|
|
130
|
+
a && (a.delete(t), a.size === 0 && this.events.delete(e));
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
@@ -136,8 +136,8 @@ class $ {
|
|
|
136
136
|
* @param data - The data to pass to subscribers
|
|
137
137
|
*/
|
|
138
138
|
publish(e, t) {
|
|
139
|
-
const
|
|
140
|
-
|
|
139
|
+
const a = this.events.get(e);
|
|
140
|
+
a && a.forEach((i) => i(t));
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Clear all event subscriptions
|
|
@@ -154,13 +154,13 @@ class $ {
|
|
|
154
154
|
return this.events.get(e)?.size || 0;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
const
|
|
158
|
-
class
|
|
157
|
+
const B = new R();
|
|
158
|
+
class O {
|
|
159
159
|
state;
|
|
160
160
|
initialState;
|
|
161
161
|
eventBus;
|
|
162
162
|
stateChangedEvent = "state-changed";
|
|
163
|
-
constructor(e, t =
|
|
163
|
+
constructor(e, t = B) {
|
|
164
164
|
this.initialState = { ...e }, this.state = { ...e }, this.eventBus = t;
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
@@ -201,41 +201,41 @@ class B {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
function x(n) {
|
|
204
|
-
return new
|
|
204
|
+
return new O(n);
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function H({
|
|
207
207
|
apiKey: n,
|
|
208
208
|
profileId: e,
|
|
209
209
|
environment: t
|
|
210
210
|
}) {
|
|
211
|
-
const
|
|
211
|
+
const a = x({
|
|
212
212
|
checkoutProfile: void 0,
|
|
213
213
|
isLoading: !0,
|
|
214
214
|
error: null
|
|
215
|
-
}),
|
|
215
|
+
}), i = async () => {
|
|
216
216
|
try {
|
|
217
|
-
|
|
218
|
-
const s = await
|
|
217
|
+
a.setState({ isLoading: !0 });
|
|
218
|
+
const s = await $({
|
|
219
219
|
apiKey: n,
|
|
220
220
|
id: e,
|
|
221
221
|
environment: t
|
|
222
222
|
});
|
|
223
|
-
s &&
|
|
223
|
+
s && a.setState({
|
|
224
224
|
checkoutProfile: s,
|
|
225
225
|
isLoading: !1,
|
|
226
226
|
error: null
|
|
227
227
|
});
|
|
228
228
|
} catch (s) {
|
|
229
|
-
|
|
229
|
+
a.setState({
|
|
230
230
|
error: "Failed to load checkout profile",
|
|
231
231
|
isLoading: !1
|
|
232
232
|
}), console.error(s);
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
|
-
return
|
|
236
|
-
getState:
|
|
237
|
-
subscribe:
|
|
238
|
-
reload:
|
|
235
|
+
return i(), {
|
|
236
|
+
getState: a.getState.bind(a),
|
|
237
|
+
subscribe: a.subscribe.bind(a),
|
|
238
|
+
reload: i
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
const T = {
|
|
@@ -244,7 +244,7 @@ const T = {
|
|
|
244
244
|
const t = n.replace(/\D/g, "").slice(0, 4);
|
|
245
245
|
return t.length > 2 ? `${t.slice(0, 2)} / ${t.slice(2)}` : t;
|
|
246
246
|
}
|
|
247
|
-
},
|
|
247
|
+
}, P = {
|
|
248
248
|
"gmail.com": [
|
|
249
249
|
"gmal.com",
|
|
250
250
|
"gmil.com",
|
|
@@ -316,7 +316,7 @@ const T = {
|
|
|
316
316
|
"comcast.net": ["comcast.com", "comcat.net", "comcst.net", "comcastnet", "comcast.nt", "comcas.net"],
|
|
317
317
|
"verizon.net": ["verizon.com", "verizon.nt", "verizonnet", "verizn.net", "verizon.ne", "verzon.net"],
|
|
318
318
|
"att.net": ["att.com", "at.net", "att.nt", "attnet", "att.ne", "attt.net"]
|
|
319
|
-
},
|
|
319
|
+
}, j = (n) => {
|
|
320
320
|
if (!n || n.includes("."))
|
|
321
321
|
return null;
|
|
322
322
|
const e = ["com", "net", "org", "edu", "gov", "io", "co"];
|
|
@@ -324,60 +324,60 @@ const T = {
|
|
|
324
324
|
if (n === "companycok" && t === "co")
|
|
325
325
|
return "company.co";
|
|
326
326
|
if (n.endsWith(t) && !n.includes(".")) {
|
|
327
|
-
const
|
|
328
|
-
return `${n.substring(0,
|
|
327
|
+
const a = n.length - t.length;
|
|
328
|
+
return `${n.substring(0, a)}.${t}`;
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
return null;
|
|
332
|
-
},
|
|
332
|
+
}, K = (n, e) => {
|
|
333
333
|
if (n.length === 0) return e.length;
|
|
334
334
|
if (e.length === 0) return n.length;
|
|
335
|
-
const t = e.length + 1,
|
|
335
|
+
const t = e.length + 1, a = n.length + 1, i = Array.from(
|
|
336
336
|
{ length: t },
|
|
337
|
-
(s, r) => Array.from({ length:
|
|
337
|
+
(s, r) => Array.from({ length: a }, (o, l) => r === 0 ? l : l === 0 ? r : 0)
|
|
338
338
|
);
|
|
339
339
|
for (let s = 1; s < t; s++)
|
|
340
|
-
for (let r = 1; r <
|
|
340
|
+
for (let r = 1; r < a; r++) {
|
|
341
341
|
const o = n[r - 1] === e[s - 1] ? 0 : 1;
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
i[s][r] = Math.min(
|
|
343
|
+
i[s - 1][r] + 1,
|
|
344
344
|
// deletion
|
|
345
|
-
|
|
345
|
+
i[s][r - 1] + 1,
|
|
346
346
|
// insertion
|
|
347
|
-
|
|
347
|
+
i[s - 1][r - 1] + o
|
|
348
348
|
// substitution
|
|
349
349
|
);
|
|
350
350
|
}
|
|
351
|
-
return
|
|
352
|
-
},
|
|
353
|
-
let t = null,
|
|
354
|
-
const
|
|
355
|
-
for (const s of Object.keys(
|
|
356
|
-
const r =
|
|
357
|
-
r <= 2 && r <
|
|
351
|
+
return i[e.length][n.length];
|
|
352
|
+
}, U = (n) => {
|
|
353
|
+
let t = null, a = 3;
|
|
354
|
+
const i = n.toLowerCase();
|
|
355
|
+
for (const s of Object.keys(P)) {
|
|
356
|
+
const r = K(i, s);
|
|
357
|
+
r <= 2 && r < a && (a = r, t = s);
|
|
358
358
|
}
|
|
359
359
|
return t;
|
|
360
|
-
},
|
|
361
|
-
const { t: n } =
|
|
360
|
+
}, q = () => {
|
|
361
|
+
const { t: n } = M();
|
|
362
362
|
return {
|
|
363
363
|
validateEmail: (t) => {
|
|
364
|
-
const
|
|
364
|
+
const a = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
365
365
|
if (!t)
|
|
366
366
|
return {
|
|
367
367
|
isValid: !1,
|
|
368
368
|
message: n("validation.emailInvalid"),
|
|
369
369
|
suggestion: null
|
|
370
370
|
};
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
371
|
+
const i = t.indexOf("@");
|
|
372
|
+
if (i === -1)
|
|
373
373
|
return {
|
|
374
374
|
isValid: !1,
|
|
375
375
|
message: n("validation.emailInvalid"),
|
|
376
376
|
suggestion: null
|
|
377
377
|
};
|
|
378
|
-
const s = t.substring(0,
|
|
378
|
+
const s = t.substring(0, i), r = t.substring(i + 1);
|
|
379
379
|
if (!r.includes(".")) {
|
|
380
|
-
const l =
|
|
380
|
+
const l = j(r);
|
|
381
381
|
if (l)
|
|
382
382
|
return {
|
|
383
383
|
isValid: !1,
|
|
@@ -386,7 +386,7 @@ const T = {
|
|
|
386
386
|
}),
|
|
387
387
|
suggestion: `${s}@${l}`
|
|
388
388
|
};
|
|
389
|
-
for (const c of Object.keys(
|
|
389
|
+
for (const c of Object.keys(P))
|
|
390
390
|
if (c.replace(/\./g, "") === r)
|
|
391
391
|
return {
|
|
392
392
|
isValid: !1,
|
|
@@ -396,13 +396,13 @@ const T = {
|
|
|
396
396
|
suggestion: `${s}@${c}`
|
|
397
397
|
};
|
|
398
398
|
}
|
|
399
|
-
if (!
|
|
399
|
+
if (!a.test(t))
|
|
400
400
|
return {
|
|
401
401
|
isValid: !1,
|
|
402
402
|
message: n("validation.emailInvalid"),
|
|
403
403
|
suggestion: null
|
|
404
404
|
};
|
|
405
|
-
const o =
|
|
405
|
+
const o = U(r);
|
|
406
406
|
if (o && o !== r) {
|
|
407
407
|
const l = `${s}@${o}`;
|
|
408
408
|
return {
|
|
@@ -418,30 +418,30 @@ const T = {
|
|
|
418
418
|
};
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
|
-
},
|
|
422
|
-
const { t: n } =
|
|
421
|
+
}, _ = () => {
|
|
422
|
+
const { t: n } = M(), { validateEmail: e } = q();
|
|
423
423
|
return {
|
|
424
424
|
email: (t) => {
|
|
425
|
-
const
|
|
426
|
-
return
|
|
425
|
+
const a = e(t);
|
|
426
|
+
return a.isValid ? void 0 : a.message;
|
|
427
427
|
},
|
|
428
428
|
name: (t) => {
|
|
429
429
|
if (!t.trim())
|
|
430
430
|
return n("validation.nameRequired");
|
|
431
431
|
},
|
|
432
432
|
cardExpiry: (t) => {
|
|
433
|
-
const
|
|
434
|
-
if (!
|
|
433
|
+
const a = t.replace(/\s/g, ""), [i, s] = a.split("/").map((m) => m.trim());
|
|
434
|
+
if (!i || !s || i.length !== 2 || s.length !== 2)
|
|
435
435
|
return n("validation.cardExpiryFormat");
|
|
436
|
-
const r = /* @__PURE__ */ new Date(), o = r.getFullYear() % 100, l = r.getMonth() + 1, c = parseInt(
|
|
436
|
+
const r = /* @__PURE__ */ new Date(), o = r.getFullYear() % 100, l = r.getMonth() + 1, c = parseInt(i, 10), h = parseInt(s, 10);
|
|
437
437
|
if (c < 1 || c > 12)
|
|
438
438
|
return n("validation.cardExpiryFormat");
|
|
439
439
|
if (h < o || h === o && c < l)
|
|
440
440
|
return n("validation.cardExpiryInvalid");
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
|
-
},
|
|
444
|
-
const n =
|
|
443
|
+
}, G = () => {
|
|
444
|
+
const n = _(), e = x({
|
|
445
445
|
formData: {
|
|
446
446
|
name: "",
|
|
447
447
|
email: "",
|
|
@@ -457,14 +457,14 @@ const T = {
|
|
|
457
457
|
}), t = (l, c) => {
|
|
458
458
|
const h = n[l];
|
|
459
459
|
return h?.(c);
|
|
460
|
-
},
|
|
460
|
+
}, a = (l) => {
|
|
461
461
|
const c = {};
|
|
462
462
|
return Object.keys(l).forEach((h) => {
|
|
463
463
|
const m = t(h, l[h]);
|
|
464
464
|
m && (c[h] = m);
|
|
465
465
|
}), c;
|
|
466
|
-
},
|
|
467
|
-
const c =
|
|
466
|
+
}, i = (l) => {
|
|
467
|
+
const c = a(l);
|
|
468
468
|
return Object.keys(c).length === 0;
|
|
469
469
|
}, s = (l, c) => {
|
|
470
470
|
const h = e.getState();
|
|
@@ -481,7 +481,7 @@ const T = {
|
|
|
481
481
|
e.setState({
|
|
482
482
|
formData: u,
|
|
483
483
|
errors: p,
|
|
484
|
-
isValid:
|
|
484
|
+
isValid: i(u)
|
|
485
485
|
});
|
|
486
486
|
}, r = (l, c) => {
|
|
487
487
|
const h = e.getState(), m = {
|
|
@@ -499,7 +499,7 @@ const T = {
|
|
|
499
499
|
};
|
|
500
500
|
e.setState({
|
|
501
501
|
formData: h,
|
|
502
|
-
isValid:
|
|
502
|
+
isValid: i(h)
|
|
503
503
|
});
|
|
504
504
|
};
|
|
505
505
|
return {
|
|
@@ -510,13 +510,13 @@ const T = {
|
|
|
510
510
|
setFormData: o,
|
|
511
511
|
reset: e.resetState.bind(e)
|
|
512
512
|
};
|
|
513
|
-
},
|
|
513
|
+
}, Z = async ({
|
|
514
514
|
props: n,
|
|
515
515
|
apiKey: e,
|
|
516
516
|
environment: t
|
|
517
517
|
}) => {
|
|
518
|
-
const
|
|
519
|
-
`${
|
|
518
|
+
const a = L(t), i = await fetch(
|
|
519
|
+
`${a}/tokenization/generate-iframe-configuration`,
|
|
520
520
|
{
|
|
521
521
|
method: "POST",
|
|
522
522
|
headers: {
|
|
@@ -526,17 +526,17 @@ const T = {
|
|
|
526
526
|
body: JSON.stringify(n)
|
|
527
527
|
}
|
|
528
528
|
);
|
|
529
|
-
if (!
|
|
530
|
-
throw new Error(`HTTP error! Status: ${
|
|
531
|
-
return await
|
|
529
|
+
if (!i.ok)
|
|
530
|
+
throw new Error(`HTTP error! Status: ${i.status}`);
|
|
531
|
+
return await i.json();
|
|
532
532
|
};
|
|
533
|
-
function
|
|
533
|
+
function Y({
|
|
534
534
|
apiKey: n,
|
|
535
535
|
// scriptLoaded,
|
|
536
536
|
checkoutProfile: e,
|
|
537
537
|
inputStyles: t,
|
|
538
|
-
setFormData:
|
|
539
|
-
environment:
|
|
538
|
+
setFormData: a,
|
|
539
|
+
environment: i
|
|
540
540
|
}) {
|
|
541
541
|
const s = x({
|
|
542
542
|
iframeConfig: void 0,
|
|
@@ -550,12 +550,12 @@ function Z({
|
|
|
550
550
|
let r = null;
|
|
551
551
|
const o = async () => {
|
|
552
552
|
try {
|
|
553
|
-
const m = await
|
|
553
|
+
const m = await Z({
|
|
554
554
|
props: {
|
|
555
555
|
allowedOrigins: [globalThis.location.origin]
|
|
556
556
|
},
|
|
557
557
|
apiKey: n,
|
|
558
|
-
environment:
|
|
558
|
+
environment: i
|
|
559
559
|
});
|
|
560
560
|
m && (s.setState({
|
|
561
561
|
iframeConfig: {
|
|
@@ -601,7 +601,7 @@ function Z({
|
|
|
601
601
|
s.setState({ loadingIframe: !1 });
|
|
602
602
|
}), r.on("autoCompleteValues", function(u) {
|
|
603
603
|
const { nameOnCard: p, cardExp: f } = u;
|
|
604
|
-
|
|
604
|
+
a({
|
|
605
605
|
name: p,
|
|
606
606
|
cardExpiry: f
|
|
607
607
|
});
|
|
@@ -642,70 +642,70 @@ function Z({
|
|
|
642
642
|
cleanup: c
|
|
643
643
|
};
|
|
644
644
|
}
|
|
645
|
-
const
|
|
646
|
-
email:
|
|
647
|
-
cardholderNameLabel:
|
|
648
|
-
cardInformation:
|
|
649
|
-
cardholderNamePlaceholder:
|
|
650
|
-
cardExpiry:
|
|
651
|
-
loading:
|
|
652
|
-
buttonTexts:
|
|
645
|
+
const J = "E-Mail", W = "Name des/der Karteninhaber/in", X = "Kartendaten", Q = "Vollständiger Name", ee = "MM / JJ", te = "Das Fenster nicht schließen", ae = { pay: "ZAHLEN", submit: "ABSENDEN", getPlan: "MEINEN PLAN ERHALTEN", donate: "spenden", book: "jetzt buchen", order: "jetzt bestellen" }, ie = { 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" }, se = {
|
|
646
|
+
email: J,
|
|
647
|
+
cardholderNameLabel: W,
|
|
648
|
+
cardInformation: X,
|
|
649
|
+
cardholderNamePlaceholder: Q,
|
|
650
|
+
cardExpiry: ee,
|
|
651
|
+
loading: te,
|
|
652
|
+
buttonTexts: ae,
|
|
653
653
|
validation: ie
|
|
654
|
-
},
|
|
655
|
-
email:
|
|
656
|
-
cardholderNameLabel:
|
|
657
|
-
cardInformation:
|
|
658
|
-
cardholderNamePlaceholder:
|
|
659
|
-
cardExpiry:
|
|
660
|
-
loading:
|
|
661
|
-
buttonTexts:
|
|
662
|
-
validation:
|
|
663
|
-
},
|
|
664
|
-
email:
|
|
665
|
-
cardholderNameLabel:
|
|
666
|
-
cardInformation:
|
|
667
|
-
cardholderNamePlaceholder:
|
|
668
|
-
cardExpiry:
|
|
669
|
-
loading:
|
|
670
|
-
buttonTexts:
|
|
671
|
-
validation:
|
|
672
|
-
},
|
|
673
|
-
email:
|
|
674
|
-
cardholderNameLabel:
|
|
675
|
-
cardInformation:
|
|
676
|
-
cardholderNamePlaceholder:
|
|
654
|
+
}, re = "Email", ne = "Cardholder name", oe = "Card information", le = "Full name on card", ce = "MM / YY", de = "Do not close the window", he = { pay: "PAY", submit: "SUBMIT", getPlan: "GET MY PLAN", donate: "DONATE", book: "BOOK NOW", order: "ORDER NOW" }, me = { 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" }, ue = {
|
|
655
|
+
email: re,
|
|
656
|
+
cardholderNameLabel: ne,
|
|
657
|
+
cardInformation: oe,
|
|
658
|
+
cardholderNamePlaceholder: le,
|
|
659
|
+
cardExpiry: ce,
|
|
660
|
+
loading: de,
|
|
661
|
+
buttonTexts: he,
|
|
662
|
+
validation: me
|
|
663
|
+
}, pe = "Correo electrónico", fe = "Nombre del titular de la tarjeta", ge = "Información de la tarjeta", ye = "Nombre completo en la tarjeta", ve = "MM / AA", Ee = "Por favor, no cierre esta ventana", be = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTENER MI PLAN", donate: "DONAR", book: "RESERVAR AHORA", order: "ORDENAR AHORA" }, Ce = { 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" }, Se = {
|
|
664
|
+
email: pe,
|
|
665
|
+
cardholderNameLabel: fe,
|
|
666
|
+
cardInformation: ge,
|
|
667
|
+
cardholderNamePlaceholder: ye,
|
|
668
|
+
cardExpiry: ve,
|
|
669
|
+
loading: Ee,
|
|
670
|
+
buttonTexts: be,
|
|
671
|
+
validation: Ce
|
|
672
|
+
}, xe = "E-mail", Fe = "Nom du titulaire de la carte", we = "Informations de la carte", Le = "Nom complet figurant sur la carte", Me = "MM / AA", ke = "Veuillez ne pas fermer cette fenêtre", Te = { pay: "PAYER", submit: "ENVOYER", getPlan: "OBTENIR MON PLAN", donate: "FAIRE UN DON", book: "RÉSERVER MAINTENANT", order: "COMMANDER MAINTENANT" }, Ie = { emailSuggestion: "Vouliez-vous dire {{email}}?", emailInvalid: "Votre adresse e-mail n’est pas valide", cardExpiryInvalid: "La date d'expiration de votre carte est dans le passé", cardExpiryFormat: "La date d’expiration de votre carte est incomplète", cardSecurityFormat: "Le code de sécurité de votre carte est incomplet", nameRequired: "Veuillez saisir le nom tel qu’il figure sur votre carte", cardNumberInvalid: "Votre numéro de carte est invalide" }, ze = {
|
|
673
|
+
email: xe,
|
|
674
|
+
cardholderNameLabel: Fe,
|
|
675
|
+
cardInformation: we,
|
|
676
|
+
cardholderNamePlaceholder: Le,
|
|
677
677
|
cardExpiry: Me,
|
|
678
|
-
loading:
|
|
679
|
-
buttonTexts:
|
|
680
|
-
validation:
|
|
681
|
-
},
|
|
682
|
-
email:
|
|
683
|
-
cardholderNameLabel:
|
|
684
|
-
cardInformation:
|
|
685
|
-
cardholderNamePlaceholder:
|
|
678
|
+
loading: ke,
|
|
679
|
+
buttonTexts: Te,
|
|
680
|
+
validation: Ie
|
|
681
|
+
}, Ne = "Adres e-mail", Pe = "Imię i nazwisko posiadacza karty", De = "Informacje o karcie", Ae = "Imię i nazwisko na karcie", Ve = "MM / RR", $e = "Proszę nie zamykać tego okna", Re = { pay: "ZAPŁAĆ", submit: "WYŚLIJ", getPlan: "POBIERZ MÓJ PLAN", donate: "PRZEKAŻ DAROWIZNĘ", book: "ZAREZERWUJ TERAZ", order: "ZAMÓW TERAZ" }, Be = { emailSuggestion: "Czy chodziło Ci o {{email}}?", emailInvalid: "Państwa adres e-mail jest nieprawidłowy", cardExpiryInvalid: "Data ważności Państwa karty jest w przeszłości", cardExpiryFormat: "Data ważności Państwa karty jest niekompletna", cardSecurityFormat: "Kod zabezpieczający Państwa karty jest niekompletny", nameRequired: "Proszę wpisać imię i nazwisko tak, jak widnieje na karcie", cardNumberInvalid: "Numer Państwa karty jest nieprawidłowy" }, Oe = {
|
|
682
|
+
email: Ne,
|
|
683
|
+
cardholderNameLabel: Pe,
|
|
684
|
+
cardInformation: De,
|
|
685
|
+
cardholderNamePlaceholder: Ae,
|
|
686
686
|
cardExpiry: Ve,
|
|
687
|
-
loading:
|
|
688
|
-
buttonTexts:
|
|
689
|
-
validation:
|
|
690
|
-
},
|
|
691
|
-
email:
|
|
692
|
-
cardholderNameLabel:
|
|
693
|
-
cardInformation:
|
|
694
|
-
cardholderNamePlaceholder:
|
|
695
|
-
cardExpiry:
|
|
696
|
-
loading:
|
|
697
|
-
buttonTexts:
|
|
698
|
-
validation:
|
|
687
|
+
loading: $e,
|
|
688
|
+
buttonTexts: Re,
|
|
689
|
+
validation: Be
|
|
690
|
+
}, He = "E-mail", je = "Nome do titular do cartão", Ke = "Informações do cartão", Ue = "Nome completo no cartão", qe = "MM / AA", _e = "Por favor, não feche esta janela", Ge = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTER MEU PLANO", donate: "DOAR", book: "RESERVAR AGORA", order: "FAZER PEDIDO" }, Ze = { 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" }, Ye = {
|
|
691
|
+
email: He,
|
|
692
|
+
cardholderNameLabel: je,
|
|
693
|
+
cardInformation: Ke,
|
|
694
|
+
cardholderNamePlaceholder: Ue,
|
|
695
|
+
cardExpiry: qe,
|
|
696
|
+
loading: _e,
|
|
697
|
+
buttonTexts: Ge,
|
|
698
|
+
validation: Ze
|
|
699
699
|
}, I = {
|
|
700
|
-
en:
|
|
701
|
-
de:
|
|
702
|
-
es:
|
|
703
|
-
fr:
|
|
704
|
-
pl:
|
|
705
|
-
pt:
|
|
700
|
+
en: ue,
|
|
701
|
+
de: se,
|
|
702
|
+
es: Se,
|
|
703
|
+
fr: ze,
|
|
704
|
+
pl: Oe,
|
|
705
|
+
pt: Ye
|
|
706
706
|
// Add other locales here
|
|
707
707
|
};
|
|
708
|
-
class
|
|
708
|
+
class Je {
|
|
709
709
|
locale;
|
|
710
710
|
loadedLocales = /* @__PURE__ */ new Set();
|
|
711
711
|
constructor(e = "en") {
|
|
@@ -718,85 +718,85 @@ class Ye {
|
|
|
718
718
|
return this.locale;
|
|
719
719
|
}
|
|
720
720
|
translate(e, t) {
|
|
721
|
-
const
|
|
722
|
-
return !t ||
|
|
721
|
+
const a = this.getNestedTranslation(e);
|
|
722
|
+
return !t || a === e ? a : this.interpolate(a, t);
|
|
723
723
|
}
|
|
724
724
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
725
725
|
getNestedTranslation(e) {
|
|
726
|
-
const t = this.locale in I ? I[this.locale] : {},
|
|
727
|
-
return
|
|
726
|
+
const t = this.locale in I ? I[this.locale] : {}, a = this.findNestedValue(t, e);
|
|
727
|
+
return a === void 0 ? e : a;
|
|
728
728
|
}
|
|
729
729
|
findNestedValue(e, t) {
|
|
730
|
-
const
|
|
731
|
-
let
|
|
732
|
-
for (const s of
|
|
733
|
-
if (
|
|
730
|
+
const a = t.split(".");
|
|
731
|
+
let i = e;
|
|
732
|
+
for (const s of a) {
|
|
733
|
+
if (i == null || !Object.prototype.hasOwnProperty.call(i, s))
|
|
734
734
|
return;
|
|
735
|
-
|
|
735
|
+
i = i[s];
|
|
736
736
|
}
|
|
737
|
-
return typeof
|
|
737
|
+
return typeof i == "string" ? i : void 0;
|
|
738
738
|
}
|
|
739
739
|
interpolate(e, t) {
|
|
740
|
-
return e.replace(/{{(\w+)}}/g, (
|
|
741
|
-
const s = t[
|
|
742
|
-
return s === void 0 ?
|
|
740
|
+
return e.replace(/{{(\w+)}}/g, (a, i) => {
|
|
741
|
+
const s = t[i];
|
|
742
|
+
return s === void 0 ? a : String(s);
|
|
743
743
|
});
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
|
-
const z = ["en", "de", "es", "fr", "pl", "pt"],
|
|
747
|
-
function
|
|
748
|
-
const e = new
|
|
746
|
+
const z = ["en", "de", "es", "fr", "pl", "pt"], We = "en";
|
|
747
|
+
function Xe(n) {
|
|
748
|
+
const e = new Je(), a = (() => {
|
|
749
749
|
const o = navigator?.language?.split("-")[0]?.toLowerCase();
|
|
750
|
-
return z.includes(o) ? o :
|
|
750
|
+
return z.includes(o) ? o : We;
|
|
751
751
|
})();
|
|
752
|
-
e.setLocale(
|
|
753
|
-
const
|
|
754
|
-
locale:
|
|
752
|
+
e.setLocale(a);
|
|
753
|
+
const i = x({
|
|
754
|
+
locale: a,
|
|
755
755
|
translationService: e
|
|
756
756
|
});
|
|
757
757
|
return {
|
|
758
|
-
store:
|
|
759
|
-
translate: (o, l) =>
|
|
758
|
+
store: i,
|
|
759
|
+
translate: (o, l) => i.getState().translationService.translate(o, l),
|
|
760
760
|
setLocale: (o) => {
|
|
761
|
-
z.includes(o) && (
|
|
761
|
+
z.includes(o) && (i.getState().translationService.setLocale(o), i.setState({ locale: o }));
|
|
762
762
|
},
|
|
763
|
-
getLocale: () =>
|
|
764
|
-
subscribe:
|
|
763
|
+
getLocale: () => i.getValue("locale"),
|
|
764
|
+
subscribe: i.subscribe.bind(i)
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
-
const
|
|
768
|
-
const { translate: n, getLocale: e, setLocale: t, subscribe:
|
|
767
|
+
const Qe = Xe(), M = () => {
|
|
768
|
+
const { translate: n, getLocale: e, setLocale: t, subscribe: a } = Qe;
|
|
769
769
|
return {
|
|
770
770
|
t: n,
|
|
771
771
|
translate: n,
|
|
772
772
|
locale: e(),
|
|
773
773
|
setLocale: t,
|
|
774
|
-
subscribe:
|
|
774
|
+
subscribe: a
|
|
775
775
|
};
|
|
776
|
-
},
|
|
776
|
+
}, et = ({ fontFamily: n }) => {
|
|
777
777
|
if (!n)
|
|
778
778
|
return { cleanup: () => {
|
|
779
779
|
} };
|
|
780
|
-
const e = n.replace(/\s+/g, "+"), t = `https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,
|
|
780
|
+
const e = n.replace(/\s+/g, "+"), t = `https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`, a = [...document.head.querySelectorAll("link")].filter(
|
|
781
781
|
(o) => o.href.includes("fonts.googleapis.com/css2") && o.rel === "stylesheet"
|
|
782
|
-
),
|
|
783
|
-
|
|
784
|
-
const s =
|
|
782
|
+
), i = document.createElement("link");
|
|
783
|
+
i.rel = "stylesheet", i.href = t;
|
|
784
|
+
const s = a.find(
|
|
785
785
|
(o) => o.href.includes(`family=${e}`)
|
|
786
786
|
);
|
|
787
787
|
if (s)
|
|
788
788
|
s.href = t;
|
|
789
|
-
else if (
|
|
790
|
-
const o =
|
|
789
|
+
else if (a.length > 0) {
|
|
790
|
+
const o = a.at(
|
|
791
791
|
-1
|
|
792
792
|
);
|
|
793
|
-
o?.nextSibling ? document.head.insertBefore(
|
|
793
|
+
o?.nextSibling ? document.head.insertBefore(i, o.nextSibling) : document.head.appendChild(i);
|
|
794
794
|
} else
|
|
795
|
-
document.head.appendChild(
|
|
795
|
+
document.head.appendChild(i);
|
|
796
796
|
return { cleanup: () => {
|
|
797
|
-
document.head.contains(
|
|
797
|
+
document.head.contains(i) && document.head.removeChild(i);
|
|
798
798
|
} };
|
|
799
|
-
},
|
|
799
|
+
}, tt = ({
|
|
800
800
|
scriptSrc: n,
|
|
801
801
|
async: e = !1
|
|
802
802
|
}) => {
|
|
@@ -814,24 +814,24 @@ const Xe = We(), L = () => {
|
|
|
814
814
|
},
|
|
815
815
|
isLoaded: Promise.resolve(!0)
|
|
816
816
|
};
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
817
|
+
const a = document.createElement("script");
|
|
818
|
+
a.src = n, a.async = e;
|
|
819
|
+
const i = new Promise((r, o) => {
|
|
820
|
+
a.onload = () => r(!0), a.onerror = () => {
|
|
821
821
|
console.error(`Failed to load script: ${n}`), o(new Error(`Failed to load script: ${n}`));
|
|
822
822
|
};
|
|
823
823
|
});
|
|
824
|
-
return document.head.appendChild(
|
|
824
|
+
return document.head.appendChild(a), {
|
|
825
825
|
cleanup: () => {
|
|
826
|
-
document.head.contains(
|
|
826
|
+
document.head.contains(a) && document.head.removeChild(a);
|
|
827
827
|
},
|
|
828
|
-
isLoaded:
|
|
828
|
+
isLoaded: i
|
|
829
829
|
};
|
|
830
830
|
}, S = (n) => Object.entries(n).map(([e, t]) => {
|
|
831
|
-
const
|
|
832
|
-
return `${
|
|
831
|
+
const a = e.replace(/([A-Z])/g, "-$1").toLowerCase(), i = typeof t == "number" ? `${t}px` : t;
|
|
832
|
+
return `${a}: ${i}`;
|
|
833
833
|
}).join("; ");
|
|
834
|
-
function
|
|
834
|
+
function at(n) {
|
|
835
835
|
if (!n)
|
|
836
836
|
return {
|
|
837
837
|
formContainerStyle: {},
|
|
@@ -855,31 +855,31 @@ function tt(n) {
|
|
|
855
855
|
lineHeight: 30,
|
|
856
856
|
boxSizing: "border-box",
|
|
857
857
|
padding: "0px 12px",
|
|
858
|
-
height:
|
|
858
|
+
height: 36,
|
|
859
859
|
width: "100%",
|
|
860
860
|
fontFamily: `${n.styles.fontFamily}, sans-serif`
|
|
861
861
|
}, t = {
|
|
862
862
|
color: "#717173",
|
|
863
863
|
opacity: "0.3",
|
|
864
864
|
fontFamily: `${n.styles.fontFamily}, sans-serif`
|
|
865
|
-
}, i = {
|
|
866
|
-
color: "#dc2727"
|
|
867
865
|
}, a = {
|
|
866
|
+
color: "#dc2727"
|
|
867
|
+
}, i = {
|
|
868
868
|
outline: 0
|
|
869
869
|
}, s = {
|
|
870
870
|
fontFamily: `${n.styles.fontFamily}, sans-serif`
|
|
871
871
|
}, r = {
|
|
872
872
|
base: S(e),
|
|
873
|
-
error: S(
|
|
874
|
-
focus: S(
|
|
873
|
+
error: S(a),
|
|
874
|
+
focus: S(i),
|
|
875
875
|
placeholder: S(t)
|
|
876
876
|
};
|
|
877
877
|
return {
|
|
878
878
|
formContainerStyle: s,
|
|
879
879
|
baseStyles: e,
|
|
880
880
|
placeholderStyles: t,
|
|
881
|
-
errorStyles:
|
|
882
|
-
focusStyles:
|
|
881
|
+
errorStyles: a,
|
|
882
|
+
focusStyles: i,
|
|
883
883
|
inputStyles: r
|
|
884
884
|
};
|
|
885
885
|
}
|
|
@@ -893,9 +893,9 @@ class d {
|
|
|
893
893
|
* @param classNames Optional CSS class names to add
|
|
894
894
|
* @param attributes Optional attributes to set on the element
|
|
895
895
|
*/
|
|
896
|
-
constructor(e, t = [],
|
|
897
|
-
this.element = document.createElement(e), t.length > 0 && this.addClass(...t), Object.entries(
|
|
898
|
-
this.setAttribute(
|
|
896
|
+
constructor(e, t = [], a = {}) {
|
|
897
|
+
this.element = document.createElement(e), t.length > 0 && this.addClass(...t), Object.entries(a).forEach(([i, s]) => {
|
|
898
|
+
this.setAttribute(i, s);
|
|
899
899
|
});
|
|
900
900
|
}
|
|
901
901
|
/**
|
|
@@ -950,14 +950,14 @@ class d {
|
|
|
950
950
|
/**
|
|
951
951
|
* Add an event listener to the element
|
|
952
952
|
*/
|
|
953
|
-
addEventListener(e, t,
|
|
954
|
-
return this.element.addEventListener(e, t,
|
|
953
|
+
addEventListener(e, t, a) {
|
|
954
|
+
return this.element.addEventListener(e, t, a), this.eventListeners.push({ type: e, listener: t }), this;
|
|
955
955
|
}
|
|
956
956
|
/**
|
|
957
957
|
* Remove an event listener from the element
|
|
958
958
|
*/
|
|
959
|
-
removeEventListener(e, t,
|
|
960
|
-
return this.element.removeEventListener(e, t,
|
|
959
|
+
removeEventListener(e, t, a) {
|
|
960
|
+
return this.element.removeEventListener(e, t, a), this;
|
|
961
961
|
}
|
|
962
962
|
/**
|
|
963
963
|
* Hide this component
|
|
@@ -996,27 +996,27 @@ class y {
|
|
|
996
996
|
/**
|
|
997
997
|
* Create a button element
|
|
998
998
|
*/
|
|
999
|
-
static createButton(e, t = [],
|
|
1000
|
-
const
|
|
1001
|
-
return
|
|
999
|
+
static createButton(e, t = [], a = {}) {
|
|
1000
|
+
const i = new d("button", t, a);
|
|
1001
|
+
return i.setText(e), i;
|
|
1002
1002
|
}
|
|
1003
1003
|
/**
|
|
1004
1004
|
* Create an input element
|
|
1005
1005
|
*/
|
|
1006
|
-
static createInput(e, t = [],
|
|
1007
|
-
const
|
|
1008
|
-
return new d("input", t,
|
|
1006
|
+
static createInput(e, t = [], a = {}) {
|
|
1007
|
+
const i = { type: e, ...a };
|
|
1008
|
+
return new d("input", t, i);
|
|
1009
1009
|
}
|
|
1010
1010
|
/**
|
|
1011
1011
|
* Create a text input
|
|
1012
1012
|
*/
|
|
1013
|
-
static createTextInput(e = "", t = [],
|
|
1014
|
-
const
|
|
1013
|
+
static createTextInput(e = "", t = [], a = {}) {
|
|
1014
|
+
const i = {
|
|
1015
1015
|
type: "text",
|
|
1016
1016
|
placeholder: e,
|
|
1017
|
-
...
|
|
1017
|
+
...a
|
|
1018
1018
|
};
|
|
1019
|
-
return new d("input", t,
|
|
1019
|
+
return new d("input", t, i);
|
|
1020
1020
|
}
|
|
1021
1021
|
/**
|
|
1022
1022
|
* Create a form element
|
|
@@ -1027,26 +1027,26 @@ class y {
|
|
|
1027
1027
|
/**
|
|
1028
1028
|
* Create a label element
|
|
1029
1029
|
*/
|
|
1030
|
-
static createLabel(e, t = "",
|
|
1031
|
-
const s = t ? { for: t, ...
|
|
1030
|
+
static createLabel(e, t = "", a = [], i = {}) {
|
|
1031
|
+
const s = t ? { for: t, ...i } : i, r = new d("label", a, s);
|
|
1032
1032
|
return r.setText(e), r;
|
|
1033
1033
|
}
|
|
1034
1034
|
/**
|
|
1035
1035
|
* Create a select element
|
|
1036
1036
|
*/
|
|
1037
|
-
static createSelect(e, t = [],
|
|
1038
|
-
const
|
|
1037
|
+
static createSelect(e, t = [], a = {}) {
|
|
1038
|
+
const i = new d("select", t, a);
|
|
1039
1039
|
return e.forEach((s) => {
|
|
1040
1040
|
const r = document.createElement("option");
|
|
1041
|
-
r.value = s.value, r.textContent = s.text, s.selected && (r.selected = !0),
|
|
1042
|
-
}),
|
|
1041
|
+
r.value = s.value, r.textContent = s.text, s.selected && (r.selected = !0), i.getElement().appendChild(r);
|
|
1042
|
+
}), i;
|
|
1043
1043
|
}
|
|
1044
1044
|
/**
|
|
1045
1045
|
* Create an image element
|
|
1046
1046
|
*/
|
|
1047
|
-
static createImage(e, t = "",
|
|
1048
|
-
const s = { src: e, alt: t, ...
|
|
1049
|
-
return new d("img",
|
|
1047
|
+
static createImage(e, t = "", a = [], i = {}) {
|
|
1048
|
+
const s = { src: e, alt: t, ...i };
|
|
1049
|
+
return new d("img", a, s);
|
|
1050
1050
|
}
|
|
1051
1051
|
}
|
|
1052
1052
|
class it extends d {
|
|
@@ -1056,10 +1056,10 @@ class it extends d {
|
|
|
1056
1056
|
const t = y.createDiv(["error-alert"], {
|
|
1057
1057
|
role: "alert",
|
|
1058
1058
|
"aria-live": "polite"
|
|
1059
|
-
}),
|
|
1059
|
+
}), a = y.createDiv(["error-alert-content"]), i = y.createDiv([
|
|
1060
1060
|
"error-alert-icon-container"
|
|
1061
1061
|
]);
|
|
1062
|
-
|
|
1062
|
+
i.getElement().innerHTML = this.createAlertCircleSVG();
|
|
1063
1063
|
const s = y.createDiv([
|
|
1064
1064
|
"error-alert-text-container"
|
|
1065
1065
|
]), r = new d("h4", [
|
|
@@ -1067,7 +1067,7 @@ class it extends d {
|
|
|
1067
1067
|
]);
|
|
1068
1068
|
r.setText("Checkout Error"), this.messageComponent = new d("p", [
|
|
1069
1069
|
"error-alert-message"
|
|
1070
|
-
]), this.messageComponent.setText(e.message || "Bad request"), s.appendChild(r), s.appendChild(this.messageComponent),
|
|
1070
|
+
]), this.messageComponent.setText(e.message || "Bad request"), s.appendChild(r), s.appendChild(this.messageComponent), a.appendChild(i), a.appendChild(s), t.appendChild(a), this.appendChild(t);
|
|
1071
1071
|
}
|
|
1072
1072
|
createAlertCircleSVG() {
|
|
1073
1073
|
return `
|
|
@@ -1092,12 +1092,12 @@ class it extends d {
|
|
|
1092
1092
|
return this.messageComponent.setText(e), this;
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
|
-
class
|
|
1095
|
+
class N extends d {
|
|
1096
1096
|
titleElement;
|
|
1097
|
-
constructor(e) {
|
|
1097
|
+
constructor(e = {}) {
|
|
1098
1098
|
super("div", ["blur-bg"]);
|
|
1099
1099
|
const t = y.createDiv(["loader"]);
|
|
1100
|
-
this.titleElement = new d("h3", ["title"]), this.titleElement.setText(e.text), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1100
|
+
this.titleElement = new d("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1101
1101
|
}
|
|
1102
1102
|
setText(e) {
|
|
1103
1103
|
return this.titleElement.setText(e), this;
|
|
@@ -1128,7 +1128,7 @@ class k extends d {
|
|
|
1128
1128
|
helperText = null;
|
|
1129
1129
|
constructor(e) {
|
|
1130
1130
|
if (super("div", ["input-wrapper"]), e.label && e.styles) {
|
|
1131
|
-
const
|
|
1131
|
+
const a = new st({
|
|
1132
1132
|
styles: {
|
|
1133
1133
|
color: e.styles.color,
|
|
1134
1134
|
fontSize: e.styles.fontSize
|
|
@@ -1136,7 +1136,7 @@ class k extends d {
|
|
|
1136
1136
|
label: e.label,
|
|
1137
1137
|
id: e.name
|
|
1138
1138
|
});
|
|
1139
|
-
this.appendChild(
|
|
1139
|
+
this.appendChild(a);
|
|
1140
1140
|
}
|
|
1141
1141
|
const t = {
|
|
1142
1142
|
id: e.name,
|
|
@@ -1148,8 +1148,8 @@ class k extends d {
|
|
|
1148
1148
|
[],
|
|
1149
1149
|
t
|
|
1150
1150
|
), e.styles) {
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1151
|
+
const a = this.inputElement.getElement();
|
|
1152
|
+
a.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.style.color = e.styles.color, a.style.fontSize = `${e.styles.fontSize}px`, a.style.borderRadius = e.styles.borderRadius;
|
|
1153
1153
|
}
|
|
1154
1154
|
e.onChange && this.inputElement.getElement().addEventListener("input", e.onChange), this.getElement().appendChild(this.inputElement.getElement()), e.error && (this.helperText = new v({ text: e.errorMsg }), this.appendChild(this.helperText));
|
|
1155
1155
|
}
|
|
@@ -1160,11 +1160,11 @@ class k extends d {
|
|
|
1160
1160
|
return this.inputElement.getElement().value = e, this;
|
|
1161
1161
|
}
|
|
1162
1162
|
setError(e, t) {
|
|
1163
|
-
const
|
|
1164
|
-
return e ? (
|
|
1163
|
+
const a = this.inputElement.getElement();
|
|
1164
|
+
return e ? (a.classList.add("form-input-error"), !this.helperText && t ? (this.helperText = new v({ text: t }), this.appendChild(this.helperText)) : this.helperText && t && this.helperText.setText(t)) : (a.classList.remove("form-input-error"), this.helperText && (this.helperText.getElement().remove(), this.helperText = null)), this;
|
|
1165
1165
|
}
|
|
1166
|
-
addEventListener(e, t,
|
|
1167
|
-
return this.inputElement.getElement().addEventListener(e, t,
|
|
1166
|
+
addEventListener(e, t, a) {
|
|
1167
|
+
return this.inputElement.getElement().addEventListener(e, t, a), this;
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
1170
1170
|
class rt {
|
|
@@ -1172,8 +1172,8 @@ class rt {
|
|
|
1172
1172
|
constructor(e) {
|
|
1173
1173
|
const {
|
|
1174
1174
|
value: t,
|
|
1175
|
-
onChange:
|
|
1176
|
-
onBlur:
|
|
1175
|
+
onChange: a,
|
|
1176
|
+
onBlur: i,
|
|
1177
1177
|
error: s,
|
|
1178
1178
|
errorMsg: r,
|
|
1179
1179
|
checkoutProfile: o,
|
|
@@ -1193,10 +1193,10 @@ class rt {
|
|
|
1193
1193
|
placeholder: l("cardholderNamePlaceholder"),
|
|
1194
1194
|
value: t,
|
|
1195
1195
|
onChange: (c) => {
|
|
1196
|
-
this.trim(),
|
|
1196
|
+
this.trim(), a(c);
|
|
1197
1197
|
}
|
|
1198
1198
|
}), this.input.addEventListener("blur", (c) => {
|
|
1199
|
-
|
|
1199
|
+
i(c);
|
|
1200
1200
|
});
|
|
1201
1201
|
}
|
|
1202
1202
|
getValue() {
|
|
@@ -1224,8 +1224,8 @@ class nt extends d {
|
|
|
1224
1224
|
super("div", []);
|
|
1225
1225
|
const t = document.createElement("div");
|
|
1226
1226
|
t.className = e.isLoading ? "loading" : "", t.style.borderRadius = `0px 0px ${e.styles.borderRadius}px 0px`;
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1227
|
+
const a = document.createElement("div");
|
|
1228
|
+
a.id = "card-cvv-element", a.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, a.style.zIndex = e.isFocused ? "2" : "0", t.appendChild(a), this.getElement().appendChild(t);
|
|
1229
1229
|
}
|
|
1230
1230
|
setFocused(e) {
|
|
1231
1231
|
const t = this.getElement().querySelector("#card-cvv-element");
|
|
@@ -1260,10 +1260,10 @@ class ht extends d {
|
|
|
1260
1260
|
super("div", []), this.cardType = e.cardType;
|
|
1261
1261
|
const t = document.createElement("label");
|
|
1262
1262
|
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);
|
|
1263
|
-
const i = document.createElement("div");
|
|
1264
|
-
i.className = e.isLoading ? "loading" : "", i.style.borderRadius = `${e.styles.borderRadius}px ${e.styles.borderRadius}px 0px 0px`;
|
|
1265
1263
|
const a = document.createElement("div");
|
|
1266
|
-
a.
|
|
1264
|
+
a.className = e.isLoading ? "loading" : "", a.style.borderRadius = `${e.styles.borderRadius}px ${e.styles.borderRadius}px 0px 0px`;
|
|
1265
|
+
const i = document.createElement("div");
|
|
1266
|
+
i.id = "card-element", i.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, i.style.zIndex = e.isFocused ? "2" : "0";
|
|
1267
1267
|
const s = document.createElement("div");
|
|
1268
1268
|
if (s.className = "cards-position", e.cardType === "unknown")
|
|
1269
1269
|
E.forEach((r) => {
|
|
@@ -1273,13 +1273,13 @@ class ht extends d {
|
|
|
1273
1273
|
const r = E.find((o) => o.type === e.cardType);
|
|
1274
1274
|
r && s.appendChild(this.createCardIcon(r));
|
|
1275
1275
|
}
|
|
1276
|
-
|
|
1276
|
+
i.appendChild(s), a.appendChild(i), this.getElement().appendChild(a);
|
|
1277
1277
|
}
|
|
1278
1278
|
createCardIcon(e) {
|
|
1279
1279
|
const t = document.createElement("div");
|
|
1280
1280
|
t.className = "card-icon";
|
|
1281
|
-
const
|
|
1282
|
-
return
|
|
1281
|
+
const a = document.createElement("img");
|
|
1282
|
+
return a.src = e.imgSrc, t.appendChild(a), t;
|
|
1283
1283
|
}
|
|
1284
1284
|
setFocused(e) {
|
|
1285
1285
|
const t = this.getElement().querySelector(
|
|
@@ -1298,16 +1298,16 @@ class ht extends d {
|
|
|
1298
1298
|
if (this.cardType === t)
|
|
1299
1299
|
return this;
|
|
1300
1300
|
this.cardType = t;
|
|
1301
|
-
const
|
|
1302
|
-
if (
|
|
1303
|
-
if (
|
|
1304
|
-
E.forEach((
|
|
1305
|
-
|
|
1301
|
+
const a = this.getElement().querySelector(".cards-position");
|
|
1302
|
+
if (a)
|
|
1303
|
+
if (a.innerHTML = "", this.cardType === "unknown")
|
|
1304
|
+
E.forEach((i) => {
|
|
1305
|
+
a.appendChild(this.createCardIcon(i));
|
|
1306
1306
|
});
|
|
1307
1307
|
else {
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1310
|
-
|
|
1308
|
+
const i = E.find((s) => s.type === this.cardType);
|
|
1309
|
+
i ? a.appendChild(this.createCardIcon(i)) : E.forEach((s) => {
|
|
1310
|
+
a.appendChild(this.createCardIcon(s));
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
1313
|
return this;
|
|
@@ -1322,8 +1322,8 @@ class mt extends d {
|
|
|
1322
1322
|
super("div", []);
|
|
1323
1323
|
const {
|
|
1324
1324
|
checkoutProfile: t,
|
|
1325
|
-
isLoading:
|
|
1326
|
-
isFocused:
|
|
1325
|
+
isLoading: a,
|
|
1326
|
+
isFocused: i,
|
|
1327
1327
|
isCvvFocused: s,
|
|
1328
1328
|
isCcValid: r,
|
|
1329
1329
|
isCvvValid: o,
|
|
@@ -1342,8 +1342,8 @@ class mt extends d {
|
|
|
1342
1342
|
borderRadius: t.styles.borderRadius
|
|
1343
1343
|
},
|
|
1344
1344
|
label: f("cardInformation"),
|
|
1345
|
-
isLoading:
|
|
1346
|
-
isFocused:
|
|
1345
|
+
isLoading: a,
|
|
1346
|
+
isFocused: i,
|
|
1347
1347
|
cardType: l
|
|
1348
1348
|
}), b.appendChild(this.cardNumber.getElement());
|
|
1349
1349
|
const C = document.createElement("div");
|
|
@@ -1372,16 +1372,16 @@ class mt extends d {
|
|
|
1372
1372
|
"Tab"
|
|
1373
1373
|
].includes(w.key) && !/^\d$/.test(w.key) && w.preventDefault();
|
|
1374
1374
|
});
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1375
|
+
const D = this.cardExpiry.getElement();
|
|
1376
|
+
D.style.height = "100%";
|
|
1377
1377
|
const F = document.createElement("div");
|
|
1378
1378
|
if (F.className = "input-wrapper", this.cardCvv = new nt({
|
|
1379
1379
|
styles: {
|
|
1380
1380
|
borderRadius: typeof t.styles.borderRadius == "number" ? t.styles.borderRadius : 0
|
|
1381
1381
|
},
|
|
1382
|
-
isLoading:
|
|
1382
|
+
isLoading: a,
|
|
1383
1383
|
isFocused: s
|
|
1384
|
-
}), F.appendChild(this.cardCvv.getElement()), C.appendChild(this.cardExpiry.getElement()), C.appendChild(F), b.appendChild(C), this.getElement().appendChild(b),
|
|
1384
|
+
}), F.appendChild(this.cardCvv.getElement()), C.appendChild(this.cardExpiry.getElement()), C.appendChild(F), b.appendChild(C), this.getElement().appendChild(b), i && !r) {
|
|
1385
1385
|
const g = new v({
|
|
1386
1386
|
text: f("validation.cardNumberInvalid")
|
|
1387
1387
|
});
|
|
@@ -1397,8 +1397,8 @@ class mt extends d {
|
|
|
1397
1397
|
updateCardType(e) {
|
|
1398
1398
|
return this.cardNumber.updateCardType(e), this;
|
|
1399
1399
|
}
|
|
1400
|
-
updateCardExpiry(e, t,
|
|
1401
|
-
return this.cardExpiry.setValue(e), t &&
|
|
1400
|
+
updateCardExpiry(e, t, a) {
|
|
1401
|
+
return this.cardExpiry.setValue(e), t && a ? this.cardExpiry.setError(!0, t) : this.cardExpiry.setError(!1), this;
|
|
1402
1402
|
}
|
|
1403
1403
|
getCardExpiryValue() {
|
|
1404
1404
|
return this.cardExpiry.getValue();
|
|
@@ -1407,31 +1407,31 @@ class mt extends d {
|
|
|
1407
1407
|
const e = this.getCardExpiryValue().trim();
|
|
1408
1408
|
return this.cardExpiry.setValue(e), this;
|
|
1409
1409
|
}
|
|
1410
|
-
updateCardNumberValidation(e, t,
|
|
1410
|
+
updateCardNumberValidation(e, t, a) {
|
|
1411
1411
|
if (this.cardNumber.setFocused(e), e && !t) {
|
|
1412
1412
|
if (!this.validationMessages.has("cardNumber")) {
|
|
1413
|
-
const
|
|
1414
|
-
text:
|
|
1413
|
+
const i = new v({
|
|
1414
|
+
text: a("validation.cardNumberInvalid")
|
|
1415
1415
|
});
|
|
1416
|
-
this.validationMessages.set("cardNumber",
|
|
1416
|
+
this.validationMessages.set("cardNumber", i), this.appendChild(i);
|
|
1417
1417
|
}
|
|
1418
1418
|
} else {
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1419
|
+
const i = this.validationMessages.get("cardNumber");
|
|
1420
|
+
i && (i.getElement().remove(), this.validationMessages.delete("cardNumber"));
|
|
1421
1421
|
}
|
|
1422
1422
|
return this;
|
|
1423
1423
|
}
|
|
1424
|
-
updateCardCvvValidation(e, t,
|
|
1424
|
+
updateCardCvvValidation(e, t, a) {
|
|
1425
1425
|
if (this.cardCvv.setFocused(e), e && !t) {
|
|
1426
1426
|
if (!this.validationMessages.has("cardCvv")) {
|
|
1427
|
-
const
|
|
1428
|
-
text:
|
|
1427
|
+
const i = new v({
|
|
1428
|
+
text: a("validation.cardSecurityFormat")
|
|
1429
1429
|
});
|
|
1430
|
-
this.validationMessages.set("cardCvv",
|
|
1430
|
+
this.validationMessages.set("cardCvv", i), this.appendChild(i);
|
|
1431
1431
|
}
|
|
1432
1432
|
} else {
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1433
|
+
const i = this.validationMessages.get("cardCvv");
|
|
1434
|
+
i && (i.getElement().remove(), this.validationMessages.delete("cardCvv"));
|
|
1435
1435
|
}
|
|
1436
1436
|
return this;
|
|
1437
1437
|
}
|
|
@@ -1444,8 +1444,8 @@ class ut {
|
|
|
1444
1444
|
constructor(e) {
|
|
1445
1445
|
const {
|
|
1446
1446
|
value: t,
|
|
1447
|
-
onChange:
|
|
1448
|
-
onBlur:
|
|
1447
|
+
onChange: a,
|
|
1448
|
+
onBlur: i,
|
|
1449
1449
|
error: s,
|
|
1450
1450
|
errorMsg: r,
|
|
1451
1451
|
checkoutProfile: o,
|
|
@@ -1467,9 +1467,9 @@ class ut {
|
|
|
1467
1467
|
value: t,
|
|
1468
1468
|
// Wrap the original onChange to apply trim before calling it
|
|
1469
1469
|
onChange: (c) => {
|
|
1470
|
-
this.trim(),
|
|
1470
|
+
this.trim(), a(c);
|
|
1471
1471
|
}
|
|
1472
|
-
}), this.input.addEventListener("blur",
|
|
1472
|
+
}), this.input.addEventListener("blur", i);
|
|
1473
1473
|
}
|
|
1474
1474
|
getValue() {
|
|
1475
1475
|
return this.input.getValue();
|
|
@@ -1498,12 +1498,12 @@ class ft extends d {
|
|
|
1498
1498
|
isSubmitting = !1;
|
|
1499
1499
|
constructor(e) {
|
|
1500
1500
|
super("div", ["paypal"]);
|
|
1501
|
-
const { formData: t, onSubmit:
|
|
1502
|
-
this.formData = t, this.onSubmit =
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1501
|
+
const { formData: t, onSubmit: a } = e;
|
|
1502
|
+
this.formData = t, this.onSubmit = a, this.getElement().style.cursor = a ? "pointer" : "default", this.getElement().style.opacity = "1";
|
|
1503
|
+
const i = document.createElement("div");
|
|
1504
|
+
i.className = "paypal-icon-container";
|
|
1505
1505
|
const s = document.createElement("img");
|
|
1506
|
-
s.src = pt, s.style.width = "69px", s.style.height = "22px", s.style.maxWidth = "100%", s.style.display = "block", s.style.height = "auto",
|
|
1506
|
+
s.src = pt, s.style.width = "69px", s.style.height = "22px", s.style.maxWidth = "100%", s.style.display = "block", s.style.height = "auto", i.appendChild(s), this.getElement().appendChild(i), a && this.getElement().addEventListener("click", () => this.handleSubmit());
|
|
1507
1507
|
}
|
|
1508
1508
|
async handleSubmit() {
|
|
1509
1509
|
if (!(!this.onSubmit || this.isSubmitting)) {
|
|
@@ -1527,7 +1527,7 @@ class ft extends d {
|
|
|
1527
1527
|
class gt extends d {
|
|
1528
1528
|
paymentMethods;
|
|
1529
1529
|
constructor(e) {
|
|
1530
|
-
const { checkoutProfile: t, formData:
|
|
1530
|
+
const { checkoutProfile: t, formData: a, onPaypalSubmit: i } = e;
|
|
1531
1531
|
if (!t?.additionalPaymentMethods) {
|
|
1532
1532
|
super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), this.getElement().style.display = "none";
|
|
1533
1533
|
return;
|
|
@@ -1543,11 +1543,11 @@ class gt extends d {
|
|
|
1543
1543
|
for (const [r] of s)
|
|
1544
1544
|
switch (r) {
|
|
1545
1545
|
case "paypal": {
|
|
1546
|
-
if (
|
|
1546
|
+
if (i) {
|
|
1547
1547
|
const o = new ft({
|
|
1548
1548
|
checkoutProfile: t,
|
|
1549
|
-
formData:
|
|
1550
|
-
onSubmit:
|
|
1549
|
+
formData: a,
|
|
1550
|
+
onSubmit: i
|
|
1551
1551
|
});
|
|
1552
1552
|
this.paymentMethods.set("paypal", o), o.appendTo(this.getElement());
|
|
1553
1553
|
}
|
|
@@ -1590,17 +1590,17 @@ class vt extends d {
|
|
|
1590
1590
|
class Et {
|
|
1591
1591
|
button;
|
|
1592
1592
|
constructor(e) {
|
|
1593
|
-
const { disabled: t, checkoutProfile:
|
|
1593
|
+
const { disabled: t, checkoutProfile: a, translationFunc: i } = e;
|
|
1594
1594
|
this.button = new vt({
|
|
1595
|
-
text:
|
|
1596
|
-
`buttonTexts.${
|
|
1595
|
+
text: i(
|
|
1596
|
+
`buttonTexts.${a?.layout.actionButton.translationKey}`
|
|
1597
1597
|
),
|
|
1598
1598
|
styles: {
|
|
1599
|
-
backgroundColor:
|
|
1600
|
-
color:
|
|
1601
|
-
fontFamily:
|
|
1602
|
-
borderRadius:
|
|
1603
|
-
fontSize:
|
|
1599
|
+
backgroundColor: a.styles.buttonColor,
|
|
1600
|
+
color: a.styles.buttonTextColor,
|
|
1601
|
+
fontFamily: a.styles.fontFamily,
|
|
1602
|
+
borderRadius: a.styles.borderRadius,
|
|
1603
|
+
fontSize: a.styles.buttonFontSize
|
|
1604
1604
|
},
|
|
1605
1605
|
disabled: t
|
|
1606
1606
|
});
|
|
@@ -1611,8 +1611,8 @@ class Et {
|
|
|
1611
1611
|
setDisabled(e) {
|
|
1612
1612
|
return this.button.setDisabled(e), this;
|
|
1613
1613
|
}
|
|
1614
|
-
addEventListener(e, t,
|
|
1615
|
-
return this.button.addEventListener(e, t,
|
|
1614
|
+
addEventListener(e, t, a) {
|
|
1615
|
+
return this.button.addEventListener(e, t, a), this;
|
|
1616
1616
|
}
|
|
1617
1617
|
appendTo(e) {
|
|
1618
1618
|
return this.button.appendTo(e), this;
|
|
@@ -1633,16 +1633,16 @@ class St extends d {
|
|
|
1633
1633
|
spinner;
|
|
1634
1634
|
alert;
|
|
1635
1635
|
// factories
|
|
1636
|
-
formManager =
|
|
1636
|
+
formManager = G();
|
|
1637
1637
|
checkoutProfile;
|
|
1638
|
-
translation =
|
|
1638
|
+
translation = M();
|
|
1639
1639
|
iframeHook;
|
|
1640
1640
|
constructor(e) {
|
|
1641
|
-
super("form", ["form-container"]), this.options = e, this.checkoutProfile =
|
|
1641
|
+
super("form", ["form-container"]), this.options = e, this.checkoutProfile = H({
|
|
1642
1642
|
apiKey: e.apiKey,
|
|
1643
1643
|
profileId: e.profileId,
|
|
1644
1644
|
environment: e.environment
|
|
1645
|
-
}), e.locale && this.translation.setLocale(e.locale), this.getElement().
|
|
1645
|
+
}), e.locale && this.translation.setLocale(e.locale), this.getElement().addEventListener("submit", this.handleSubmit), this.getElement().addEventListener("keydown", this.handleKeyDown), this.formManager.subscribe(this.handleFormStateChange), this.checkoutProfile.subscribe(this.handleProfileStateChange), this.initializeForm(), this.appendTo(e.container);
|
|
1646
1646
|
}
|
|
1647
1647
|
_getFormStateData() {
|
|
1648
1648
|
const e = this.formManager.getFormState();
|
|
@@ -1661,10 +1661,10 @@ class St extends d {
|
|
|
1661
1661
|
};
|
|
1662
1662
|
handleProfileStateChange = (e) => {
|
|
1663
1663
|
if (!e.isLoading)
|
|
1664
|
-
if (this.
|
|
1664
|
+
if (this.setLoadingState(!1), e.checkoutProfile)
|
|
1665
1665
|
try {
|
|
1666
1666
|
if (e.checkoutProfile.styles?.fontFamily) {
|
|
1667
|
-
const { cleanup: t } =
|
|
1667
|
+
const { cleanup: t } = et({
|
|
1668
1668
|
fontFamily: e.checkoutProfile.styles.fontFamily
|
|
1669
1669
|
});
|
|
1670
1670
|
this.fontCleanup = t;
|
|
@@ -1687,15 +1687,15 @@ class St extends d {
|
|
|
1687
1687
|
setTimeout(() => this.initializeTokenExIframe(), 500);
|
|
1688
1688
|
return;
|
|
1689
1689
|
}
|
|
1690
|
-
const { inputStyles: t, formContainerStyle:
|
|
1690
|
+
const { inputStyles: t, formContainerStyle: a } = at(
|
|
1691
1691
|
e.checkoutProfile
|
|
1692
1692
|
);
|
|
1693
|
-
this.applyFormContainerStyles(
|
|
1693
|
+
this.applyFormContainerStyles(a), this.iframeHook = Y({
|
|
1694
1694
|
apiKey: this.options.apiKey,
|
|
1695
1695
|
checkoutProfile: e.checkoutProfile,
|
|
1696
1696
|
inputStyles: t,
|
|
1697
|
-
setFormData: (
|
|
1698
|
-
this.formManager.setFormData(
|
|
1697
|
+
setFormData: (i) => {
|
|
1698
|
+
this.formManager.setFormData(i);
|
|
1699
1699
|
},
|
|
1700
1700
|
environment: this.options.environment
|
|
1701
1701
|
}), this.iframeHook?.subscribe(this.handleIframeStateChange), this.renderFormComponents();
|
|
@@ -1718,7 +1718,7 @@ class St extends d {
|
|
|
1718
1718
|
createCardSection = (e) => {
|
|
1719
1719
|
if (this.iframeHook && !this.cardSection)
|
|
1720
1720
|
try {
|
|
1721
|
-
const { formData: t, errors:
|
|
1721
|
+
const { formData: t, errors: a, touched: i } = this._getFormStateData(), s = this.iframeHook.getState();
|
|
1722
1722
|
this.cardSection = new mt({
|
|
1723
1723
|
checkoutProfile: e,
|
|
1724
1724
|
isLoading: s.loadingIframe,
|
|
@@ -1728,24 +1728,24 @@ class St extends d {
|
|
|
1728
1728
|
isCvvValid: s.isCvvValid,
|
|
1729
1729
|
cardType: s.possibleCardType,
|
|
1730
1730
|
cardExpiry: t.cardExpiry,
|
|
1731
|
-
cardExpiryError:
|
|
1732
|
-
cardExpiryTouched: !!
|
|
1731
|
+
cardExpiryError: a.cardExpiry,
|
|
1732
|
+
cardExpiryTouched: !!i.cardExpiry,
|
|
1733
1733
|
onChange: this.handleChange,
|
|
1734
1734
|
onBlur: this.handleBlur,
|
|
1735
1735
|
translationFunc: this.translation.t
|
|
1736
|
-
}), this.element.appendChild(this.cardSection.getElement()), this.updateFormUI(), this.cardSection && this.emailField && this.cardholderSection && this.submitButton
|
|
1736
|
+
}), this.element.appendChild(this.cardSection.getElement()), this.updateFormUI(), this.cardSection && this.emailField && this.cardholderSection && this.submitButton;
|
|
1737
1737
|
} catch {
|
|
1738
1738
|
this.setErrorMessage("Card section temporarily unavailabl");
|
|
1739
1739
|
}
|
|
1740
1740
|
};
|
|
1741
1741
|
initializeForm() {
|
|
1742
|
-
this.
|
|
1743
|
-
const e = this.options.environment === "test" ? bt : Ct, { cleanup: t, isLoaded:
|
|
1742
|
+
this.setLoadingState(!0), this.options.errorMsg && this.setErrorMessage(this.options.errorMsg);
|
|
1743
|
+
const e = this.options.environment === "test" ? bt : Ct, { cleanup: t, isLoaded: a } = tt({
|
|
1744
1744
|
scriptSrc: e
|
|
1745
1745
|
});
|
|
1746
|
-
this.scriptCleanup = t,
|
|
1746
|
+
this.scriptCleanup = t, a.then(() => {
|
|
1747
1747
|
}).catch(() => {
|
|
1748
|
-
this.setErrorMessage(
|
|
1748
|
+
this.setLoadingState(!1), this.setErrorMessage(
|
|
1749
1749
|
"Failed to load payment system. Please try again later."
|
|
1750
1750
|
);
|
|
1751
1751
|
});
|
|
@@ -1758,53 +1758,45 @@ class St extends d {
|
|
|
1758
1758
|
this.setErrorMessage("Failed to load checkout configuration");
|
|
1759
1759
|
return;
|
|
1760
1760
|
}
|
|
1761
|
-
this.createPaymentMethods(e.checkoutProfile), this.createEmailField(e.checkoutProfile), this.createCardSection(e.checkoutProfile), this.createCardholderSection(e.checkoutProfile), this.createSubmitButton(e.checkoutProfile)
|
|
1761
|
+
this.createPaymentMethods(e.checkoutProfile), this.createEmailField(e.checkoutProfile), this.createCardSection(e.checkoutProfile), this.createCardholderSection(e.checkoutProfile), this.createSubmitButton(e.checkoutProfile);
|
|
1762
1762
|
} catch {
|
|
1763
1763
|
this.setErrorMessage("Failed to render checkout form components");
|
|
1764
1764
|
}
|
|
1765
1765
|
}
|
|
1766
|
-
/**
|
|
1767
|
-
* Animate the form's visibility by transitioning opacity
|
|
1768
|
-
*/
|
|
1769
|
-
animateFormVisibility() {
|
|
1770
|
-
setTimeout(() => {
|
|
1771
|
-
this.getElement().style.opacity = "1";
|
|
1772
|
-
}, 100);
|
|
1773
|
-
}
|
|
1774
1766
|
createPaymentMethods(e) {
|
|
1775
1767
|
if (!e?.additionalPaymentMethods || Object.entries(
|
|
1776
1768
|
e.additionalPaymentMethods
|
|
1777
|
-
).filter(([,
|
|
1769
|
+
).filter(([, i]) => i.enabled).length === 0)
|
|
1778
1770
|
return;
|
|
1779
|
-
const { formData:
|
|
1771
|
+
const { formData: a } = this._getFormStateData();
|
|
1780
1772
|
this.paymentMethods = new gt({
|
|
1781
1773
|
checkoutProfile: e,
|
|
1782
|
-
formData:
|
|
1774
|
+
formData: a,
|
|
1783
1775
|
onPaypalSubmit: async () => {
|
|
1784
1776
|
await this.handlePaypalSubmit();
|
|
1785
1777
|
}
|
|
1786
1778
|
}), this.appendChild(this.paymentMethods);
|
|
1787
1779
|
}
|
|
1788
1780
|
createEmailField(e) {
|
|
1789
|
-
const { formData: t, errors:
|
|
1781
|
+
const { formData: t, errors: a, touched: i } = this._getFormStateData();
|
|
1790
1782
|
this.emailField = new ut({
|
|
1791
1783
|
value: t.email,
|
|
1792
1784
|
onChange: this.handleChange,
|
|
1793
1785
|
onBlur: this.handleBlur,
|
|
1794
|
-
error: !!(
|
|
1795
|
-
errorMsg:
|
|
1786
|
+
error: !!(a.email && i.email),
|
|
1787
|
+
errorMsg: a.email,
|
|
1796
1788
|
checkoutProfile: e,
|
|
1797
1789
|
translationFunc: this.translation.t
|
|
1798
1790
|
}), this.element.appendChild(this.emailField.getElement());
|
|
1799
1791
|
}
|
|
1800
1792
|
createCardholderSection(e) {
|
|
1801
|
-
const { formData: t, errors:
|
|
1793
|
+
const { formData: t, errors: a, touched: i } = this._getFormStateData();
|
|
1802
1794
|
this.cardholderSection = new rt({
|
|
1803
1795
|
value: t.name,
|
|
1804
1796
|
onChange: this.handleChange,
|
|
1805
1797
|
onBlur: this.handleBlur,
|
|
1806
|
-
error: !!(
|
|
1807
|
-
errorMsg:
|
|
1798
|
+
error: !!(a.name && i.name),
|
|
1799
|
+
errorMsg: a.name,
|
|
1808
1800
|
checkoutProfile: e,
|
|
1809
1801
|
translationFunc: this.translation.t
|
|
1810
1802
|
}), this.element.appendChild(this.cardholderSection.getElement());
|
|
@@ -1817,12 +1809,12 @@ class St extends d {
|
|
|
1817
1809
|
}), this.element.appendChild(this.submitButton.getElement());
|
|
1818
1810
|
}
|
|
1819
1811
|
handleChange = (e) => {
|
|
1820
|
-
const t = e.target, { name:
|
|
1821
|
-
this.formManager.handleChange(
|
|
1812
|
+
const t = e.target, { name: a, value: i } = t;
|
|
1813
|
+
this.formManager.handleChange(a, i);
|
|
1822
1814
|
};
|
|
1823
1815
|
handleBlur = (e) => {
|
|
1824
|
-
const t = e.target, { name:
|
|
1825
|
-
this.formManager.handleBlur(
|
|
1816
|
+
const t = e.target, { name: a, value: i } = t;
|
|
1817
|
+
this.formManager.handleBlur(a, i);
|
|
1826
1818
|
};
|
|
1827
1819
|
updateFormUI() {
|
|
1828
1820
|
const e = this.formManager.getFormState();
|
|
@@ -1845,15 +1837,22 @@ class St extends d {
|
|
|
1845
1837
|
isCvvValid: !1
|
|
1846
1838
|
};
|
|
1847
1839
|
this.iframeHook && (t = this.iframeHook.getState());
|
|
1848
|
-
const
|
|
1840
|
+
const a = Object.keys(e.errors).length > 0, i = (
|
|
1849
1841
|
// Only require card validation if CardSection exists
|
|
1850
1842
|
(!this.cardSection || t.isCcValid && t.isCvvValid) && !!e.formData.email && !!e.formData.name && // Only require card expiry if CardSection exists
|
|
1851
1843
|
(!this.cardSection || !!e.formData.cardExpiry)
|
|
1852
1844
|
);
|
|
1853
|
-
return
|
|
1845
|
+
return a || !i || this.isSubmitting;
|
|
1846
|
+
}
|
|
1847
|
+
setLoadingState(e) {
|
|
1848
|
+
if (this.options.onLoadingStateChange) {
|
|
1849
|
+
this.options.onLoadingStateChange(e);
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
e ? (this.hideSpinner(), this.spinner = new N(), this.appendChild(this.spinner)) : this.hideSpinner();
|
|
1854
1853
|
}
|
|
1855
1854
|
showSpinner(e) {
|
|
1856
|
-
this.hideSpinner(), this.spinner = new
|
|
1855
|
+
this.hideSpinner(), this.spinner = new N({ text: e }), this.appendChild(this.spinner);
|
|
1857
1856
|
}
|
|
1858
1857
|
hideSpinner() {
|
|
1859
1858
|
this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
|
|
@@ -1901,7 +1900,7 @@ class St extends d {
|
|
|
1901
1900
|
* Update the form error message
|
|
1902
1901
|
*/
|
|
1903
1902
|
setErrorMessage(e) {
|
|
1904
|
-
return this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new it({ message: e }), this.element.insertBefore(this.alert.getElement(), this.element.firstChild), this
|
|
1903
|
+
return this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new it({ message: e }), this.element.insertBefore(this.alert.getElement(), this.element.firstChild), this;
|
|
1905
1904
|
}
|
|
1906
1905
|
/**
|
|
1907
1906
|
* Clean up resources when the form is destroyed
|
|
@@ -1935,7 +1934,8 @@ class xt {
|
|
|
1935
1934
|
errorMsg: this.options.disableErrorMessages ? void 0 : e,
|
|
1936
1935
|
profileId: this.options.profileId,
|
|
1937
1936
|
container: this.container,
|
|
1938
|
-
environment: this.options.environment
|
|
1937
|
+
environment: this.options.environment,
|
|
1938
|
+
onLoadingStateChange: this.options.onLoadingStateChange
|
|
1939
1939
|
}));
|
|
1940
1940
|
}
|
|
1941
1941
|
unmount() {
|
|
@@ -1982,7 +1982,8 @@ class wt {
|
|
|
1982
1982
|
apiKey: this.config.apiKey,
|
|
1983
1983
|
profileId: this.config.profileId,
|
|
1984
1984
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
1985
|
-
environment: this.config.environment
|
|
1985
|
+
environment: this.config.environment,
|
|
1986
|
+
onLoadingStateChange: this.config.callbacks.onLoadingStateChange
|
|
1986
1987
|
},
|
|
1987
1988
|
this.handleSubmit.bind(this)
|
|
1988
1989
|
);
|
|
@@ -2005,7 +2006,8 @@ class wt {
|
|
|
2005
2006
|
callbacks: {
|
|
2006
2007
|
onPaymentSucceeded: e.callbacks?.onPaymentSucceeded || void 0,
|
|
2007
2008
|
onPaymentFailed: e.callbacks?.onPaymentFailed || void 0,
|
|
2008
|
-
onActionRequired: e.callbacks?.onActionRequired || void 0
|
|
2009
|
+
onActionRequired: e.callbacks?.onActionRequired || void 0,
|
|
2010
|
+
onLoadingStateChange: e.callbacks?.onLoadingStateChange || void 0
|
|
2009
2011
|
}
|
|
2010
2012
|
};
|
|
2011
2013
|
}
|
|
@@ -2013,11 +2015,11 @@ class wt {
|
|
|
2013
2015
|
const t = document.querySelector(e);
|
|
2014
2016
|
if (!t)
|
|
2015
2017
|
throw new Error(`Container ${e} not found`);
|
|
2016
|
-
const
|
|
2017
|
-
return t.appendChild(
|
|
2018
|
-
form:
|
|
2018
|
+
const a = document.createElement("div");
|
|
2019
|
+
return t.appendChild(a), this.stateManager.updateState({
|
|
2020
|
+
form: a,
|
|
2019
2021
|
mounted: !0
|
|
2020
|
-
}), this.formManager.mount(
|
|
2022
|
+
}), this.formManager.mount(a), this;
|
|
2021
2023
|
}
|
|
2022
2024
|
unmount() {
|
|
2023
2025
|
const { mounted: e } = this.stateManager.getState();
|
|
@@ -2035,16 +2037,16 @@ class wt {
|
|
|
2035
2037
|
formData: t
|
|
2036
2038
|
}) {
|
|
2037
2039
|
try {
|
|
2038
|
-
const
|
|
2040
|
+
const a = await this.apiService.authorizePayment({
|
|
2039
2041
|
checkoutKey: this.config.checkoutKey,
|
|
2040
2042
|
formData: t || null,
|
|
2041
2043
|
token: e?.token || null,
|
|
2042
2044
|
paymentId: this.config.paymentId,
|
|
2043
2045
|
returnUrl: this.config.returnUrl
|
|
2044
2046
|
});
|
|
2045
|
-
this.handlePaymentResponse(
|
|
2046
|
-
} catch (
|
|
2047
|
-
this.handleAuthorizationError(
|
|
2047
|
+
this.handlePaymentResponse(a);
|
|
2048
|
+
} catch (a) {
|
|
2049
|
+
this.handleAuthorizationError(a);
|
|
2048
2050
|
}
|
|
2049
2051
|
}
|
|
2050
2052
|
handlePaymentResponse(e) {
|
|
@@ -2064,11 +2066,11 @@ class wt {
|
|
|
2064
2066
|
typeof globalThis < "u" && (globalThis.OdusCheckout = wt);
|
|
2065
2067
|
export {
|
|
2066
2068
|
wt as OdusCheckout,
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2069
|
+
se as deLocale,
|
|
2070
|
+
ue as enLocale,
|
|
2071
|
+
Se as esLocale,
|
|
2072
|
+
ze as frLocale,
|
|
2073
|
+
Oe as plLocale,
|
|
2074
|
+
Ye as ptLocale
|
|
2073
2075
|
};
|
|
2074
2076
|
//# sourceMappingURL=checkout.es.js.map
|