@odus/checkout 1.14.3 → 1.14.4
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 +180 -174
- package/dist/components/checkout/form/Form.d.ts +3 -0
- package/dist/components/checkout/form/Form.d.ts.map +1 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts +11 -2
- package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
- package/dist/components/checkout/form/FormStateCoordinator.d.ts +3 -0
- package/dist/components/checkout/form/FormStateCoordinator.d.ts.map +1 -1
- package/dist/components/checkout/form/PaymentMethods.d.ts +2 -1
- package/dist/components/checkout/form/PaymentMethods.d.ts.map +1 -1
- package/dist/components/payment-methods/applePay/ApplePayButton.d.ts +9 -1
- package/dist/components/payment-methods/applePay/ApplePayButton.d.ts.map +1 -1
- package/dist/core/vgs/VGSCollectService.d.ts.map +1 -1
- package/dist/core/vgs/vgs.constants.d.ts +18 -0
- package/dist/core/vgs/vgs.constants.d.ts.map +1 -1
- package/dist/elements/ApplePayElement.d.ts +3 -1
- package/dist/elements/ApplePayElement.d.ts.map +1 -1
- package/dist/elements/OdusElements.d.ts +6 -2
- package/dist/elements/OdusElements.d.ts.map +1 -1
- package/dist/elements/PhoneElement.d.ts +13 -0
- package/dist/elements/PhoneElement.d.ts.map +1 -1
- package/dist/elements.es.js +204 -167
- package/dist/services/telemetry/CheckoutReadiness.service.d.ts +4 -2
- package/dist/services/telemetry/CheckoutReadiness.service.d.ts.map +1 -1
- package/dist/shared.js +751 -690
- package/dist/types/telemetry/TelemetryEvents.type.d.ts +9 -1
- package/dist/types/telemetry/TelemetryEvents.type.d.ts.map +1 -1
- package/dist/utils/helpers/errorClass.util.d.ts +10 -0
- package/dist/utils/helpers/errorClass.util.d.ts.map +1 -0
- package/dist/utils/helpers/stageFailure.util.d.ts +7 -1
- package/dist/utils/helpers/stageFailure.util.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, F as i, G as a, H as o, I as s, J as c, K as l, L as u, M as d, N as f, O as p, P as m, Q as
|
|
2
|
-
import { t as
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, G as a, H as o, I as s, J as c, K as l, L as u, M as d, N as f, O as p, P as m, Q as h, R as g, S as _, V as ee, W as te, X as ne, Y as re, Z as v, _t as ie, a as ae, at as y, b, c as oe, ct as x, d as S, dt as C, et as se, f as w, ft as T, g as ce, gt as E, h as D, ht as O, it as le, j as k, k as ue, l as A, lt as j, m as M, mt as N, n as de, nt as P, o as fe, ot as pe, pt as F, q as I, r as L, rt as R, s as z, st as B, t as me, tt as he, u as ge, ut as V, v as H, vt as _e, w as ve, x as ye, y as U, z as W } from "./shared.js";
|
|
2
|
+
import { t as G } from "./shared2.js";
|
|
3
3
|
//#region libs/checkout/src/utils/focus/FocusManager.ts
|
|
4
|
-
var
|
|
4
|
+
var be = class {
|
|
5
5
|
focusSequence = [
|
|
6
6
|
"cardNumber",
|
|
7
7
|
"cardExpiry",
|
|
@@ -81,19 +81,19 @@ var ve = class {
|
|
|
81
81
|
};
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
|
|
84
|
-
function
|
|
84
|
+
function xe(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);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function K(e) {
|
|
90
90
|
if (!e) return !1;
|
|
91
91
|
let { billingFields: t, shippingFields: n } = e, r = t?.firstName?.enabled && t?.lastName?.enabled, i = n?.firstName?.enabled && n?.lastName?.enabled;
|
|
92
92
|
return !!(r || i);
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region libs/checkout/src/components/checkout/form/AddressSection.ts
|
|
96
|
-
var
|
|
96
|
+
var q = class extends b {
|
|
97
97
|
inputs = /* @__PURE__ */ new Map();
|
|
98
98
|
type;
|
|
99
99
|
onChange;
|
|
@@ -115,7 +115,7 @@ var J = class extends v {
|
|
|
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 D({
|
|
119
119
|
text: "",
|
|
120
120
|
visible: !1
|
|
121
121
|
}), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
|
|
@@ -189,7 +189,7 @@ var J = class extends v {
|
|
|
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"), g(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 J = class extends v {
|
|
|
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 w({
|
|
209
209
|
name: c,
|
|
210
210
|
error: !1,
|
|
211
211
|
errorMsg: void 0,
|
|
@@ -227,7 +227,7 @@ var J = class extends v {
|
|
|
227
227
|
let t = this.translationFunc("validation.maxLengthExceeded");
|
|
228
228
|
this.applyFieldError(e, !0, t.replace("{{max}}", String(s)));
|
|
229
229
|
} else this.applyFieldError(e, !1);
|
|
230
|
-
this.onChange(
|
|
230
|
+
this.onChange(G({
|
|
231
231
|
type: "input",
|
|
232
232
|
target: {
|
|
233
233
|
name: c,
|
|
@@ -237,7 +237,7 @@ var J = class extends v {
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
return l.addEventListener("blur", (e) => {
|
|
240
|
-
this.onBlur(
|
|
240
|
+
this.onBlur(G({
|
|
241
241
|
type: "blur",
|
|
242
242
|
target: {
|
|
243
243
|
name: c,
|
|
@@ -247,7 +247,7 @@ var J = class extends v {
|
|
|
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 = ce(i, this.locale), c = new S({
|
|
251
251
|
name: o,
|
|
252
252
|
error: !1,
|
|
253
253
|
errorMsg: void 0,
|
|
@@ -261,7 +261,7 @@ var J = class extends v {
|
|
|
261
261
|
onChange: (e) => {
|
|
262
262
|
this.applyFieldError("country", !1);
|
|
263
263
|
let t = e.target.value;
|
|
264
|
-
this.onChange(
|
|
264
|
+
this.onChange(G({
|
|
265
265
|
type: "change",
|
|
266
266
|
target: {
|
|
267
267
|
name: o,
|
|
@@ -271,7 +271,7 @@ var J = class extends v {
|
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
return c.addEventListener("blur", (e) => {
|
|
274
|
-
this.onBlur(
|
|
274
|
+
this.onBlur(G({
|
|
275
275
|
type: "blur",
|
|
276
276
|
target: {
|
|
277
277
|
name: o,
|
|
@@ -289,11 +289,11 @@ var J = class extends v {
|
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
291
|
if (!r && n && (this.stateRow.style.display = ""), r) return;
|
|
292
|
-
let i = this.inputs.get("state") instanceof
|
|
292
|
+
let i = this.inputs.get("state") instanceof S, a = g(e);
|
|
293
293
|
if (i && a) {
|
|
294
294
|
let t = this.inputs.get("state");
|
|
295
|
-
if (t instanceof
|
|
296
|
-
let n =
|
|
295
|
+
if (t instanceof S) {
|
|
296
|
+
let n = W(e), r = s(n), i = this.translationFunc(u(n));
|
|
297
297
|
t.setOptions(r, i);
|
|
298
298
|
}
|
|
299
299
|
this.clearStateValue();
|
|
@@ -309,7 +309,7 @@ var J = class extends v {
|
|
|
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")), g(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 {
|
|
@@ -321,7 +321,7 @@ var J = class extends v {
|
|
|
321
321
|
let e = this.inputs.get("state");
|
|
322
322
|
e && e.setValue("");
|
|
323
323
|
let t = `${this.type}Address.state`;
|
|
324
|
-
this.onChange(
|
|
324
|
+
this.onChange(G({
|
|
325
325
|
type: "input",
|
|
326
326
|
target: {
|
|
327
327
|
name: t,
|
|
@@ -331,7 +331,7 @@ var J = class extends v {
|
|
|
331
331
|
}));
|
|
332
332
|
}
|
|
333
333
|
createStateSelect(e, t, n, r, i, a) {
|
|
334
|
-
let o = `${this.type}Address.state`, c =
|
|
334
|
+
let o = `${this.type}Address.state`, c = W(i), l = s(c), d = this.translationFunc(u(c)), f = new S({
|
|
335
335
|
name: o,
|
|
336
336
|
error: !1,
|
|
337
337
|
errorMsg: void 0,
|
|
@@ -343,7 +343,7 @@ var J = class extends v {
|
|
|
343
343
|
options: l,
|
|
344
344
|
autocomplete: "address-level1",
|
|
345
345
|
onChange: (e) => {
|
|
346
|
-
this.applyFieldError("state", !1), this.onChange(
|
|
346
|
+
this.applyFieldError("state", !1), this.onChange(G({
|
|
347
347
|
type: "change",
|
|
348
348
|
target: {
|
|
349
349
|
name: o,
|
|
@@ -353,7 +353,7 @@ var J = class extends v {
|
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
return f.addEventListener("blur", (e) => {
|
|
356
|
-
this.onBlur(
|
|
356
|
+
this.onBlur(G({
|
|
357
357
|
type: "blur",
|
|
358
358
|
target: {
|
|
359
359
|
name: o,
|
|
@@ -381,7 +381,7 @@ var J = class extends v {
|
|
|
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 = g(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());
|
|
@@ -447,7 +447,7 @@ var J = class extends v {
|
|
|
447
447
|
let e = this.inputs.values().next().value;
|
|
448
448
|
e && e.focus();
|
|
449
449
|
}
|
|
450
|
-
},
|
|
450
|
+
}, Se = class {
|
|
451
451
|
input = null;
|
|
452
452
|
isVgsMode;
|
|
453
453
|
vgsWrapper = null;
|
|
@@ -455,7 +455,7 @@ var J = class extends v {
|
|
|
455
455
|
vgsHelperText = null;
|
|
456
456
|
wrapperElement;
|
|
457
457
|
_vgsFieldsReady = !1;
|
|
458
|
-
_fieldHeight =
|
|
458
|
+
_fieldHeight = U(H, 14);
|
|
459
459
|
_borderRadius = 0;
|
|
460
460
|
constructor(e) {
|
|
461
461
|
let { value: t, onChange: n, onBlur: r, errorMsg: i, checkoutProfile: a, translationFunc: o, autocomplete: s = "cc-name", isVgsMode: c = !1 } = e;
|
|
@@ -463,16 +463,16 @@ var J = class extends v {
|
|
|
463
463
|
}
|
|
464
464
|
buildVgsLayout(e, t) {
|
|
465
465
|
let n = e.styles.borderRadius;
|
|
466
|
-
this._borderRadius = n, this._fieldHeight =
|
|
466
|
+
this._borderRadius = n, this._fieldHeight = U(H, e.styles.fontSize);
|
|
467
467
|
let r = document.createElement("div");
|
|
468
468
|
r.style.marginBottom = "4px";
|
|
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 D({ 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 w({
|
|
476
476
|
name: "name",
|
|
477
477
|
label: a("cardholderNameLabel"),
|
|
478
478
|
error: !1,
|
|
@@ -499,9 +499,9 @@ var J = class extends v {
|
|
|
499
499
|
}
|
|
500
500
|
handleVgsStateChange(e, t) {
|
|
501
501
|
if (!this.isVgsMode || !this.vgsWrapper) return;
|
|
502
|
-
let n = e[
|
|
502
|
+
let n = e[A.CARDHOLDER]?.isFocused;
|
|
503
503
|
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;
|
|
504
|
-
let r = t[
|
|
504
|
+
let r = t[A.CARDHOLDER];
|
|
505
505
|
r ? (this.vgsHelperText.setText(r), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
|
|
506
506
|
}
|
|
507
507
|
setFieldHeight(e) {
|
|
@@ -543,7 +543,7 @@ var J = class extends v {
|
|
|
543
543
|
focus() {
|
|
544
544
|
this.isVgsMode || this.input?.focus();
|
|
545
545
|
}
|
|
546
|
-
},
|
|
546
|
+
}, J = class extends b {
|
|
547
547
|
constructor() {
|
|
548
548
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
549
549
|
}
|
|
@@ -551,14 +551,14 @@ var J = class extends v {
|
|
|
551
551
|
this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
|
|
552
552
|
}
|
|
553
553
|
createPaymentMethodSkeleton() {
|
|
554
|
-
let e =
|
|
554
|
+
let e = M.createDiv(["skeleton-field"]), t = M.createDiv(["skeleton", "skeleton-payment-method"]);
|
|
555
555
|
return e.appendChild(t), e;
|
|
556
556
|
}
|
|
557
557
|
createPaymentSeparatorSkeleton() {
|
|
558
|
-
let e =
|
|
558
|
+
let e = M.createDiv(["payment-separator_container"]), t = M.createDiv(["payment-separator__line"]), n = M.createDiv(["skeleton", "skeleton-separator-text"]), r = M.createDiv(["payment-separator__line"]);
|
|
559
559
|
return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
|
|
560
560
|
}
|
|
561
|
-
},
|
|
561
|
+
}, Ce = class extends b {
|
|
562
562
|
constructor(e) {
|
|
563
563
|
let { translationFunc: t, checkoutProfile: n } = e;
|
|
564
564
|
super("div", ["payment-separator"]);
|
|
@@ -569,32 +569,32 @@ var J = class extends v {
|
|
|
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
|
+
}, we = class extends b {
|
|
573
573
|
paymentMethods;
|
|
574
574
|
paymentSeparator;
|
|
575
575
|
skeleton;
|
|
576
576
|
constructor(e) {
|
|
577
|
-
let { checkoutProfile: t, formData: n, onPaypalSubmit: r, onApplePaySubmit: i, onApplePayStartFailed: a,
|
|
577
|
+
let { checkoutProfile: t, formData: n, onPaypalSubmit: r, onApplePaySubmit: i, onApplePayStartFailed: a, onApplePayPaymentDataFailed: o, supportedPaymentMethods: s, translationFunc: c, paymentId: l, checkoutKey: u, checkoutDetails: d, environment: f, countryCode: p } = e;
|
|
578
578
|
if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
|
|
579
579
|
this.getElement().style.display = "none";
|
|
580
580
|
return;
|
|
581
581
|
}
|
|
582
|
-
if (
|
|
582
|
+
if (s === void 0) {
|
|
583
583
|
this.renderSkeleton();
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
let
|
|
587
|
-
let n = t.enabled, r = !
|
|
586
|
+
let m = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
|
|
587
|
+
let n = t.enabled, r = !s || s[e] === !0, i = ae(t.countries, p);
|
|
588
588
|
return n && r && i;
|
|
589
589
|
}).sort((e, t) => e[1].order - t[1].order);
|
|
590
|
-
if (
|
|
590
|
+
if (m.length === 0) {
|
|
591
591
|
this.getElement().style.display = "none";
|
|
592
592
|
return;
|
|
593
593
|
}
|
|
594
|
-
for (let [e] of
|
|
594
|
+
for (let [e] of m) switch (e) {
|
|
595
595
|
case "paypal":
|
|
596
596
|
if (r) {
|
|
597
|
-
let e = new
|
|
597
|
+
let e = new de({
|
|
598
598
|
checkoutProfile: t,
|
|
599
599
|
formData: n,
|
|
600
600
|
onSubmit: r
|
|
@@ -603,16 +603,17 @@ var J = class extends v {
|
|
|
603
603
|
}
|
|
604
604
|
break;
|
|
605
605
|
case "applePay":
|
|
606
|
-
if (i &&
|
|
606
|
+
if (i && l && u) {
|
|
607
607
|
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new L({
|
|
608
608
|
checkoutProfile: t,
|
|
609
609
|
formData: n,
|
|
610
610
|
onSubmit: i,
|
|
611
611
|
onStartFailed: a,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
612
|
+
onPaymentDataFailed: o,
|
|
613
|
+
paymentId: l,
|
|
614
|
+
checkoutKey: u,
|
|
615
|
+
checkoutDetails: d,
|
|
616
|
+
environment: f,
|
|
616
617
|
displayName: e?.displayName,
|
|
617
618
|
requiredBillingContactFields: e?.requiredBillingContactFields,
|
|
618
619
|
requiredShippingContactFields: e?.requiredShippingContactFields
|
|
@@ -622,13 +623,13 @@ var J = class extends v {
|
|
|
622
623
|
break;
|
|
623
624
|
default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
|
|
624
625
|
}
|
|
625
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
626
|
-
translationFunc:
|
|
626
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new Ce({
|
|
627
|
+
translationFunc: c,
|
|
627
628
|
checkoutProfile: t
|
|
628
629
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
629
630
|
}
|
|
630
631
|
renderSkeleton() {
|
|
631
|
-
this.skeleton = new
|
|
632
|
+
this.skeleton = new J(), this.getElement().appendChild(this.skeleton.getElement());
|
|
632
633
|
}
|
|
633
634
|
updateFormData(e) {
|
|
634
635
|
let t = this.paymentMethods.get("paypal");
|
|
@@ -639,7 +640,7 @@ var J = class extends v {
|
|
|
639
640
|
hasVisiblePaymentMethods() {
|
|
640
641
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
641
642
|
}
|
|
642
|
-
},
|
|
643
|
+
}, Te = 17, Ee = class extends b {
|
|
643
644
|
styles;
|
|
644
645
|
isHovered = !1;
|
|
645
646
|
constructor(e) {
|
|
@@ -647,7 +648,7 @@ var J = class extends v {
|
|
|
647
648
|
}
|
|
648
649
|
applyStyles() {
|
|
649
650
|
let e = this.getElement();
|
|
650
|
-
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 ===
|
|
651
|
+
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 === Te ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
651
652
|
}
|
|
652
653
|
handleMouseEnter() {
|
|
653
654
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -658,11 +659,11 @@ var J = class extends v {
|
|
|
658
659
|
setDisabled(e) {
|
|
659
660
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
660
661
|
}
|
|
661
|
-
},
|
|
662
|
+
}, De = class {
|
|
662
663
|
button;
|
|
663
664
|
constructor(e) {
|
|
664
665
|
let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
|
|
665
|
-
this.button = new
|
|
666
|
+
this.button = new Ee({
|
|
666
667
|
text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
|
|
667
668
|
styles: {
|
|
668
669
|
backgroundColor: n.styles.buttonColor,
|
|
@@ -686,7 +687,7 @@ var J = class extends v {
|
|
|
686
687
|
appendTo(e) {
|
|
687
688
|
return this.button.appendTo(e), this;
|
|
688
689
|
}
|
|
689
|
-
},
|
|
690
|
+
}, Oe = class {
|
|
690
691
|
formElement;
|
|
691
692
|
focusManager;
|
|
692
693
|
translationFunc;
|
|
@@ -697,6 +698,7 @@ var J = class extends v {
|
|
|
697
698
|
onPaypalSubmit;
|
|
698
699
|
onApplePaySubmit;
|
|
699
700
|
onApplePayStartFailed;
|
|
701
|
+
onApplePayPaymentDataFailed;
|
|
700
702
|
supportedPaymentMethods;
|
|
701
703
|
paymentId;
|
|
702
704
|
checkoutKey;
|
|
@@ -720,12 +722,12 @@ var J = class extends v {
|
|
|
720
722
|
phoneNumberFocusHandler;
|
|
721
723
|
nameFocusHandler;
|
|
722
724
|
constructor(e) {
|
|
723
|
-
this.formElement = e.formElement, this.focusManager = e.focusManager, this.translationFunc = e.translationFunc, this.locale = e.locale, this.onFieldFocus = e.onFieldFocus, this.onChange = e.onChange, this.onBlur = e.onBlur, this.onPaypalSubmit = e.onPaypalSubmit, this.onApplePaySubmit = e.onApplePaySubmit, this.onApplePayStartFailed = e.onApplePayStartFailed, this.supportedPaymentMethods = e.supportedPaymentMethods, this.paymentId = e.paymentId, this.checkoutKey = e.checkoutKey, this.checkoutDetails = e.checkoutDetails, this.environment = e.environment, this.vgsService = e.vgsService, this.isCheckoutDetailsLoaded = !!(e.paymentId && e.checkoutDetails);
|
|
725
|
+
this.formElement = e.formElement, this.focusManager = e.focusManager, this.translationFunc = e.translationFunc, this.locale = e.locale, this.onFieldFocus = e.onFieldFocus, this.onChange = e.onChange, this.onBlur = e.onBlur, this.onPaypalSubmit = e.onPaypalSubmit, this.onApplePaySubmit = e.onApplePaySubmit, this.onApplePayStartFailed = e.onApplePayStartFailed, this.onApplePayPaymentDataFailed = e.onApplePayPaymentDataFailed, this.supportedPaymentMethods = e.supportedPaymentMethods, this.paymentId = e.paymentId, this.checkoutKey = e.checkoutKey, this.checkoutDetails = e.checkoutDetails, this.environment = e.environment, this.vgsService = e.vgsService, this.isCheckoutDetailsLoaded = !!(e.paymentId && e.checkoutDetails);
|
|
724
726
|
}
|
|
725
727
|
createPaymentMethods(e, t, n = !1) {
|
|
726
728
|
try {
|
|
727
729
|
if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
|
|
728
|
-
this.removePaymentMethods(), this.paymentMethods = new
|
|
730
|
+
this.removePaymentMethods(), this.paymentMethods = new we({
|
|
729
731
|
checkoutProfile: e,
|
|
730
732
|
formData: t,
|
|
731
733
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -733,6 +735,7 @@ var J = class extends v {
|
|
|
733
735
|
onPaypalSubmit: this.onPaypalSubmit,
|
|
734
736
|
onApplePaySubmit: this.onApplePaySubmit,
|
|
735
737
|
onApplePayStartFailed: this.onApplePayStartFailed,
|
|
738
|
+
onApplePayPaymentDataFailed: this.onApplePayPaymentDataFailed,
|
|
736
739
|
paymentId: this.paymentId,
|
|
737
740
|
checkoutKey: this.checkoutKey,
|
|
738
741
|
checkoutDetails: this.checkoutDetails,
|
|
@@ -746,7 +749,7 @@ var J = class extends v {
|
|
|
746
749
|
createEmailField(e, t, n, r) {
|
|
747
750
|
try {
|
|
748
751
|
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);
|
|
749
|
-
this.emailField = new
|
|
752
|
+
this.emailField = new fe({
|
|
750
753
|
value: t.email,
|
|
751
754
|
onChange: this.onChange,
|
|
752
755
|
onBlur: this.onBlur,
|
|
@@ -762,22 +765,21 @@ var J = class extends v {
|
|
|
762
765
|
}
|
|
763
766
|
createPhoneNumberField(e, t, n, r) {
|
|
764
767
|
let i = document.createElement("div");
|
|
765
|
-
this.phonePlaceholder = i, this.formElement.appendChild(i), o().then(({ PhoneNumberField: a }) => {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
console.error("Error creating phone number field:", e), i.remove(), this.phonePlaceholder = void 0;
|
|
768
|
+
return this.phonePlaceholder = i, this.formElement.appendChild(i), o().then(({ PhoneNumberField: a }) => this.phonePlaceholder === i && (this.phoneNumberField = new a({
|
|
769
|
+
value: t.phoneNumber ?? "",
|
|
770
|
+
onChange: this.onChange,
|
|
771
|
+
onBlur: this.onBlur,
|
|
772
|
+
onTab: () => this.focusManager.focusField("cardNumber"),
|
|
773
|
+
error: !!(n.phoneNumber && r.phoneNumber),
|
|
774
|
+
errorMsg: n.phoneNumber,
|
|
775
|
+
checkoutProfile: e,
|
|
776
|
+
translationFunc: this.translationFunc,
|
|
777
|
+
defaultCountry: e.layout.phoneNumber?.defaultCountry || "US",
|
|
778
|
+
allowedCountries: e.layout.phoneNumber?.allowedCountries,
|
|
779
|
+
locale: this.locale
|
|
780
|
+
}), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField), i.replaceWith(this.phoneNumberField.getElement()), this.phonePlaceholder = void 0, !0)).catch((e) => {
|
|
781
|
+
if (console.error("Error creating phone number field:", e), this.phonePlaceholder !== i) return !1;
|
|
782
|
+
throw i.remove(), this.phonePlaceholder = void 0, e;
|
|
781
783
|
});
|
|
782
784
|
}
|
|
783
785
|
setCheckoutDetailsLoaded(e) {
|
|
@@ -797,7 +799,7 @@ var J = class extends v {
|
|
|
797
799
|
}), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
|
|
798
800
|
return;
|
|
799
801
|
}
|
|
800
|
-
this.cardSection = new
|
|
802
|
+
this.cardSection = new oe({
|
|
801
803
|
checkoutProfile: e,
|
|
802
804
|
translationFunc: this.translationFunc,
|
|
803
805
|
vgsService: this.vgsService
|
|
@@ -814,7 +816,7 @@ var J = class extends v {
|
|
|
814
816
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
815
817
|
return;
|
|
816
818
|
}
|
|
817
|
-
if (this.cardholderSection = new
|
|
819
|
+
if (this.cardholderSection = new Se({
|
|
818
820
|
value: t.name,
|
|
819
821
|
onChange: this.onChange,
|
|
820
822
|
onBlur: this.onBlur,
|
|
@@ -845,7 +847,7 @@ var J = class extends v {
|
|
|
845
847
|
zipCode: "",
|
|
846
848
|
country: ""
|
|
847
849
|
};
|
|
848
|
-
this.billingAddressSection = new
|
|
850
|
+
this.billingAddressSection = new q({
|
|
849
851
|
type: "billing",
|
|
850
852
|
title: this.translationFunc("address.billingTitle"),
|
|
851
853
|
checkoutProfile: e,
|
|
@@ -876,7 +878,7 @@ var J = class extends v {
|
|
|
876
878
|
zipCode: "",
|
|
877
879
|
country: ""
|
|
878
880
|
};
|
|
879
|
-
this.shippingAddressSection = new
|
|
881
|
+
this.shippingAddressSection = new q({
|
|
880
882
|
type: "shipping",
|
|
881
883
|
title: this.translationFunc("address.shippingTitle"),
|
|
882
884
|
checkoutProfile: e,
|
|
@@ -896,7 +898,7 @@ var J = class extends v {
|
|
|
896
898
|
}
|
|
897
899
|
createSubmitButton(e, t) {
|
|
898
900
|
try {
|
|
899
|
-
this.submitButton = new
|
|
901
|
+
this.submitButton = new De({
|
|
900
902
|
disabled: t,
|
|
901
903
|
checkoutProfile: e,
|
|
902
904
|
translationFunc: this.translationFunc
|
|
@@ -945,7 +947,7 @@ var J = class extends v {
|
|
|
945
947
|
return !this.supportedPaymentMethods || !!this.supportedPaymentMethods.card;
|
|
946
948
|
}
|
|
947
949
|
buildCardSkeleton(e) {
|
|
948
|
-
let t = e.styles.borderRadius, n =
|
|
950
|
+
let t = e.styles.borderRadius, n = U(H, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
|
|
949
951
|
i.style.marginBottom = "4px";
|
|
950
952
|
let a = document.createElement("label");
|
|
951
953
|
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);
|
|
@@ -974,11 +976,11 @@ var J = class extends v {
|
|
|
974
976
|
let i = document.createElement("label");
|
|
975
977
|
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);
|
|
976
978
|
let a = document.createElement("div");
|
|
977
|
-
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height =
|
|
979
|
+
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = U(H, 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;
|
|
978
980
|
}
|
|
979
981
|
async mountVgsFields(e) {
|
|
980
982
|
if (!this.vgsService || !this.cardSection) return !1;
|
|
981
|
-
let t =
|
|
983
|
+
let t = ye(e.styles.fontFamily);
|
|
982
984
|
await this.vgsService.whenReady();
|
|
983
985
|
let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
|
|
984
986
|
if (this.cardholderSection && a.cardholderName) {
|
|
@@ -1019,7 +1021,7 @@ var J = class extends v {
|
|
|
1019
1021
|
}
|
|
1020
1022
|
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);
|
|
1021
1023
|
}
|
|
1022
|
-
},
|
|
1024
|
+
}, ke = class {
|
|
1023
1025
|
formManager;
|
|
1024
1026
|
focusManager;
|
|
1025
1027
|
onFormSubmit;
|
|
@@ -1059,12 +1061,13 @@ var J = class extends v {
|
|
|
1059
1061
|
clearTouchedFields() {
|
|
1060
1062
|
this.localTouchedFields.clear();
|
|
1061
1063
|
}
|
|
1062
|
-
},
|
|
1064
|
+
}, Ae = class {
|
|
1063
1065
|
formManager;
|
|
1064
1066
|
checkoutProfile;
|
|
1065
1067
|
formElement;
|
|
1066
1068
|
onUIUpdate;
|
|
1067
1069
|
onProfileLoaded;
|
|
1070
|
+
onRenderFailed;
|
|
1068
1071
|
onError;
|
|
1069
1072
|
onLoadingChange;
|
|
1070
1073
|
fontCleanup;
|
|
@@ -1073,27 +1076,22 @@ var J = class extends v {
|
|
|
1073
1076
|
isCardCaptureUnavailable = !1;
|
|
1074
1077
|
vgsFieldsState = {};
|
|
1075
1078
|
constructor(e) {
|
|
1076
|
-
this.formManager = e.formManager, this.checkoutProfile = e.checkoutProfile, this.formElement = e.formElement, this.onUIUpdate = e.onUIUpdate, this.onProfileLoaded = e.onProfileLoaded, this.onError = e.onError, this.onLoadingChange = e.onLoadingChange;
|
|
1079
|
+
this.formManager = e.formManager, this.checkoutProfile = e.checkoutProfile, this.formElement = e.formElement, this.onUIUpdate = e.onUIUpdate, this.onProfileLoaded = e.onProfileLoaded, this.onRenderFailed = e.onRenderFailed, this.onError = e.onError, this.onLoadingChange = e.onLoadingChange;
|
|
1077
1080
|
}
|
|
1078
1081
|
handleFormStateChange = () => {
|
|
1079
1082
|
this.onUIUpdate();
|
|
1080
1083
|
};
|
|
1081
1084
|
handleProfileStateChange = (e) => {
|
|
1082
|
-
if (!e.isLoading) {
|
|
1083
|
-
if (e.checkoutProfile) try {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
console.error("Error loading Google Font:", e);
|
|
1089
|
-
}
|
|
1090
|
-
this.onProfileLoaded(), this.onLoadingChange(!1);
|
|
1091
|
-
} catch (t) {
|
|
1092
|
-
console.error("Error in profile state change:", t);
|
|
1093
|
-
let n = e.error || "Failed to load checkout profile data";
|
|
1094
|
-
this.onError(n), this.onLoadingChange(!1);
|
|
1085
|
+
if (!e.isLoading && e.checkoutProfile) try {
|
|
1086
|
+
if (e.checkoutProfile.styles?.fontFamily) try {
|
|
1087
|
+
let { cleanup: t } = _({ fontFamily: e.checkoutProfile.styles.fontFamily });
|
|
1088
|
+
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
1089
|
+
} catch (e) {
|
|
1090
|
+
console.error("Error loading Google Font:", e);
|
|
1095
1091
|
}
|
|
1096
|
-
|
|
1092
|
+
this.onProfileLoaded(), this.onLoadingChange(!1);
|
|
1093
|
+
} catch (e) {
|
|
1094
|
+
console.error("Error in profile state change:", e), this.onRenderFailed(e), this.onError("Failed to load checkout profile data"), this.onLoadingChange(!1);
|
|
1097
1095
|
}
|
|
1098
1096
|
};
|
|
1099
1097
|
isFormDisabled() {
|
|
@@ -1101,7 +1099,7 @@ var J = class extends v {
|
|
|
1101
1099
|
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) => {
|
|
1102
1100
|
if (!e) return !0;
|
|
1103
1101
|
let n = t?.country ?? "";
|
|
1104
|
-
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!
|
|
1102
|
+
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!g(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
|
|
1105
1103
|
}, 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);
|
|
1106
1104
|
return s || !m || this.isSubmitting;
|
|
1107
1105
|
}
|
|
@@ -1123,7 +1121,7 @@ var J = class extends v {
|
|
|
1123
1121
|
if (!r?.isTouched || r.isFocused || r.isValid) continue;
|
|
1124
1122
|
let i = r.errors?.[0];
|
|
1125
1123
|
if (!i) continue;
|
|
1126
|
-
let a =
|
|
1124
|
+
let a = ge(n, i.code);
|
|
1127
1125
|
a && (t[n] = e(a));
|
|
1128
1126
|
}
|
|
1129
1127
|
return t;
|
|
@@ -1134,17 +1132,17 @@ var J = class extends v {
|
|
|
1134
1132
|
cleanup() {
|
|
1135
1133
|
this.fontCleanup &&= (this.fontCleanup(), void 0);
|
|
1136
1134
|
}
|
|
1137
|
-
},
|
|
1135
|
+
}, je = class extends b {
|
|
1138
1136
|
titleElement;
|
|
1139
1137
|
constructor(e = {}) {
|
|
1140
1138
|
super("div", ["blur-bg"]);
|
|
1141
|
-
let t =
|
|
1142
|
-
this.titleElement = new
|
|
1139
|
+
let t = M.createDiv(["loader"]);
|
|
1140
|
+
this.titleElement = new b("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1143
1141
|
}
|
|
1144
1142
|
setText(e) {
|
|
1145
1143
|
return this.titleElement.setText(e), this;
|
|
1146
1144
|
}
|
|
1147
|
-
},
|
|
1145
|
+
}, Y = {
|
|
1148
1146
|
street: "",
|
|
1149
1147
|
firstName: "",
|
|
1150
1148
|
lastName: "",
|
|
@@ -1152,7 +1150,7 @@ var J = class extends v {
|
|
|
1152
1150
|
city: "",
|
|
1153
1151
|
zipCode: "",
|
|
1154
1152
|
country: ""
|
|
1155
|
-
},
|
|
1153
|
+
}, X = (e, t) => {
|
|
1156
1154
|
let n = {}, r = `${t}.`;
|
|
1157
1155
|
return Object.keys(e).forEach((t) => {
|
|
1158
1156
|
if (t.startsWith(r)) {
|
|
@@ -1160,7 +1158,7 @@ var J = class extends v {
|
|
|
1160
1158
|
n[i] = e[t];
|
|
1161
1159
|
}
|
|
1162
1160
|
}), n;
|
|
1163
|
-
},
|
|
1161
|
+
}, Me = class {
|
|
1164
1162
|
formElement;
|
|
1165
1163
|
componentManager;
|
|
1166
1164
|
onLoadingStateChange;
|
|
@@ -1172,17 +1170,17 @@ var J = class extends v {
|
|
|
1172
1170
|
this.formElement = e.formElement, this.componentManager = e.componentManager, this.onLoadingStateChange = e.onLoadingStateChange;
|
|
1173
1171
|
}
|
|
1174
1172
|
updateFormUI(e, t) {
|
|
1175
|
-
this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ??
|
|
1173
|
+
this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ?? Y, e.errors.billingAddress ?? {}, X(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? Y, e.errors.shippingAddress ?? {}, X(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
|
|
1176
1174
|
}
|
|
1177
1175
|
setLoadingState(e) {
|
|
1178
1176
|
if (this.onLoadingStateChange) {
|
|
1179
1177
|
this.onLoadingStateChange(e);
|
|
1180
1178
|
return;
|
|
1181
1179
|
}
|
|
1182
|
-
e ? (this.hideSkeleton(), this.formSkeleton = new
|
|
1180
|
+
e ? (this.hideSkeleton(), this.formSkeleton = new J(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
1183
1181
|
}
|
|
1184
1182
|
showSpinner(e) {
|
|
1185
|
-
this.hideSpinner(), this.spinner = new
|
|
1183
|
+
this.hideSpinner(), this.spinner = new je({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
1186
1184
|
}
|
|
1187
1185
|
hideSpinner() {
|
|
1188
1186
|
this.spinner &&= (this.spinner.getElement().remove(), void 0);
|
|
@@ -1199,7 +1197,7 @@ var J = class extends v {
|
|
|
1199
1197
|
cleanup() {
|
|
1200
1198
|
this.spinner &&= (this.spinner.getElement().remove(), void 0), this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0), this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
1201
1199
|
}
|
|
1202
|
-
};
|
|
1200
|
+
}, Z = "phone_number", Ne = "form";
|
|
1203
1201
|
globalThis.navigator.userAgent;
|
|
1204
1202
|
var Q = (e) => ({
|
|
1205
1203
|
street: "",
|
|
@@ -1210,12 +1208,12 @@ var Q = (e) => ({
|
|
|
1210
1208
|
zipCode: "",
|
|
1211
1209
|
country: "",
|
|
1212
1210
|
...e
|
|
1213
|
-
}),
|
|
1211
|
+
}), Pe = class extends b {
|
|
1214
1212
|
options;
|
|
1215
1213
|
formManager = m();
|
|
1216
1214
|
checkoutProfile;
|
|
1217
|
-
translation =
|
|
1218
|
-
focusManager = new
|
|
1215
|
+
translation = ve();
|
|
1216
|
+
focusManager = new be();
|
|
1219
1217
|
componentManager;
|
|
1220
1218
|
eventHandler;
|
|
1221
1219
|
stateCoordinator;
|
|
@@ -1229,7 +1227,7 @@ var Q = (e) => ({
|
|
|
1229
1227
|
constructor(e) {
|
|
1230
1228
|
super("form", ["form-container"]), this.options = e;
|
|
1231
1229
|
let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
|
|
1232
|
-
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new l()), this.checkoutProfile =
|
|
1230
|
+
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new l()), this.checkoutProfile = ee({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Oe({
|
|
1233
1231
|
formElement: this.element,
|
|
1234
1232
|
focusManager: this.focusManager,
|
|
1235
1233
|
translationFunc: this.translation.t,
|
|
@@ -1240,27 +1238,29 @@ var Q = (e) => ({
|
|
|
1240
1238
|
onPaypalSubmit: async () => this.handlePaypalSubmit(),
|
|
1241
1239
|
onApplePaySubmit: async (e) => this.handleApplePaySubmit(e),
|
|
1242
1240
|
onApplePayStartFailed: (e) => this.options.onSubmitOutcome?.(c(e)),
|
|
1241
|
+
onApplePayPaymentDataFailed: (e) => this.options.onSubmitOutcome?.(e),
|
|
1243
1242
|
supportedPaymentMethods: e.supportedPaymentMethods,
|
|
1244
1243
|
paymentId: e.paymentId,
|
|
1245
1244
|
checkoutKey: e.checkoutKey,
|
|
1246
1245
|
checkoutDetails: e.checkoutDetails,
|
|
1247
1246
|
environment: e.environment,
|
|
1248
1247
|
vgsService: this.vgsService
|
|
1249
|
-
}), this.uiManager = new
|
|
1248
|
+
}), this.uiManager = new Me({
|
|
1250
1249
|
formElement: this.element,
|
|
1251
1250
|
componentManager: this.componentManager,
|
|
1252
1251
|
onLoadingStateChange: e.onLoadingStateChange
|
|
1253
|
-
}), this.stateCoordinator = new
|
|
1252
|
+
}), this.stateCoordinator = new Ae({
|
|
1254
1253
|
formManager: this.formManager,
|
|
1255
1254
|
checkoutProfile: this.checkoutProfile,
|
|
1256
1255
|
componentManager: this.componentManager,
|
|
1257
1256
|
formElement: this.element,
|
|
1258
1257
|
onUIUpdate: () => this.updateFormUI(),
|
|
1259
1258
|
onProfileLoaded: () => this.renderFormComponents(),
|
|
1259
|
+
onRenderFailed: (e) => this.reportRenderFailure(Ne, e),
|
|
1260
1260
|
onError: (e) => this.uiManager.setErrorMessage(e),
|
|
1261
1261
|
onLoadingChange: (e) => this.uiManager.setLoadingState(e),
|
|
1262
1262
|
getInitialFormData: () => this._getFormStateData().formData
|
|
1263
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
1263
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new ke({
|
|
1264
1264
|
formManager: this.formManager,
|
|
1265
1265
|
focusManager: this.focusManager,
|
|
1266
1266
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -1295,7 +1295,7 @@ var Q = (e) => ({
|
|
|
1295
1295
|
}
|
|
1296
1296
|
initializeForm() {
|
|
1297
1297
|
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) {
|
|
1298
|
-
this.failCardCaptureClosed(
|
|
1298
|
+
this.failCardCaptureClosed(C.NO_TOKENIZATION_SESSION);
|
|
1299
1299
|
return;
|
|
1300
1300
|
}
|
|
1301
1301
|
if (this.vgsService) {
|
|
@@ -1303,7 +1303,7 @@ var Q = (e) => ({
|
|
|
1303
1303
|
e.init(this.options.environment).then((t) => {
|
|
1304
1304
|
this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
|
|
1305
1305
|
}).catch((t) => {
|
|
1306
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1306
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(C.INIT_FAILED));
|
|
1307
1307
|
});
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
@@ -1317,7 +1317,7 @@ var Q = (e) => ({
|
|
|
1317
1317
|
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), this.reportLoadOutcome({
|
|
1318
1318
|
status: "failed",
|
|
1319
1319
|
reason: e
|
|
1320
|
-
}), t ||
|
|
1320
|
+
}), t || R(T.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
|
|
1321
1321
|
}
|
|
1322
1322
|
dropVgsService() {
|
|
1323
1323
|
let e = this.vgsService;
|
|
@@ -1336,7 +1336,7 @@ var Q = (e) => ({
|
|
|
1336
1336
|
phoneNumber: "",
|
|
1337
1337
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1338
1338
|
}), 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() });
|
|
1339
|
-
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i =
|
|
1339
|
+
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = xe(e.checkoutProfile.layout);
|
|
1340
1340
|
try {
|
|
1341
1341
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
1342
1342
|
} catch (e) {
|
|
@@ -1359,27 +1359,28 @@ var Q = (e) => ({
|
|
|
1359
1359
|
console.error("Failed to create shipping address section:", e), this.reportRenderFailure("shipping_address");
|
|
1360
1360
|
}
|
|
1361
1361
|
}
|
|
1362
|
+
let a;
|
|
1362
1363
|
if (e.checkoutProfile.layout.phoneNumber?.enabled) try {
|
|
1363
|
-
this.componentManager.createPhoneNumberField(e.checkoutProfile, t, n, r);
|
|
1364
|
+
a = this.componentManager.createPhoneNumberField(e.checkoutProfile, t, n, r).catch((e) => (this.reportRenderFailure(Z, e), !1));
|
|
1364
1365
|
} catch (e) {
|
|
1365
|
-
console.error("Failed to create phone number field:", e), this.reportRenderFailure(
|
|
1366
|
+
console.error("Failed to create phone number field:", e), this.reportRenderFailure(Z, e), a = Promise.resolve(!1);
|
|
1366
1367
|
}
|
|
1367
1368
|
try {
|
|
1368
1369
|
this.componentManager.createCardSection(e.checkoutProfile);
|
|
1369
1370
|
} catch (e) {
|
|
1370
1371
|
console.error("Failed to create card section:", e), this.reportRenderFailure("card_section");
|
|
1371
1372
|
}
|
|
1372
|
-
if (!
|
|
1373
|
+
if (!K(e.checkoutProfile.layout) && this.componentManager.isCardSupported()) try {
|
|
1373
1374
|
this.componentManager.createCardholderSection(e.checkoutProfile, t, n, r);
|
|
1374
1375
|
} catch (e) {
|
|
1375
1376
|
console.error("Failed to create cardholder section:", e), this.reportRenderFailure("cardholder");
|
|
1376
1377
|
}
|
|
1377
1378
|
if (this.vgsService) {
|
|
1378
1379
|
let t = this.vgsService, n = ++this.vgsMountGeneration;
|
|
1379
|
-
this.componentManager.mountVgsFields(e.checkoutProfile).then((e) => {
|
|
1380
|
-
e && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
|
|
1380
|
+
this.componentManager.mountVgsFields(e.checkoutProfile).then(async (e) => {
|
|
1381
|
+
e && this.vgsMountGeneration === n && this.vgsService === t && (!a || await a) && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
|
|
1381
1382
|
}).catch((e) => {
|
|
1382
|
-
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(
|
|
1383
|
+
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(C.FIELDS_NOT_READY));
|
|
1383
1384
|
});
|
|
1384
1385
|
}
|
|
1385
1386
|
try {
|
|
@@ -1387,13 +1388,18 @@ var Q = (e) => ({
|
|
|
1387
1388
|
} catch (e) {
|
|
1388
1389
|
console.error("Failed to create submit button:", e), this.reportRenderFailure("submit_button");
|
|
1389
1390
|
}
|
|
1390
|
-
this.options.checkoutDetails && !this.componentManager.isCardSupported() &&
|
|
1391
|
+
this.options.checkoutDetails && !this.componentManager.isCardSupported() && (a ? a.then((e) => {
|
|
1392
|
+
e && this.reportLoadOutcome({ status: "ready" });
|
|
1393
|
+
}) : this.reportLoadOutcome({ status: "ready" }));
|
|
1391
1394
|
}
|
|
1392
|
-
reportRenderFailure(e) {
|
|
1395
|
+
reportRenderFailure(e, t) {
|
|
1393
1396
|
this.reportLoadOutcome({
|
|
1394
1397
|
status: "failed",
|
|
1395
|
-
reason:
|
|
1396
|
-
attributes: {
|
|
1398
|
+
reason: F.FORM_RENDER_FAILED,
|
|
1399
|
+
attributes: {
|
|
1400
|
+
form_part: e,
|
|
1401
|
+
...t !== void 0 && { error_class: se(t) }
|
|
1402
|
+
}
|
|
1397
1403
|
});
|
|
1398
1404
|
}
|
|
1399
1405
|
reportLoadOutcome(e) {
|
|
@@ -1405,7 +1411,7 @@ var Q = (e) => ({
|
|
|
1405
1411
|
}
|
|
1406
1412
|
inferCardholderName() {
|
|
1407
1413
|
let e = this.checkoutProfile.getState();
|
|
1408
|
-
if (!e.checkoutProfile || !
|
|
1414
|
+
if (!e.checkoutProfile || !K(e.checkoutProfile.layout)) return;
|
|
1409
1415
|
let { formData: t } = this._getFormStateData(), n = t.billingAddress ?? t.shippingAddress;
|
|
1410
1416
|
if (!n) return;
|
|
1411
1417
|
let r = [n.firstName?.trim() ?? "", n.lastName?.trim() ?? ""].filter(Boolean).join(" ");
|
|
@@ -1425,13 +1431,13 @@ var Q = (e) => ({
|
|
|
1425
1431
|
async handleSubmit() {
|
|
1426
1432
|
if (!this.stateCoordinator.isFormDisabled()) try {
|
|
1427
1433
|
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) {
|
|
1428
|
-
this.options.onSubmitOutcome?.(
|
|
1434
|
+
this.options.onSubmitOutcome?.(v(h(/* @__PURE__ */ Error("Card capture unavailable"), _e.CAPTURE_UNAVAILABLE), "card")), this.handleSubmitError(this.translation.t("cardUnavailable"));
|
|
1429
1435
|
return;
|
|
1430
1436
|
}
|
|
1431
1437
|
try {
|
|
1432
1438
|
this.vgsCardResult = await this.vgsService.createCard(this.vgsJwt);
|
|
1433
1439
|
} catch (e) {
|
|
1434
|
-
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(
|
|
1440
|
+
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(v(e, "card")), this.handleSubmitError("Card processing failed. Please check your card details and try again.");
|
|
1435
1441
|
return;
|
|
1436
1442
|
}
|
|
1437
1443
|
let e = this.formManager.getFormState().formData;
|
|
@@ -1492,17 +1498,17 @@ var Q = (e) => ({
|
|
|
1492
1498
|
this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
|
|
1493
1499
|
this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
|
|
1494
1500
|
}).catch((t) => {
|
|
1495
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1501
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(C.INIT_FAILED));
|
|
1496
1502
|
});
|
|
1497
1503
|
}
|
|
1498
|
-
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(
|
|
1504
|
+
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(C.NO_TOKENIZATION_SESSION);
|
|
1499
1505
|
let o = this.checkoutProfile.getState();
|
|
1500
1506
|
if (o.checkoutProfile) {
|
|
1501
1507
|
let { formData: e } = this._getFormStateData();
|
|
1502
1508
|
this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
|
|
1503
1509
|
}
|
|
1504
1510
|
}
|
|
1505
|
-
},
|
|
1511
|
+
}, Fe = class {
|
|
1506
1512
|
container = null;
|
|
1507
1513
|
options;
|
|
1508
1514
|
onSubmit;
|
|
@@ -1526,7 +1532,7 @@ var Q = (e) => ({
|
|
|
1526
1532
|
}
|
|
1527
1533
|
}
|
|
1528
1534
|
renderForm(e) {
|
|
1529
|
-
this.container && (this.form &&= (this.form.destroy(), null), this.form = new
|
|
1535
|
+
this.container && (this.form &&= (this.form.destroy(), null), this.form = new Pe({
|
|
1530
1536
|
apiKey: this.options.apiKey,
|
|
1531
1537
|
onSubmit: this.onSubmit,
|
|
1532
1538
|
locale: this.options.locale,
|
|
@@ -1558,7 +1564,7 @@ var Q = (e) => ({
|
|
|
1558
1564
|
async associatePayment(e, t, n, r, i) {
|
|
1559
1565
|
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);
|
|
1560
1566
|
}
|
|
1561
|
-
},
|
|
1567
|
+
}, Ie = class {
|
|
1562
1568
|
state;
|
|
1563
1569
|
listeners = /* @__PURE__ */ new Set();
|
|
1564
1570
|
constructor(e) {
|
|
@@ -1582,7 +1588,7 @@ var Q = (e) => ({
|
|
|
1582
1588
|
let e = this.getState();
|
|
1583
1589
|
this.listeners.forEach((t) => t(e));
|
|
1584
1590
|
}
|
|
1585
|
-
},
|
|
1591
|
+
}, Le = "en", $ = class {
|
|
1586
1592
|
config;
|
|
1587
1593
|
_callbacks;
|
|
1588
1594
|
paymentState;
|
|
@@ -1590,17 +1596,17 @@ var Q = (e) => ({
|
|
|
1590
1596
|
formManager;
|
|
1591
1597
|
stateManager;
|
|
1592
1598
|
sessionId;
|
|
1593
|
-
readiness = new
|
|
1599
|
+
readiness = new te();
|
|
1594
1600
|
associationSequence = 0;
|
|
1595
1601
|
constructor(e) {
|
|
1596
|
-
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), a(),
|
|
1602
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), a(), he({
|
|
1597
1603
|
environment: this.config.environment,
|
|
1598
1604
|
sessionId: this.sessionId,
|
|
1599
1605
|
integration: "dropin"
|
|
1600
|
-
}),
|
|
1606
|
+
}), R(T.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new t(this.config.apiKey, this.config.environment), this.stateManager = new Ie({
|
|
1601
1607
|
mounted: !1,
|
|
1602
1608
|
form: null
|
|
1603
|
-
}), this.formManager = new
|
|
1609
|
+
}), this.formManager = new Fe({
|
|
1604
1610
|
locale: this.config.locale,
|
|
1605
1611
|
apiKey: this.config.apiKey,
|
|
1606
1612
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
@@ -1621,7 +1627,7 @@ var Q = (e) => ({
|
|
|
1621
1627
|
apiKey: e.apiKey,
|
|
1622
1628
|
returnUrl: e.returnUrl,
|
|
1623
1629
|
environment: e.environment,
|
|
1624
|
-
locale: e.locale ||
|
|
1630
|
+
locale: e.locale || Le,
|
|
1625
1631
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1626
1632
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1627
1633
|
appearance: e.appearance,
|
|
@@ -1642,15 +1648,15 @@ var Q = (e) => ({
|
|
|
1642
1648
|
return n = !0, t = document.createElement("div"), r.appendChild(t), this.stateManager.updateState({
|
|
1643
1649
|
form: t,
|
|
1644
1650
|
mounted: !0
|
|
1645
|
-
}), this.formManager.mount(t), this.readiness.markMounted(),
|
|
1651
|
+
}), this.formManager.mount(t), this.readiness.markMounted(), R(T.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1646
1652
|
} catch (r) {
|
|
1647
1653
|
throw t?.remove(), this.stateManager.updateState({
|
|
1648
1654
|
form: null,
|
|
1649
1655
|
mounted: !1
|
|
1650
|
-
}),
|
|
1656
|
+
}), R(T.CHECKOUT_MOUNT_FAILED, {
|
|
1651
1657
|
container_id: e,
|
|
1652
1658
|
error_message: r instanceof Error ? r.message : "Unknown error"
|
|
1653
|
-
}),
|
|
1659
|
+
}), P(r instanceof Error ? r : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n ? this.readiness.fail({ reason: F.MOUNT_FAILED }) : this.readiness.exclude({ reason: F.CONTAINER_NOT_FOUND }), r;
|
|
1654
1660
|
}
|
|
1655
1661
|
}
|
|
1656
1662
|
unmount() {
|
|
@@ -1661,13 +1667,13 @@ var Q = (e) => ({
|
|
|
1661
1667
|
e && e.remove(), this.stateManager.updateState({
|
|
1662
1668
|
form: null,
|
|
1663
1669
|
mounted: !1
|
|
1664
|
-
}),
|
|
1670
|
+
}), R(T.CHECKOUT_UNMOUNTED);
|
|
1665
1671
|
});
|
|
1666
1672
|
}
|
|
1667
1673
|
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1668
1674
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1669
1675
|
let n = this.getPaymentMethod(e, t);
|
|
1670
|
-
|
|
1676
|
+
R(T.PAYMENT_SUBMIT_STARTED, {
|
|
1671
1677
|
payment_id: this.paymentState.paymentId,
|
|
1672
1678
|
payment_method: n
|
|
1673
1679
|
});
|
|
@@ -1681,46 +1687,46 @@ var Q = (e) => ({
|
|
|
1681
1687
|
applePayData: t
|
|
1682
1688
|
});
|
|
1683
1689
|
this.readiness.reportSubmit({
|
|
1684
|
-
outcome:
|
|
1690
|
+
outcome: ie.SUCCEEDED,
|
|
1685
1691
|
paymentMethod: n
|
|
1686
1692
|
});
|
|
1687
1693
|
let a = performance.now() - r;
|
|
1688
|
-
return
|
|
1694
|
+
return y(N.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
|
|
1689
1695
|
payment_id: this.paymentState.paymentId,
|
|
1690
1696
|
payment_method: n,
|
|
1691
1697
|
status: "success"
|
|
1692
|
-
}),
|
|
1698
|
+
}), R(T.PAYMENT_SUBMIT_SUCCESS, {
|
|
1693
1699
|
payment_id: this.paymentState.paymentId,
|
|
1694
1700
|
payment_method: n
|
|
1695
1701
|
}), this.handlePaymentResponse(i);
|
|
1696
1702
|
} catch (e) {
|
|
1697
1703
|
let t = performance.now() - r;
|
|
1698
|
-
return
|
|
1704
|
+
return y(N.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1699
1705
|
payment_id: this.paymentState.paymentId,
|
|
1700
1706
|
payment_method: n,
|
|
1701
1707
|
status: "failed"
|
|
1702
|
-
}),
|
|
1708
|
+
}), R(T.PAYMENT_SUBMIT_FAILED, {
|
|
1703
1709
|
payment_id: this.paymentState.paymentId,
|
|
1704
1710
|
payment_method: n,
|
|
1705
1711
|
error_message: e.details?.message ?? "Unknown error",
|
|
1706
|
-
...
|
|
1707
|
-
}), this.readiness.reportSubmit(
|
|
1712
|
+
...B(e)
|
|
1713
|
+
}), this.readiness.reportSubmit(ne(e, n)), this.handleAuthorizationError(e), !1;
|
|
1708
1714
|
}
|
|
1709
1715
|
}
|
|
1710
1716
|
handlePaymentResponse(e) {
|
|
1711
1717
|
let t = !1;
|
|
1712
|
-
if (e.latestTransaction.status === "authorized" && (
|
|
1718
|
+
if (e.latestTransaction.status === "authorized" && (R(T.PAYMENT_AUTHORIZED, {
|
|
1713
1719
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1714
1720
|
status: e.latestTransaction.status
|
|
1715
|
-
}),
|
|
1721
|
+
}), j(() => this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status)), t = !0), e.latestTransaction.status === "failed" && (R(T.PAYMENT_FAILED, {
|
|
1716
1722
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1717
1723
|
status: e.latestTransaction.status
|
|
1718
|
-
}),
|
|
1724
|
+
}), j(() => this._callbacks.onPaymentFailed?.(e.latestTransaction.status))), e.status === "requires_action") {
|
|
1719
1725
|
let { redirectUrl: n } = e.action;
|
|
1720
|
-
|
|
1726
|
+
R(T.PAYMENT_ACTION_REQUIRED, {
|
|
1721
1727
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1722
1728
|
status: e.status
|
|
1723
|
-
}), this.config.manualActionHandling ?
|
|
1729
|
+
}), this.config.manualActionHandling ? j(() => this._callbacks.onActionRequired?.(n)) : globalThis.location.href = n, t = !0;
|
|
1724
1730
|
}
|
|
1725
1731
|
return t;
|
|
1726
1732
|
}
|
|
@@ -1754,35 +1760,35 @@ var Q = (e) => ({
|
|
|
1754
1760
|
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
1755
1761
|
let n = ++this.associationSequence;
|
|
1756
1762
|
this.readiness.start(e), this.paymentState.paymentId = e, this.paymentState.checkoutKey = t, I(this.config.environment);
|
|
1757
|
-
let r =
|
|
1763
|
+
let r = E.CHECKOUT_DETAILS;
|
|
1758
1764
|
try {
|
|
1759
|
-
let i = await
|
|
1765
|
+
let i = await pe({
|
|
1760
1766
|
id: e,
|
|
1761
1767
|
checkoutKey: t,
|
|
1762
1768
|
environment: this.config.environment
|
|
1763
1769
|
});
|
|
1764
|
-
if (!i || !i.supportedPaymentMethods || !Array.isArray(i.supportedPaymentMethods)) throw
|
|
1765
|
-
if (!i.supportedPaymentMethods.every((e) => typeof e == "string")) throw
|
|
1770
|
+
if (!i || !i.supportedPaymentMethods || !Array.isArray(i.supportedPaymentMethods)) throw V(/* @__PURE__ */ Error("Invalid response: supportedPaymentMethods must be an array"), O.INVALID_RESPONSE, x(i));
|
|
1771
|
+
if (!i.supportedPaymentMethods.every((e) => typeof e == "string")) throw V(/* @__PURE__ */ Error("Invalid response: all supportedPaymentMethods must be strings"), O.INVALID_RESPONSE, x(i));
|
|
1766
1772
|
if (n !== this.associationSequence) return;
|
|
1767
|
-
r =
|
|
1773
|
+
r = E.FORM_SETUP, this.readiness.markAssociated(), this.paymentState.checkoutDetails = {
|
|
1768
1774
|
amount: i.amount,
|
|
1769
1775
|
currency: i.currency,
|
|
1770
1776
|
countryCode: i.countryCode
|
|
1771
1777
|
};
|
|
1772
1778
|
let a = i.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
|
|
1773
|
-
await this.formManager.associatePayment(e, t, a, this.paymentState.checkoutDetails, i.vgsJwt),
|
|
1779
|
+
await this.formManager.associatePayment(e, t, a, this.paymentState.checkoutDetails, i.vgsJwt), R(T.PAYMENT_ASSOCIATED, {
|
|
1774
1780
|
payment_id: e,
|
|
1775
1781
|
currency: i.currency,
|
|
1776
1782
|
country_code: i.countryCode
|
|
1777
1783
|
});
|
|
1778
1784
|
} catch (t) {
|
|
1779
|
-
if (
|
|
1785
|
+
if (R(T.PAYMENT_ASSOCIATION_FAILED, {
|
|
1780
1786
|
payment_id: e,
|
|
1781
1787
|
error_message: t instanceof Error ? t.message : "Unknown error",
|
|
1782
1788
|
stage: r,
|
|
1783
|
-
...
|
|
1784
|
-
}),
|
|
1785
|
-
let { ours: e, ...n } =
|
|
1789
|
+
...B(t)
|
|
1790
|
+
}), P(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), n === this.associationSequence) {
|
|
1791
|
+
let { ours: e, ...n } = re(t, r);
|
|
1786
1792
|
e ? this.readiness.fail(n) : this.readiness.exclude(n);
|
|
1787
1793
|
}
|
|
1788
1794
|
throw t;
|
|
@@ -1796,4 +1802,4 @@ var Q = (e) => ({
|
|
|
1796
1802
|
//#region libs/checkout/src/index.ts
|
|
1797
1803
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1798
1804
|
//#endregion
|
|
1799
|
-
export { $ as OdusCheckout, f as deLocale, d as enLocale,
|
|
1805
|
+
export { $ as OdusCheckout, f as deLocale, d as enLocale, k as esLocale, e as frLocale, ue as itLocale, p as plLocale, n as ptLocale, P as pushError, R as pushEvent, le as pushLog, y as pushMeasurement, r as trLocale };
|