@flopay/shared 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1312,7 +1312,7 @@ declare function getConfiguredBillingApiUrl(): string;
1312
1312
  declare function getFloPayEnvironment(): FloPayEnvironment;
1313
1313
 
1314
1314
  /** Current SDK version. */
1315
- declare const SDK_VERSION = "1.3.0";
1315
+ declare const SDK_VERSION = "1.3.2";
1316
1316
  /**
1317
1317
  * HTTP header the SDK sends on `POST /v1/checkouts/sessions` so the backend
1318
1318
  * can decide whether to embed the vault capture block (the hosted PCI card
@@ -1744,6 +1744,38 @@ declare function getStateLabel(countryCode: string): string;
1744
1744
  */
1745
1745
  declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
1746
1746
 
1747
+ /**
1748
+ * True when `validator` has an authoritative postcode pattern for the country
1749
+ * (normalized to ISO 3166-1 alpha-2 via {@link normalizeCountryToIso2}).
1750
+ * Supported countries validate the postcode format; unsupported / no-postcode /
1751
+ * unresolvable countries fail open. Note the 2-letter passthrough means `UK`
1752
+ * (an unsupported `validator` locale) returns `false` here — matching the
1753
+ * backend; use the full name `United Kingdom` for `GB` semantics.
1754
+ */
1755
+ declare function isPostalCodeSupported(country: string): boolean;
1756
+ /**
1757
+ * Validate a postcode against the country's expected format. A faithful mirror
1758
+ * of the backend's `isPostalCodeValidForCountry`, so the SDK never blocks a
1759
+ * value the server would accept, nor opens the submit gate on one it would
1760
+ * reject. Fail-open (returns `true`) in exactly the backend's three cases:
1761
+ *
1762
+ * - `postalCode` is blank / whitespace-only;
1763
+ * - the country can't be normalized to an ISO-2 locale;
1764
+ * - the ISO-2 locale isn't one `validator` recognises.
1765
+ *
1766
+ * Otherwise returns `validator`'s `isPostalCode(zip.trim(), locale)`. Callers
1767
+ * that distinguish "required" (empty) from "malformed" (bad format) must check
1768
+ * emptiness themselves — an empty value fails open here, as it does server-side.
1769
+ */
1770
+ declare function isValidPostalCode(country: string, postalCode: string): boolean;
1771
+ /**
1772
+ * The example postcode the backend would embed in its 400 message for the
1773
+ * country (e.g. US `12345 or 12345-6789`, GB `SW1A 1AA`, CA `A1A 1A1`), or
1774
+ * `undefined` when there is none (unresolvable country, or a supported country
1775
+ * absent from {@link POSTAL_CODE_EXAMPLES}).
1776
+ */
1777
+ declare function getPostalCodeExample(country: string): string | undefined;
1778
+
1747
1779
  /** A single line item formatted for display in the checkout UI. */
1748
1780
  interface DisplayLineItem {
1749
1781
  name: string;
@@ -1875,4 +1907,4 @@ declare function isValidSecretKey(key: string): boolean;
1875
1907
  */
1876
1908
  declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
1877
1909
 
1878
- export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BOLD_DARK_APPEARANCE, BOLD_LIGHT_APPEARANCE, BUTTONS_LAYOUT_BOLD_DARK, BUTTONS_LAYOUT_BOLD_LIGHT, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_GLASS_DARK, BUTTONS_LAYOUT_GLASS_LIGHT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_MODERN_DARK, BUTTONS_LAYOUT_MODERN_LIGHT, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type BuildCheckoutDisplayDataOptions, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CardCaptureAdapter, type CardCaptureEventType, type CardCaptureMountOptions, type CardCaptureOutcomeEvent, type CardCaptureProviderId, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ConfirmCardPaymentParams, type ConfirmCardPaymentResult, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreatePaymentMethodResult, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, FLO_SDK_VERSION_HEADER, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, STRIPE_EXPRESS_METHODS, STRIPE_METHOD_AMOUNT_LIMITS, STRIPE_METHOD_COUNTRIES, STRIPE_METHOD_CURRENCIES, STRIPE_METHOD_MATRIX, SUPPORTED_CARD_BRANDS, type StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, THEMES, type TagsData, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, type UpdateCustomerParams, type VaultCaptureBlock, type VaultCaptureResultMessage, type VaultCardFieldKey, type VaultCardThemeColors, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, configureFlopay, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isSetupIntentClientSecret, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeGatewayEnvironment, partitionStripeMethods, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, stripeExpressMethodToOptionKey, validationError };
1910
+ export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BOLD_DARK_APPEARANCE, BOLD_LIGHT_APPEARANCE, BUTTONS_LAYOUT_BOLD_DARK, BUTTONS_LAYOUT_BOLD_LIGHT, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_GLASS_DARK, BUTTONS_LAYOUT_GLASS_LIGHT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_MODERN_DARK, BUTTONS_LAYOUT_MODERN_LIGHT, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type BuildCheckoutDisplayDataOptions, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CardCaptureAdapter, type CardCaptureEventType, type CardCaptureMountOptions, type CardCaptureOutcomeEvent, type CardCaptureProviderId, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ConfirmCardPaymentParams, type ConfirmCardPaymentResult, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreatePaymentMethodResult, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, FLO_SDK_VERSION_HEADER, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, STRIPE_EXPRESS_METHODS, STRIPE_METHOD_AMOUNT_LIMITS, STRIPE_METHOD_COUNTRIES, STRIPE_METHOD_CURRENCIES, STRIPE_METHOD_MATRIX, SUPPORTED_CARD_BRANDS, type StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, THEMES, type TagsData, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, type UpdateCustomerParams, type VaultCaptureBlock, type VaultCaptureResultMessage, type VaultCardFieldKey, type VaultCardThemeColors, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, configureFlopay, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeExample, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isPostalCodeSupported, isSetupIntentClientSecret, isValidPostalCode, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeGatewayEnvironment, partitionStripeMethods, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, stripeExpressMethodToOptionKey, validationError };
package/dist/index.d.ts CHANGED
@@ -1312,7 +1312,7 @@ declare function getConfiguredBillingApiUrl(): string;
1312
1312
  declare function getFloPayEnvironment(): FloPayEnvironment;
1313
1313
 
1314
1314
  /** Current SDK version. */
1315
- declare const SDK_VERSION = "1.3.0";
1315
+ declare const SDK_VERSION = "1.3.2";
1316
1316
  /**
1317
1317
  * HTTP header the SDK sends on `POST /v1/checkouts/sessions` so the backend
1318
1318
  * can decide whether to embed the vault capture block (the hosted PCI card
@@ -1744,6 +1744,38 @@ declare function getStateLabel(countryCode: string): string;
1744
1744
  */
1745
1745
  declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
1746
1746
 
1747
+ /**
1748
+ * True when `validator` has an authoritative postcode pattern for the country
1749
+ * (normalized to ISO 3166-1 alpha-2 via {@link normalizeCountryToIso2}).
1750
+ * Supported countries validate the postcode format; unsupported / no-postcode /
1751
+ * unresolvable countries fail open. Note the 2-letter passthrough means `UK`
1752
+ * (an unsupported `validator` locale) returns `false` here — matching the
1753
+ * backend; use the full name `United Kingdom` for `GB` semantics.
1754
+ */
1755
+ declare function isPostalCodeSupported(country: string): boolean;
1756
+ /**
1757
+ * Validate a postcode against the country's expected format. A faithful mirror
1758
+ * of the backend's `isPostalCodeValidForCountry`, so the SDK never blocks a
1759
+ * value the server would accept, nor opens the submit gate on one it would
1760
+ * reject. Fail-open (returns `true`) in exactly the backend's three cases:
1761
+ *
1762
+ * - `postalCode` is blank / whitespace-only;
1763
+ * - the country can't be normalized to an ISO-2 locale;
1764
+ * - the ISO-2 locale isn't one `validator` recognises.
1765
+ *
1766
+ * Otherwise returns `validator`'s `isPostalCode(zip.trim(), locale)`. Callers
1767
+ * that distinguish "required" (empty) from "malformed" (bad format) must check
1768
+ * emptiness themselves — an empty value fails open here, as it does server-side.
1769
+ */
1770
+ declare function isValidPostalCode(country: string, postalCode: string): boolean;
1771
+ /**
1772
+ * The example postcode the backend would embed in its 400 message for the
1773
+ * country (e.g. US `12345 or 12345-6789`, GB `SW1A 1AA`, CA `A1A 1A1`), or
1774
+ * `undefined` when there is none (unresolvable country, or a supported country
1775
+ * absent from {@link POSTAL_CODE_EXAMPLES}).
1776
+ */
1777
+ declare function getPostalCodeExample(country: string): string | undefined;
1778
+
1747
1779
  /** A single line item formatted for display in the checkout UI. */
1748
1780
  interface DisplayLineItem {
1749
1781
  name: string;
@@ -1875,4 +1907,4 @@ declare function isValidSecretKey(key: string): boolean;
1875
1907
  */
1876
1908
  declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
1877
1909
 
1878
- export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BOLD_DARK_APPEARANCE, BOLD_LIGHT_APPEARANCE, BUTTONS_LAYOUT_BOLD_DARK, BUTTONS_LAYOUT_BOLD_LIGHT, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_GLASS_DARK, BUTTONS_LAYOUT_GLASS_LIGHT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_MODERN_DARK, BUTTONS_LAYOUT_MODERN_LIGHT, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type BuildCheckoutDisplayDataOptions, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CardCaptureAdapter, type CardCaptureEventType, type CardCaptureMountOptions, type CardCaptureOutcomeEvent, type CardCaptureProviderId, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ConfirmCardPaymentParams, type ConfirmCardPaymentResult, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreatePaymentMethodResult, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, FLO_SDK_VERSION_HEADER, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, STRIPE_EXPRESS_METHODS, STRIPE_METHOD_AMOUNT_LIMITS, STRIPE_METHOD_COUNTRIES, STRIPE_METHOD_CURRENCIES, STRIPE_METHOD_MATRIX, SUPPORTED_CARD_BRANDS, type StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, THEMES, type TagsData, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, type UpdateCustomerParams, type VaultCaptureBlock, type VaultCaptureResultMessage, type VaultCardFieldKey, type VaultCardThemeColors, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, configureFlopay, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isSetupIntentClientSecret, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeGatewayEnvironment, partitionStripeMethods, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, stripeExpressMethodToOptionKey, validationError };
1910
+ export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BOLD_DARK_APPEARANCE, BOLD_LIGHT_APPEARANCE, BUTTONS_LAYOUT_BOLD_DARK, BUTTONS_LAYOUT_BOLD_LIGHT, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_GLASS_DARK, BUTTONS_LAYOUT_GLASS_LIGHT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_MODERN_DARK, BUTTONS_LAYOUT_MODERN_LIGHT, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type BuildCheckoutDisplayDataOptions, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CardCaptureAdapter, type CardCaptureEventType, type CardCaptureMountOptions, type CardCaptureOutcomeEvent, type CardCaptureProviderId, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ConfirmCardPaymentParams, type ConfirmCardPaymentResult, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreatePaymentMethodResult, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, FLO_SDK_VERSION_HEADER, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, STRIPE_EXPRESS_METHODS, STRIPE_METHOD_AMOUNT_LIMITS, STRIPE_METHOD_COUNTRIES, STRIPE_METHOD_CURRENCIES, STRIPE_METHOD_MATRIX, SUPPORTED_CARD_BRANDS, type StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, THEMES, type TagsData, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, type UpdateCustomerParams, type VaultCaptureBlock, type VaultCaptureResultMessage, type VaultCardFieldKey, type VaultCardThemeColors, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, configureFlopay, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeExample, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isPostalCodeSupported, isSetupIntentClientSecret, isValidPostalCode, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeGatewayEnvironment, partitionStripeMethods, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, stripeExpressMethodToOptionKey, validationError };
package/dist/index.mjs CHANGED
@@ -79,7 +79,7 @@ var PAYMENT_METHOD_LOGOS = {
79
79
  };
80
80
 
81
81
  // src/constants.ts
82
- var SDK_VERSION = "1.3.0";
82
+ var SDK_VERSION = "1.3.2";
83
83
  var FLO_SDK_VERSION_HEADER = "x-flo-sdk-version";
84
84
  var BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
85
85
  var BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
@@ -1856,6 +1856,107 @@ function getStateFromPostalCode(country, postalCode) {
1856
1856
  }
1857
1857
  }
1858
1858
 
1859
+ // src/postal-code-validation.ts
1860
+ import * as isPostalCodeModule from "validator/lib/isPostalCode.js";
1861
+ var mod = isPostalCodeModule;
1862
+ var isPostalCode = typeof mod.default === "function" ? mod.default : mod.default?.default;
1863
+ if (typeof isPostalCode !== "function") {
1864
+ throw new Error(
1865
+ "validator/lib/isPostalCode.js interop failed: unexpected module shape. This likely means the bundler's CJS/ESM interop changed."
1866
+ );
1867
+ }
1868
+ var SUPPORTED_LOCALES = new Set(
1869
+ mod.locales.map((code) => code.toUpperCase())
1870
+ );
1871
+ var COUNTRY_ALIASES = {
1872
+ AUSTRALIA: "AU",
1873
+ BRAZIL: "BR",
1874
+ CANADA: "CA",
1875
+ CH: "CH",
1876
+ DENMARK: "DK",
1877
+ DE: "DE",
1878
+ DEUTSCHLAND: "DE",
1879
+ FRANCE: "FR",
1880
+ GB: "GB",
1881
+ GERMANY: "DE",
1882
+ GREATBRITAIN: "GB",
1883
+ GREAT_BRITAIN: "GB",
1884
+ INDIA: "IN",
1885
+ IRELAND: "IE",
1886
+ ITALY: "IT",
1887
+ JAPAN: "JP",
1888
+ MEXICO: "MX",
1889
+ NETHERLANDS: "NL",
1890
+ NEWZEALAND: "NZ",
1891
+ NORWAY: "NO",
1892
+ POLAND: "PL",
1893
+ PORTUGAL: "PT",
1894
+ SINGAPORE: "SG",
1895
+ SOUTHAFRICA: "ZA",
1896
+ SPAIN: "ES",
1897
+ SWEDEN: "SE",
1898
+ SWITZERLAND: "CH",
1899
+ UK: "GB",
1900
+ UNITEDKINGDOM: "GB",
1901
+ UNITEDSTATES: "US",
1902
+ US: "US",
1903
+ USA: "US",
1904
+ "UNITED STATES": "US",
1905
+ "UNITED KINGDOM": "GB",
1906
+ "GREAT BRITAIN": "GB",
1907
+ ENGLAND: "GB"
1908
+ };
1909
+ function normalizeCountryToIso2(country) {
1910
+ const upper = (country ?? "").trim().toUpperCase();
1911
+ if (!upper) return null;
1912
+ if (upper.length === 2) return upper;
1913
+ return COUNTRY_ALIASES[upper] ?? null;
1914
+ }
1915
+ var POSTAL_CODE_EXAMPLES = {
1916
+ AU: "2000",
1917
+ BR: "01000-000",
1918
+ CA: "A1A 1A1",
1919
+ CH: "8001",
1920
+ DE: "10115",
1921
+ DK: "1050",
1922
+ ES: "28001",
1923
+ FR: "75008",
1924
+ GB: "SW1A 1AA",
1925
+ IE: "D02 X285",
1926
+ IN: "110001",
1927
+ IT: "00118",
1928
+ JP: "100-0001",
1929
+ MX: "06500",
1930
+ NL: "1012 JS",
1931
+ NO: "0150",
1932
+ NZ: "6011",
1933
+ PL: "00-001",
1934
+ PT: "1100-148",
1935
+ SE: "111 22",
1936
+ SG: "018989",
1937
+ US: "12345 or 12345-6789",
1938
+ ZA: "8001"
1939
+ };
1940
+ function isPostalCodeSupported(country) {
1941
+ const iso2 = normalizeCountryToIso2(country);
1942
+ return iso2 !== null && SUPPORTED_LOCALES.has(iso2);
1943
+ }
1944
+ function isValidPostalCode(country, postalCode) {
1945
+ const trimmed = (postalCode ?? "").trim();
1946
+ if (!trimmed) return true;
1947
+ const iso2 = normalizeCountryToIso2(country);
1948
+ if (iso2 === null || !SUPPORTED_LOCALES.has(iso2)) return true;
1949
+ try {
1950
+ return isPostalCode(trimmed, iso2);
1951
+ } catch {
1952
+ return true;
1953
+ }
1954
+ }
1955
+ function getPostalCodeExample(country) {
1956
+ const iso2 = normalizeCountryToIso2(country);
1957
+ return iso2 ? POSTAL_CODE_EXAMPLES[iso2] : void 0;
1958
+ }
1959
+
1859
1960
  // src/checkout-payload.ts
1860
1961
  function nonBlank(value) {
1861
1962
  if (typeof value !== "string") return void 0;
@@ -2112,6 +2213,7 @@ export {
2112
2213
  getCountryByCode,
2113
2214
  getCurrencyByCountry,
2114
2215
  getFloPayEnvironment,
2216
+ getPostalCodeExample,
2115
2217
  getPostalCodeLabel,
2116
2218
  getStateFromPostalCode,
2117
2219
  getStateLabel,
@@ -2120,7 +2222,9 @@ export {
2120
2222
  hasVendoredStripeMethodLogo,
2121
2223
  isAVSEnabled,
2122
2224
  isAVSFieldVisible,
2225
+ isPostalCodeSupported,
2123
2226
  isSetupIntentClientSecret,
2227
+ isValidPostalCode,
2124
2228
  isValidPublishableKey,
2125
2229
  isValidSecretKey,
2126
2230
  needsStripeMethodExplicitConfirm,