@odus/checkout 0.5.6 → 0.5.7
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 +68 -88
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -469,24 +469,24 @@ const z = {
|
|
|
469
469
|
const E = {
|
|
470
470
|
...d.formData,
|
|
471
471
|
[l]: u
|
|
472
|
-
},
|
|
472
|
+
}, g = { ...d.errors };
|
|
473
473
|
if (d.touched[l]) {
|
|
474
474
|
const m = t(l, u);
|
|
475
|
-
m ?
|
|
475
|
+
m ? g[l] = m : delete g[l];
|
|
476
476
|
}
|
|
477
477
|
e.setState({
|
|
478
478
|
formData: E,
|
|
479
|
-
errors:
|
|
479
|
+
errors: g,
|
|
480
480
|
isValid: i(E)
|
|
481
481
|
});
|
|
482
482
|
}, n = (l, c) => {
|
|
483
483
|
const d = e.getState(), u = {
|
|
484
484
|
...d.touched,
|
|
485
485
|
[l]: !0
|
|
486
|
-
}, E = t(l, c),
|
|
487
|
-
E ?
|
|
486
|
+
}, E = t(l, c), g = { ...d.errors };
|
|
487
|
+
E ? g[l] = E : delete g[l], e.setState({
|
|
488
488
|
touched: u,
|
|
489
|
-
errors:
|
|
489
|
+
errors: g
|
|
490
490
|
});
|
|
491
491
|
}, o = (l) => {
|
|
492
492
|
const d = {
|
|
@@ -566,11 +566,11 @@ function Q({
|
|
|
566
566
|
const m = r.getState();
|
|
567
567
|
if (!m.iframeConfig || !e)
|
|
568
568
|
return;
|
|
569
|
-
const
|
|
570
|
-
if (!
|
|
569
|
+
const y = document.getElementById("card-element"), f = document.getElementById("card-cvv-element");
|
|
570
|
+
if (!y || !f)
|
|
571
571
|
throw new Error("Card elements not found in DOM");
|
|
572
572
|
console.log("✅ TokenEx iframe initializing successfully:", {
|
|
573
|
-
cardElementId:
|
|
573
|
+
cardElementId: y.id,
|
|
574
574
|
cvvElementId: f.id,
|
|
575
575
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
576
576
|
}), n = new globalThis.TokenEx.Iframe("card-element", {
|
|
@@ -627,12 +627,12 @@ function Q({
|
|
|
627
627
|
), n.load();
|
|
628
628
|
}, c = () => {
|
|
629
629
|
let m = 0;
|
|
630
|
-
const
|
|
630
|
+
const y = X;
|
|
631
631
|
console.warn(
|
|
632
632
|
"Card elements not found in DOM, retrying iframe initialization..."
|
|
633
633
|
);
|
|
634
634
|
const f = () => {
|
|
635
|
-
if (m++, m >
|
|
635
|
+
if (m++, m > y) {
|
|
636
636
|
console.error("Failed to find card elements after maximum retries");
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
@@ -648,7 +648,7 @@ function Q({
|
|
|
648
648
|
} catch (v) {
|
|
649
649
|
console.error("Failed to create TokenEx iframe:", v);
|
|
650
650
|
}
|
|
651
|
-
else m <
|
|
651
|
+
else m < y && f();
|
|
652
652
|
}, p);
|
|
653
653
|
};
|
|
654
654
|
f();
|
|
@@ -659,12 +659,8 @@ function Q({
|
|
|
659
659
|
console.error("TokenEx script not loaded correctly");
|
|
660
660
|
return;
|
|
661
661
|
}
|
|
662
|
-
const
|
|
663
|
-
if (
|
|
664
|
-
cardElementExists: !!g,
|
|
665
|
-
cvvElementExists: !!f,
|
|
666
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
667
|
-
}), !g || !f) {
|
|
662
|
+
const y = document.getElementById("card-element"), f = document.getElementById("card-cvv-element");
|
|
663
|
+
if (!y || !f) {
|
|
668
664
|
c();
|
|
669
665
|
return;
|
|
670
666
|
}
|
|
@@ -677,15 +673,15 @@ function Q({
|
|
|
677
673
|
s && await o();
|
|
678
674
|
}, E = () => {
|
|
679
675
|
n && (n.remove(), n = null);
|
|
680
|
-
},
|
|
681
|
-
n && (n.on("tokenize", async function(
|
|
682
|
-
await m(
|
|
676
|
+
}, g = async (m) => {
|
|
677
|
+
n && (n.on("tokenize", async function(y) {
|
|
678
|
+
await m(y);
|
|
683
679
|
}), n.tokenize());
|
|
684
680
|
};
|
|
685
681
|
return {
|
|
686
682
|
getState: r.getState.bind(r),
|
|
687
683
|
subscribe: r.subscribe.bind(r),
|
|
688
|
-
tokenize:
|
|
684
|
+
tokenize: g,
|
|
689
685
|
cleanup: E,
|
|
690
686
|
initialize: u
|
|
691
687
|
};
|
|
@@ -1411,9 +1407,9 @@ class Pt extends h {
|
|
|
1411
1407
|
cardExpiryError: d,
|
|
1412
1408
|
cardExpiryTouched: u,
|
|
1413
1409
|
onChange: E,
|
|
1414
|
-
onBlur:
|
|
1410
|
+
onBlur: g,
|
|
1415
1411
|
translationFunc: m,
|
|
1416
|
-
cardExpiryAutocomplete:
|
|
1412
|
+
cardExpiryAutocomplete: y = "cc-exp"
|
|
1417
1413
|
} = e, f = document.createElement("div");
|
|
1418
1414
|
f.className = "card-grid", this.cardNumber = new At({
|
|
1419
1415
|
styles: {
|
|
@@ -1433,7 +1429,7 @@ class Pt extends h {
|
|
|
1433
1429
|
error: !!(d && u),
|
|
1434
1430
|
errorMsg: d,
|
|
1435
1431
|
value: c,
|
|
1436
|
-
autocomplete:
|
|
1432
|
+
autocomplete: y,
|
|
1437
1433
|
onChange: (v) => {
|
|
1438
1434
|
this.trimCardExpiry(), E(v);
|
|
1439
1435
|
},
|
|
@@ -1443,7 +1439,7 @@ class Pt extends h {
|
|
|
1443
1439
|
fontSize: t.styles.fontSize,
|
|
1444
1440
|
fontFamily: t.styles.fontFamily
|
|
1445
1441
|
}
|
|
1446
|
-
}), this.cardExpiry.addEventListener("blur",
|
|
1442
|
+
}), this.cardExpiry.addEventListener("blur", g), this.cardExpiry.addEventListener("keydown", (v) => {
|
|
1447
1443
|
const M = v;
|
|
1448
1444
|
![
|
|
1449
1445
|
"Backspace",
|
|
@@ -1611,18 +1607,17 @@ class Vt extends h {
|
|
|
1611
1607
|
paymentMethods;
|
|
1612
1608
|
constructor(e) {
|
|
1613
1609
|
const { checkoutProfile: t, formData: a, onPaypalSubmit: i } = e;
|
|
1614
|
-
if (!t?.additionalPaymentMethods) {
|
|
1615
|
-
|
|
1610
|
+
if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
|
|
1611
|
+
this.getElement().style.display = "none";
|
|
1616
1612
|
return;
|
|
1617
1613
|
}
|
|
1618
1614
|
const r = Object.entries(
|
|
1619
1615
|
t.additionalPaymentMethods
|
|
1620
1616
|
).filter(([, n]) => n.enabled).sort((n, o) => n[1].order - o[1].order);
|
|
1621
1617
|
if (r.length === 0) {
|
|
1622
|
-
|
|
1618
|
+
this.getElement().style.display = "none";
|
|
1623
1619
|
return;
|
|
1624
1620
|
}
|
|
1625
|
-
super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map();
|
|
1626
1621
|
for (const [n] of r)
|
|
1627
1622
|
switch (n) {
|
|
1628
1623
|
case "paypal": {
|
|
@@ -1774,51 +1769,48 @@ class Ut extends h {
|
|
|
1774
1769
|
console.error("Cannot initialize iframe: No checkout profile available");
|
|
1775
1770
|
return;
|
|
1776
1771
|
}
|
|
1777
|
-
if (this.iframeHook)
|
|
1778
|
-
console.log("TokenEx iframe already initialized, skipping");
|
|
1779
|
-
return;
|
|
1780
|
-
}
|
|
1781
|
-
try {
|
|
1782
|
-
if (!("TokenEx" in globalThis))
|
|
1783
|
-
return console.log("TokenEx not available yet, retrying..."), new Promise((n) => {
|
|
1784
|
-
setTimeout(() => {
|
|
1785
|
-
this.initializeTokenExIframe().then(n);
|
|
1786
|
-
}, 500);
|
|
1787
|
-
});
|
|
1788
|
-
const { inputStyles: t, formContainerStyle: a } = Ft(
|
|
1789
|
-
e.checkoutProfile
|
|
1790
|
-
);
|
|
1791
|
-
this.applyFormContainerStyles(a);
|
|
1772
|
+
if (!this.iframeHook)
|
|
1792
1773
|
try {
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
const i = document.getElementById("card-element"), r = document.getElementById("card-cvv-element");
|
|
1802
|
-
if (!i || !r) {
|
|
1803
|
-
console.error(
|
|
1804
|
-
"Card elements not found, cannot initialize TokenEx iframe"
|
|
1774
|
+
if (!("TokenEx" in globalThis))
|
|
1775
|
+
return new Promise((n) => {
|
|
1776
|
+
setTimeout(() => {
|
|
1777
|
+
this.initializeTokenExIframe().then(n);
|
|
1778
|
+
}, 500);
|
|
1779
|
+
});
|
|
1780
|
+
const { inputStyles: t, formContainerStyle: a } = Ft(
|
|
1781
|
+
e.checkoutProfile
|
|
1805
1782
|
);
|
|
1806
|
-
|
|
1783
|
+
this.applyFormContainerStyles(a);
|
|
1784
|
+
try {
|
|
1785
|
+
this.cardSection || (this.createCardSection(e.checkoutProfile), console.log("✅ Card element check before iframe initialization:", {
|
|
1786
|
+
cardElementExists: !!document.getElementById("card-element"),
|
|
1787
|
+
cvvElementExists: !!document.getElementById("card-cvv-element"),
|
|
1788
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1789
|
+
}));
|
|
1790
|
+
} catch (n) {
|
|
1791
|
+
console.error("Failed to create card section:", n);
|
|
1792
|
+
}
|
|
1793
|
+
const i = document.getElementById("card-element"), r = document.getElementById("card-cvv-element");
|
|
1794
|
+
if (!i || !r) {
|
|
1795
|
+
console.error(
|
|
1796
|
+
"Card elements not found, cannot initialize TokenEx iframe"
|
|
1797
|
+
);
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
this.iframeHook = Q({
|
|
1801
|
+
apiKey: this.options.apiKey,
|
|
1802
|
+
checkoutProfile: e.checkoutProfile,
|
|
1803
|
+
inputStyles: t,
|
|
1804
|
+
setFormData: (n) => {
|
|
1805
|
+
this.formManager.setFormData(n);
|
|
1806
|
+
},
|
|
1807
|
+
environment: this.options.environment
|
|
1808
|
+
}), this.iframeHook?.subscribe(this.handleIframeStateChange), await this.iframeHook?.initialize(), console.log("✅ TokenEx iframe initialized successfully:", {
|
|
1809
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1810
|
+
});
|
|
1811
|
+
} catch (t) {
|
|
1812
|
+
throw console.error("Failed to initialize payment form:", t), t;
|
|
1807
1813
|
}
|
|
1808
|
-
this.iframeHook = Q({
|
|
1809
|
-
apiKey: this.options.apiKey,
|
|
1810
|
-
checkoutProfile: e.checkoutProfile,
|
|
1811
|
-
inputStyles: t,
|
|
1812
|
-
setFormData: (n) => {
|
|
1813
|
-
this.formManager.setFormData(n);
|
|
1814
|
-
},
|
|
1815
|
-
environment: this.options.environment
|
|
1816
|
-
}), this.iframeHook?.subscribe(this.handleIframeStateChange), await this.iframeHook?.initialize(), console.log("✅ TokenEx iframe initialized successfully:", {
|
|
1817
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1818
|
-
});
|
|
1819
|
-
} catch (t) {
|
|
1820
|
-
throw console.error("Failed to initialize payment form:", t), t;
|
|
1821
|
-
}
|
|
1822
1814
|
};
|
|
1823
1815
|
handleIframeStateChange = (e) => {
|
|
1824
1816
|
this.cardSection && (this.cardSection.updateCardNumberValidation(
|
|
@@ -1892,9 +1884,6 @@ class Ut extends h {
|
|
|
1892
1884
|
renderFormComponents() {
|
|
1893
1885
|
if (this.emailField)
|
|
1894
1886
|
return;
|
|
1895
|
-
console.log("🏗️ Starting form components rendering:", {
|
|
1896
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1897
|
-
});
|
|
1898
1887
|
const e = this.checkoutProfile.getState();
|
|
1899
1888
|
if (!e.checkoutProfile) {
|
|
1900
1889
|
this.setErrorMessage("Failed to load checkout configuration");
|
|
@@ -1920,15 +1909,6 @@ class Ut extends h {
|
|
|
1920
1909
|
} catch (t) {
|
|
1921
1910
|
console.error("Failed to create submit button:", t);
|
|
1922
1911
|
}
|
|
1923
|
-
console.log("✅ Form components rendered successfully:", {
|
|
1924
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1925
|
-
components: {
|
|
1926
|
-
paymentMethods: !!this.paymentMethods,
|
|
1927
|
-
emailField: !!this.emailField,
|
|
1928
|
-
cardholderSection: !!this.cardholderSection,
|
|
1929
|
-
submitButton: !!this.submitButton
|
|
1930
|
-
}
|
|
1931
|
-
});
|
|
1932
1912
|
}
|
|
1933
1913
|
createPaymentMethods(e) {
|
|
1934
1914
|
try {
|
|
@@ -1951,7 +1931,7 @@ class Ut extends h {
|
|
|
1951
1931
|
onPaypalSubmit: async () => {
|
|
1952
1932
|
await this.handlePaypalSubmit();
|
|
1953
1933
|
}
|
|
1954
|
-
}), this.element.appendChild(this.paymentMethods.getElement())
|
|
1934
|
+
}), this.element.appendChild(this.paymentMethods.getElement());
|
|
1955
1935
|
} catch (t) {
|
|
1956
1936
|
throw console.error("Error creating payment methods:", t), t;
|
|
1957
1937
|
}
|
|
@@ -1967,7 +1947,7 @@ class Ut extends h {
|
|
|
1967
1947
|
errorMsg: a.email,
|
|
1968
1948
|
checkoutProfile: e,
|
|
1969
1949
|
translationFunc: this.translation.t
|
|
1970
|
-
}), this.element.appendChild(this.emailField.getElement())
|
|
1950
|
+
}), this.element.appendChild(this.emailField.getElement());
|
|
1971
1951
|
} catch (t) {
|
|
1972
1952
|
throw console.error("Error creating email field:", t), t;
|
|
1973
1953
|
}
|
|
@@ -1983,7 +1963,7 @@ class Ut extends h {
|
|
|
1983
1963
|
errorMsg: a.name,
|
|
1984
1964
|
checkoutProfile: e,
|
|
1985
1965
|
translationFunc: this.translation.t
|
|
1986
|
-
}), this.element.appendChild(this.cardholderSection.getElement())
|
|
1966
|
+
}), this.element.appendChild(this.cardholderSection.getElement());
|
|
1987
1967
|
} catch (t) {
|
|
1988
1968
|
throw console.error("Error creating cardholder section:", t), t;
|
|
1989
1969
|
}
|
|
@@ -1994,7 +1974,7 @@ class Ut extends h {
|
|
|
1994
1974
|
disabled: this.isFormDisabled(),
|
|
1995
1975
|
checkoutProfile: e,
|
|
1996
1976
|
translationFunc: this.translation.t
|
|
1997
|
-
}), this.element.appendChild(this.submitButton.getElement())
|
|
1977
|
+
}), this.element.appendChild(this.submitButton.getElement());
|
|
1998
1978
|
} catch (t) {
|
|
1999
1979
|
throw console.error("Error creating submit button:", t), t;
|
|
2000
1980
|
}
|
package/dist/package.json
CHANGED