@odus/checkout 1.18.0 → 1.19.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/checkout.es.js +241 -231
- package/dist/components/checkout/form/AddressSection.d.ts.map +1 -1
- package/dist/components/checkout/form/CardSection.d.ts.map +1 -1
- package/dist/components/checkout/form/CardUnavailableNotice.d.ts.map +1 -1
- package/dist/components/checkout/form/CardholderSection.d.ts.map +1 -1
- package/dist/components/checkout/form/Form.d.ts.map +1 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
- package/dist/components/checkout/form/PhoneCountrySelector.d.ts.map +1 -1
- package/dist/components/checkout/form/PhoneNumberField.d.ts.map +1 -1
- package/dist/components/common/CountryDialCodeDropdown.d.ts.map +1 -1
- package/dist/components/common/Input.d.ts.map +1 -1
- package/dist/components/common/Select.d.ts.map +1 -1
- package/dist/core/constants/fontSize.constants.d.ts +7 -0
- package/dist/core/constants/fontSize.constants.d.ts.map +1 -0
- package/dist/core/vgs/VGSCollectService.d.ts +0 -7
- package/dist/core/vgs/VGSCollectService.d.ts.map +1 -1
- package/dist/elements/ApplePayElement.d.ts.map +1 -1
- package/dist/elements/EmailElement.d.ts.map +1 -1
- package/dist/elements/PayPalElement.d.ts.map +1 -1
- package/dist/elements/PhoneElement.d.ts.map +1 -1
- package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
- package/dist/elements/cardElement.constants.d.ts.map +1 -1
- package/dist/elements/theme/index.d.ts.map +1 -1
- package/dist/elements.es.js +267 -267
- package/dist/factories/createCheckoutProfile.d.ts.map +1 -1
- package/dist/loader.es.js +1 -1
- package/dist/phone.js +477 -474
- package/dist/shared.js +79 -110
- package/dist/types/common/FormData.type.d.ts +0 -2
- package/dist/types/common/FormData.type.d.ts.map +1 -1
- package/dist/types/telemetry/TelemetryEvents.type.d.ts +2 -2
- package/dist/types/telemetry/TelemetryEvents.type.d.ts.map +1 -1
- package/dist/utils/dom/fontFamily.util.d.ts +23 -0
- package/dist/utils/dom/fontFamily.util.d.ts.map +1 -0
- package/dist/utils/dom/googleFontUrl.d.ts +5 -5
- package/dist/utils/dom/googleFontUrl.d.ts.map +1 -1
- package/dist/utils/dom/index.d.ts +1 -0
- package/dist/utils/dom/index.d.ts.map +1 -1
- package/dist/utils/phone/countryDialCodes.d.ts +6 -0
- package/dist/utils/phone/countryDialCodes.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as e, A as t, B as n, C as r,
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, E as i, F as a, I as o, J as s, K as c, L as l, M as u, N as d, O as f, P as p, Q as m, R as h, S as ee, St as te, T as ne, U as re, V as g, W as ie, X as _, Y as ae, Z as oe, _ as se, _t as v, at as ce, b as y, bt as b, c as le, ct as ue, d as de, dt as x, et as fe, f as S, ft as C, g as w, gt as T, h as E, ht as D, i as pe, it as me, j as he, k as ge, l as _e, lt as O, mt as k, n as ve, nt as ye, o as be, ot as A, p as j, pt as M, q as N, r as xe, s as Se, st as P, t as Ce, tt as F, u as I, ut as we, vt as L, w as R, x as z, xt as Te, y as B, yt as V, z as H } from "./shared.js";
|
|
2
2
|
import { t as U } from "./shared2.js";
|
|
3
3
|
//#region libs/checkout/src/utils/focus/FocusManager.ts
|
|
4
|
-
var
|
|
4
|
+
var Ee = class {
|
|
5
5
|
focusSequence = [
|
|
6
6
|
"cardNumber",
|
|
7
7
|
"cardExpiry",
|
|
@@ -81,7 +81,7 @@ var Te = class {
|
|
|
81
81
|
};
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
|
|
84
|
-
function
|
|
84
|
+
function De(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);
|
|
@@ -113,9 +113,9 @@ var G = class extends z {
|
|
|
113
113
|
let { title: t, checkoutProfile: n, fieldsConfig: r, values: i, errors: a, touched: o } = e;
|
|
114
114
|
if (this.grouped) {
|
|
115
115
|
let e = document.createElement("h3");
|
|
116
|
-
e.className = "address-section-title", e.textContent = t, e.style.color = n.styles.textColor, e.style.fontFamily =
|
|
116
|
+
e.className = "address-section-title", e.textContent = t, e.style.color = n.styles.textColor, e.style.fontFamily = R(n.styles.fontFamily), 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()));
|
|
@@ -124,69 +124,69 @@ var G = class extends z {
|
|
|
124
124
|
let a = (t) => t ? `${e}px` : "0px";
|
|
125
125
|
return `${a(t)} ${a(n)} ${a(r)} ${a(i)}`;
|
|
126
126
|
}
|
|
127
|
-
createFields(e, t,
|
|
127
|
+
createFields(e, t, r, i, a) {
|
|
128
128
|
if (!this.grouped) {
|
|
129
|
-
this.createUngroupedFields(e, t,
|
|
129
|
+
this.createUngroupedFields(e, t, r, i, a);
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
let
|
|
132
|
+
let o = e.styles.borderRadius, s = {
|
|
133
133
|
color: e.styles.textColor,
|
|
134
134
|
fontSize: e.styles.fontSize,
|
|
135
135
|
fontFamily: e.styles.fontFamily
|
|
136
|
-
},
|
|
137
|
-
t.street?.enabled &&
|
|
138
|
-
let c = [];
|
|
139
|
-
t.firstName?.enabled && c.push("firstName"), t.lastName?.enabled && c.push("lastName"), c.length > 0 && s.push({
|
|
140
|
-
kind: "name",
|
|
141
|
-
fields: c
|
|
142
|
-
}), t.country?.enabled && s.push({ kind: "country" });
|
|
136
|
+
}, c = [];
|
|
137
|
+
t.street?.enabled && c.push({ kind: "street" });
|
|
143
138
|
let l = [];
|
|
144
|
-
t.
|
|
145
|
-
kind: "
|
|
139
|
+
t.firstName?.enabled && l.push("firstName"), t.lastName?.enabled && l.push("lastName"), l.length > 0 && c.push({
|
|
140
|
+
kind: "name",
|
|
146
141
|
fields: l
|
|
147
|
-
}), t.
|
|
148
|
-
let u =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
}), t.country?.enabled && c.push({ kind: "country" });
|
|
143
|
+
let u = [];
|
|
144
|
+
t.city?.enabled && u.push("city"), t.zipCode?.enabled && u.push("zipCode"), u.length > 0 && c.push({
|
|
145
|
+
kind: "cityZip",
|
|
146
|
+
fields: u
|
|
147
|
+
}), t.state?.enabled && c.push({ kind: "state" });
|
|
148
|
+
let d = c.length;
|
|
149
|
+
c.forEach((e, c) => {
|
|
150
|
+
let l = c === 0, u = c === d - 1, f = (e, t) => ({
|
|
151
|
+
...s,
|
|
152
|
+
borderRadius: this.borderRadius(o, l && e, l && t, u && t, u && e)
|
|
153
153
|
});
|
|
154
154
|
if (e.kind === "street") {
|
|
155
|
-
let e = this.createRow(["full"]),
|
|
156
|
-
this.inputs.set("street",
|
|
155
|
+
let e = this.createRow(["full"]), n = this.createInput("street", t.street?.label ?? this.translationFunc("address.addressLine1"), r.street, i.street, a.street, f(!0, !0), "street-address", t.street?.maxLength);
|
|
156
|
+
this.inputs.set("street", n), e.appendChild(n.getElement()), this.fieldsContainer.appendChild(e);
|
|
157
157
|
} else if (e.kind === "name") {
|
|
158
|
-
let
|
|
158
|
+
let n = this.createRow(e.fields.map(() => "half")), o = e.fields.length === 1;
|
|
159
159
|
if (e.fields.includes("firstName")) {
|
|
160
|
-
let s = o || e.fields[e.fields.length - 1] === "firstName", c = this.createInput("firstName", t.firstName?.label ?? this.translationFunc("address.firstName"),
|
|
161
|
-
this.inputs.set("firstName", c),
|
|
160
|
+
let s = o || e.fields[e.fields.length - 1] === "firstName", c = this.createInput("firstName", t.firstName?.label ?? this.translationFunc("address.firstName"), r.firstName, i.firstName, a.firstName, f(!0, s), "given-name");
|
|
161
|
+
this.inputs.set("firstName", c), n.appendChild(c.getElement());
|
|
162
162
|
}
|
|
163
163
|
if (e.fields.includes("lastName")) {
|
|
164
|
-
let s = o || e.fields[0] === "lastName", c = this.createInput("lastName", t.lastName?.label ?? this.translationFunc("address.lastName"),
|
|
165
|
-
this.inputs.set("lastName", c),
|
|
164
|
+
let s = o || e.fields[0] === "lastName", c = this.createInput("lastName", t.lastName?.label ?? this.translationFunc("address.lastName"), r.lastName, i.lastName, a.lastName, f(s, !0), "family-name");
|
|
165
|
+
this.inputs.set("lastName", c), n.appendChild(c.getElement());
|
|
166
166
|
}
|
|
167
|
-
this.fieldsContainer.appendChild(
|
|
167
|
+
this.fieldsContainer.appendChild(n);
|
|
168
168
|
} else if (e.kind === "country") {
|
|
169
|
-
let e = this.createRow(["full"]),
|
|
170
|
-
this.inputs.set("country",
|
|
169
|
+
let e = this.createRow(["full"]), n = this.createCountrySelect(r.country, i.country, a.country, f(!0, !0), t.country?.options, t.country?.label);
|
|
170
|
+
this.inputs.set("country", n), e.appendChild(n.getElement()), this.fieldsContainer.appendChild(e);
|
|
171
171
|
} else if (e.kind === "cityZip") {
|
|
172
|
-
let
|
|
172
|
+
let n = this.createRow(e.fields.map(() => "half")), o = e.fields.length === 1;
|
|
173
173
|
if (e.fields.includes("city")) {
|
|
174
|
-
let s = o || e.fields[e.fields.length - 1] === "city", c = this.createInput("city", t.city?.label ?? this.translationFunc("address.townCity"),
|
|
175
|
-
this.inputs.set("city", c),
|
|
174
|
+
let s = o || e.fields[e.fields.length - 1] === "city", c = this.createInput("city", t.city?.label ?? this.translationFunc("address.townCity"), r.city, i.city, a.city, f(!0, s), "address-level2");
|
|
175
|
+
this.inputs.set("city", c), n.appendChild(c.getElement());
|
|
176
176
|
}
|
|
177
177
|
if (e.fields.includes("zipCode")) {
|
|
178
|
-
let s = o || e.fields[0] === "zipCode", c = this.createInput("zipCode", t.zipCode?.label ?? this.translationFunc("address.postalCode"),
|
|
179
|
-
this.inputs.set("zipCode", c),
|
|
178
|
+
let s = o || e.fields[0] === "zipCode", c = this.createInput("zipCode", t.zipCode?.label ?? this.translationFunc("address.postalCode"), r.zipCode, i.zipCode, a.zipCode, f(s, !0), "postal-code");
|
|
179
|
+
this.inputs.set("zipCode", c), n.appendChild(c.getElement());
|
|
180
180
|
}
|
|
181
|
-
this.fieldsContainer.appendChild(
|
|
181
|
+
this.fieldsContainer.appendChild(n);
|
|
182
182
|
} else if (e.kind === "state") {
|
|
183
183
|
let e = this.createRow(["full"]);
|
|
184
|
-
if (this.stateFieldConfig = t.state, this.stateRow = e, this.stateStyles =
|
|
185
|
-
let
|
|
186
|
-
this.inputs.set("state",
|
|
184
|
+
if (this.stateFieldConfig = t.state, this.stateRow = e, this.stateStyles = f(!0, !0), this.currentCountry = r.country, t.state?.hiddenForCountries?.includes(r.country) && (e.style.display = "none"), n(r.country)) {
|
|
185
|
+
let n = this.createStateSelect(r.state, i.state, a.state, this.stateStyles, r.country, t.state?.label);
|
|
186
|
+
this.inputs.set("state", n), e.appendChild(n.getElement());
|
|
187
187
|
} else {
|
|
188
|
-
let
|
|
189
|
-
this.inputs.set("state",
|
|
188
|
+
let n = this.createInput("state", t.state?.label ?? this.translationFunc("address.state"), r.state, i.state, a.state, this.stateStyles, "address-level1");
|
|
189
|
+
this.inputs.set("state", n), e.appendChild(n.getElement());
|
|
190
190
|
}
|
|
191
191
|
this.fieldsContainer.appendChild(e);
|
|
192
192
|
}
|
|
@@ -239,7 +239,7 @@ var G = class extends z {
|
|
|
239
239
|
}), l;
|
|
240
240
|
}
|
|
241
241
|
createCountrySelect(e, t, n, r, i, a) {
|
|
242
|
-
let o = `${this.type}Address.country`, s = se(i, this.locale), c = new
|
|
242
|
+
let o = `${this.type}Address.country`, s = se(i, this.locale), c = new S({
|
|
243
243
|
name: o,
|
|
244
244
|
error: !1,
|
|
245
245
|
errorMsg: void 0,
|
|
@@ -281,12 +281,12 @@ var G = class extends z {
|
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
if (!i && r && (this.stateRow.style.display = ""), i) return;
|
|
284
|
-
let a = this.inputs.get("state") instanceof
|
|
284
|
+
let a = this.inputs.get("state") instanceof S, o = n(e);
|
|
285
285
|
if (a && o) {
|
|
286
286
|
let t = this.inputs.get("state");
|
|
287
|
-
if (t instanceof
|
|
288
|
-
let
|
|
289
|
-
t.setOptions(
|
|
287
|
+
if (t instanceof S) {
|
|
288
|
+
let n = g(e), r = h(n), i = this.translationFunc(H(n));
|
|
289
|
+
t.setOptions(r, i);
|
|
290
290
|
}
|
|
291
291
|
this.clearStateValue();
|
|
292
292
|
} else a === o ? !a && !o && t !== e && this.clearStateValue() : (this.rebuildStateField(e), this.clearStateValue());
|
|
@@ -295,7 +295,7 @@ var G = class extends z {
|
|
|
295
295
|
if (!this.stateRow || !this.stateStyles) return;
|
|
296
296
|
this.applyFieldError("state", !1);
|
|
297
297
|
let t = this.inputs.get("state");
|
|
298
|
-
if (t && (t.getElement().remove(), this.inputs.delete("state")),
|
|
298
|
+
if (t && (t.getElement().remove(), this.inputs.delete("state")), n(e)) {
|
|
299
299
|
let t = this.createStateSelect("", void 0, void 0, this.stateStyles, e, this.stateFieldConfig?.label);
|
|
300
300
|
this.inputs.set("state", t), this.stateRow.appendChild(t.getElement());
|
|
301
301
|
} else {
|
|
@@ -316,68 +316,68 @@ var G = class extends z {
|
|
|
316
316
|
detail: { programmatic: !0 }
|
|
317
317
|
}));
|
|
318
318
|
}
|
|
319
|
-
createStateSelect(e, t, r, i, a
|
|
320
|
-
let
|
|
321
|
-
name:
|
|
319
|
+
createStateSelect(e, t, n, r, i, a) {
|
|
320
|
+
let o = `${this.type}Address.state`, s = g(i), c = h(s), l = this.translationFunc(H(s)), u = new S({
|
|
321
|
+
name: o,
|
|
322
322
|
error: !1,
|
|
323
323
|
errorMsg: void 0,
|
|
324
|
-
styles:
|
|
325
|
-
placeholder:
|
|
324
|
+
styles: r,
|
|
325
|
+
placeholder: l,
|
|
326
326
|
renderMessage: !this.grouped,
|
|
327
|
-
...!this.grouped && { label:
|
|
327
|
+
...!this.grouped && { label: a ?? l },
|
|
328
328
|
value: e,
|
|
329
|
-
options:
|
|
329
|
+
options: c,
|
|
330
330
|
autocomplete: "address-level1",
|
|
331
331
|
onChange: (e) => {
|
|
332
332
|
this.applyFieldError("state", !1), this.onChange(U({
|
|
333
333
|
type: "change",
|
|
334
334
|
target: {
|
|
335
|
-
name:
|
|
335
|
+
name: o,
|
|
336
336
|
value: e.target.value
|
|
337
337
|
}
|
|
338
338
|
}));
|
|
339
339
|
}
|
|
340
340
|
});
|
|
341
|
-
return
|
|
341
|
+
return u.addEventListener("blur", (e) => {
|
|
342
342
|
this.onBlur(U({
|
|
343
343
|
type: "blur",
|
|
344
344
|
target: {
|
|
345
|
-
name:
|
|
345
|
+
name: o,
|
|
346
346
|
value: e.target.value
|
|
347
347
|
}
|
|
348
348
|
}));
|
|
349
|
-
}),
|
|
349
|
+
}), u;
|
|
350
350
|
}
|
|
351
|
-
createUngroupedFields(e, t,
|
|
352
|
-
let
|
|
351
|
+
createUngroupedFields(e, t, r, i, a) {
|
|
352
|
+
let o = e.styles.borderRadius, s = {
|
|
353
353
|
color: e.styles.textColor,
|
|
354
354
|
fontSize: e.styles.fontSize,
|
|
355
355
|
fontFamily: e.styles.fontFamily,
|
|
356
|
-
borderRadius: `${
|
|
357
|
-
},
|
|
356
|
+
borderRadius: `${o}px`
|
|
357
|
+
}, c = (e, n, o, c) => {
|
|
358
358
|
if (!t[e]?.enabled) return;
|
|
359
|
-
let l = t[e]?.label ?? this.translationFunc(
|
|
359
|
+
let l = t[e]?.label ?? this.translationFunc(n), u = this.createRow(["full"]), d = this.createInput(e, l, r[e], i[e], a[e], s, o, c);
|
|
360
360
|
this.inputs.set(e, d), u.appendChild(d.getElement()), this.fieldsContainer.appendChild(u);
|
|
361
361
|
};
|
|
362
|
-
if (
|
|
363
|
-
let e = t.country?.label ?? this.translationFunc("address.chooseCountry"),
|
|
364
|
-
this.inputs.set("country",
|
|
362
|
+
if (c("firstName", "address.firstName", "given-name"), c("lastName", "address.lastName", "family-name"), c("street", "address.addressLine1", "street-address", t.street?.maxLength), c("city", "address.townCity", "address-level2"), t.country?.enabled) {
|
|
363
|
+
let e = t.country?.label ?? this.translationFunc("address.chooseCountry"), n = this.createRow(["full"]), o = this.createCountrySelect(r.country, i.country, a.country, s, t.country?.options, e);
|
|
364
|
+
this.inputs.set("country", o), n.appendChild(o.getElement()), this.fieldsContainer.appendChild(n);
|
|
365
365
|
}
|
|
366
366
|
if (t.state?.enabled) {
|
|
367
367
|
this.stateFieldConfig = t.state;
|
|
368
368
|
let e = this.createRow(["full"]);
|
|
369
|
-
this.stateRow = e, this.stateStyles =
|
|
370
|
-
let
|
|
371
|
-
if (
|
|
372
|
-
let t = this.createStateSelect(
|
|
369
|
+
this.stateRow = e, this.stateStyles = s, this.currentCountry = r.country, t.state?.hiddenForCountries?.includes(r.country) && (e.style.display = "none");
|
|
370
|
+
let o = n(r.country), c = t.state?.label ?? this.translationFunc("address.state");
|
|
371
|
+
if (o) {
|
|
372
|
+
let t = this.createStateSelect(r.state, i.state, a.state, s, r.country, c);
|
|
373
373
|
this.inputs.set("state", t), e.appendChild(t.getElement());
|
|
374
374
|
} else {
|
|
375
|
-
let t = this.createInput("state",
|
|
375
|
+
let t = this.createInput("state", c, r.state, i.state, a.state, s, "address-level1");
|
|
376
376
|
this.inputs.set("state", t), e.appendChild(t.getElement());
|
|
377
377
|
}
|
|
378
378
|
this.fieldsContainer.appendChild(e);
|
|
379
379
|
}
|
|
380
|
-
|
|
380
|
+
c("zipCode", "address.postalCode", "postal-code");
|
|
381
381
|
}
|
|
382
382
|
getValue(e) {
|
|
383
383
|
return this.inputs.get(e)?.getValue() ?? "";
|
|
@@ -433,7 +433,7 @@ var G = class extends z {
|
|
|
433
433
|
let e = this.inputs.values().next().value;
|
|
434
434
|
e && e.focus();
|
|
435
435
|
}
|
|
436
|
-
},
|
|
436
|
+
}, Oe = class {
|
|
437
437
|
input = null;
|
|
438
438
|
isVgsMode;
|
|
439
439
|
vgsWrapper = null;
|
|
@@ -453,9 +453,9 @@ var G = class extends z {
|
|
|
453
453
|
let r = document.createElement("div");
|
|
454
454
|
r.style.marginBottom = "4px";
|
|
455
455
|
let i = document.createElement("label");
|
|
456
|
-
i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily =
|
|
456
|
+
i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily = R(e.styles.fontFamily), i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), this.wrapperElement.appendChild(r), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${n}px`, this.vgsWrapper.style.height = this._fieldHeight, this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
|
|
457
457
|
let a = document.createElement("div");
|
|
458
|
-
a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new
|
|
458
|
+
a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new w({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
|
|
459
459
|
}
|
|
460
460
|
buildNativeLayout(e, t, n, r, i, a, o) {
|
|
461
461
|
this.input = new j({
|
|
@@ -537,14 +537,14 @@ var G = class extends z {
|
|
|
537
537
|
this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
|
|
538
538
|
}
|
|
539
539
|
createPaymentMethodSkeleton() {
|
|
540
|
-
let e =
|
|
540
|
+
let e = E.createDiv(["skeleton-field"]), t = E.createDiv(["skeleton", "skeleton-payment-method"]);
|
|
541
541
|
return e.appendChild(t), e;
|
|
542
542
|
}
|
|
543
543
|
createPaymentSeparatorSkeleton() {
|
|
544
|
-
let e =
|
|
544
|
+
let e = E.createDiv(["payment-separator_container"]), t = E.createDiv(["payment-separator__line"]), n = E.createDiv(["skeleton", "skeleton-separator-text"]), r = E.createDiv(["payment-separator__line"]);
|
|
545
545
|
return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
|
|
546
546
|
}
|
|
547
|
-
},
|
|
547
|
+
}, ke = class extends z {
|
|
548
548
|
constructor(e) {
|
|
549
549
|
let { translationFunc: t, checkoutProfile: n } = e;
|
|
550
550
|
super("div", ["payment-separator"]);
|
|
@@ -555,7 +555,7 @@ var G = class extends z {
|
|
|
555
555
|
let o = document.createElement("span");
|
|
556
556
|
o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
|
|
557
557
|
}
|
|
558
|
-
},
|
|
558
|
+
}, Ae = class extends z {
|
|
559
559
|
paymentMethods;
|
|
560
560
|
paymentSeparator;
|
|
561
561
|
skeleton;
|
|
@@ -570,7 +570,7 @@ var G = class extends z {
|
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
572
|
let m = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
|
|
573
|
-
let n = t.enabled, r = !s || s[e] === !0, i =
|
|
573
|
+
let n = t.enabled, r = !s || s[e] === !0, i = be(t.countries, p);
|
|
574
574
|
return n && r && i;
|
|
575
575
|
}).sort((e, t) => e[1].order - t[1].order);
|
|
576
576
|
if (m.length === 0) this.getElement().style.display = "none";
|
|
@@ -578,7 +578,7 @@ var G = class extends z {
|
|
|
578
578
|
for (let [e] of m) switch (e) {
|
|
579
579
|
case "paypal":
|
|
580
580
|
if (r) {
|
|
581
|
-
let e = new
|
|
581
|
+
let e = new xe({
|
|
582
582
|
checkoutProfile: t,
|
|
583
583
|
formData: n,
|
|
584
584
|
onSubmit: r
|
|
@@ -588,7 +588,7 @@ var G = class extends z {
|
|
|
588
588
|
break;
|
|
589
589
|
case "applePay":
|
|
590
590
|
if (i && l && u) {
|
|
591
|
-
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new
|
|
591
|
+
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new pe({
|
|
592
592
|
checkoutProfile: t,
|
|
593
593
|
formData: n,
|
|
594
594
|
onSubmit: i,
|
|
@@ -607,7 +607,7 @@ var G = class extends z {
|
|
|
607
607
|
break;
|
|
608
608
|
default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
|
|
609
609
|
}
|
|
610
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
610
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new ke({
|
|
611
611
|
translationFunc: c,
|
|
612
612
|
checkoutProfile: t
|
|
613
613
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
@@ -625,7 +625,7 @@ var G = class extends z {
|
|
|
625
625
|
hasVisiblePaymentMethods() {
|
|
626
626
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
627
627
|
}
|
|
628
|
-
},
|
|
628
|
+
}, je = 17, Me = class extends z {
|
|
629
629
|
styles;
|
|
630
630
|
isHovered = !1;
|
|
631
631
|
constructor(e) {
|
|
@@ -633,7 +633,7 @@ var G = class extends z {
|
|
|
633
633
|
}
|
|
634
634
|
applyStyles() {
|
|
635
635
|
let e = this.getElement();
|
|
636
|
-
e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius ===
|
|
636
|
+
e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius === je ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
637
637
|
}
|
|
638
638
|
handleMouseEnter() {
|
|
639
639
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -644,12 +644,12 @@ var G = class extends z {
|
|
|
644
644
|
setDisabled(e) {
|
|
645
645
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
646
646
|
}
|
|
647
|
-
}, q = "pay",
|
|
647
|
+
}, q = "pay", Ne = class {
|
|
648
648
|
button;
|
|
649
649
|
constructor(e) {
|
|
650
650
|
let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
|
|
651
|
-
this.button = new
|
|
652
|
-
text:
|
|
651
|
+
this.button = new Me({
|
|
652
|
+
text: Pe(n, r),
|
|
653
653
|
styles: {
|
|
654
654
|
backgroundColor: n.styles.buttonColor,
|
|
655
655
|
color: n.styles.buttonTextColor,
|
|
@@ -673,13 +673,13 @@ var G = class extends z {
|
|
|
673
673
|
return this.button.appendTo(e), this;
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
|
-
function
|
|
676
|
+
function Pe(e, t) {
|
|
677
677
|
let n = `buttonTexts.${e?.layout?.actionButton?.translationKey || q}`, r = t(n);
|
|
678
678
|
return r === n ? t(`buttonTexts.${q}`) : r;
|
|
679
679
|
}
|
|
680
680
|
//#endregion
|
|
681
681
|
//#region libs/checkout/src/components/checkout/form/FormComponentManager.ts
|
|
682
|
-
var
|
|
682
|
+
var Fe = class {
|
|
683
683
|
formElement;
|
|
684
684
|
focusManager;
|
|
685
685
|
translationFunc;
|
|
@@ -719,7 +719,7 @@ var Pe = class {
|
|
|
719
719
|
createPaymentMethods(e, t, n = !1) {
|
|
720
720
|
try {
|
|
721
721
|
if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
|
|
722
|
-
this.removePaymentMethods(), this.paymentMethods = new
|
|
722
|
+
this.removePaymentMethods(), this.paymentMethods = new Ae({
|
|
723
723
|
checkoutProfile: e,
|
|
724
724
|
formData: t,
|
|
725
725
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -741,7 +741,7 @@ var Pe = class {
|
|
|
741
741
|
createEmailField(e, t, n, r) {
|
|
742
742
|
try {
|
|
743
743
|
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);
|
|
744
|
-
this.emailField = new
|
|
744
|
+
this.emailField = new Se({
|
|
745
745
|
value: t.email,
|
|
746
746
|
onChange: this.onChange,
|
|
747
747
|
onBlur: this.onBlur,
|
|
@@ -757,19 +757,30 @@ var Pe = class {
|
|
|
757
757
|
}
|
|
758
758
|
createPhoneNumberField(e, t, n, r) {
|
|
759
759
|
let i = document.createElement("div");
|
|
760
|
-
return this.phonePlaceholder = i, this.formElement.appendChild(i), ie().then(({ PhoneNumberField: a }) =>
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
760
|
+
return this.phonePlaceholder = i, this.formElement.appendChild(i), ie().then(({ PhoneNumberField: a }) => {
|
|
761
|
+
if (this.phonePlaceholder !== i) return !1;
|
|
762
|
+
this.phoneNumberField = new a({
|
|
763
|
+
value: t.phoneNumber ?? "",
|
|
764
|
+
onChange: this.onChange,
|
|
765
|
+
onBlur: this.onBlur,
|
|
766
|
+
onTab: () => this.focusManager.focusField("cardNumber"),
|
|
767
|
+
error: !!(n.phoneNumber && r.phoneNumber),
|
|
768
|
+
errorMsg: n.phoneNumber,
|
|
769
|
+
checkoutProfile: e,
|
|
770
|
+
translationFunc: this.translationFunc,
|
|
771
|
+
defaultCountry: t.phoneCountryCode || e.layout.phoneNumber?.defaultCountry || "US",
|
|
772
|
+
allowedCountries: e.layout.phoneNumber?.allowedCountries,
|
|
773
|
+
locale: this.locale
|
|
774
|
+
}), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField), i.replaceWith(this.phoneNumberField.getElement()), this.phonePlaceholder = void 0;
|
|
775
|
+
let o = this.phoneNumberField.getCountry();
|
|
776
|
+
return t.phoneCountryCode !== o && this.onChange(U({
|
|
777
|
+
type: "input",
|
|
778
|
+
target: {
|
|
779
|
+
name: "phoneCountryCode",
|
|
780
|
+
value: o
|
|
781
|
+
}
|
|
782
|
+
})), !0;
|
|
783
|
+
}).catch((e) => {
|
|
773
784
|
if (console.error("Error creating phone number field:", e), this.phonePlaceholder !== i) return !1;
|
|
774
785
|
throw i.remove(), this.phonePlaceholder = void 0, e;
|
|
775
786
|
});
|
|
@@ -791,7 +802,7 @@ var Pe = class {
|
|
|
791
802
|
}), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
|
|
792
803
|
return;
|
|
793
804
|
}
|
|
794
|
-
this.cardSection = new
|
|
805
|
+
this.cardSection = new _e({
|
|
795
806
|
checkoutProfile: e,
|
|
796
807
|
translationFunc: this.translationFunc,
|
|
797
808
|
vgsService: this.vgsService
|
|
@@ -808,7 +819,7 @@ var Pe = class {
|
|
|
808
819
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
809
820
|
return;
|
|
810
821
|
}
|
|
811
|
-
if (this.cardholderSection = new
|
|
822
|
+
if (this.cardholderSection = new Oe({
|
|
812
823
|
value: t.name,
|
|
813
824
|
onChange: this.onChange,
|
|
814
825
|
onBlur: this.onBlur,
|
|
@@ -890,7 +901,7 @@ var Pe = class {
|
|
|
890
901
|
}
|
|
891
902
|
createSubmitButton(e, t) {
|
|
892
903
|
try {
|
|
893
|
-
this.submitButton = new
|
|
904
|
+
this.submitButton = new Ne({
|
|
894
905
|
disabled: t,
|
|
895
906
|
checkoutProfile: e,
|
|
896
907
|
translationFunc: this.translationFunc
|
|
@@ -942,7 +953,7 @@ var Pe = class {
|
|
|
942
953
|
let t = e.styles.borderRadius, n = y(B, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
|
|
943
954
|
i.style.marginBottom = "4px";
|
|
944
955
|
let a = document.createElement("label");
|
|
945
|
-
a.className = "input-label", a.textContent = this.translationFunc("cardInformation"), a.style.fontFamily =
|
|
956
|
+
a.className = "input-label", a.textContent = this.translationFunc("cardInformation"), a.style.fontFamily = R(e.styles.fontFamily), a.style.fontSize = `${e.styles.fontSize}px`, i.appendChild(a), r.appendChild(i);
|
|
946
957
|
let o = document.createElement("div");
|
|
947
958
|
o.className = "vgs-card-group", o.style.borderRadius = `${t}px`, o.style.background = "#fff", o.style.display = "flex", o.style.flexDirection = "column", o.style.position = "relative";
|
|
948
959
|
let s = document.createElement("div");
|
|
@@ -966,13 +977,13 @@ var Pe = class {
|
|
|
966
977
|
let t = e.styles.borderRadius, n = document.createElement("div"), r = document.createElement("div");
|
|
967
978
|
r.style.marginBottom = "4px";
|
|
968
979
|
let i = document.createElement("label");
|
|
969
|
-
i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily =
|
|
980
|
+
i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = R(e.styles.fontFamily), i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), n.appendChild(r);
|
|
970
981
|
let a = document.createElement("div");
|
|
971
982
|
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = y(B, 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;
|
|
972
983
|
}
|
|
973
984
|
async mountVgsFields(e) {
|
|
974
985
|
if (!this.vgsService || !this.cardSection) return !1;
|
|
975
|
-
let t =
|
|
986
|
+
let t = ee(e.styles.fontFamily);
|
|
976
987
|
await this.vgsService.whenReady();
|
|
977
988
|
let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
|
|
978
989
|
if (this.cardholderSection && a.cardholderName) {
|
|
@@ -1013,7 +1024,7 @@ var Pe = class {
|
|
|
1013
1024
|
}
|
|
1014
1025
|
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);
|
|
1015
1026
|
}
|
|
1016
|
-
},
|
|
1027
|
+
}, Ie = class {
|
|
1017
1028
|
formManager;
|
|
1018
1029
|
focusManager;
|
|
1019
1030
|
onFormSubmit;
|
|
@@ -1053,7 +1064,7 @@ var Pe = class {
|
|
|
1053
1064
|
clearTouchedFields() {
|
|
1054
1065
|
this.localTouchedFields.clear();
|
|
1055
1066
|
}
|
|
1056
|
-
},
|
|
1067
|
+
}, Le = class {
|
|
1057
1068
|
formManager;
|
|
1058
1069
|
checkoutProfile;
|
|
1059
1070
|
formElement;
|
|
@@ -1088,12 +1099,12 @@ var Pe = class {
|
|
|
1088
1099
|
};
|
|
1089
1100
|
isFormDisabled() {
|
|
1090
1101
|
if (this.isCardCaptureUnavailable) return !0;
|
|
1091
|
-
let e = this.formManager.getFormState(), t = this.checkoutProfile.getState(),
|
|
1102
|
+
let e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), r = Object.keys(e.errors).filter((e) => e !== "billingAddress" && e !== "shippingAddress").length > 0, i = e.errors.billingAddress, a = i && typeof i == "object" ? Object.keys(i).length > 0 : !1, o = e.errors.shippingAddress, s = o && typeof o == "object" ? Object.keys(o).length > 0 : !1, c = r || a || s, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: u, shippingFields: d } = t.checkoutProfile?.layout ?? {}, f = (e, t) => {
|
|
1092
1103
|
if (!e) return !0;
|
|
1093
|
-
let
|
|
1094
|
-
return Object.entries(e).every(([e,
|
|
1095
|
-
},
|
|
1096
|
-
return
|
|
1104
|
+
let r = t?.country ?? "";
|
|
1105
|
+
return Object.entries(e).every(([e, i]) => !i?.enabled || e === "state" && (!n(r) || i.hiddenForCountries?.includes(r)) ? !0 : !!t?.[e]?.trim());
|
|
1106
|
+
}, p = Object.values(this.vgsFieldsState), m = p.length > 0 && p.every((e) => e?.isValid === !0), h = this.isVgsMode && !!e.formData.email && l && m && f(u, e.formData.billingAddress) && f(d, e.formData.shippingAddress);
|
|
1107
|
+
return c || !h || this.isSubmitting;
|
|
1097
1108
|
}
|
|
1098
1109
|
setSubmitting(e) {
|
|
1099
1110
|
this.isSubmitting = e;
|
|
@@ -1113,7 +1124,7 @@ var Pe = class {
|
|
|
1113
1124
|
if (!r?.isTouched || r.isFocused || r.isValid) continue;
|
|
1114
1125
|
let i = r.errors?.[0];
|
|
1115
1126
|
if (!i) continue;
|
|
1116
|
-
let a =
|
|
1127
|
+
let a = de(n, i.code);
|
|
1117
1128
|
a && (t[n] = e(a));
|
|
1118
1129
|
}
|
|
1119
1130
|
return t;
|
|
@@ -1124,11 +1135,11 @@ var Pe = class {
|
|
|
1124
1135
|
cleanup() {
|
|
1125
1136
|
this.fontCleanup &&= (this.fontCleanup(), void 0);
|
|
1126
1137
|
}
|
|
1127
|
-
},
|
|
1138
|
+
}, Re = class extends z {
|
|
1128
1139
|
titleElement;
|
|
1129
1140
|
constructor(e = {}) {
|
|
1130
1141
|
super("div", ["blur-bg"]);
|
|
1131
|
-
let t =
|
|
1142
|
+
let t = E.createDiv(["loader"]);
|
|
1132
1143
|
this.titleElement = new z("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1133
1144
|
}
|
|
1134
1145
|
setText(e) {
|
|
@@ -1150,11 +1161,11 @@ var Pe = class {
|
|
|
1150
1161
|
n[i] = e[t];
|
|
1151
1162
|
}
|
|
1152
1163
|
}), n;
|
|
1153
|
-
},
|
|
1164
|
+
}, ze = class {
|
|
1154
1165
|
formElement;
|
|
1155
1166
|
componentManager;
|
|
1156
1167
|
onLoadingStateChange;
|
|
1157
|
-
validationSchema =
|
|
1168
|
+
validationSchema = l();
|
|
1158
1169
|
spinner;
|
|
1159
1170
|
formSkeleton;
|
|
1160
1171
|
alert;
|
|
@@ -1168,7 +1179,7 @@ var Pe = class {
|
|
|
1168
1179
|
this.onLoadingStateChange ? this.onLoadingStateChange(e) : e ? (this.hideSkeleton(), this.formSkeleton = new K(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
1169
1180
|
}
|
|
1170
1181
|
showSpinner(e) {
|
|
1171
|
-
this.hideSpinner(), this.spinner = new
|
|
1182
|
+
this.hideSpinner(), this.spinner = new Re({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
1172
1183
|
}
|
|
1173
1184
|
hideSpinner() {
|
|
1174
1185
|
this.spinner &&= (this.spinner.getElement().remove(), void 0);
|
|
@@ -1177,7 +1188,7 @@ var Pe = class {
|
|
|
1177
1188
|
this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
|
|
1178
1189
|
}
|
|
1179
1190
|
setErrorMessage(e) {
|
|
1180
|
-
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new
|
|
1191
|
+
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new ve({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
|
|
1181
1192
|
}
|
|
1182
1193
|
clearErrorMessage() {
|
|
1183
1194
|
this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
@@ -1185,7 +1196,7 @@ var Pe = class {
|
|
|
1185
1196
|
cleanup() {
|
|
1186
1197
|
this.spinner &&= (this.spinner.getElement().remove(), void 0), this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0), this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
1187
1198
|
}
|
|
1188
|
-
},
|
|
1199
|
+
}, X = "phone_number", Z = "form";
|
|
1189
1200
|
globalThis.navigator.userAgent;
|
|
1190
1201
|
var Q = (e) => ({
|
|
1191
1202
|
street: "",
|
|
@@ -1196,12 +1207,12 @@ var Q = (e) => ({
|
|
|
1196
1207
|
zipCode: "",
|
|
1197
1208
|
country: "",
|
|
1198
1209
|
...e
|
|
1199
|
-
}),
|
|
1210
|
+
}), Be = class extends z {
|
|
1200
1211
|
options;
|
|
1201
|
-
formManager =
|
|
1212
|
+
formManager = o();
|
|
1202
1213
|
checkoutProfile;
|
|
1203
|
-
translation =
|
|
1204
|
-
focusManager = new
|
|
1214
|
+
translation = i();
|
|
1215
|
+
focusManager = new Ee();
|
|
1205
1216
|
componentManager;
|
|
1206
1217
|
eventHandler;
|
|
1207
1218
|
stateCoordinator;
|
|
@@ -1215,7 +1226,7 @@ var Q = (e) => ({
|
|
|
1215
1226
|
constructor(e) {
|
|
1216
1227
|
super("form", ["form-container"]), this.options = e;
|
|
1217
1228
|
let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
|
|
1218
|
-
e.vgsJwt && t && (this.vgsSession = this.createVgsSession(e.vgsJwt), this.vgsService = new
|
|
1229
|
+
e.vgsJwt && t && (this.vgsSession = this.createVgsSession(e.vgsJwt), this.vgsService = new _()), this.checkoutProfile = re({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Fe({
|
|
1219
1230
|
formElement: this.element,
|
|
1220
1231
|
focusManager: this.focusManager,
|
|
1221
1232
|
translationFunc: this.translation.t,
|
|
@@ -1225,7 +1236,7 @@ var Q = (e) => ({
|
|
|
1225
1236
|
onBlur: (e) => this.eventHandler.handleBlur(e),
|
|
1226
1237
|
onPaypalSubmit: async () => this.handlePaypalSubmit(),
|
|
1227
1238
|
onApplePaySubmit: async (e) => this.handleApplePaySubmit(e),
|
|
1228
|
-
onApplePayStartFailed: (e) => this.options.onSubmitOutcome?.(
|
|
1239
|
+
onApplePayStartFailed: (e) => this.options.onSubmitOutcome?.(m(e)),
|
|
1229
1240
|
onApplePayPaymentDataFailed: (e) => this.options.onSubmitOutcome?.(e),
|
|
1230
1241
|
supportedPaymentMethods: e.supportedPaymentMethods,
|
|
1231
1242
|
paymentId: e.paymentId,
|
|
@@ -1233,22 +1244,22 @@ var Q = (e) => ({
|
|
|
1233
1244
|
checkoutDetails: e.checkoutDetails,
|
|
1234
1245
|
environment: e.environment,
|
|
1235
1246
|
vgsService: this.vgsService
|
|
1236
|
-
}), this.uiManager = new
|
|
1247
|
+
}), this.uiManager = new ze({
|
|
1237
1248
|
formElement: this.element,
|
|
1238
1249
|
componentManager: this.componentManager,
|
|
1239
1250
|
onLoadingStateChange: e.onLoadingStateChange
|
|
1240
|
-
}), this.stateCoordinator = new
|
|
1251
|
+
}), this.stateCoordinator = new Le({
|
|
1241
1252
|
formManager: this.formManager,
|
|
1242
1253
|
checkoutProfile: this.checkoutProfile,
|
|
1243
1254
|
componentManager: this.componentManager,
|
|
1244
1255
|
formElement: this.element,
|
|
1245
1256
|
onUIUpdate: () => this.updateFormUI(),
|
|
1246
1257
|
onProfileLoaded: () => this.renderFormComponents(),
|
|
1247
|
-
onRenderFailed: (e) => this.reportRenderFailure(
|
|
1258
|
+
onRenderFailed: (e) => this.reportRenderFailure(Z, e),
|
|
1248
1259
|
onError: (e) => this.uiManager.setErrorMessage(e),
|
|
1249
1260
|
onLoadingChange: (e) => this.uiManager.setLoadingState(e),
|
|
1250
1261
|
getInitialFormData: () => this._getFormStateData().formData
|
|
1251
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
1262
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Ie({
|
|
1252
1263
|
formManager: this.formManager,
|
|
1253
1264
|
focusManager: this.focusManager,
|
|
1254
1265
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -1282,13 +1293,13 @@ var Q = (e) => ({
|
|
|
1282
1293
|
};
|
|
1283
1294
|
}
|
|
1284
1295
|
initializeForm() {
|
|
1285
|
-
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) this.failCardCaptureClosed(
|
|
1296
|
+
if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) this.failCardCaptureClosed(D.NO_TOKENIZATION_SESSION);
|
|
1286
1297
|
else if (this.vgsService) {
|
|
1287
1298
|
let e = this.vgsService;
|
|
1288
1299
|
e.init(this.options.environment).then((t) => {
|
|
1289
1300
|
this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
|
|
1290
1301
|
}).catch((t) => {
|
|
1291
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1302
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(D.INIT_FAILED));
|
|
1292
1303
|
});
|
|
1293
1304
|
}
|
|
1294
1305
|
}
|
|
@@ -1302,11 +1313,11 @@ var Q = (e) => ({
|
|
|
1302
1313
|
this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), this.reportLoadOutcome({
|
|
1303
1314
|
status: "failed",
|
|
1304
1315
|
reason: e
|
|
1305
|
-
}), t ||
|
|
1316
|
+
}), t || P(T.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
|
|
1306
1317
|
}
|
|
1307
1318
|
createVgsSession(e) {
|
|
1308
1319
|
let { paymentId: t, checkoutKey: n, environment: r } = this.options;
|
|
1309
|
-
return new
|
|
1320
|
+
return new s(e, t && n ? ae({
|
|
1310
1321
|
id: t,
|
|
1311
1322
|
checkoutKey: n,
|
|
1312
1323
|
environment: r
|
|
@@ -1329,7 +1340,7 @@ var Q = (e) => ({
|
|
|
1329
1340
|
phoneNumber: "",
|
|
1330
1341
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1331
1342
|
}), 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 =
|
|
1343
|
+
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = De(e.checkoutProfile.layout);
|
|
1333
1344
|
try {
|
|
1334
1345
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
1335
1346
|
} catch (e) {
|
|
@@ -1354,9 +1365,9 @@ var Q = (e) => ({
|
|
|
1354
1365
|
}
|
|
1355
1366
|
let a;
|
|
1356
1367
|
if (e.checkoutProfile.layout.phoneNumber?.enabled) try {
|
|
1357
|
-
a = this.componentManager.createPhoneNumberField(e.checkoutProfile, t, n, r).catch((e) => (this.reportRenderFailure(
|
|
1368
|
+
a = this.componentManager.createPhoneNumberField(e.checkoutProfile, t, n, r).catch((e) => (this.reportRenderFailure(X, e), !1));
|
|
1358
1369
|
} catch (e) {
|
|
1359
|
-
console.error("Failed to create phone number field:", e), this.reportRenderFailure(
|
|
1370
|
+
console.error("Failed to create phone number field:", e), this.reportRenderFailure(X, e), a = Promise.resolve(!1);
|
|
1360
1371
|
}
|
|
1361
1372
|
try {
|
|
1362
1373
|
this.componentManager.createCardSection(e.checkoutProfile);
|
|
@@ -1373,7 +1384,7 @@ var Q = (e) => ({
|
|
|
1373
1384
|
this.componentManager.mountVgsFields(e.checkoutProfile).then(async (e) => {
|
|
1374
1385
|
e && this.vgsMountGeneration === n && this.vgsService === t && (!a || await a) && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
|
|
1375
1386
|
}).catch((e) => {
|
|
1376
|
-
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(
|
|
1387
|
+
this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(D.FIELDS_NOT_READY));
|
|
1377
1388
|
});
|
|
1378
1389
|
}
|
|
1379
1390
|
try {
|
|
@@ -1388,10 +1399,10 @@ var Q = (e) => ({
|
|
|
1388
1399
|
reportRenderFailure(e, t) {
|
|
1389
1400
|
this.reportLoadOutcome({
|
|
1390
1401
|
status: "failed",
|
|
1391
|
-
reason:
|
|
1402
|
+
reason: v.FORM_RENDER_FAILED,
|
|
1392
1403
|
attributes: {
|
|
1393
1404
|
form_part: e,
|
|
1394
|
-
...t !== void 0 && { error_class:
|
|
1405
|
+
...t !== void 0 && { error_class: me(t) }
|
|
1395
1406
|
}
|
|
1396
1407
|
});
|
|
1397
1408
|
}
|
|
@@ -1424,13 +1435,13 @@ var Q = (e) => ({
|
|
|
1424
1435
|
async handleSubmit() {
|
|
1425
1436
|
if (!this.stateCoordinator.isFormDisabled()) try {
|
|
1426
1437
|
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.vgsSession) {
|
|
1427
|
-
this.options.onSubmitOutcome?.(
|
|
1438
|
+
this.options.onSubmitOutcome?.(F(ye(/* @__PURE__ */ Error("Card capture unavailable"), te.CAPTURE_UNAVAILABLE), "card")), this.handleSubmitError(this.translation.t("cardUnavailable"));
|
|
1428
1439
|
return;
|
|
1429
1440
|
}
|
|
1430
1441
|
try {
|
|
1431
1442
|
this.vgsCardResult = await this.vgsService.createCard(this.vgsSession);
|
|
1432
1443
|
} catch (e) {
|
|
1433
|
-
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(
|
|
1444
|
+
console.error("VGS card creation failed:", e), this.options.onSubmitOutcome?.(F(e, "card")), this.handleSubmitError("Card processing failed. Please check your card details and try again.");
|
|
1434
1445
|
return;
|
|
1435
1446
|
}
|
|
1436
1447
|
let e = this.formManager.getFormState().formData;
|
|
@@ -1440,8 +1451,7 @@ var Q = (e) => ({
|
|
|
1440
1451
|
cardId: this.vgsCardResult.cardId,
|
|
1441
1452
|
expMonth: this.vgsCardResult.expMonth,
|
|
1442
1453
|
expYear: this.vgsCardResult.expYear,
|
|
1443
|
-
name: this.vgsCardResult.name
|
|
1444
|
-
...this.vgsCardResult.updatedValues && { updatedValues: this.vgsCardResult.updatedValues }
|
|
1454
|
+
name: this.vgsCardResult.name
|
|
1445
1455
|
}
|
|
1446
1456
|
} : e }), this.uiManager.hideSpinner(), this.options.onLoadingStateChange?.(!1), this.stateCoordinator.setSubmitting(!1), this.updateFormUI();
|
|
1447
1457
|
} catch {
|
|
@@ -1487,21 +1497,21 @@ var Q = (e) => ({
|
|
|
1487
1497
|
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = r, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
|
|
1488
1498
|
let a = this.componentManager.isCardSupported();
|
|
1489
1499
|
if (i && a && (this.vgsSession = this.createVgsSession(i)), i && a && !this.vgsService) {
|
|
1490
|
-
let e = new
|
|
1500
|
+
let e = new _();
|
|
1491
1501
|
this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
|
|
1492
1502
|
this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
|
|
1493
1503
|
}).catch((t) => {
|
|
1494
|
-
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(
|
|
1504
|
+
this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(D.INIT_FAILED));
|
|
1495
1505
|
});
|
|
1496
1506
|
}
|
|
1497
|
-
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(
|
|
1507
|
+
this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(D.NO_TOKENIZATION_SESSION);
|
|
1498
1508
|
let o = this.checkoutProfile.getState();
|
|
1499
1509
|
if (o.checkoutProfile) {
|
|
1500
1510
|
let { formData: e } = this._getFormStateData();
|
|
1501
1511
|
this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
|
|
1502
1512
|
}
|
|
1503
1513
|
}
|
|
1504
|
-
},
|
|
1514
|
+
}, Ve = class {
|
|
1505
1515
|
container = null;
|
|
1506
1516
|
options;
|
|
1507
1517
|
onSubmit;
|
|
@@ -1519,7 +1529,7 @@ var Q = (e) => ({
|
|
|
1519
1529
|
}) : e.errorMsg && !this.options.disableErrorMessages ? this.form.setErrorMessage(e.errorMsg) : this.renderForm(e.errorMsg));
|
|
1520
1530
|
}
|
|
1521
1531
|
renderForm(e) {
|
|
1522
|
-
this.container && (this.form &&= (this.form.destroy(), null), this.form = new
|
|
1532
|
+
this.container && (this.form &&= (this.form.destroy(), null), this.form = new Be({
|
|
1523
1533
|
apiKey: this.options.apiKey,
|
|
1524
1534
|
onSubmit: this.onSubmit,
|
|
1525
1535
|
locale: this.options.locale,
|
|
@@ -1551,7 +1561,7 @@ var Q = (e) => ({
|
|
|
1551
1561
|
async associatePayment(e, t, n, r, i) {
|
|
1552
1562
|
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);
|
|
1553
1563
|
}
|
|
1554
|
-
},
|
|
1564
|
+
}, He = class {
|
|
1555
1565
|
state;
|
|
1556
1566
|
listeners = /* @__PURE__ */ new Set();
|
|
1557
1567
|
constructor(e) {
|
|
@@ -1575,7 +1585,7 @@ var Q = (e) => ({
|
|
|
1575
1585
|
let e = this.getState();
|
|
1576
1586
|
this.listeners.forEach((t) => t(e));
|
|
1577
1587
|
}
|
|
1578
|
-
},
|
|
1588
|
+
}, Ue = "en", $ = class {
|
|
1579
1589
|
config;
|
|
1580
1590
|
_callbacks;
|
|
1581
1591
|
paymentState;
|
|
@@ -1583,17 +1593,17 @@ var Q = (e) => ({
|
|
|
1583
1593
|
formManager;
|
|
1584
1594
|
stateManager;
|
|
1585
1595
|
sessionId;
|
|
1586
|
-
readiness = new
|
|
1596
|
+
readiness = new c();
|
|
1587
1597
|
associationSequence = 0;
|
|
1588
1598
|
constructor(e) {
|
|
1589
|
-
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
1599
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), N(), ce({
|
|
1590
1600
|
environment: this.config.environment,
|
|
1591
1601
|
sessionId: this.sessionId,
|
|
1592
1602
|
integration: "dropin"
|
|
1593
|
-
}),
|
|
1603
|
+
}), P(T.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new ne(this.config.apiKey, this.config.environment), this.stateManager = new He({
|
|
1594
1604
|
mounted: !1,
|
|
1595
1605
|
form: null
|
|
1596
|
-
}), this.formManager = new
|
|
1606
|
+
}), this.formManager = new Ve({
|
|
1597
1607
|
locale: this.config.locale,
|
|
1598
1608
|
apiKey: this.config.apiKey,
|
|
1599
1609
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
@@ -1614,7 +1624,7 @@ var Q = (e) => ({
|
|
|
1614
1624
|
apiKey: e.apiKey,
|
|
1615
1625
|
returnUrl: e.returnUrl,
|
|
1616
1626
|
environment: e.environment,
|
|
1617
|
-
locale: e.locale ||
|
|
1627
|
+
locale: e.locale || Ue,
|
|
1618
1628
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1619
1629
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1620
1630
|
appearance: e.appearance,
|
|
@@ -1635,15 +1645,15 @@ var Q = (e) => ({
|
|
|
1635
1645
|
return n = !0, t = document.createElement("div"), r.appendChild(t), this.stateManager.updateState({
|
|
1636
1646
|
form: t,
|
|
1637
1647
|
mounted: !0
|
|
1638
|
-
}), this.formManager.mount(t), this.readiness.markMounted(),
|
|
1648
|
+
}), this.formManager.mount(t), this.readiness.markMounted(), P(T.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1639
1649
|
} catch (r) {
|
|
1640
1650
|
throw t?.remove(), this.stateManager.updateState({
|
|
1641
1651
|
form: null,
|
|
1642
1652
|
mounted: !1
|
|
1643
|
-
}),
|
|
1653
|
+
}), P(T.CHECKOUT_MOUNT_FAILED, {
|
|
1644
1654
|
container_id: e,
|
|
1645
1655
|
error_message: r instanceof Error ? r.message : "Unknown error"
|
|
1646
|
-
}),
|
|
1656
|
+
}), A(r instanceof Error ? r : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n ? this.readiness.fail({ reason: v.MOUNT_FAILED }) : this.readiness.exclude({ reason: v.CONTAINER_NOT_FOUND }), r;
|
|
1647
1657
|
}
|
|
1648
1658
|
}
|
|
1649
1659
|
unmount() {
|
|
@@ -1654,66 +1664,66 @@ var Q = (e) => ({
|
|
|
1654
1664
|
e && e.remove(), this.stateManager.updateState({
|
|
1655
1665
|
form: null,
|
|
1656
1666
|
mounted: !1
|
|
1657
|
-
}),
|
|
1667
|
+
}), P(T.CHECKOUT_UNMOUNTED);
|
|
1658
1668
|
});
|
|
1659
1669
|
}
|
|
1660
|
-
async handleSubmit({ formData:
|
|
1670
|
+
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1661
1671
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1662
|
-
let
|
|
1663
|
-
|
|
1672
|
+
let n = this.getPaymentMethod(e, t);
|
|
1673
|
+
P(T.PAYMENT_SUBMIT_STARTED, {
|
|
1664
1674
|
payment_id: this.paymentState.paymentId,
|
|
1665
|
-
payment_method:
|
|
1675
|
+
payment_method: n
|
|
1666
1676
|
});
|
|
1667
|
-
let
|
|
1677
|
+
let r = performance.now();
|
|
1668
1678
|
try {
|
|
1669
|
-
let
|
|
1679
|
+
let i = await this.apiService.authorizePayment({
|
|
1670
1680
|
checkoutKey: this.paymentState.checkoutKey,
|
|
1671
|
-
formData:
|
|
1681
|
+
formData: e || null,
|
|
1672
1682
|
paymentId: this.paymentState.paymentId,
|
|
1673
1683
|
returnUrl: this.config.returnUrl,
|
|
1674
|
-
applePayData:
|
|
1684
|
+
applePayData: t
|
|
1675
1685
|
});
|
|
1676
1686
|
this.readiness.reportSubmit({
|
|
1677
|
-
outcome:
|
|
1678
|
-
paymentMethod:
|
|
1687
|
+
outcome: Te.SUCCEEDED,
|
|
1688
|
+
paymentMethod: n
|
|
1679
1689
|
});
|
|
1680
|
-
let a = performance.now() -
|
|
1681
|
-
return
|
|
1690
|
+
let a = performance.now() - r;
|
|
1691
|
+
return O(L.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
|
|
1682
1692
|
payment_id: this.paymentState.paymentId,
|
|
1683
|
-
payment_method:
|
|
1693
|
+
payment_method: n,
|
|
1684
1694
|
status: "success"
|
|
1685
|
-
}),
|
|
1695
|
+
}), P(T.PAYMENT_SUBMIT_SUCCESS, {
|
|
1686
1696
|
payment_id: this.paymentState.paymentId,
|
|
1687
|
-
payment_method:
|
|
1688
|
-
}), this.handlePaymentResponse(
|
|
1689
|
-
} catch (
|
|
1690
|
-
let
|
|
1691
|
-
return
|
|
1697
|
+
payment_method: n
|
|
1698
|
+
}), this.handlePaymentResponse(i);
|
|
1699
|
+
} catch (e) {
|
|
1700
|
+
let t = performance.now() - r;
|
|
1701
|
+
return O(L.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1692
1702
|
payment_id: this.paymentState.paymentId,
|
|
1693
|
-
payment_method:
|
|
1703
|
+
payment_method: n,
|
|
1694
1704
|
status: "failed"
|
|
1695
|
-
}),
|
|
1705
|
+
}), P(T.PAYMENT_SUBMIT_FAILED, {
|
|
1696
1706
|
payment_id: this.paymentState.paymentId,
|
|
1697
|
-
payment_method:
|
|
1698
|
-
error_message:
|
|
1699
|
-
...
|
|
1700
|
-
}), this.readiness.reportSubmit(e
|
|
1707
|
+
payment_method: n,
|
|
1708
|
+
error_message: e.details?.message ?? "Unknown error",
|
|
1709
|
+
...x(e)
|
|
1710
|
+
}), this.readiness.reportSubmit(fe(e, n)), this.handleAuthorizationError(e), !1;
|
|
1701
1711
|
}
|
|
1702
1712
|
}
|
|
1703
1713
|
handlePaymentResponse(e) {
|
|
1704
|
-
let t = !1, n =
|
|
1705
|
-
if (n === "authorized" && (
|
|
1714
|
+
let t = !1, n = Ce(e);
|
|
1715
|
+
if (n === "authorized" && (P(T.PAYMENT_AUTHORIZED, {
|
|
1706
1716
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1707
1717
|
status: n
|
|
1708
|
-
}),
|
|
1718
|
+
}), M(() => this._callbacks.onPaymentSucceeded?.(n)), t = !0), n === "failed" && (P(T.PAYMENT_FAILED, {
|
|
1709
1719
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1710
1720
|
status: n
|
|
1711
|
-
}),
|
|
1721
|
+
}), M(() => this._callbacks.onPaymentFailed?.(n))), e.status === "requires_action") {
|
|
1712
1722
|
let { redirectUrl: n } = e.action;
|
|
1713
|
-
|
|
1723
|
+
P(T.PAYMENT_ACTION_REQUIRED, {
|
|
1714
1724
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1715
1725
|
status: e.status
|
|
1716
|
-
}), this.config.manualActionHandling ?
|
|
1726
|
+
}), this.config.manualActionHandling ? M(() => this._callbacks.onActionRequired?.(n)) : globalThis.location.href = n, t = !0;
|
|
1717
1727
|
}
|
|
1718
1728
|
return t;
|
|
1719
1729
|
}
|
|
@@ -1743,42 +1753,42 @@ var Q = (e) => ({
|
|
|
1743
1753
|
locale: e.locale
|
|
1744
1754
|
});
|
|
1745
1755
|
}
|
|
1746
|
-
async associatePayment(
|
|
1747
|
-
if (!
|
|
1748
|
-
let
|
|
1749
|
-
this.readiness.start(
|
|
1750
|
-
let
|
|
1756
|
+
async associatePayment(t, n) {
|
|
1757
|
+
if (!t || !n) throw Error("paymentId and checkoutKey are required");
|
|
1758
|
+
let r = ++this.associationSequence;
|
|
1759
|
+
this.readiness.start(t), this.paymentState.paymentId = t, this.paymentState.checkoutKey = n, oe(this.config.environment);
|
|
1760
|
+
let i = b.CHECKOUT_DETAILS;
|
|
1751
1761
|
try {
|
|
1752
|
-
let
|
|
1753
|
-
id:
|
|
1754
|
-
checkoutKey:
|
|
1762
|
+
let e = await we({
|
|
1763
|
+
id: t,
|
|
1764
|
+
checkoutKey: n,
|
|
1755
1765
|
environment: this.config.environment
|
|
1756
1766
|
});
|
|
1757
|
-
if (!
|
|
1758
|
-
if (!
|
|
1759
|
-
if (
|
|
1760
|
-
|
|
1761
|
-
amount:
|
|
1762
|
-
currency:
|
|
1763
|
-
countryCode:
|
|
1767
|
+
if (!e || !e.supportedPaymentMethods || !Array.isArray(e.supportedPaymentMethods)) throw k(/* @__PURE__ */ Error("Invalid response: supportedPaymentMethods must be an array"), V.INVALID_RESPONSE, C(e));
|
|
1768
|
+
if (!e.supportedPaymentMethods.every((e) => typeof e == "string")) throw k(/* @__PURE__ */ Error("Invalid response: all supportedPaymentMethods must be strings"), V.INVALID_RESPONSE, C(e));
|
|
1769
|
+
if (r !== this.associationSequence) return;
|
|
1770
|
+
i = b.FORM_SETUP, this.readiness.markAssociated(), this.paymentState.checkoutDetails = {
|
|
1771
|
+
amount: e.amount,
|
|
1772
|
+
currency: e.currency,
|
|
1773
|
+
countryCode: e.countryCode
|
|
1764
1774
|
};
|
|
1765
|
-
let a =
|
|
1766
|
-
await this.formManager.associatePayment(
|
|
1767
|
-
payment_id:
|
|
1768
|
-
currency:
|
|
1769
|
-
country_code:
|
|
1775
|
+
let a = e.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
|
|
1776
|
+
await this.formManager.associatePayment(t, n, a, this.paymentState.checkoutDetails, e.vgsJwt), P(T.PAYMENT_ASSOCIATED, {
|
|
1777
|
+
payment_id: t,
|
|
1778
|
+
currency: e.currency,
|
|
1779
|
+
country_code: e.countryCode
|
|
1770
1780
|
});
|
|
1771
|
-
} catch (
|
|
1772
|
-
if (
|
|
1773
|
-
payment_id:
|
|
1774
|
-
error_message:
|
|
1775
|
-
stage:
|
|
1776
|
-
...
|
|
1777
|
-
}),
|
|
1778
|
-
let { ours:
|
|
1779
|
-
|
|
1781
|
+
} catch (n) {
|
|
1782
|
+
if (P(T.PAYMENT_ASSOCIATION_FAILED, {
|
|
1783
|
+
payment_id: t,
|
|
1784
|
+
error_message: n instanceof Error ? n.message : "Unknown error",
|
|
1785
|
+
stage: i,
|
|
1786
|
+
...x(n)
|
|
1787
|
+
}), A(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: t }), r === this.associationSequence) {
|
|
1788
|
+
let { ours: t, ...r } = e(n, i);
|
|
1789
|
+
t ? this.readiness.fail(r) : this.readiness.exclude(r);
|
|
1780
1790
|
}
|
|
1781
|
-
throw
|
|
1791
|
+
throw n;
|
|
1782
1792
|
}
|
|
1783
1793
|
}
|
|
1784
1794
|
setCallbacks(e) {
|
|
@@ -1789,4 +1799,4 @@ var Q = (e) => ({
|
|
|
1789
1799
|
//#region libs/checkout/src/index.ts
|
|
1790
1800
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1791
1801
|
//#endregion
|
|
1792
|
-
export { $ as OdusCheckout,
|
|
1802
|
+
export { $ as OdusCheckout, a as deLocale, p as enLocale, d as esLocale, u as frLocale, he as itLocale, t as plLocale, ge as ptLocale, A as pushError, P as pushEvent, ue as pushLog, O as pushMeasurement, f as trLocale };
|