@odus/checkout 1.11.1 → 1.11.3
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 +121 -120
- package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
- package/dist/core/vgs/VGSCollectService.d.ts +20 -0
- package/dist/core/vgs/VGSCollectService.d.ts.map +1 -1
- package/dist/core/vgs/index.d.ts +1 -1
- package/dist/core/vgs/index.d.ts.map +1 -1
- package/dist/elements/OdusElements.d.ts.map +1 -1
- package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
- package/dist/elements.es.js +170 -168
- package/dist/phone.js +1 -1
- package/dist/services/checkout/Checkout.service.d.ts.map +1 -1
- package/dist/shared.js +3981 -3967
- package/dist/utils/dom/appendGoogleFont.d.ts.map +1 -1
- package/dist/utils/dom/fetchGoogleFontFace.d.ts.map +1 -1
- package/dist/utils/dom/googleFontUrl.d.ts +26 -0
- package/dist/utils/dom/googleFontUrl.d.ts.map +1 -0
- package/dist/utils/dom/index.d.ts +1 -0
- package/dist/utils/dom/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as e, A as t,
|
|
1
|
+
import { $ as e, A as t, C as n, D as r, E 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 h, Q as g, R as _, S as v, V as ee, W as y, X as b, Y as x, Z as S, a as te, b as C, c as ne, d as w, et as T, f as E, g as D, h as O, j as k, k as re, l as A, m as j, n as ie, o as ae, q as M, r as oe, s as N, t as P, tt as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./shared.js";
|
|
2
2
|
import { t as H } from "./shared2.js";
|
|
3
3
|
//#region libs/checkout/src/utils/focus/FocusManager.ts
|
|
4
4
|
var U = class {
|
|
@@ -115,7 +115,7 @@ var K = class extends C {
|
|
|
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 O({
|
|
119
119
|
text: "",
|
|
120
120
|
visible: !1
|
|
121
121
|
}), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
|
|
@@ -189,7 +189,7 @@ var K = class extends C {
|
|
|
189
189
|
}
|
|
190
190
|
if (e.kind === "state") {
|
|
191
191
|
let e = this.createRow(["full"]);
|
|
192
|
-
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"),
|
|
192
|
+
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"), _(n.country)) {
|
|
193
193
|
let a = this.createStateSelect(n.state, r.state, i.state, this.stateStyles, n.country, t.state?.label);
|
|
194
194
|
this.inputs.set("state", a), e.appendChild(a.getElement());
|
|
195
195
|
} else {
|
|
@@ -205,7 +205,7 @@ var K = class extends C {
|
|
|
205
205
|
return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
|
|
206
206
|
}
|
|
207
207
|
createInput(e, t, n, r, i, a, o, s) {
|
|
208
|
-
let c = `${this.type}Address.${e}`, l = new
|
|
208
|
+
let c = `${this.type}Address.${e}`, l = new E({
|
|
209
209
|
name: c,
|
|
210
210
|
error: !1,
|
|
211
211
|
errorMsg: void 0,
|
|
@@ -247,7 +247,7 @@ var K = class extends C {
|
|
|
247
247
|
}), l;
|
|
248
248
|
}
|
|
249
249
|
createCountrySelect(e, t, n, r, i, a) {
|
|
250
|
-
let o = `${this.type}Address.country`, s =
|
|
250
|
+
let o = `${this.type}Address.country`, s = D(i, this.locale), c = new w({
|
|
251
251
|
name: o,
|
|
252
252
|
error: !1,
|
|
253
253
|
errorMsg: void 0,
|
|
@@ -283,33 +283,33 @@ var K = class extends C {
|
|
|
283
283
|
handleCountryChange(e) {
|
|
284
284
|
let t = this.currentCountry;
|
|
285
285
|
if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
|
|
286
|
-
let
|
|
287
|
-
if (
|
|
286
|
+
let n = this.stateFieldConfig.hiddenForCountries?.includes(t), r = this.stateFieldConfig.hiddenForCountries?.includes(e);
|
|
287
|
+
if (r && !n) {
|
|
288
288
|
this.stateRow.style.display = "none", this.applyFieldError("state", !1), this.clearStateValue();
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
|
-
if (!
|
|
292
|
-
let
|
|
293
|
-
if (
|
|
291
|
+
if (!r && n && (this.stateRow.style.display = ""), r) return;
|
|
292
|
+
let i = this.inputs.get("state") instanceof w, a = _(e);
|
|
293
|
+
if (i && a) {
|
|
294
294
|
let t = this.inputs.get("state");
|
|
295
|
-
if (t instanceof
|
|
296
|
-
let
|
|
297
|
-
t.setOptions(
|
|
295
|
+
if (t instanceof w) {
|
|
296
|
+
let n = V(e), r = c(n), i = this.translationFunc(d(n));
|
|
297
|
+
t.setOptions(r, i);
|
|
298
298
|
}
|
|
299
299
|
this.clearStateValue();
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
|
-
if (
|
|
302
|
+
if (i !== a) {
|
|
303
303
|
this.rebuildStateField(e), this.clearStateValue();
|
|
304
304
|
return;
|
|
305
305
|
}
|
|
306
|
-
!
|
|
306
|
+
!i && !a && t !== e && this.clearStateValue();
|
|
307
307
|
}
|
|
308
308
|
rebuildStateField(e) {
|
|
309
309
|
if (!this.stateRow || !this.stateStyles) return;
|
|
310
310
|
this.applyFieldError("state", !1);
|
|
311
311
|
let t = this.inputs.get("state");
|
|
312
|
-
if (t && (t.getElement().remove(), this.inputs.delete("state")),
|
|
312
|
+
if (t && (t.getElement().remove(), this.inputs.delete("state")), _(e)) {
|
|
313
313
|
let t = this.createStateSelect("", void 0, void 0, this.stateStyles, e, this.stateFieldConfig?.label);
|
|
314
314
|
this.inputs.set("state", t), this.stateRow.appendChild(t.getElement());
|
|
315
315
|
} else {
|
|
@@ -330,15 +330,15 @@ var K = class extends C {
|
|
|
330
330
|
detail: { programmatic: !0 }
|
|
331
331
|
}));
|
|
332
332
|
}
|
|
333
|
-
createStateSelect(e, t, r, i, a
|
|
334
|
-
let
|
|
335
|
-
name:
|
|
333
|
+
createStateSelect(e, t, n, r, i, a) {
|
|
334
|
+
let o = `${this.type}Address.state`, s = V(i), l = c(s), u = this.translationFunc(d(s)), f = new w({
|
|
335
|
+
name: o,
|
|
336
336
|
error: !1,
|
|
337
337
|
errorMsg: void 0,
|
|
338
|
-
styles:
|
|
338
|
+
styles: r,
|
|
339
339
|
placeholder: u,
|
|
340
340
|
renderMessage: !this.grouped,
|
|
341
|
-
...!this.grouped && { label:
|
|
341
|
+
...!this.grouped && { label: a ?? u },
|
|
342
342
|
value: e,
|
|
343
343
|
options: l,
|
|
344
344
|
autocomplete: "address-level1",
|
|
@@ -346,7 +346,7 @@ var K = class extends C {
|
|
|
346
346
|
this.applyFieldError("state", !1), this.onChange(H({
|
|
347
347
|
type: "change",
|
|
348
348
|
target: {
|
|
349
|
-
name:
|
|
349
|
+
name: o,
|
|
350
350
|
value: e.target.value
|
|
351
351
|
}
|
|
352
352
|
}));
|
|
@@ -356,7 +356,7 @@ var K = class extends C {
|
|
|
356
356
|
this.onBlur(H({
|
|
357
357
|
type: "blur",
|
|
358
358
|
target: {
|
|
359
|
-
name:
|
|
359
|
+
name: o,
|
|
360
360
|
value: e.target.value
|
|
361
361
|
}
|
|
362
362
|
}));
|
|
@@ -381,7 +381,7 @@ var K = class extends C {
|
|
|
381
381
|
this.stateFieldConfig = t.state;
|
|
382
382
|
let e = this.createRow(["full"]);
|
|
383
383
|
this.stateRow = e, this.stateStyles = o, this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none");
|
|
384
|
-
let a =
|
|
384
|
+
let a = _(n.country), s = t.state?.label ?? this.translationFunc("address.state");
|
|
385
385
|
if (a) {
|
|
386
386
|
let t = this.createStateSelect(n.state, r.state, i.state, o, n.country, s);
|
|
387
387
|
this.inputs.set("state", t), e.appendChild(t.getElement());
|
|
@@ -469,10 +469,10 @@ var K = class extends C {
|
|
|
469
469
|
let i = document.createElement("label");
|
|
470
470
|
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";
|
|
471
471
|
let a = document.createElement("div");
|
|
472
|
-
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
|
|
472
|
+
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 O({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
|
|
473
473
|
}
|
|
474
474
|
buildNativeLayout(e, t, n, r, i, a, o) {
|
|
475
|
-
this.input = new
|
|
475
|
+
this.input = new E({
|
|
476
476
|
name: "name",
|
|
477
477
|
label: a("cardholderNameLabel"),
|
|
478
478
|
error: !1,
|
|
@@ -558,7 +558,7 @@ var K = class extends C {
|
|
|
558
558
|
let e = j.createDiv(["payment-separator_container"]), t = j.createDiv(["payment-separator__line"]), n = j.createDiv(["skeleton", "skeleton-separator-text"]), r = j.createDiv(["payment-separator__line"]);
|
|
559
559
|
return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
|
|
560
560
|
}
|
|
561
|
-
},
|
|
561
|
+
}, se = class extends C {
|
|
562
562
|
constructor(e) {
|
|
563
563
|
let { translationFunc: t, checkoutProfile: n } = e;
|
|
564
564
|
super("div", ["payment-separator"]);
|
|
@@ -569,7 +569,7 @@ var K = class extends C {
|
|
|
569
569
|
let o = document.createElement("span");
|
|
570
570
|
o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
|
|
571
571
|
}
|
|
572
|
-
},
|
|
572
|
+
}, ce = class extends C {
|
|
573
573
|
paymentMethods;
|
|
574
574
|
paymentSeparator;
|
|
575
575
|
skeleton;
|
|
@@ -604,7 +604,7 @@ var K = class extends C {
|
|
|
604
604
|
break;
|
|
605
605
|
case "applePay":
|
|
606
606
|
if (i && s && c) {
|
|
607
|
-
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new
|
|
607
|
+
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new oe({
|
|
608
608
|
checkoutProfile: t,
|
|
609
609
|
formData: n,
|
|
610
610
|
onSubmit: i,
|
|
@@ -621,7 +621,7 @@ var K = class extends C {
|
|
|
621
621
|
break;
|
|
622
622
|
default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
|
|
623
623
|
}
|
|
624
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
624
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new se({
|
|
625
625
|
translationFunc: o,
|
|
626
626
|
checkoutProfile: t
|
|
627
627
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
@@ -638,7 +638,7 @@ var K = class extends C {
|
|
|
638
638
|
hasVisiblePaymentMethods() {
|
|
639
639
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
640
640
|
}
|
|
641
|
-
},
|
|
641
|
+
}, le = 17, ue = class extends C {
|
|
642
642
|
styles;
|
|
643
643
|
isHovered = !1;
|
|
644
644
|
constructor(e) {
|
|
@@ -646,7 +646,7 @@ var K = class extends C {
|
|
|
646
646
|
}
|
|
647
647
|
applyStyles() {
|
|
648
648
|
let e = this.getElement();
|
|
649
|
-
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 ===
|
|
649
|
+
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 === le ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
650
650
|
}
|
|
651
651
|
handleMouseEnter() {
|
|
652
652
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -657,11 +657,11 @@ var K = class extends C {
|
|
|
657
657
|
setDisabled(e) {
|
|
658
658
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
659
659
|
}
|
|
660
|
-
},
|
|
660
|
+
}, de = class {
|
|
661
661
|
button;
|
|
662
662
|
constructor(e) {
|
|
663
663
|
let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
|
|
664
|
-
this.button = new
|
|
664
|
+
this.button = new ue({
|
|
665
665
|
text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
|
|
666
666
|
styles: {
|
|
667
667
|
backgroundColor: n.styles.buttonColor,
|
|
@@ -685,7 +685,7 @@ var K = class extends C {
|
|
|
685
685
|
appendTo(e) {
|
|
686
686
|
return this.button.appendTo(e), this;
|
|
687
687
|
}
|
|
688
|
-
},
|
|
688
|
+
}, fe = class {
|
|
689
689
|
formElement;
|
|
690
690
|
focusManager;
|
|
691
691
|
translationFunc;
|
|
@@ -723,7 +723,7 @@ var K = class extends C {
|
|
|
723
723
|
createPaymentMethods(e, t, n = !1) {
|
|
724
724
|
try {
|
|
725
725
|
if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
|
|
726
|
-
this.removePaymentMethods(), this.paymentMethods = new
|
|
726
|
+
this.removePaymentMethods(), this.paymentMethods = new ce({
|
|
727
727
|
checkoutProfile: e,
|
|
728
728
|
formData: t,
|
|
729
729
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -759,7 +759,7 @@ var K = class extends C {
|
|
|
759
759
|
}
|
|
760
760
|
createPhoneNumberField(e, t, n, r) {
|
|
761
761
|
let i = document.createElement("div");
|
|
762
|
-
this.phonePlaceholder = i, this.formElement.appendChild(i),
|
|
762
|
+
this.phonePlaceholder = i, this.formElement.appendChild(i), s().then(({ PhoneNumberField: a }) => {
|
|
763
763
|
i.isConnected && (this.phoneNumberField = new a({
|
|
764
764
|
value: t.phoneNumber ?? "",
|
|
765
765
|
onChange: this.onChange,
|
|
@@ -788,13 +788,13 @@ var K = class extends C {
|
|
|
788
788
|
}
|
|
789
789
|
if (!this.isCardSupported()) return;
|
|
790
790
|
if (!this.vgsService) {
|
|
791
|
-
this.cardUnavailableNotice = new
|
|
791
|
+
this.cardUnavailableNotice = new N({
|
|
792
792
|
checkoutProfile: e,
|
|
793
793
|
translationFunc: this.translationFunc
|
|
794
794
|
}), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
|
|
795
795
|
return;
|
|
796
796
|
}
|
|
797
|
-
this.cardSection = new
|
|
797
|
+
this.cardSection = new ne({
|
|
798
798
|
checkoutProfile: e,
|
|
799
799
|
translationFunc: this.translationFunc,
|
|
800
800
|
vgsService: this.vgsService
|
|
@@ -893,7 +893,7 @@ var K = class extends C {
|
|
|
893
893
|
}
|
|
894
894
|
createSubmitButton(e, t) {
|
|
895
895
|
try {
|
|
896
|
-
this.submitButton = new
|
|
896
|
+
this.submitButton = new de({
|
|
897
897
|
disabled: t,
|
|
898
898
|
checkoutProfile: e,
|
|
899
899
|
translationFunc: this.translationFunc
|
|
@@ -975,20 +975,21 @@ var K = class extends C {
|
|
|
975
975
|
}
|
|
976
976
|
async mountVgsFields(e) {
|
|
977
977
|
if (!this.vgsService || !this.cardSection) return;
|
|
978
|
+
let t = z(e.styles.fontFamily);
|
|
978
979
|
await this.vgsService.whenReady();
|
|
979
|
-
let
|
|
980
|
-
if (this.cardholderSection &&
|
|
981
|
-
let e =
|
|
980
|
+
let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
|
|
981
|
+
if (this.cardholderSection && a.cardholderName) {
|
|
982
|
+
let e = a.cardholderName;
|
|
982
983
|
typeof e.height == "string" && this.cardholderSection.setFieldHeight(e.height);
|
|
983
984
|
let t = e["border-radius"];
|
|
984
985
|
typeof t == "string" && this.cardholderSection.setBorderRadius(parseFloat(t));
|
|
985
986
|
}
|
|
986
987
|
this.vgsService.mountCardFields({
|
|
987
|
-
cardNumber:
|
|
988
|
-
cardExpiry:
|
|
989
|
-
cardCvv:
|
|
990
|
-
cardholderName:
|
|
991
|
-
},
|
|
988
|
+
cardNumber: n.cardNumber ? `#${n.cardNumber}` : void 0,
|
|
989
|
+
cardExpiry: n.cardExpiry ? `#${n.cardExpiry}` : void 0,
|
|
990
|
+
cardCvv: n.cardCvv ? `#${n.cardCvv}` : void 0,
|
|
991
|
+
cardholderName: r ? `#${r}` : void 0
|
|
992
|
+
}, a, {
|
|
992
993
|
cardNumber: "1234 5678 9012 3456",
|
|
993
994
|
cardExpiry: this.translationFunc("cardExpiry"),
|
|
994
995
|
cardCvv: "CVV",
|
|
@@ -1015,7 +1016,7 @@ var K = class extends C {
|
|
|
1015
1016
|
}
|
|
1016
1017
|
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);
|
|
1017
1018
|
}
|
|
1018
|
-
},
|
|
1019
|
+
}, pe = class {
|
|
1019
1020
|
formManager;
|
|
1020
1021
|
focusManager;
|
|
1021
1022
|
onFormSubmit;
|
|
@@ -1055,7 +1056,7 @@ var K = class extends C {
|
|
|
1055
1056
|
clearTouchedFields() {
|
|
1056
1057
|
this.localTouchedFields.clear();
|
|
1057
1058
|
}
|
|
1058
|
-
},
|
|
1059
|
+
}, me = class {
|
|
1059
1060
|
formManager;
|
|
1060
1061
|
checkoutProfile;
|
|
1061
1062
|
formElement;
|
|
@@ -1078,7 +1079,7 @@ var K = class extends C {
|
|
|
1078
1079
|
if (!e.isLoading) {
|
|
1079
1080
|
if (e.checkoutProfile) try {
|
|
1080
1081
|
if (e.checkoutProfile.styles?.fontFamily) try {
|
|
1081
|
-
let { cleanup: t } =
|
|
1082
|
+
let { cleanup: t } = v({ fontFamily: e.checkoutProfile.styles.fontFamily });
|
|
1082
1083
|
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
1083
1084
|
} catch (e) {
|
|
1084
1085
|
console.error("Error loading Google Font:", e);
|
|
@@ -1097,7 +1098,7 @@ var K = class extends C {
|
|
|
1097
1098
|
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) => {
|
|
1098
1099
|
if (!e) return !0;
|
|
1099
1100
|
let n = t?.country ?? "";
|
|
1100
|
-
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!
|
|
1101
|
+
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!_(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
|
|
1101
1102
|
}, 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);
|
|
1102
1103
|
return s || !m || this.isSubmitting;
|
|
1103
1104
|
}
|
|
@@ -1130,7 +1131,7 @@ var K = class extends C {
|
|
|
1130
1131
|
cleanup() {
|
|
1131
1132
|
this.fontCleanup &&= (this.fontCleanup(), void 0);
|
|
1132
1133
|
}
|
|
1133
|
-
},
|
|
1134
|
+
}, he = class extends C {
|
|
1134
1135
|
titleElement;
|
|
1135
1136
|
constructor(e = {}) {
|
|
1136
1137
|
super("div", ["blur-bg"]);
|
|
@@ -1156,11 +1157,11 @@ var K = class extends C {
|
|
|
1156
1157
|
n[i] = e[t];
|
|
1157
1158
|
}
|
|
1158
1159
|
}), n;
|
|
1159
|
-
},
|
|
1160
|
+
}, Z = class {
|
|
1160
1161
|
formElement;
|
|
1161
1162
|
componentManager;
|
|
1162
1163
|
onLoadingStateChange;
|
|
1163
|
-
validationSchema =
|
|
1164
|
+
validationSchema = a();
|
|
1164
1165
|
spinner;
|
|
1165
1166
|
formSkeleton;
|
|
1166
1167
|
alert;
|
|
@@ -1178,7 +1179,7 @@ var K = class extends C {
|
|
|
1178
1179
|
e ? (this.hideSkeleton(), this.formSkeleton = new J(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
1179
1180
|
}
|
|
1180
1181
|
showSpinner(e) {
|
|
1181
|
-
this.hideSpinner(), this.spinner = new
|
|
1182
|
+
this.hideSpinner(), this.spinner = new he({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
1182
1183
|
}
|
|
1183
1184
|
hideSpinner() {
|
|
1184
1185
|
this.spinner &&= (this.spinner.getElement().remove(), void 0);
|
|
@@ -1187,7 +1188,7 @@ var K = class extends C {
|
|
|
1187
1188
|
this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
|
|
1188
1189
|
}
|
|
1189
1190
|
setErrorMessage(e) {
|
|
1190
|
-
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new
|
|
1191
|
+
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new P({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
|
|
1191
1192
|
}
|
|
1192
1193
|
clearErrorMessage() {
|
|
1193
1194
|
this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
@@ -1197,7 +1198,7 @@ var K = class extends C {
|
|
|
1197
1198
|
}
|
|
1198
1199
|
};
|
|
1199
1200
|
globalThis.navigator.userAgent;
|
|
1200
|
-
var
|
|
1201
|
+
var Q = (e) => ({
|
|
1201
1202
|
street: "",
|
|
1202
1203
|
firstName: "",
|
|
1203
1204
|
lastName: "",
|
|
@@ -1208,9 +1209,9 @@ var Z = (e) => ({
|
|
|
1208
1209
|
...e
|
|
1209
1210
|
}), ge = class extends C {
|
|
1210
1211
|
options;
|
|
1211
|
-
formManager =
|
|
1212
|
+
formManager = h();
|
|
1212
1213
|
checkoutProfile;
|
|
1213
|
-
translation =
|
|
1214
|
+
translation = R();
|
|
1214
1215
|
focusManager = new U();
|
|
1215
1216
|
componentManager;
|
|
1216
1217
|
eventHandler;
|
|
@@ -1225,7 +1226,7 @@ var Z = (e) => ({
|
|
|
1225
1226
|
constructor(e) {
|
|
1226
1227
|
super("form", ["form-container"]), this.options = e;
|
|
1227
1228
|
let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
|
|
1228
|
-
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new
|
|
1229
|
+
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new o()), this.checkoutProfile = ee({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new fe({
|
|
1229
1230
|
formElement: this.element,
|
|
1230
1231
|
focusManager: this.focusManager,
|
|
1231
1232
|
translationFunc: this.translation.t,
|
|
@@ -1241,11 +1242,11 @@ var Z = (e) => ({
|
|
|
1241
1242
|
checkoutDetails: e.checkoutDetails,
|
|
1242
1243
|
environment: e.environment,
|
|
1243
1244
|
vgsService: this.vgsService
|
|
1244
|
-
}), this.uiManager = new
|
|
1245
|
+
}), this.uiManager = new Z({
|
|
1245
1246
|
formElement: this.element,
|
|
1246
1247
|
componentManager: this.componentManager,
|
|
1247
1248
|
onLoadingStateChange: e.onLoadingStateChange
|
|
1248
|
-
}), this.stateCoordinator = new
|
|
1249
|
+
}), this.stateCoordinator = new me({
|
|
1249
1250
|
formManager: this.formManager,
|
|
1250
1251
|
checkoutProfile: this.checkoutProfile,
|
|
1251
1252
|
componentManager: this.componentManager,
|
|
@@ -1255,7 +1256,7 @@ var Z = (e) => ({
|
|
|
1255
1256
|
onError: (e) => this.uiManager.setErrorMessage(e),
|
|
1256
1257
|
onLoadingChange: (e) => this.uiManager.setLoadingState(e),
|
|
1257
1258
|
getInitialFormData: () => this._getFormStateData().formData
|
|
1258
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
1259
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new pe({
|
|
1259
1260
|
formManager: this.formManager,
|
|
1260
1261
|
focusManager: this.focusManager,
|
|
1261
1262
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -1267,8 +1268,8 @@ var Z = (e) => ({
|
|
|
1267
1268
|
...e.initialValues.email && { email: e.initialValues.email },
|
|
1268
1269
|
...e.initialValues.phoneNumber && { phoneNumber: e.initialValues.phoneNumber },
|
|
1269
1270
|
...e.initialValues.name && { name: e.initialValues.name },
|
|
1270
|
-
...e.initialValues.billingAddress && { billingAddress:
|
|
1271
|
-
...e.initialValues.shippingAddress && { shippingAddress:
|
|
1271
|
+
...e.initialValues.billingAddress && { billingAddress: Q(e.initialValues.billingAddress) },
|
|
1272
|
+
...e.initialValues.shippingAddress && { shippingAddress: Q(e.initialValues.shippingAddress) }
|
|
1272
1273
|
}), this.initializeForm(), this.appendTo(e.container);
|
|
1273
1274
|
}
|
|
1274
1275
|
_getFormStateData() {
|
|
@@ -1281,8 +1282,8 @@ var Z = (e) => ({
|
|
|
1281
1282
|
cardExpiry: "",
|
|
1282
1283
|
cardNumber: "",
|
|
1283
1284
|
cardCvv: "",
|
|
1284
|
-
...t?.billingAddress && { billingAddress:
|
|
1285
|
-
...t?.shippingAddress && { shippingAddress:
|
|
1285
|
+
...t?.billingAddress && { billingAddress: Q(t.billingAddress) },
|
|
1286
|
+
...t?.shippingAddress && { shippingAddress: Q(t.shippingAddress) }
|
|
1286
1287
|
},
|
|
1287
1288
|
errors: e.errors || {},
|
|
1288
1289
|
touched: e.touched || {}
|
|
@@ -1290,7 +1291,7 @@ var Z = (e) => ({
|
|
|
1290
1291
|
}
|
|
1291
1292
|
initializeForm() {
|
|
1292
1293
|
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) {
|
|
1293
|
-
this.failCardCaptureClosed(
|
|
1294
|
+
this.failCardCaptureClosed(M.NO_TOKENIZATION_SESSION);
|
|
1294
1295
|
return;
|
|
1295
1296
|
}
|
|
1296
1297
|
if (this.vgsService) {
|
|
@@ -1298,7 +1299,7 @@ var Z = (e) => ({
|
|
|
1298
1299
|
e.init(this.options.environment).then((t) => {
|
|
1299
1300
|
this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
|
|
1300
1301
|
}).catch((t) => {
|
|
1301
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1302
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(M.INIT_FAILED));
|
|
1302
1303
|
});
|
|
1303
1304
|
}
|
|
1304
1305
|
}
|
|
@@ -1309,7 +1310,7 @@ var Z = (e) => ({
|
|
|
1309
1310
|
return;
|
|
1310
1311
|
}
|
|
1311
1312
|
let t = this.isCardCaptureUnavailable;
|
|
1312
|
-
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), t ||
|
|
1313
|
+
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), t || g(l.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
|
|
1313
1314
|
}
|
|
1314
1315
|
dropVgsService() {
|
|
1315
1316
|
let e = this.vgsService;
|
|
@@ -1327,7 +1328,7 @@ var Z = (e) => ({
|
|
|
1327
1328
|
this.componentManager.hasComponents() && this.componentManager.cleanup(), e.checkoutProfile.layout.phoneNumber?.enabled && this.formManager.getFormState().formData.phoneNumber === void 0 && this.formManager.setFormData({
|
|
1328
1329
|
phoneNumber: "",
|
|
1329
1330
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1330
|
-
}), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress:
|
|
1331
|
+
}), 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() });
|
|
1331
1332
|
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = W(e.checkoutProfile.layout);
|
|
1332
1333
|
try {
|
|
1333
1334
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
@@ -1369,7 +1370,7 @@ var Z = (e) => ({
|
|
|
1369
1370
|
if (this.vgsService) {
|
|
1370
1371
|
let t = this.vgsService, n = ++this.vgsMountGeneration;
|
|
1371
1372
|
this.componentManager.mountVgsFields(e.checkoutProfile).catch((e) => {
|
|
1372
|
-
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(
|
|
1373
|
+
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(M.FIELDS_NOT_READY));
|
|
1373
1374
|
});
|
|
1374
1375
|
}
|
|
1375
1376
|
try {
|
|
@@ -1463,18 +1464,18 @@ var Z = (e) => ({
|
|
|
1463
1464
|
destroy() {
|
|
1464
1465
|
this.isDestroyed = !0, this.vgsMountGeneration += 1, this.vgsService?.destroy(), this.vgsService = void 0, this.stateCoordinator.cleanup(), this.eventHandler.clearTouchedFields(), this.getElement().removeEventListener("submit", this.eventHandler.handleSubmit), this.getElement().removeEventListener("keydown", this.eventHandler.handleKeyDown), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
|
|
1465
1466
|
}
|
|
1466
|
-
associatePayment(e, t, n,
|
|
1467
|
-
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails =
|
|
1468
|
-
let
|
|
1469
|
-
if (
|
|
1470
|
-
let e = new
|
|
1467
|
+
associatePayment(e, t, n, r, i) {
|
|
1468
|
+
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = r, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
|
|
1469
|
+
let a = this.componentManager.isCardSupported();
|
|
1470
|
+
if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
|
|
1471
|
+
let e = new o();
|
|
1471
1472
|
this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
|
|
1472
1473
|
this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
|
|
1473
1474
|
}).catch((t) => {
|
|
1474
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1475
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(M.INIT_FAILED));
|
|
1475
1476
|
});
|
|
1476
1477
|
}
|
|
1477
|
-
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t,
|
|
1478
|
+
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(M.NO_TOKENIZATION_SESSION);
|
|
1478
1479
|
let s = this.checkoutProfile.getState();
|
|
1479
1480
|
if (s.checkoutProfile) {
|
|
1480
1481
|
let { formData: e } = this._getFormStateData();
|
|
@@ -1535,7 +1536,7 @@ var Z = (e) => ({
|
|
|
1535
1536
|
async associatePayment(e, t, n, r, i) {
|
|
1536
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);
|
|
1537
1538
|
}
|
|
1538
|
-
},
|
|
1539
|
+
}, ve = class {
|
|
1539
1540
|
state;
|
|
1540
1541
|
listeners = /* @__PURE__ */ new Set();
|
|
1541
1542
|
constructor(e) {
|
|
@@ -1559,7 +1560,7 @@ var Z = (e) => ({
|
|
|
1559
1560
|
let e = this.getState();
|
|
1560
1561
|
this.listeners.forEach((t) => t(e));
|
|
1561
1562
|
}
|
|
1562
|
-
},
|
|
1563
|
+
}, ye = "en", $ = class {
|
|
1563
1564
|
config;
|
|
1564
1565
|
_callbacks;
|
|
1565
1566
|
paymentState;
|
|
@@ -1568,11 +1569,11 @@ var Z = (e) => ({
|
|
|
1568
1569
|
stateManager;
|
|
1569
1570
|
sessionId;
|
|
1570
1571
|
constructor(e) {
|
|
1571
|
-
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
1572
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), y(), b({
|
|
1572
1573
|
environment: this.config.environment,
|
|
1573
1574
|
sessionId: this.sessionId,
|
|
1574
1575
|
integration: "dropin"
|
|
1575
|
-
}),
|
|
1576
|
+
}), g(l.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new n(this.config.apiKey, this.config.environment), this.stateManager = new ve({
|
|
1576
1577
|
mounted: !1,
|
|
1577
1578
|
form: null
|
|
1578
1579
|
}), this.formManager = new _e({
|
|
@@ -1592,7 +1593,7 @@ var Z = (e) => ({
|
|
|
1592
1593
|
apiKey: e.apiKey,
|
|
1593
1594
|
returnUrl: e.returnUrl,
|
|
1594
1595
|
environment: e.environment,
|
|
1595
|
-
locale: e.locale ||
|
|
1596
|
+
locale: e.locale || ye,
|
|
1596
1597
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1597
1598
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1598
1599
|
appearance: e.appearance,
|
|
@@ -1613,15 +1614,15 @@ var Z = (e) => ({
|
|
|
1613
1614
|
return t = document.createElement("div"), n.appendChild(t), this.stateManager.updateState({
|
|
1614
1615
|
form: t,
|
|
1615
1616
|
mounted: !0
|
|
1616
|
-
}), this.formManager.mount(t),
|
|
1617
|
+
}), this.formManager.mount(t), g(l.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1617
1618
|
} catch (n) {
|
|
1618
1619
|
throw t?.remove(), this.stateManager.updateState({
|
|
1619
1620
|
form: null,
|
|
1620
1621
|
mounted: !1
|
|
1621
|
-
}),
|
|
1622
|
+
}), g(l.CHECKOUT_MOUNT_FAILED, {
|
|
1622
1623
|
container_id: e,
|
|
1623
1624
|
error_message: n instanceof Error ? n.message : "Unknown error"
|
|
1624
|
-
}),
|
|
1625
|
+
}), S(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n;
|
|
1625
1626
|
}
|
|
1626
1627
|
}
|
|
1627
1628
|
unmount() {
|
|
@@ -1632,57 +1633,57 @@ var Z = (e) => ({
|
|
|
1632
1633
|
e && e.remove(), this.stateManager.updateState({
|
|
1633
1634
|
form: null,
|
|
1634
1635
|
mounted: !1
|
|
1635
|
-
}),
|
|
1636
|
+
}), g(l.CHECKOUT_UNMOUNTED);
|
|
1636
1637
|
});
|
|
1637
1638
|
}
|
|
1638
|
-
async handleSubmit({ formData:
|
|
1639
|
+
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1639
1640
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1640
|
-
let
|
|
1641
|
-
|
|
1641
|
+
let n = this.getPaymentMethod(e, t);
|
|
1642
|
+
g(l.PAYMENT_SUBMIT_STARTED, {
|
|
1642
1643
|
payment_id: this.paymentState.paymentId,
|
|
1643
|
-
payment_method:
|
|
1644
|
+
payment_method: n
|
|
1644
1645
|
});
|
|
1645
|
-
let
|
|
1646
|
+
let r = performance.now();
|
|
1646
1647
|
try {
|
|
1647
|
-
let
|
|
1648
|
+
let i = await this.apiService.authorizePayment({
|
|
1648
1649
|
checkoutKey: this.paymentState.checkoutKey,
|
|
1649
|
-
formData:
|
|
1650
|
+
formData: e || null,
|
|
1650
1651
|
paymentId: this.paymentState.paymentId,
|
|
1651
1652
|
returnUrl: this.config.returnUrl,
|
|
1652
|
-
applePayData:
|
|
1653
|
-
}),
|
|
1654
|
-
return x
|
|
1653
|
+
applePayData: t
|
|
1654
|
+
}), a = performance.now() - r;
|
|
1655
|
+
return T(x.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
|
|
1655
1656
|
payment_id: this.paymentState.paymentId,
|
|
1656
|
-
payment_method:
|
|
1657
|
+
payment_method: n,
|
|
1657
1658
|
status: "success"
|
|
1658
|
-
}),
|
|
1659
|
+
}), g(l.PAYMENT_SUBMIT_SUCCESS, {
|
|
1659
1660
|
payment_id: this.paymentState.paymentId,
|
|
1660
|
-
payment_method:
|
|
1661
|
-
}), this.handlePaymentResponse(
|
|
1662
|
-
} catch (
|
|
1663
|
-
let
|
|
1664
|
-
return x
|
|
1661
|
+
payment_method: n
|
|
1662
|
+
}), this.handlePaymentResponse(i);
|
|
1663
|
+
} catch (e) {
|
|
1664
|
+
let t = performance.now() - r;
|
|
1665
|
+
return T(x.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1665
1666
|
payment_id: this.paymentState.paymentId,
|
|
1666
|
-
payment_method:
|
|
1667
|
+
payment_method: n,
|
|
1667
1668
|
status: "failed"
|
|
1668
|
-
}),
|
|
1669
|
+
}), g(l.PAYMENT_SUBMIT_FAILED, {
|
|
1669
1670
|
payment_id: this.paymentState.paymentId,
|
|
1670
|
-
payment_method:
|
|
1671
|
-
error_message:
|
|
1672
|
-
}), this.handleAuthorizationError(
|
|
1671
|
+
payment_method: n,
|
|
1672
|
+
error_message: e.details?.message ?? "Unknown error"
|
|
1673
|
+
}), this.handleAuthorizationError(e), !1;
|
|
1673
1674
|
}
|
|
1674
1675
|
}
|
|
1675
1676
|
handlePaymentResponse(e) {
|
|
1676
1677
|
let t = !1;
|
|
1677
|
-
if (e.latestTransaction.status === "authorized" && (
|
|
1678
|
+
if (e.latestTransaction.status === "authorized" && (g(l.PAYMENT_AUTHORIZED, {
|
|
1678
1679
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1679
1680
|
status: e.latestTransaction.status
|
|
1680
|
-
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (
|
|
1681
|
+
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (g(l.PAYMENT_FAILED, {
|
|
1681
1682
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1682
1683
|
status: e.latestTransaction.status
|
|
1683
1684
|
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
|
|
1684
1685
|
let { redirectUrl: n } = e.action;
|
|
1685
|
-
|
|
1686
|
+
g(l.PAYMENT_ACTION_REQUIRED, {
|
|
1686
1687
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1687
1688
|
status: e.status
|
|
1688
1689
|
}), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(n) : globalThis.location.href = n, t = !0;
|
|
@@ -1717,9 +1718,9 @@ var Z = (e) => ({
|
|
|
1717
1718
|
}
|
|
1718
1719
|
async associatePayment(e, t) {
|
|
1719
1720
|
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
1720
|
-
this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
|
|
1721
|
+
this.paymentState.paymentId = e, this.paymentState.checkoutKey = t, u(this.config.environment);
|
|
1721
1722
|
try {
|
|
1722
|
-
let n = await
|
|
1723
|
+
let n = await F({
|
|
1723
1724
|
id: e,
|
|
1724
1725
|
checkoutKey: t,
|
|
1725
1726
|
environment: this.config.environment
|
|
@@ -1732,16 +1733,16 @@ var Z = (e) => ({
|
|
|
1732
1733
|
countryCode: n.countryCode
|
|
1733
1734
|
};
|
|
1734
1735
|
let r = n.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
|
|
1735
|
-
await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt),
|
|
1736
|
+
await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), g(l.PAYMENT_ASSOCIATED, {
|
|
1736
1737
|
payment_id: e,
|
|
1737
1738
|
currency: n.currency,
|
|
1738
1739
|
country_code: n.countryCode
|
|
1739
1740
|
});
|
|
1740
1741
|
} catch (t) {
|
|
1741
|
-
throw
|
|
1742
|
+
throw g(l.PAYMENT_ASSOCIATION_FAILED, {
|
|
1742
1743
|
payment_id: e,
|
|
1743
1744
|
error_message: t instanceof Error ? t.message : "Unknown error"
|
|
1744
|
-
}),
|
|
1745
|
+
}), S(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
|
|
1745
1746
|
}
|
|
1746
1747
|
}
|
|
1747
1748
|
setCallbacks(e) {
|
|
@@ -1752,4 +1753,4 @@ var Z = (e) => ({
|
|
|
1752
1753
|
//#region libs/checkout/src/index.ts
|
|
1753
1754
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1754
1755
|
//#endregion
|
|
1755
|
-
export { $ as OdusCheckout,
|
|
1756
|
+
export { $ as OdusCheckout, p as deLocale, f as enLocale, k as esLocale, t as frLocale, re as itLocale, m as plLocale, r as ptLocale, S as pushError, g as pushEvent, e as pushLog, T as pushMeasurement, i as trLocale };
|