@flopay/react 0.4.11 → 0.5.0
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/index.cjs +283 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -7
- package/dist/index.d.ts +17 -7
- package/dist/index.mjs +292 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1056,12 +1056,15 @@ function SplitCardFormInner({
|
|
|
1056
1056
|
showSecurityFooter = true,
|
|
1057
1057
|
onButtonClick,
|
|
1058
1058
|
onBeforeButtonClick,
|
|
1059
|
-
enableAVS
|
|
1059
|
+
enableAVS: enableAVSProp,
|
|
1060
1060
|
avsLayout: avsLayoutProp = "row",
|
|
1061
1061
|
country: countryProp,
|
|
1062
1062
|
zip: zipProp,
|
|
1063
1063
|
onCountryChange,
|
|
1064
1064
|
onZipChange,
|
|
1065
|
+
avsCheck: avsCheckProp,
|
|
1066
|
+
checkoutType: checkoutTypeProp,
|
|
1067
|
+
checkoutLayout: checkoutLayoutProp,
|
|
1065
1068
|
totalAmount = 0,
|
|
1066
1069
|
currency = "usd",
|
|
1067
1070
|
initialCardOpen = false,
|
|
@@ -1077,9 +1080,19 @@ function SplitCardFormInner({
|
|
|
1077
1080
|
const [is3DSActive, setIs3DSActive] = (0, import_react7.useState)(false);
|
|
1078
1081
|
const [selectedCountry, setSelectedCountry] = (0, import_react7.useState)(countryProp ?? "US");
|
|
1079
1082
|
const [zipCode, setZipCode] = (0, import_react7.useState)(zipProp ?? "");
|
|
1083
|
+
const [addressLine1, setAddressLine1] = (0, import_react7.useState)("");
|
|
1084
|
+
const [addressLine2, setAddressLine2] = (0, import_react7.useState)("");
|
|
1085
|
+
const [city, setCity] = (0, import_react7.useState)("");
|
|
1086
|
+
const [stateValue, setStateValue] = (0, import_react7.useState)("");
|
|
1080
1087
|
const [accountPatch, setAccountPatch] = (0, import_react7.useState)({});
|
|
1081
1088
|
const zipCodeRef = (0, import_react7.useRef)(zipProp ?? "");
|
|
1082
1089
|
const selectedCountryRef = (0, import_react7.useRef)(countryProp ?? "US");
|
|
1090
|
+
const addressLine1Ref = (0, import_react7.useRef)("");
|
|
1091
|
+
const addressLine2Ref = (0, import_react7.useRef)("");
|
|
1092
|
+
const cityRef = (0, import_react7.useRef)("");
|
|
1093
|
+
const stateRef = (0, import_react7.useRef)("");
|
|
1094
|
+
const avsConfig = (0, import_react7.useMemo)(() => (0, import_shared4.resolveAVSConfig)(enableAVSProp), [enableAVSProp]);
|
|
1095
|
+
const enableAVS = avsConfig !== null;
|
|
1083
1096
|
const [viewState, setViewState] = (0, import_react7.useState)(initialCardOpen ? "card" : "buttons");
|
|
1084
1097
|
const showCardForm = viewState === "expanding" || viewState === "card";
|
|
1085
1098
|
const TRANSITION_MS = 280;
|
|
@@ -1251,9 +1264,33 @@ function SplitCardFormInner({
|
|
|
1251
1264
|
email: effectiveAccount.email ?? "",
|
|
1252
1265
|
firstName: effectiveAccount.firstName ?? fullName.trim().split(/\s+/)[0] ?? "",
|
|
1253
1266
|
lastName: effectiveAccount.lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? "",
|
|
1254
|
-
...
|
|
1267
|
+
...avsConfig ? (() => {
|
|
1268
|
+
const c = selectedCountryRef.current;
|
|
1269
|
+
return {
|
|
1270
|
+
country: c,
|
|
1271
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, c) && zipCodeRef.current ? { zip: zipCodeRef.current } : {},
|
|
1272
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, c) && cityRef.current ? { city: cityRef.current } : {},
|
|
1273
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.state, c) && stateRef.current ? { state: stateRef.current } : {},
|
|
1274
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, c) && addressLine1Ref.current ? { addressLine1: addressLine1Ref.current } : {},
|
|
1275
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, c) && addressLine2Ref.current ? { addressLine2: addressLine2Ref.current } : {}
|
|
1276
|
+
};
|
|
1277
|
+
})() : {}
|
|
1255
1278
|
},
|
|
1256
|
-
chv
|
|
1279
|
+
chv,
|
|
1280
|
+
// Checkout analytics metadata
|
|
1281
|
+
avsCheck: avsCheckProp ?? false,
|
|
1282
|
+
checkoutType: checkoutTypeProp,
|
|
1283
|
+
checkoutLayout: checkoutLayoutProp,
|
|
1284
|
+
// Resolved exposure: which fields were actually shown for the active country.
|
|
1285
|
+
// Country-scoped rules (e.g. ['US', 'CA']) are flattened to booleans here.
|
|
1286
|
+
avsConfig: avsConfig ? {
|
|
1287
|
+
country: (0, import_shared4.isAVSFieldVisible)(avsConfig.country, selectedCountryRef.current),
|
|
1288
|
+
postal_code: (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, selectedCountryRef.current),
|
|
1289
|
+
address_line_1: (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, selectedCountryRef.current),
|
|
1290
|
+
address_line_2: (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, selectedCountryRef.current),
|
|
1291
|
+
city: (0, import_shared4.isAVSFieldVisible)(avsConfig.city, selectedCountryRef.current),
|
|
1292
|
+
state: (0, import_shared4.isAVSFieldVisible)(avsConfig.state, selectedCountryRef.current)
|
|
1293
|
+
} : void 0
|
|
1257
1294
|
})
|
|
1258
1295
|
});
|
|
1259
1296
|
if (response.ok) {
|
|
@@ -1277,14 +1314,19 @@ function SplitCardFormInner({
|
|
|
1277
1314
|
}
|
|
1278
1315
|
setIs3DSActive(true);
|
|
1279
1316
|
try {
|
|
1280
|
-
const retryBillingAddress = {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1317
|
+
const retryBillingAddress = {};
|
|
1318
|
+
const retryCC = selectedCountryRef.current;
|
|
1319
|
+
const retryCountry = enableAVS ? retryCC : effectiveAccount.country;
|
|
1320
|
+
if (retryCountry) retryBillingAddress["country"] = retryCountry;
|
|
1321
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, retryCC) && zipCodeRef.current.trim()) {
|
|
1322
|
+
retryBillingAddress["postal_code"] = zipCodeRef.current.trim();
|
|
1323
|
+
} else if (!avsConfig && effectiveAccount.zip) {
|
|
1324
|
+
retryBillingAddress["postal_code"] = effectiveAccount.zip;
|
|
1325
|
+
}
|
|
1326
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, retryCC) && addressLine1Ref.current.trim()) retryBillingAddress["line1"] = addressLine1Ref.current.trim();
|
|
1327
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, retryCC) && addressLine2Ref.current.trim()) retryBillingAddress["line2"] = addressLine2Ref.current.trim();
|
|
1328
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.city, retryCC) && cityRef.current.trim()) retryBillingAddress["city"] = cityRef.current.trim();
|
|
1329
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.state, retryCC) && stateRef.current.trim()) retryBillingAddress["state"] = stateRef.current.trim();
|
|
1288
1330
|
const result = await flopay.confirmPayment({
|
|
1289
1331
|
clientSecret: secret,
|
|
1290
1332
|
returnUrl: window.location.href,
|
|
@@ -1442,9 +1484,24 @@ function SplitCardFormInner({
|
|
|
1442
1484
|
updateError(null);
|
|
1443
1485
|
let handedOff = false;
|
|
1444
1486
|
try {
|
|
1445
|
-
if (
|
|
1446
|
-
|
|
1447
|
-
|
|
1487
|
+
if (avsConfig) {
|
|
1488
|
+
const country = selectedCountryRef.current;
|
|
1489
|
+
if ((0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, country) && !zipCodeRef.current.trim()) {
|
|
1490
|
+
updateError((0, import_shared4.getPostalCodeLabel)(country) + " is required");
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
if ((0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, country) && !addressLine1Ref.current.trim()) {
|
|
1494
|
+
updateError("Street address is required");
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
if ((0, import_shared4.isAVSFieldVisible)(avsConfig.city, country) && !cityRef.current.trim()) {
|
|
1498
|
+
updateError("City is required");
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
if ((0, import_shared4.isAVSFieldVisible)(avsConfig.state, country) && !stateRef.current.trim()) {
|
|
1502
|
+
updateError((0, import_shared4.getStateLabel)(country) + " is required");
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1448
1505
|
}
|
|
1449
1506
|
const submitResult = await flopay.submitElements();
|
|
1450
1507
|
if (submitResult.error) {
|
|
@@ -1452,14 +1509,19 @@ function SplitCardFormInner({
|
|
|
1452
1509
|
onError?.(submitResult.error);
|
|
1453
1510
|
return;
|
|
1454
1511
|
}
|
|
1455
|
-
const billingAddress = {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1512
|
+
const billingAddress = {};
|
|
1513
|
+
const cc = selectedCountryRef.current;
|
|
1514
|
+
const avsCountry = enableAVS ? cc : resolvedAccount.country;
|
|
1515
|
+
if (avsCountry) billingAddress["country"] = avsCountry;
|
|
1516
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) && zipCodeRef.current.trim()) {
|
|
1517
|
+
billingAddress["postal_code"] = zipCodeRef.current.trim();
|
|
1518
|
+
} else if (!avsConfig && resolvedAccount.zip) {
|
|
1519
|
+
billingAddress["postal_code"] = resolvedAccount.zip;
|
|
1520
|
+
}
|
|
1521
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, cc) && addressLine1Ref.current.trim()) billingAddress["line1"] = addressLine1Ref.current.trim();
|
|
1522
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, cc) && addressLine2Ref.current.trim()) billingAddress["line2"] = addressLine2Ref.current.trim();
|
|
1523
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && cityRef.current.trim()) billingAddress["city"] = cityRef.current.trim();
|
|
1524
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && stateRef.current.trim()) billingAddress["state"] = stateRef.current.trim();
|
|
1463
1525
|
const billingDetails = {
|
|
1464
1526
|
...resolvedAccount.email ? { email: resolvedAccount.email } : {},
|
|
1465
1527
|
...fullName.trim() ? { name: fullName.trim() } : {},
|
|
@@ -1686,80 +1748,198 @@ function SplitCardFormInner({
|
|
|
1686
1748
|
}
|
|
1687
1749
|
}
|
|
1688
1750
|
) }),
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
gap: avsLayoutProp === "column" ? "0.5rem" : "0",
|
|
1693
|
-
marginTop: "0.5rem"
|
|
1694
|
-
}, children: [
|
|
1695
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1696
|
-
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1697
|
-
backgroundColor: cardInputBg,
|
|
1698
|
-
border: `1px solid ${resolvedBorder}`,
|
|
1699
|
-
padding: "10px",
|
|
1700
|
-
...avsLayoutProp === "row" ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
|
|
1701
|
-
...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
|
|
1702
|
-
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1703
|
-
"select",
|
|
1704
|
-
{
|
|
1705
|
-
value: selectedCountry,
|
|
1706
|
-
onChange: (e) => {
|
|
1707
|
-
selectedCountryRef.current = e.target.value;
|
|
1708
|
-
setSelectedCountry(e.target.value);
|
|
1709
|
-
onCountryChange?.(e.target.value);
|
|
1710
|
-
},
|
|
1711
|
-
disabled: isSubmitting,
|
|
1712
|
-
autoComplete: "country",
|
|
1713
|
-
"data-testid": "flopay-country",
|
|
1714
|
-
style: {
|
|
1715
|
-
width: "100%",
|
|
1716
|
-
border: "none",
|
|
1717
|
-
outline: "none",
|
|
1718
|
-
background: "transparent",
|
|
1719
|
-
...sharedInputTypography,
|
|
1720
|
-
cursor: "pointer",
|
|
1721
|
-
...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
|
|
1722
|
-
},
|
|
1723
|
-
children: import_shared4.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: c.code, children: [
|
|
1724
|
-
c.flag,
|
|
1725
|
-
" ",
|
|
1726
|
-
c.name
|
|
1727
|
-
] }, c.code))
|
|
1728
|
-
}
|
|
1729
|
-
) }),
|
|
1730
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1731
|
-
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1751
|
+
avsConfig && (() => {
|
|
1752
|
+
const cc = selectedCountry;
|
|
1753
|
+
const inputWrapStyle = (extraStyle) => ({
|
|
1732
1754
|
backgroundColor: cardInputBg,
|
|
1733
1755
|
border: `1px solid ${resolvedBorder}`,
|
|
1756
|
+
borderRadius: "8px",
|
|
1757
|
+
marginTop: "0.5rem",
|
|
1734
1758
|
padding: "10px",
|
|
1735
|
-
...
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
"
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
+
...isButtons && extraStyle ? extraStyle : {}
|
|
1760
|
+
});
|
|
1761
|
+
const inputFieldStyle = () => ({
|
|
1762
|
+
width: "100%",
|
|
1763
|
+
border: "none",
|
|
1764
|
+
outline: "none",
|
|
1765
|
+
background: "transparent",
|
|
1766
|
+
...sharedInputTypography,
|
|
1767
|
+
...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
|
|
1768
|
+
});
|
|
1769
|
+
const stateOpts = (0, import_shared4.getStateOptions)(cc);
|
|
1770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1771
|
+
(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: inputWrapStyle(bStyles.addressLine1Input), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1772
|
+
"input",
|
|
1773
|
+
{
|
|
1774
|
+
className: "flopay-shared-input",
|
|
1775
|
+
placeholder: "Street Address (e.g. 123 Main St)",
|
|
1776
|
+
autoComplete: "address-line1",
|
|
1777
|
+
value: addressLine1,
|
|
1778
|
+
onChange: (e) => {
|
|
1779
|
+
addressLine1Ref.current = e.target.value;
|
|
1780
|
+
setAddressLine1(e.target.value);
|
|
1781
|
+
},
|
|
1782
|
+
disabled: isSubmitting,
|
|
1783
|
+
required: true,
|
|
1784
|
+
"data-testid": "flopay-address-line1",
|
|
1785
|
+
style: inputFieldStyle()
|
|
1759
1786
|
}
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1787
|
+
) }),
|
|
1788
|
+
(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: inputWrapStyle(bStyles.addressLine2Input), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1789
|
+
"input",
|
|
1790
|
+
{
|
|
1791
|
+
className: "flopay-shared-input",
|
|
1792
|
+
placeholder: "Apt, Suite, Unit (optional)",
|
|
1793
|
+
autoComplete: "address-line2",
|
|
1794
|
+
value: addressLine2,
|
|
1795
|
+
onChange: (e) => {
|
|
1796
|
+
addressLine2Ref.current = e.target.value;
|
|
1797
|
+
setAddressLine2(e.target.value);
|
|
1798
|
+
},
|
|
1799
|
+
disabled: isSubmitting,
|
|
1800
|
+
"data-testid": "flopay-address-line2",
|
|
1801
|
+
style: inputFieldStyle()
|
|
1802
|
+
}
|
|
1803
|
+
) }),
|
|
1804
|
+
((0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
|
|
1805
|
+
display: "flex",
|
|
1806
|
+
gap: "0",
|
|
1807
|
+
marginTop: "0.5rem"
|
|
1808
|
+
}, children: [
|
|
1809
|
+
(0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1810
|
+
flex: 1,
|
|
1811
|
+
backgroundColor: cardInputBg,
|
|
1812
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1813
|
+
padding: "10px",
|
|
1814
|
+
borderTopLeftRadius: "8px",
|
|
1815
|
+
borderBottomLeftRadius: "8px",
|
|
1816
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) ? { borderRight: "none", borderTopRightRadius: 0, borderBottomRightRadius: 0 } : { borderRadius: "8px" },
|
|
1817
|
+
...isButtons && bStyles.cityInput ? bStyles.cityInput : {}
|
|
1818
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1819
|
+
"input",
|
|
1820
|
+
{
|
|
1821
|
+
className: "flopay-shared-input",
|
|
1822
|
+
placeholder: "City",
|
|
1823
|
+
autoComplete: "address-level2",
|
|
1824
|
+
value: city,
|
|
1825
|
+
onChange: (e) => {
|
|
1826
|
+
cityRef.current = e.target.value;
|
|
1827
|
+
setCity(e.target.value);
|
|
1828
|
+
},
|
|
1829
|
+
disabled: isSubmitting,
|
|
1830
|
+
required: true,
|
|
1831
|
+
"data-testid": "flopay-city",
|
|
1832
|
+
style: inputFieldStyle()
|
|
1833
|
+
}
|
|
1834
|
+
) }),
|
|
1835
|
+
(0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1836
|
+
flex: 1,
|
|
1837
|
+
backgroundColor: cardInputBg,
|
|
1838
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1839
|
+
padding: "10px",
|
|
1840
|
+
borderTopRightRadius: "8px",
|
|
1841
|
+
borderBottomRightRadius: "8px",
|
|
1842
|
+
...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : { borderRadius: "8px" },
|
|
1843
|
+
...isButtons && bStyles.stateInput ? bStyles.stateInput : {}
|
|
1844
|
+
}, children: stateOpts ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1845
|
+
"select",
|
|
1846
|
+
{
|
|
1847
|
+
value: stateValue,
|
|
1848
|
+
onChange: (e) => {
|
|
1849
|
+
stateRef.current = e.target.value;
|
|
1850
|
+
setStateValue(e.target.value);
|
|
1851
|
+
},
|
|
1852
|
+
disabled: isSubmitting,
|
|
1853
|
+
autoComplete: "address-level1",
|
|
1854
|
+
required: true,
|
|
1855
|
+
"data-testid": "flopay-state",
|
|
1856
|
+
style: { ...inputFieldStyle(), cursor: "pointer" },
|
|
1857
|
+
children: [
|
|
1858
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: (0, import_shared4.getStateLabel)(cc) }),
|
|
1859
|
+
stateOpts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: s.code, children: s.name }, s.code))
|
|
1860
|
+
]
|
|
1861
|
+
}
|
|
1862
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1863
|
+
"input",
|
|
1864
|
+
{
|
|
1865
|
+
className: "flopay-shared-input",
|
|
1866
|
+
placeholder: (0, import_shared4.getStateLabel)(cc),
|
|
1867
|
+
autoComplete: "address-level1",
|
|
1868
|
+
value: stateValue,
|
|
1869
|
+
onChange: (e) => {
|
|
1870
|
+
stateRef.current = e.target.value;
|
|
1871
|
+
setStateValue(e.target.value);
|
|
1872
|
+
},
|
|
1873
|
+
disabled: isSubmitting,
|
|
1874
|
+
required: true,
|
|
1875
|
+
"data-testid": "flopay-state",
|
|
1876
|
+
style: inputFieldStyle()
|
|
1877
|
+
}
|
|
1878
|
+
) })
|
|
1879
|
+
] }),
|
|
1880
|
+
((0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
|
|
1881
|
+
display: "flex",
|
|
1882
|
+
flexDirection: avsLayoutProp === "column" ? "column" : "row",
|
|
1883
|
+
gap: avsLayoutProp === "column" ? "0.5rem" : "0",
|
|
1884
|
+
marginTop: "0.5rem"
|
|
1885
|
+
}, children: [
|
|
1886
|
+
(0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1887
|
+
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1888
|
+
backgroundColor: cardInputBg,
|
|
1889
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1890
|
+
padding: "10px",
|
|
1891
|
+
...avsLayoutProp === "row" && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
|
|
1892
|
+
...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
|
|
1893
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1894
|
+
"select",
|
|
1895
|
+
{
|
|
1896
|
+
value: selectedCountry,
|
|
1897
|
+
onChange: (e) => {
|
|
1898
|
+
selectedCountryRef.current = e.target.value;
|
|
1899
|
+
setSelectedCountry(e.target.value);
|
|
1900
|
+
onCountryChange?.(e.target.value);
|
|
1901
|
+
stateRef.current = "";
|
|
1902
|
+
setStateValue("");
|
|
1903
|
+
},
|
|
1904
|
+
disabled: isSubmitting,
|
|
1905
|
+
autoComplete: "country",
|
|
1906
|
+
"data-testid": "flopay-country",
|
|
1907
|
+
style: { ...inputFieldStyle(), cursor: "pointer" },
|
|
1908
|
+
children: import_shared4.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: c.code, children: [
|
|
1909
|
+
c.flag,
|
|
1910
|
+
" ",
|
|
1911
|
+
c.name
|
|
1912
|
+
] }, c.code))
|
|
1913
|
+
}
|
|
1914
|
+
) }),
|
|
1915
|
+
(0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1916
|
+
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1917
|
+
backgroundColor: cardInputBg,
|
|
1918
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1919
|
+
padding: "10px",
|
|
1920
|
+
...avsLayoutProp === "row" && (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
|
|
1921
|
+
...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
|
|
1922
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1923
|
+
"input",
|
|
1924
|
+
{
|
|
1925
|
+
className: "flopay-shared-input",
|
|
1926
|
+
placeholder: (0, import_shared4.getPostalCodeLabel)(selectedCountry),
|
|
1927
|
+
autoComplete: "postal-code",
|
|
1928
|
+
value: zipCode,
|
|
1929
|
+
onChange: (e) => {
|
|
1930
|
+
zipCodeRef.current = e.target.value;
|
|
1931
|
+
setZipCode(e.target.value);
|
|
1932
|
+
onZipChange?.(e.target.value);
|
|
1933
|
+
},
|
|
1934
|
+
disabled: isSubmitting,
|
|
1935
|
+
required: true,
|
|
1936
|
+
"data-testid": "flopay-zip",
|
|
1937
|
+
style: inputFieldStyle()
|
|
1938
|
+
}
|
|
1939
|
+
) })
|
|
1940
|
+
] })
|
|
1941
|
+
] });
|
|
1942
|
+
})(),
|
|
1763
1943
|
displayError && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
|
|
1764
1944
|
margin: "0.75rem 0",
|
|
1765
1945
|
padding: "0.625rem 0.875rem",
|
|
@@ -2903,7 +3083,14 @@ function FloPayCheckout({
|
|
|
2903
3083
|
}
|
|
2904
3084
|
}
|
|
2905
3085
|
if (!sid) {
|
|
2906
|
-
|
|
3086
|
+
const paramsWithAnalytics = {
|
|
3087
|
+
...params,
|
|
3088
|
+
avsCheck: !!enableAVS,
|
|
3089
|
+
avsConfig: typeof enableAVS === "object" ? enableAVS : void 0,
|
|
3090
|
+
checkoutType: "embedded_checkout",
|
|
3091
|
+
checkoutLayout: children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout"
|
|
3092
|
+
};
|
|
3093
|
+
realResult = await api.createAndFetchSession(paramsWithAnalytics);
|
|
2907
3094
|
sid = realResult.data.session?.id ?? "";
|
|
2908
3095
|
if (sid && typeof window !== "undefined") {
|
|
2909
3096
|
window.sessionStorage.setItem(cacheKey, sid);
|
|
@@ -3387,6 +3574,9 @@ function FloPayCheckout({
|
|
|
3387
3574
|
country: session?.customer?.country,
|
|
3388
3575
|
onCountryChange,
|
|
3389
3576
|
onZipChange,
|
|
3577
|
+
avsCheck: !!enableAVS,
|
|
3578
|
+
checkoutType: createSessionParams ? "embedded_checkout" : "standard_checkout",
|
|
3579
|
+
checkoutLayout: children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout",
|
|
3390
3580
|
submitLabel,
|
|
3391
3581
|
className
|
|
3392
3582
|
}
|