@odus/checkout 1.9.2 → 1.10.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 +288 -199
- package/dist/components/checkout/form/CardSection.d.ts +6 -25
- package/dist/components/checkout/form/CardSection.d.ts.map +1 -1
- package/dist/components/checkout/form/CardUnavailableNotice.d.ts +16 -0
- package/dist/components/checkout/form/CardUnavailableNotice.d.ts.map +1 -0
- package/dist/components/checkout/form/Form.d.ts +17 -3
- package/dist/components/checkout/form/Form.d.ts.map +1 -1
- package/dist/components/checkout/form/FormComponentManager.d.ts +7 -7
- package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
- package/dist/components/checkout/form/FormStateCoordinator.d.ts +2 -0
- package/dist/components/checkout/form/FormStateCoordinator.d.ts.map +1 -1
- package/dist/components/checkout/form/FormUIManager.d.ts.map +1 -1
- package/dist/core/api/CheckoutAPI.service.d.ts +5 -1
- package/dist/core/api/CheckoutAPI.service.d.ts.map +1 -1
- package/dist/elements/CardElement.d.ts +42 -5
- package/dist/elements/CardElement.d.ts.map +1 -1
- package/dist/elements/OdusElements.d.ts.map +1 -1
- package/dist/elements/card/VgsCardAdapter.d.ts +6 -1
- package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
- package/dist/elements/cardElement.constants.d.ts +0 -2
- package/dist/elements/cardElement.constants.d.ts.map +1 -1
- package/dist/elements/types/CardPayload.type.d.ts +0 -6
- package/dist/elements/types/CardPayload.type.d.ts.map +1 -1
- package/dist/elements/types/index.d.ts +1 -1
- package/dist/elements/types/index.d.ts.map +1 -1
- package/dist/elements.d.ts +1 -1
- package/dist/elements.d.ts.map +1 -1
- package/dist/elements.es.js +269 -335
- package/dist/factories/createForm.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/locales/cs.json.d.ts +1 -0
- package/dist/locales/de.json.d.ts +1 -0
- package/dist/locales/en.json.d.ts +1 -0
- package/dist/locales/es.json.d.ts +1 -0
- package/dist/locales/fr.json.d.ts +1 -0
- package/dist/locales/it.json.d.ts +1 -0
- package/dist/locales/nl.json.d.ts +1 -0
- package/dist/locales/pl.json.d.ts +1 -0
- package/dist/locales/pt.json.d.ts +1 -0
- package/dist/locales/sk.json.d.ts +1 -0
- package/dist/locales/tr.json.d.ts +1 -0
- package/dist/phone.js +46 -45
- package/dist/services/checkout/CheckoutAPI.service.d.ts +1 -1
- package/dist/services/checkout/CheckoutAPI.service.d.ts.map +1 -1
- package/dist/services/checkout/CheckoutForm.service.d.ts +6 -0
- package/dist/services/checkout/CheckoutForm.service.d.ts.map +1 -1
- package/dist/shared.js +3656 -5960
- package/dist/shared2.js +13 -0
- package/dist/types/common/FormData.type.d.ts +0 -3
- package/dist/types/common/FormData.type.d.ts.map +1 -1
- package/dist/types/telemetry/TelemetryEvents.type.d.ts +15 -0
- package/dist/types/telemetry/TelemetryEvents.type.d.ts.map +1 -1
- package/dist/utils/focus/FocusManager.d.ts.map +1 -1
- package/dist/utils/validation/createValidationSchema.d.ts +0 -3
- package/dist/utils/validation/createValidationSchema.d.ts.map +1 -1
- package/package.json +1 -2
- package/dist/components/checkout/card-elements/CardCvvElement.d.ts +0 -28
- package/dist/components/checkout/card-elements/CardCvvElement.d.ts.map +0 -1
- package/dist/components/checkout/card-elements/CardNumberElement.d.ts +0 -32
- package/dist/components/checkout/card-elements/CardNumberElement.d.ts.map +0 -1
- package/dist/components/checkout/card-elements/index.d.ts +0 -3
- package/dist/components/checkout/card-elements/index.d.ts.map +0 -1
- package/dist/elements/card/NativeCardAdapter.d.ts +0 -35
- package/dist/elements/card/NativeCardAdapter.d.ts.map +0 -1
- package/dist/utils/card/detectCardBrand.d.ts +0 -3
- package/dist/utils/card/detectCardBrand.d.ts.map +0 -1
- package/dist/utils/card/luhnCheck.d.ts +0 -7
- package/dist/utils/card/luhnCheck.d.ts.map +0 -1
- package/dist/utils/formatters/formatters.d.ts +0 -6
- package/dist/utils/formatters/formatters.d.ts.map +0 -1
package/dist/elements.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as e, C as t, D as n, E as r,
|
|
1
|
+
import { B as e, C as t, D as n, E as r, H as i, J as a, K as o, O as s, R as c, T as l, U as ee, V as te, W as u, X as d, Y as f, _ as p, a as ne, b as m, c as h, d as g, f as _, g as v, i as re, n as y, o as b, q as x, r as ie, s as ae, t as S, u as C, w, x as T } from "./shared.js";
|
|
2
2
|
//#region libs/checkout/src/assets/styles/helperText.css?inline
|
|
3
|
-
var
|
|
3
|
+
var E = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-index:3;position:relative}.form-helper-text{color:#dc2727;font-family:var(--odus-font-family,inherit);font-size:12px;font-weight:500;line-height:var(--odus-helper-text-line-height,14px);background:var(--odus-color-background,#fff);pointer-events:none;transition:opacity .2s ease-in-out;display:block;position:absolute;top:2px;left:0;right:0}.form-helper-text-hidden{opacity:0;visibility:hidden}.form-helper-text-hint{color:var(--odus-color-muted,#6b7280);font-weight:400}", D = ".input-wrapper{box-sizing:border-box;flex-direction:column;align-items:stretch;width:100%;min-width:0;display:flex}.input-wrapper *{box-sizing:border-box}.form-input{opacity:1;font-size:var(--odus-input-font-size,16px);font-weight:var(--odus-input-font-weight,400);letter-spacing:var(--odus-input-letter-spacing,.02em);box-shadow:0 0 0 1px var(--odus-border-color,#e0e0e0), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d;background:var(--odus-color-background,#fff);padding:var(--odus-input-padding,8px 12px);line-height:var(--odus-input-line-height,1.5);z-index:0;box-sizing:border-box;border:none;outline:none;flex:1;width:100%;min-height:0;transition:box-shadow .1s ease-in,border-radius .2s ease-in}.form-input[name=cardNumber]{padding-right:100px}.form-input-error{box-shadow:0 0 0 1px var(--odus-color-error,#dc2727), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d}.form-input::placeholder{color:var(--odus-input-placeholder-color,#717173);opacity:var(--odus-input-placeholder-opacity,.3)}.form-input:focus{z-index:2;position:relative;box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}", O = ".input-label{font-family:var(--odus-font-family,inherit);font-size:var(--odus-label-font-size,14px);font-weight:var(--odus-label-font-weight,400);color:var(--odus-label-color,var(--odus-color-text,#1a1a1a));letter-spacing:var(--odus-label-letter-spacing,normal);line-height:var(--odus-label-line-height,1.4);margin-bottom:var(--odus-label-margin-bottom,6px)}", oe = ":host{--odus-font-family:system-ui, sans-serif;--odus-font-size:16px;--odus-color-error:#dc2727;--odus-color-text:#1a1a1a;--odus-color-background:#fff;--odus-border-color:#e0e0e0;--odus-border-radius:6px;--odus-spacing-sm:8px;--odus-spacing-md:16px;--odus-spacing-lg:24px;--odus-input-height:44px;--odus-input-padding:8px 12px;--odus-input-font-size:var(--odus-font-size);--odus-input-font-weight:400;--odus-input-letter-spacing:.02em;--odus-input-line-height:1.5;--odus-input-placeholder-color:#717173;--odus-input-placeholder-opacity:.3;--odus-input-focus-shadow:0 0 0 1px #3297d3b3, 0 1px 1px 0 #00000012, 0 0 0 4px #3297d34d;--odus-label-font-size:14px;--odus-label-font-weight:400;--odus-label-color:var(--odus-color-text);--odus-label-letter-spacing:normal;--odus-label-line-height:1.4;--odus-label-margin-bottom:6px;--odus-card-gap:12px;--odus-button-height:48px;--odus-button-border-radius:var(--odus-border-radius)}.form-input{opacity:1;font-weight:var(--odus-input-font-weight,400);letter-spacing:var(--odus-input-letter-spacing,.02em);box-shadow:0 0 0 1px var(--odus-border-color,#e0e0e0), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d;background:var(--odus-color-background,#fff);padding:var(--odus-input-padding,8px 12px);line-height:var(--odus-input-line-height,1.5);z-index:0;box-sizing:border-box;border:none;outline:none;flex:1;width:100%;min-height:0;transition:box-shadow .1s ease-in,border-radius .2s ease-in}.form-input::placeholder{color:var(--odus-input-placeholder-color,#717173);opacity:var(--odus-input-placeholder-opacity,.3)}.form-input:focus{box-shadow:var(--odus-input-focus-shadow,0 0 0 1px #3297d3b3, 0 1px 1px 0 #00000012, 0 0 0 4px #3297d34d);z-index:2;position:relative}.input-label{font-family:var(--odus-font-family,inherit)!important;font-size:var(--odus-label-font-size,14px)!important;font-weight:var(--odus-label-font-weight,400)!important;color:var(--odus-label-color,var(--odus-color-text,#1a1a1a))!important;letter-spacing:var(--odus-label-letter-spacing,normal)!important;line-height:var(--odus-label-line-height,1.4)!important;margin-bottom:var(--odus-label-margin-bottom,6px)!important}.form-helper-text{font-family:var(--odus-font-family,inherit)!important}", k = class {
|
|
4
4
|
shadowRoot = null;
|
|
5
5
|
host = null;
|
|
6
6
|
options = {};
|
|
@@ -64,7 +64,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
64
64
|
this.options.callbacks?.[e]?.(t);
|
|
65
65
|
}
|
|
66
66
|
getCss() {
|
|
67
|
-
return
|
|
67
|
+
return oe;
|
|
68
68
|
}
|
|
69
69
|
}, A = class extends k {
|
|
70
70
|
_value = "";
|
|
@@ -73,7 +73,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
73
73
|
render() {
|
|
74
74
|
if (!this.shadowRoot) return;
|
|
75
75
|
this._input?.getElement().remove();
|
|
76
|
-
let { t: e } =
|
|
76
|
+
let { t: e } = n();
|
|
77
77
|
this._input = new _({
|
|
78
78
|
name: "billingAddress.city",
|
|
79
79
|
label: this.options.label ?? e("address.townCity"),
|
|
@@ -85,15 +85,15 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
85
85
|
this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
|
|
86
86
|
}
|
|
87
87
|
}), this._input.addEventListener("blur", () => {
|
|
88
|
-
let { t: e } =
|
|
88
|
+
let { t: e } = n();
|
|
89
89
|
this._error = this._value.trim() ? null : e("validation.townCityRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
90
90
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
91
91
|
}
|
|
92
92
|
getCss() {
|
|
93
93
|
return super.getCss() + [
|
|
94
|
-
E,
|
|
95
94
|
D,
|
|
96
|
-
|
|
95
|
+
O,
|
|
96
|
+
E
|
|
97
97
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
98
98
|
}
|
|
99
99
|
getValue() {
|
|
@@ -116,27 +116,27 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
116
116
|
render() {
|
|
117
117
|
if (!this.shadowRoot) return;
|
|
118
118
|
this._select?.getElement().remove(), this.options.initialValue && !this._value && (this._value = String(this.options.initialValue), this.emit("change", this._value));
|
|
119
|
-
let { t: e, locale: t } =
|
|
120
|
-
this._select = new
|
|
119
|
+
let { t: e, locale: t } = n();
|
|
120
|
+
this._select = new g({
|
|
121
121
|
name: "billingAddress.country",
|
|
122
122
|
label: this.options.label ?? e("address.chooseCountry"),
|
|
123
123
|
error: !1,
|
|
124
124
|
placeholder: this.options.placeholder ?? e("address.chooseCountry"),
|
|
125
125
|
value: this._value,
|
|
126
|
-
options:
|
|
126
|
+
options: p(this._allowedCountries, t),
|
|
127
127
|
autocomplete: "country",
|
|
128
128
|
onChange: (e) => {
|
|
129
129
|
this._value = e.target.value, this._error = null, this.emit("change", this._value);
|
|
130
130
|
}
|
|
131
131
|
}), this._select.addEventListener("blur", () => {
|
|
132
|
-
let { t: e } =
|
|
132
|
+
let { t: e } = n();
|
|
133
133
|
this._error = this._value ? null : e("validation.countryRequired"), this._select?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
134
134
|
}), this.shadowRoot.appendChild(this._select.getElement());
|
|
135
135
|
}
|
|
136
136
|
getCss() {
|
|
137
137
|
return super.getCss() + [
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
O,
|
|
139
|
+
E,
|
|
140
140
|
j
|
|
141
141
|
].join("\n") + "\n :host { display: block; }\n .form-select {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background-color: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-select:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-select-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
142
142
|
}
|
|
@@ -156,7 +156,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
156
156
|
render() {
|
|
157
157
|
if (!this.shadowRoot) return;
|
|
158
158
|
this._input?.getElement().remove();
|
|
159
|
-
let { t: e } =
|
|
159
|
+
let { t: e } = n();
|
|
160
160
|
this._input = new _({
|
|
161
161
|
name: "billingAddress.firstName",
|
|
162
162
|
label: this.options.label ?? e("address.firstName"),
|
|
@@ -168,15 +168,15 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
168
168
|
this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
|
|
169
169
|
}
|
|
170
170
|
}), this._input.addEventListener("blur", () => {
|
|
171
|
-
let { t: e } =
|
|
171
|
+
let { t: e } = n();
|
|
172
172
|
this._error = this._value.trim() ? null : e("validation.firstNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
173
173
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
174
174
|
}
|
|
175
175
|
getCss() {
|
|
176
176
|
return super.getCss() + [
|
|
177
|
-
E,
|
|
178
177
|
D,
|
|
179
|
-
|
|
178
|
+
O,
|
|
179
|
+
E
|
|
180
180
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
181
181
|
}
|
|
182
182
|
getValue() {
|
|
@@ -195,7 +195,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
195
195
|
render() {
|
|
196
196
|
if (!this.shadowRoot) return;
|
|
197
197
|
this._input?.getElement().remove();
|
|
198
|
-
let { t: e } =
|
|
198
|
+
let { t: e } = n();
|
|
199
199
|
this._input = new _({
|
|
200
200
|
name: "billingAddress.lastName",
|
|
201
201
|
label: this.options.label ?? e("address.lastName"),
|
|
@@ -207,15 +207,15 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
207
207
|
this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
|
|
208
208
|
}
|
|
209
209
|
}), this._input.addEventListener("blur", () => {
|
|
210
|
-
let { t: e } =
|
|
210
|
+
let { t: e } = n();
|
|
211
211
|
this._error = this._value.trim() ? null : e("validation.lastNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
212
212
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
213
213
|
}
|
|
214
214
|
getCss() {
|
|
215
215
|
return super.getCss() + [
|
|
216
|
-
E,
|
|
217
216
|
D,
|
|
218
|
-
|
|
217
|
+
O,
|
|
218
|
+
E
|
|
219
219
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
220
220
|
}
|
|
221
221
|
getValue() {
|
|
@@ -235,13 +235,13 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
235
235
|
setCountry(e) {
|
|
236
236
|
let t = this._country;
|
|
237
237
|
if (this._country = e, !this.shadowRoot) return;
|
|
238
|
-
let
|
|
239
|
-
if (
|
|
240
|
-
let { t } =
|
|
241
|
-
this._select?.setOptions(
|
|
238
|
+
let r = F.has(t), i = F.has(e);
|
|
239
|
+
if (r && i && t !== e) {
|
|
240
|
+
let { t } = n(), r = e, i = t(r === "US" ? "address.chooseState" : "address.chooseProvince");
|
|
241
|
+
this._select?.setOptions(v(r), this.options.placeholder ?? i), this._value = "", this.emit("change", this._value);
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
r !== i && (this._value = "", this.render(), this.emit("change", this._value));
|
|
245
245
|
}
|
|
246
246
|
render() {
|
|
247
247
|
if (this.shadowRoot) {
|
|
@@ -252,7 +252,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
_renderInput() {
|
|
255
|
-
let { t: e } =
|
|
255
|
+
let { t: e } = n();
|
|
256
256
|
this._input = new _({
|
|
257
257
|
name: "billingAddress.state",
|
|
258
258
|
label: this.options.label ?? e("address.state"),
|
|
@@ -269,14 +269,14 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
269
269
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
270
270
|
}
|
|
271
271
|
_renderSelect(e) {
|
|
272
|
-
let { t } =
|
|
273
|
-
this._select = new
|
|
272
|
+
let { t } = n(), r = v(e), i = t(e === "US" ? "address.chooseState" : "address.chooseProvince");
|
|
273
|
+
this._select = new g({
|
|
274
274
|
name: "billingAddress.state",
|
|
275
275
|
label: this.options.label ?? t("address.state"),
|
|
276
276
|
error: !1,
|
|
277
277
|
placeholder: this.options.placeholder ?? i,
|
|
278
278
|
value: this._value,
|
|
279
|
-
options:
|
|
279
|
+
options: r,
|
|
280
280
|
autocomplete: "address-level1",
|
|
281
281
|
onChange: (e) => {
|
|
282
282
|
this._value = e.target.value, this._select?.setError(!1), this.emit("change", this._value);
|
|
@@ -288,9 +288,9 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
288
288
|
}
|
|
289
289
|
getCss() {
|
|
290
290
|
return super.getCss() + [
|
|
291
|
-
E,
|
|
292
291
|
D,
|
|
293
|
-
|
|
292
|
+
O,
|
|
293
|
+
E,
|
|
294
294
|
j
|
|
295
295
|
].join("\n") + "\n :host { display: block; }\n .form-input,\n .form-select {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background-color: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus,\n .form-select:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error,\n .form-select-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
296
296
|
}
|
|
@@ -302,7 +302,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
302
302
|
}
|
|
303
303
|
getError() {
|
|
304
304
|
if (this.getIsValid()) return null;
|
|
305
|
-
let { t: e } =
|
|
305
|
+
let { t: e } = n();
|
|
306
306
|
return e("validation.stateRequired");
|
|
307
307
|
}
|
|
308
308
|
}, L = class extends k {
|
|
@@ -312,7 +312,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
312
312
|
render() {
|
|
313
313
|
if (!this.shadowRoot) return;
|
|
314
314
|
this._input?.getElement().remove();
|
|
315
|
-
let { t: e } =
|
|
315
|
+
let { t: e } = n();
|
|
316
316
|
this._input = new _({
|
|
317
317
|
name: "billingAddress.street",
|
|
318
318
|
label: this.options.label ?? e("address.addressLine1"),
|
|
@@ -329,15 +329,15 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
329
329
|
this.emit("change", this._value);
|
|
330
330
|
}
|
|
331
331
|
}), this._input.addEventListener("blur", () => {
|
|
332
|
-
let { t: e } =
|
|
332
|
+
let { t: e } = n();
|
|
333
333
|
this._error = this._value.trim() ? null : e("validation.addressLine1Required"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
334
334
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
335
335
|
}
|
|
336
336
|
getCss() {
|
|
337
337
|
return super.getCss() + [
|
|
338
|
-
E,
|
|
339
338
|
D,
|
|
340
|
-
|
|
339
|
+
O,
|
|
340
|
+
E
|
|
341
341
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
342
342
|
}
|
|
343
343
|
getValue() {
|
|
@@ -356,7 +356,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
356
356
|
render() {
|
|
357
357
|
if (!this.shadowRoot) return;
|
|
358
358
|
this._input?.getElement().remove();
|
|
359
|
-
let { t: e } =
|
|
359
|
+
let { t: e } = n();
|
|
360
360
|
this._input = new _({
|
|
361
361
|
name: "billingAddress.zipCode",
|
|
362
362
|
label: this.options.label ?? e("address.postalCode"),
|
|
@@ -368,15 +368,15 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
368
368
|
this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
|
|
369
369
|
}
|
|
370
370
|
}), this._input.addEventListener("blur", () => {
|
|
371
|
-
let { t: e } =
|
|
371
|
+
let { t: e } = n();
|
|
372
372
|
this._error = this._value.trim() ? null : e("validation.postalCodeRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
373
373
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
374
374
|
}
|
|
375
375
|
getCss() {
|
|
376
376
|
return super.getCss() + [
|
|
377
|
-
E,
|
|
378
377
|
D,
|
|
379
|
-
|
|
378
|
+
O,
|
|
379
|
+
E
|
|
380
380
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
381
381
|
}
|
|
382
382
|
getValue() {
|
|
@@ -431,15 +431,15 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
let { paymentId: e, checkoutKey: t, environment: n, checkoutDetails: r, displayName: i, countries: a, requiredBillingContactFields: o, requiredShippingContactFields: s, onAuthorize: c } = this._paymentContext;
|
|
434
|
-
if (!
|
|
434
|
+
if (!ne(a, r?.countryCode)) {
|
|
435
435
|
this._setAvailability(!1);
|
|
436
436
|
return;
|
|
437
437
|
}
|
|
438
|
-
if (!
|
|
438
|
+
if (!re()) {
|
|
439
439
|
this._setAvailability(!1);
|
|
440
440
|
return;
|
|
441
441
|
}
|
|
442
|
-
this._button = new
|
|
442
|
+
this._button = new ie({
|
|
443
443
|
checkoutProfile: B,
|
|
444
444
|
paymentId: e,
|
|
445
445
|
checkoutKey: t,
|
|
@@ -471,7 +471,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
471
471
|
getError() {
|
|
472
472
|
return null;
|
|
473
473
|
}
|
|
474
|
-
}, H = ".card-
|
|
474
|
+
}, H = ".card-icon{opacity:1;width:18px;transition:opacity .6s ease-in}.card-icon img{max-width:100%;height:auto;display:block}.cards-position{z-index:10;pointer-events:none;align-items:center;gap:8px;display:flex;position:absolute;top:50%;right:12px;transform:translateY(-50%)}.loading{position:relative}.loading:after{content:\"\";border-radius:inherit;background-color:#fff;width:100%;height:100%;position:absolute;inset:0}@media only screen and (min-width:600px){.card-icon{width:20px}}.vgs-card-group iframe,.vgs-wrap iframe{width:100%;min-width:0;display:block}.fake-ph{color:#717173;opacity:.3;font-size:var(--odus-input-font-size,16px);letter-spacing:.02em;font-weight:400;line-height:1.5;font-family:var(--odus-font-family,inherit);pointer-events:none;-webkit-user-select:none;user-select:none;white-space:nowrap;z-index:0;background:#fff;align-items:center;padding:8px 12px;display:flex;position:absolute;inset:0}@keyframes vgs-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.vgs-field-skeleton{pointer-events:none;z-index:11;border-radius:inherit;background:linear-gradient(90deg,#f7f7f7 25%,#fdfdfd 50%,#f7f7f7 75%) 0 0/200% 100%;animation:1.5s ease-in-out infinite vgs-shimmer;position:absolute;inset:0}.card-unavailable-message{color:var(--odus-color-error,#dc2727);background:color-mix(in srgb, var(--odus-color-error,#dc2727) 6%, transparent);box-shadow:0 0 0 1px var(--odus-color-error,#dc2727);box-sizing:border-box;padding:12px;line-height:1.4}.card-pending{width:100%;position:relative;overflow:hidden}", U = {
|
|
475
475
|
name: "odus-elements",
|
|
476
476
|
styles: {
|
|
477
477
|
fontSize: 14,
|
|
@@ -495,116 +495,7 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
495
495
|
}
|
|
496
496
|
},
|
|
497
497
|
additionalPaymentMethods: {}
|
|
498
|
-
},
|
|
499
|
-
_cardNumber = "";
|
|
500
|
-
_cardExpiry = "";
|
|
501
|
-
_cardCvv = "";
|
|
502
|
-
_section = null;
|
|
503
|
-
_focusManager = new u();
|
|
504
|
-
_touchedFields = /* @__PURE__ */ new Set();
|
|
505
|
-
_focusHandlers = [];
|
|
506
|
-
get section() {
|
|
507
|
-
return this._section;
|
|
508
|
-
}
|
|
509
|
-
renderSection(e, t, n) {
|
|
510
|
-
this._section?.getElement().remove();
|
|
511
|
-
let { t: i } = r();
|
|
512
|
-
this._section = new S({
|
|
513
|
-
checkoutProfile: G,
|
|
514
|
-
cardNumber: this._cardNumber,
|
|
515
|
-
cardNumberTouched: !1,
|
|
516
|
-
cardCvv: this._cardCvv,
|
|
517
|
-
cardCvvTouched: !1,
|
|
518
|
-
cardExpiry: this._cardExpiry,
|
|
519
|
-
cardExpiryTouched: !1,
|
|
520
|
-
translationFunc: i,
|
|
521
|
-
onChange: (e) => {
|
|
522
|
-
let n = e.target;
|
|
523
|
-
if (n.name === "cardNumber") this._cardNumber = n.value;
|
|
524
|
-
else if (n.name === "cardExpiry") {
|
|
525
|
-
let e = l.cardExpiry(n.value);
|
|
526
|
-
this._cardExpiry = e, this._section?.updateCardExpiry(e);
|
|
527
|
-
} else n.name === "cardCvv" && (this._cardCvv = n.value);
|
|
528
|
-
this._touchedFields.add(n.name), this._updateFocusManagerState(), t(this.getValue());
|
|
529
|
-
},
|
|
530
|
-
onBlur: (e) => {
|
|
531
|
-
let t = e.target, r = t.name ?? "cardExpiry", i = s();
|
|
532
|
-
if (this._touchedFields.add(r), t.name === "cardNumber") {
|
|
533
|
-
let e = i.cardNumber(this._cardNumber);
|
|
534
|
-
this._section?.updateCardNumber(this._cardNumber, e, !0);
|
|
535
|
-
} else if (t.name === "cardCvv") {
|
|
536
|
-
let e = i.cardCvv(this._cardCvv, this._cardNumber);
|
|
537
|
-
this._section?.updateCardCvv(this._cardCvv, e, !0);
|
|
538
|
-
} else {
|
|
539
|
-
let e = i.cardExpiry(this._cardExpiry);
|
|
540
|
-
this._section?.updateCardExpiry(this._cardExpiry, e, !0);
|
|
541
|
-
}
|
|
542
|
-
this._updateFocusManagerState(), n(this.getValue());
|
|
543
|
-
}
|
|
544
|
-
}), e.appendChild(this._section.getElement()), this._registerFocusFields();
|
|
545
|
-
}
|
|
546
|
-
getValue() {
|
|
547
|
-
return {
|
|
548
|
-
number: this._cardNumber,
|
|
549
|
-
expiry: this._cardExpiry,
|
|
550
|
-
cvv: this._cardCvv
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
async getPayload(e) {
|
|
554
|
-
let t = e === "live" ? W : U, n = new f();
|
|
555
|
-
n.setPublicKey(t);
|
|
556
|
-
let r = this._cardNumber.replace(/\s+/g, ""), i = this._cardExpiry.replace(/\s+/g, "").split("/"), a = i[0] ?? "", o = i[1] ?? "";
|
|
557
|
-
return o.length === 2 && (o = `20${o}`), {
|
|
558
|
-
encryptedCardNumber: n.encrypt(r),
|
|
559
|
-
encryptedCvv: n.encrypt(this._cardCvv),
|
|
560
|
-
expMonth: a,
|
|
561
|
-
expYear: o
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
isValid() {
|
|
565
|
-
let e = s(), t = this._cardCvv.length >= 3;
|
|
566
|
-
return !e.cardNumber(this._cardNumber) && !e.cardExpiry(this._cardExpiry) && t;
|
|
567
|
-
}
|
|
568
|
-
getError() {
|
|
569
|
-
let e = s();
|
|
570
|
-
return e.cardNumber(this._cardNumber) ?? e.cardExpiry(this._cardExpiry) ?? null;
|
|
571
|
-
}
|
|
572
|
-
destroy() {
|
|
573
|
-
this._cleanupFocusHandlers(), this._section = null;
|
|
574
|
-
}
|
|
575
|
-
_registerFocusFields() {
|
|
576
|
-
if (this._cleanupFocusHandlers(), !this._section) return;
|
|
577
|
-
let e = this._section.getElement();
|
|
578
|
-
this._focusManager.registerField("cardNumber", { focus: () => this._section?.focusField("cardNumber") }), this._focusManager.registerField("cardExpiry", { focus: () => this._section?.focusField("cardExpiry") }), this._focusManager.registerField("cardCvv", { focus: () => this._section?.focusField("cardCvv") });
|
|
579
|
-
for (let t of [
|
|
580
|
-
"cardNumber",
|
|
581
|
-
"cardExpiry",
|
|
582
|
-
"cardCvv"
|
|
583
|
-
]) {
|
|
584
|
-
let n = e.querySelector(`input[name="${t}"]`);
|
|
585
|
-
if (!n) continue;
|
|
586
|
-
let r = () => this._focusManager.handleFieldFocus(t);
|
|
587
|
-
n.addEventListener("focus", r), this._focusHandlers.push(() => n.removeEventListener("focus", r));
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
_cleanupFocusHandlers() {
|
|
591
|
-
for (let e of this._focusHandlers) e();
|
|
592
|
-
this._focusHandlers = [];
|
|
593
|
-
}
|
|
594
|
-
_updateFocusManagerState() {
|
|
595
|
-
let e = s(), t = {
|
|
596
|
-
cardNumber: this._cardNumber,
|
|
597
|
-
cardExpiry: this._cardExpiry,
|
|
598
|
-
cardCvv: this._cardCvv,
|
|
599
|
-
name: "",
|
|
600
|
-
email: ""
|
|
601
|
-
}, n = {}, r = e.cardNumber(this._cardNumber), i = e.cardExpiry(this._cardExpiry), a = e.cardCvv(this._cardCvv, this._cardNumber);
|
|
602
|
-
r && (n.cardNumber = r), i && (n.cardExpiry = i), a && (n.cardCvv = a);
|
|
603
|
-
let o = {};
|
|
604
|
-
for (let e of this._touchedFields) o[e] = !0;
|
|
605
|
-
this._focusManager.handleStateUpdate(t, n, o);
|
|
606
|
-
}
|
|
607
|
-
}, q = {
|
|
498
|
+
}, W = {
|
|
608
499
|
"--odus-font-family": "system-ui, sans-serif",
|
|
609
500
|
"--odus-font-size": "16px",
|
|
610
501
|
"--odus-color-error": "#dc2727",
|
|
@@ -628,11 +519,11 @@ var T = ".form-helper-text-anchor{height:var(--odus-helper-text-space,4px);z-ind
|
|
|
628
519
|
"--odus-button-height": "48px",
|
|
629
520
|
"--odus-button-border-radius": "var(--odus-border-radius)"
|
|
630
521
|
}["--odus-font-size"];
|
|
631
|
-
function
|
|
522
|
+
function G(e, t) {
|
|
632
523
|
let n = Object.keys(e);
|
|
633
524
|
return n.length === Object.keys(t).length && n.every((n) => e[n] === t[n]);
|
|
634
525
|
}
|
|
635
|
-
var
|
|
526
|
+
var K = class {
|
|
636
527
|
_vgsService;
|
|
637
528
|
_vgsJwt;
|
|
638
529
|
_vgsState = {};
|
|
@@ -642,26 +533,20 @@ var se = class {
|
|
|
642
533
|
_environment = "test";
|
|
643
534
|
_section = null;
|
|
644
535
|
_initGeneration = 0;
|
|
645
|
-
|
|
646
|
-
|
|
536
|
+
_onInitFailure = null;
|
|
537
|
+
_onFieldsNotReady = null;
|
|
538
|
+
constructor(e, t, n = {}) {
|
|
539
|
+
this._vgsJwt = e, this._environment = t, this._onInitFailure = n.onInitFailure ?? null, this._onFieldsNotReady = n.onFieldsNotReady ?? null, this._vgsService = new l();
|
|
647
540
|
}
|
|
648
541
|
get section() {
|
|
649
542
|
return this._section;
|
|
650
543
|
}
|
|
651
544
|
renderSection(e, t) {
|
|
652
545
|
this._section?.getElement().remove();
|
|
653
|
-
let { t:
|
|
654
|
-
this._section = new
|
|
655
|
-
checkoutProfile:
|
|
656
|
-
|
|
657
|
-
cardNumberTouched: !1,
|
|
658
|
-
cardCvv: "",
|
|
659
|
-
cardCvvTouched: !1,
|
|
660
|
-
cardExpiry: "",
|
|
661
|
-
cardExpiryTouched: !1,
|
|
662
|
-
translationFunc: n,
|
|
663
|
-
onChange: () => {},
|
|
664
|
-
onBlur: () => {},
|
|
546
|
+
let { t: r } = n();
|
|
547
|
+
this._section = new h({
|
|
548
|
+
checkoutProfile: U,
|
|
549
|
+
translationFunc: r,
|
|
665
550
|
vgsService: this._vgsService
|
|
666
551
|
}), this._applySkeletonMetrics(), e.appendChild(this._section.getElement()), this._onChangeEmit = t;
|
|
667
552
|
}
|
|
@@ -674,7 +559,11 @@ var se = class {
|
|
|
674
559
|
initVgs() {
|
|
675
560
|
let e = ++this._initGeneration;
|
|
676
561
|
this._vgsService.init(this._environment).then((t) => {
|
|
677
|
-
e === this._initGeneration && (this._vgsService.createForm(t, (e) => this._handleStateChange(e)), this._mountFields(e))
|
|
562
|
+
e === this._initGeneration && (this._vgsService.createForm(t, (e) => this._handleStateChange(e)), this._mountFields(e).catch((t) => {
|
|
563
|
+
e === this._initGeneration && (console.error("Failed to mount VGS card fields:", t), this._onFieldsNotReady?.());
|
|
564
|
+
}));
|
|
565
|
+
}).catch((t) => {
|
|
566
|
+
e === this._initGeneration && (console.error("Failed to load VGS Collect:", t), this._onInitFailure?.());
|
|
678
567
|
});
|
|
679
568
|
}
|
|
680
569
|
async getPayload() {
|
|
@@ -691,12 +580,12 @@ var se = class {
|
|
|
691
580
|
return this._vgsFieldsValid;
|
|
692
581
|
}
|
|
693
582
|
getError() {
|
|
694
|
-
let { t: e } =
|
|
583
|
+
let { t: e } = n();
|
|
695
584
|
for (let [t, n] of Object.entries(this._vgsState)) {
|
|
696
585
|
if (!n?.isTouched || n.isFocused || n.isValid) continue;
|
|
697
586
|
let r = n.errors?.[0];
|
|
698
587
|
if (!r) continue;
|
|
699
|
-
let i =
|
|
588
|
+
let i = C(t, r.code);
|
|
700
589
|
if (i) return e(i);
|
|
701
590
|
}
|
|
702
591
|
return null;
|
|
@@ -706,7 +595,7 @@ var se = class {
|
|
|
706
595
|
...this._currentTheme,
|
|
707
596
|
...e
|
|
708
597
|
};
|
|
709
|
-
|
|
598
|
+
G(this._currentTheme, t) || (this._currentTheme = t, this._section && (this._applySkeletonMetrics(), this._reinitWithTheme()));
|
|
710
599
|
}
|
|
711
600
|
resetTheme(e) {
|
|
712
601
|
let t = e.filter((e) => e in this._currentTheme);
|
|
@@ -716,29 +605,29 @@ var se = class {
|
|
|
716
605
|
}
|
|
717
606
|
}
|
|
718
607
|
destroy() {
|
|
719
|
-
this._vgsReinitTimer &&= (clearTimeout(this._vgsReinitTimer), null), this._vgsService.destroy(), this._section = null;
|
|
608
|
+
this._vgsReinitTimer &&= (clearTimeout(this._vgsReinitTimer), null), this._initGeneration += 1, this._onInitFailure = null, this._onFieldsNotReady = null, this._vgsService.destroy(), this._section = null;
|
|
720
609
|
}
|
|
721
610
|
_reinitWithTheme() {
|
|
722
611
|
this._vgsReinitTimer && clearTimeout(this._vgsReinitTimer), this._vgsReinitTimer = setTimeout(() => {
|
|
723
|
-
this._vgsReinitTimer = null, this._vgsService.destroy(), this._vgsService = new
|
|
612
|
+
this._vgsReinitTimer = null, this._vgsService.destroy(), this._vgsService = new l(), this._section?.setVgsService(this._vgsService), this.initVgs();
|
|
724
613
|
}, 300);
|
|
725
614
|
}
|
|
726
615
|
_buildProfileFromTheme(e) {
|
|
727
|
-
let t = e["--odus-input-font-size"] ?? e["--odus-font-size"] ??
|
|
616
|
+
let t = e["--odus-input-font-size"] ?? e["--odus-font-size"] ?? W, n = e["--odus-font-family"] ?? U.styles.fontFamily, r = e["--odus-color-text"] ?? U.styles.textColor, i = e["--odus-border-radius"] ?? `${U.styles.borderRadius}px`;
|
|
728
617
|
return {
|
|
729
|
-
...
|
|
618
|
+
...U,
|
|
730
619
|
styles: {
|
|
731
|
-
...
|
|
732
|
-
fontSize: parseInt(t, 10) || parseInt(
|
|
620
|
+
...U.styles,
|
|
621
|
+
fontSize: parseInt(t, 10) || parseInt(W, 10),
|
|
733
622
|
fontFamily: n,
|
|
734
623
|
textColor: r,
|
|
735
|
-
borderRadius: parseInt(i, 10) ||
|
|
624
|
+
borderRadius: parseInt(i, 10) || U.styles.borderRadius
|
|
736
625
|
}
|
|
737
626
|
};
|
|
738
627
|
}
|
|
739
628
|
async _mountFields(e) {
|
|
740
629
|
if (!this._section) return;
|
|
741
|
-
let
|
|
630
|
+
let r = this._buildProfileFromTheme(this._currentTheme), i = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
|
|
742
631
|
this._applySkeletonMetrics();
|
|
743
632
|
let a = this._section.getVgsContainerIds();
|
|
744
633
|
for (let e of Object.values(a)) {
|
|
@@ -746,15 +635,15 @@ var se = class {
|
|
|
746
635
|
let t = document.getElementById(e);
|
|
747
636
|
t && t.querySelectorAll("iframe").forEach((e) => e.remove());
|
|
748
637
|
}
|
|
749
|
-
let o = await t(
|
|
638
|
+
let o = await t(r.styles.fontFamily);
|
|
750
639
|
if (e !== this._initGeneration) return;
|
|
751
|
-
let s = this._section.buildVgsFieldCss(
|
|
640
|
+
let s = this._section.buildVgsFieldCss(r, o, {
|
|
752
641
|
borderColor: i,
|
|
753
642
|
backgroundColor: this._currentTheme["--odus-color-background"],
|
|
754
643
|
placeholderColor: this._currentTheme["--odus-input-placeholder-color"],
|
|
755
644
|
placeholderOpacity: this._currentTheme["--odus-input-placeholder-opacity"],
|
|
756
645
|
padding: this._currentTheme["--odus-input-padding"]
|
|
757
|
-
}), { t: c } =
|
|
646
|
+
}), { t: c } = n();
|
|
758
647
|
this._vgsService.mountCardFields({
|
|
759
648
|
cardNumber: a.cardNumber ? `#${a.cardNumber}` : void 0,
|
|
760
649
|
cardExpiry: a.cardExpiry ? `#${a.cardExpiry}` : void 0,
|
|
@@ -768,12 +657,14 @@ var se = class {
|
|
|
768
657
|
this._section?.updateVgsCardBrand(e);
|
|
769
658
|
}), this._vgsService.waitForFieldsReady().then(() => {
|
|
770
659
|
this._section?.hideFakePlaceholders();
|
|
660
|
+
}).catch((t) => {
|
|
661
|
+
e === this._initGeneration && (console.error("VGS card fields did not become ready:", t), this._onFieldsNotReady?.());
|
|
771
662
|
});
|
|
772
663
|
}
|
|
773
664
|
_handleStateChange(e) {
|
|
774
665
|
this._vgsState = e, this._vgsFieldsValid = Object.values(e).every((e) => e?.isValid === !0);
|
|
775
|
-
let { t } =
|
|
776
|
-
this._section?.handleVgsStateChange(e,
|
|
666
|
+
let { t } = n(), r = this._deriveFieldErrors(t);
|
|
667
|
+
this._section?.handleVgsStateChange(e, r), this._onChangeEmit?.();
|
|
777
668
|
}
|
|
778
669
|
_deriveFieldErrors(e) {
|
|
779
670
|
let t = {};
|
|
@@ -781,100 +672,150 @@ var se = class {
|
|
|
781
672
|
if (!r?.isTouched || r.isFocused || r.isValid) continue;
|
|
782
673
|
let i = r.errors?.[0];
|
|
783
674
|
if (!i) continue;
|
|
784
|
-
let a =
|
|
675
|
+
let a = C(n, i.code);
|
|
785
676
|
a && (t[n] = e(a));
|
|
786
677
|
}
|
|
787
678
|
return t;
|
|
788
679
|
}
|
|
789
|
-
},
|
|
680
|
+
}, se = "Card capture is unavailable: no tokenization session", q = class extends k {
|
|
790
681
|
_environment = "test";
|
|
791
|
-
|
|
682
|
+
_captureState = "pending";
|
|
792
683
|
_mountContainer = null;
|
|
793
|
-
_nativeAdapter = new K();
|
|
794
684
|
_vgsAdapter = null;
|
|
795
685
|
_vgsJwt = null;
|
|
686
|
+
_reportedUnavailable = !1;
|
|
687
|
+
_unavailableReason = x.NO_TOKENIZATION_SESSION;
|
|
796
688
|
get isVgsMode() {
|
|
797
|
-
return this.
|
|
689
|
+
return this._captureState === "vgs";
|
|
690
|
+
}
|
|
691
|
+
get captureState() {
|
|
692
|
+
return this._captureState;
|
|
798
693
|
}
|
|
799
694
|
setEnvironment(e) {
|
|
800
695
|
this._environment = e;
|
|
801
696
|
}
|
|
802
697
|
setVgsJwt(e) {
|
|
803
|
-
this._vgsAdapter && this._vgsJwt === e
|
|
698
|
+
if (this._vgsAdapter && this._vgsJwt === e) return;
|
|
699
|
+
this._captureState = "vgs", this._reportedUnavailable = !1, this._vgsJwt = e, this._vgsAdapter?.destroy();
|
|
700
|
+
let t = new K(e, this._environment, {
|
|
701
|
+
onInitFailure: () => {
|
|
702
|
+
this._vgsAdapter !== t || !this.isMounted || this.markCaptureUnavailable(x.INIT_FAILED);
|
|
703
|
+
},
|
|
704
|
+
onFieldsNotReady: () => {
|
|
705
|
+
this._vgsAdapter !== t || !this.isMounted || this.markCaptureUnavailable(x.FIELDS_NOT_READY);
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
this._vgsAdapter = t, this.isMounted && this._mountContainer && (this.unmount(), this.mount(this._mountContainer));
|
|
709
|
+
}
|
|
710
|
+
markCaptureUnavailable(e = x.NO_TOKENIZATION_SESSION) {
|
|
711
|
+
if (this._captureState === "unavailable") return;
|
|
712
|
+
let t = this._mountContainer, n = this.isMounted && t !== null;
|
|
713
|
+
this.isMounted && this.unmount(), this._unavailableReason = e, this._captureState = "unavailable", this._vgsAdapter?.destroy(), this._vgsAdapter = null, this._vgsJwt = null, n && t && this.mount(t);
|
|
714
|
+
}
|
|
715
|
+
resetCardCapture() {
|
|
716
|
+
if (this._captureState === "unsupported") return;
|
|
717
|
+
let e = this._mountContainer, t = this.isMounted && e !== null;
|
|
718
|
+
this.isMounted && this.unmount(), this._captureState = "unsupported", this._reportedUnavailable = !1, this._vgsAdapter?.destroy(), this._vgsAdapter = null, this._vgsJwt = null, t && e && this.mount(e);
|
|
804
719
|
}
|
|
805
720
|
mount(e) {
|
|
806
721
|
this.isMounted && this.unmount();
|
|
807
722
|
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
808
723
|
if (!t) throw Error(`[CardElement] mount target not found: ${String(e)}`);
|
|
809
|
-
if (this._mountContainer = e, this.
|
|
724
|
+
if (this._mountContainer = e, this._captureState === "vgs") {
|
|
810
725
|
this.host = document.createElement("div");
|
|
811
726
|
let e = document.createElement("style");
|
|
812
727
|
e.textContent = this.getCss(), this.host.appendChild(e), t.appendChild(this.host), this.reapplyTheme(), Object.keys(this._appliedTheme).length > 0 && this._vgsAdapter?.applyTheme(this._appliedTheme), this.render(), this._vgsAdapter?.initVgs(), this.emit("ready");
|
|
813
728
|
} else super.mount(e);
|
|
814
729
|
}
|
|
815
730
|
unmount() {
|
|
816
|
-
this.
|
|
731
|
+
this._captureState === "vgs" ? (this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null) : super.unmount();
|
|
817
732
|
}
|
|
818
733
|
render() {
|
|
819
|
-
if (this.
|
|
734
|
+
if (this._captureState === "vgs") {
|
|
820
735
|
if (!this.host || !this._vgsAdapter) return;
|
|
821
736
|
this._vgsAdapter.renderSection(this.host, () => this.emit("change", this.getValue()));
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
if (this._captureState === "unsupported") {
|
|
740
|
+
this.clearBody();
|
|
741
|
+
return;
|
|
825
742
|
}
|
|
743
|
+
if (this._captureState === "pending") {
|
|
744
|
+
this.renderPendingPlaceholder();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
this.renderUnavailableNotice();
|
|
748
|
+
}
|
|
749
|
+
clearBody() {
|
|
750
|
+
this.shadowRoot?.querySelectorAll(".card-unavailable, .card-pending").forEach((e) => e.remove());
|
|
751
|
+
}
|
|
752
|
+
renderPendingPlaceholder() {
|
|
753
|
+
if (!this.shadowRoot) return;
|
|
754
|
+
this.clearBody();
|
|
755
|
+
let e = document.createElement("div");
|
|
756
|
+
e.className = "card-pending";
|
|
757
|
+
let t = T(m, U.styles.fontSize);
|
|
758
|
+
e.style.height = `calc((${t}) * 2 - 1px)`, e.style.borderRadius = `var(--odus-border-radius, ${U.styles.borderRadius}px)`;
|
|
759
|
+
let n = document.createElement("div");
|
|
760
|
+
n.className = "vgs-field-skeleton", e.appendChild(n), this.shadowRoot.appendChild(e);
|
|
761
|
+
}
|
|
762
|
+
renderUnavailableNotice() {
|
|
763
|
+
if (!this.shadowRoot) return;
|
|
764
|
+
this.clearBody();
|
|
765
|
+
let { t: e } = n(), t = new ae({
|
|
766
|
+
checkoutProfile: U,
|
|
767
|
+
translationFunc: e
|
|
768
|
+
});
|
|
769
|
+
this.shadowRoot.appendChild(t.getElement()), this.emit("error", e("cardUnavailable")), this._reportedUnavailable || (this._reportedUnavailable = !0, u(a.CARD_CAPTURE_UNAVAILABLE, { reason: this._unavailableReason }));
|
|
826
770
|
}
|
|
827
771
|
focus() {
|
|
828
|
-
|
|
772
|
+
this._vgsAdapter?.section?.focus();
|
|
829
773
|
}
|
|
830
774
|
focusField(e) {
|
|
831
|
-
|
|
775
|
+
this._vgsAdapter?.section?.focusField(e);
|
|
832
776
|
}
|
|
833
777
|
destroy() {
|
|
834
|
-
this.
|
|
778
|
+
this._vgsAdapter?.destroy(), this._vgsAdapter = null, this._vgsJwt = null, this._captureState = "pending", this._reportedUnavailable = !1, super.destroy();
|
|
835
779
|
}
|
|
836
780
|
setTheme(e) {
|
|
837
|
-
super.setTheme(e), !(
|
|
781
|
+
super.setTheme(e), !(this._captureState !== "vgs" || !this._vgsAdapter) && this._vgsAdapter.applyTheme(e);
|
|
838
782
|
}
|
|
839
783
|
resetTheme(e) {
|
|
840
|
-
super.resetTheme(e), !(
|
|
784
|
+
super.resetTheme(e), !(this._captureState !== "vgs" || !this._vgsAdapter) && this._vgsAdapter.resetTheme(Object.keys(e));
|
|
841
785
|
}
|
|
842
786
|
getCss() {
|
|
843
787
|
return super.getCss() + [
|
|
844
|
-
E,
|
|
845
788
|
D,
|
|
846
|
-
|
|
789
|
+
O,
|
|
790
|
+
E,
|
|
847
791
|
H
|
|
848
792
|
].join("\n") + "\n :host { display: block; }\n .card-grid {\n display: flex;\n flex-direction: column;\n gap: var(--odus-card-gap, 12px);\n }\n .card-details {\n display: flex;\n gap: var(--odus-card-gap, 12px);\n }\n .form-input,\n .form-select {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus,\n .form-select:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error,\n .form-select-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
849
793
|
}
|
|
850
794
|
getValue() {
|
|
851
|
-
return
|
|
795
|
+
return {
|
|
852
796
|
number: "",
|
|
853
797
|
expiry: "",
|
|
854
798
|
cvv: ""
|
|
855
|
-
}
|
|
799
|
+
};
|
|
856
800
|
}
|
|
857
801
|
async getPayload() {
|
|
858
|
-
if (this.
|
|
859
|
-
|
|
860
|
-
return this._vgsAdapter.getPayload();
|
|
861
|
-
}
|
|
862
|
-
return this._nativeAdapter.getPayload(this._environment);
|
|
802
|
+
if (this._captureState !== "vgs" || !this._vgsAdapter) throw Error(se);
|
|
803
|
+
return this._vgsAdapter.getPayload();
|
|
863
804
|
}
|
|
864
805
|
getIsValid() {
|
|
865
|
-
return this.
|
|
806
|
+
return this._captureState === "unsupported" ? !0 : this._vgsAdapter?.isValid() ?? !1;
|
|
866
807
|
}
|
|
867
808
|
getError() {
|
|
868
|
-
return this.
|
|
809
|
+
return this._captureState === "unavailable" ? n().t("cardUnavailable") : this._vgsAdapter?.getError() ?? null;
|
|
869
810
|
}
|
|
870
|
-
},
|
|
811
|
+
}, J = class extends k {
|
|
871
812
|
_value = "";
|
|
872
813
|
_error = null;
|
|
873
814
|
_input = null;
|
|
874
815
|
render() {
|
|
875
816
|
if (!this.shadowRoot) return;
|
|
876
817
|
this._input?.getElement().remove();
|
|
877
|
-
let { t: e } =
|
|
818
|
+
let { t: e } = n();
|
|
878
819
|
this._input = new _({
|
|
879
820
|
name: "billingAddress.cardholderName",
|
|
880
821
|
label: this.options.label ?? e("cardholderNameLabel"),
|
|
@@ -887,15 +828,15 @@ var se = class {
|
|
|
887
828
|
t !== n && this._input?.setValue(n), this._value = n, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
|
|
888
829
|
}
|
|
889
830
|
}), this._input.addEventListener("blur", () => {
|
|
890
|
-
let { t: e } =
|
|
831
|
+
let { t: e } = n();
|
|
891
832
|
this._error = this._value.trim() ? null : e("validation.nameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
|
|
892
833
|
}), this.shadowRoot.appendChild(this._input.getElement());
|
|
893
834
|
}
|
|
894
835
|
getCss() {
|
|
895
836
|
return super.getCss() + [
|
|
896
|
-
E,
|
|
897
837
|
D,
|
|
898
|
-
|
|
838
|
+
O,
|
|
839
|
+
E
|
|
899
840
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
900
841
|
}
|
|
901
842
|
getValue() {
|
|
@@ -931,7 +872,7 @@ var se = class {
|
|
|
931
872
|
}
|
|
932
873
|
},
|
|
933
874
|
additionalPaymentMethods: {}
|
|
934
|
-
},
|
|
875
|
+
}, Y = class extends k {
|
|
935
876
|
_email = "";
|
|
936
877
|
_error = null;
|
|
937
878
|
_suggestion = null;
|
|
@@ -939,8 +880,8 @@ var se = class {
|
|
|
939
880
|
render() {
|
|
940
881
|
if (!this.shadowRoot) return;
|
|
941
882
|
this._field?.getElement().remove(), this.options.initialValue && !this._email && (this._email = String(this.options.initialValue));
|
|
942
|
-
let { t: e } =
|
|
943
|
-
this._field = new
|
|
883
|
+
let { t: e } = n();
|
|
884
|
+
this._field = new b({
|
|
944
885
|
value: this._email,
|
|
945
886
|
error: !1,
|
|
946
887
|
checkoutProfile: ce,
|
|
@@ -952,23 +893,23 @@ var se = class {
|
|
|
952
893
|
this._email = t.value ?? this._field?.getValue() ?? "", this._error = null, this._suggestion = null, this._field?.setError(!1), this._field?.setSuggestion(null), this.emit("change", this._email);
|
|
953
894
|
},
|
|
954
895
|
onBlur: () => {
|
|
955
|
-
let e =
|
|
896
|
+
let e = c();
|
|
956
897
|
this._error = e.email(this._email) ?? null, this._suggestion = e.emailSuggestion(this._email) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this._field?.setSuggestion(this._suggestion), this.emit("blur", this._email);
|
|
957
898
|
}
|
|
958
899
|
}), this.shadowRoot.appendChild(this._field.getElement());
|
|
959
900
|
}
|
|
960
901
|
getCss() {
|
|
961
902
|
return super.getCss() + [
|
|
962
|
-
E,
|
|
963
903
|
D,
|
|
964
|
-
|
|
904
|
+
O,
|
|
905
|
+
E
|
|
965
906
|
].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text-hint {\n color: var(--odus-color-muted, #6b7280) !important;\n }\n ";
|
|
966
907
|
}
|
|
967
908
|
getValue() {
|
|
968
909
|
return this._email;
|
|
969
910
|
}
|
|
970
911
|
getIsValid() {
|
|
971
|
-
return !
|
|
912
|
+
return !c().email(this._email);
|
|
972
913
|
}
|
|
973
914
|
getError() {
|
|
974
915
|
return this._error;
|
|
@@ -976,18 +917,18 @@ var se = class {
|
|
|
976
917
|
get suggestion() {
|
|
977
918
|
return this._suggestion;
|
|
978
919
|
}
|
|
979
|
-
}, le = "@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.error-alert{background-color:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;animation:.3s ease-out slideIn;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f}.error-alert-content{align-items:flex-start;gap:12px;display:flex}.error-alert-icon-container{color:#dc2626;background-color:#fee2e2;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;display:flex}.error-alert-icon{color:#dc2626}.error-alert-text-container{flex:1;min-width:0}.error-alert-title{color:#991b1b;margin:0 0 4px;font-size:14px;font-weight:600;line-height:1.4}.error-alert-message{font-family:var(--odus-font-family,inherit);color:#7f1d1d;word-break:break-word;margin:0;font-size:14px;line-height:1.5}",
|
|
920
|
+
}, le = "@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.error-alert{background-color:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;animation:.3s ease-out slideIn;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f}.error-alert-content{align-items:flex-start;gap:12px;display:flex}.error-alert-icon-container{color:#dc2626;background-color:#fee2e2;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;display:flex}.error-alert-icon{color:#dc2626}.error-alert-text-container{flex:1;min-width:0}.error-alert-title{color:#991b1b;margin:0 0 4px;font-size:14px;font-weight:600;line-height:1.4}.error-alert-message{font-family:var(--odus-font-family,inherit);color:#7f1d1d;word-break:break-word;margin:0;font-size:14px;line-height:1.5}", X = class extends k {
|
|
980
921
|
_alert = null;
|
|
981
922
|
_message = null;
|
|
982
923
|
render() {
|
|
983
|
-
this.shadowRoot && (this._alert?.getElement().remove(), this._alert = null, this._message && (this._alert = new
|
|
924
|
+
this.shadowRoot && (this._alert?.getElement().remove(), this._alert = null, this._message && (this._alert = new S({ message: this._message }), this.shadowRoot.appendChild(this._alert.getElement())));
|
|
984
925
|
}
|
|
985
926
|
setError(e) {
|
|
986
927
|
if (this._message = e, !this.shadowRoot) {
|
|
987
928
|
this.emit("error", e);
|
|
988
929
|
return;
|
|
989
930
|
}
|
|
990
|
-
this._alert ? this._alert.setMessage(e) : (this._alert = new
|
|
931
|
+
this._alert ? this._alert.setMessage(e) : (this._alert = new S({ message: e }), this.shadowRoot.appendChild(this._alert.getElement())), this.emit("error", e);
|
|
991
932
|
}
|
|
992
933
|
clearError() {
|
|
993
934
|
this._message = null, this._alert?.getElement().remove(), this._alert = null;
|
|
@@ -1004,7 +945,7 @@ var se = class {
|
|
|
1004
945
|
getError() {
|
|
1005
946
|
return this._message;
|
|
1006
947
|
}
|
|
1007
|
-
}, ue = ".paypal{color:#253b80;text-transform:none;cursor:pointer;background-color:#ffc439;border-radius:4px;padding:8px 16px;font-weight:700;box-shadow:0 2px 4px #0000001a}.paypal:hover{filter:brightness(.95);background-color:#ffc439}.paypal-icon-container{justify-content:center;align-items:center;display:flex}.paypal-icon-container img{width:69px;height:22px}",
|
|
948
|
+
}, ue = ".paypal{color:#253b80;text-transform:none;cursor:pointer;background-color:#ffc439;border-radius:4px;padding:8px 16px;font-weight:700;box-shadow:0 2px 4px #0000001a}.paypal:hover{filter:brightness(.95);background-color:#ffc439}.paypal-icon-container{justify-content:center;align-items:center;display:flex}.paypal-icon-container img{width:69px;height:22px}", Z = {
|
|
1008
949
|
name: "odus-elements",
|
|
1009
950
|
styles: {
|
|
1010
951
|
fontSize: 14,
|
|
@@ -1037,8 +978,8 @@ var se = class {
|
|
|
1037
978
|
render() {
|
|
1038
979
|
if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
|
|
1039
980
|
let { onAuthorize: e } = this._paymentContext;
|
|
1040
|
-
this._button = new
|
|
1041
|
-
checkoutProfile:
|
|
981
|
+
this._button = new y({
|
|
982
|
+
checkoutProfile: Z,
|
|
1042
983
|
onSubmit: async () => {
|
|
1043
984
|
this._button?.setSubmitting(!0);
|
|
1044
985
|
try {
|
|
@@ -1061,7 +1002,7 @@ var se = class {
|
|
|
1061
1002
|
getError() {
|
|
1062
1003
|
return null;
|
|
1063
1004
|
}
|
|
1064
|
-
},
|
|
1005
|
+
}, de = ".country-dial-code-dropdown{display:inline-block;position:relative}.country-dial-code-trigger{padding:var(--odus-input-padding,8px 12px);cursor:pointer;letter-spacing:.02em;font-weight:400;line-height:var(--odus-input-line-height,1.5);white-space:nowrap;box-sizing:border-box;background:#fff;border:none;border-right:1px solid #e0e0e0;align-items:center;gap:6px;padding-right:8px;transition:all .1s ease-in;display:flex}.country-dial-code-trigger:hover{background:#f5f5f5}.country-dial-code-trigger:focus{outline:none}.country-dial-code-trigger .country-flag{font-size:14px;line-height:1}.country-dial-code-trigger .country-chevron{color:#717173;flex-shrink:0;transition:transform .15s}.country-dial-code-trigger[aria-expanded=true] .country-chevron{transform:rotate(180deg)}.country-dial-code-panel{z-index:10000;background:#fff;border-radius:8px;flex-direction:column;width:280px;max-height:360px;display:flex;position:fixed;top:0;left:0;overflow:hidden;box-shadow:0 0 0 1px #0000000d,0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}.country-dial-code-panel.hidden{display:none}.country-search-wrapper{border-bottom:1px solid #e0e0e0;flex-shrink:0;padding:12px}.country-search{width:100%;font-size:inherit;box-sizing:border-box;border:1px solid #e0e0e0;border-radius:6px;outline:none;padding:6px 12px;font-family:inherit;transition:all .1s ease-in}.country-search:focus{border-color:#3297d3b3;box-shadow:0 0 0 3px #3297d31a}.country-search::placeholder{color:#717173;opacity:.6}.countries-list{flex:1;min-height:0;overflow-y:auto}.countries-list::-webkit-scrollbar{width:8px}.countries-list::-webkit-scrollbar-track{background:#f5f5f5}.countries-list::-webkit-scrollbar-thumb{background:#d0d0d0;border-radius:4px}.countries-list::-webkit-scrollbar-thumb:hover{background:#b0b0b0}.country-group-header{color:#717173;text-transform:uppercase;letter-spacing:.05em;z-index:1;background:#fafafa;padding:8px 16px 4px;font-size:12px;font-weight:600;position:sticky;top:0}.country-item{cursor:pointer;text-align:left;width:100%;color:inherit;background:#fff;border:none;align-items:center;gap:12px;padding:10px 16px;font-family:inherit;font-size:14px;transition:background .1s;display:flex}.country-item:hover{background:#f5f5f5}.country-item.selected{color:#3297d3;background:#3297d314}.country-item:focus{background:#f0f0f0;outline:none}.country-item .country-flag{flex-shrink:0;font-size:20px;line-height:1}.country-item .country-name{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.country-item .country-dial-code{color:#717173;flex-shrink:0;font-size:.95em}.country-item.selected .country-dial-code{color:#3297d3cc}.no-results{text-align:center;color:#717173;padding:24px 16px;font-size:14px}.phone-number-field-wrapper{width:100%;display:flex}.phone-number-field-container{border-radius:inherit;background:#fff;align-items:center;width:100%;transition:box-shadow .1s ease-in,border-radius .2s ease-in;display:flex;position:relative;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d}.phone-number-field-container.focused{z-index:2;box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}.phone-number-field-container.error{box-shadow:0 0 0 1px #dc2727,0 2px 4px #dc27271a}.phone-number-field-container.error.focused{box-shadow:0 0 0 1px #dc2727,0 1px 1px #00000012,0 0 0 4px #dc272733}.phone-number-field-container .country-select-wrapper{padding:var(--odus-input-padding,8px 12px);border-top-left-radius:var(--phone-border-radius,0px);border-bottom-left-radius:var(--phone-border-radius,0px);white-space:nowrap;background:0 0;flex-shrink:0;align-items:center;gap:4px;padding-right:6px;display:flex;position:relative}.phone-number-field-container .country-select-wrapper .country-flag{pointer-events:none;font-size:14px;line-height:1}.phone-number-field-container .country-select-wrapper .country-chevron{color:#717173;pointer-events:none;flex-shrink:0;align-items:center;display:flex}.phone-number-field-container .country-select-wrapper .country-select{cursor:pointer;opacity:0;background:0 0;border:none;outline:none;width:100%;height:100%;position:absolute;inset:0}.phone-number-field-container .phone-input-wrapper{flex:1;min-width:0}.phone-number-field-container .phone-input-wrapper .form-input{box-shadow:none;border-radius:0;border-top-right-radius:var(--phone-border-radius,0px);border-bottom-right-radius:var(--phone-border-radius,0px);padding:var(--odus-input-padding,8px 2px);border:none}.phone-number-field-container .phone-input-wrapper .form-input:focus{box-shadow:none;z-index:auto}", fe = {
|
|
1065
1006
|
name: "odus-elements",
|
|
1066
1007
|
styles: {
|
|
1067
1008
|
fontSize: 14,
|
|
@@ -1093,15 +1034,15 @@ var se = class {
|
|
|
1093
1034
|
render() {
|
|
1094
1035
|
if (!this.shadowRoot) return;
|
|
1095
1036
|
this._field?.destroy(), this._field?.getElement().remove(), this._field = null, this.options.initialValue && !this._phone && (this._phone = String(this.options.initialValue));
|
|
1096
|
-
let
|
|
1097
|
-
|
|
1098
|
-
if (!this.shadowRoot || this._renderGeneration !==
|
|
1099
|
-
let { t:
|
|
1100
|
-
this._field = new
|
|
1037
|
+
let t = ++this._renderGeneration;
|
|
1038
|
+
e().then(({ PhoneNumberField: e }) => {
|
|
1039
|
+
if (!this.shadowRoot || this._renderGeneration !== t) return;
|
|
1040
|
+
let { t: r, locale: i } = n();
|
|
1041
|
+
this._field = new e({
|
|
1101
1042
|
value: this._phone,
|
|
1102
1043
|
error: !1,
|
|
1103
|
-
checkoutProfile:
|
|
1104
|
-
translationFunc:
|
|
1044
|
+
checkoutProfile: fe,
|
|
1045
|
+
translationFunc: r,
|
|
1105
1046
|
locale: i,
|
|
1106
1047
|
label: this.options.label,
|
|
1107
1048
|
placeholder: this.options.placeholder,
|
|
@@ -1111,33 +1052,33 @@ var se = class {
|
|
|
1111
1052
|
},
|
|
1112
1053
|
onBlur: () => {
|
|
1113
1054
|
this._phone = this._field?.getValue() ?? "";
|
|
1114
|
-
let e =
|
|
1055
|
+
let e = c(), t = this._field?.getCountry();
|
|
1115
1056
|
this._error = e.phoneNumber(this._phone, t) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._phone);
|
|
1116
1057
|
}
|
|
1117
1058
|
}), this.shadowRoot.appendChild(this._field.getElement());
|
|
1118
|
-
}).catch((
|
|
1119
|
-
!this.shadowRoot || this._renderGeneration !==
|
|
1059
|
+
}).catch((e) => {
|
|
1060
|
+
!this.shadowRoot || this._renderGeneration !== t || console.error("Error creating phone number field:", e);
|
|
1120
1061
|
});
|
|
1121
1062
|
}
|
|
1122
1063
|
getCss() {
|
|
1123
1064
|
return super.getCss() + [
|
|
1124
|
-
E,
|
|
1125
1065
|
D,
|
|
1126
|
-
|
|
1127
|
-
|
|
1066
|
+
O,
|
|
1067
|
+
E,
|
|
1068
|
+
de
|
|
1128
1069
|
].join("\n") + "\n :host { display: block; }\n .form-input,\n .country-select-wrapper {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: 0 !important;\n box-shadow: none !important;\n }\n .phone-number-field-container {\n min-height: calc(var(--odus-input-font-size, 16px) * 1.5 + 16px);\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n overflow: hidden;\n }\n .phone-number-field-container:focus-within {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n }\n .phone-number-field-container.error {\n box-shadow: 0 0 0 1px var(--odus-color-error, #dc2727) !important;\n }\n .form-input:focus {\n box-shadow: none !important;\n outline: none !important;\n }\n .form-input-error {\n box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
|
|
1129
1070
|
}
|
|
1130
1071
|
getValue() {
|
|
1131
1072
|
return this._phone;
|
|
1132
1073
|
}
|
|
1133
1074
|
getIsValid() {
|
|
1134
|
-
let e =
|
|
1075
|
+
let e = c(), t = this._field?.getCountry();
|
|
1135
1076
|
return !e.phoneNumber(this._phone, t);
|
|
1136
1077
|
}
|
|
1137
1078
|
getError() {
|
|
1138
1079
|
return this._error;
|
|
1139
1080
|
}
|
|
1140
|
-
},
|
|
1081
|
+
}, pe = "Payment failed", me = "We couldn't securely process your card details. Please check your card information and try again.", he = "No payment details were entered. Please add your card and try again.", ge = "This payment is no longer available. Please reload the page and try again.", _e = class {
|
|
1141
1082
|
_config;
|
|
1142
1083
|
_apiService;
|
|
1143
1084
|
_changeListeners = [];
|
|
@@ -1167,17 +1108,17 @@ var se = class {
|
|
|
1167
1108
|
environment: e.environment,
|
|
1168
1109
|
sessionId: this._sessionId,
|
|
1169
1110
|
integration: "elements"
|
|
1170
|
-
}),
|
|
1111
|
+
}), u(a.CHECKOUT_INITIALIZED, { environment: e.environment }), e.locale && s.setLocale(e.locale), this._apiService = new r(e.apiKey, e.environment);
|
|
1171
1112
|
let t = {};
|
|
1172
1113
|
Object.defineProperty(t, "email", {
|
|
1173
|
-
get: () => (this._email || (this._email = new
|
|
1114
|
+
get: () => (this._email || (this._email = new Y(), this._trackElement(this._email)), this._email),
|
|
1174
1115
|
enumerable: !0
|
|
1175
1116
|
}), Object.defineProperty(t, "phone", {
|
|
1176
1117
|
get: () => (this._phone || (this._phone = new $(), this._trackElement(this._phone)), this._phone),
|
|
1177
1118
|
enumerable: !0
|
|
1178
1119
|
});
|
|
1179
|
-
let
|
|
1180
|
-
Object.defineProperty(
|
|
1120
|
+
let n = {};
|
|
1121
|
+
Object.defineProperty(n, "applePay", {
|
|
1181
1122
|
get: () => (this._applePay || (this._applePay = new V(), this._trackElement(this._applePay), this._paymentState.paymentId && this._paymentState.checkoutKey && this._applePay.setPaymentContext({
|
|
1182
1123
|
paymentId: this._paymentState.paymentId,
|
|
1183
1124
|
checkoutKey: this._paymentState.checkoutKey,
|
|
@@ -1190,7 +1131,7 @@ var se = class {
|
|
|
1190
1131
|
})
|
|
1191
1132
|
})), this._applePay),
|
|
1192
1133
|
enumerable: !0
|
|
1193
|
-
}), Object.defineProperty(
|
|
1134
|
+
}), Object.defineProperty(n, "payPal", {
|
|
1194
1135
|
get: () => (this._paypal || (this._paypal = new Q(), this._trackElement(this._paypal), this._paymentState.paymentId && this._paymentState.checkoutKey && this._paypal.setPaymentContext({
|
|
1195
1136
|
paymentId: this._paymentState.paymentId,
|
|
1196
1137
|
checkoutKey: this._paymentState.checkoutKey,
|
|
@@ -1200,63 +1141,63 @@ var se = class {
|
|
|
1200
1141
|
})), this._paypal),
|
|
1201
1142
|
enumerable: !0
|
|
1202
1143
|
});
|
|
1203
|
-
let
|
|
1204
|
-
Object.defineProperty(
|
|
1144
|
+
let o = {};
|
|
1145
|
+
Object.defineProperty(o, "street", {
|
|
1205
1146
|
get: () => (this._addressStreet || (this._addressStreet = new L(), this._trackElement(this._addressStreet)), this._addressStreet),
|
|
1206
1147
|
enumerable: !0
|
|
1207
|
-
}), Object.defineProperty(
|
|
1148
|
+
}), Object.defineProperty(o, "firstName", {
|
|
1208
1149
|
get: () => (this._addressFirstName || (this._addressFirstName = new N(), this._trackElement(this._addressFirstName)), this._addressFirstName),
|
|
1209
1150
|
enumerable: !0
|
|
1210
|
-
}), Object.defineProperty(
|
|
1151
|
+
}), Object.defineProperty(o, "lastName", {
|
|
1211
1152
|
get: () => (this._addressLastName || (this._addressLastName = new P(), this._trackElement(this._addressLastName)), this._addressLastName),
|
|
1212
1153
|
enumerable: !0
|
|
1213
|
-
}), Object.defineProperty(
|
|
1154
|
+
}), Object.defineProperty(o, "city", {
|
|
1214
1155
|
get: () => (this._addressCity || (this._addressCity = new A(), this._trackElement(this._addressCity)), this._addressCity),
|
|
1215
1156
|
enumerable: !0
|
|
1216
|
-
}), Object.defineProperty(
|
|
1157
|
+
}), Object.defineProperty(o, "state", {
|
|
1217
1158
|
get: () => (this._addressState || (this._addressState = new I(), this._trackElement(this._addressState), this._addressCountry?.value && this._addressState.setCountry(this._addressCountry.value)), this._addressState),
|
|
1218
1159
|
enumerable: !0
|
|
1219
|
-
}), Object.defineProperty(
|
|
1160
|
+
}), Object.defineProperty(o, "zipCode", {
|
|
1220
1161
|
get: () => (this._addressZipCode || (this._addressZipCode = new R(), this._trackElement(this._addressZipCode)), this._addressZipCode),
|
|
1221
1162
|
enumerable: !0
|
|
1222
|
-
}), Object.defineProperty(
|
|
1163
|
+
}), Object.defineProperty(o, "country", {
|
|
1223
1164
|
get: () => (this._addressCountry || (this._addressCountry = new M(), this._trackElement(this._addressCountry), this._addressCountry.on("change", (e) => {
|
|
1224
1165
|
this._addressState?.setCountry(e);
|
|
1225
1166
|
})), this._addressCountry),
|
|
1226
1167
|
enumerable: !0
|
|
1227
1168
|
});
|
|
1228
|
-
let
|
|
1169
|
+
let c = {
|
|
1229
1170
|
contact: t,
|
|
1230
|
-
express:
|
|
1171
|
+
express: n
|
|
1231
1172
|
};
|
|
1232
|
-
Object.defineProperty(
|
|
1233
|
-
get: () => (this._card || (this._card = new
|
|
1173
|
+
Object.defineProperty(c, "card", {
|
|
1174
|
+
get: () => (this._card || (this._card = new q(), this._card.setEnvironment(this._config.environment), this._trackElement(this._card), this._paymentState.vgsJwt ? this._card.setVgsJwt(this._paymentState.vgsJwt) : this._paymentState.cardCapture === "unavailable" ? this._card.markCaptureUnavailable() : this._paymentState.cardCapture === "unsupported" && this._card.resetCardCapture()), this._card),
|
|
1234
1175
|
enumerable: !0
|
|
1235
|
-
}), Object.defineProperty(
|
|
1236
|
-
get: () => (this._cardholderName || (this._cardholderName = new
|
|
1176
|
+
}), Object.defineProperty(c, "cardholderName", {
|
|
1177
|
+
get: () => (this._cardholderName || (this._cardholderName = new J(), this._trackElement(this._cardholderName)), this._cardholderName),
|
|
1237
1178
|
enumerable: !0
|
|
1238
|
-
}), Object.defineProperty(
|
|
1239
|
-
get: () =>
|
|
1179
|
+
}), Object.defineProperty(c, "address", {
|
|
1180
|
+
get: () => o,
|
|
1240
1181
|
enumerable: !0
|
|
1241
|
-
}), Object.defineProperty(
|
|
1242
|
-
get: () => (this._error || (this._error = new
|
|
1182
|
+
}), Object.defineProperty(c, "error", {
|
|
1183
|
+
get: () => (this._error || (this._error = new X(), this._trackElement(this._error)), this._error),
|
|
1243
1184
|
enumerable: !0
|
|
1244
|
-
}), this.elements =
|
|
1185
|
+
}), this.elements = c;
|
|
1245
1186
|
}
|
|
1246
1187
|
async associatePayment(e, t) {
|
|
1247
1188
|
if (!e || !t) throw Error("paymentId and checkoutKey are required");
|
|
1248
1189
|
let n = ++this._associationSequence, r;
|
|
1249
1190
|
try {
|
|
1250
|
-
r = await
|
|
1191
|
+
r = await d({
|
|
1251
1192
|
id: e,
|
|
1252
1193
|
checkoutKey: t,
|
|
1253
1194
|
environment: this._config.environment
|
|
1254
1195
|
});
|
|
1255
1196
|
} catch (t) {
|
|
1256
|
-
throw n === this._associationSequence && (this._paymentState = {}),
|
|
1197
|
+
throw n === this._associationSequence && (this._paymentState = {}), u(a.PAYMENT_ASSOCIATION_FAILED, {
|
|
1257
1198
|
payment_id: e,
|
|
1258
1199
|
error_message: t instanceof Error ? t.message : "Unknown error"
|
|
1259
|
-
}),
|
|
1200
|
+
}), ee(t instanceof Error ? t : Error("Failed to associate payment"), { payment_id: e }), t;
|
|
1260
1201
|
}
|
|
1261
1202
|
n === this._associationSequence && (this._paymentState = {
|
|
1262
1203
|
paymentId: e,
|
|
@@ -1266,11 +1207,11 @@ var se = class {
|
|
|
1266
1207
|
currency: r.currency,
|
|
1267
1208
|
countryCode: r.countryCode
|
|
1268
1209
|
}
|
|
1269
|
-
},
|
|
1210
|
+
}, u(a.PAYMENT_ASSOCIATED, {
|
|
1270
1211
|
payment_id: e,
|
|
1271
1212
|
currency: r.currency,
|
|
1272
1213
|
country_code: r.countryCode
|
|
1273
|
-
}), r.vgsJwt
|
|
1214
|
+
}), this._card?.setEnvironment(this._config.environment), r.supportedPaymentMethods?.includes("card") ? r.vgsJwt ? (this._paymentState.vgsJwt = r.vgsJwt, this._paymentState.cardCapture = void 0, this._card?.setVgsJwt(r.vgsJwt)) : (this._paymentState.vgsJwt = void 0, this._paymentState.cardCapture = "unavailable", this._card?.markCaptureUnavailable()) : (this._paymentState.vgsJwt = void 0, this._paymentState.cardCapture = "unsupported", this._card?.resetCardCapture()), this._applePay?.setPaymentContext({
|
|
1274
1215
|
paymentId: e,
|
|
1275
1216
|
checkoutKey: t,
|
|
1276
1217
|
environment: this._config.environment,
|
|
@@ -1289,14 +1230,14 @@ var se = class {
|
|
|
1289
1230
|
}));
|
|
1290
1231
|
}
|
|
1291
1232
|
validate() {
|
|
1292
|
-
let e = {}, { t } =
|
|
1233
|
+
let e = {}, { t } = n();
|
|
1293
1234
|
return this._card?.isMounted && !this._card.isValid && (e.card = this._card.error ?? t("validation.cardNumberInvalid")), this._email?.isMounted && !this._email.isValid && (e.email = this._email.error ?? t("validation.emailInvalid")), this._phone?.isMounted && !this._phone.isValid && (e.phone = this._phone.error ?? t("validation.phoneNumberInvalid")), this._addressStreet?.isMounted && !this._addressStreet.isValid && (e["address.street"] = this._addressStreet.error ?? t("validation.addressLine1Required")), this._addressCity?.isMounted && !this._addressCity.isValid && (e["address.city"] = this._addressCity.error ?? t("validation.townCityRequired")), this._addressCountry?.isMounted && !this._addressCountry.isValid && (e["address.country"] = this._addressCountry.error ?? t("validation.countryRequired")), this._addressFirstName?.isMounted && !this._addressFirstName.isValid && (e["address.firstName"] = this._addressFirstName.error ?? t("validation.firstNameRequired")), this._addressLastName?.isMounted && !this._addressLastName.isValid && (e["address.lastName"] = this._addressLastName.error ?? t("validation.lastNameRequired")), this._cardholderName?.isMounted && !this._cardholderName.isValid && (e.cardholderName = this._cardholderName.error ?? t("validation.nameRequired")), this._addressState?.isMounted && !this._addressState.isValid && (e["address.state"] = this._addressState.error ?? t("validation.stateRequired")), this._addressZipCode?.isMounted && !this._addressZipCode.isValid && (e["address.zipCode"] = this._addressZipCode.error ?? t("validation.postalCodeRequired")), this._applePay?.isMounted && !this._applePay.isValid && (e.applePay = "Apple Pay authorization required"), this._paypal?.isMounted && !this._paypal.isValid && (e.paypal = "PayPal authorization required"), {
|
|
1294
1235
|
valid: Object.keys(e).length === 0,
|
|
1295
1236
|
errors: e
|
|
1296
1237
|
};
|
|
1297
1238
|
}
|
|
1298
1239
|
async _getPayload() {
|
|
1299
|
-
let e = this._email?.isMounted ? this._email.value : "", t = this._phone?.isMounted ? this._phone.value : void 0,
|
|
1240
|
+
let e = this._email?.isMounted ? this._email.value : "", t = this._phone?.isMounted ? this._phone.value : void 0, r = this._addressStreet?.isMounted || this._addressCity?.isMounted || this._addressCountry?.isMounted || this._addressFirstName?.isMounted || this._addressLastName?.isMounted || this._cardholderName?.isMounted || this._addressState?.isMounted || this._addressZipCode?.isMounted ? {
|
|
1300
1241
|
street: this._addressStreet?.isMounted ? this._addressStreet.value : "",
|
|
1301
1242
|
city: this._addressCity?.isMounted ? this._addressCity.value : "",
|
|
1302
1243
|
country: this._addressCountry?.isMounted ? this._addressCountry.value : "",
|
|
@@ -1304,52 +1245,45 @@ var se = class {
|
|
|
1304
1245
|
lastName: this._addressLastName?.isMounted ? this._addressLastName.value : "",
|
|
1305
1246
|
state: this._addressState?.isMounted ? this._addressState.value : "",
|
|
1306
1247
|
zipCode: this._addressZipCode?.isMounted ? this._addressZipCode.value : ""
|
|
1307
|
-
} : void 0,
|
|
1308
|
-
if (this._card?.isMounted
|
|
1309
|
-
|
|
1248
|
+
} : void 0, i = this._cardholderName?.isMounted ? this._cardholderName.value : "", o = [r?.firstName ?? "", r?.lastName ?? ""].filter(Boolean), s = i || o.join(" ");
|
|
1249
|
+
if (!this._card?.isMounted || this._card.captureState === "unsupported") return {
|
|
1250
|
+
ok: !1,
|
|
1251
|
+
error: {
|
|
1252
|
+
message: he,
|
|
1253
|
+
status: 0,
|
|
1254
|
+
statusText: "No Payment Method"
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
if (!this._card.isVgsMode) return u(a.CARD_CAPTURE_UNAVAILABLE, { reason: x.NO_TOKENIZATION_SESSION }), {
|
|
1258
|
+
ok: !1,
|
|
1259
|
+
error: {
|
|
1260
|
+
message: n().t("cardUnavailable"),
|
|
1261
|
+
status: 0,
|
|
1262
|
+
statusText: "Card Capture Unavailable"
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
try {
|
|
1266
|
+
let n = await this._card.getPayload();
|
|
1310
1267
|
return {
|
|
1311
1268
|
ok: !0,
|
|
1312
1269
|
formData: {
|
|
1313
|
-
name:
|
|
1270
|
+
name: s,
|
|
1314
1271
|
email: e,
|
|
1315
1272
|
phoneNumber: t || void 0,
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
cardCvv: "",
|
|
1319
|
-
billingAddress: n,
|
|
1320
|
-
vgsCardData: r
|
|
1273
|
+
billingAddress: r,
|
|
1274
|
+
vgsCardData: n
|
|
1321
1275
|
}
|
|
1322
1276
|
};
|
|
1323
1277
|
} catch {
|
|
1324
1278
|
return {
|
|
1325
1279
|
ok: !1,
|
|
1326
1280
|
error: {
|
|
1327
|
-
message:
|
|
1281
|
+
message: me,
|
|
1328
1282
|
status: 0,
|
|
1329
1283
|
statusText: "Card Tokenization Failed"
|
|
1330
1284
|
}
|
|
1331
1285
|
};
|
|
1332
1286
|
}
|
|
1333
|
-
let o = this._card?.isMounted ? this._card.value : null;
|
|
1334
|
-
return o ? {
|
|
1335
|
-
ok: !0,
|
|
1336
|
-
formData: {
|
|
1337
|
-
name: a,
|
|
1338
|
-
email: e,
|
|
1339
|
-
phoneNumber: t || void 0,
|
|
1340
|
-
cardNumber: o.number,
|
|
1341
|
-
cardExpiry: o.expiry,
|
|
1342
|
-
cardCvv: o.cvv,
|
|
1343
|
-
billingAddress: n
|
|
1344
|
-
}
|
|
1345
|
-
} : {
|
|
1346
|
-
ok: !1,
|
|
1347
|
-
error: {
|
|
1348
|
-
message: ge,
|
|
1349
|
-
status: 0,
|
|
1350
|
-
statusText: "No Payment Method"
|
|
1351
|
-
}
|
|
1352
|
-
};
|
|
1353
1287
|
}
|
|
1354
1288
|
async authorize(e) {
|
|
1355
1289
|
if (!this._paymentState.paymentId || !this._paymentState.checkoutKey) throw Error("Call associatePayment() before authorize()");
|
|
@@ -1375,7 +1309,7 @@ var se = class {
|
|
|
1375
1309
|
let t = e["--odus-font-family"];
|
|
1376
1310
|
if (t) {
|
|
1377
1311
|
this._fontCleanup?.();
|
|
1378
|
-
let { cleanup: e } =
|
|
1312
|
+
let { cleanup: e } = w({ fontFamily: t });
|
|
1379
1313
|
this._fontCleanup = e;
|
|
1380
1314
|
}
|
|
1381
1315
|
for (let t of this._allElements()) t.setTheme(e);
|
|
@@ -1398,7 +1332,7 @@ var se = class {
|
|
|
1398
1332
|
}
|
|
1399
1333
|
_trackElement(e) {
|
|
1400
1334
|
e.on("ready", () => {
|
|
1401
|
-
this._mountedReported || (this._mountedReported = !0,
|
|
1335
|
+
this._mountedReported || (this._mountedReported = !0, u(a.CHECKOUT_MOUNTED, { container_id: "elements" }));
|
|
1402
1336
|
}), e.on("change", () => {
|
|
1403
1337
|
for (let e of this._changeListeners) e();
|
|
1404
1338
|
});
|
|
@@ -1422,19 +1356,19 @@ var se = class {
|
|
|
1422
1356
|
].filter((e) => e !== void 0);
|
|
1423
1357
|
}
|
|
1424
1358
|
async _executeAuthorization({ formData: e, applePayData: t, customCustomerData: n }) {
|
|
1425
|
-
let { paymentId: r, checkoutKey: i } = this._paymentState,
|
|
1359
|
+
let { paymentId: r, checkoutKey: i } = this._paymentState, s = this._getPaymentMethod(e, t);
|
|
1426
1360
|
if (!r || !i) return this._reportSubmitFailure({
|
|
1427
|
-
message:
|
|
1361
|
+
message: ge,
|
|
1428
1362
|
status: 0,
|
|
1429
1363
|
statusText: "No Associated Payment"
|
|
1430
|
-
},
|
|
1431
|
-
this._emitLoadingState(!0),
|
|
1364
|
+
}, s), !1;
|
|
1365
|
+
this._emitLoadingState(!0), u(a.PAYMENT_SUBMIT_STARTED, {
|
|
1432
1366
|
payment_id: r,
|
|
1433
|
-
payment_method:
|
|
1367
|
+
payment_method: s
|
|
1434
1368
|
});
|
|
1435
|
-
let
|
|
1369
|
+
let c = performance.now();
|
|
1436
1370
|
try {
|
|
1437
|
-
let
|
|
1371
|
+
let l = await this._apiService.authorizePayment({
|
|
1438
1372
|
paymentId: r,
|
|
1439
1373
|
checkoutKey: i,
|
|
1440
1374
|
formData: e,
|
|
@@ -1442,22 +1376,22 @@ var se = class {
|
|
|
1442
1376
|
applePayData: t,
|
|
1443
1377
|
customCustomerData: n
|
|
1444
1378
|
});
|
|
1445
|
-
return
|
|
1379
|
+
return o(f.PAYMENT_AUTHORIZATION_TIME, performance.now() - c, "ms", {
|
|
1446
1380
|
payment_id: r,
|
|
1447
|
-
payment_method:
|
|
1381
|
+
payment_method: s,
|
|
1448
1382
|
status: "success"
|
|
1449
|
-
}),
|
|
1383
|
+
}), u(a.PAYMENT_SUBMIT_SUCCESS, {
|
|
1450
1384
|
payment_id: r,
|
|
1451
|
-
payment_method:
|
|
1452
|
-
}), this._handlePaymentResponse(
|
|
1385
|
+
payment_method: s
|
|
1386
|
+
}), this._handlePaymentResponse(l);
|
|
1453
1387
|
} catch (e) {
|
|
1454
|
-
return
|
|
1388
|
+
return o(f.PAYMENT_AUTHORIZATION_TIME, performance.now() - c, "ms", {
|
|
1455
1389
|
payment_id: r,
|
|
1456
|
-
payment_method:
|
|
1390
|
+
payment_method: s,
|
|
1457
1391
|
status: "failed"
|
|
1458
|
-
}),
|
|
1392
|
+
}), u(a.PAYMENT_SUBMIT_FAILED, {
|
|
1459
1393
|
payment_id: r,
|
|
1460
|
-
payment_method:
|
|
1394
|
+
payment_method: s,
|
|
1461
1395
|
error_message: this._readErrorMessage(e, "Unknown error")
|
|
1462
1396
|
}), this._handleAuthorizationError(e), !1;
|
|
1463
1397
|
} finally {
|
|
@@ -1474,13 +1408,13 @@ var se = class {
|
|
|
1474
1408
|
}
|
|
1475
1409
|
_handlePaymentResponse(e) {
|
|
1476
1410
|
let t = this._paymentState.paymentId ?? "";
|
|
1477
|
-
return e.latestTransaction.status === "authorized" ? (
|
|
1411
|
+
return e.latestTransaction.status === "authorized" ? (u(a.PAYMENT_AUTHORIZED, {
|
|
1478
1412
|
payment_id: t,
|
|
1479
1413
|
status: e.latestTransaction.status
|
|
1480
|
-
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), !0) : e.latestTransaction.status === "failed" ? (
|
|
1414
|
+
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), !0) : e.latestTransaction.status === "failed" ? (u(a.PAYMENT_FAILED, {
|
|
1481
1415
|
payment_id: t,
|
|
1482
1416
|
status: e.latestTransaction.status
|
|
1483
|
-
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status), !1) : e.status === "requires_action" && (
|
|
1417
|
+
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status), !1) : e.status === "requires_action" && (u(a.PAYMENT_ACTION_REQUIRED, {
|
|
1484
1418
|
payment_id: t,
|
|
1485
1419
|
status: e.status
|
|
1486
1420
|
}), this._callbacks.onActionRequired?.(e.action.redirectUrl), !0);
|
|
@@ -1490,13 +1424,13 @@ var se = class {
|
|
|
1490
1424
|
payment_id: this._paymentState.paymentId ?? "",
|
|
1491
1425
|
payment_method: t
|
|
1492
1426
|
};
|
|
1493
|
-
|
|
1427
|
+
u(a.PAYMENT_SUBMIT_STARTED, n), u(a.PAYMENT_SUBMIT_FAILED, {
|
|
1494
1428
|
...n,
|
|
1495
1429
|
error_message: this._readErrorMessage(e, "Unknown error")
|
|
1496
1430
|
}), this._handleAuthorizationError(e);
|
|
1497
1431
|
}
|
|
1498
1432
|
_handleAuthorizationError(e) {
|
|
1499
|
-
let t = this._readErrorMessage(e,
|
|
1433
|
+
let t = this._readErrorMessage(e, pe);
|
|
1500
1434
|
this._callbacks.onPaymentFailed?.(t), this._error?.isMounted && this._error.setError(t);
|
|
1501
1435
|
}
|
|
1502
1436
|
_readErrorMessage(e, t) {
|
|
@@ -1505,4 +1439,4 @@ var se = class {
|
|
|
1505
1439
|
}
|
|
1506
1440
|
};
|
|
1507
1441
|
//#endregion
|
|
1508
|
-
export { A as AddressCityElement, M as AddressCountryElement, N as AddressFirstNameElement, P as AddressLastNameElement, I as AddressStateElement, L as AddressStreetElement, R as AddressZipCodeElement, V as ApplePayElement, k as BaseElement,
|
|
1442
|
+
export { A as AddressCityElement, M as AddressCountryElement, N as AddressFirstNameElement, P as AddressLastNameElement, I as AddressStateElement, L as AddressStreetElement, R as AddressZipCodeElement, V as ApplePayElement, k as BaseElement, q as CardElement, J as CardholderElement, Y as EmailElement, X as ErrorElement, _e as OdusElements, Q as PayPalElement, $ as PhoneElement };
|