@odus/checkout 1.13.0 → 1.14.1
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 +190 -166
- package/dist/components/checkout/form/Form.d.ts +11 -1
- package/dist/components/checkout/form/Form.d.ts.map +1 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts +4 -0
- 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 +4 -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 +7 -0
- package/dist/elements/BaseElement.d.ts.map +1 -1
- package/dist/elements/OdusElements.d.ts +2 -1
- package/dist/elements/OdusElements.d.ts.map +1 -1
- package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
- package/dist/elements.es.js +243 -219
- package/dist/phone.js +2 -0
- package/dist/services/checkout/Checkout.service.d.ts +1 -1
- package/dist/services/checkout/Checkout.service.d.ts.map +1 -1
- package/dist/services/checkout/CheckoutForm.service.d.ts +2 -1
- 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 +1312 -1049
- 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 +156 -3
- 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 +1 -1
- package/dist/services/telemetry/LoadTimer.service.d.ts +0 -28
- package/dist/services/telemetry/LoadTimer.service.d.ts.map +0 -1
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,7 +81,7 @@ var G = 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);
|
|
@@ -93,7 +93,7 @@ function q(e) {
|
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region libs/checkout/src/components/checkout/form/AddressSection.ts
|
|
96
|
-
var J = class extends
|
|
96
|
+
var J = class extends v {
|
|
97
97
|
inputs = /* @__PURE__ */ new Map();
|
|
98
98
|
type;
|
|
99
99
|
onChange;
|
|
@@ -115,7 +115,7 @@ var J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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,
|
|
@@ -543,7 +543,7 @@ var J = class extends S {
|
|
|
543
543
|
focus() {
|
|
544
544
|
this.isVgsMode || this.input?.focus();
|
|
545
545
|
}
|
|
546
|
-
}, Y = class extends
|
|
546
|
+
}, Y = class extends v {
|
|
547
547
|
constructor() {
|
|
548
548
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
549
549
|
}
|
|
@@ -551,14 +551,14 @@ var J = class extends S {
|
|
|
551
551
|
this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
|
|
552
552
|
}
|
|
553
553
|
createPaymentMethodSkeleton() {
|
|
554
|
-
let e =
|
|
554
|
+
let e = j.createDiv(["skeleton-field"]), t = j.createDiv(["skeleton", "skeleton-payment-method"]);
|
|
555
555
|
return e.appendChild(t), e;
|
|
556
556
|
}
|
|
557
557
|
createPaymentSeparatorSkeleton() {
|
|
558
|
-
let e =
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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,8 +622,8 @@ var J = class extends S {
|
|
|
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
|
}
|
|
@@ -638,7 +639,7 @@ var J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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,
|
|
@@ -893,7 +896,7 @@ var J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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
980
|
if (!this.vgsService || !this.cardSection) return !1;
|
|
978
|
-
let t =
|
|
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) {
|
|
@@ -1016,7 +1019,7 @@ var J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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 J = class extends S {
|
|
|
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,12 +1134,12 @@ var J = class extends S {
|
|
|
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
|
-
let t =
|
|
1139
|
-
this.titleElement = new
|
|
1141
|
+
let t = j.createDiv(["loader"]);
|
|
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;
|
|
@@ -1157,11 +1160,11 @@ var J = class extends S {
|
|
|
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;
|
|
@@ -1179,7 +1182,7 @@ var J = class extends S {
|
|
|
1179
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 J = class extends S {
|
|
|
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
|
}
|
|
@@ -1313,7 +1317,7 @@ var Q = (e) => ({
|
|
|
1313
1317
|
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), this.reportLoadOutcome({
|
|
1314
1318
|
status: "failed",
|
|
1315
1319
|
reason: e
|
|
1316
|
-
}), t ||
|
|
1320
|
+
}), t || N(x.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
|
|
1317
1321
|
}
|
|
1318
1322
|
dropVgsService() {
|
|
1319
1323
|
let e = this.vgsService;
|
|
@@ -1332,59 +1336,66 @@ var Q = (e) => ({
|
|
|
1332
1336
|
phoneNumber: "",
|
|
1333
1337
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1334
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() });
|
|
1335
|
-
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);
|
|
1336
1340
|
try {
|
|
1337
1341
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
1338
1342
|
} catch (e) {
|
|
1339
|
-
console.error("Failed to create payment methods:", e);
|
|
1343
|
+
console.error("Failed to create payment methods:", e), this.reportRenderFailure("payment_methods");
|
|
1340
1344
|
}
|
|
1341
1345
|
try {
|
|
1342
1346
|
this.componentManager.createEmailField(e.checkoutProfile, t, n, r);
|
|
1343
1347
|
} catch (e) {
|
|
1344
|
-
console.error("Failed to create email field:", e);
|
|
1348
|
+
console.error("Failed to create email field:", e), this.reportRenderFailure("email");
|
|
1345
1349
|
}
|
|
1346
1350
|
if (i) {
|
|
1347
1351
|
try {
|
|
1348
1352
|
this.componentManager.createBillingAddressSection(e.checkoutProfile, t, n, r);
|
|
1349
1353
|
} catch (e) {
|
|
1350
|
-
console.error("Failed to create billing address section:", e);
|
|
1354
|
+
console.error("Failed to create billing address section:", e), this.reportRenderFailure("billing_address");
|
|
1351
1355
|
}
|
|
1352
1356
|
try {
|
|
1353
1357
|
this.componentManager.createShippingAddressSection(e.checkoutProfile, t, n, r);
|
|
1354
1358
|
} catch (e) {
|
|
1355
|
-
console.error("Failed to create shipping address section:", e);
|
|
1359
|
+
console.error("Failed to create shipping address section:", e), this.reportRenderFailure("shipping_address");
|
|
1356
1360
|
}
|
|
1357
1361
|
}
|
|
1358
1362
|
if (e.checkoutProfile.layout.phoneNumber?.enabled) try {
|
|
1359
1363
|
this.componentManager.createPhoneNumberField(e.checkoutProfile, t, n, r);
|
|
1360
1364
|
} catch (e) {
|
|
1361
|
-
console.error("Failed to create phone number field:", e);
|
|
1365
|
+
console.error("Failed to create phone number field:", e), this.reportRenderFailure("phone_number");
|
|
1362
1366
|
}
|
|
1363
1367
|
try {
|
|
1364
1368
|
this.componentManager.createCardSection(e.checkoutProfile);
|
|
1365
1369
|
} catch (e) {
|
|
1366
|
-
console.error("Failed to create card section:", e);
|
|
1370
|
+
console.error("Failed to create card section:", e), this.reportRenderFailure("card_section");
|
|
1367
1371
|
}
|
|
1368
1372
|
if (!q(e.checkoutProfile.layout) && this.componentManager.isCardSupported()) try {
|
|
1369
1373
|
this.componentManager.createCardholderSection(e.checkoutProfile, t, n, r);
|
|
1370
1374
|
} catch (e) {
|
|
1371
|
-
console.error("Failed to create cardholder section:", e);
|
|
1375
|
+
console.error("Failed to create cardholder section:", e), this.reportRenderFailure("cardholder");
|
|
1372
1376
|
}
|
|
1373
1377
|
if (this.vgsService) {
|
|
1374
1378
|
let t = this.vgsService, n = ++this.vgsMountGeneration;
|
|
1375
1379
|
this.componentManager.mountVgsFields(e.checkoutProfile).then((e) => {
|
|
1376
1380
|
e && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
|
|
1377
1381
|
}).catch((e) => {
|
|
1378
|
-
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(
|
|
1382
|
+
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(H.FIELDS_NOT_READY));
|
|
1379
1383
|
});
|
|
1380
1384
|
}
|
|
1381
1385
|
try {
|
|
1382
1386
|
this.componentManager.createSubmitButton(e.checkoutProfile, this.stateCoordinator.isFormDisabled());
|
|
1383
1387
|
} catch (e) {
|
|
1384
|
-
console.error("Failed to create submit button:", e);
|
|
1388
|
+
console.error("Failed to create submit button:", e), this.reportRenderFailure("submit_button");
|
|
1385
1389
|
}
|
|
1386
1390
|
this.options.checkoutDetails && !this.componentManager.isCardSupported() && this.reportLoadOutcome({ status: "ready" });
|
|
1387
1391
|
}
|
|
1392
|
+
reportRenderFailure(e) {
|
|
1393
|
+
this.reportLoadOutcome({
|
|
1394
|
+
status: "failed",
|
|
1395
|
+
reason: C.FORM_RENDER_FAILED,
|
|
1396
|
+
attributes: { form_part: e }
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1388
1399
|
reportLoadOutcome(e) {
|
|
1389
1400
|
this.isDestroyed || this.options.onLoadOutcome?.(e);
|
|
1390
1401
|
}
|
|
@@ -1414,13 +1425,13 @@ var Q = (e) => ({
|
|
|
1414
1425
|
async handleSubmit() {
|
|
1415
1426
|
if (!this.stateCoordinator.isFormDisabled()) try {
|
|
1416
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) {
|
|
1417
|
-
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"));
|
|
1418
1429
|
return;
|
|
1419
1430
|
}
|
|
1420
1431
|
try {
|
|
1421
1432
|
this.vgsCardResult = await this.vgsService.createCard(this.vgsJwt);
|
|
1422
1433
|
} catch (e) {
|
|
1423
|
-
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.");
|
|
1424
1435
|
return;
|
|
1425
1436
|
}
|
|
1426
1437
|
let e = this.formManager.getFormState().formData;
|
|
@@ -1477,21 +1488,21 @@ var Q = (e) => ({
|
|
|
1477
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);
|
|
1478
1489
|
let a = this.componentManager.isCardSupported();
|
|
1479
1490
|
if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
|
|
1480
|
-
let e = new
|
|
1491
|
+
let e = new l();
|
|
1481
1492
|
this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
|
|
1482
1493
|
this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
|
|
1483
1494
|
}).catch((t) => {
|
|
1484
|
-
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));
|
|
1485
1496
|
});
|
|
1486
1497
|
}
|
|
1487
|
-
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(
|
|
1498
|
+
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(H.NO_TOKENIZATION_SESSION);
|
|
1488
1499
|
let o = this.checkoutProfile.getState();
|
|
1489
1500
|
if (o.checkoutProfile) {
|
|
1490
1501
|
let { formData: e } = this._getFormStateData();
|
|
1491
1502
|
this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
|
|
1492
1503
|
}
|
|
1493
1504
|
}
|
|
1494
|
-
},
|
|
1505
|
+
}, Me = class {
|
|
1495
1506
|
container = null;
|
|
1496
1507
|
options;
|
|
1497
1508
|
onSubmit;
|
|
@@ -1515,7 +1526,7 @@ var Q = (e) => ({
|
|
|
1515
1526
|
}
|
|
1516
1527
|
}
|
|
1517
1528
|
renderForm(e) {
|
|
1518
|
-
this.container && (this.form &&= (this.form.destroy(), null), this.form = new
|
|
1529
|
+
this.container && (this.form &&= (this.form.destroy(), null), this.form = new je({
|
|
1519
1530
|
apiKey: this.options.apiKey,
|
|
1520
1531
|
onSubmit: this.onSubmit,
|
|
1521
1532
|
locale: this.options.locale,
|
|
@@ -1525,6 +1536,7 @@ var Q = (e) => ({
|
|
|
1525
1536
|
appearance: this.options.appearance,
|
|
1526
1537
|
onLoadingStateChange: this.options.onLoadingStateChange,
|
|
1527
1538
|
onLoadOutcome: this.options.onLoadOutcome,
|
|
1539
|
+
onSubmitOutcome: this.options.onSubmitOutcome,
|
|
1528
1540
|
paymentId: this.options.paymentId,
|
|
1529
1541
|
checkoutKey: this.options.checkoutKey,
|
|
1530
1542
|
checkoutDetails: this.options.checkoutDetails,
|
|
@@ -1546,7 +1558,7 @@ var Q = (e) => ({
|
|
|
1546
1558
|
async associatePayment(e, t, n, r, i) {
|
|
1547
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);
|
|
1548
1560
|
}
|
|
1549
|
-
},
|
|
1561
|
+
}, Ne = class {
|
|
1550
1562
|
state;
|
|
1551
1563
|
listeners = /* @__PURE__ */ new Set();
|
|
1552
1564
|
constructor(e) {
|
|
@@ -1570,7 +1582,7 @@ var Q = (e) => ({
|
|
|
1570
1582
|
let e = this.getState();
|
|
1571
1583
|
this.listeners.forEach((t) => t(e));
|
|
1572
1584
|
}
|
|
1573
|
-
},
|
|
1585
|
+
}, Pe = "en", $ = class {
|
|
1574
1586
|
config;
|
|
1575
1587
|
_callbacks;
|
|
1576
1588
|
paymentState;
|
|
@@ -1578,17 +1590,17 @@ var Q = (e) => ({
|
|
|
1578
1590
|
formManager;
|
|
1579
1591
|
stateManager;
|
|
1580
1592
|
sessionId;
|
|
1581
|
-
|
|
1593
|
+
readiness = new re();
|
|
1582
1594
|
associationSequence = 0;
|
|
1583
1595
|
constructor(e) {
|
|
1584
|
-
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({
|
|
1585
1597
|
environment: this.config.environment,
|
|
1586
1598
|
sessionId: this.sessionId,
|
|
1587
1599
|
integration: "dropin"
|
|
1588
|
-
}),
|
|
1600
|
+
}), N(x.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new t(this.config.apiKey, this.config.environment), this.stateManager = new Ne({
|
|
1589
1601
|
mounted: !1,
|
|
1590
1602
|
form: null
|
|
1591
|
-
}), this.formManager = new
|
|
1603
|
+
}), this.formManager = new Me({
|
|
1592
1604
|
locale: this.config.locale,
|
|
1593
1605
|
apiKey: this.config.apiKey,
|
|
1594
1606
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
@@ -1597,8 +1609,9 @@ var Q = (e) => ({
|
|
|
1597
1609
|
onLoadingStateChange: (...e) => this._callbacks.onLoadingStateChange?.(...e),
|
|
1598
1610
|
initialValues: this.config.initialValues,
|
|
1599
1611
|
onLoadOutcome: (e) => {
|
|
1600
|
-
this.
|
|
1601
|
-
}
|
|
1612
|
+
this.readiness.markMounted(), this.readiness.settle(e);
|
|
1613
|
+
},
|
|
1614
|
+
onSubmitOutcome: (e) => this.readiness.reportSubmit(e)
|
|
1602
1615
|
}, this.handleSubmit.bind(this));
|
|
1603
1616
|
}
|
|
1604
1617
|
validateConfig(e) {
|
|
@@ -1608,7 +1621,7 @@ var Q = (e) => ({
|
|
|
1608
1621
|
apiKey: e.apiKey,
|
|
1609
1622
|
returnUrl: e.returnUrl,
|
|
1610
1623
|
environment: e.environment,
|
|
1611
|
-
locale: e.locale ||
|
|
1624
|
+
locale: e.locale || Pe,
|
|
1612
1625
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1613
1626
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1614
1627
|
appearance: e.appearance,
|
|
@@ -1621,23 +1634,23 @@ var Q = (e) => ({
|
|
|
1621
1634
|
}
|
|
1622
1635
|
};
|
|
1623
1636
|
}
|
|
1624
|
-
mount(
|
|
1625
|
-
let n;
|
|
1637
|
+
mount(e) {
|
|
1638
|
+
let t, n = !1;
|
|
1626
1639
|
try {
|
|
1627
|
-
let
|
|
1628
|
-
if (!
|
|
1629
|
-
return n = document.createElement("div"),
|
|
1630
|
-
form:
|
|
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({
|
|
1643
|
+
form: t,
|
|
1631
1644
|
mounted: !0
|
|
1632
|
-
}), this.formManager.mount(
|
|
1645
|
+
}), this.formManager.mount(t), this.readiness.markMounted(), N(x.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1633
1646
|
} catch (r) {
|
|
1634
|
-
throw
|
|
1647
|
+
throw t?.remove(), this.stateManager.updateState({
|
|
1635
1648
|
form: null,
|
|
1636
1649
|
mounted: !1
|
|
1637
|
-
}),
|
|
1638
|
-
container_id:
|
|
1650
|
+
}), N(x.CHECKOUT_MOUNT_FAILED, {
|
|
1651
|
+
container_id: e,
|
|
1639
1652
|
error_message: r instanceof Error ? r.message : "Unknown error"
|
|
1640
|
-
}),
|
|
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;
|
|
1641
1654
|
}
|
|
1642
1655
|
}
|
|
1643
1656
|
unmount() {
|
|
@@ -1648,13 +1661,13 @@ var Q = (e) => ({
|
|
|
1648
1661
|
e && e.remove(), this.stateManager.updateState({
|
|
1649
1662
|
form: null,
|
|
1650
1663
|
mounted: !1
|
|
1651
|
-
}),
|
|
1664
|
+
}), N(x.CHECKOUT_UNMOUNTED);
|
|
1652
1665
|
});
|
|
1653
1666
|
}
|
|
1654
1667
|
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1655
1668
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1656
1669
|
let n = this.getPaymentMethod(e, t);
|
|
1657
|
-
|
|
1670
|
+
N(x.PAYMENT_SUBMIT_STARTED, {
|
|
1658
1671
|
payment_id: this.paymentState.paymentId,
|
|
1659
1672
|
payment_method: n
|
|
1660
1673
|
});
|
|
@@ -1666,42 +1679,48 @@ var Q = (e) => ({
|
|
|
1666
1679
|
paymentId: this.paymentState.paymentId,
|
|
1667
1680
|
returnUrl: this.config.returnUrl,
|
|
1668
1681
|
applePayData: t
|
|
1669
|
-
})
|
|
1670
|
-
|
|
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", {
|
|
1671
1689
|
payment_id: this.paymentState.paymentId,
|
|
1672
1690
|
payment_method: n,
|
|
1673
1691
|
status: "success"
|
|
1674
|
-
}),
|
|
1692
|
+
}), N(x.PAYMENT_SUBMIT_SUCCESS, {
|
|
1675
1693
|
payment_id: this.paymentState.paymentId,
|
|
1676
1694
|
payment_method: n
|
|
1677
1695
|
}), this.handlePaymentResponse(i);
|
|
1678
1696
|
} catch (e) {
|
|
1679
1697
|
let t = performance.now() - r;
|
|
1680
|
-
return
|
|
1698
|
+
return E(F.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1681
1699
|
payment_id: this.paymentState.paymentId,
|
|
1682
1700
|
payment_method: n,
|
|
1683
1701
|
status: "failed"
|
|
1684
|
-
}),
|
|
1702
|
+
}), N(x.PAYMENT_SUBMIT_FAILED, {
|
|
1685
1703
|
payment_id: this.paymentState.paymentId,
|
|
1686
1704
|
payment_method: n,
|
|
1687
|
-
error_message: e.details?.message ?? "Unknown error"
|
|
1688
|
-
|
|
1705
|
+
error_message: e.details?.message ?? "Unknown error",
|
|
1706
|
+
...P(e)
|
|
1707
|
+
}), this.readiness.reportSubmit(ie(e, n)), this.handleAuthorizationError(e), !1;
|
|
1689
1708
|
}
|
|
1690
1709
|
}
|
|
1691
1710
|
handlePaymentResponse(e) {
|
|
1692
1711
|
let t = !1;
|
|
1693
|
-
if (e.latestTransaction.status === "authorized" && (
|
|
1712
|
+
if (e.latestTransaction.status === "authorized" && (N(x.PAYMENT_AUTHORIZED, {
|
|
1694
1713
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1695
1714
|
status: e.latestTransaction.status
|
|
1696
|
-
}), 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, {
|
|
1697
1716
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1698
1717
|
status: e.latestTransaction.status
|
|
1699
|
-
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
|
|
1718
|
+
}), y(() => this._callbacks.onPaymentFailed?.(e.latestTransaction.status))), e.status === "requires_action") {
|
|
1700
1719
|
let { redirectUrl: n } = e.action;
|
|
1701
|
-
|
|
1720
|
+
N(x.PAYMENT_ACTION_REQUIRED, {
|
|
1702
1721
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1703
1722
|
status: e.status
|
|
1704
|
-
}), 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;
|
|
1705
1724
|
}
|
|
1706
1725
|
return t;
|
|
1707
1726
|
}
|
|
@@ -1731,37 +1750,42 @@ var Q = (e) => ({
|
|
|
1731
1750
|
locale: e.locale
|
|
1732
1751
|
});
|
|
1733
1752
|
}
|
|
1734
|
-
async associatePayment(
|
|
1735
|
-
if (!
|
|
1736
|
-
let
|
|
1737
|
-
this.paymentState.paymentId =
|
|
1753
|
+
async associatePayment(e, t) {
|
|
1754
|
+
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
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;
|
|
1738
1758
|
try {
|
|
1739
|
-
let
|
|
1740
|
-
id:
|
|
1741
|
-
checkoutKey:
|
|
1759
|
+
let i = await _({
|
|
1760
|
+
id: e,
|
|
1761
|
+
checkoutKey: t,
|
|
1742
1762
|
environment: this.config.environment
|
|
1743
1763
|
});
|
|
1744
|
-
if (!
|
|
1745
|
-
if (!
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
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
|
|
1750
1771
|
};
|
|
1751
|
-
let
|
|
1752
|
-
await this.formManager.associatePayment(
|
|
1753
|
-
payment_id:
|
|
1754
|
-
currency:
|
|
1755
|
-
country_code:
|
|
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, {
|
|
1774
|
+
payment_id: e,
|
|
1775
|
+
currency: i.currency,
|
|
1776
|
+
country_code: i.countryCode
|
|
1756
1777
|
});
|
|
1757
|
-
} catch (
|
|
1758
|
-
|
|
1759
|
-
payment_id:
|
|
1760
|
-
error_message:
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1778
|
+
} catch (t) {
|
|
1779
|
+
if (N(x.PAYMENT_ASSOCIATION_FAILED, {
|
|
1780
|
+
payment_id: e,
|
|
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;
|
|
1765
1789
|
}
|
|
1766
1790
|
}
|
|
1767
1791
|
setCallbacks(e) {
|
|
@@ -1772,4 +1796,4 @@ var Q = (e) => ({
|
|
|
1772
1796
|
//#region libs/checkout/src/index.ts
|
|
1773
1797
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1774
1798
|
//#endregion
|
|
1775
|
-
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 };
|