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