@odus/checkout 1.8.0 → 1.8.2
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 +166 -145
- package/dist/components/checkout/card-elements/CardCvvElement.d.ts.map +1 -1
- package/dist/components/checkout/card-elements/CardNumberElement.d.ts.map +1 -1
- package/dist/components/checkout/form/AddressSection.d.ts +10 -0
- package/dist/components/checkout/form/AddressSection.d.ts.map +1 -1
- package/dist/components/checkout/form/CardSection.d.ts +14 -1
- package/dist/components/checkout/form/CardSection.d.ts.map +1 -1
- package/dist/components/checkout/form/CardholderSection.d.ts.map +1 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts +1 -0
- package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
- package/dist/components/checkout/form/PaymentMethods.d.ts.map +1 -1
- package/dist/components/common/HelperText.d.ts +2 -0
- package/dist/components/common/HelperText.d.ts.map +1 -1
- package/dist/components/common/Input.d.ts +14 -2
- package/dist/components/common/Input.d.ts.map +1 -1
- package/dist/components/common/Select.d.ts +7 -0
- package/dist/components/common/Select.d.ts.map +1 -1
- package/dist/elements/ApplePayElement.d.ts.map +1 -1
- package/dist/elements/CardElement.d.ts +1 -0
- package/dist/elements/CardElement.d.ts.map +1 -1
- package/dist/elements/card/VgsCardAdapter.d.ts +6 -0
- package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
- package/dist/elements.es.js +184 -173
- package/dist/index.css +1 -1
- package/dist/locales/cs.json.d.ts +1 -1
- package/dist/locales/de.json.d.ts +1 -1
- package/dist/locales/en.json.d.ts +1 -1
- package/dist/locales/es.json.d.ts +1 -1
- package/dist/locales/fr.json.d.ts +1 -1
- package/dist/locales/it.json.d.ts +1 -1
- package/dist/locales/nl.json.d.ts +1 -1
- package/dist/locales/pl.json.d.ts +1 -1
- package/dist/locales/pt.json.d.ts +1 -1
- package/dist/locales/sk.json.d.ts +1 -1
- package/dist/locales/tr.json.d.ts +1 -1
- package/dist/phone.js +29 -29
- package/dist/shared.js +169 -151
- package/dist/utils/country/isCountryAllowed.util.d.ts +17 -0
- package/dist/utils/country/isCountryAllowed.util.d.ts.map +1 -0
- package/dist/utils/helpers/vgsFieldMetrics.util.d.ts +9 -0
- package/dist/utils/helpers/vgsFieldMetrics.util.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { A as e,
|
|
1
|
+
import { A as e, B as t, C 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, S as h, T as g, V as _, W as ee, X as v, Y as y, Z as b, a as x, b as S, c as C, d as w, g as T, h as E, j as D, k as O, l as k, m as A, n as te, o as ne, p as j, q as re, r as ie, s as M, t as N, u as P, w as F, x as I, y as L, z as R } from "./shared.js";
|
|
2
2
|
//#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
|
|
3
|
-
function
|
|
3
|
+
function z(e) {
|
|
4
4
|
if (!e) return !1;
|
|
5
5
|
let { billingFields: t, shippingFields: n } = e, r = t && Object.values(t).some((e) => e?.enabled), i = n && Object.values(n).some((e) => e?.enabled);
|
|
6
6
|
return !!(r || i);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function B(e) {
|
|
9
9
|
if (!e) return !1;
|
|
10
10
|
let { billingFields: t, shippingFields: n } = e, r = t?.firstName?.enabled && t?.lastName?.enabled, i = n?.firstName?.enabled && n?.lastName?.enabled;
|
|
11
11
|
return !!(r || i);
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region libs/checkout/src/components/checkout/form/AddressSection.ts
|
|
15
|
-
var
|
|
15
|
+
var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
|
|
16
16
|
inputs = /* @__PURE__ */ new Map();
|
|
17
17
|
type;
|
|
18
18
|
onChange;
|
|
@@ -24,6 +24,8 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
24
24
|
currentCountry = "";
|
|
25
25
|
stateRow = null;
|
|
26
26
|
stateFieldConfig;
|
|
27
|
+
groupMessage = null;
|
|
28
|
+
groupMessages = /* @__PURE__ */ new Map();
|
|
27
29
|
stateStyles;
|
|
28
30
|
constructor(e) {
|
|
29
31
|
super("div", ["address-section"]), this.type = e.type, this.onChange = e.onChange, this.onBlur = e.onBlur, this.translationFunc = e.translationFunc, this.locale = e.locale, this.grouped = e.grouped ?? !0;
|
|
@@ -32,7 +34,10 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
32
34
|
let e = document.createElement("h3");
|
|
33
35
|
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);
|
|
34
36
|
}
|
|
35
|
-
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)
|
|
37
|
+
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 A({
|
|
38
|
+
text: "",
|
|
39
|
+
visible: !1
|
|
40
|
+
}), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
|
|
36
41
|
}
|
|
37
42
|
borderRadius(e, t, n, r, i) {
|
|
38
43
|
let a = (t) => t ? `${e}px` : "0px";
|
|
@@ -103,7 +108,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
103
108
|
}
|
|
104
109
|
if (e.kind === "state") {
|
|
105
110
|
let e = this.createRow(["full"]);
|
|
106
|
-
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"),
|
|
111
|
+
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"), V.has(n.country)) {
|
|
107
112
|
let a = this.createStateSelect(n.state, r.state, i.state, this.stateStyles, n.country, t.state?.label);
|
|
108
113
|
this.inputs.set("state", a), e.appendChild(a.getElement());
|
|
109
114
|
} else {
|
|
@@ -119,12 +124,13 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
119
124
|
return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
|
|
120
125
|
}
|
|
121
126
|
createInput(e, t, n, r, i, a, o, s) {
|
|
122
|
-
let c = `${this.type}Address.${e}`, l = new
|
|
127
|
+
let c = `${this.type}Address.${e}`, l = new w({
|
|
123
128
|
name: c,
|
|
124
129
|
error: !1,
|
|
125
130
|
errorMsg: void 0,
|
|
126
131
|
styles: a,
|
|
127
132
|
maxLength: s,
|
|
133
|
+
renderMessage: !this.grouped,
|
|
128
134
|
...this.grouped ? { placeholder: t } : {
|
|
129
135
|
label: t,
|
|
130
136
|
placeholder: (() => {
|
|
@@ -134,23 +140,23 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
134
140
|
},
|
|
135
141
|
value: n,
|
|
136
142
|
autocomplete: o,
|
|
137
|
-
onChange: (
|
|
138
|
-
let
|
|
139
|
-
if (s &&
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
} else
|
|
143
|
-
this.onChange(
|
|
143
|
+
onChange: (t) => {
|
|
144
|
+
let n = t.target.value;
|
|
145
|
+
if (s && n.length >= s) {
|
|
146
|
+
let t = this.translationFunc("validation.maxLengthExceeded");
|
|
147
|
+
this.applyFieldError(e, !0, t.replace("{{max}}", String(s)));
|
|
148
|
+
} else this.applyFieldError(e, !1);
|
|
149
|
+
this.onChange(F({
|
|
144
150
|
type: "input",
|
|
145
151
|
target: {
|
|
146
152
|
name: c,
|
|
147
|
-
value:
|
|
153
|
+
value: n
|
|
148
154
|
}
|
|
149
155
|
}));
|
|
150
156
|
}
|
|
151
157
|
});
|
|
152
158
|
return l.addEventListener("blur", (e) => {
|
|
153
|
-
this.onBlur(
|
|
159
|
+
this.onBlur(F({
|
|
154
160
|
type: "blur",
|
|
155
161
|
target: {
|
|
156
162
|
name: c,
|
|
@@ -160,20 +166,21 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
160
166
|
}), l;
|
|
161
167
|
}
|
|
162
168
|
createCountrySelect(e, t, n, r, i, a) {
|
|
163
|
-
let o = `${this.type}Address.country`, s =
|
|
169
|
+
let o = `${this.type}Address.country`, s = T(i, this.locale), c = new P({
|
|
164
170
|
name: o,
|
|
165
171
|
error: !1,
|
|
166
172
|
errorMsg: void 0,
|
|
167
173
|
styles: r,
|
|
168
174
|
placeholder: this.translationFunc("address.chooseCountry"),
|
|
175
|
+
renderMessage: !this.grouped,
|
|
169
176
|
...!this.grouped && { label: a ?? this.translationFunc("address.chooseCountry") },
|
|
170
177
|
value: e,
|
|
171
178
|
options: s,
|
|
172
179
|
autocomplete: "country",
|
|
173
180
|
onChange: (e) => {
|
|
174
|
-
|
|
181
|
+
this.applyFieldError("country", !1);
|
|
175
182
|
let t = e.target.value;
|
|
176
|
-
this.onChange(
|
|
183
|
+
this.onChange(F({
|
|
177
184
|
type: "change",
|
|
178
185
|
target: {
|
|
179
186
|
name: o,
|
|
@@ -183,7 +190,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
183
190
|
}
|
|
184
191
|
});
|
|
185
192
|
return c.addEventListener("blur", (e) => {
|
|
186
|
-
this.onBlur(
|
|
193
|
+
this.onBlur(F({
|
|
187
194
|
type: "blur",
|
|
188
195
|
target: {
|
|
189
196
|
name: o,
|
|
@@ -197,15 +204,15 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
197
204
|
if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
|
|
198
205
|
let n = this.stateFieldConfig.hiddenForCountries?.includes(t), r = this.stateFieldConfig.hiddenForCountries?.includes(e);
|
|
199
206
|
if (r && !n) {
|
|
200
|
-
this.stateRow.style.display = "none", this.clearStateValue();
|
|
207
|
+
this.stateRow.style.display = "none", this.applyFieldError("state", !1), this.clearStateValue();
|
|
201
208
|
return;
|
|
202
209
|
}
|
|
203
210
|
if (!r && n && (this.stateRow.style.display = ""), r) return;
|
|
204
|
-
let i = this.inputs.get("state") instanceof
|
|
211
|
+
let i = this.inputs.get("state") instanceof P, a = V.has(e);
|
|
205
212
|
if (i && a) {
|
|
206
213
|
let t = this.inputs.get("state");
|
|
207
|
-
if (t instanceof
|
|
208
|
-
let n = e === "CA" ? "CA" : "US", r =
|
|
214
|
+
if (t instanceof P) {
|
|
215
|
+
let n = e === "CA" ? "CA" : "US", r = E(n), i = n === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
|
|
209
216
|
t.setOptions(r, i);
|
|
210
217
|
}
|
|
211
218
|
this.clearStateValue();
|
|
@@ -219,8 +226,9 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
219
226
|
}
|
|
220
227
|
rebuildStateField(e) {
|
|
221
228
|
if (!this.stateRow || !this.stateStyles) return;
|
|
229
|
+
this.applyFieldError("state", !1);
|
|
222
230
|
let t = this.inputs.get("state");
|
|
223
|
-
if (t && (t.getElement().remove(), this.inputs.delete("state")),
|
|
231
|
+
if (t && (t.getElement().remove(), this.inputs.delete("state")), V.has(e)) {
|
|
224
232
|
let t = this.createStateSelect("", void 0, void 0, this.stateStyles, e, this.stateFieldConfig?.label);
|
|
225
233
|
this.inputs.set("state", t), this.stateRow.appendChild(t.getElement());
|
|
226
234
|
} else {
|
|
@@ -232,7 +240,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
232
240
|
let e = this.inputs.get("state");
|
|
233
241
|
e && e.setValue("");
|
|
234
242
|
let t = `${this.type}Address.state`;
|
|
235
|
-
this.onChange(
|
|
243
|
+
this.onChange(F({
|
|
236
244
|
type: "input",
|
|
237
245
|
target: {
|
|
238
246
|
name: t,
|
|
@@ -242,18 +250,19 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
242
250
|
}));
|
|
243
251
|
}
|
|
244
252
|
createStateSelect(e, t, n, r, i, a) {
|
|
245
|
-
let o = `${this.type}Address.state`, s = i === "CA" ? "CA" : "US", c =
|
|
253
|
+
let o = `${this.type}Address.state`, s = i === "CA" ? "CA" : "US", c = E(s), l = s === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), u = new P({
|
|
246
254
|
name: o,
|
|
247
255
|
error: !1,
|
|
248
256
|
errorMsg: void 0,
|
|
249
257
|
styles: r,
|
|
250
258
|
placeholder: l,
|
|
259
|
+
renderMessage: !this.grouped,
|
|
251
260
|
...!this.grouped && { label: a ?? l },
|
|
252
261
|
value: e,
|
|
253
262
|
options: c,
|
|
254
263
|
autocomplete: "address-level1",
|
|
255
264
|
onChange: (e) => {
|
|
256
|
-
|
|
265
|
+
this.applyFieldError("state", !1), this.onChange(F({
|
|
257
266
|
type: "change",
|
|
258
267
|
target: {
|
|
259
268
|
name: o,
|
|
@@ -263,7 +272,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
263
272
|
}
|
|
264
273
|
});
|
|
265
274
|
return u.addEventListener("blur", (e) => {
|
|
266
|
-
this.onBlur(
|
|
275
|
+
this.onBlur(F({
|
|
267
276
|
type: "blur",
|
|
268
277
|
target: {
|
|
269
278
|
name: o,
|
|
@@ -291,7 +300,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
291
300
|
this.stateFieldConfig = t.state;
|
|
292
301
|
let e = this.createRow(["full"]);
|
|
293
302
|
this.stateRow = e, this.stateStyles = o, this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none");
|
|
294
|
-
let a =
|
|
303
|
+
let a = V.has(n.country), s = t.state?.label ?? this.translationFunc("address.state");
|
|
295
304
|
if (a) {
|
|
296
305
|
let t = this.createStateSelect(n.state, r.state, i.state, o, n.country, s);
|
|
297
306
|
this.inputs.set("state", t), e.appendChild(t.getElement());
|
|
@@ -328,10 +337,18 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
328
337
|
setError(e, t, n) {
|
|
329
338
|
let r = this.inputs.get(e);
|
|
330
339
|
if (r) {
|
|
331
|
-
let
|
|
332
|
-
document.activeElement !==
|
|
340
|
+
let i = r.getElement().querySelector("input") || r.getElement().querySelector("select");
|
|
341
|
+
document.activeElement !== i && this.applyFieldError(e, t, n);
|
|
333
342
|
}
|
|
334
343
|
}
|
|
344
|
+
applyFieldError(e, t, n) {
|
|
345
|
+
this.inputs.get(e)?.setError(t, n), this.groupMessage && (t && n ? this.groupMessages.set(e, n) : this.groupMessages.delete(e), this.renderGroupMessage());
|
|
346
|
+
}
|
|
347
|
+
renderGroupMessage() {
|
|
348
|
+
if (!this.groupMessage) return;
|
|
349
|
+
let e = [...this.inputs.keys()].find((e) => this.groupMessages.has(e)), t = e && this.groupMessages.get(e);
|
|
350
|
+
t ? this.groupMessage.setText(t).toggleVisibility(!0) : this.groupMessage.toggleVisibility(!1);
|
|
351
|
+
}
|
|
335
352
|
updateField(e, t, n, r) {
|
|
336
353
|
let i = this.inputs.get(e);
|
|
337
354
|
if (!i) return;
|
|
@@ -349,7 +366,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
349
366
|
let e = this.inputs.values().next().value;
|
|
350
367
|
e && e.focus();
|
|
351
368
|
}
|
|
352
|
-
},
|
|
369
|
+
}, U = class {
|
|
353
370
|
input = null;
|
|
354
371
|
isVgsMode;
|
|
355
372
|
vgsWrapper = null;
|
|
@@ -357,7 +374,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
357
374
|
vgsHelperText = null;
|
|
358
375
|
wrapperElement;
|
|
359
376
|
_vgsFieldsReady = !1;
|
|
360
|
-
_fieldHeight =
|
|
377
|
+
_fieldHeight = S(L, 14);
|
|
361
378
|
_borderRadius = 0;
|
|
362
379
|
constructor(e) {
|
|
363
380
|
let { value: t, onChange: n, onBlur: r, errorMsg: i, checkoutProfile: a, translationFunc: o, autocomplete: s = "cc-name", isVgsMode: c = !1 } = e;
|
|
@@ -365,16 +382,16 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
365
382
|
}
|
|
366
383
|
buildVgsLayout(e, t) {
|
|
367
384
|
let n = e.styles.borderRadius;
|
|
368
|
-
this._borderRadius = n;
|
|
385
|
+
this._borderRadius = n, this._fieldHeight = S(L, e.styles.fontSize);
|
|
369
386
|
let r = document.createElement("div");
|
|
370
387
|
r.style.marginBottom = "4px";
|
|
371
388
|
let i = document.createElement("label");
|
|
372
|
-
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 =
|
|
389
|
+
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";
|
|
373
390
|
let a = document.createElement("div");
|
|
374
|
-
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
|
|
391
|
+
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 A({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
|
|
375
392
|
}
|
|
376
393
|
buildNativeLayout(e, t, n, r, i, a, o) {
|
|
377
|
-
this.input = new
|
|
394
|
+
this.input = new w({
|
|
378
395
|
name: "name",
|
|
379
396
|
label: a("cardholderNameLabel"),
|
|
380
397
|
error: !1,
|
|
@@ -401,9 +418,9 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
401
418
|
}
|
|
402
419
|
handleVgsStateChange(e, t) {
|
|
403
420
|
if (!this.isVgsMode || !this.vgsWrapper) return;
|
|
404
|
-
let n = e[
|
|
421
|
+
let n = e[C.CARDHOLDER]?.isFocused;
|
|
405
422
|
if (this._vgsFieldsReady && (this.vgsWrapper.style.boxShadow = n ? "0 0 0 1px rgba(50, 151, 211, 0.7), 0 1px 1px 0 rgba(0, 0, 0, 0.07), 0 0 0 4px rgba(50, 151, 211, 0.3)" : "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)"), !t || !this.vgsHelperText) return;
|
|
406
|
-
let r = t[
|
|
423
|
+
let r = t[C.CARDHOLDER];
|
|
407
424
|
r ? (this.vgsHelperText.setText(r), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
|
|
408
425
|
}
|
|
409
426
|
setFieldHeight(e) {
|
|
@@ -445,7 +462,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
445
462
|
focus() {
|
|
446
463
|
this.isVgsMode || this.input?.focus();
|
|
447
464
|
}
|
|
448
|
-
},
|
|
465
|
+
}, W = class extends I {
|
|
449
466
|
constructor() {
|
|
450
467
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
451
468
|
}
|
|
@@ -453,14 +470,14 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
453
470
|
this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
|
|
454
471
|
}
|
|
455
472
|
createPaymentMethodSkeleton() {
|
|
456
|
-
let e =
|
|
473
|
+
let e = j.createDiv(["skeleton-field"]), t = j.createDiv(["skeleton", "skeleton-payment-method"]);
|
|
457
474
|
return e.appendChild(t), e;
|
|
458
475
|
}
|
|
459
476
|
createPaymentSeparatorSkeleton() {
|
|
460
|
-
let e =
|
|
477
|
+
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"]);
|
|
461
478
|
return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
|
|
462
479
|
}
|
|
463
|
-
},
|
|
480
|
+
}, G = class extends I {
|
|
464
481
|
constructor(e) {
|
|
465
482
|
let { translationFunc: t, checkoutProfile: n } = e;
|
|
466
483
|
super("div", ["payment-separator"]);
|
|
@@ -471,7 +488,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
471
488
|
let o = document.createElement("span");
|
|
472
489
|
o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
|
|
473
490
|
}
|
|
474
|
-
},
|
|
491
|
+
}, K = class extends I {
|
|
475
492
|
paymentMethods;
|
|
476
493
|
paymentSeparator;
|
|
477
494
|
skeleton;
|
|
@@ -486,7 +503,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
486
503
|
return;
|
|
487
504
|
}
|
|
488
505
|
let f = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
|
|
489
|
-
let n = t.enabled, r = !a || a[e] === !0, i =
|
|
506
|
+
let n = t.enabled, r = !a || a[e] === !0, i = x(t.countries, d);
|
|
490
507
|
return n && r && i;
|
|
491
508
|
}).sort((e, t) => e[1].order - t[1].order);
|
|
492
509
|
if (f.length === 0) {
|
|
@@ -496,7 +513,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
496
513
|
for (let [e] of f) switch (e) {
|
|
497
514
|
case "paypal":
|
|
498
515
|
if (r) {
|
|
499
|
-
let e = new
|
|
516
|
+
let e = new te({
|
|
500
517
|
checkoutProfile: t,
|
|
501
518
|
formData: n,
|
|
502
519
|
onSubmit: r
|
|
@@ -506,7 +523,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
506
523
|
break;
|
|
507
524
|
case "applePay":
|
|
508
525
|
if (i && s && c) {
|
|
509
|
-
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new
|
|
526
|
+
let e = t.appearance?.additionalPaymentMethods?.applePay, r = new ie({
|
|
510
527
|
checkoutProfile: t,
|
|
511
528
|
formData: n,
|
|
512
529
|
onSubmit: i,
|
|
@@ -523,13 +540,13 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
523
540
|
break;
|
|
524
541
|
default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
|
|
525
542
|
}
|
|
526
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
543
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new G({
|
|
527
544
|
translationFunc: o,
|
|
528
545
|
checkoutProfile: t
|
|
529
546
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
530
547
|
}
|
|
531
548
|
renderSkeleton() {
|
|
532
|
-
this.skeleton = new
|
|
549
|
+
this.skeleton = new W(), this.getElement().appendChild(this.skeleton.getElement());
|
|
533
550
|
}
|
|
534
551
|
updateFormData(e) {
|
|
535
552
|
let t = this.paymentMethods.get("paypal");
|
|
@@ -540,7 +557,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
540
557
|
hasVisiblePaymentMethods() {
|
|
541
558
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
542
559
|
}
|
|
543
|
-
},
|
|
560
|
+
}, q = 17, J = class extends I {
|
|
544
561
|
styles;
|
|
545
562
|
isHovered = !1;
|
|
546
563
|
constructor(e) {
|
|
@@ -548,7 +565,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
548
565
|
}
|
|
549
566
|
applyStyles() {
|
|
550
567
|
let e = this.getElement();
|
|
551
|
-
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 ===
|
|
568
|
+
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 === q ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
552
569
|
}
|
|
553
570
|
handleMouseEnter() {
|
|
554
571
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -559,11 +576,11 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
559
576
|
setDisabled(e) {
|
|
560
577
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
561
578
|
}
|
|
562
|
-
},
|
|
579
|
+
}, ae = class {
|
|
563
580
|
button;
|
|
564
581
|
constructor(e) {
|
|
565
582
|
let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
|
|
566
|
-
this.button = new
|
|
583
|
+
this.button = new J({
|
|
567
584
|
text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
|
|
568
585
|
styles: {
|
|
569
586
|
backgroundColor: n.styles.buttonColor,
|
|
@@ -587,7 +604,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
587
604
|
appendTo(e) {
|
|
588
605
|
return this.button.appendTo(e), this;
|
|
589
606
|
}
|
|
590
|
-
},
|
|
607
|
+
}, oe = class {
|
|
591
608
|
formElement;
|
|
592
609
|
focusManager;
|
|
593
610
|
translationFunc;
|
|
@@ -628,7 +645,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
628
645
|
createPaymentMethods(e, t, n = !1) {
|
|
629
646
|
try {
|
|
630
647
|
if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
|
|
631
|
-
this.paymentMethods = new
|
|
648
|
+
this.paymentMethods = new K({
|
|
632
649
|
checkoutProfile: e,
|
|
633
650
|
formData: t,
|
|
634
651
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -648,7 +665,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
648
665
|
createEmailField(e, t, n, r) {
|
|
649
666
|
try {
|
|
650
667
|
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);
|
|
651
|
-
this.emailField = new
|
|
668
|
+
this.emailField = new ne({
|
|
652
669
|
value: t.email,
|
|
653
670
|
onChange: this.onChange,
|
|
654
671
|
onBlur: this.onBlur,
|
|
@@ -664,7 +681,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
664
681
|
}
|
|
665
682
|
createPhoneNumberField(e, t, n, r) {
|
|
666
683
|
let i = document.createElement("div");
|
|
667
|
-
this.phonePlaceholder = i, this.formElement.appendChild(i),
|
|
684
|
+
this.phonePlaceholder = i, this.formElement.appendChild(i), o().then(({ PhoneNumberField: a }) => {
|
|
668
685
|
i.isConnected && (this.phoneNumberField = new a({
|
|
669
686
|
value: t.phoneNumber ?? "",
|
|
670
687
|
onChange: this.onChange,
|
|
@@ -691,7 +708,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
691
708
|
this.cardSectionSkeleton = this.buildCardSkeleton(e), this.formElement.appendChild(this.cardSectionSkeleton);
|
|
692
709
|
return;
|
|
693
710
|
}
|
|
694
|
-
if (this.cardSection = new
|
|
711
|
+
if (this.cardSection = new M({
|
|
695
712
|
checkoutProfile: e,
|
|
696
713
|
cardNumber: t.cardNumber,
|
|
697
714
|
cardNumberError: n.cardNumber,
|
|
@@ -705,7 +722,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
705
722
|
onChange: this.onChange,
|
|
706
723
|
onBlur: this.onBlur,
|
|
707
724
|
onCardBrandChange: () => {
|
|
708
|
-
t.cardCvv && this.onBlur(
|
|
725
|
+
t.cardCvv && this.onBlur(F({
|
|
709
726
|
type: "blur",
|
|
710
727
|
target: {
|
|
711
728
|
name: "cardCvv",
|
|
@@ -738,7 +755,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
738
755
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
739
756
|
return;
|
|
740
757
|
}
|
|
741
|
-
if (this.cardholderSection = new
|
|
758
|
+
if (this.cardholderSection = new U({
|
|
742
759
|
value: t.name,
|
|
743
760
|
onChange: this.onChange,
|
|
744
761
|
onBlur: this.onBlur,
|
|
@@ -769,7 +786,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
769
786
|
zipCode: "",
|
|
770
787
|
country: ""
|
|
771
788
|
};
|
|
772
|
-
this.billingAddressSection = new
|
|
789
|
+
this.billingAddressSection = new H({
|
|
773
790
|
type: "billing",
|
|
774
791
|
title: this.translationFunc("address.billingTitle"),
|
|
775
792
|
checkoutProfile: e,
|
|
@@ -800,7 +817,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
800
817
|
zipCode: "",
|
|
801
818
|
country: ""
|
|
802
819
|
};
|
|
803
|
-
this.shippingAddressSection = new
|
|
820
|
+
this.shippingAddressSection = new H({
|
|
804
821
|
type: "shipping",
|
|
805
822
|
title: this.translationFunc("address.shippingTitle"),
|
|
806
823
|
checkoutProfile: e,
|
|
@@ -820,7 +837,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
820
837
|
}
|
|
821
838
|
createSubmitButton(e, t) {
|
|
822
839
|
try {
|
|
823
|
-
this.submitButton = new
|
|
840
|
+
this.submitButton = new ae({
|
|
824
841
|
disabled: t,
|
|
825
842
|
checkoutProfile: e,
|
|
826
843
|
translationFunc: this.translationFunc
|
|
@@ -869,20 +886,24 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
869
886
|
this.vgsService = e;
|
|
870
887
|
}
|
|
871
888
|
buildCardSkeleton(e) {
|
|
872
|
-
let t = e.styles.borderRadius, n = document.createElement("div"),
|
|
873
|
-
|
|
874
|
-
let
|
|
875
|
-
|
|
876
|
-
let a = document.createElement("div");
|
|
877
|
-
a.className = "vgs-card-group", a.style.borderRadius = `${t}px`, a.style.background = "#fff", a.style.display = "flex", a.style.flexDirection = "column", a.style.gap = "8px";
|
|
889
|
+
let t = e.styles.borderRadius, n = S(L, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
|
|
890
|
+
i.style.marginBottom = "4px";
|
|
891
|
+
let a = document.createElement("label");
|
|
892
|
+
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);
|
|
878
893
|
let o = document.createElement("div");
|
|
879
|
-
o.className = "card-
|
|
894
|
+
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";
|
|
880
895
|
let s = document.createElement("div");
|
|
881
|
-
s.style.
|
|
896
|
+
s.className = "card-number-row", s.style.position = "relative", s.style.height = n, s.style.overflow = "hidden", s.style.borderRadius = `${t}px ${t}px 0 0`, o.appendChild(s);
|
|
882
897
|
let c = document.createElement("div");
|
|
883
|
-
c.style.
|
|
898
|
+
c.style.display = "flex", c.style.marginTop = "-1px";
|
|
884
899
|
let l = document.createElement("div");
|
|
885
|
-
|
|
900
|
+
l.style.position = "relative", l.style.flex = "1", l.style.height = n, l.style.overflow = "hidden", l.style.borderRadius = `0 0 0 ${t}px`, c.appendChild(l);
|
|
901
|
+
let u = document.createElement("div");
|
|
902
|
+
return u.style.position = "relative", u.style.flex = "1", u.style.height = n, u.style.overflow = "hidden", u.style.marginLeft = "-1px", u.style.borderRadius = `0 0 ${t}px 0`, c.appendChild(u), o.appendChild(c), o.appendChild(this.createSkeletonDiv()), r.appendChild(o), r.appendChild(this.createHelperTextSpacer("error-messages-container")), r;
|
|
903
|
+
}
|
|
904
|
+
createHelperTextSpacer(e) {
|
|
905
|
+
let t = document.createElement("div");
|
|
906
|
+
return t.className = e, t;
|
|
886
907
|
}
|
|
887
908
|
createSkeletonDiv() {
|
|
888
909
|
let e = document.createElement("div");
|
|
@@ -892,16 +913,16 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
892
913
|
let t = e.styles.borderRadius, n = document.createElement("div"), r = document.createElement("div");
|
|
893
914
|
r.style.marginBottom = "4px";
|
|
894
915
|
let i = document.createElement("label");
|
|
895
|
-
i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, r.appendChild(i), n.appendChild(r);
|
|
916
|
+
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);
|
|
896
917
|
let a = document.createElement("div");
|
|
897
|
-
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height =
|
|
918
|
+
return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = S(L, 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;
|
|
898
919
|
}
|
|
899
920
|
async mountVgsFields(e) {
|
|
900
921
|
if (!this.vgsService || !this.cardSection) return;
|
|
901
922
|
await this.vgsService.whenReady();
|
|
902
|
-
let t = this.cardSection.getVgsContainerIds(),
|
|
903
|
-
if (this.cardholderSection &&
|
|
904
|
-
let e =
|
|
923
|
+
let t = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await n(e.styles.fontFamily), a = this.cardSection.buildVgsFieldCss(e, i);
|
|
924
|
+
if (this.cardholderSection && a.cardholderName) {
|
|
925
|
+
let e = a.cardholderName;
|
|
905
926
|
typeof e.height == "string" && this.cardholderSection.setFieldHeight(e.height);
|
|
906
927
|
let t = e["border-radius"];
|
|
907
928
|
typeof t == "string" && this.cardholderSection.setBorderRadius(parseFloat(t));
|
|
@@ -910,8 +931,8 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
910
931
|
cardNumber: t.cardNumber ? `#${t.cardNumber}` : void 0,
|
|
911
932
|
cardExpiry: t.cardExpiry ? `#${t.cardExpiry}` : void 0,
|
|
912
933
|
cardCvv: t.cardCvv ? `#${t.cardCvv}` : void 0,
|
|
913
|
-
cardholderName:
|
|
914
|
-
},
|
|
934
|
+
cardholderName: r ? `#${r}` : void 0
|
|
935
|
+
}, a, {
|
|
915
936
|
cardNumber: "1234 5678 9012 3456",
|
|
916
937
|
cardExpiry: this.translationFunc("cardExpiry"),
|
|
917
938
|
cardCvv: "CVV",
|
|
@@ -948,7 +969,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
948
969
|
}
|
|
949
970
|
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);
|
|
950
971
|
}
|
|
951
|
-
},
|
|
972
|
+
}, se = class {
|
|
952
973
|
formManager;
|
|
953
974
|
focusManager;
|
|
954
975
|
onFormSubmit;
|
|
@@ -988,7 +1009,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
988
1009
|
clearTouchedFields() {
|
|
989
1010
|
this.localTouchedFields.clear();
|
|
990
1011
|
}
|
|
991
|
-
},
|
|
1012
|
+
}, ce = class {
|
|
992
1013
|
formManager;
|
|
993
1014
|
checkoutProfile;
|
|
994
1015
|
formElement;
|
|
@@ -1010,7 +1031,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1010
1031
|
if (!e.isLoading) {
|
|
1011
1032
|
if (e.checkoutProfile) try {
|
|
1012
1033
|
if (e.checkoutProfile.styles?.fontFamily) try {
|
|
1013
|
-
let { cleanup: t } =
|
|
1034
|
+
let { cleanup: t } = g({ fontFamily: e.checkoutProfile.styles.fontFamily });
|
|
1014
1035
|
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
1015
1036
|
} catch (e) {
|
|
1016
1037
|
console.error("Error loading Google Font:", e);
|
|
@@ -1025,7 +1046,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1025
1046
|
}
|
|
1026
1047
|
};
|
|
1027
1048
|
isFormDisabled() {
|
|
1028
|
-
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 =
|
|
1049
|
+
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 = B(t.checkoutProfile?.layout) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: u, shippingFields: d } = t.checkoutProfile?.layout ?? {}, f = /* @__PURE__ */ new Set(["US", "CA"]), p = (e, t) => {
|
|
1029
1050
|
if (!e) return !0;
|
|
1030
1051
|
let n = t?.country ?? "";
|
|
1031
1052
|
return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!f.has(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
|
|
@@ -1047,7 +1068,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1047
1068
|
if (!r?.isTouched || r.isFocused || r.isValid) continue;
|
|
1048
1069
|
let i = r.errors?.[0];
|
|
1049
1070
|
if (!i) continue;
|
|
1050
|
-
let a =
|
|
1071
|
+
let a = k(n, i.code);
|
|
1051
1072
|
a && (t[n] = e(a));
|
|
1052
1073
|
}
|
|
1053
1074
|
return t;
|
|
@@ -1058,17 +1079,17 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1058
1079
|
cleanup() {
|
|
1059
1080
|
this.fontCleanup &&= (this.fontCleanup(), void 0);
|
|
1060
1081
|
}
|
|
1061
|
-
},
|
|
1082
|
+
}, le = class extends I {
|
|
1062
1083
|
titleElement;
|
|
1063
1084
|
constructor(e = {}) {
|
|
1064
1085
|
super("div", ["blur-bg"]);
|
|
1065
|
-
let t =
|
|
1066
|
-
this.titleElement = new
|
|
1086
|
+
let t = j.createDiv(["loader"]);
|
|
1087
|
+
this.titleElement = new I("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
1067
1088
|
}
|
|
1068
1089
|
setText(e) {
|
|
1069
1090
|
return this.titleElement.setText(e), this;
|
|
1070
1091
|
}
|
|
1071
|
-
},
|
|
1092
|
+
}, Y = {
|
|
1072
1093
|
street: "",
|
|
1073
1094
|
firstName: "",
|
|
1074
1095
|
lastName: "",
|
|
@@ -1076,7 +1097,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1076
1097
|
city: "",
|
|
1077
1098
|
zipCode: "",
|
|
1078
1099
|
country: ""
|
|
1079
|
-
},
|
|
1100
|
+
}, X = (e, t) => {
|
|
1080
1101
|
let n = {}, r = `${t}.`;
|
|
1081
1102
|
return Object.keys(e).forEach((t) => {
|
|
1082
1103
|
if (t.startsWith(r)) {
|
|
@@ -1084,11 +1105,11 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1084
1105
|
n[i] = e[t];
|
|
1085
1106
|
}
|
|
1086
1107
|
}), n;
|
|
1087
|
-
},
|
|
1108
|
+
}, ue = class {
|
|
1088
1109
|
formElement;
|
|
1089
1110
|
componentManager;
|
|
1090
1111
|
onLoadingStateChange;
|
|
1091
|
-
validationSchema =
|
|
1112
|
+
validationSchema = u();
|
|
1092
1113
|
spinner;
|
|
1093
1114
|
formSkeleton;
|
|
1094
1115
|
alert;
|
|
@@ -1096,17 +1117,17 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1096
1117
|
this.formElement = e.formElement, this.componentManager = e.componentManager, this.onLoadingStateChange = e.onLoadingStateChange;
|
|
1097
1118
|
}
|
|
1098
1119
|
updateFormUI(e, t) {
|
|
1099
|
-
this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardSection(e.formData.cardNumber, e.errors.cardNumber, !!e.touched.cardNumber, e.formData.cardCvv, e.errors.cardCvv, !!e.touched.cardCvv, e.formData.cardExpiry, e.errors.cardExpiry, !!e.touched.cardExpiry), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ??
|
|
1120
|
+
this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardSection(e.formData.cardNumber, e.errors.cardNumber, !!e.touched.cardNumber, e.formData.cardCvv, e.errors.cardCvv, !!e.touched.cardCvv, e.formData.cardExpiry, e.errors.cardExpiry, !!e.touched.cardExpiry), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ?? Y, e.errors.billingAddress ?? {}, X(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? Y, e.errors.shippingAddress ?? {}, X(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
|
|
1100
1121
|
}
|
|
1101
1122
|
setLoadingState(e) {
|
|
1102
1123
|
if (this.onLoadingStateChange) {
|
|
1103
1124
|
this.onLoadingStateChange(e);
|
|
1104
1125
|
return;
|
|
1105
1126
|
}
|
|
1106
|
-
e ? (this.hideSkeleton(), this.formSkeleton = new
|
|
1127
|
+
e ? (this.hideSkeleton(), this.formSkeleton = new W(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
1107
1128
|
}
|
|
1108
1129
|
showSpinner(e) {
|
|
1109
|
-
this.hideSpinner(), this.spinner = new
|
|
1130
|
+
this.hideSpinner(), this.spinner = new le({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
1110
1131
|
}
|
|
1111
1132
|
hideSpinner() {
|
|
1112
1133
|
this.spinner &&= (this.spinner.getElement().remove(), void 0);
|
|
@@ -1115,7 +1136,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1115
1136
|
this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
|
|
1116
1137
|
}
|
|
1117
1138
|
setErrorMessage(e) {
|
|
1118
|
-
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new
|
|
1139
|
+
this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new N({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
|
|
1119
1140
|
}
|
|
1120
1141
|
clearErrorMessage() {
|
|
1121
1142
|
this.alert &&= (this.alert.getElement().remove(), void 0);
|
|
@@ -1125,7 +1146,7 @@ var z = /* @__PURE__ */ new Set(["US", "CA"]), B = class extends N {
|
|
|
1125
1146
|
}
|
|
1126
1147
|
};
|
|
1127
1148
|
globalThis.navigator.userAgent;
|
|
1128
|
-
var
|
|
1149
|
+
var Z = (e) => ({
|
|
1129
1150
|
street: "",
|
|
1130
1151
|
firstName: "",
|
|
1131
1152
|
lastName: "",
|
|
@@ -1134,12 +1155,12 @@ var Q = (e) => ({
|
|
|
1134
1155
|
zipCode: "",
|
|
1135
1156
|
country: "",
|
|
1136
1157
|
...e
|
|
1137
|
-
}),
|
|
1158
|
+
}), Q = class extends I {
|
|
1138
1159
|
options;
|
|
1139
|
-
formManager =
|
|
1160
|
+
formManager = s();
|
|
1140
1161
|
checkoutProfile;
|
|
1141
|
-
translation =
|
|
1142
|
-
focusManager = new
|
|
1162
|
+
translation = r();
|
|
1163
|
+
focusManager = new h();
|
|
1143
1164
|
componentManager;
|
|
1144
1165
|
eventHandler;
|
|
1145
1166
|
stateCoordinator;
|
|
@@ -1148,7 +1169,7 @@ var Q = (e) => ({
|
|
|
1148
1169
|
vgsJwt;
|
|
1149
1170
|
vgsCardResult;
|
|
1150
1171
|
constructor(e) {
|
|
1151
|
-
super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new
|
|
1172
|
+
super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new t()), this.checkoutProfile = R({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new oe({
|
|
1152
1173
|
formElement: this.element,
|
|
1153
1174
|
focusManager: this.focusManager,
|
|
1154
1175
|
translationFunc: this.translation.t,
|
|
@@ -1165,11 +1186,11 @@ var Q = (e) => ({
|
|
|
1165
1186
|
environment: e.environment,
|
|
1166
1187
|
vgsService: this.vgsService,
|
|
1167
1188
|
onVgsStateChange: (e) => this.handleVgsStateChange(e)
|
|
1168
|
-
}), this.uiManager = new
|
|
1189
|
+
}), this.uiManager = new ue({
|
|
1169
1190
|
formElement: this.element,
|
|
1170
1191
|
componentManager: this.componentManager,
|
|
1171
1192
|
onLoadingStateChange: e.onLoadingStateChange
|
|
1172
|
-
}), this.stateCoordinator = new
|
|
1193
|
+
}), this.stateCoordinator = new ce({
|
|
1173
1194
|
formManager: this.formManager,
|
|
1174
1195
|
checkoutProfile: this.checkoutProfile,
|
|
1175
1196
|
componentManager: this.componentManager,
|
|
@@ -1179,7 +1200,7 @@ var Q = (e) => ({
|
|
|
1179
1200
|
onError: (e) => this.uiManager.setErrorMessage(e),
|
|
1180
1201
|
onLoadingChange: (e) => this.uiManager.setLoadingState(e),
|
|
1181
1202
|
getInitialFormData: () => this._getFormStateData().formData
|
|
1182
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
1203
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new se({
|
|
1183
1204
|
formManager: this.formManager,
|
|
1184
1205
|
focusManager: this.focusManager,
|
|
1185
1206
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -1191,8 +1212,8 @@ var Q = (e) => ({
|
|
|
1191
1212
|
...e.initialValues.email && { email: e.initialValues.email },
|
|
1192
1213
|
...e.initialValues.phoneNumber && { phoneNumber: e.initialValues.phoneNumber },
|
|
1193
1214
|
...e.initialValues.name && { name: e.initialValues.name },
|
|
1194
|
-
...e.initialValues.billingAddress && { billingAddress:
|
|
1195
|
-
...e.initialValues.shippingAddress && { shippingAddress:
|
|
1215
|
+
...e.initialValues.billingAddress && { billingAddress: Z(e.initialValues.billingAddress) },
|
|
1216
|
+
...e.initialValues.shippingAddress && { shippingAddress: Z(e.initialValues.shippingAddress) }
|
|
1196
1217
|
}), this.initializeForm(), this.appendTo(e.container);
|
|
1197
1218
|
}
|
|
1198
1219
|
_getFormStateData() {
|
|
@@ -1205,8 +1226,8 @@ var Q = (e) => ({
|
|
|
1205
1226
|
cardExpiry: "",
|
|
1206
1227
|
cardNumber: "",
|
|
1207
1228
|
cardCvv: "",
|
|
1208
|
-
...t?.billingAddress && { billingAddress:
|
|
1209
|
-
...t?.shippingAddress && { shippingAddress:
|
|
1229
|
+
...t?.billingAddress && { billingAddress: Z(t.billingAddress) },
|
|
1230
|
+
...t?.shippingAddress && { shippingAddress: Z(t.shippingAddress) }
|
|
1210
1231
|
},
|
|
1211
1232
|
errors: e.errors || {},
|
|
1212
1233
|
touched: e.touched || {}
|
|
@@ -1228,8 +1249,8 @@ var Q = (e) => ({
|
|
|
1228
1249
|
this.componentManager.hasComponents() && this.componentManager.cleanup(), e.checkoutProfile.layout.phoneNumber?.enabled && this.formManager.getFormState().formData.phoneNumber === void 0 && this.formManager.setFormData({
|
|
1229
1250
|
phoneNumber: "",
|
|
1230
1251
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
1231
|
-
}), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress:
|
|
1232
|
-
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i =
|
|
1252
|
+
}), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress: Z() }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({ shippingAddress: Z() });
|
|
1253
|
+
let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = z(e.checkoutProfile.layout);
|
|
1233
1254
|
try {
|
|
1234
1255
|
this.componentManager.createPaymentMethods(e.checkoutProfile, t);
|
|
1235
1256
|
} catch (e) {
|
|
@@ -1262,7 +1283,7 @@ var Q = (e) => ({
|
|
|
1262
1283
|
} catch (e) {
|
|
1263
1284
|
console.error("Failed to create card section:", e);
|
|
1264
1285
|
}
|
|
1265
|
-
if (!
|
|
1286
|
+
if (!B(e.checkoutProfile.layout)) try {
|
|
1266
1287
|
this.componentManager.createCardholderSection(e.checkoutProfile, t, n, r);
|
|
1267
1288
|
} catch (e) {
|
|
1268
1289
|
console.error("Failed to create cardholder section:", e);
|
|
@@ -1282,7 +1303,7 @@ var Q = (e) => ({
|
|
|
1282
1303
|
}
|
|
1283
1304
|
inferCardholderName() {
|
|
1284
1305
|
let e = this.checkoutProfile.getState();
|
|
1285
|
-
if (!e.checkoutProfile || !
|
|
1306
|
+
if (!e.checkoutProfile || !B(e.checkoutProfile.layout)) return;
|
|
1286
1307
|
let { formData: t } = this._getFormStateData(), n = t.billingAddress ?? t.shippingAddress;
|
|
1287
1308
|
if (!n) return;
|
|
1288
1309
|
let r = [n.firstName?.trim() ?? "", n.lastName?.trim() ?? ""].filter(Boolean).join(" ");
|
|
@@ -1356,19 +1377,19 @@ var Q = (e) => ({
|
|
|
1356
1377
|
destroy() {
|
|
1357
1378
|
this.vgsService?.destroy(), this.stateCoordinator.cleanup(), this.eventHandler.clearTouchedFields(), this.getElement().removeEventListener("submit", this.eventHandler.handleSubmit), this.getElement().removeEventListener("keydown", this.eventHandler.handleKeyDown), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
|
|
1358
1379
|
}
|
|
1359
|
-
associatePayment(e,
|
|
1360
|
-
this.options.paymentId = e, this.options.checkoutKey =
|
|
1380
|
+
associatePayment(e, n, r, i, a) {
|
|
1381
|
+
this.options.paymentId = e, this.options.checkoutKey = n, this.options.supportedPaymentMethods = r, this.options.checkoutDetails = i, this.componentManager.setCheckoutDetailsLoaded(!0), a && !this.vgsService && (this.vgsJwt = a, this.vgsService = new t(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((e) => {
|
|
1361
1382
|
this.vgsService?.createForm(e, (e) => this.handleVgsStateChange(e)), this.renderFormComponents();
|
|
1362
1383
|
}).catch((e) => {
|
|
1363
1384
|
console.error("Failed to load VGS Collect:", e), this.vgsService = void 0, this.vgsJwt = void 0, this.renderFormComponents();
|
|
1364
|
-
})), this.componentManager.removePaymentMethods(), this.componentManager.updateSupportedPaymentMethods(
|
|
1365
|
-
let
|
|
1366
|
-
if (
|
|
1385
|
+
})), this.componentManager.removePaymentMethods(), this.componentManager.updateSupportedPaymentMethods(r), this.componentManager.updatePaymentDetails(e, n, i), !a && this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents();
|
|
1386
|
+
let o = this.checkoutProfile.getState();
|
|
1387
|
+
if (o.checkoutProfile) {
|
|
1367
1388
|
let { formData: e } = this._getFormStateData();
|
|
1368
|
-
this.componentManager.createPaymentMethods(
|
|
1389
|
+
this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
|
|
1369
1390
|
}
|
|
1370
1391
|
}
|
|
1371
|
-
},
|
|
1392
|
+
}, de = class {
|
|
1372
1393
|
container = null;
|
|
1373
1394
|
options;
|
|
1374
1395
|
onSubmit;
|
|
@@ -1392,7 +1413,7 @@ var Q = (e) => ({
|
|
|
1392
1413
|
}
|
|
1393
1414
|
}
|
|
1394
1415
|
renderForm(e) {
|
|
1395
|
-
this.container && (this.form &&= (this.form.destroy(), null), this.form = new
|
|
1416
|
+
this.container && (this.form &&= (this.form.destroy(), null), this.form = new Q({
|
|
1396
1417
|
apiKey: this.options.apiKey,
|
|
1397
1418
|
onSubmit: this.onSubmit,
|
|
1398
1419
|
locale: this.options.locale,
|
|
@@ -1421,7 +1442,7 @@ var Q = (e) => ({
|
|
|
1421
1442
|
async associatePayment(e, t, n, r, i) {
|
|
1422
1443
|
this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = r, this.options.vgsJwt = i, this.form && this.form.associatePayment(e, t, n, r, i);
|
|
1423
1444
|
}
|
|
1424
|
-
},
|
|
1445
|
+
}, fe = class {
|
|
1425
1446
|
state;
|
|
1426
1447
|
listeners = /* @__PURE__ */ new Set();
|
|
1427
1448
|
constructor(e) {
|
|
@@ -1445,7 +1466,7 @@ var Q = (e) => ({
|
|
|
1445
1466
|
let e = this.getState();
|
|
1446
1467
|
this.listeners.forEach((t) => t(e));
|
|
1447
1468
|
}
|
|
1448
|
-
},
|
|
1469
|
+
}, pe = "en", $ = class {
|
|
1449
1470
|
config;
|
|
1450
1471
|
_callbacks;
|
|
1451
1472
|
paymentState;
|
|
@@ -1454,14 +1475,14 @@ var Q = (e) => ({
|
|
|
1454
1475
|
stateManager;
|
|
1455
1476
|
sessionId;
|
|
1456
1477
|
constructor(e) {
|
|
1457
|
-
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
1478
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), ee({
|
|
1458
1479
|
environment: this.config.environment,
|
|
1459
1480
|
sessionId: this.sessionId,
|
|
1460
1481
|
integration: "dropin"
|
|
1461
|
-
}),
|
|
1482
|
+
}), l(y.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new _(this.config.apiKey, this.config.environment), this.stateManager = new fe({
|
|
1462
1483
|
mounted: !1,
|
|
1463
1484
|
form: null
|
|
1464
|
-
}), this.formManager = new
|
|
1485
|
+
}), this.formManager = new de({
|
|
1465
1486
|
locale: this.config.locale,
|
|
1466
1487
|
apiKey: this.config.apiKey,
|
|
1467
1488
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
@@ -1478,7 +1499,7 @@ var Q = (e) => ({
|
|
|
1478
1499
|
apiKey: e.apiKey,
|
|
1479
1500
|
returnUrl: e.returnUrl,
|
|
1480
1501
|
environment: e.environment,
|
|
1481
|
-
locale: e.locale ||
|
|
1502
|
+
locale: e.locale || pe,
|
|
1482
1503
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
1483
1504
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
1484
1505
|
appearance: e.appearance,
|
|
@@ -1498,7 +1519,7 @@ var Q = (e) => ({
|
|
|
1498
1519
|
return t.appendChild(n), this.stateManager.updateState({
|
|
1499
1520
|
form: n,
|
|
1500
1521
|
mounted: !0
|
|
1501
|
-
}), this.formManager.mount(n),
|
|
1522
|
+
}), this.formManager.mount(n), l(y.CHECKOUT_MOUNTED, { container_id: e }), this;
|
|
1502
1523
|
}
|
|
1503
1524
|
unmount() {
|
|
1504
1525
|
let { mounted: e } = this.stateManager.getState();
|
|
@@ -1508,40 +1529,40 @@ var Q = (e) => ({
|
|
|
1508
1529
|
e && e.remove(), this.stateManager.updateState({
|
|
1509
1530
|
form: null,
|
|
1510
1531
|
mounted: !1
|
|
1511
|
-
}),
|
|
1532
|
+
}), l(y.CHECKOUT_UNMOUNTED);
|
|
1512
1533
|
});
|
|
1513
1534
|
}
|
|
1514
1535
|
async handleSubmit({ formData: e, applePayData: t }) {
|
|
1515
1536
|
if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
|
|
1516
1537
|
let n = this.getPaymentMethod(e, t);
|
|
1517
|
-
|
|
1538
|
+
l(y.PAYMENT_SUBMIT_STARTED, {
|
|
1518
1539
|
payment_id: this.paymentState.paymentId,
|
|
1519
1540
|
payment_method: n
|
|
1520
1541
|
});
|
|
1521
1542
|
let r = performance.now();
|
|
1522
1543
|
try {
|
|
1523
|
-
let
|
|
1544
|
+
let i = await this.apiService.authorizePayment({
|
|
1524
1545
|
checkoutKey: this.paymentState.checkoutKey,
|
|
1525
1546
|
formData: e || null,
|
|
1526
1547
|
paymentId: this.paymentState.paymentId,
|
|
1527
1548
|
returnUrl: this.config.returnUrl,
|
|
1528
1549
|
applePayData: t
|
|
1529
|
-
}),
|
|
1530
|
-
|
|
1550
|
+
}), a = performance.now() - r;
|
|
1551
|
+
c(v.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
|
|
1531
1552
|
payment_id: this.paymentState.paymentId,
|
|
1532
1553
|
payment_method: n,
|
|
1533
1554
|
status: "success"
|
|
1534
|
-
}),
|
|
1555
|
+
}), l(y.PAYMENT_SUBMIT_SUCCESS, {
|
|
1535
1556
|
payment_id: this.paymentState.paymentId,
|
|
1536
1557
|
payment_method: n
|
|
1537
|
-
}), this.handlePaymentResponse(
|
|
1558
|
+
}), this.handlePaymentResponse(i);
|
|
1538
1559
|
} catch (e) {
|
|
1539
1560
|
let t = performance.now() - r;
|
|
1540
|
-
|
|
1561
|
+
c(v.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
|
|
1541
1562
|
payment_id: this.paymentState.paymentId,
|
|
1542
1563
|
payment_method: n,
|
|
1543
1564
|
status: "failed"
|
|
1544
|
-
}),
|
|
1565
|
+
}), l(y.PAYMENT_SUBMIT_FAILED, {
|
|
1545
1566
|
payment_id: this.paymentState.paymentId,
|
|
1546
1567
|
payment_method: n,
|
|
1547
1568
|
error_message: e.details?.message ?? "Unknown error"
|
|
@@ -1549,15 +1570,15 @@ var Q = (e) => ({
|
|
|
1549
1570
|
}
|
|
1550
1571
|
}
|
|
1551
1572
|
handlePaymentResponse(e) {
|
|
1552
|
-
if (e.latestTransaction.status === "authorized" && (
|
|
1573
|
+
if (e.latestTransaction.status === "authorized" && (l(y.PAYMENT_AUTHORIZED, {
|
|
1553
1574
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1554
1575
|
status: e.latestTransaction.status
|
|
1555
|
-
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status)), e.latestTransaction.status === "failed" && (
|
|
1576
|
+
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status)), e.latestTransaction.status === "failed" && (l(y.PAYMENT_FAILED, {
|
|
1556
1577
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1557
1578
|
status: e.latestTransaction.status
|
|
1558
1579
|
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
|
|
1559
1580
|
let { redirectUrl: t } = e.action;
|
|
1560
|
-
|
|
1581
|
+
l(y.PAYMENT_ACTION_REQUIRED, {
|
|
1561
1582
|
payment_id: this.paymentState.paymentId ?? "",
|
|
1562
1583
|
status: e.status
|
|
1563
1584
|
}), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(t) : globalThis.location.href = t;
|
|
@@ -1593,7 +1614,7 @@ var Q = (e) => ({
|
|
|
1593
1614
|
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
1594
1615
|
this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
|
|
1595
1616
|
try {
|
|
1596
|
-
let n = await
|
|
1617
|
+
let n = await b({
|
|
1597
1618
|
id: e,
|
|
1598
1619
|
checkoutKey: t,
|
|
1599
1620
|
environment: this.config.environment
|
|
@@ -1606,13 +1627,13 @@ var Q = (e) => ({
|
|
|
1606
1627
|
countryCode: n.countryCode
|
|
1607
1628
|
};
|
|
1608
1629
|
let r = n.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
|
|
1609
|
-
await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt),
|
|
1630
|
+
await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), l(y.PAYMENT_ASSOCIATED, {
|
|
1610
1631
|
payment_id: e,
|
|
1611
1632
|
currency: n.currency,
|
|
1612
1633
|
country_code: n.countryCode
|
|
1613
1634
|
});
|
|
1614
1635
|
} catch (t) {
|
|
1615
|
-
throw
|
|
1636
|
+
throw l(y.PAYMENT_ASSOCIATION_FAILED, {
|
|
1616
1637
|
payment_id: e,
|
|
1617
1638
|
error_message: t instanceof Error ? t.message : "Unknown error"
|
|
1618
1639
|
}), a(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
|
|
@@ -1626,4 +1647,4 @@ var Q = (e) => ({
|
|
|
1626
1647
|
//#region libs/checkout/src/index.ts
|
|
1627
1648
|
typeof globalThis < "u" && (globalThis.OdusCheckout = $);
|
|
1628
1649
|
//#endregion
|
|
1629
|
-
export { $ as OdusCheckout,
|
|
1650
|
+
export { $ as OdusCheckout, i as deLocale, m as enLocale, f as esLocale, d as frLocale, D as itLocale, e as plLocale, O as ptLocale, a as pushError, l as pushEvent, re as pushLog, c as pushMeasurement, p as trLocale };
|