@odus/checkout 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/getCheckoutDetails.query.d.ts.map +1 -1
- package/dist/checkout.es.js +210 -167
- package/dist/components/checkout/form/Form.d.ts +17 -0
- package/dist/components/checkout/form/Form.d.ts.map +1 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts +6 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
- package/dist/components/checkout/form/PaymentMethods.d.ts +2 -0
- package/dist/components/checkout/form/PaymentMethods.d.ts.map +1 -1
- package/dist/components/payment-methods/applePay/ApplePayButton.d.ts +5 -0
- package/dist/components/payment-methods/applePay/ApplePayButton.d.ts.map +1 -1
- package/dist/core/api/CheckoutAPI.service.d.ts.map +1 -1
- package/dist/core/vgs/VGSCollectService.d.ts +6 -0
- package/dist/core/vgs/VGSCollectService.d.ts.map +1 -1
- package/dist/core/vgs/vgsCsp.d.ts +17 -0
- package/dist/core/vgs/vgsCsp.d.ts.map +1 -0
- package/dist/elements/ApplePayElement.d.ts +3 -0
- package/dist/elements/ApplePayElement.d.ts.map +1 -1
- package/dist/elements/BaseElement.d.ts +15 -0
- package/dist/elements/BaseElement.d.ts.map +1 -1
- package/dist/elements/CardElement.d.ts +10 -3
- package/dist/elements/CardElement.d.ts.map +1 -1
- package/dist/elements/OdusElements.d.ts +9 -0
- package/dist/elements/OdusElements.d.ts.map +1 -1
- package/dist/elements/card/VgsCardAdapter.d.ts +2 -0
- package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
- package/dist/elements.es.js +304 -248
- package/dist/phone.js +10 -14
- package/dist/services/checkout/Checkout.service.d.ts +2 -0
- package/dist/services/checkout/Checkout.service.d.ts.map +1 -1
- package/dist/services/checkout/CheckoutForm.service.d.ts +3 -0
- package/dist/services/checkout/CheckoutForm.service.d.ts.map +1 -1
- package/dist/services/telemetry/CheckoutReadiness.service.d.ts +88 -0
- package/dist/services/telemetry/CheckoutReadiness.service.d.ts.map +1 -0
- package/dist/services/telemetry/Telemetry.service.d.ts +6 -0
- package/dist/services/telemetry/Telemetry.service.d.ts.map +1 -1
- package/dist/shared.js +1335 -1026
- package/dist/types/api/ApiError.type.d.ts +3 -0
- package/dist/types/api/ApiError.type.d.ts.map +1 -1
- package/dist/types/telemetry/TelemetryEvents.type.d.ts +189 -1
- package/dist/types/telemetry/TelemetryEvents.type.d.ts.map +1 -1
- package/dist/utils/helpers/failureCause.util.d.ts +24 -0
- package/dist/utils/helpers/failureCause.util.d.ts.map +1 -0
- package/dist/utils/helpers/stageFailure.util.d.ts +35 -0
- package/dist/utils/helpers/stageFailure.util.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/checkout.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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 ee, R as h, S as te, V as ne, W as re, X as ie, Y as ae, Z as g, _t as oe, a as se, at as _, b as v, c as ce, ct as y, d as b, dt as x, et as le, f as S, ft as C, g as ue, gt as de, h as w, ht as T, it as E, j as D, k as O, l as k, lt as A, m as j, mt as M, n as fe, nt as N, o as pe, ot as P, pt as F, q as I, r as L, rt as R, s as z, st as B, t as me, tt as V, u as he, ut as H, v as U, w as ge, x as _e, y as W, z as G } from "./shared.js";
|
|
2
|
+
import { t as K } from "./shared2.js";
|
|
3
3
|
//#region libs/checkout/src/utils/focus/FocusManager.ts
|
|
4
|
-
var
|
|
4
|
+
var ve = class {
|
|
5
5
|
focusSequence = [
|
|
6
6
|
"cardNumber",
|
|
7
7
|
"cardExpiry",
|
|
@@ -81,19 +81,19 @@ var U = class {
|
|
|
81
81
|
};
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
|
|
84
|
-
function
|
|
84
|
+
function ye(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 q(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 J = class extends v {
|
|
97
97
|
inputs = /* @__PURE__ */ new Map();
|
|
98
98
|
type;
|
|
99
99
|
onChange;
|
|
@@ -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 w({
|
|
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"), h(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 S({
|
|
209
209
|
name: c,
|
|
210
210
|
error: !1,
|
|
211
211
|
errorMsg: void 0,
|
|
@@ -227,7 +227,7 @@ var K = class extends C {
|
|
|
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(K({
|
|
231
231
|
type: "input",
|
|
232
232
|
target: {
|
|
233
233
|
name: c,
|
|
@@ -237,7 +237,7 @@ var K = class extends C {
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
return l.addEventListener("blur", (e) => {
|
|
240
|
-
this.onBlur(
|
|
240
|
+
this.onBlur(K({
|
|
241
241
|
type: "blur",
|
|
242
242
|
target: {
|
|
243
243
|
name: c,
|
|
@@ -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 = ue(i, this.locale), c = new b({
|
|
251
251
|
name: o,
|
|
252
252
|
error: !1,
|
|
253
253
|
errorMsg: void 0,
|
|
@@ -261,7 +261,7 @@ var K = class extends C {
|
|
|
261
261
|
onChange: (e) => {
|
|
262
262
|
this.applyFieldError("country", !1);
|
|
263
263
|
let t = e.target.value;
|
|
264
|
-
this.onChange(
|
|
264
|
+
this.onChange(K({
|
|
265
265
|
type: "change",
|
|
266
266
|
target: {
|
|
267
267
|
name: o,
|
|
@@ -271,7 +271,7 @@ var K = class extends C {
|
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
return c.addEventListener("blur", (e) => {
|
|
274
|
-
this.onBlur(
|
|
274
|
+
this.onBlur(K({
|
|
275
275
|
type: "blur",
|
|
276
276
|
target: {
|
|
277
277
|
name: o,
|
|
@@ -289,11 +289,11 @@ var K = class extends C {
|
|
|
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 b, a = h(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 b) {
|
|
296
|
+
let n = G(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 K = class extends C {
|
|
|
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")), h(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 K = class extends C {
|
|
|
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(K({
|
|
325
325
|
type: "input",
|
|
326
326
|
target: {
|
|
327
327
|
name: t,
|
|
@@ -331,19 +331,19 @@ var K = class extends C {
|
|
|
331
331
|
}));
|
|
332
332
|
}
|
|
333
333
|
createStateSelect(e, t, n, r, i, a) {
|
|
334
|
-
let o = `${this.type}Address.state`,
|
|
334
|
+
let o = `${this.type}Address.state`, c = G(i), l = s(c), d = this.translationFunc(u(c)), f = new b({
|
|
335
335
|
name: o,
|
|
336
336
|
error: !1,
|
|
337
337
|
errorMsg: void 0,
|
|
338
338
|
styles: r,
|
|
339
|
-
placeholder:
|
|
339
|
+
placeholder: d,
|
|
340
340
|
renderMessage: !this.grouped,
|
|
341
|
-
...!this.grouped && { label: a ??
|
|
341
|
+
...!this.grouped && { label: a ?? d },
|
|
342
342
|
value: e,
|
|
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(K({
|
|
347
347
|
type: "change",
|
|
348
348
|
target: {
|
|
349
349
|
name: o,
|
|
@@ -353,7 +353,7 @@ var K = class extends C {
|
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
return f.addEventListener("blur", (e) => {
|
|
356
|
-
this.onBlur(
|
|
356
|
+
this.onBlur(K({
|
|
357
357
|
type: "blur",
|
|
358
358
|
target: {
|
|
359
359
|
name: o,
|
|
@@ -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 = h(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 K = class extends C {
|
|
|
447
447
|
let e = this.inputs.values().next().value;
|
|
448
448
|
e && e.focus();
|
|
449
449
|
}
|
|
450
|
-
},
|
|
450
|
+
}, be = class {
|
|
451
451
|
input = null;
|
|
452
452
|
isVgsMode;
|
|
453
453
|
vgsWrapper = null;
|
|
@@ -455,7 +455,7 @@ var K = class extends C {
|
|
|
455
455
|
vgsHelperText = null;
|
|
456
456
|
wrapperElement;
|
|
457
457
|
_vgsFieldsReady = !1;
|
|
458
|
-
_fieldHeight =
|
|
458
|
+
_fieldHeight = W(U, 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 K = class extends C {
|
|
|
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 = W(U, 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 w({ 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 S({
|
|
476
476
|
name: "name",
|
|
477
477
|
label: a("cardholderNameLabel"),
|
|
478
478
|
error: !1,
|
|
@@ -499,9 +499,9 @@ var K = class extends C {
|
|
|
499
499
|
}
|
|
500
500
|
handleVgsStateChange(e, t) {
|
|
501
501
|
if (!this.isVgsMode || !this.vgsWrapper) return;
|
|
502
|
-
let n = e[
|
|
502
|
+
let n = e[k.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[k.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 K = class extends C {
|
|
|
543
543
|
focus() {
|
|
544
544
|
this.isVgsMode || this.input?.focus();
|
|
545
545
|
}
|
|
546
|
-
},
|
|
546
|
+
}, Y = class extends v {
|
|
547
547
|
constructor() {
|
|
548
548
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
549
549
|
}
|
|
@@ -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
|
+
}, xe = class extends v {
|
|
562
562
|
constructor(e) {
|
|
563
563
|
let { translationFunc: t, checkoutProfile: n } = e;
|
|
564
564
|
super("div", ["payment-separator"]);
|
|
@@ -569,32 +569,32 @@ 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
|
+
}, Se = class extends v {
|
|
573
573
|
paymentMethods;
|
|
574
574
|
paymentSeparator;
|
|
575
575
|
skeleton;
|
|
576
576
|
constructor(e) {
|
|
577
|
-
let { checkoutProfile: t, formData: n, onPaypalSubmit: r, onApplePaySubmit: i,
|
|
577
|
+
let { checkoutProfile: t, formData: n, onPaypalSubmit: r, onApplePaySubmit: i, onApplePayStartFailed: a, supportedPaymentMethods: o, translationFunc: s, paymentId: c, checkoutKey: l, checkoutDetails: u, environment: d, countryCode: f } = 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 (o === void 0) {
|
|
583
583
|
this.renderSkeleton();
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
let
|
|
587
|
-
let n = t.enabled, r = !
|
|
586
|
+
let p = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
|
|
587
|
+
let n = t.enabled, r = !o || o[e] === !0, i = se(t.countries, f);
|
|
588
588
|
return n && r && i;
|
|
589
589
|
}).sort((e, t) => e[1].order - t[1].order);
|
|
590
|
-
if (
|
|
590
|
+
if (p.length === 0) {
|
|
591
591
|
this.getElement().style.display = "none";
|
|
592
592
|
return;
|
|
593
593
|
}
|
|
594
|
-
for (let [e] of
|
|
594
|
+
for (let [e] of p) switch (e) {
|
|
595
595
|
case "paypal":
|
|
596
596
|
if (r) {
|
|
597
|
-
let e = new
|
|
597
|
+
let e = new fe({
|
|
598
598
|
checkoutProfile: t,
|
|
599
599
|
formData: n,
|
|
600
600
|
onSubmit: r
|
|
@@ -603,15 +603,16 @@ var K = class extends C {
|
|
|
603
603
|
}
|
|
604
604
|
break;
|
|
605
605
|
case "applePay":
|
|
606
|
-
if (i &&
|
|
607
|
-
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new
|
|
606
|
+
if (i && c && l) {
|
|
607
|
+
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new L({
|
|
608
608
|
checkoutProfile: t,
|
|
609
609
|
formData: n,
|
|
610
610
|
onSubmit: i,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
611
|
+
onStartFailed: a,
|
|
612
|
+
paymentId: c,
|
|
613
|
+
checkoutKey: l,
|
|
614
|
+
checkoutDetails: u,
|
|
615
|
+
environment: d,
|
|
615
616
|
displayName: e?.displayName,
|
|
616
617
|
requiredBillingContactFields: e?.requiredBillingContactFields,
|
|
617
618
|
requiredShippingContactFields: e?.requiredShippingContactFields
|
|
@@ -621,13 +622,13 @@ var K = class extends C {
|
|
|
621
622
|
break;
|
|
622
623
|
default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
|
|
623
624
|
}
|
|
624
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
625
|
-
translationFunc:
|
|
625
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new xe({
|
|
626
|
+
translationFunc: s,
|
|
626
627
|
checkoutProfile: t
|
|
627
628
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
628
629
|
}
|
|
629
630
|
renderSkeleton() {
|
|
630
|
-
this.skeleton = new
|
|
631
|
+
this.skeleton = new Y(), this.getElement().appendChild(this.skeleton.getElement());
|
|
631
632
|
}
|
|
632
633
|
updateFormData(e) {
|
|
633
634
|
let t = this.paymentMethods.get("paypal");
|
|
@@ -638,7 +639,7 @@ var K = class extends C {
|
|
|
638
639
|
hasVisiblePaymentMethods() {
|
|
639
640
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
640
641
|
}
|
|
641
|
-
},
|
|
642
|
+
}, Ce = 17, we = class extends v {
|
|
642
643
|
styles;
|
|
643
644
|
isHovered = !1;
|
|
644
645
|
constructor(e) {
|
|
@@ -646,7 +647,7 @@ var K = class extends C {
|
|
|
646
647
|
}
|
|
647
648
|
applyStyles() {
|
|
648
649
|
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 ===
|
|
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 === Ce ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
650
651
|
}
|
|
651
652
|
handleMouseEnter() {
|
|
652
653
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -657,11 +658,11 @@ var K = class extends C {
|
|
|
657
658
|
setDisabled(e) {
|
|
658
659
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
659
660
|
}
|
|
660
|
-
},
|
|
661
|
+
}, Te = class {
|
|
661
662
|
button;
|
|
662
663
|
constructor(e) {
|
|
663
664
|
let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
|
|
664
|
-
this.button = new
|
|
665
|
+
this.button = new we({
|
|
665
666
|
text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
|
|
666
667
|
styles: {
|
|
667
668
|
backgroundColor: n.styles.buttonColor,
|
|
@@ -685,7 +686,7 @@ var K = class extends C {
|
|
|
685
686
|
appendTo(e) {
|
|
686
687
|
return this.button.appendTo(e), this;
|
|
687
688
|
}
|
|
688
|
-
},
|
|
689
|
+
}, Ee = class {
|
|
689
690
|
formElement;
|
|
690
691
|
focusManager;
|
|
691
692
|
translationFunc;
|
|
@@ -695,6 +696,7 @@ var K = class extends C {
|
|
|
695
696
|
onBlur;
|
|
696
697
|
onPaypalSubmit;
|
|
697
698
|
onApplePaySubmit;
|
|
699
|
+
onApplePayStartFailed;
|
|
698
700
|
supportedPaymentMethods;
|
|
699
701
|
paymentId;
|
|
700
702
|
checkoutKey;
|
|
@@ -718,18 +720,19 @@ var K = class extends C {
|
|
|
718
720
|
phoneNumberFocusHandler;
|
|
719
721
|
nameFocusHandler;
|
|
720
722
|
constructor(e) {
|
|
721
|
-
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.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);
|
|
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);
|
|
722
724
|
}
|
|
723
725
|
createPaymentMethods(e, t, n = !1) {
|
|
724
726
|
try {
|
|
725
727
|
if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
|
|
726
|
-
this.removePaymentMethods(), this.paymentMethods = new
|
|
728
|
+
this.removePaymentMethods(), this.paymentMethods = new Se({
|
|
727
729
|
checkoutProfile: e,
|
|
728
730
|
formData: t,
|
|
729
731
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
730
732
|
translationFunc: this.translationFunc,
|
|
731
733
|
onPaypalSubmit: this.onPaypalSubmit,
|
|
732
734
|
onApplePaySubmit: this.onApplePaySubmit,
|
|
735
|
+
onApplePayStartFailed: this.onApplePayStartFailed,
|
|
733
736
|
paymentId: this.paymentId,
|
|
734
737
|
checkoutKey: this.checkoutKey,
|
|
735
738
|
checkoutDetails: this.checkoutDetails,
|
|
@@ -743,7 +746,7 @@ var K = class extends C {
|
|
|
743
746
|
createEmailField(e, t, n, r) {
|
|
744
747
|
try {
|
|
745
748
|
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);
|
|
746
|
-
this.emailField = new
|
|
749
|
+
this.emailField = new pe({
|
|
747
750
|
value: t.email,
|
|
748
751
|
onChange: this.onChange,
|
|
749
752
|
onBlur: this.onBlur,
|
|
@@ -759,7 +762,7 @@ var K = class extends C {
|
|
|
759
762
|
}
|
|
760
763
|
createPhoneNumberField(e, t, n, r) {
|
|
761
764
|
let i = document.createElement("div");
|
|
762
|
-
this.phonePlaceholder = i, this.formElement.appendChild(i),
|
|
765
|
+
this.phonePlaceholder = i, this.formElement.appendChild(i), o().then(({ PhoneNumberField: a }) => {
|
|
763
766
|
i.isConnected && (this.phoneNumberField = new a({
|
|
764
767
|
value: t.phoneNumber ?? "",
|
|
765
768
|
onChange: this.onChange,
|
|
@@ -788,13 +791,13 @@ var K = class extends C {
|
|
|
788
791
|
}
|
|
789
792
|
if (!this.isCardSupported()) return;
|
|
790
793
|
if (!this.vgsService) {
|
|
791
|
-
this.cardUnavailableNotice = new
|
|
794
|
+
this.cardUnavailableNotice = new z({
|
|
792
795
|
checkoutProfile: e,
|
|
793
796
|
translationFunc: this.translationFunc
|
|
794
797
|
}), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
|
|
795
798
|
return;
|
|
796
799
|
}
|
|
797
|
-
this.cardSection = new
|
|
800
|
+
this.cardSection = new ce({
|
|
798
801
|
checkoutProfile: e,
|
|
799
802
|
translationFunc: this.translationFunc,
|
|
800
803
|
vgsService: this.vgsService
|
|
@@ -811,7 +814,7 @@ var K = class extends C {
|
|
|
811
814
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
812
815
|
return;
|
|
813
816
|
}
|
|
814
|
-
if (this.cardholderSection = new
|
|
817
|
+
if (this.cardholderSection = new be({
|
|
815
818
|
value: t.name,
|
|
816
819
|
onChange: this.onChange,
|
|
817
820
|
onBlur: this.onBlur,
|
|
@@ -842,7 +845,7 @@ var K = class extends C {
|
|
|
842
845
|
zipCode: "",
|
|
843
846
|
country: ""
|
|
844
847
|
};
|
|
845
|
-
this.billingAddressSection = new
|
|
848
|
+
this.billingAddressSection = new J({
|
|
846
849
|
type: "billing",
|
|
847
850
|
title: this.translationFunc("address.billingTitle"),
|
|
848
851
|
checkoutProfile: e,
|
|
@@ -873,7 +876,7 @@ var K = class extends C {
|
|
|
873
876
|
zipCode: "",
|
|
874
877
|
country: ""
|
|
875
878
|
};
|
|
876
|
-
this.shippingAddressSection = new
|
|
879
|
+
this.shippingAddressSection = new J({
|
|
877
880
|
type: "shipping",
|
|
878
881
|
title: this.translationFunc("address.shippingTitle"),
|
|
879
882
|
checkoutProfile: e,
|
|
@@ -893,7 +896,7 @@ var K = class extends C {
|
|
|
893
896
|
}
|
|
894
897
|
createSubmitButton(e, t) {
|
|
895
898
|
try {
|
|
896
|
-
this.submitButton = new
|
|
899
|
+
this.submitButton = new Te({
|
|
897
900
|
disabled: t,
|
|
898
901
|
checkoutProfile: e,
|
|
899
902
|
translationFunc: this.translationFunc
|
|
@@ -942,7 +945,7 @@ var K = class extends C {
|
|
|
942
945
|
return !this.supportedPaymentMethods || !!this.supportedPaymentMethods.card;
|
|
943
946
|
}
|
|
944
947
|
buildCardSkeleton(e) {
|
|
945
|
-
let t = e.styles.borderRadius, n =
|
|
948
|
+
let t = e.styles.borderRadius, n = W(U, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
|
|
946
949
|
i.style.marginBottom = "4px";
|
|
947
950
|
let a = document.createElement("label");
|
|
948
951
|
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);
|
|
@@ -971,11 +974,11 @@ var K = class extends C {
|
|
|
971
974
|
let i = document.createElement("label");
|
|
972
975
|
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);
|
|
973
976
|
let a = document.createElement("div");
|
|
974
|
-
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height =
|
|
977
|
+
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = W(U, e.styles.fontSize), a.style.width = "100%", a.style.overflow = "hidden", a.style.background = "#fff", a.appendChild(this.createSkeletonDiv()), n.appendChild(a), n.appendChild(this.createHelperTextSpacer("form-helper-text-anchor")), n;
|
|
975
978
|
}
|
|
976
979
|
async mountVgsFields(e) {
|
|
977
|
-
if (!this.vgsService || !this.cardSection) return;
|
|
978
|
-
let t =
|
|
980
|
+
if (!this.vgsService || !this.cardSection) return !1;
|
|
981
|
+
let t = _e(e.styles.fontFamily);
|
|
979
982
|
await this.vgsService.whenReady();
|
|
980
983
|
let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
|
|
981
984
|
if (this.cardholderSection && a.cardholderName) {
|
|
@@ -984,7 +987,7 @@ var K = class extends C {
|
|
|
984
987
|
let t = e["border-radius"];
|
|
985
988
|
typeof t == "string" && this.cardholderSection.setBorderRadius(parseFloat(t));
|
|
986
989
|
}
|
|
987
|
-
this.vgsService.mountCardFields({
|
|
990
|
+
return this.vgsService.mountCardFields({
|
|
988
991
|
cardNumber: n.cardNumber ? `#${n.cardNumber}` : void 0,
|
|
989
992
|
cardExpiry: n.cardExpiry ? `#${n.cardExpiry}` : void 0,
|
|
990
993
|
cardCvv: n.cardCvv ? `#${n.cardCvv}` : void 0,
|
|
@@ -996,7 +999,7 @@ var K = class extends C {
|
|
|
996
999
|
cardholderName: this.translationFunc("cardholderNamePlaceholder")
|
|
997
1000
|
}, (e) => this.cardSection?.updateVgsCardBrand(e)), await this.vgsService.waitForFieldsReady(), requestAnimationFrame(() => {
|
|
998
1001
|
this.cardSection?.hideFakePlaceholders(), this.cardholderSection?.hideFakePlaceholder();
|
|
999
|
-
});
|
|
1002
|
+
}), !0;
|
|
1000
1003
|
}
|
|
1001
1004
|
handleVgsStateChange(e, t) {
|
|
1002
1005
|
this.cardSection?.handleVgsStateChange(e, t), this.cardholderSection?.handleVgsStateChange(e, t);
|
|
@@ -1016,7 +1019,7 @@ var K = class extends C {
|
|
|
1016
1019
|
}
|
|
1017
1020
|
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);
|
|
1018
1021
|
}
|
|
1019
|
-
},
|
|
1022
|
+
}, De = class {
|
|
1020
1023
|
formManager;
|
|
1021
1024
|
focusManager;
|
|
1022
1025
|
onFormSubmit;
|
|
@@ -1056,7 +1059,7 @@ var K = class extends C {
|
|
|
1056
1059
|
clearTouchedFields() {
|
|
1057
1060
|
this.localTouchedFields.clear();
|
|
1058
1061
|
}
|
|
1059
|
-
},
|
|
1062
|
+
}, Oe = class {
|
|
1060
1063
|
formManager;
|
|
1061
1064
|
checkoutProfile;
|
|
1062
1065
|
formElement;
|
|
@@ -1079,7 +1082,7 @@ var K = class extends C {
|
|
|
1079
1082
|
if (!e.isLoading) {
|
|
1080
1083
|
if (e.checkoutProfile) try {
|
|
1081
1084
|
if (e.checkoutProfile.styles?.fontFamily) try {
|
|
1082
|
-
let { cleanup: t } =
|
|
1085
|
+
let { cleanup: t } = te({ fontFamily: e.checkoutProfile.styles.fontFamily });
|
|
1083
1086
|
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
1084
1087
|
} catch (e) {
|
|
1085
1088
|
console.error("Error loading Google Font:", e);
|
|
@@ -1098,7 +1101,7 @@ var K = class extends C {
|
|
|
1098
1101
|
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) => {
|
|
1099
1102
|
if (!e) return !0;
|
|
1100
1103
|
let n = t?.country ?? "";
|
|
1101
|
-
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!
|
|
1104
|
+
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!h(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
|
|
1102
1105
|
}, 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);
|
|
1103
1106
|
return s || !m || this.isSubmitting;
|
|
1104
1107
|
}
|
|
@@ -1120,7 +1123,7 @@ var K = class extends C {
|
|
|
1120
1123
|
if (!r?.isTouched || r.isFocused || r.isValid) continue;
|
|
1121
1124
|
let i = r.errors?.[0];
|
|
1122
1125
|
if (!i) continue;
|
|
1123
|
-
let a =
|
|
1126
|
+
let a = he(n, i.code);
|
|
1124
1127
|
a && (t[n] = e(a));
|
|
1125
1128
|
}
|
|
1126
1129
|
return t;
|
|
@@ -1131,17 +1134,17 @@ var K = class extends C {
|
|
|
1131
1134
|
cleanup() {
|
|
1132
1135
|
this.fontCleanup &&= (this.fontCleanup(), void 0);
|
|
1133
1136
|
}
|
|
1134
|
-
},
|
|
1137
|
+
}, ke = class extends v {
|
|
1135
1138
|
titleElement;
|
|
1136
1139
|
constructor(e = {}) {
|
|
1137
1140
|
super("div", ["blur-bg"]);
|
|
1138
1141
|
let t = j.createDiv(["loader"]);
|
|
1139
|
-
this.titleElement = new
|
|
1142
|
+
this.titleElement = new v("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1140
1143
|
}
|
|
1141
1144
|
setText(e) {
|
|
1142
1145
|
return this.titleElement.setText(e), this;
|
|
1143
1146
|
}
|
|
1144
|
-
},
|
|
1147
|
+
}, X = {
|
|
1145
1148
|
street: "",
|
|
1146
1149
|
firstName: "",
|
|
1147
1150
|
lastName: "",
|
|
@@ -1149,7 +1152,7 @@ var K = class extends C {
|
|
|
1149
1152
|
city: "",
|
|
1150
1153
|
zipCode: "",
|
|
1151
1154
|
country: ""
|
|
1152
|
-
},
|
|
1155
|
+
}, Z = (e, t) => {
|
|
1153
1156
|
let n = {}, r = `${t}.`;
|
|
1154
1157
|
return Object.keys(e).forEach((t) => {
|
|
1155
1158
|
if (t.startsWith(r)) {
|
|
@@ -1157,11 +1160,11 @@ var K = class extends C {
|
|
|
1157
1160
|
n[i] = e[t];
|
|
1158
1161
|
}
|
|
1159
1162
|
}), n;
|
|
1160
|
-
},
|
|
1163
|
+
}, Ae = class {
|
|
1161
1164
|
formElement;
|
|
1162
1165
|
componentManager;
|
|
1163
1166
|
onLoadingStateChange;
|
|
1164
|
-
validationSchema =
|
|
1167
|
+
validationSchema = i();
|
|
1165
1168
|
spinner;
|
|
1166
1169
|
formSkeleton;
|
|
1167
1170
|
alert;
|
|
@@ -1169,17 +1172,17 @@ var K = class extends C {
|
|
|
1169
1172
|
this.formElement = e.formElement, this.componentManager = e.componentManager, this.onLoadingStateChange = e.onLoadingStateChange;
|
|
1170
1173
|
}
|
|
1171
1174
|
updateFormUI(e, t) {
|
|
1172
|
-
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 ??
|
|
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 ?? X, e.errors.billingAddress ?? {}, Z(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? X, e.errors.shippingAddress ?? {}, Z(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
|
|
1173
1176
|
}
|
|
1174
1177
|
setLoadingState(e) {
|
|
1175
1178
|
if (this.onLoadingStateChange) {
|
|
1176
1179
|
this.onLoadingStateChange(e);
|
|
1177
1180
|
return;
|
|
1178
1181
|
}
|
|
1179
|
-
e ? (this.hideSkeleton(), this.formSkeleton = new
|
|
1182
|
+
e ? (this.hideSkeleton(), this.formSkeleton = new Y(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
1180
1183
|
}
|
|
1181
1184
|
showSpinner(e) {
|
|
1182
|
-
this.hideSpinner(), this.spinner = new
|
|
1185
|
+
this.hideSpinner(), this.spinner = new ke({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
1183
1186
|
}
|
|
1184
1187
|
hideSpinner() {
|
|
1185
1188
|
this.spinner &&= (this.spinner.getElement().remove(), void 0);
|
|
@@ -1188,7 +1191,7 @@ var K = class extends C {
|
|
|
1188
1191
|
this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
|
|
1189
1192
|
}
|
|
1190
1193
|
setErrorMessage(e) {
|
|
1191
|
-
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new
|
|
1194
|
+
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new me({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
|
|
1192
1195
|
}
|
|
1193
1196
|
clearErrorMessage() {
|
|
1194
1197
|
this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
@@ -1207,12 +1210,12 @@ var Q = (e) => ({
|
|
|
1207
1210
|
zipCode: "",
|
|
1208
1211
|
country: "",
|
|
1209
1212
|
...e
|
|
1210
|
-
}),
|
|
1213
|
+
}), je = class extends v {
|
|
1211
1214
|
options;
|
|
1212
|
-
formManager =
|
|
1215
|
+
formManager = m();
|
|
1213
1216
|
checkoutProfile;
|
|
1214
|
-
translation =
|
|
1215
|
-
focusManager = new
|
|
1217
|
+
translation = ge();
|
|
1218
|
+
focusManager = new ve();
|
|
1216
1219
|
componentManager;
|
|
1217
1220
|
eventHandler;
|
|
1218
1221
|
stateCoordinator;
|
|
@@ -1226,7 +1229,7 @@ var Q = (e) => ({
|
|
|
1226
1229
|
constructor(e) {
|
|
1227
1230
|
super("form", ["form-container"]), this.options = e;
|
|
1228
1231
|
let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
|
|
1229
|
-
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new
|
|
1232
|
+
e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new l()), this.checkoutProfile = ne({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Ee({
|
|
1230
1233
|
formElement: this.element,
|
|
1231
1234
|
focusManager: this.focusManager,
|
|
1232
1235
|
translationFunc: this.translation.t,
|
|
@@ -1236,17 +1239,18 @@ var Q = (e) => ({
|
|
|
1236
1239
|
onBlur: (e) => this.eventHandler.handleBlur(e),
|
|
1237
1240
|
onPaypalSubmit: async () => this.handlePaypalSubmit(),
|
|
1238
1241
|
onApplePaySubmit: async (e) => this.handleApplePaySubmit(e),
|
|
1242
|
+
onApplePayStartFailed: (e) => this.options.onSubmitOutcome?.(c(e)),
|
|
1239
1243
|
supportedPaymentMethods: e.supportedPaymentMethods,
|
|
1240
1244
|
paymentId: e.paymentId,
|
|
1241
1245
|
checkoutKey: e.checkoutKey,
|
|
1242
1246
|
checkoutDetails: e.checkoutDetails,
|
|
1243
1247
|
environment: e.environment,
|
|
1244
1248
|
vgsService: this.vgsService
|
|
1245
|
-
}), this.uiManager = new
|
|
1249
|
+
}), this.uiManager = new Ae({
|
|
1246
1250
|
formElement: this.element,
|
|
1247
1251
|
componentManager: this.componentManager,
|
|
1248
1252
|
onLoadingStateChange: e.onLoadingStateChange
|
|
1249
|
-
}), this.stateCoordinator = new
|
|
1253
|
+
}), this.stateCoordinator = new Oe({
|
|
1250
1254
|
formManager: this.formManager,
|
|
1251
1255
|
checkoutProfile: this.checkoutProfile,
|
|
1252
1256
|
componentManager: this.componentManager,
|
|
@@ -1256,7 +1260,7 @@ var Q = (e) => ({
|
|
|
1256
1260
|
onError: (e) => this.uiManager.setErrorMessage(e),
|
|
1257
1261
|
onLoadingChange: (e) => this.uiManager.setLoadingState(e),
|
|
1258
1262
|
getInitialFormData: () => this._getFormStateData().formData
|
|
1259
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
1263
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new De({
|
|
1260
1264
|
formManager: this.formManager,
|
|
1261
1265
|
focusManager: this.focusManager,
|
|
1262
1266
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -1291,7 +1295,7 @@ var Q = (e) => ({
|
|
|
1291
1295
|
}
|
|
1292
1296
|
initializeForm() {
|
|
1293
1297
|
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) {
|
|
1294
|
-
this.failCardCaptureClosed(
|
|
1298
|
+
this.failCardCaptureClosed(H.NO_TOKENIZATION_SESSION);
|
|
1295
1299
|
return;
|
|
1296
1300
|
}
|
|
1297
1301
|
if (this.vgsService) {
|
|
@@ -1299,7 +1303,7 @@ var Q = (e) => ({
|
|
|
1299
1303
|
e.init(this.options.environment).then((t) => {
|
|
1300
1304
|
this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
|
|
1301
1305
|
}).catch((t) => {
|
|
1302
|
-
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(H.INIT_FAILED));
|
|
1303
1307
|
});
|
|
1304
1308
|
}
|
|
1305
1309
|
}
|
|
@@ -1310,7 +1314,10 @@ var Q = (e) => ({
|
|
|
1310
1314
|
return;
|
|
1311
1315
|
}
|
|
1312
1316
|
let t = this.isCardCaptureUnavailable;
|
|
1313
|
-
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0),
|
|
1317
|
+
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), this.reportLoadOutcome({
|
|
1318
|
+
status: "failed",
|
|
1319
|
+
reason: e
|
|
1320
|
+
}), t || N(x.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
|
|
1314
1321
|
}
|
|
1315
1322
|
dropVgsService() {
|
|
1316
1323
|
let e = this.vgsService;
|
|
@@ -1329,55 +1336,68 @@ var Q = (e) => ({
|
|
|
1329
1336
|
phoneNumber: "",
|
|
1330
1337
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1331
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() });
|
|
1332
|
-
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i =
|
|
1339
|
+
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = ye(e.checkoutProfile.layout);
|
|
1333
1340
|
try {
|
|
1334
1341
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
1335
1342
|
} catch (e) {
|
|
1336
|
-
console.error("Failed to create payment methods:", e);
|
|
1343
|
+
console.error("Failed to create payment methods:", e), this.reportRenderFailure("payment_methods");
|
|
1337
1344
|
}
|
|
1338
1345
|
try {
|
|
1339
1346
|
this.componentManager.createEmailField(e.checkoutProfile, t, n, r);
|
|
1340
1347
|
} catch (e) {
|
|
1341
|
-
console.error("Failed to create email field:", e);
|
|
1348
|
+
console.error("Failed to create email field:", e), this.reportRenderFailure("email");
|
|
1342
1349
|
}
|
|
1343
1350
|
if (i) {
|
|
1344
1351
|
try {
|
|
1345
1352
|
this.componentManager.createBillingAddressSection(e.checkoutProfile, t, n, r);
|
|
1346
1353
|
} catch (e) {
|
|
1347
|
-
console.error("Failed to create billing address section:", e);
|
|
1354
|
+
console.error("Failed to create billing address section:", e), this.reportRenderFailure("billing_address");
|
|
1348
1355
|
}
|
|
1349
1356
|
try {
|
|
1350
1357
|
this.componentManager.createShippingAddressSection(e.checkoutProfile, t, n, r);
|
|
1351
1358
|
} catch (e) {
|
|
1352
|
-
console.error("Failed to create shipping address section:", e);
|
|
1359
|
+
console.error("Failed to create shipping address section:", e), this.reportRenderFailure("shipping_address");
|
|
1353
1360
|
}
|
|
1354
1361
|
}
|
|
1355
1362
|
if (e.checkoutProfile.layout.phoneNumber?.enabled) try {
|
|
1356
1363
|
this.componentManager.createPhoneNumberField(e.checkoutProfile, t, n, r);
|
|
1357
1364
|
} catch (e) {
|
|
1358
|
-
console.error("Failed to create phone number field:", e);
|
|
1365
|
+
console.error("Failed to create phone number field:", e), this.reportRenderFailure("phone_number");
|
|
1359
1366
|
}
|
|
1360
1367
|
try {
|
|
1361
1368
|
this.componentManager.createCardSection(e.checkoutProfile);
|
|
1362
1369
|
} catch (e) {
|
|
1363
|
-
console.error("Failed to create card section:", e);
|
|
1370
|
+
console.error("Failed to create card section:", e), this.reportRenderFailure("card_section");
|
|
1364
1371
|
}
|
|
1365
|
-
if (!
|
|
1372
|
+
if (!q(e.checkoutProfile.layout) && this.componentManager.isCardSupported()) try {
|
|
1366
1373
|
this.componentManager.createCardholderSection(e.checkoutProfile, t, n, r);
|
|
1367
1374
|
} catch (e) {
|
|
1368
|
-
console.error("Failed to create cardholder section:", e);
|
|
1375
|
+
console.error("Failed to create cardholder section:", e), this.reportRenderFailure("cardholder");
|
|
1369
1376
|
}
|
|
1370
1377
|
if (this.vgsService) {
|
|
1371
1378
|
let t = this.vgsService, n = ++this.vgsMountGeneration;
|
|
1372
|
-
this.componentManager.mountVgsFields(e.checkoutProfile).
|
|
1373
|
-
this.vgsMountGeneration === n && this.vgsService === t &&
|
|
1379
|
+
this.componentManager.mountVgsFields(e.checkoutProfile).then((e) => {
|
|
1380
|
+
e && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
|
|
1381
|
+
}).catch((e) => {
|
|
1382
|
+
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(H.FIELDS_NOT_READY));
|
|
1374
1383
|
});
|
|
1375
1384
|
}
|
|
1376
1385
|
try {
|
|
1377
1386
|
this.componentManager.createSubmitButton(e.checkoutProfile, this.stateCoordinator.isFormDisabled());
|
|
1378
1387
|
} catch (e) {
|
|
1379
|
-
console.error("Failed to create submit button:", e);
|
|
1388
|
+
console.error("Failed to create submit button:", e), this.reportRenderFailure("submit_button");
|
|
1380
1389
|
}
|
|
1390
|
+
this.options.checkoutDetails && !this.componentManager.isCardSupported() && this.reportLoadOutcome({ status: "ready" });
|
|
1391
|
+
}
|
|
1392
|
+
reportRenderFailure(e) {
|
|
1393
|
+
this.reportLoadOutcome({
|
|
1394
|
+
status: "failed",
|
|
1395
|
+
reason: C.FORM_RENDER_FAILED,
|
|
1396
|
+
attributes: { form_part: e }
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
reportLoadOutcome(e) {
|
|
1400
|
+
this.isDestroyed || this.options.onLoadOutcome?.(e);
|
|
1381
1401
|
}
|
|
1382
1402
|
updateFormUI() {
|
|
1383
1403
|
let e = this.formManager.getFormState();
|
|
@@ -1385,7 +1405,7 @@ var Q = (e) => ({
|
|
|
1385
1405
|
}
|
|
1386
1406
|
inferCardholderName() {
|
|
1387
1407
|
let e = this.checkoutProfile.getState();
|
|
1388
|
-
if (!e.checkoutProfile || !
|
|
1408
|
+
if (!e.checkoutProfile || !q(e.checkoutProfile.layout)) return;
|
|
1389
1409
|
let { formData: t } = this._getFormStateData(), n = t.billingAddress ?? t.shippingAddress;
|
|
1390
1410
|
if (!n) return;
|
|
1391
1411
|
let r = [n.firstName?.trim() ?? "", n.lastName?.trim() ?? ""].filter(Boolean).join(" ");
|
|
@@ -1405,13 +1425,13 @@ var Q = (e) => ({
|
|
|
1405
1425
|
async handleSubmit() {
|
|
1406
1426
|
if (!this.stateCoordinator.isFormDisabled()) try {
|
|
1407
1427
|
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) {
|
|
1408
|
-
this.handleSubmitError(this.translation.t("cardUnavailable"));
|
|
1428
|
+
this.options.onSubmitOutcome?.(g(ee(/* @__PURE__ */ Error("Card capture unavailable"), oe.CAPTURE_UNAVAILABLE), "card")), this.handleSubmitError(this.translation.t("cardUnavailable"));
|
|
1409
1429
|
return;
|
|
1410
1430
|
}
|
|
1411
1431
|
try {
|
|
1412
1432
|
this.vgsCardResult = await this.vgsService.createCard(this.vgsJwt);
|
|
1413
1433
|
} catch (e) {
|
|
1414
|
-
console.error("VGS card creation failed:", e), this.handleSubmitError("Card processing failed. Please check your card details and try again.");
|
|
1434
|
+
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(g(e, "card")), this.handleSubmitError("Card processing failed. Please check your card details and try again.");
|
|
1415
1435
|
return;
|
|
1416
1436
|
}
|
|
1417
1437
|
let e = this.formManager.getFormState().formData;
|
|
@@ -1468,21 +1488,21 @@ var Q = (e) => ({
|
|
|
1468
1488
|
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
1489
|
let a = this.componentManager.isCardSupported();
|
|
1470
1490
|
if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
|
|
1471
|
-
let e = new
|
|
1491
|
+
let e = new l();
|
|
1472
1492
|
this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
|
|
1473
1493
|
this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
|
|
1474
1494
|
}).catch((t) => {
|
|
1475
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1495
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(H.INIT_FAILED));
|
|
1476
1496
|
});
|
|
1477
1497
|
}
|
|
1478
|
-
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(
|
|
1479
|
-
let
|
|
1480
|
-
if (
|
|
1498
|
+
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(H.NO_TOKENIZATION_SESSION);
|
|
1499
|
+
let o = this.checkoutProfile.getState();
|
|
1500
|
+
if (o.checkoutProfile) {
|
|
1481
1501
|
let { formData: e } = this._getFormStateData();
|
|
1482
|
-
this.componentManager.createPaymentMethods(
|
|
1502
|
+
this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
|
|
1483
1503
|
}
|
|
1484
1504
|
}
|
|
1485
|
-
},
|
|
1505
|
+
}, Me = class {
|
|
1486
1506
|
container = null;
|
|
1487
1507
|
options;
|
|
1488
1508
|
onSubmit;
|
|
@@ -1506,7 +1526,7 @@ var Q = (e) => ({
|
|
|
1506
1526
|
}
|
|
1507
1527
|
}
|
|
1508
1528
|
renderForm(e) {
|
|
1509
|
-
this.container && (this.form &&= (this.form.destroy(), null), this.form = new
|
|
1529
|
+
this.container && (this.form &&= (this.form.destroy(), null), this.form = new je({
|
|
1510
1530
|
apiKey: this.options.apiKey,
|
|
1511
1531
|
onSubmit: this.onSubmit,
|
|
1512
1532
|
locale: this.options.locale,
|
|
@@ -1515,6 +1535,8 @@ var Q = (e) => ({
|
|
|
1515
1535
|
environment: this.options.environment,
|
|
1516
1536
|
appearance: this.options.appearance,
|
|
1517
1537
|
onLoadingStateChange: this.options.onLoadingStateChange,
|
|
1538
|
+
onLoadOutcome: this.options.onLoadOutcome,
|
|
1539
|
+
onSubmitOutcome: this.options.onSubmitOutcome,
|
|
1518
1540
|
paymentId: this.options.paymentId,
|
|
1519
1541
|
checkoutKey: this.options.checkoutKey,
|
|
1520
1542
|
checkoutDetails: this.options.checkoutDetails,
|
|
@@ -1536,7 +1558,7 @@ var Q = (e) => ({
|
|
|
1536
1558
|
async associatePayment(e, t, n, r, i) {
|
|
1537
1559
|
this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = r, this.options.vgsJwt = i, this.options.supportedPaymentMethods = n, this.form && this.form.associatePayment(e, t, n, r, i);
|
|
1538
1560
|
}
|
|
1539
|
-
},
|
|
1561
|
+
}, Ne = class {
|
|
1540
1562
|
state;
|
|
1541
1563
|
listeners = /* @__PURE__ */ new Set();
|
|
1542
1564
|
constructor(e) {
|
|
@@ -1560,7 +1582,7 @@ var Q = (e) => ({
|
|
|
1560
1582
|
let e = this.getState();
|
|
1561
1583
|
this.listeners.forEach((t) => t(e));
|
|
1562
1584
|
}
|
|
1563
|
-
},
|
|
1585
|
+
}, Pe = "en", $ = class {
|
|
1564
1586
|
config;
|
|
1565
1587
|
_callbacks;
|
|
1566
1588
|
paymentState;
|
|
@@ -1568,22 +1590,28 @@ var Q = (e) => ({
|
|
|
1568
1590
|
formManager;
|
|
1569
1591
|
stateManager;
|
|
1570
1592
|
sessionId;
|
|
1593
|
+
readiness = new re();
|
|
1594
|
+
associationSequence = 0;
|
|
1571
1595
|
constructor(e) {
|
|
1572
|
-
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
1596
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), a(), le({
|
|
1573
1597
|
environment: this.config.environment,
|
|
1574
1598
|
sessionId: this.sessionId,
|
|
1575
1599
|
integration: "dropin"
|
|
1576
|
-
}),
|
|
1600
|
+
}), N(x.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new t(this.config.apiKey, this.config.environment), this.stateManager = new Ne({
|
|
1577
1601
|
mounted: !1,
|
|
1578
1602
|
form: null
|
|
1579
|
-
}), this.formManager = new
|
|
1603
|
+
}), this.formManager = new Me({
|
|
1580
1604
|
locale: this.config.locale,
|
|
1581
1605
|
apiKey: this.config.apiKey,
|
|
1582
1606
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
1583
1607
|
environment: this.config.environment,
|
|
1584
1608
|
appearance: this.config.appearance,
|
|
1585
1609
|
onLoadingStateChange: (...e) => this._callbacks.onLoadingStateChange?.(...e),
|
|
1586
|
-
initialValues: this.config.initialValues
|
|
1610
|
+
initialValues: this.config.initialValues,
|
|
1611
|
+
onLoadOutcome: (e) => {
|
|
1612
|
+
this.readiness.markMounted(), this.readiness.settle(e);
|
|
1613
|
+
},
|
|
1614
|
+
onSubmitOutcome: (e) => this.readiness.reportSubmit(e)
|
|
1587
1615
|
}, this.handleSubmit.bind(this));
|
|
1588
1616
|
}
|
|
1589
1617
|
validateConfig(e) {
|
|
@@ -1593,7 +1621,7 @@ var Q = (e) => ({
|
|
|
1593
1621
|
apiKey: e.apiKey,
|
|
1594
1622
|
returnUrl: e.returnUrl,
|
|
1595
1623
|
environment: e.environment,
|
|
1596
|
-
locale: e.locale ||
|
|
1624
|
+
locale: e.locale || Pe,
|
|
1597
1625
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1598
1626
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1599
1627
|
appearance: e.appearance,
|
|
@@ -1607,22 +1635,22 @@ var Q = (e) => ({
|
|
|
1607
1635
|
};
|
|
1608
1636
|
}
|
|
1609
1637
|
mount(e) {
|
|
1610
|
-
let t;
|
|
1638
|
+
let t, n = !1;
|
|
1611
1639
|
try {
|
|
1612
|
-
let
|
|
1613
|
-
if (!
|
|
1614
|
-
return t = document.createElement("div"),
|
|
1640
|
+
let r = document.querySelector(e);
|
|
1641
|
+
if (!r) throw Error(`Container ${e} not found`);
|
|
1642
|
+
return n = !0, t = document.createElement("div"), r.appendChild(t), this.stateManager.updateState({
|
|
1615
1643
|
form: t,
|
|
1616
1644
|
mounted: !0
|
|
1617
|
-
}), this.formManager.mount(t),
|
|
1618
|
-
} catch (
|
|
1645
|
+
}), this.formManager.mount(t), this.readiness.markMounted(), N(x.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1646
|
+
} catch (r) {
|
|
1619
1647
|
throw t?.remove(), this.stateManager.updateState({
|
|
1620
1648
|
form: null,
|
|
1621
1649
|
mounted: !1
|
|
1622
|
-
}),
|
|
1650
|
+
}), N(x.CHECKOUT_MOUNT_FAILED, {
|
|
1623
1651
|
container_id: e,
|
|
1624
|
-
error_message:
|
|
1625
|
-
}),
|
|
1652
|
+
error_message: r instanceof Error ? r.message : "Unknown error"
|
|
1653
|
+
}), V(r instanceof Error ? r : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n ? this.readiness.fail({ reason: C.MOUNT_FAILED }) : this.readiness.exclude({ reason: C.CONTAINER_NOT_FOUND }), r;
|
|
1626
1654
|
}
|
|
1627
1655
|
}
|
|
1628
1656
|
unmount() {
|
|
@@ -1633,13 +1661,13 @@ var Q = (e) => ({
|
|
|
1633
1661
|
e && e.remove(), this.stateManager.updateState({
|
|
1634
1662
|
form: null,
|
|
1635
1663
|
mounted: !1
|
|
1636
|
-
}),
|
|
1664
|
+
}), N(x.CHECKOUT_UNMOUNTED);
|
|
1637
1665
|
});
|
|
1638
1666
|
}
|
|
1639
1667
|
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1640
1668
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1641
1669
|
let n = this.getPaymentMethod(e, t);
|
|
1642
|
-
|
|
1670
|
+
N(x.PAYMENT_SUBMIT_STARTED, {
|
|
1643
1671
|
payment_id: this.paymentState.paymentId,
|
|
1644
1672
|
payment_method: n
|
|
1645
1673
|
});
|
|
@@ -1651,42 +1679,48 @@ var Q = (e) => ({
|
|
|
1651
1679
|
paymentId: this.paymentState.paymentId,
|
|
1652
1680
|
returnUrl: this.config.returnUrl,
|
|
1653
1681
|
applePayData: t
|
|
1654
|
-
})
|
|
1655
|
-
|
|
1682
|
+
});
|
|
1683
|
+
this.readiness.reportSubmit({
|
|
1684
|
+
outcome: de.SUCCEEDED,
|
|
1685
|
+
paymentMethod: n
|
|
1686
|
+
});
|
|
1687
|
+
let a = performance.now() - r;
|
|
1688
|
+
return E(F.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
|
|
1656
1689
|
payment_id: this.paymentState.paymentId,
|
|
1657
1690
|
payment_method: n,
|
|
1658
1691
|
status: "success"
|
|
1659
|
-
}),
|
|
1692
|
+
}), N(x.PAYMENT_SUBMIT_SUCCESS, {
|
|
1660
1693
|
payment_id: this.paymentState.paymentId,
|
|
1661
1694
|
payment_method: n
|
|
1662
1695
|
}), this.handlePaymentResponse(i);
|
|
1663
1696
|
} catch (e) {
|
|
1664
1697
|
let t = performance.now() - r;
|
|
1665
|
-
return
|
|
1698
|
+
return E(F.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1666
1699
|
payment_id: this.paymentState.paymentId,
|
|
1667
1700
|
payment_method: n,
|
|
1668
1701
|
status: "failed"
|
|
1669
|
-
}),
|
|
1702
|
+
}), N(x.PAYMENT_SUBMIT_FAILED, {
|
|
1670
1703
|
payment_id: this.paymentState.paymentId,
|
|
1671
1704
|
payment_method: n,
|
|
1672
|
-
error_message: e.details?.message ?? "Unknown error"
|
|
1673
|
-
|
|
1705
|
+
error_message: e.details?.message ?? "Unknown error",
|
|
1706
|
+
...P(e)
|
|
1707
|
+
}), this.readiness.reportSubmit(ie(e, n)), this.handleAuthorizationError(e), !1;
|
|
1674
1708
|
}
|
|
1675
1709
|
}
|
|
1676
1710
|
handlePaymentResponse(e) {
|
|
1677
1711
|
let t = !1;
|
|
1678
|
-
if (e.latestTransaction.status === "authorized" && (
|
|
1712
|
+
if (e.latestTransaction.status === "authorized" && (N(x.PAYMENT_AUTHORIZED, {
|
|
1679
1713
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1680
1714
|
status: e.latestTransaction.status
|
|
1681
|
-
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (
|
|
1715
|
+
}), y(() => this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status)), t = !0), e.latestTransaction.status === "failed" && (N(x.PAYMENT_FAILED, {
|
|
1682
1716
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1683
1717
|
status: e.latestTransaction.status
|
|
1684
|
-
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
|
|
1718
|
+
}), y(() => this._callbacks.onPaymentFailed?.(e.latestTransaction.status))), e.status === "requires_action") {
|
|
1685
1719
|
let { redirectUrl: n } = e.action;
|
|
1686
|
-
|
|
1720
|
+
N(x.PAYMENT_ACTION_REQUIRED, {
|
|
1687
1721
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1688
1722
|
status: e.status
|
|
1689
|
-
}), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(n) : globalThis.location.href = n, t = !0;
|
|
1723
|
+
}), this.config.manualActionHandling ? y(() => this._callbacks.onActionRequired?.(n)) : globalThis.location.href = n, t = !0;
|
|
1690
1724
|
}
|
|
1691
1725
|
return t;
|
|
1692
1726
|
}
|
|
@@ -1718,31 +1752,40 @@ var Q = (e) => ({
|
|
|
1718
1752
|
}
|
|
1719
1753
|
async associatePayment(e, t) {
|
|
1720
1754
|
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
1721
|
-
|
|
1755
|
+
let n = ++this.associationSequence;
|
|
1756
|
+
this.readiness.start(e), this.paymentState.paymentId = e, this.paymentState.checkoutKey = t, I(this.config.environment);
|
|
1757
|
+
let r = T.CHECKOUT_DETAILS;
|
|
1722
1758
|
try {
|
|
1723
|
-
let
|
|
1759
|
+
let i = await _({
|
|
1724
1760
|
id: e,
|
|
1725
1761
|
checkoutKey: t,
|
|
1726
1762
|
environment: this.config.environment
|
|
1727
1763
|
});
|
|
1728
|
-
if (!
|
|
1729
|
-
if (!
|
|
1730
|
-
this.
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1764
|
+
if (!i || !i.supportedPaymentMethods || !Array.isArray(i.supportedPaymentMethods)) throw A(/* @__PURE__ */ Error("Invalid response: supportedPaymentMethods must be an array"), M.INVALID_RESPONSE, B(i));
|
|
1765
|
+
if (!i.supportedPaymentMethods.every((e) => typeof e == "string")) throw A(/* @__PURE__ */ Error("Invalid response: all supportedPaymentMethods must be strings"), M.INVALID_RESPONSE, B(i));
|
|
1766
|
+
if (n !== this.associationSequence) return;
|
|
1767
|
+
r = T.FORM_SETUP, this.readiness.markAssociated(), this.paymentState.checkoutDetails = {
|
|
1768
|
+
amount: i.amount,
|
|
1769
|
+
currency: i.currency,
|
|
1770
|
+
countryCode: i.countryCode
|
|
1734
1771
|
};
|
|
1735
|
-
let
|
|
1736
|
-
await this.formManager.associatePayment(e, t,
|
|
1772
|
+
let a = i.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
|
|
1773
|
+
await this.formManager.associatePayment(e, t, a, this.paymentState.checkoutDetails, i.vgsJwt), N(x.PAYMENT_ASSOCIATED, {
|
|
1737
1774
|
payment_id: e,
|
|
1738
|
-
currency:
|
|
1739
|
-
country_code:
|
|
1775
|
+
currency: i.currency,
|
|
1776
|
+
country_code: i.countryCode
|
|
1740
1777
|
});
|
|
1741
1778
|
} catch (t) {
|
|
1742
|
-
|
|
1779
|
+
if (N(x.PAYMENT_ASSOCIATION_FAILED, {
|
|
1743
1780
|
payment_id: e,
|
|
1744
|
-
error_message: t instanceof Error ? t.message : "Unknown error"
|
|
1745
|
-
|
|
1781
|
+
error_message: t instanceof Error ? t.message : "Unknown error",
|
|
1782
|
+
stage: r,
|
|
1783
|
+
...P(t)
|
|
1784
|
+
}), V(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), n === this.associationSequence) {
|
|
1785
|
+
let { ours: e, ...n } = ae(t, r);
|
|
1786
|
+
e ? this.readiness.fail(n) : this.readiness.exclude(n);
|
|
1787
|
+
}
|
|
1788
|
+
throw t;
|
|
1746
1789
|
}
|
|
1747
1790
|
}
|
|
1748
1791
|
setCallbacks(e) {
|
|
@@ -1753,4 +1796,4 @@ var Q = (e) => ({
|
|
|
1753
1796
|
//#region libs/checkout/src/index.ts
|
|
1754
1797
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1755
1798
|
//#endregion
|
|
1756
|
-
export { $ as OdusCheckout,
|
|
1799
|
+
export { $ as OdusCheckout, f as deLocale, d as enLocale, D as esLocale, e as frLocale, O as itLocale, p as plLocale, n as ptLocale, V as pushError, N as pushEvent, R as pushLog, E as pushMeasurement, r as trLocale };
|