@odus/checkout 1.16.0 → 1.17.0-beta.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/dist/checkout.es.js +136 -136
- package/dist/elements/OdusElements.d.ts.map +1 -1
- package/dist/elements.es.js +217 -217
- package/dist/phone.js +38 -38
- package/dist/services/checkout/Checkout.service.d.ts.map +1 -1
- package/dist/shared.js +3 -3
- package/dist/types/payment/Payment.type.d.ts +2 -1
- package/dist/types/payment/Payment.type.d.ts.map +1 -1
- package/dist/utils/helpers/paymentResult.util.d.ts +12 -0
- package/dist/utils/helpers/paymentResult.util.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/checkout.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, D as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, O as m, P as ee, Q as h, R as g, S as _, T as te, U as ne, X as re, Y as ie, Z as v, _ as ae, _t as y, at as oe, b, c as se, ct as x, d as ce, dt as S, f as C, ft as w, g as T, gt as E, h as D, ht as O, i as k, it as A, j as le, k as ue, l as de, lt as j, mt as M, n as fe, nt as pe, o as me, ot as N, p as P, pt as F, q as I, r as L, rt as R, s as z, st as he, t as ge, tt as _e, u as B, ut as V, vt as ve, w as ye, x as H, y as U, yt as be, z as W } from "./shared.js";
|
|
2
2
|
import { t as G } from "./shared2.js";
|
|
3
3
|
//#region libs/checkout/src/utils/focus/FocusManager.ts
|
|
4
|
-
var
|
|
4
|
+
var xe = class {
|
|
5
5
|
focusSequence = [
|
|
6
6
|
"cardNumber",
|
|
7
7
|
"cardExpiry",
|
|
@@ -81,7 +81,7 @@ var be = class {
|
|
|
81
81
|
};
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
|
|
84
|
-
function
|
|
84
|
+
function Se(e) {
|
|
85
85
|
if (!e) return !1;
|
|
86
86
|
let { billingFields: t, shippingFields: n } = e, r = t && Object.values(t).some((e) => e?.enabled), i = n && Object.values(n).some((e) => e?.enabled);
|
|
87
87
|
return !!(r || i);
|
|
@@ -93,7 +93,7 @@ function K(e) {
|
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region libs/checkout/src/components/checkout/form/AddressSection.ts
|
|
96
|
-
var q = class extends
|
|
96
|
+
var q = class extends H {
|
|
97
97
|
inputs = /* @__PURE__ */ new Map();
|
|
98
98
|
type;
|
|
99
99
|
onChange;
|
|
@@ -115,7 +115,7 @@ var q = class extends b {
|
|
|
115
115
|
let e = document.createElement("h3");
|
|
116
116
|
e.className = "address-section-title", e.textContent = t, e.style.color = n.styles.textColor, e.style.fontFamily = `"${n.styles.fontFamily}", sans-serif`, e.style.fontSize = `${n.styles.fontSize}px`, e.style.fontWeight = "normal", this.getElement().appendChild(e);
|
|
117
117
|
}
|
|
118
|
-
this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(n, r, i, a, o), this.grouped && (this.groupMessage = new
|
|
118
|
+
this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(n, r, i, a, o), this.grouped && (this.groupMessage = new T({
|
|
119
119
|
text: "",
|
|
120
120
|
visible: !1
|
|
121
121
|
}), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
|
|
@@ -181,7 +181,7 @@ var q = class extends b {
|
|
|
181
181
|
this.fieldsContainer.appendChild(a);
|
|
182
182
|
} else if (e.kind === "state") {
|
|
183
183
|
let e = this.createRow(["full"]);
|
|
184
|
-
if (this.stateFieldConfig = t.state, this.stateRow = e, this.stateStyles = d(!0, !0), this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none"),
|
|
184
|
+
if (this.stateFieldConfig = t.state, this.stateRow = e, this.stateStyles = d(!0, !0), this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none"), W(n.country)) {
|
|
185
185
|
let a = this.createStateSelect(n.state, r.state, i.state, this.stateStyles, n.country, t.state?.label);
|
|
186
186
|
this.inputs.set("state", a), e.appendChild(a.getElement());
|
|
187
187
|
} else {
|
|
@@ -197,7 +197,7 @@ var q = class extends b {
|
|
|
197
197
|
return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
|
|
198
198
|
}
|
|
199
199
|
createInput(e, t, n, r, i, a, o, s) {
|
|
200
|
-
let c = `${this.type}Address.${e}`, l = new
|
|
200
|
+
let c = `${this.type}Address.${e}`, l = new P({
|
|
201
201
|
name: c,
|
|
202
202
|
error: !1,
|
|
203
203
|
errorMsg: void 0,
|
|
@@ -239,7 +239,7 @@ var q = class extends b {
|
|
|
239
239
|
}), l;
|
|
240
240
|
}
|
|
241
241
|
createCountrySelect(e, t, n, r, i, a) {
|
|
242
|
-
let o = `${this.type}Address.country`, s =
|
|
242
|
+
let o = `${this.type}Address.country`, s = ae(i, this.locale), c = new C({
|
|
243
243
|
name: o,
|
|
244
244
|
error: !1,
|
|
245
245
|
errorMsg: void 0,
|
|
@@ -275,27 +275,27 @@ var q = class extends b {
|
|
|
275
275
|
handleCountryChange(e) {
|
|
276
276
|
let t = this.currentCountry;
|
|
277
277
|
if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
|
|
278
|
-
let
|
|
279
|
-
if (
|
|
278
|
+
let r = this.stateFieldConfig.hiddenForCountries?.includes(t), i = this.stateFieldConfig.hiddenForCountries?.includes(e);
|
|
279
|
+
if (i && !r) {
|
|
280
280
|
this.stateRow.style.display = "none", this.applyFieldError("state", !1), this.clearStateValue();
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
|
-
if (!
|
|
284
|
-
let
|
|
285
|
-
if (
|
|
283
|
+
if (!i && r && (this.stateRow.style.display = ""), i) return;
|
|
284
|
+
let a = this.inputs.get("state") instanceof C, o = W(e);
|
|
285
|
+
if (a && o) {
|
|
286
286
|
let t = this.inputs.get("state");
|
|
287
|
-
if (t instanceof
|
|
288
|
-
let
|
|
289
|
-
t.setOptions(
|
|
287
|
+
if (t instanceof C) {
|
|
288
|
+
let r = n(e), i = d(r), a = this.translationFunc(g(r));
|
|
289
|
+
t.setOptions(i, a);
|
|
290
290
|
}
|
|
291
291
|
this.clearStateValue();
|
|
292
|
-
} else
|
|
292
|
+
} else a === o ? !a && !o && t !== e && this.clearStateValue() : (this.rebuildStateField(e), this.clearStateValue());
|
|
293
293
|
}
|
|
294
294
|
rebuildStateField(e) {
|
|
295
295
|
if (!this.stateRow || !this.stateStyles) return;
|
|
296
296
|
this.applyFieldError("state", !1);
|
|
297
297
|
let t = this.inputs.get("state");
|
|
298
|
-
if (t && (t.getElement().remove(), this.inputs.delete("state")),
|
|
298
|
+
if (t && (t.getElement().remove(), this.inputs.delete("state")), W(e)) {
|
|
299
299
|
let t = this.createStateSelect("", void 0, void 0, this.stateStyles, e, this.stateFieldConfig?.label);
|
|
300
300
|
this.inputs.set("state", t), this.stateRow.appendChild(t.getElement());
|
|
301
301
|
} else {
|
|
@@ -316,15 +316,15 @@ var q = class extends b {
|
|
|
316
316
|
detail: { programmatic: !0 }
|
|
317
317
|
}));
|
|
318
318
|
}
|
|
319
|
-
createStateSelect(e, t,
|
|
320
|
-
let
|
|
321
|
-
name:
|
|
319
|
+
createStateSelect(e, t, r, i, a, o) {
|
|
320
|
+
let s = `${this.type}Address.state`, c = n(a), l = d(c), u = this.translationFunc(g(c)), f = new C({
|
|
321
|
+
name: s,
|
|
322
322
|
error: !1,
|
|
323
323
|
errorMsg: void 0,
|
|
324
|
-
styles:
|
|
325
|
-
placeholder:
|
|
324
|
+
styles: i,
|
|
325
|
+
placeholder: u,
|
|
326
326
|
renderMessage: !this.grouped,
|
|
327
|
-
...!this.grouped && { label:
|
|
327
|
+
...!this.grouped && { label: o ?? u },
|
|
328
328
|
value: e,
|
|
329
329
|
options: l,
|
|
330
330
|
autocomplete: "address-level1",
|
|
@@ -332,7 +332,7 @@ var q = class extends b {
|
|
|
332
332
|
this.applyFieldError("state", !1), this.onChange(G({
|
|
333
333
|
type: "change",
|
|
334
334
|
target: {
|
|
335
|
-
name:
|
|
335
|
+
name: s,
|
|
336
336
|
value: e.target.value
|
|
337
337
|
}
|
|
338
338
|
}));
|
|
@@ -342,7 +342,7 @@ var q = class extends b {
|
|
|
342
342
|
this.onBlur(G({
|
|
343
343
|
type: "blur",
|
|
344
344
|
target: {
|
|
345
|
-
name:
|
|
345
|
+
name: s,
|
|
346
346
|
value: e.target.value
|
|
347
347
|
}
|
|
348
348
|
}));
|
|
@@ -367,7 +367,7 @@ var q = class extends b {
|
|
|
367
367
|
this.stateFieldConfig = t.state;
|
|
368
368
|
let e = this.createRow(["full"]);
|
|
369
369
|
this.stateRow = e, this.stateStyles = o, this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none");
|
|
370
|
-
let a =
|
|
370
|
+
let a = W(n.country), s = t.state?.label ?? this.translationFunc("address.state");
|
|
371
371
|
if (a) {
|
|
372
372
|
let t = this.createStateSelect(n.state, r.state, i.state, o, n.country, s);
|
|
373
373
|
this.inputs.set("state", t), e.appendChild(t.getElement());
|
|
@@ -433,7 +433,7 @@ var q = class extends b {
|
|
|
433
433
|
let e = this.inputs.values().next().value;
|
|
434
434
|
e && e.focus();
|
|
435
435
|
}
|
|
436
|
-
},
|
|
436
|
+
}, Ce = class {
|
|
437
437
|
input = null;
|
|
438
438
|
isVgsMode;
|
|
439
439
|
vgsWrapper = null;
|
|
@@ -441,7 +441,7 @@ var q = class extends b {
|
|
|
441
441
|
vgsHelperText = null;
|
|
442
442
|
wrapperElement;
|
|
443
443
|
_vgsFieldsReady = !1;
|
|
444
|
-
_fieldHeight = U
|
|
444
|
+
_fieldHeight = b(U, 14);
|
|
445
445
|
_borderRadius = 0;
|
|
446
446
|
constructor(e) {
|
|
447
447
|
let { value: t, onChange: n, onBlur: r, errorMsg: i, checkoutProfile: a, translationFunc: o, autocomplete: s = "cc-name", isVgsMode: c = !1 } = e;
|
|
@@ -449,16 +449,16 @@ var q = class extends b {
|
|
|
449
449
|
}
|
|
450
450
|
buildVgsLayout(e, t) {
|
|
451
451
|
let n = e.styles.borderRadius;
|
|
452
|
-
this._borderRadius = n, this._fieldHeight = U
|
|
452
|
+
this._borderRadius = n, this._fieldHeight = b(U, e.styles.fontSize);
|
|
453
453
|
let r = document.createElement("div");
|
|
454
454
|
r.style.marginBottom = "4px";
|
|
455
455
|
let i = document.createElement("label");
|
|
456
456
|
i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), this.wrapperElement.appendChild(r), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${n}px`, this.vgsWrapper.style.height = this._fieldHeight, this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
|
|
457
457
|
let a = document.createElement("div");
|
|
458
|
-
a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new
|
|
458
|
+
a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new T({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
|
|
459
459
|
}
|
|
460
460
|
buildNativeLayout(e, t, n, r, i, a, o) {
|
|
461
|
-
this.input = new
|
|
461
|
+
this.input = new P({
|
|
462
462
|
name: "name",
|
|
463
463
|
label: a("cardholderNameLabel"),
|
|
464
464
|
error: !1,
|
|
@@ -485,9 +485,9 @@ var q = class extends b {
|
|
|
485
485
|
}
|
|
486
486
|
handleVgsStateChange(e, t) {
|
|
487
487
|
if (!this.isVgsMode || !this.vgsWrapper) return;
|
|
488
|
-
let n = e[
|
|
488
|
+
let n = e[B.CARDHOLDER]?.isFocused;
|
|
489
489
|
if (this._vgsFieldsReady && (this.vgsWrapper.style.boxShadow = n ? "0 0 0 1px rgba(50, 151, 211, 0.7), 0 1px 1px 0 rgba(0, 0, 0, 0.07), 0 0 0 4px rgba(50, 151, 211, 0.3)" : "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)"), !t || !this.vgsHelperText) return;
|
|
490
|
-
let r = t[
|
|
490
|
+
let r = t[B.CARDHOLDER];
|
|
491
491
|
r ? (this.vgsHelperText.setText(r), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
|
|
492
492
|
}
|
|
493
493
|
setFieldHeight(e) {
|
|
@@ -529,7 +529,7 @@ var q = class extends b {
|
|
|
529
529
|
focus() {
|
|
530
530
|
this.isVgsMode || this.input?.focus();
|
|
531
531
|
}
|
|
532
|
-
}, J = class extends
|
|
532
|
+
}, J = class extends H {
|
|
533
533
|
constructor() {
|
|
534
534
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
535
535
|
}
|
|
@@ -537,14 +537,14 @@ var q = class extends b {
|
|
|
537
537
|
this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
|
|
538
538
|
}
|
|
539
539
|
createPaymentMethodSkeleton() {
|
|
540
|
-
let e =
|
|
540
|
+
let e = D.createDiv(["skeleton-field"]), t = D.createDiv(["skeleton", "skeleton-payment-method"]);
|
|
541
541
|
return e.appendChild(t), e;
|
|
542
542
|
}
|
|
543
543
|
createPaymentSeparatorSkeleton() {
|
|
544
|
-
let e =
|
|
544
|
+
let e = D.createDiv(["payment-separator_container"]), t = D.createDiv(["payment-separator__line"]), n = D.createDiv(["skeleton", "skeleton-separator-text"]), r = D.createDiv(["payment-separator__line"]);
|
|
545
545
|
return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
|
|
546
546
|
}
|
|
547
|
-
},
|
|
547
|
+
}, we = class extends H {
|
|
548
548
|
constructor(e) {
|
|
549
549
|
let { translationFunc: t, checkoutProfile: n } = e;
|
|
550
550
|
super("div", ["payment-separator"]);
|
|
@@ -555,7 +555,7 @@ var q = class extends b {
|
|
|
555
555
|
let o = document.createElement("span");
|
|
556
556
|
o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
|
|
557
557
|
}
|
|
558
|
-
},
|
|
558
|
+
}, Te = class extends H {
|
|
559
559
|
paymentMethods;
|
|
560
560
|
paymentSeparator;
|
|
561
561
|
skeleton;
|
|
@@ -570,7 +570,7 @@ var q = class extends b {
|
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
572
|
let m = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
|
|
573
|
-
let n = t.enabled, r = !s || s[e] === !0, i =
|
|
573
|
+
let n = t.enabled, r = !s || s[e] === !0, i = me(t.countries, p);
|
|
574
574
|
return n && r && i;
|
|
575
575
|
}).sort((e, t) => e[1].order - t[1].order);
|
|
576
576
|
if (m.length === 0) this.getElement().style.display = "none";
|
|
@@ -578,7 +578,7 @@ var q = class extends b {
|
|
|
578
578
|
for (let [e] of m) switch (e) {
|
|
579
579
|
case "paypal":
|
|
580
580
|
if (r) {
|
|
581
|
-
let e = new
|
|
581
|
+
let e = new L({
|
|
582
582
|
checkoutProfile: t,
|
|
583
583
|
formData: n,
|
|
584
584
|
onSubmit: r
|
|
@@ -588,7 +588,7 @@ var q = class extends b {
|
|
|
588
588
|
break;
|
|
589
589
|
case "applePay":
|
|
590
590
|
if (i && l && u) {
|
|
591
|
-
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new
|
|
591
|
+
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new k({
|
|
592
592
|
checkoutProfile: t,
|
|
593
593
|
formData: n,
|
|
594
594
|
onSubmit: i,
|
|
@@ -607,7 +607,7 @@ var q = class extends b {
|
|
|
607
607
|
break;
|
|
608
608
|
default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
|
|
609
609
|
}
|
|
610
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
610
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new we({
|
|
611
611
|
translationFunc: c,
|
|
612
612
|
checkoutProfile: t
|
|
613
613
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
@@ -625,7 +625,7 @@ var q = class extends b {
|
|
|
625
625
|
hasVisiblePaymentMethods() {
|
|
626
626
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
627
627
|
}
|
|
628
|
-
},
|
|
628
|
+
}, Ee = 17, De = class extends H {
|
|
629
629
|
styles;
|
|
630
630
|
isHovered = !1;
|
|
631
631
|
constructor(e) {
|
|
@@ -633,7 +633,7 @@ var q = class extends b {
|
|
|
633
633
|
}
|
|
634
634
|
applyStyles() {
|
|
635
635
|
let e = this.getElement();
|
|
636
|
-
e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius ===
|
|
636
|
+
e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius === Ee ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
637
637
|
}
|
|
638
638
|
handleMouseEnter() {
|
|
639
639
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -644,11 +644,11 @@ var q = class extends b {
|
|
|
644
644
|
setDisabled(e) {
|
|
645
645
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
646
646
|
}
|
|
647
|
-
},
|
|
647
|
+
}, Oe = class {
|
|
648
648
|
button;
|
|
649
649
|
constructor(e) {
|
|
650
650
|
let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
|
|
651
|
-
this.button = new
|
|
651
|
+
this.button = new De({
|
|
652
652
|
text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
|
|
653
653
|
styles: {
|
|
654
654
|
backgroundColor: n.styles.buttonColor,
|
|
@@ -672,7 +672,7 @@ var q = class extends b {
|
|
|
672
672
|
appendTo(e) {
|
|
673
673
|
return this.button.appendTo(e), this;
|
|
674
674
|
}
|
|
675
|
-
},
|
|
675
|
+
}, ke = class {
|
|
676
676
|
formElement;
|
|
677
677
|
focusManager;
|
|
678
678
|
translationFunc;
|
|
@@ -712,7 +712,7 @@ var q = class extends b {
|
|
|
712
712
|
createPaymentMethods(e, t, n = !1) {
|
|
713
713
|
try {
|
|
714
714
|
if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
|
|
715
|
-
this.removePaymentMethods(), this.paymentMethods = new
|
|
715
|
+
this.removePaymentMethods(), this.paymentMethods = new Te({
|
|
716
716
|
checkoutProfile: e,
|
|
717
717
|
formData: t,
|
|
718
718
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -734,7 +734,7 @@ var q = class extends b {
|
|
|
734
734
|
createEmailField(e, t, n, r) {
|
|
735
735
|
try {
|
|
736
736
|
let i = e.layout.billingFields && Object.values(e.layout.billingFields).some((e) => e?.enabled) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some((e) => e?.enabled);
|
|
737
|
-
this.emailField = new
|
|
737
|
+
this.emailField = new z({
|
|
738
738
|
value: t.email,
|
|
739
739
|
onChange: this.onChange,
|
|
740
740
|
onBlur: this.onBlur,
|
|
@@ -750,7 +750,7 @@ var q = class extends b {
|
|
|
750
750
|
}
|
|
751
751
|
createPhoneNumberField(e, t, n, r) {
|
|
752
752
|
let i = document.createElement("div");
|
|
753
|
-
return this.phonePlaceholder = i, this.formElement.appendChild(i),
|
|
753
|
+
return this.phonePlaceholder = i, this.formElement.appendChild(i), ne().then(({ PhoneNumberField: a }) => this.phonePlaceholder === i && (this.phoneNumberField = new a({
|
|
754
754
|
value: t.phoneNumber ?? "",
|
|
755
755
|
onChange: this.onChange,
|
|
756
756
|
onBlur: this.onBlur,
|
|
@@ -778,13 +778,13 @@ var q = class extends b {
|
|
|
778
778
|
}
|
|
779
779
|
if (!this.isCardSupported()) return;
|
|
780
780
|
if (!this.vgsService) {
|
|
781
|
-
this.cardUnavailableNotice = new
|
|
781
|
+
this.cardUnavailableNotice = new se({
|
|
782
782
|
checkoutProfile: e,
|
|
783
783
|
translationFunc: this.translationFunc
|
|
784
784
|
}), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
|
|
785
785
|
return;
|
|
786
786
|
}
|
|
787
|
-
this.cardSection = new
|
|
787
|
+
this.cardSection = new de({
|
|
788
788
|
checkoutProfile: e,
|
|
789
789
|
translationFunc: this.translationFunc,
|
|
790
790
|
vgsService: this.vgsService
|
|
@@ -801,7 +801,7 @@ var q = class extends b {
|
|
|
801
801
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
802
802
|
return;
|
|
803
803
|
}
|
|
804
|
-
if (this.cardholderSection = new
|
|
804
|
+
if (this.cardholderSection = new Ce({
|
|
805
805
|
value: t.name,
|
|
806
806
|
onChange: this.onChange,
|
|
807
807
|
onBlur: this.onBlur,
|
|
@@ -883,7 +883,7 @@ var q = class extends b {
|
|
|
883
883
|
}
|
|
884
884
|
createSubmitButton(e, t) {
|
|
885
885
|
try {
|
|
886
|
-
this.submitButton = new
|
|
886
|
+
this.submitButton = new Oe({
|
|
887
887
|
disabled: t,
|
|
888
888
|
checkoutProfile: e,
|
|
889
889
|
translationFunc: this.translationFunc
|
|
@@ -932,7 +932,7 @@ var q = class extends b {
|
|
|
932
932
|
return !this.supportedPaymentMethods || !!this.supportedPaymentMethods.card;
|
|
933
933
|
}
|
|
934
934
|
buildCardSkeleton(e) {
|
|
935
|
-
let t = e.styles.borderRadius, n = U
|
|
935
|
+
let t = e.styles.borderRadius, n = b(U, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
|
|
936
936
|
i.style.marginBottom = "4px";
|
|
937
937
|
let a = document.createElement("label");
|
|
938
938
|
a.className = "input-label", a.textContent = this.translationFunc("cardInformation"), a.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.style.fontSize = `${e.styles.fontSize}px`, i.appendChild(a), r.appendChild(i);
|
|
@@ -961,11 +961,11 @@ var q = class extends b {
|
|
|
961
961
|
let i = document.createElement("label");
|
|
962
962
|
i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), n.appendChild(r);
|
|
963
963
|
let a = document.createElement("div");
|
|
964
|
-
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = U
|
|
964
|
+
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = b(U, e.styles.fontSize), a.style.width = "100%", a.style.overflow = "hidden", a.style.background = "#fff", a.appendChild(this.createSkeletonDiv()), n.appendChild(a), n.appendChild(this.createHelperTextSpacer("form-helper-text-anchor")), n;
|
|
965
965
|
}
|
|
966
966
|
async mountVgsFields(e) {
|
|
967
967
|
if (!this.vgsService || !this.cardSection) return !1;
|
|
968
|
-
let t =
|
|
968
|
+
let t = _(e.styles.fontFamily);
|
|
969
969
|
await this.vgsService.whenReady();
|
|
970
970
|
let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
|
|
971
971
|
if (this.cardholderSection && a.cardholderName) {
|
|
@@ -1006,7 +1006,7 @@ var q = class extends b {
|
|
|
1006
1006
|
}
|
|
1007
1007
|
this.billingAddressSection &&= (this.billingAddressSection.getElement().remove(), void 0), this.shippingAddressSection &&= (this.shippingAddressSection.getElement().remove(), void 0), this.submitButton &&= (this.submitButton.getElement().remove(), void 0), this.paymentMethods &&= (this.paymentMethods.getElement().remove(), void 0);
|
|
1008
1008
|
}
|
|
1009
|
-
},
|
|
1009
|
+
}, Ae = class {
|
|
1010
1010
|
formManager;
|
|
1011
1011
|
focusManager;
|
|
1012
1012
|
onFormSubmit;
|
|
@@ -1046,7 +1046,7 @@ var q = class extends b {
|
|
|
1046
1046
|
clearTouchedFields() {
|
|
1047
1047
|
this.localTouchedFields.clear();
|
|
1048
1048
|
}
|
|
1049
|
-
},
|
|
1049
|
+
}, je = class {
|
|
1050
1050
|
formManager;
|
|
1051
1051
|
checkoutProfile;
|
|
1052
1052
|
formElement;
|
|
@@ -1069,7 +1069,7 @@ var q = class extends b {
|
|
|
1069
1069
|
handleProfileStateChange = (e) => {
|
|
1070
1070
|
if (!e.isLoading && e.checkoutProfile) try {
|
|
1071
1071
|
if (e.checkoutProfile.styles?.fontFamily) try {
|
|
1072
|
-
let { cleanup: t } =
|
|
1072
|
+
let { cleanup: t } = r({ fontFamily: e.checkoutProfile.styles.fontFamily });
|
|
1073
1073
|
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
1074
1074
|
} catch (e) {
|
|
1075
1075
|
console.error("Error loading Google Font:", e);
|
|
@@ -1084,7 +1084,7 @@ var q = class extends b {
|
|
|
1084
1084
|
let e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), n = Object.keys(e.errors).filter((e) => e !== "billingAddress" && e !== "shippingAddress").length > 0, r = e.errors.billingAddress, i = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, a = e.errors.shippingAddress, o = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, s = n || i || o, c = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: l, shippingFields: u } = t.checkoutProfile?.layout ?? {}, d = (e, t) => {
|
|
1085
1085
|
if (!e) return !0;
|
|
1086
1086
|
let n = t?.country ?? "";
|
|
1087
|
-
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!
|
|
1087
|
+
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!W(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
|
|
1088
1088
|
}, f = Object.values(this.vgsFieldsState), p = f.length > 0 && f.every((e) => e?.isValid === !0), m = this.isVgsMode && !!e.formData.email && c && p && d(l, e.formData.billingAddress) && d(u, e.formData.shippingAddress);
|
|
1089
1089
|
return s || !m || this.isSubmitting;
|
|
1090
1090
|
}
|
|
@@ -1106,7 +1106,7 @@ var q = class extends b {
|
|
|
1106
1106
|
if (!r?.isTouched || r.isFocused || r.isValid) continue;
|
|
1107
1107
|
let i = r.errors?.[0];
|
|
1108
1108
|
if (!i) continue;
|
|
1109
|
-
let a =
|
|
1109
|
+
let a = ce(n, i.code);
|
|
1110
1110
|
a && (t[n] = e(a));
|
|
1111
1111
|
}
|
|
1112
1112
|
return t;
|
|
@@ -1117,12 +1117,12 @@ var q = class extends b {
|
|
|
1117
1117
|
cleanup() {
|
|
1118
1118
|
this.fontCleanup &&= (this.fontCleanup(), void 0);
|
|
1119
1119
|
}
|
|
1120
|
-
},
|
|
1120
|
+
}, Me = class extends H {
|
|
1121
1121
|
titleElement;
|
|
1122
1122
|
constructor(e = {}) {
|
|
1123
1123
|
super("div", ["blur-bg"]);
|
|
1124
|
-
let t =
|
|
1125
|
-
this.titleElement = new
|
|
1124
|
+
let t = D.createDiv(["loader"]);
|
|
1125
|
+
this.titleElement = new H("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1126
1126
|
}
|
|
1127
1127
|
setText(e) {
|
|
1128
1128
|
return this.titleElement.setText(e), this;
|
|
@@ -1143,11 +1143,11 @@ var q = class extends b {
|
|
|
1143
1143
|
n[i] = e[t];
|
|
1144
1144
|
}
|
|
1145
1145
|
}), n;
|
|
1146
|
-
},
|
|
1146
|
+
}, Ne = class {
|
|
1147
1147
|
formElement;
|
|
1148
1148
|
componentManager;
|
|
1149
1149
|
onLoadingStateChange;
|
|
1150
|
-
validationSchema =
|
|
1150
|
+
validationSchema = c();
|
|
1151
1151
|
spinner;
|
|
1152
1152
|
formSkeleton;
|
|
1153
1153
|
alert;
|
|
@@ -1161,7 +1161,7 @@ var q = class extends b {
|
|
|
1161
1161
|
this.onLoadingStateChange ? this.onLoadingStateChange(e) : e ? (this.hideSkeleton(), this.formSkeleton = new J(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
1162
1162
|
}
|
|
1163
1163
|
showSpinner(e) {
|
|
1164
|
-
this.hideSpinner(), this.spinner = new
|
|
1164
|
+
this.hideSpinner(), this.spinner = new Me({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
1165
1165
|
}
|
|
1166
1166
|
hideSpinner() {
|
|
1167
1167
|
this.spinner &&= (this.spinner.getElement().remove(), void 0);
|
|
@@ -1170,7 +1170,7 @@ var q = class extends b {
|
|
|
1170
1170
|
this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
|
|
1171
1171
|
}
|
|
1172
1172
|
setErrorMessage(e) {
|
|
1173
|
-
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new
|
|
1173
|
+
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new fe({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
|
|
1174
1174
|
}
|
|
1175
1175
|
clearErrorMessage() {
|
|
1176
1176
|
this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
@@ -1178,7 +1178,7 @@ var q = class extends b {
|
|
|
1178
1178
|
cleanup() {
|
|
1179
1179
|
this.spinner &&= (this.spinner.getElement().remove(), void 0), this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0), this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
1180
1180
|
}
|
|
1181
|
-
}, Z = "phone_number",
|
|
1181
|
+
}, Z = "phone_number", Pe = "form";
|
|
1182
1182
|
globalThis.navigator.userAgent;
|
|
1183
1183
|
var Q = (e) => ({
|
|
1184
1184
|
street: "",
|
|
@@ -1189,12 +1189,12 @@ var Q = (e) => ({
|
|
|
1189
1189
|
zipCode: "",
|
|
1190
1190
|
country: "",
|
|
1191
1191
|
...e
|
|
1192
|
-
}),
|
|
1192
|
+
}), Fe = class extends H {
|
|
1193
1193
|
options;
|
|
1194
|
-
formManager =
|
|
1194
|
+
formManager = a();
|
|
1195
1195
|
checkoutProfile;
|
|
1196
|
-
translation =
|
|
1197
|
-
focusManager = new
|
|
1196
|
+
translation = te();
|
|
1197
|
+
focusManager = new xe();
|
|
1198
1198
|
componentManager;
|
|
1199
1199
|
eventHandler;
|
|
1200
1200
|
stateCoordinator;
|
|
@@ -1208,7 +1208,7 @@ var Q = (e) => ({
|
|
|
1208
1208
|
constructor(e) {
|
|
1209
1209
|
super("form", ["form-container"]), this.options = e;
|
|
1210
1210
|
let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
|
|
1211
|
-
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new
|
|
1211
|
+
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new I()), this.checkoutProfile = s({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new ke({
|
|
1212
1212
|
formElement: this.element,
|
|
1213
1213
|
focusManager: this.focusManager,
|
|
1214
1214
|
translationFunc: this.translation.t,
|
|
@@ -1218,7 +1218,7 @@ var Q = (e) => ({
|
|
|
1218
1218
|
onBlur: (e) => this.eventHandler.handleBlur(e),
|
|
1219
1219
|
onPaypalSubmit: async () => this.handlePaypalSubmit(),
|
|
1220
1220
|
onApplePaySubmit: async (e) => this.handleApplePaySubmit(e),
|
|
1221
|
-
onApplePayStartFailed: (e) => this.options.onSubmitOutcome?.(
|
|
1221
|
+
onApplePayStartFailed: (e) => this.options.onSubmitOutcome?.(ie(e)),
|
|
1222
1222
|
onApplePayPaymentDataFailed: (e) => this.options.onSubmitOutcome?.(e),
|
|
1223
1223
|
supportedPaymentMethods: e.supportedPaymentMethods,
|
|
1224
1224
|
paymentId: e.paymentId,
|
|
@@ -1226,22 +1226,22 @@ var Q = (e) => ({
|
|
|
1226
1226
|
checkoutDetails: e.checkoutDetails,
|
|
1227
1227
|
environment: e.environment,
|
|
1228
1228
|
vgsService: this.vgsService
|
|
1229
|
-
}), this.uiManager = new
|
|
1229
|
+
}), this.uiManager = new Ne({
|
|
1230
1230
|
formElement: this.element,
|
|
1231
1231
|
componentManager: this.componentManager,
|
|
1232
1232
|
onLoadingStateChange: e.onLoadingStateChange
|
|
1233
|
-
}), this.stateCoordinator = new
|
|
1233
|
+
}), this.stateCoordinator = new je({
|
|
1234
1234
|
formManager: this.formManager,
|
|
1235
1235
|
checkoutProfile: this.checkoutProfile,
|
|
1236
1236
|
componentManager: this.componentManager,
|
|
1237
1237
|
formElement: this.element,
|
|
1238
1238
|
onUIUpdate: () => this.updateFormUI(),
|
|
1239
1239
|
onProfileLoaded: () => this.renderFormComponents(),
|
|
1240
|
-
onRenderFailed: (e) => this.reportRenderFailure(
|
|
1240
|
+
onRenderFailed: (e) => this.reportRenderFailure(Pe, e),
|
|
1241
1241
|
onError: (e) => this.uiManager.setErrorMessage(e),
|
|
1242
1242
|
onLoadingChange: (e) => this.uiManager.setLoadingState(e),
|
|
1243
1243
|
getInitialFormData: () => this._getFormStateData().formData
|
|
1244
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
1244
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Ae({
|
|
1245
1245
|
formManager: this.formManager,
|
|
1246
1246
|
focusManager: this.focusManager,
|
|
1247
1247
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -1275,13 +1275,13 @@ var Q = (e) => ({
|
|
|
1275
1275
|
};
|
|
1276
1276
|
}
|
|
1277
1277
|
initializeForm() {
|
|
1278
|
-
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) this.failCardCaptureClosed(
|
|
1278
|
+
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) this.failCardCaptureClosed(w.NO_TOKENIZATION_SESSION);
|
|
1279
1279
|
else if (this.vgsService) {
|
|
1280
1280
|
let e = this.vgsService;
|
|
1281
1281
|
e.init(this.options.environment).then((t) => {
|
|
1282
1282
|
this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
|
|
1283
1283
|
}).catch((t) => {
|
|
1284
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1284
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(w.INIT_FAILED));
|
|
1285
1285
|
});
|
|
1286
1286
|
}
|
|
1287
1287
|
}
|
|
@@ -1295,7 +1295,7 @@ var Q = (e) => ({
|
|
|
1295
1295
|
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), this.reportLoadOutcome({
|
|
1296
1296
|
status: "failed",
|
|
1297
1297
|
reason: e
|
|
1298
|
-
}), t ||
|
|
1298
|
+
}), t || A(F.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
|
|
1299
1299
|
}
|
|
1300
1300
|
dropVgsService() {
|
|
1301
1301
|
let e = this.vgsService;
|
|
@@ -1314,7 +1314,7 @@ var Q = (e) => ({
|
|
|
1314
1314
|
phoneNumber: "",
|
|
1315
1315
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1316
1316
|
}), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress: Q() }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({ shippingAddress: Q() });
|
|
1317
|
-
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i =
|
|
1317
|
+
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = Se(e.checkoutProfile.layout);
|
|
1318
1318
|
try {
|
|
1319
1319
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
1320
1320
|
} catch (e) {
|
|
@@ -1358,7 +1358,7 @@ var Q = (e) => ({
|
|
|
1358
1358
|
this.componentManager.mountVgsFields(e.checkoutProfile).then(async (e) => {
|
|
1359
1359
|
e && this.vgsMountGeneration === n && this.vgsService === t && (!a || await a) && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
|
|
1360
1360
|
}).catch((e) => {
|
|
1361
|
-
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(
|
|
1361
|
+
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(w.FIELDS_NOT_READY));
|
|
1362
1362
|
});
|
|
1363
1363
|
}
|
|
1364
1364
|
try {
|
|
@@ -1373,10 +1373,10 @@ var Q = (e) => ({
|
|
|
1373
1373
|
reportRenderFailure(e, t) {
|
|
1374
1374
|
this.reportLoadOutcome({
|
|
1375
1375
|
status: "failed",
|
|
1376
|
-
reason:
|
|
1376
|
+
reason: M.FORM_RENDER_FAILED,
|
|
1377
1377
|
attributes: {
|
|
1378
1378
|
form_part: e,
|
|
1379
|
-
...t !== void 0 && { error_class:
|
|
1379
|
+
...t !== void 0 && { error_class: _e(t) }
|
|
1380
1380
|
}
|
|
1381
1381
|
});
|
|
1382
1382
|
}
|
|
@@ -1409,18 +1409,18 @@ var Q = (e) => ({
|
|
|
1409
1409
|
async handleSubmit() {
|
|
1410
1410
|
if (!this.stateCoordinator.isFormDisabled()) try {
|
|
1411
1411
|
if (this.stateCoordinator.setSubmitting(!0), this.updateFormUI(), this.options.onLoadingStateChange?.(!0), this.uiManager.showSpinner(this.translation.t("loading")), this.inferCardholderName(), this.inferAddresses(), !this.vgsService || !this.vgsJwt) {
|
|
1412
|
-
this.options.onSubmitOutcome?.(
|
|
1412
|
+
this.options.onSubmitOutcome?.(h(e(/* @__PURE__ */ Error("Card capture unavailable"), be.CAPTURE_UNAVAILABLE), "card")), this.handleSubmitError(this.translation.t("cardUnavailable"));
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
1415
|
try {
|
|
1416
1416
|
this.vgsCardResult = await this.vgsService.createCard(this.vgsJwt);
|
|
1417
1417
|
} catch (e) {
|
|
1418
|
-
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(
|
|
1418
|
+
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(h(e, "card")), this.handleSubmitError("Card processing failed. Please check your card details and try again.");
|
|
1419
1419
|
return;
|
|
1420
1420
|
}
|
|
1421
|
-
let
|
|
1421
|
+
let t = this.formManager.getFormState().formData;
|
|
1422
1422
|
await this.options.onSubmit({ formData: this.vgsCardResult ? {
|
|
1423
|
-
...
|
|
1423
|
+
...t,
|
|
1424
1424
|
vgsCardData: {
|
|
1425
1425
|
cardId: this.vgsCardResult.cardId,
|
|
1426
1426
|
expMonth: this.vgsCardResult.expMonth,
|
|
@@ -1428,7 +1428,7 @@ var Q = (e) => ({
|
|
|
1428
1428
|
name: this.vgsCardResult.name,
|
|
1429
1429
|
...this.vgsCardResult.updatedValues && { updatedValues: this.vgsCardResult.updatedValues }
|
|
1430
1430
|
}
|
|
1431
|
-
} :
|
|
1431
|
+
} : t }), this.uiManager.hideSpinner(), this.options.onLoadingStateChange?.(!1), this.stateCoordinator.setSubmitting(!1), this.updateFormUI();
|
|
1432
1432
|
} catch {
|
|
1433
1433
|
this.handleSubmitError("Payment processing failed. Please try again.");
|
|
1434
1434
|
}
|
|
@@ -1472,21 +1472,21 @@ var Q = (e) => ({
|
|
|
1472
1472
|
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = r, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
|
|
1473
1473
|
let a = this.componentManager.isCardSupported();
|
|
1474
1474
|
if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
|
|
1475
|
-
let e = new
|
|
1475
|
+
let e = new I();
|
|
1476
1476
|
this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
|
|
1477
1477
|
this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
|
|
1478
1478
|
}).catch((t) => {
|
|
1479
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1479
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(w.INIT_FAILED));
|
|
1480
1480
|
});
|
|
1481
1481
|
}
|
|
1482
|
-
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(
|
|
1482
|
+
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(w.NO_TOKENIZATION_SESSION);
|
|
1483
1483
|
let o = this.checkoutProfile.getState();
|
|
1484
1484
|
if (o.checkoutProfile) {
|
|
1485
1485
|
let { formData: e } = this._getFormStateData();
|
|
1486
1486
|
this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
|
|
1487
1487
|
}
|
|
1488
1488
|
}
|
|
1489
|
-
},
|
|
1489
|
+
}, Ie = class {
|
|
1490
1490
|
container = null;
|
|
1491
1491
|
options;
|
|
1492
1492
|
onSubmit;
|
|
@@ -1504,7 +1504,7 @@ var Q = (e) => ({
|
|
|
1504
1504
|
}) : e.errorMsg && !this.options.disableErrorMessages ? this.form.setErrorMessage(e.errorMsg) : this.renderForm(e.errorMsg));
|
|
1505
1505
|
}
|
|
1506
1506
|
renderForm(e) {
|
|
1507
|
-
this.container && (this.form &&= (this.form.destroy(), null), this.form = new
|
|
1507
|
+
this.container && (this.form &&= (this.form.destroy(), null), this.form = new Fe({
|
|
1508
1508
|
apiKey: this.options.apiKey,
|
|
1509
1509
|
onSubmit: this.onSubmit,
|
|
1510
1510
|
locale: this.options.locale,
|
|
@@ -1536,7 +1536,7 @@ var Q = (e) => ({
|
|
|
1536
1536
|
async associatePayment(e, t, n, r, i) {
|
|
1537
1537
|
this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = r, this.options.vgsJwt = i, this.options.supportedPaymentMethods = n, this.form && this.form.associatePayment(e, t, n, r, i);
|
|
1538
1538
|
}
|
|
1539
|
-
},
|
|
1539
|
+
}, Le = class {
|
|
1540
1540
|
state;
|
|
1541
1541
|
listeners = /* @__PURE__ */ new Set();
|
|
1542
1542
|
constructor(e) {
|
|
@@ -1560,7 +1560,7 @@ var Q = (e) => ({
|
|
|
1560
1560
|
let e = this.getState();
|
|
1561
1561
|
this.listeners.forEach((t) => t(e));
|
|
1562
1562
|
}
|
|
1563
|
-
},
|
|
1563
|
+
}, Re = "en", $ = class {
|
|
1564
1564
|
config;
|
|
1565
1565
|
_callbacks;
|
|
1566
1566
|
paymentState;
|
|
@@ -1568,17 +1568,17 @@ var Q = (e) => ({
|
|
|
1568
1568
|
formManager;
|
|
1569
1569
|
stateManager;
|
|
1570
1570
|
sessionId;
|
|
1571
|
-
readiness = new
|
|
1571
|
+
readiness = new o();
|
|
1572
1572
|
associationSequence = 0;
|
|
1573
1573
|
constructor(e) {
|
|
1574
|
-
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
1574
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), u(), pe({
|
|
1575
1575
|
environment: this.config.environment,
|
|
1576
1576
|
sessionId: this.sessionId,
|
|
1577
1577
|
integration: "dropin"
|
|
1578
|
-
}),
|
|
1578
|
+
}), A(F.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new ye(this.config.apiKey, this.config.environment), this.stateManager = new Le({
|
|
1579
1579
|
mounted: !1,
|
|
1580
1580
|
form: null
|
|
1581
|
-
}), this.formManager = new
|
|
1581
|
+
}), this.formManager = new Ie({
|
|
1582
1582
|
locale: this.config.locale,
|
|
1583
1583
|
apiKey: this.config.apiKey,
|
|
1584
1584
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
@@ -1599,7 +1599,7 @@ var Q = (e) => ({
|
|
|
1599
1599
|
apiKey: e.apiKey,
|
|
1600
1600
|
returnUrl: e.returnUrl,
|
|
1601
1601
|
environment: e.environment,
|
|
1602
|
-
locale: e.locale ||
|
|
1602
|
+
locale: e.locale || Re,
|
|
1603
1603
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1604
1604
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1605
1605
|
appearance: e.appearance,
|
|
@@ -1620,15 +1620,15 @@ var Q = (e) => ({
|
|
|
1620
1620
|
return n = !0, t = document.createElement("div"), r.appendChild(t), this.stateManager.updateState({
|
|
1621
1621
|
form: t,
|
|
1622
1622
|
mounted: !0
|
|
1623
|
-
}), this.formManager.mount(t), this.readiness.markMounted(),
|
|
1623
|
+
}), this.formManager.mount(t), this.readiness.markMounted(), A(F.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1624
1624
|
} catch (r) {
|
|
1625
1625
|
throw t?.remove(), this.stateManager.updateState({
|
|
1626
1626
|
form: null,
|
|
1627
1627
|
mounted: !1
|
|
1628
|
-
}),
|
|
1628
|
+
}), A(F.CHECKOUT_MOUNT_FAILED, {
|
|
1629
1629
|
container_id: e,
|
|
1630
1630
|
error_message: r instanceof Error ? r.message : "Unknown error"
|
|
1631
|
-
}),
|
|
1631
|
+
}), R(r instanceof Error ? r : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n ? this.readiness.fail({ reason: M.MOUNT_FAILED }) : this.readiness.exclude({ reason: M.CONTAINER_NOT_FOUND }), r;
|
|
1632
1632
|
}
|
|
1633
1633
|
}
|
|
1634
1634
|
unmount() {
|
|
@@ -1639,13 +1639,13 @@ var Q = (e) => ({
|
|
|
1639
1639
|
e && e.remove(), this.stateManager.updateState({
|
|
1640
1640
|
form: null,
|
|
1641
1641
|
mounted: !1
|
|
1642
|
-
}),
|
|
1642
|
+
}), A(F.CHECKOUT_UNMOUNTED);
|
|
1643
1643
|
});
|
|
1644
1644
|
}
|
|
1645
1645
|
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1646
1646
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1647
1647
|
let n = this.getPaymentMethod(e, t);
|
|
1648
|
-
|
|
1648
|
+
A(F.PAYMENT_SUBMIT_STARTED, {
|
|
1649
1649
|
payment_id: this.paymentState.paymentId,
|
|
1650
1650
|
payment_method: n
|
|
1651
1651
|
});
|
|
@@ -1659,46 +1659,46 @@ var Q = (e) => ({
|
|
|
1659
1659
|
applePayData: t
|
|
1660
1660
|
});
|
|
1661
1661
|
this.readiness.reportSubmit({
|
|
1662
|
-
outcome:
|
|
1662
|
+
outcome: ve.SUCCEEDED,
|
|
1663
1663
|
paymentMethod: n
|
|
1664
1664
|
});
|
|
1665
1665
|
let a = performance.now() - r;
|
|
1666
|
-
return
|
|
1666
|
+
return N(O.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
|
|
1667
1667
|
payment_id: this.paymentState.paymentId,
|
|
1668
1668
|
payment_method: n,
|
|
1669
1669
|
status: "success"
|
|
1670
|
-
}),
|
|
1670
|
+
}), A(F.PAYMENT_SUBMIT_SUCCESS, {
|
|
1671
1671
|
payment_id: this.paymentState.paymentId,
|
|
1672
1672
|
payment_method: n
|
|
1673
1673
|
}), this.handlePaymentResponse(i);
|
|
1674
1674
|
} catch (e) {
|
|
1675
1675
|
let t = performance.now() - r;
|
|
1676
|
-
return
|
|
1676
|
+
return N(O.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1677
1677
|
payment_id: this.paymentState.paymentId,
|
|
1678
1678
|
payment_method: n,
|
|
1679
1679
|
status: "failed"
|
|
1680
|
-
}),
|
|
1680
|
+
}), A(F.PAYMENT_SUBMIT_FAILED, {
|
|
1681
1681
|
payment_id: this.paymentState.paymentId,
|
|
1682
1682
|
payment_method: n,
|
|
1683
1683
|
error_message: e.details?.message ?? "Unknown error",
|
|
1684
|
-
...
|
|
1685
|
-
}), this.readiness.reportSubmit(
|
|
1684
|
+
...x(e)
|
|
1685
|
+
}), this.readiness.reportSubmit(v(e, n)), this.handleAuthorizationError(e), !1;
|
|
1686
1686
|
}
|
|
1687
1687
|
}
|
|
1688
1688
|
handlePaymentResponse(e) {
|
|
1689
|
-
let t = !1;
|
|
1690
|
-
if (
|
|
1689
|
+
let t = !1, n = ge(e);
|
|
1690
|
+
if (n === "authorized" && (A(F.PAYMENT_AUTHORIZED, {
|
|
1691
1691
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1692
|
-
status:
|
|
1693
|
-
}),
|
|
1692
|
+
status: n
|
|
1693
|
+
}), V(() => this._callbacks.onPaymentSucceeded?.(n)), t = !0), n === "failed" && (A(F.PAYMENT_FAILED, {
|
|
1694
1694
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1695
|
-
status:
|
|
1696
|
-
}),
|
|
1695
|
+
status: n
|
|
1696
|
+
}), V(() => this._callbacks.onPaymentFailed?.(n))), e.status === "requires_action") {
|
|
1697
1697
|
let { redirectUrl: n } = e.action;
|
|
1698
|
-
|
|
1698
|
+
A(F.PAYMENT_ACTION_REQUIRED, {
|
|
1699
1699
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1700
1700
|
status: e.status
|
|
1701
|
-
}), this.config.manualActionHandling ?
|
|
1701
|
+
}), this.config.manualActionHandling ? V(() => this._callbacks.onActionRequired?.(n)) : globalThis.location.href = n, t = !0;
|
|
1702
1702
|
}
|
|
1703
1703
|
return t;
|
|
1704
1704
|
}
|
|
@@ -1731,35 +1731,35 @@ var Q = (e) => ({
|
|
|
1731
1731
|
async associatePayment(e, t) {
|
|
1732
1732
|
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
1733
1733
|
let n = ++this.associationSequence;
|
|
1734
|
-
this.readiness.start(e), this.paymentState.paymentId = e, this.paymentState.checkoutKey = t,
|
|
1735
|
-
let r =
|
|
1734
|
+
this.readiness.start(e), this.paymentState.paymentId = e, this.paymentState.checkoutKey = t, l(this.config.environment);
|
|
1735
|
+
let r = y.CHECKOUT_DETAILS;
|
|
1736
1736
|
try {
|
|
1737
|
-
let i = await
|
|
1737
|
+
let i = await he({
|
|
1738
1738
|
id: e,
|
|
1739
1739
|
checkoutKey: t,
|
|
1740
1740
|
environment: this.config.environment
|
|
1741
1741
|
});
|
|
1742
|
-
if (!i || !i.supportedPaymentMethods || !Array.isArray(i.supportedPaymentMethods)) throw
|
|
1743
|
-
if (!i.supportedPaymentMethods.every((e) => typeof e == "string")) throw
|
|
1742
|
+
if (!i || !i.supportedPaymentMethods || !Array.isArray(i.supportedPaymentMethods)) throw S(/* @__PURE__ */ Error("Invalid response: supportedPaymentMethods must be an array"), E.INVALID_RESPONSE, j(i));
|
|
1743
|
+
if (!i.supportedPaymentMethods.every((e) => typeof e == "string")) throw S(/* @__PURE__ */ Error("Invalid response: all supportedPaymentMethods must be strings"), E.INVALID_RESPONSE, j(i));
|
|
1744
1744
|
if (n !== this.associationSequence) return;
|
|
1745
|
-
r =
|
|
1745
|
+
r = y.FORM_SETUP, this.readiness.markAssociated(), this.paymentState.checkoutDetails = {
|
|
1746
1746
|
amount: i.amount,
|
|
1747
1747
|
currency: i.currency,
|
|
1748
1748
|
countryCode: i.countryCode
|
|
1749
1749
|
};
|
|
1750
1750
|
let a = i.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
|
|
1751
|
-
await this.formManager.associatePayment(e, t, a, this.paymentState.checkoutDetails, i.vgsJwt),
|
|
1751
|
+
await this.formManager.associatePayment(e, t, a, this.paymentState.checkoutDetails, i.vgsJwt), A(F.PAYMENT_ASSOCIATED, {
|
|
1752
1752
|
payment_id: e,
|
|
1753
1753
|
currency: i.currency,
|
|
1754
1754
|
country_code: i.countryCode
|
|
1755
1755
|
});
|
|
1756
1756
|
} catch (t) {
|
|
1757
|
-
if (
|
|
1757
|
+
if (A(F.PAYMENT_ASSOCIATION_FAILED, {
|
|
1758
1758
|
payment_id: e,
|
|
1759
1759
|
error_message: t instanceof Error ? t.message : "Unknown error",
|
|
1760
1760
|
stage: r,
|
|
1761
|
-
...
|
|
1762
|
-
}),
|
|
1761
|
+
...x(t)
|
|
1762
|
+
}), R(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), n === this.associationSequence) {
|
|
1763
1763
|
let { ours: e, ...n } = re(t, r);
|
|
1764
1764
|
e ? this.readiness.fail(n) : this.readiness.exclude(n);
|
|
1765
1765
|
}
|
|
@@ -1774,4 +1774,4 @@ var Q = (e) => ({
|
|
|
1774
1774
|
//#region libs/checkout/src/index.ts
|
|
1775
1775
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1776
1776
|
//#endregion
|
|
1777
|
-
export { $ as OdusCheckout,
|
|
1777
|
+
export { $ as OdusCheckout, ee as deLocale, p as enLocale, f as esLocale, le as frLocale, t as itLocale, ue as plLocale, m as ptLocale, R as pushError, A as pushEvent, oe as pushLog, N as pushMeasurement, i as trLocale };
|