@flopay/shared 0.5.1 → 0.5.3
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 +110 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.mjs +109 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ __export(index_exports, {
|
|
|
50
50
|
getCurrencyByCountry: () => getCurrencyByCountry,
|
|
51
51
|
getFloPayEnvironment: () => getFloPayEnvironment,
|
|
52
52
|
getPostalCodeLabel: () => getPostalCodeLabel,
|
|
53
|
+
getStateFromPostalCode: () => getStateFromPostalCode,
|
|
53
54
|
getStateLabel: () => getStateLabel,
|
|
54
55
|
getStateOptions: () => getStateOptions,
|
|
55
56
|
isAVSEnabled: () => isAVSEnabled,
|
|
@@ -111,7 +112,7 @@ function getFloPayEnvironment() {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
// src/constants.ts
|
|
114
|
-
var SDK_VERSION = "0.5.
|
|
115
|
+
var SDK_VERSION = "0.5.3";
|
|
115
116
|
var BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
116
117
|
var BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
|
|
117
118
|
var DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;
|
|
@@ -657,6 +658,113 @@ function getStateLabel(countryCode) {
|
|
|
657
658
|
}
|
|
658
659
|
}
|
|
659
660
|
|
|
661
|
+
// src/postal-code-lookup.ts
|
|
662
|
+
var US_ZIP_PREFIX_RANGES = [
|
|
663
|
+
[5, 5, "NY"],
|
|
664
|
+
[10, 27, "MA"],
|
|
665
|
+
[28, 29, "RI"],
|
|
666
|
+
[30, 38, "NH"],
|
|
667
|
+
[39, 49, "ME"],
|
|
668
|
+
[50, 59, "VT"],
|
|
669
|
+
[60, 69, "CT"],
|
|
670
|
+
[70, 89, "NJ"],
|
|
671
|
+
[100, 149, "NY"],
|
|
672
|
+
[150, 196, "PA"],
|
|
673
|
+
[197, 199, "DE"],
|
|
674
|
+
[200, 205, "DC"],
|
|
675
|
+
[206, 219, "MD"],
|
|
676
|
+
[220, 246, "VA"],
|
|
677
|
+
[247, 268, "WV"],
|
|
678
|
+
[270, 289, "NC"],
|
|
679
|
+
[290, 299, "SC"],
|
|
680
|
+
[300, 319, "GA"],
|
|
681
|
+
[320, 349, "FL"],
|
|
682
|
+
[350, 369, "AL"],
|
|
683
|
+
[370, 385, "TN"],
|
|
684
|
+
[386, 397, "MS"],
|
|
685
|
+
[398, 399, "GA"],
|
|
686
|
+
[400, 427, "KY"],
|
|
687
|
+
[430, 459, "OH"],
|
|
688
|
+
[460, 479, "IN"],
|
|
689
|
+
[480, 499, "MI"],
|
|
690
|
+
[500, 528, "IA"],
|
|
691
|
+
[530, 549, "WI"],
|
|
692
|
+
[550, 567, "MN"],
|
|
693
|
+
[570, 577, "SD"],
|
|
694
|
+
[580, 588, "ND"],
|
|
695
|
+
[590, 599, "MT"],
|
|
696
|
+
[600, 629, "IL"],
|
|
697
|
+
[630, 658, "MO"],
|
|
698
|
+
[660, 679, "KS"],
|
|
699
|
+
[680, 693, "NE"],
|
|
700
|
+
[700, 714, "LA"],
|
|
701
|
+
[716, 729, "AR"],
|
|
702
|
+
[730, 749, "OK"],
|
|
703
|
+
[750, 799, "TX"],
|
|
704
|
+
[800, 816, "CO"],
|
|
705
|
+
[820, 831, "WY"],
|
|
706
|
+
[832, 838, "ID"],
|
|
707
|
+
[840, 847, "UT"],
|
|
708
|
+
[850, 865, "AZ"],
|
|
709
|
+
[870, 884, "NM"],
|
|
710
|
+
[889, 898, "NV"],
|
|
711
|
+
[900, 961, "CA"],
|
|
712
|
+
[967, 968, "HI"],
|
|
713
|
+
[970, 979, "OR"],
|
|
714
|
+
[980, 994, "WA"],
|
|
715
|
+
[995, 999, "AK"]
|
|
716
|
+
];
|
|
717
|
+
var CA_FSA_FIRST_LETTER_TO_PROVINCE = {
|
|
718
|
+
A: "NL",
|
|
719
|
+
B: "NS",
|
|
720
|
+
C: "PE",
|
|
721
|
+
E: "NB",
|
|
722
|
+
G: "QC",
|
|
723
|
+
H: "QC",
|
|
724
|
+
J: "QC",
|
|
725
|
+
K: "ON",
|
|
726
|
+
L: "ON",
|
|
727
|
+
M: "ON",
|
|
728
|
+
N: "ON",
|
|
729
|
+
P: "ON",
|
|
730
|
+
R: "MB",
|
|
731
|
+
S: "SK",
|
|
732
|
+
T: "AB",
|
|
733
|
+
V: "BC",
|
|
734
|
+
X: "NT",
|
|
735
|
+
Y: "YT"
|
|
736
|
+
};
|
|
737
|
+
function deriveUsState(zip) {
|
|
738
|
+
const digits = zip.replace(/\D/g, "");
|
|
739
|
+
if (digits.length < 5) return null;
|
|
740
|
+
const prefix = Number.parseInt(digits.slice(0, 3), 10);
|
|
741
|
+
if (!Number.isFinite(prefix)) return null;
|
|
742
|
+
for (const [start, end, code] of US_ZIP_PREFIX_RANGES) {
|
|
743
|
+
if (prefix >= start && prefix <= end) return code;
|
|
744
|
+
}
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
function deriveCaProvince(postalCode) {
|
|
748
|
+
const compact = postalCode.replace(/\s+/g, "").toUpperCase();
|
|
749
|
+
if (!/^[A-Z]\d[A-Z]\d[A-Z]\d$/.test(compact)) return null;
|
|
750
|
+
const firstLetter = compact[0] ?? "";
|
|
751
|
+
return CA_FSA_FIRST_LETTER_TO_PROVINCE[firstLetter] ?? null;
|
|
752
|
+
}
|
|
753
|
+
function getStateFromPostalCode(country, postalCode) {
|
|
754
|
+
if (!country || !postalCode) return null;
|
|
755
|
+
const normalizedCountry = country.trim().toUpperCase();
|
|
756
|
+
const normalizedZip = postalCode.trim();
|
|
757
|
+
if (!normalizedZip) return null;
|
|
758
|
+
switch (normalizedCountry) {
|
|
759
|
+
case "US":
|
|
760
|
+
return deriveUsState(normalizedZip);
|
|
761
|
+
case "CA":
|
|
762
|
+
return deriveCaProvince(normalizedZip);
|
|
763
|
+
default:
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
660
768
|
// src/display.ts
|
|
661
769
|
function buildCheckoutDisplayData(session) {
|
|
662
770
|
const itemsList = [];
|
|
@@ -757,6 +865,7 @@ function isValidSecretKey(key) {
|
|
|
757
865
|
getCurrencyByCountry,
|
|
758
866
|
getFloPayEnvironment,
|
|
759
867
|
getPostalCodeLabel,
|
|
868
|
+
getStateFromPostalCode,
|
|
760
869
|
getStateLabel,
|
|
761
870
|
getStateOptions,
|
|
762
871
|
isAVSEnabled,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/config.ts","../src/constants.ts","../src/display.ts","../src/validation.ts"],"sourcesContent":["// Types\nexport type {\n FloPayThemeVariables,\n FloPayAppearance,\n Customer,\n RecurringInterval,\n PriceData,\n LineItem,\n CheckoutMode,\n CheckoutSession,\n CheckoutSessionItem,\n CheckoutSessionSubscription,\n PaymentResult,\n ConfirmPaymentParams,\n CreatePaymentMethodResult,\n ConfirmCardPaymentParams,\n ConfirmCardPaymentResult,\n ElementType,\n ElementChangeEvent,\n ElementOptions,\n MountedElement,\n FloPayConfig,\n PaymentProviderAdapter,\n BillingProvider,\n TokenizedBody,\n CheckoutProcessError,\n CheckoutModeKind,\n NormalizedCheckoutSession,\n CheckoutItem,\n CheckoutSubscription,\n CheckoutAccount,\n TagsData,\n CreateSessionParams,\n CheckoutSessionResult,\n ProcessPaymentParams,\n CreateCustomerParams,\n UpdateCustomerParams,\n WebhookEvent,\n CurrencyInfo,\n CountryOption,\n ButtonsLayoutStyles,\n ButtonsLayoutTheme,\n AVSFieldConfig,\n InlineSessionParams,\n InlineSessionDraft,\n InlineSessionPatch,\n BeforeButtonClickEvent,\n CheckoutButtonMethod,\n DeclineEvent,\n BillingDetails,\n} from './types.js';\n\n// Errors\nexport {\n FloPayError,\n validationError,\n apiError,\n authenticationError,\n rateLimitError,\n networkError,\n} from './errors.js';\nexport type { FloPayErrorType } from './errors.js';\n\n// Configuration\nexport { configureFlopay, getConfiguredBillingApiUrl, getFloPayEnvironment } from './config.js';\nexport type { FloPayEnvironment } from './config.js';\n\n// Constants\nexport {\n SDK_VERSION,\n DEFAULT_API_BASE_URL,\n DEFAULT_API_VERSION,\n BILLING_API_URL,\n BILLING_API_URL_STAGING,\n BILLING_API_URL_PRODUCTION,\n resolveBillingApiUrl,\n DEFAULT_APPEARANCE,\n FLAT_APPEARANCE,\n NIGHT_APPEARANCE,\n ELEMENT_TYPES,\n SUPPORTED_CARD_BRANDS,\n CURRENCY_MAP,\n DEFAULT_CURRENCY,\n BUTTONS_LAYOUT_DEFAULT,\n BUTTONS_LAYOUT_MINIMAL,\n BUTTONS_LAYOUT_ROUNDED,\n BUTTONS_LAYOUT_DARK,\n resolveButtonsLayoutTheme,\n getPostalCodeLabel,\n COUNTRY_OPTIONS,\n getCountryByCode,\n resolveAVSConfig,\n isAVSFieldVisible,\n isAVSEnabled,\n US_STATES,\n CA_PROVINCES,\n getStateOptions,\n getStateLabel,\n type StateOption,\n} from './constants.js';\n\n// Display helpers\nexport { buildCheckoutDisplayData } from './display.js';\nexport type { DisplayLineItem, CheckoutDisplayData } from './display.js';\n\n// Validation helpers\nexport {\n getCurrencyByCountry,\n isValidPublishableKey,\n isValidSecretKey,\n} from './validation.js';\n","/** Discriminated error types returned by the FloPay SDK. */\nexport type FloPayErrorType =\n | 'validation_error'\n | 'api_error'\n | 'authentication_error'\n | 'rate_limit_error'\n | 'network_error';\n\n/**\n * Custom error class for all FloPay SDK errors.\n *\n * Extends the native `Error` and adds structured fields that mirror\n * Stripe-style error responses for familiarity.\n */\nexport class FloPayError extends Error {\n readonly type: FloPayErrorType;\n readonly code?: string;\n readonly declineCode?: string;\n readonly param?: string;\n\n constructor(\n message: string,\n type: FloPayErrorType,\n options?: { code?: string; declineCode?: string; param?: string },\n ) {\n super(message);\n this.name = 'FloPayError';\n this.type = type;\n this.code = options?.code;\n this.declineCode = options?.declineCode;\n this.param = options?.param;\n\n // Restore prototype chain (required when extending built-ins)\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error Factories\n// ---------------------------------------------------------------------------\n\n/** Create a validation error (e.g. missing required field). */\nexport function validationError(\n message: string,\n param?: string,\n): FloPayError {\n return new FloPayError(message, 'validation_error', { param });\n}\n\n/** Create an API error (e.g. upstream provider returned an error). */\nexport function apiError(\n message: string,\n code?: string,\n): FloPayError {\n return new FloPayError(message, 'api_error', { code });\n}\n\n/** Create an authentication error (e.g. invalid publishable key). */\nexport function authenticationError(message: string): FloPayError {\n return new FloPayError(message, 'authentication_error');\n}\n\n/** Create a rate limit error. */\nexport function rateLimitError(message: string): FloPayError {\n return new FloPayError(message, 'rate_limit_error');\n}\n\n/** Create a network error (e.g. fetch failed). */\nexport function networkError(message: string): FloPayError {\n return new FloPayError(message, 'network_error');\n}\n","/** FloPay environment — determines which billing API URL is used. */\nexport type FloPayEnvironment = 'staging' | 'production' | 'local';\n\nconst ENV_URL_MAP: Record<FloPayEnvironment, string> = {\n local: 'https://flo.ngrok.pro',\n staging: 'https://api.stage.flopay.com',\n production: 'https://api.flopay.com',\n};\n\nlet globalEnvironment: FloPayEnvironment = 'staging';\n\n/**\n * Configure the FloPay SDK globally. Call once at app startup.\n *\n * The environment determines which billing API URL is used for all\n * FloPay operations (session creation, payment processing, etc.).\n *\n * @example\n * ```ts\n * import { configureFlopay } from '@flopay/shared';\n *\n * // In production\n * configureFlopay({ environment: 'production' });\n *\n * // In staging/development\n * configureFlopay({ environment: 'staging' });\n * ```\n *\n * Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable\n * to `'staging'` or `'production'` — the SDK reads it automatically.\n */\nexport function configureFlopay(config: { environment: FloPayEnvironment }): void {\n globalEnvironment = config.environment;\n}\n\n/** Get the billing API URL for the currently configured environment. */\nexport function getConfiguredBillingApiUrl(): string {\n return ENV_URL_MAP[globalEnvironment];\n}\n\n/** Get the current configured environment. */\nexport function getFloPayEnvironment(): FloPayEnvironment {\n return globalEnvironment;\n}\n","import type { CurrencyInfo, CountryOption, FloPayAppearance, ButtonsLayoutStyles, ButtonsLayoutTheme, AVSFieldConfig } from './types.js';\n\nimport type { FloPayEnvironment } from './config.js';\nimport { getConfiguredBillingApiUrl } from './config.js';\n\n// ---------------------------------------------------------------------------\n// SDK Version & API\n// ---------------------------------------------------------------------------\n\n/** Current SDK version. */\nexport const SDK_VERSION = '0.5.1';\n\n/** Billing API URL for staging environment. */\nexport const BILLING_API_URL_STAGING = 'https://api.stage.flopay.com';\n\n/** Billing API URL for production environment. */\nexport const BILLING_API_URL_PRODUCTION = 'https://api.flopay.com';\n\n/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */\nexport const DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;\n\n/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */\nexport const BILLING_API_URL = BILLING_API_URL_STAGING;\n\n/**\n * Resolve the billing API URL from available configuration.\n *\n * Priority:\n * 1. Explicit `billingApiUrl` (prop/param override)\n * 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)\n * 3. `configureFlopay()` global environment setting\n * 4. Fallback: staging URL\n *\n * @example\n * ```ts\n * import { resolveBillingApiUrl } from '@flopay/shared';\n *\n * // Reads from env var or configureFlopay() — no args needed\n * const url = resolveBillingApiUrl();\n *\n * // Explicit override takes priority\n * const url = resolveBillingApiUrl('https://custom.example.com');\n * ```\n */\nexport function resolveBillingApiUrl(billingApiUrl?: string): string {\n if (billingApiUrl) return billingApiUrl;\n\n // Environment variable (works in Next.js and bundlers that inline process.env)\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_FLOPAY_ENV) {\n const env = process.env.NEXT_PUBLIC_FLOPAY_ENV as FloPayEnvironment;\n if (env === 'production') return BILLING_API_URL_PRODUCTION;\n return BILLING_API_URL_STAGING;\n }\n\n // Global config from configureFlopay()\n return getConfiguredBillingApiUrl();\n}\n\n/** Default API version header value. */\nexport const DEFAULT_API_VERSION = '2024-01-01';\n\n// ---------------------------------------------------------------------------\n// Default Themes\n// ---------------------------------------------------------------------------\n\n/** The default appearance applied when no custom appearance is provided. */\nexport const DEFAULT_APPEARANCE: FloPayAppearance = {\n theme: 'default',\n variables: {\n colorPrimary: '#4A49FF',\n colorBackground: '#FFFFFF',\n colorText: '#262833',\n colorDanger: '#DF1B41',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n/** Flat theme — minimal borders and shadows. */\nexport const FLAT_APPEARANCE: FloPayAppearance = {\n theme: 'flat',\n variables: {\n ...DEFAULT_APPEARANCE.variables,\n borderRadius: '4px',\n },\n};\n\n/** Night theme — dark background. */\nexport const NIGHT_APPEARANCE: FloPayAppearance = {\n theme: 'night',\n variables: {\n colorPrimary: '#7B7BFF',\n colorBackground: '#1A1A2E',\n colorText: '#E0E0E0',\n colorDanger: '#FF6B6B',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Buttons Layout Theme Presets\n// ---------------------------------------------------------------------------\n\n/** Default buttons layout — white card button, neutral borders. */\nexport const BUTTONS_LAYOUT_DEFAULT: ButtonsLayoutStyles = {};\n\n/** Minimal buttons layout — borderless, subtle hover. */\nexport const BUTTONS_LAYOUT_MINIMAL: ButtonsLayoutStyles = {\n cardButton: {\n border: 'none',\n backgroundColor: '#f9fafb',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#f9fafb',\n border: 'none',\n },\n cardInputBorder: '#e5e7eb',\n backButtonIcon: {\n backgroundColor: '#e5e7eb',\n },\n submitButton: {\n borderRadius: '6px',\n },\n};\n\n/** Rounded buttons layout — large border radius, soft shadows. */\nexport const BUTTONS_LAYOUT_ROUNDED: ButtonsLayoutStyles = {\n cardButton: {\n borderRadius: '9999px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 1px 3px rgba(0,0,0,0.06)',\n },\n cardFormContainer: {\n borderRadius: '16px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 2px 8px rgba(0,0,0,0.06)',\n },\n cardInputBorder: '#d1d5db',\n submitButton: {\n borderRadius: '9999px',\n },\n backButtonIcon: {\n backgroundColor: '#f3f4f6',\n },\n};\n\n/** Dark buttons layout — dark backgrounds, light text. */\nexport const BUTTONS_LAYOUT_DARK: ButtonsLayoutStyles = {\n cardButton: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n border: '1px solid #374151',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#111827',\n border: '1px solid #374151',\n },\n cardInputBorder: '#4b5563',\n cardInputColor: '#f9fafb',\n cardInputPlaceholderColor: '#6b7280',\n cardInputBackground: '#1f2937',\n nameInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n backButton: {\n color: '#9ca3af',\n },\n backButtonIcon: {\n backgroundColor: '#374151',\n },\n submitButton: {\n backgroundColor: '#6366f1',\n },\n title: {\n color: '#f9fafb',\n },\n countrySelect: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n zipInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n};\n\n/** Resolve a buttons layout theme name to its style preset. */\nexport function resolveButtonsLayoutTheme(theme?: ButtonsLayoutTheme): ButtonsLayoutStyles {\n switch (theme) {\n case 'minimal': return BUTTONS_LAYOUT_MINIMAL;\n case 'rounded': return BUTTONS_LAYOUT_ROUNDED;\n case 'dark': return BUTTONS_LAYOUT_DARK;\n default: return BUTTONS_LAYOUT_DEFAULT;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Supported Element Types\n// ---------------------------------------------------------------------------\n\n/** All supported element type identifiers. */\nexport const ELEMENT_TYPES = [\n 'payment',\n 'card',\n 'cardNumber',\n 'cardExpiry',\n 'cardCvc',\n 'address',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Supported Card Brands\n// ---------------------------------------------------------------------------\n\nexport const SUPPORTED_CARD_BRANDS = [\n 'visa',\n 'mastercard',\n 'mastercard_debit',\n 'amex',\n 'discover',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Currency Mapping (from checkout project)\n// ---------------------------------------------------------------------------\n\n/** Country code to currency information mapping. */\nexport const CURRENCY_MAP: Record<string, CurrencyInfo> = {\n // EUR (VAT applies)\n AT: { currency: 'EUR', symbol: '\\u20AC', country: 'Austria', countryCode: 'AT', tax: 1 },\n BE: { currency: 'EUR', symbol: '\\u20AC', country: 'Belgium', countryCode: 'BE', tax: 1 },\n CY: { currency: 'EUR', symbol: '\\u20AC', country: 'Cyprus', countryCode: 'CY', tax: 1 },\n DE: { currency: 'EUR', symbol: '\\u20AC', country: 'Germany', countryCode: 'DE', tax: 1 },\n EE: { currency: 'EUR', symbol: '\\u20AC', country: 'Estonia', countryCode: 'EE', tax: 1 },\n ES: { currency: 'EUR', symbol: '\\u20AC', country: 'Spain', countryCode: 'ES', tax: 1 },\n FI: { currency: 'EUR', symbol: '\\u20AC', country: 'Finland', countryCode: 'FI', tax: 1 },\n FR: { currency: 'EUR', symbol: '\\u20AC', country: 'France', countryCode: 'FR', tax: 1 },\n GR: { currency: 'EUR', symbol: '\\u20AC', country: 'Greece', countryCode: 'GR', tax: 1 },\n HR: { currency: 'EUR', symbol: '\\u20AC', country: 'Croatia', countryCode: 'HR', tax: 1 },\n IE: { currency: 'EUR', symbol: '\\u20AC', country: 'Ireland', countryCode: 'IE', tax: 1 },\n IT: { currency: 'EUR', symbol: '\\u20AC', country: 'Italy', countryCode: 'IT', tax: 1 },\n LT: { currency: 'EUR', symbol: '\\u20AC', country: 'Lithuania', countryCode: 'LT', tax: 1 },\n LU: { currency: 'EUR', symbol: '\\u20AC', country: 'Luxembourg', countryCode: 'LU', tax: 1 },\n LV: { currency: 'EUR', symbol: '\\u20AC', country: 'Latvia', countryCode: 'LV', tax: 1 },\n MT: { currency: 'EUR', symbol: '\\u20AC', country: 'Malta', countryCode: 'MT', tax: 1 },\n NL: { currency: 'EUR', symbol: '\\u20AC', country: 'Netherlands', countryCode: 'NL', tax: 1 },\n PT: { currency: 'EUR', symbol: '\\u20AC', country: 'Portugal', countryCode: 'PT', tax: 1 },\n SI: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovenia', countryCode: 'SI', tax: 1 },\n SK: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovakia', countryCode: 'SK', tax: 1 },\n BG: { currency: 'EUR', symbol: '\\u20AC', country: 'Bulgaria', countryCode: 'BG', tax: 1 },\n RO: { currency: 'EUR', symbol: '\\u20AC', country: 'Romania', countryCode: 'RO', tax: 1 },\n CZ: { currency: 'EUR', symbol: '\\u20AC', country: 'Czech Republic', countryCode: 'CZ', tax: 1 },\n SE: { currency: 'EUR', symbol: '\\u20AC', country: 'Sweden', countryCode: 'SE', tax: 1 },\n DK: { currency: 'EUR', symbol: '\\u20AC', country: 'Denmark', countryCode: 'DK', tax: 1 },\n PL: { currency: 'EUR', symbol: '\\u20AC', country: 'Poland', countryCode: 'PL', tax: 1 },\n HU: { currency: 'EUR', symbol: '\\u20AC', country: 'Hungary', countryCode: 'HU', tax: 1 },\n // GBP (VAT applies)\n GB: { currency: 'GBP', symbol: '\\u00A3', country: 'United Kingdom', countryCode: 'GB', tax: 1 },\n // USD (no VAT)\n US: { currency: 'USD', symbol: '$', country: 'United States', countryCode: 'US', tax: 0 },\n // CAD (no VAT)\n CA: { currency: 'CAD', symbol: 'CA$', country: 'Canada', countryCode: 'CA', tax: 0 },\n // NZD (no VAT)\n NZ: { currency: 'NZD', symbol: 'NZ$', country: 'New Zealand', countryCode: 'NZ', tax: 0 },\n // AUD (no VAT)\n AU: { currency: 'AUD', symbol: 'AU$', country: 'Australia', countryCode: 'AU', tax: 0 },\n};\n\n/** Default currency info when country is unknown. */\nexport const DEFAULT_CURRENCY: CurrencyInfo = {\n currency: 'USD',\n symbol: '$',\n country: 'United States',\n countryCode: 'US',\n tax: 0,\n};\n\n// ---------------------------------------------------------------------------\n// Postal Code Labels\n// ---------------------------------------------------------------------------\n\n/** Returns the correct postal code label for a country code (ISO 3166-1 alpha-2). */\nexport function getPostalCodeLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'ZIP Code';\n case 'GB': return 'Postcode';\n case 'CA': return 'Postal Code';\n case 'AU':\n case 'NZ': return 'Postcode';\n case 'IE': return 'Eircode';\n default: return 'Postal Code';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Country List (ISO 3166-1 alpha-2)\n// ---------------------------------------------------------------------------\n\nconst regionNames = new Intl.DisplayNames(['en'], { type: 'region' });\n\nfunction codeToFlag(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Priority countries shown first in dropdowns. */\nconst PRIORITY_CODES = ['US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'DE', 'FR'];\n\nconst ALL_CODES = [\n 'AD', 'AE', 'AF', 'AG', 'AL', 'AM', 'AO', 'AR', 'AT', 'AU',\n 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ',\n 'BN', 'BO', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CD',\n 'CF', 'CG', 'CH', 'CI', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',\n 'CV', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',\n 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FM', 'FR', 'GA',\n 'GB', 'GD', 'GE', 'GH', 'GM', 'GN', 'GQ', 'GR', 'GT', 'GW',\n 'GY', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IQ',\n 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI',\n 'KM', 'KN', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',\n 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',\n 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MR', 'MT', 'MU', 'MV',\n 'MW', 'MX', 'MY', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NL', 'NO',\n 'NP', 'NR', 'NZ', 'OM', 'PA', 'PE', 'PG', 'PH', 'PK', 'PL',\n 'PT', 'PW', 'PY', 'QA', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB',\n 'SC', 'SD', 'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'SO',\n 'SR', 'SS', 'ST', 'SV', 'SY', 'SZ', 'TD', 'TG', 'TH', 'TJ',\n 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',\n 'UG', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VN', 'VU', 'WS',\n 'XK', 'YE', 'ZA', 'ZM', 'ZW',\n] as const;\n\nfunction buildCountryOption(code: string): CountryOption {\n return { code, name: regionNames.of(code) ?? code, flag: codeToFlag(code) };\n}\n\nconst prioritySet = new Set(PRIORITY_CODES);\nconst rest = ALL_CODES.filter((c) => !prioritySet.has(c));\n\n/** All countries for dropdown select, priority countries first. */\nexport const COUNTRY_OPTIONS: CountryOption[] = [\n ...PRIORITY_CODES.map(buildCountryOption),\n ...rest.map(buildCountryOption),\n];\n\n/** Look up a country option by ISO 3166-1 alpha-2 code. */\nexport function getCountryByCode(code: string): CountryOption | undefined {\n return COUNTRY_OPTIONS.find((c) => c.code === code);\n}\n\n// ---------------------------------------------------------------------------\n// AVS Configuration Helpers\n// ---------------------------------------------------------------------------\n\n/** Default AVS config when `enableAVS: true` (backward compatible — country + postal code). */\nconst DEFAULT_AVS_CONFIG: AVSFieldConfig = {\n country: true,\n postal_code: true,\n};\n\n/**\n * Normalize `enableAVS` to a resolved config object.\n * - `false` / `undefined` → `null` (AVS disabled)\n * - `true` → default config (country + postal_code)\n * - `AVSFieldConfig` → returned as-is\n */\nexport function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFieldConfig | null {\n if (!enableAVS) return null;\n if (enableAVS === true) return DEFAULT_AVS_CONFIG;\n return enableAVS;\n}\n\n/**\n * Check if an AVS field should be visible for the given country.\n * - `undefined` / `false` → hidden\n * - `true` → visible for all countries\n * - `string[]` → visible only for listed country codes\n */\nexport function isAVSFieldVisible(\n field: boolean | string[] | undefined,\n country: string,\n): boolean {\n if (field === undefined || field === false) return false;\n if (field === true) return true;\n const normalizedCountry = country.trim().toUpperCase();\n return field.some((code) => code.trim().toUpperCase() === normalizedCountry);\n}\n\n/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */\nexport function isAVSEnabled(enableAVS?: boolean | AVSFieldConfig): boolean {\n const config = resolveAVSConfig(enableAVS);\n if (!config) return false;\n return Object.values(config).some(\n (v) => v === true || (Array.isArray(v) && v.length > 0),\n );\n}\n\n// ---------------------------------------------------------------------------\n// US States & CA Provinces\n// ---------------------------------------------------------------------------\n\nexport interface StateOption {\n code: string;\n name: string;\n}\n\nexport const US_STATES: StateOption[] = [\n { code: 'AL', name: 'Alabama' },\n { code: 'AK', name: 'Alaska' },\n { code: 'AZ', name: 'Arizona' },\n { code: 'AR', name: 'Arkansas' },\n { code: 'CA', name: 'California' },\n { code: 'CO', name: 'Colorado' },\n { code: 'CT', name: 'Connecticut' },\n { code: 'DE', name: 'Delaware' },\n { code: 'DC', name: 'District of Columbia' },\n { code: 'FL', name: 'Florida' },\n { code: 'GA', name: 'Georgia' },\n { code: 'HI', name: 'Hawaii' },\n { code: 'ID', name: 'Idaho' },\n { code: 'IL', name: 'Illinois' },\n { code: 'IN', name: 'Indiana' },\n { code: 'IA', name: 'Iowa' },\n { code: 'KS', name: 'Kansas' },\n { code: 'KY', name: 'Kentucky' },\n { code: 'LA', name: 'Louisiana' },\n { code: 'ME', name: 'Maine' },\n { code: 'MD', name: 'Maryland' },\n { code: 'MA', name: 'Massachusetts' },\n { code: 'MI', name: 'Michigan' },\n { code: 'MN', name: 'Minnesota' },\n { code: 'MS', name: 'Mississippi' },\n { code: 'MO', name: 'Missouri' },\n { code: 'MT', name: 'Montana' },\n { code: 'NE', name: 'Nebraska' },\n { code: 'NV', name: 'Nevada' },\n { code: 'NH', name: 'New Hampshire' },\n { code: 'NJ', name: 'New Jersey' },\n { code: 'NM', name: 'New Mexico' },\n { code: 'NY', name: 'New York' },\n { code: 'NC', name: 'North Carolina' },\n { code: 'ND', name: 'North Dakota' },\n { code: 'OH', name: 'Ohio' },\n { code: 'OK', name: 'Oklahoma' },\n { code: 'OR', name: 'Oregon' },\n { code: 'PA', name: 'Pennsylvania' },\n { code: 'RI', name: 'Rhode Island' },\n { code: 'SC', name: 'South Carolina' },\n { code: 'SD', name: 'South Dakota' },\n { code: 'TN', name: 'Tennessee' },\n { code: 'TX', name: 'Texas' },\n { code: 'UT', name: 'Utah' },\n { code: 'VT', name: 'Vermont' },\n { code: 'VA', name: 'Virginia' },\n { code: 'WA', name: 'Washington' },\n { code: 'WV', name: 'West Virginia' },\n { code: 'WI', name: 'Wisconsin' },\n { code: 'WY', name: 'Wyoming' },\n];\n\nexport const CA_PROVINCES: StateOption[] = [\n { code: 'AB', name: 'Alberta' },\n { code: 'BC', name: 'British Columbia' },\n { code: 'MB', name: 'Manitoba' },\n { code: 'NB', name: 'New Brunswick' },\n { code: 'NL', name: 'Newfoundland and Labrador' },\n { code: 'NS', name: 'Nova Scotia' },\n { code: 'NT', name: 'Northwest Territories' },\n { code: 'NU', name: 'Nunavut' },\n { code: 'ON', name: 'Ontario' },\n { code: 'PE', name: 'Prince Edward Island' },\n { code: 'QC', name: 'Quebec' },\n { code: 'SK', name: 'Saskatchewan' },\n { code: 'YT', name: 'Yukon' },\n];\n\n/**\n * Get state/province options for a country.\n * Returns a list for US and CA, or `null` for countries where a free-text input is appropriate.\n */\nexport function getStateOptions(country: string): StateOption[] | null {\n switch (country.toUpperCase()) {\n case 'US': return US_STATES;\n case 'CA': return CA_PROVINCES;\n default: return null;\n }\n}\n\n/** Returns the appropriate label for the state/province field based on country. */\nexport function getStateLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'State';\n case 'CA': return 'Province';\n case 'GB': return 'County';\n case 'AU': return 'State / Territory';\n default: return 'State / Province / Region';\n }\n}\n","import type { CheckoutSession } from './types.js';\n\n/** A single line item formatted for display in the checkout UI. */\nexport interface DisplayLineItem {\n name: string;\n quantity: number;\n /** Price per unit in the session's currency (major units, e.g. 24.95). */\n price: number;\n /** Original price per unit before any discount (major units). */\n originalPrice: number;\n}\n\n/** Computed display data for rendering an order summary. */\nexport interface CheckoutDisplayData {\n /** Individual items/subscriptions with names, prices, and quantities. */\n items: DisplayLineItem[];\n /** ISO 4217 currency code (uppercase). */\n currency: string;\n /** Total amount due after discounts (major units, e.g. 24.95). */\n total: number;\n /** Sum of original prices before discounts (major units). */\n originalTotal: number;\n /** Total savings (originalTotal - total), clamped to >= 0. */\n totalSave: number;\n /** Discount percentage (0–100). */\n discountPercent: number;\n}\n\n/**\n * Builds display data from a `CheckoutSession` for rendering an order summary.\n *\n * Matches the display logic in checkout/CheckoutModal exactly:\n * - Subscriptions are always shown\n * - Items are hidden when the session has both subscriptions AND items\n * - `overrideAmount` (when not null/undefined) is the discounted price\n * - Plan name \"4-WEEK PLAN\" with price <= 1 is renamed to \"7-DAY TRIAL: FULL ACCESS\"\n * - Discount percentage and savings are computed from the difference\n *\n * All amounts are in **major currency units** (dollars, not cents).\n *\n * @example\n * ```ts\n * import { buildCheckoutDisplayData } from '@flopay/shared';\n *\n * const display = buildCheckoutDisplayData(session);\n * // display.items → [{ name: 'Starter', price: 24.95, originalPrice: 24.95, quantity: 1 }]\n * // display.total → 24.95\n * // display.currency → 'EUR'\n * ```\n */\nexport function buildCheckoutDisplayData(session: CheckoutSession): CheckoutDisplayData {\n const itemsList: DisplayLineItem[] = [];\n let currency = 'USD';\n\n const subscriptions = session.subscriptions ?? [];\n const items = session.items ?? [];\n\n // Subscriptions\n for (const sub of subscriptions) {\n const originalPrice = sub.totalAmount;\n const discountedPrice = sub.overrideAmount ?? originalPrice;\n\n // Match checkout/CheckoutModal: rename \"4-WEEK PLAN\" to \"7-DAY TRIAL: FULL ACCESS\"\n // when the discounted price is $1 or less\n let name = sub.providerPlanName || 'Subscription';\n if (name === '4-WEEK PLAN' && discountedPrice <= 1) {\n name = '7-DAY TRIAL: FULL ACCESS';\n }\n\n itemsList.push({\n name,\n quantity: sub.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (sub.currency) currency = sub.currency.toUpperCase();\n }\n\n // Items — hidden when session has both subscriptions and items\n // (matches checkout/CheckoutModal: hideItems logic)\n const hideItems = subscriptions.length > 0 && items.length > 0;\n\n if (!hideItems) {\n for (const item of items) {\n const originalPrice = item.totalAmount;\n const discountedPrice = item.overrideAmount ?? originalPrice;\n\n itemsList.push({\n name: item.providerItemName || 'Item',\n quantity: item.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (item.currency) currency = item.currency.toUpperCase();\n }\n }\n\n // Fallback if session has no items/subscriptions\n if (itemsList.length === 0) {\n itemsList.push({\n name: 'Purchase',\n quantity: 1,\n price: session.amount / 100,\n originalPrice: session.amount / 100,\n });\n currency = session.currency?.toUpperCase() ?? 'USD';\n }\n\n const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);\n const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);\n const totalSave = Math.max(0, originalTotal - total);\n const discountPercent = originalTotal > 0\n ? Math.round((totalSave / originalTotal) * 100)\n : 0;\n\n return {\n items: itemsList,\n currency,\n total,\n originalTotal,\n totalSave,\n discountPercent,\n };\n}\n","import type { CurrencyInfo } from './types.js';\nimport { CURRENCY_MAP, DEFAULT_CURRENCY } from './constants.js';\n\n/**\n * Look up currency information by ISO 3166-1 alpha-2 country code.\n * Falls back to USD when the country is not in the map.\n */\nexport function getCurrencyByCountry(countryCode: string): CurrencyInfo {\n return CURRENCY_MAP[countryCode.toUpperCase()] ?? DEFAULT_CURRENCY;\n}\n\n/** Returns `true` if the string looks like a Stripe publishable key. */\nexport function isValidPublishableKey(key: string): boolean {\n return /^pk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n\n/** Returns `true` if the string looks like a Stripe secret key. */\nexport function isValidSecretKey(key: string): boolean {\n return /^sk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAMrC,YACE,SACA,MACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO,SAAS;AACrB,SAAK,cAAc,SAAS;AAC5B,SAAK,QAAQ,SAAS;AAGtB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAOO,SAAS,gBACd,SACA,OACa;AACb,SAAO,IAAI,YAAY,SAAS,oBAAoB,EAAE,MAAM,CAAC;AAC/D;AAGO,SAAS,SACd,SACA,MACa;AACb,SAAO,IAAI,YAAY,SAAS,aAAa,EAAE,KAAK,CAAC;AACvD;AAGO,SAAS,oBAAoB,SAA8B;AAChE,SAAO,IAAI,YAAY,SAAS,sBAAsB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../src/config.ts","../src/constants.ts","../src/postal-code-lookup.ts","../src/display.ts","../src/validation.ts"],"sourcesContent":["// Types\nexport type {\n FloPayThemeVariables,\n FloPayAppearance,\n Customer,\n RecurringInterval,\n PriceData,\n LineItem,\n CheckoutMode,\n CheckoutSession,\n CheckoutSessionItem,\n CheckoutSessionSubscription,\n PaymentResult,\n ConfirmPaymentParams,\n CreatePaymentMethodResult,\n ConfirmCardPaymentParams,\n ConfirmCardPaymentResult,\n ElementType,\n ElementChangeEvent,\n ElementOptions,\n MountedElement,\n FloPayConfig,\n PaymentProviderAdapter,\n BillingProvider,\n TokenizedBody,\n CheckoutProcessError,\n CheckoutModeKind,\n NormalizedCheckoutSession,\n CheckoutItem,\n CheckoutSubscription,\n CheckoutAccount,\n TagsData,\n CreateSessionParams,\n CheckoutSessionResult,\n ProcessPaymentParams,\n CreateCustomerParams,\n UpdateCustomerParams,\n WebhookEvent,\n CurrencyInfo,\n CountryOption,\n ButtonsLayoutStyles,\n ButtonsLayoutTheme,\n AVSFieldConfig,\n InlineSessionParams,\n InlineSessionDraft,\n InlineSessionPatch,\n BeforeButtonClickEvent,\n CheckoutButtonMethod,\n DeclineEvent,\n BillingDetails,\n} from './types.js';\n\n// Errors\nexport {\n FloPayError,\n validationError,\n apiError,\n authenticationError,\n rateLimitError,\n networkError,\n} from './errors.js';\nexport type { FloPayErrorType } from './errors.js';\n\n// Configuration\nexport { configureFlopay, getConfiguredBillingApiUrl, getFloPayEnvironment } from './config.js';\nexport type { FloPayEnvironment } from './config.js';\n\n// Constants\nexport {\n SDK_VERSION,\n DEFAULT_API_BASE_URL,\n DEFAULT_API_VERSION,\n BILLING_API_URL,\n BILLING_API_URL_STAGING,\n BILLING_API_URL_PRODUCTION,\n resolveBillingApiUrl,\n DEFAULT_APPEARANCE,\n FLAT_APPEARANCE,\n NIGHT_APPEARANCE,\n ELEMENT_TYPES,\n SUPPORTED_CARD_BRANDS,\n CURRENCY_MAP,\n DEFAULT_CURRENCY,\n BUTTONS_LAYOUT_DEFAULT,\n BUTTONS_LAYOUT_MINIMAL,\n BUTTONS_LAYOUT_ROUNDED,\n BUTTONS_LAYOUT_DARK,\n resolveButtonsLayoutTheme,\n getPostalCodeLabel,\n COUNTRY_OPTIONS,\n getCountryByCode,\n resolveAVSConfig,\n isAVSFieldVisible,\n isAVSEnabled,\n US_STATES,\n CA_PROVINCES,\n getStateOptions,\n getStateLabel,\n type StateOption,\n} from './constants.js';\n\n// Postal code lookups\nexport { getStateFromPostalCode } from './postal-code-lookup.js';\n\n// Display helpers\nexport { buildCheckoutDisplayData } from './display.js';\nexport type { DisplayLineItem, CheckoutDisplayData } from './display.js';\n\n// Validation helpers\nexport {\n getCurrencyByCountry,\n isValidPublishableKey,\n isValidSecretKey,\n} from './validation.js';\n","/** Discriminated error types returned by the FloPay SDK. */\nexport type FloPayErrorType =\n | 'validation_error'\n | 'api_error'\n | 'authentication_error'\n | 'rate_limit_error'\n | 'network_error';\n\n/**\n * Custom error class for all FloPay SDK errors.\n *\n * Extends the native `Error` and adds structured fields that mirror\n * Stripe-style error responses for familiarity.\n */\nexport class FloPayError extends Error {\n readonly type: FloPayErrorType;\n readonly code?: string;\n readonly declineCode?: string;\n readonly param?: string;\n\n constructor(\n message: string,\n type: FloPayErrorType,\n options?: { code?: string; declineCode?: string; param?: string },\n ) {\n super(message);\n this.name = 'FloPayError';\n this.type = type;\n this.code = options?.code;\n this.declineCode = options?.declineCode;\n this.param = options?.param;\n\n // Restore prototype chain (required when extending built-ins)\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error Factories\n// ---------------------------------------------------------------------------\n\n/** Create a validation error (e.g. missing required field). */\nexport function validationError(\n message: string,\n param?: string,\n): FloPayError {\n return new FloPayError(message, 'validation_error', { param });\n}\n\n/** Create an API error (e.g. upstream provider returned an error). */\nexport function apiError(\n message: string,\n code?: string,\n): FloPayError {\n return new FloPayError(message, 'api_error', { code });\n}\n\n/** Create an authentication error (e.g. invalid publishable key). */\nexport function authenticationError(message: string): FloPayError {\n return new FloPayError(message, 'authentication_error');\n}\n\n/** Create a rate limit error. */\nexport function rateLimitError(message: string): FloPayError {\n return new FloPayError(message, 'rate_limit_error');\n}\n\n/** Create a network error (e.g. fetch failed). */\nexport function networkError(message: string): FloPayError {\n return new FloPayError(message, 'network_error');\n}\n","/** FloPay environment — determines which billing API URL is used. */\nexport type FloPayEnvironment = 'staging' | 'production' | 'local';\n\nconst ENV_URL_MAP: Record<FloPayEnvironment, string> = {\n local: 'https://flo.ngrok.pro',\n staging: 'https://api.stage.flopay.com',\n production: 'https://api.flopay.com',\n};\n\nlet globalEnvironment: FloPayEnvironment = 'staging';\n\n/**\n * Configure the FloPay SDK globally. Call once at app startup.\n *\n * The environment determines which billing API URL is used for all\n * FloPay operations (session creation, payment processing, etc.).\n *\n * @example\n * ```ts\n * import { configureFlopay } from '@flopay/shared';\n *\n * // In production\n * configureFlopay({ environment: 'production' });\n *\n * // In staging/development\n * configureFlopay({ environment: 'staging' });\n * ```\n *\n * Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable\n * to `'staging'` or `'production'` — the SDK reads it automatically.\n */\nexport function configureFlopay(config: { environment: FloPayEnvironment }): void {\n globalEnvironment = config.environment;\n}\n\n/** Get the billing API URL for the currently configured environment. */\nexport function getConfiguredBillingApiUrl(): string {\n return ENV_URL_MAP[globalEnvironment];\n}\n\n/** Get the current configured environment. */\nexport function getFloPayEnvironment(): FloPayEnvironment {\n return globalEnvironment;\n}\n","import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CountryOption, CurrencyInfo, FloPayAppearance } from './types.js';\n\nimport type { FloPayEnvironment } from './config.js';\nimport { getConfiguredBillingApiUrl } from './config.js';\n\n// ---------------------------------------------------------------------------\n// SDK Version & API\n// ---------------------------------------------------------------------------\n\n/** Current SDK version. */\nexport const SDK_VERSION = '0.5.3';\n\n/** Billing API URL for staging environment. */\nexport const BILLING_API_URL_STAGING = 'https://api.stage.flopay.com';\n\n/** Billing API URL for production environment. */\nexport const BILLING_API_URL_PRODUCTION = 'https://api.flopay.com';\n\n/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */\nexport const DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;\n\n/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */\nexport const BILLING_API_URL = BILLING_API_URL_STAGING;\n\n/**\n * Resolve the billing API URL from available configuration.\n *\n * Priority:\n * 1. Explicit `billingApiUrl` (prop/param override)\n * 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)\n * 3. `configureFlopay()` global environment setting\n * 4. Fallback: staging URL\n *\n * @example\n * ```ts\n * import { resolveBillingApiUrl } from '@flopay/shared';\n *\n * // Reads from env var or configureFlopay() — no args needed\n * const url = resolveBillingApiUrl();\n *\n * // Explicit override takes priority\n * const url = resolveBillingApiUrl('https://custom.example.com');\n * ```\n */\nexport function resolveBillingApiUrl(billingApiUrl?: string): string {\n if (billingApiUrl) return billingApiUrl;\n\n // Environment variable (works in Next.js and bundlers that inline process.env)\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_FLOPAY_ENV) {\n const env = process.env.NEXT_PUBLIC_FLOPAY_ENV as FloPayEnvironment;\n if (env === 'production') return BILLING_API_URL_PRODUCTION;\n return BILLING_API_URL_STAGING;\n }\n\n // Global config from configureFlopay()\n return getConfiguredBillingApiUrl();\n}\n\n/** Default API version header value. */\nexport const DEFAULT_API_VERSION = '2024-01-01';\n\n// ---------------------------------------------------------------------------\n// Default Themes\n// ---------------------------------------------------------------------------\n\n/** The default appearance applied when no custom appearance is provided. */\nexport const DEFAULT_APPEARANCE: FloPayAppearance = {\n theme: 'default',\n variables: {\n colorPrimary: '#4A49FF',\n colorBackground: '#FFFFFF',\n colorText: '#262833',\n colorDanger: '#DF1B41',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n/** Flat theme — minimal borders and shadows. */\nexport const FLAT_APPEARANCE: FloPayAppearance = {\n theme: 'flat',\n variables: {\n ...DEFAULT_APPEARANCE.variables,\n borderRadius: '4px',\n },\n};\n\n/** Night theme — dark background. */\nexport const NIGHT_APPEARANCE: FloPayAppearance = {\n theme: 'night',\n variables: {\n colorPrimary: '#7B7BFF',\n colorBackground: '#1A1A2E',\n colorText: '#E0E0E0',\n colorDanger: '#FF6B6B',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Buttons Layout Theme Presets\n// ---------------------------------------------------------------------------\n\n/** Default buttons layout — white card button, neutral borders. */\nexport const BUTTONS_LAYOUT_DEFAULT: ButtonsLayoutStyles = {};\n\n/** Minimal buttons layout — borderless, subtle hover. */\nexport const BUTTONS_LAYOUT_MINIMAL: ButtonsLayoutStyles = {\n cardButton: {\n border: 'none',\n backgroundColor: '#f9fafb',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#f9fafb',\n border: 'none',\n },\n cardInputBorder: '#e5e7eb',\n backButtonIcon: {\n backgroundColor: '#e5e7eb',\n },\n submitButton: {\n borderRadius: '6px',\n },\n};\n\n/** Rounded buttons layout — large border radius, soft shadows. */\nexport const BUTTONS_LAYOUT_ROUNDED: ButtonsLayoutStyles = {\n cardButton: {\n borderRadius: '9999px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 1px 3px rgba(0,0,0,0.06)',\n },\n cardFormContainer: {\n borderRadius: '16px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 2px 8px rgba(0,0,0,0.06)',\n },\n cardInputBorder: '#d1d5db',\n submitButton: {\n borderRadius: '9999px',\n },\n backButtonIcon: {\n backgroundColor: '#f3f4f6',\n },\n};\n\n/** Dark buttons layout — dark backgrounds, light text. */\nexport const BUTTONS_LAYOUT_DARK: ButtonsLayoutStyles = {\n cardButton: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n border: '1px solid #374151',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#111827',\n border: '1px solid #374151',\n },\n cardInputBorder: '#4b5563',\n cardInputColor: '#f9fafb',\n cardInputPlaceholderColor: '#6b7280',\n cardInputBackground: '#1f2937',\n nameInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n backButton: {\n color: '#9ca3af',\n },\n backButtonIcon: {\n backgroundColor: '#374151',\n },\n submitButton: {\n backgroundColor: '#6366f1',\n },\n title: {\n color: '#f9fafb',\n },\n countrySelect: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n zipInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n};\n\n/** Resolve a buttons layout theme name to its style preset. */\nexport function resolveButtonsLayoutTheme(theme?: ButtonsLayoutTheme): ButtonsLayoutStyles {\n switch (theme) {\n case 'minimal': return BUTTONS_LAYOUT_MINIMAL;\n case 'rounded': return BUTTONS_LAYOUT_ROUNDED;\n case 'dark': return BUTTONS_LAYOUT_DARK;\n default: return BUTTONS_LAYOUT_DEFAULT;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Supported Element Types\n// ---------------------------------------------------------------------------\n\n/** All supported element type identifiers. */\nexport const ELEMENT_TYPES = [\n 'payment',\n 'card',\n 'cardNumber',\n 'cardExpiry',\n 'cardCvc',\n 'address',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Supported Card Brands\n// ---------------------------------------------------------------------------\n\nexport const SUPPORTED_CARD_BRANDS = [\n 'visa',\n 'mastercard',\n 'mastercard_debit',\n 'amex',\n 'discover',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Currency Mapping (from checkout project)\n// ---------------------------------------------------------------------------\n\n/** Country code to currency information mapping. */\nexport const CURRENCY_MAP: Record<string, CurrencyInfo> = {\n // EUR (VAT applies)\n AT: { currency: 'EUR', symbol: '\\u20AC', country: 'Austria', countryCode: 'AT', tax: 1 },\n BE: { currency: 'EUR', symbol: '\\u20AC', country: 'Belgium', countryCode: 'BE', tax: 1 },\n CY: { currency: 'EUR', symbol: '\\u20AC', country: 'Cyprus', countryCode: 'CY', tax: 1 },\n DE: { currency: 'EUR', symbol: '\\u20AC', country: 'Germany', countryCode: 'DE', tax: 1 },\n EE: { currency: 'EUR', symbol: '\\u20AC', country: 'Estonia', countryCode: 'EE', tax: 1 },\n ES: { currency: 'EUR', symbol: '\\u20AC', country: 'Spain', countryCode: 'ES', tax: 1 },\n FI: { currency: 'EUR', symbol: '\\u20AC', country: 'Finland', countryCode: 'FI', tax: 1 },\n FR: { currency: 'EUR', symbol: '\\u20AC', country: 'France', countryCode: 'FR', tax: 1 },\n GR: { currency: 'EUR', symbol: '\\u20AC', country: 'Greece', countryCode: 'GR', tax: 1 },\n HR: { currency: 'EUR', symbol: '\\u20AC', country: 'Croatia', countryCode: 'HR', tax: 1 },\n IE: { currency: 'EUR', symbol: '\\u20AC', country: 'Ireland', countryCode: 'IE', tax: 1 },\n IT: { currency: 'EUR', symbol: '\\u20AC', country: 'Italy', countryCode: 'IT', tax: 1 },\n LT: { currency: 'EUR', symbol: '\\u20AC', country: 'Lithuania', countryCode: 'LT', tax: 1 },\n LU: { currency: 'EUR', symbol: '\\u20AC', country: 'Luxembourg', countryCode: 'LU', tax: 1 },\n LV: { currency: 'EUR', symbol: '\\u20AC', country: 'Latvia', countryCode: 'LV', tax: 1 },\n MT: { currency: 'EUR', symbol: '\\u20AC', country: 'Malta', countryCode: 'MT', tax: 1 },\n NL: { currency: 'EUR', symbol: '\\u20AC', country: 'Netherlands', countryCode: 'NL', tax: 1 },\n PT: { currency: 'EUR', symbol: '\\u20AC', country: 'Portugal', countryCode: 'PT', tax: 1 },\n SI: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovenia', countryCode: 'SI', tax: 1 },\n SK: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovakia', countryCode: 'SK', tax: 1 },\n BG: { currency: 'EUR', symbol: '\\u20AC', country: 'Bulgaria', countryCode: 'BG', tax: 1 },\n RO: { currency: 'EUR', symbol: '\\u20AC', country: 'Romania', countryCode: 'RO', tax: 1 },\n CZ: { currency: 'EUR', symbol: '\\u20AC', country: 'Czech Republic', countryCode: 'CZ', tax: 1 },\n SE: { currency: 'EUR', symbol: '\\u20AC', country: 'Sweden', countryCode: 'SE', tax: 1 },\n DK: { currency: 'EUR', symbol: '\\u20AC', country: 'Denmark', countryCode: 'DK', tax: 1 },\n PL: { currency: 'EUR', symbol: '\\u20AC', country: 'Poland', countryCode: 'PL', tax: 1 },\n HU: { currency: 'EUR', symbol: '\\u20AC', country: 'Hungary', countryCode: 'HU', tax: 1 },\n // GBP (VAT applies)\n GB: { currency: 'GBP', symbol: '\\u00A3', country: 'United Kingdom', countryCode: 'GB', tax: 1 },\n // USD (no VAT)\n US: { currency: 'USD', symbol: '$', country: 'United States', countryCode: 'US', tax: 0 },\n // CAD (no VAT)\n CA: { currency: 'CAD', symbol: 'CA$', country: 'Canada', countryCode: 'CA', tax: 0 },\n // NZD (no VAT)\n NZ: { currency: 'NZD', symbol: 'NZ$', country: 'New Zealand', countryCode: 'NZ', tax: 0 },\n // AUD (no VAT)\n AU: { currency: 'AUD', symbol: 'AU$', country: 'Australia', countryCode: 'AU', tax: 0 },\n};\n\n/** Default currency info when country is unknown. */\nexport const DEFAULT_CURRENCY: CurrencyInfo = {\n currency: 'USD',\n symbol: '$',\n country: 'United States',\n countryCode: 'US',\n tax: 0,\n};\n\n// ---------------------------------------------------------------------------\n// Postal Code Labels\n// ---------------------------------------------------------------------------\n\n/** Returns the correct postal code label for a country code (ISO 3166-1 alpha-2). */\nexport function getPostalCodeLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'ZIP Code';\n case 'GB': return 'Postcode';\n case 'CA': return 'Postal Code';\n case 'AU':\n case 'NZ': return 'Postcode';\n case 'IE': return 'Eircode';\n default: return 'Postal Code';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Country List (ISO 3166-1 alpha-2)\n// ---------------------------------------------------------------------------\n\nconst regionNames = new Intl.DisplayNames(['en'], { type: 'region' });\n\nfunction codeToFlag(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Priority countries shown first in dropdowns. */\nconst PRIORITY_CODES = ['US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'DE', 'FR'];\n\nconst ALL_CODES = [\n 'AD', 'AE', 'AF', 'AG', 'AL', 'AM', 'AO', 'AR', 'AT', 'AU',\n 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ',\n 'BN', 'BO', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CD',\n 'CF', 'CG', 'CH', 'CI', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',\n 'CV', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',\n 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FM', 'FR', 'GA',\n 'GB', 'GD', 'GE', 'GH', 'GM', 'GN', 'GQ', 'GR', 'GT', 'GW',\n 'GY', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IQ',\n 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI',\n 'KM', 'KN', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',\n 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',\n 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MR', 'MT', 'MU', 'MV',\n 'MW', 'MX', 'MY', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NL', 'NO',\n 'NP', 'NR', 'NZ', 'OM', 'PA', 'PE', 'PG', 'PH', 'PK', 'PL',\n 'PT', 'PW', 'PY', 'QA', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB',\n 'SC', 'SD', 'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'SO',\n 'SR', 'SS', 'ST', 'SV', 'SY', 'SZ', 'TD', 'TG', 'TH', 'TJ',\n 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',\n 'UG', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VN', 'VU', 'WS',\n 'XK', 'YE', 'ZA', 'ZM', 'ZW',\n] as const;\n\nfunction buildCountryOption(code: string): CountryOption {\n return { code, name: regionNames.of(code) ?? code, flag: codeToFlag(code) };\n}\n\nconst prioritySet = new Set(PRIORITY_CODES);\nconst rest = ALL_CODES.filter((c) => !prioritySet.has(c));\n\n/** All countries for dropdown select, priority countries first. */\nexport const COUNTRY_OPTIONS: CountryOption[] = [\n ...PRIORITY_CODES.map(buildCountryOption),\n ...rest.map(buildCountryOption),\n];\n\n/** Look up a country option by ISO 3166-1 alpha-2 code. */\nexport function getCountryByCode(code: string): CountryOption | undefined {\n return COUNTRY_OPTIONS.find((c) => c.code === code);\n}\n\n// ---------------------------------------------------------------------------\n// AVS Configuration Helpers\n// ---------------------------------------------------------------------------\n\n/** Default AVS config when `enableAVS: true` (backward compatible — country + postal code). */\nconst DEFAULT_AVS_CONFIG: AVSFieldConfig = {\n country: true,\n postal_code: true,\n};\n\n/**\n * Normalize `enableAVS` to a resolved config object.\n * - `false` / `undefined` → `null` (AVS disabled)\n * - `true` → default config (country + postal_code)\n * - `AVSFieldConfig` → returned as-is\n */\nexport function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFieldConfig | null {\n if (!enableAVS) return null;\n if (enableAVS === true) return DEFAULT_AVS_CONFIG;\n return enableAVS;\n}\n\n/**\n * Check if an AVS field should be visible for the given country.\n * - `undefined` / `false` → hidden\n * - `true` → visible for all countries\n * - `string[]` → visible only for listed country codes\n */\nexport function isAVSFieldVisible(\n field: boolean | string[] | undefined,\n country: string,\n): boolean {\n if (field === undefined || field === false) return false;\n if (field === true) return true;\n const normalizedCountry = country.trim().toUpperCase();\n return field.some((code) => code.trim().toUpperCase() === normalizedCountry);\n}\n\n/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */\nexport function isAVSEnabled(enableAVS?: boolean | AVSFieldConfig): boolean {\n const config = resolveAVSConfig(enableAVS);\n if (!config) return false;\n return Object.values(config).some(\n (v) => v === true || (Array.isArray(v) && v.length > 0),\n );\n}\n\n// ---------------------------------------------------------------------------\n// US States & CA Provinces\n// ---------------------------------------------------------------------------\n\nexport interface StateOption {\n code: string;\n name: string;\n}\n\nexport const US_STATES: StateOption[] = [\n { code: 'AL', name: 'Alabama' },\n { code: 'AK', name: 'Alaska' },\n { code: 'AZ', name: 'Arizona' },\n { code: 'AR', name: 'Arkansas' },\n { code: 'CA', name: 'California' },\n { code: 'CO', name: 'Colorado' },\n { code: 'CT', name: 'Connecticut' },\n { code: 'DE', name: 'Delaware' },\n { code: 'DC', name: 'District of Columbia' },\n { code: 'FL', name: 'Florida' },\n { code: 'GA', name: 'Georgia' },\n { code: 'HI', name: 'Hawaii' },\n { code: 'ID', name: 'Idaho' },\n { code: 'IL', name: 'Illinois' },\n { code: 'IN', name: 'Indiana' },\n { code: 'IA', name: 'Iowa' },\n { code: 'KS', name: 'Kansas' },\n { code: 'KY', name: 'Kentucky' },\n { code: 'LA', name: 'Louisiana' },\n { code: 'ME', name: 'Maine' },\n { code: 'MD', name: 'Maryland' },\n { code: 'MA', name: 'Massachusetts' },\n { code: 'MI', name: 'Michigan' },\n { code: 'MN', name: 'Minnesota' },\n { code: 'MS', name: 'Mississippi' },\n { code: 'MO', name: 'Missouri' },\n { code: 'MT', name: 'Montana' },\n { code: 'NE', name: 'Nebraska' },\n { code: 'NV', name: 'Nevada' },\n { code: 'NH', name: 'New Hampshire' },\n { code: 'NJ', name: 'New Jersey' },\n { code: 'NM', name: 'New Mexico' },\n { code: 'NY', name: 'New York' },\n { code: 'NC', name: 'North Carolina' },\n { code: 'ND', name: 'North Dakota' },\n { code: 'OH', name: 'Ohio' },\n { code: 'OK', name: 'Oklahoma' },\n { code: 'OR', name: 'Oregon' },\n { code: 'PA', name: 'Pennsylvania' },\n { code: 'RI', name: 'Rhode Island' },\n { code: 'SC', name: 'South Carolina' },\n { code: 'SD', name: 'South Dakota' },\n { code: 'TN', name: 'Tennessee' },\n { code: 'TX', name: 'Texas' },\n { code: 'UT', name: 'Utah' },\n { code: 'VT', name: 'Vermont' },\n { code: 'VA', name: 'Virginia' },\n { code: 'WA', name: 'Washington' },\n { code: 'WV', name: 'West Virginia' },\n { code: 'WI', name: 'Wisconsin' },\n { code: 'WY', name: 'Wyoming' },\n];\n\nexport const CA_PROVINCES: StateOption[] = [\n { code: 'AB', name: 'Alberta' },\n { code: 'BC', name: 'British Columbia' },\n { code: 'MB', name: 'Manitoba' },\n { code: 'NB', name: 'New Brunswick' },\n { code: 'NL', name: 'Newfoundland and Labrador' },\n { code: 'NS', name: 'Nova Scotia' },\n { code: 'NT', name: 'Northwest Territories' },\n { code: 'NU', name: 'Nunavut' },\n { code: 'ON', name: 'Ontario' },\n { code: 'PE', name: 'Prince Edward Island' },\n { code: 'QC', name: 'Quebec' },\n { code: 'SK', name: 'Saskatchewan' },\n { code: 'YT', name: 'Yukon' },\n];\n\n/**\n * Get state/province options for a country.\n * Returns a list for US and CA, or `null` for countries where a free-text input is appropriate.\n */\nexport function getStateOptions(country: string): StateOption[] | null {\n switch (country.toUpperCase()) {\n case 'US': return US_STATES;\n case 'CA': return CA_PROVINCES;\n default: return null;\n }\n}\n\n/** Returns the appropriate label for the state/province field based on country. */\nexport function getStateLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'State';\n case 'CA': return 'Province';\n case 'GB': return 'County';\n case 'AU': return 'State / Territory';\n default: return 'State / Province / Region';\n }\n}\n","/**\n * Postal-code → state derivation for AVS.\n *\n * Used when the form configuration shows `address_line_1` but hides the\n * `state` input — we still want to populate `billing_details.address.state`\n * so Stripe Radar gets a richer address signal. Currently supports US and CA;\n * other countries return `null` (caller should fall back to omitting state).\n */\n\n/**\n * US 3-digit ZIP-prefix ranges → state code (USPS Sectional Center Facility).\n * Sourced from the public USPS SCF table. Each entry is `[startPrefix, endPrefix, stateCode]`,\n * inclusive on both ends. Coverage is contiguous within a state; gaps in the table\n * (e.g. unused 3-digit prefixes) are intentional and resolve to `null`.\n */\nconst US_ZIP_PREFIX_RANGES: ReadonlyArray<readonly [number, number, string]> = [\n [5, 5, 'NY'],\n [10, 27, 'MA'],\n [28, 29, 'RI'],\n [30, 38, 'NH'],\n [39, 49, 'ME'],\n [50, 59, 'VT'],\n [60, 69, 'CT'],\n [70, 89, 'NJ'],\n [100, 149, 'NY'],\n [150, 196, 'PA'],\n [197, 199, 'DE'],\n [200, 205, 'DC'],\n [206, 219, 'MD'],\n [220, 246, 'VA'],\n [247, 268, 'WV'],\n [270, 289, 'NC'],\n [290, 299, 'SC'],\n [300, 319, 'GA'],\n [320, 349, 'FL'],\n [350, 369, 'AL'],\n [370, 385, 'TN'],\n [386, 397, 'MS'],\n [398, 399, 'GA'],\n [400, 427, 'KY'],\n [430, 459, 'OH'],\n [460, 479, 'IN'],\n [480, 499, 'MI'],\n [500, 528, 'IA'],\n [530, 549, 'WI'],\n [550, 567, 'MN'],\n [570, 577, 'SD'],\n [580, 588, 'ND'],\n [590, 599, 'MT'],\n [600, 629, 'IL'],\n [630, 658, 'MO'],\n [660, 679, 'KS'],\n [680, 693, 'NE'],\n [700, 714, 'LA'],\n [716, 729, 'AR'],\n [730, 749, 'OK'],\n [750, 799, 'TX'],\n [800, 816, 'CO'],\n [820, 831, 'WY'],\n [832, 838, 'ID'],\n [840, 847, 'UT'],\n [850, 865, 'AZ'],\n [870, 884, 'NM'],\n [889, 898, 'NV'],\n [900, 961, 'CA'],\n [967, 968, 'HI'],\n [970, 979, 'OR'],\n [980, 994, 'WA'],\n [995, 999, 'AK'],\n];\n\n/**\n * CA postal-code first letter → province code (Forward Sortation Area).\n * The first letter of every Canadian postal code identifies the province\n * uniquely, except `X` which is shared by Northwest Territories and Nunavut\n * — we resolve it to `NT` because the volume strongly favours NT.\n */\nconst CA_FSA_FIRST_LETTER_TO_PROVINCE: Readonly<Record<string, string>> = {\n A: 'NL',\n B: 'NS',\n C: 'PE',\n E: 'NB',\n G: 'QC',\n H: 'QC',\n J: 'QC',\n K: 'ON',\n L: 'ON',\n M: 'ON',\n N: 'ON',\n P: 'ON',\n R: 'MB',\n S: 'SK',\n T: 'AB',\n V: 'BC',\n X: 'NT',\n Y: 'YT',\n};\n\nfunction deriveUsState(zip: string): string | null {\n const digits = zip.replace(/\\D/g, '');\n if (digits.length < 5) return null;\n const prefix = Number.parseInt(digits.slice(0, 3), 10);\n if (!Number.isFinite(prefix)) return null;\n\n for (const [start, end, code] of US_ZIP_PREFIX_RANGES) {\n if (prefix >= start && prefix <= end) return code;\n }\n return null;\n}\n\nfunction deriveCaProvince(postalCode: string): string | null {\n const compact = postalCode.replace(/\\s+/g, '').toUpperCase();\n if (!/^[A-Z]\\d[A-Z]\\d[A-Z]\\d$/.test(compact)) return null;\n const firstLetter = compact[0] ?? '';\n return CA_FSA_FIRST_LETTER_TO_PROVINCE[firstLetter] ?? null;\n}\n\n/**\n * Resolve a state / province code from a postal code for the given country.\n *\n * - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).\n * - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).\n * - All other countries: `null`.\n *\n * Returns `null` when the postal code is malformed or falls in an unmapped\n * range. Callers should treat `null` as \"skip — don't derive\".\n */\nexport function getStateFromPostalCode(\n country: string,\n postalCode: string,\n): string | null {\n if (!country || !postalCode) return null;\n const normalizedCountry = country.trim().toUpperCase();\n const normalizedZip = postalCode.trim();\n if (!normalizedZip) return null;\n\n switch (normalizedCountry) {\n case 'US':\n return deriveUsState(normalizedZip);\n case 'CA':\n return deriveCaProvince(normalizedZip);\n default:\n return null;\n }\n}\n","import type { CheckoutSession } from './types.js';\n\n/** A single line item formatted for display in the checkout UI. */\nexport interface DisplayLineItem {\n name: string;\n quantity: number;\n /** Price per unit in the session's currency (major units, e.g. 24.95). */\n price: number;\n /** Original price per unit before any discount (major units). */\n originalPrice: number;\n}\n\n/** Computed display data for rendering an order summary. */\nexport interface CheckoutDisplayData {\n /** Individual items/subscriptions with names, prices, and quantities. */\n items: DisplayLineItem[];\n /** ISO 4217 currency code (uppercase). */\n currency: string;\n /** Total amount due after discounts (major units, e.g. 24.95). */\n total: number;\n /** Sum of original prices before discounts (major units). */\n originalTotal: number;\n /** Total savings (originalTotal - total), clamped to >= 0. */\n totalSave: number;\n /** Discount percentage (0–100). */\n discountPercent: number;\n}\n\n/**\n * Builds display data from a `CheckoutSession` for rendering an order summary.\n *\n * Matches the display logic in checkout/CheckoutModal exactly:\n * - Subscriptions are always shown\n * - Items are hidden when the session has both subscriptions AND items\n * - `overrideAmount` (when not null/undefined) is the discounted price\n * - Plan name \"4-WEEK PLAN\" with price <= 1 is renamed to \"7-DAY TRIAL: FULL ACCESS\"\n * - Discount percentage and savings are computed from the difference\n *\n * All amounts are in **major currency units** (dollars, not cents).\n *\n * @example\n * ```ts\n * import { buildCheckoutDisplayData } from '@flopay/shared';\n *\n * const display = buildCheckoutDisplayData(session);\n * // display.items → [{ name: 'Starter', price: 24.95, originalPrice: 24.95, quantity: 1 }]\n * // display.total → 24.95\n * // display.currency → 'EUR'\n * ```\n */\nexport function buildCheckoutDisplayData(session: CheckoutSession): CheckoutDisplayData {\n const itemsList: DisplayLineItem[] = [];\n let currency = 'USD';\n\n const subscriptions = session.subscriptions ?? [];\n const items = session.items ?? [];\n\n // Subscriptions\n for (const sub of subscriptions) {\n const originalPrice = sub.totalAmount;\n const discountedPrice = sub.overrideAmount ?? originalPrice;\n\n // Match checkout/CheckoutModal: rename \"4-WEEK PLAN\" to \"7-DAY TRIAL: FULL ACCESS\"\n // when the discounted price is $1 or less\n let name = sub.providerPlanName || 'Subscription';\n if (name === '4-WEEK PLAN' && discountedPrice <= 1) {\n name = '7-DAY TRIAL: FULL ACCESS';\n }\n\n itemsList.push({\n name,\n quantity: sub.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (sub.currency) currency = sub.currency.toUpperCase();\n }\n\n // Items — hidden when session has both subscriptions and items\n // (matches checkout/CheckoutModal: hideItems logic)\n const hideItems = subscriptions.length > 0 && items.length > 0;\n\n if (!hideItems) {\n for (const item of items) {\n const originalPrice = item.totalAmount;\n const discountedPrice = item.overrideAmount ?? originalPrice;\n\n itemsList.push({\n name: item.providerItemName || 'Item',\n quantity: item.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (item.currency) currency = item.currency.toUpperCase();\n }\n }\n\n // Fallback if session has no items/subscriptions\n if (itemsList.length === 0) {\n itemsList.push({\n name: 'Purchase',\n quantity: 1,\n price: session.amount / 100,\n originalPrice: session.amount / 100,\n });\n currency = session.currency?.toUpperCase() ?? 'USD';\n }\n\n const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);\n const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);\n const totalSave = Math.max(0, originalTotal - total);\n const discountPercent = originalTotal > 0\n ? Math.round((totalSave / originalTotal) * 100)\n : 0;\n\n return {\n items: itemsList,\n currency,\n total,\n originalTotal,\n totalSave,\n discountPercent,\n };\n}\n","import type { CurrencyInfo } from './types.js';\nimport { CURRENCY_MAP, DEFAULT_CURRENCY } from './constants.js';\n\n/**\n * Look up currency information by ISO 3166-1 alpha-2 country code.\n * Falls back to USD when the country is not in the map.\n */\nexport function getCurrencyByCountry(countryCode: string): CurrencyInfo {\n return CURRENCY_MAP[countryCode.toUpperCase()] ?? DEFAULT_CURRENCY;\n}\n\n/** Returns `true` if the string looks like a Stripe publishable key. */\nexport function isValidPublishableKey(key: string): boolean {\n return /^pk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n\n/** Returns `true` if the string looks like a Strip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F;AACF;;;ACtHO,SAAS,qBAAqB,aAAmC;AACtE,SAAO,aAAa,YAAY,YAAY,CAAC,KAAK;AACpD;AAGO,SAAS,sBAAsB,KAAsB;AAC1D,SAAO,gCAAgC,KAAK,GAAG;AACjD;AAGO,SAAS,iBAAiB,KAAsB;AACrD,SAAO,gCAAgC,KAAK,GAAG;AACjD;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -730,7 +730,7 @@ declare function getConfiguredBillingApiUrl(): string;
|
|
|
730
730
|
declare function getFloPayEnvironment(): FloPayEnvironment;
|
|
731
731
|
|
|
732
732
|
/** Current SDK version. */
|
|
733
|
-
declare const SDK_VERSION = "0.5.
|
|
733
|
+
declare const SDK_VERSION = "0.5.3";
|
|
734
734
|
/** Billing API URL for staging environment. */
|
|
735
735
|
declare const BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
736
736
|
/** Billing API URL for production environment. */
|
|
@@ -821,6 +821,26 @@ declare function getStateOptions(country: string): StateOption[] | null;
|
|
|
821
821
|
/** Returns the appropriate label for the state/province field based on country. */
|
|
822
822
|
declare function getStateLabel(countryCode: string): string;
|
|
823
823
|
|
|
824
|
+
/**
|
|
825
|
+
* Postal-code → state derivation for AVS.
|
|
826
|
+
*
|
|
827
|
+
* Used when the form configuration shows `address_line_1` but hides the
|
|
828
|
+
* `state` input — we still want to populate `billing_details.address.state`
|
|
829
|
+
* so Stripe Radar gets a richer address signal. Currently supports US and CA;
|
|
830
|
+
* other countries return `null` (caller should fall back to omitting state).
|
|
831
|
+
*/
|
|
832
|
+
/**
|
|
833
|
+
* Resolve a state / province code from a postal code for the given country.
|
|
834
|
+
*
|
|
835
|
+
* - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).
|
|
836
|
+
* - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).
|
|
837
|
+
* - All other countries: `null`.
|
|
838
|
+
*
|
|
839
|
+
* Returns `null` when the postal code is malformed or falls in an unmapped
|
|
840
|
+
* range. Callers should treat `null` as "skip — don't derive".
|
|
841
|
+
*/
|
|
842
|
+
declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
|
|
843
|
+
|
|
824
844
|
/** A single line item formatted for display in the checkout UI. */
|
|
825
845
|
interface DisplayLineItem {
|
|
826
846
|
name: string;
|
|
@@ -879,4 +899,4 @@ declare function isValidPublishableKey(key: string): boolean;
|
|
|
879
899
|
/** Returns `true` if the string looks like a Stripe secret key. */
|
|
880
900
|
declare function isValidSecretKey(key: string): boolean;
|
|
881
901
|
|
|
882
|
-
export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutSession, type CheckoutSessionItem, type CheckoutSessionResult, type CheckoutSessionSubscription, 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, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, SUPPORTED_CARD_BRANDS, type StateOption, type TagsData, type TokenizedBody, US_STATES, type UpdateCustomerParams, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, configureFlopay, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateLabel, getStateOptions, isAVSEnabled, isAVSFieldVisible, isValidPublishableKey, isValidSecretKey, networkError, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, validationError };
|
|
902
|
+
export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutSession, type CheckoutSessionItem, type CheckoutSessionResult, type CheckoutSessionSubscription, 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, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, SUPPORTED_CARD_BRANDS, type StateOption, type TagsData, type TokenizedBody, US_STATES, type UpdateCustomerParams, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, configureFlopay, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, isAVSEnabled, isAVSFieldVisible, isValidPublishableKey, isValidSecretKey, networkError, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, validationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -730,7 +730,7 @@ declare function getConfiguredBillingApiUrl(): string;
|
|
|
730
730
|
declare function getFloPayEnvironment(): FloPayEnvironment;
|
|
731
731
|
|
|
732
732
|
/** Current SDK version. */
|
|
733
|
-
declare const SDK_VERSION = "0.5.
|
|
733
|
+
declare const SDK_VERSION = "0.5.3";
|
|
734
734
|
/** Billing API URL for staging environment. */
|
|
735
735
|
declare const BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
736
736
|
/** Billing API URL for production environment. */
|
|
@@ -821,6 +821,26 @@ declare function getStateOptions(country: string): StateOption[] | null;
|
|
|
821
821
|
/** Returns the appropriate label for the state/province field based on country. */
|
|
822
822
|
declare function getStateLabel(countryCode: string): string;
|
|
823
823
|
|
|
824
|
+
/**
|
|
825
|
+
* Postal-code → state derivation for AVS.
|
|
826
|
+
*
|
|
827
|
+
* Used when the form configuration shows `address_line_1` but hides the
|
|
828
|
+
* `state` input — we still want to populate `billing_details.address.state`
|
|
829
|
+
* so Stripe Radar gets a richer address signal. Currently supports US and CA;
|
|
830
|
+
* other countries return `null` (caller should fall back to omitting state).
|
|
831
|
+
*/
|
|
832
|
+
/**
|
|
833
|
+
* Resolve a state / province code from a postal code for the given country.
|
|
834
|
+
*
|
|
835
|
+
* - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).
|
|
836
|
+
* - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).
|
|
837
|
+
* - All other countries: `null`.
|
|
838
|
+
*
|
|
839
|
+
* Returns `null` when the postal code is malformed or falls in an unmapped
|
|
840
|
+
* range. Callers should treat `null` as "skip — don't derive".
|
|
841
|
+
*/
|
|
842
|
+
declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
|
|
843
|
+
|
|
824
844
|
/** A single line item formatted for display in the checkout UI. */
|
|
825
845
|
interface DisplayLineItem {
|
|
826
846
|
name: string;
|
|
@@ -879,4 +899,4 @@ declare function isValidPublishableKey(key: string): boolean;
|
|
|
879
899
|
/** Returns `true` if the string looks like a Stripe secret key. */
|
|
880
900
|
declare function isValidSecretKey(key: string): boolean;
|
|
881
901
|
|
|
882
|
-
export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutSession, type CheckoutSessionItem, type CheckoutSessionResult, type CheckoutSessionSubscription, 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, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, SUPPORTED_CARD_BRANDS, type StateOption, type TagsData, type TokenizedBody, US_STATES, type UpdateCustomerParams, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, configureFlopay, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateLabel, getStateOptions, isAVSEnabled, isAVSFieldVisible, isValidPublishableKey, isValidSecretKey, networkError, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, validationError };
|
|
902
|
+
export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutSession, type CheckoutSessionItem, type CheckoutSessionResult, type CheckoutSessionSubscription, 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, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, SUPPORTED_CARD_BRANDS, type StateOption, type TagsData, type TokenizedBody, US_STATES, type UpdateCustomerParams, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, configureFlopay, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, isAVSEnabled, isAVSFieldVisible, isValidPublishableKey, isValidSecretKey, networkError, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, validationError };
|
package/dist/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ function getFloPayEnvironment() {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// src/constants.ts
|
|
47
|
-
var SDK_VERSION = "0.5.
|
|
47
|
+
var SDK_VERSION = "0.5.3";
|
|
48
48
|
var BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
49
49
|
var BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
|
|
50
50
|
var DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;
|
|
@@ -590,6 +590,113 @@ function getStateLabel(countryCode) {
|
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
+
// src/postal-code-lookup.ts
|
|
594
|
+
var US_ZIP_PREFIX_RANGES = [
|
|
595
|
+
[5, 5, "NY"],
|
|
596
|
+
[10, 27, "MA"],
|
|
597
|
+
[28, 29, "RI"],
|
|
598
|
+
[30, 38, "NH"],
|
|
599
|
+
[39, 49, "ME"],
|
|
600
|
+
[50, 59, "VT"],
|
|
601
|
+
[60, 69, "CT"],
|
|
602
|
+
[70, 89, "NJ"],
|
|
603
|
+
[100, 149, "NY"],
|
|
604
|
+
[150, 196, "PA"],
|
|
605
|
+
[197, 199, "DE"],
|
|
606
|
+
[200, 205, "DC"],
|
|
607
|
+
[206, 219, "MD"],
|
|
608
|
+
[220, 246, "VA"],
|
|
609
|
+
[247, 268, "WV"],
|
|
610
|
+
[270, 289, "NC"],
|
|
611
|
+
[290, 299, "SC"],
|
|
612
|
+
[300, 319, "GA"],
|
|
613
|
+
[320, 349, "FL"],
|
|
614
|
+
[350, 369, "AL"],
|
|
615
|
+
[370, 385, "TN"],
|
|
616
|
+
[386, 397, "MS"],
|
|
617
|
+
[398, 399, "GA"],
|
|
618
|
+
[400, 427, "KY"],
|
|
619
|
+
[430, 459, "OH"],
|
|
620
|
+
[460, 479, "IN"],
|
|
621
|
+
[480, 499, "MI"],
|
|
622
|
+
[500, 528, "IA"],
|
|
623
|
+
[530, 549, "WI"],
|
|
624
|
+
[550, 567, "MN"],
|
|
625
|
+
[570, 577, "SD"],
|
|
626
|
+
[580, 588, "ND"],
|
|
627
|
+
[590, 599, "MT"],
|
|
628
|
+
[600, 629, "IL"],
|
|
629
|
+
[630, 658, "MO"],
|
|
630
|
+
[660, 679, "KS"],
|
|
631
|
+
[680, 693, "NE"],
|
|
632
|
+
[700, 714, "LA"],
|
|
633
|
+
[716, 729, "AR"],
|
|
634
|
+
[730, 749, "OK"],
|
|
635
|
+
[750, 799, "TX"],
|
|
636
|
+
[800, 816, "CO"],
|
|
637
|
+
[820, 831, "WY"],
|
|
638
|
+
[832, 838, "ID"],
|
|
639
|
+
[840, 847, "UT"],
|
|
640
|
+
[850, 865, "AZ"],
|
|
641
|
+
[870, 884, "NM"],
|
|
642
|
+
[889, 898, "NV"],
|
|
643
|
+
[900, 961, "CA"],
|
|
644
|
+
[967, 968, "HI"],
|
|
645
|
+
[970, 979, "OR"],
|
|
646
|
+
[980, 994, "WA"],
|
|
647
|
+
[995, 999, "AK"]
|
|
648
|
+
];
|
|
649
|
+
var CA_FSA_FIRST_LETTER_TO_PROVINCE = {
|
|
650
|
+
A: "NL",
|
|
651
|
+
B: "NS",
|
|
652
|
+
C: "PE",
|
|
653
|
+
E: "NB",
|
|
654
|
+
G: "QC",
|
|
655
|
+
H: "QC",
|
|
656
|
+
J: "QC",
|
|
657
|
+
K: "ON",
|
|
658
|
+
L: "ON",
|
|
659
|
+
M: "ON",
|
|
660
|
+
N: "ON",
|
|
661
|
+
P: "ON",
|
|
662
|
+
R: "MB",
|
|
663
|
+
S: "SK",
|
|
664
|
+
T: "AB",
|
|
665
|
+
V: "BC",
|
|
666
|
+
X: "NT",
|
|
667
|
+
Y: "YT"
|
|
668
|
+
};
|
|
669
|
+
function deriveUsState(zip) {
|
|
670
|
+
const digits = zip.replace(/\D/g, "");
|
|
671
|
+
if (digits.length < 5) return null;
|
|
672
|
+
const prefix = Number.parseInt(digits.slice(0, 3), 10);
|
|
673
|
+
if (!Number.isFinite(prefix)) return null;
|
|
674
|
+
for (const [start, end, code] of US_ZIP_PREFIX_RANGES) {
|
|
675
|
+
if (prefix >= start && prefix <= end) return code;
|
|
676
|
+
}
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
function deriveCaProvince(postalCode) {
|
|
680
|
+
const compact = postalCode.replace(/\s+/g, "").toUpperCase();
|
|
681
|
+
if (!/^[A-Z]\d[A-Z]\d[A-Z]\d$/.test(compact)) return null;
|
|
682
|
+
const firstLetter = compact[0] ?? "";
|
|
683
|
+
return CA_FSA_FIRST_LETTER_TO_PROVINCE[firstLetter] ?? null;
|
|
684
|
+
}
|
|
685
|
+
function getStateFromPostalCode(country, postalCode) {
|
|
686
|
+
if (!country || !postalCode) return null;
|
|
687
|
+
const normalizedCountry = country.trim().toUpperCase();
|
|
688
|
+
const normalizedZip = postalCode.trim();
|
|
689
|
+
if (!normalizedZip) return null;
|
|
690
|
+
switch (normalizedCountry) {
|
|
691
|
+
case "US":
|
|
692
|
+
return deriveUsState(normalizedZip);
|
|
693
|
+
case "CA":
|
|
694
|
+
return deriveCaProvince(normalizedZip);
|
|
695
|
+
default:
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
593
700
|
// src/display.ts
|
|
594
701
|
function buildCheckoutDisplayData(session) {
|
|
595
702
|
const itemsList = [];
|
|
@@ -689,6 +796,7 @@ export {
|
|
|
689
796
|
getCurrencyByCountry,
|
|
690
797
|
getFloPayEnvironment,
|
|
691
798
|
getPostalCodeLabel,
|
|
799
|
+
getStateFromPostalCode,
|
|
692
800
|
getStateLabel,
|
|
693
801
|
getStateOptions,
|
|
694
802
|
isAVSEnabled,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/config.ts","../src/constants.ts","../src/display.ts","../src/validation.ts"],"sourcesContent":["/** Discriminated error types returned by the FloPay SDK. */\nexport type FloPayErrorType =\n | 'validation_error'\n | 'api_error'\n | 'authentication_error'\n | 'rate_limit_error'\n | 'network_error';\n\n/**\n * Custom error class for all FloPay SDK errors.\n *\n * Extends the native `Error` and adds structured fields that mirror\n * Stripe-style error responses for familiarity.\n */\nexport class FloPayError extends Error {\n readonly type: FloPayErrorType;\n readonly code?: string;\n readonly declineCode?: string;\n readonly param?: string;\n\n constructor(\n message: string,\n type: FloPayErrorType,\n options?: { code?: string; declineCode?: string; param?: string },\n ) {\n super(message);\n this.name = 'FloPayError';\n this.type = type;\n this.code = options?.code;\n this.declineCode = options?.declineCode;\n this.param = options?.param;\n\n // Restore prototype chain (required when extending built-ins)\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error Factories\n// ---------------------------------------------------------------------------\n\n/** Create a validation error (e.g. missing required field). */\nexport function validationError(\n message: string,\n param?: string,\n): FloPayError {\n return new FloPayError(message, 'validation_error', { param });\n}\n\n/** Create an API error (e.g. upstream provider returned an error). */\nexport function apiError(\n message: string,\n code?: string,\n): FloPayError {\n return new FloPayError(message, 'api_error', { code });\n}\n\n/** Create an authentication error (e.g. invalid publishable key). */\nexport function authenticationError(message: string): FloPayError {\n return new FloPayError(message, 'authentication_error');\n}\n\n/** Create a rate limit error. */\nexport function rateLimitError(message: string): FloPayError {\n return new FloPayError(message, 'rate_limit_error');\n}\n\n/** Create a network error (e.g. fetch failed). */\nexport function networkError(message: string): FloPayError {\n return new FloPayError(message, 'network_error');\n}\n","/** FloPay environment — determines which billing API URL is used. */\nexport type FloPayEnvironment = 'staging' | 'production' | 'local';\n\nconst ENV_URL_MAP: Record<FloPayEnvironment, string> = {\n local: 'https://flo.ngrok.pro',\n staging: 'https://api.stage.flopay.com',\n production: 'https://api.flopay.com',\n};\n\nlet globalEnvironment: FloPayEnvironment = 'staging';\n\n/**\n * Configure the FloPay SDK globally. Call once at app startup.\n *\n * The environment determines which billing API URL is used for all\n * FloPay operations (session creation, payment processing, etc.).\n *\n * @example\n * ```ts\n * import { configureFlopay } from '@flopay/shared';\n *\n * // In production\n * configureFlopay({ environment: 'production' });\n *\n * // In staging/development\n * configureFlopay({ environment: 'staging' });\n * ```\n *\n * Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable\n * to `'staging'` or `'production'` — the SDK reads it automatically.\n */\nexport function configureFlopay(config: { environment: FloPayEnvironment }): void {\n globalEnvironment = config.environment;\n}\n\n/** Get the billing API URL for the currently configured environment. */\nexport function getConfiguredBillingApiUrl(): string {\n return ENV_URL_MAP[globalEnvironment];\n}\n\n/** Get the current configured environment. */\nexport function getFloPayEnvironment(): FloPayEnvironment {\n return globalEnvironment;\n}\n","import type { CurrencyInfo, CountryOption, FloPayAppearance, ButtonsLayoutStyles, ButtonsLayoutTheme, AVSFieldConfig } from './types.js';\n\nimport type { FloPayEnvironment } from './config.js';\nimport { getConfiguredBillingApiUrl } from './config.js';\n\n// ---------------------------------------------------------------------------\n// SDK Version & API\n// ---------------------------------------------------------------------------\n\n/** Current SDK version. */\nexport const SDK_VERSION = '0.5.1';\n\n/** Billing API URL for staging environment. */\nexport const BILLING_API_URL_STAGING = 'https://api.stage.flopay.com';\n\n/** Billing API URL for production environment. */\nexport const BILLING_API_URL_PRODUCTION = 'https://api.flopay.com';\n\n/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */\nexport const DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;\n\n/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */\nexport const BILLING_API_URL = BILLING_API_URL_STAGING;\n\n/**\n * Resolve the billing API URL from available configuration.\n *\n * Priority:\n * 1. Explicit `billingApiUrl` (prop/param override)\n * 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)\n * 3. `configureFlopay()` global environment setting\n * 4. Fallback: staging URL\n *\n * @example\n * ```ts\n * import { resolveBillingApiUrl } from '@flopay/shared';\n *\n * // Reads from env var or configureFlopay() — no args needed\n * const url = resolveBillingApiUrl();\n *\n * // Explicit override takes priority\n * const url = resolveBillingApiUrl('https://custom.example.com');\n * ```\n */\nexport function resolveBillingApiUrl(billingApiUrl?: string): string {\n if (billingApiUrl) return billingApiUrl;\n\n // Environment variable (works in Next.js and bundlers that inline process.env)\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_FLOPAY_ENV) {\n const env = process.env.NEXT_PUBLIC_FLOPAY_ENV as FloPayEnvironment;\n if (env === 'production') return BILLING_API_URL_PRODUCTION;\n return BILLING_API_URL_STAGING;\n }\n\n // Global config from configureFlopay()\n return getConfiguredBillingApiUrl();\n}\n\n/** Default API version header value. */\nexport const DEFAULT_API_VERSION = '2024-01-01';\n\n// ---------------------------------------------------------------------------\n// Default Themes\n// ---------------------------------------------------------------------------\n\n/** The default appearance applied when no custom appearance is provided. */\nexport const DEFAULT_APPEARANCE: FloPayAppearance = {\n theme: 'default',\n variables: {\n colorPrimary: '#4A49FF',\n colorBackground: '#FFFFFF',\n colorText: '#262833',\n colorDanger: '#DF1B41',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n/** Flat theme — minimal borders and shadows. */\nexport const FLAT_APPEARANCE: FloPayAppearance = {\n theme: 'flat',\n variables: {\n ...DEFAULT_APPEARANCE.variables,\n borderRadius: '4px',\n },\n};\n\n/** Night theme — dark background. */\nexport const NIGHT_APPEARANCE: FloPayAppearance = {\n theme: 'night',\n variables: {\n colorPrimary: '#7B7BFF',\n colorBackground: '#1A1A2E',\n colorText: '#E0E0E0',\n colorDanger: '#FF6B6B',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Buttons Layout Theme Presets\n// ---------------------------------------------------------------------------\n\n/** Default buttons layout — white card button, neutral borders. */\nexport const BUTTONS_LAYOUT_DEFAULT: ButtonsLayoutStyles = {};\n\n/** Minimal buttons layout — borderless, subtle hover. */\nexport const BUTTONS_LAYOUT_MINIMAL: ButtonsLayoutStyles = {\n cardButton: {\n border: 'none',\n backgroundColor: '#f9fafb',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#f9fafb',\n border: 'none',\n },\n cardInputBorder: '#e5e7eb',\n backButtonIcon: {\n backgroundColor: '#e5e7eb',\n },\n submitButton: {\n borderRadius: '6px',\n },\n};\n\n/** Rounded buttons layout — large border radius, soft shadows. */\nexport const BUTTONS_LAYOUT_ROUNDED: ButtonsLayoutStyles = {\n cardButton: {\n borderRadius: '9999px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 1px 3px rgba(0,0,0,0.06)',\n },\n cardFormContainer: {\n borderRadius: '16px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 2px 8px rgba(0,0,0,0.06)',\n },\n cardInputBorder: '#d1d5db',\n submitButton: {\n borderRadius: '9999px',\n },\n backButtonIcon: {\n backgroundColor: '#f3f4f6',\n },\n};\n\n/** Dark buttons layout — dark backgrounds, light text. */\nexport const BUTTONS_LAYOUT_DARK: ButtonsLayoutStyles = {\n cardButton: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n border: '1px solid #374151',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#111827',\n border: '1px solid #374151',\n },\n cardInputBorder: '#4b5563',\n cardInputColor: '#f9fafb',\n cardInputPlaceholderColor: '#6b7280',\n cardInputBackground: '#1f2937',\n nameInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n backButton: {\n color: '#9ca3af',\n },\n backButtonIcon: {\n backgroundColor: '#374151',\n },\n submitButton: {\n backgroundColor: '#6366f1',\n },\n title: {\n color: '#f9fafb',\n },\n countrySelect: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n zipInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n};\n\n/** Resolve a buttons layout theme name to its style preset. */\nexport function resolveButtonsLayoutTheme(theme?: ButtonsLayoutTheme): ButtonsLayoutStyles {\n switch (theme) {\n case 'minimal': return BUTTONS_LAYOUT_MINIMAL;\n case 'rounded': return BUTTONS_LAYOUT_ROUNDED;\n case 'dark': return BUTTONS_LAYOUT_DARK;\n default: return BUTTONS_LAYOUT_DEFAULT;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Supported Element Types\n// ---------------------------------------------------------------------------\n\n/** All supported element type identifiers. */\nexport const ELEMENT_TYPES = [\n 'payment',\n 'card',\n 'cardNumber',\n 'cardExpiry',\n 'cardCvc',\n 'address',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Supported Card Brands\n// ---------------------------------------------------------------------------\n\nexport const SUPPORTED_CARD_BRANDS = [\n 'visa',\n 'mastercard',\n 'mastercard_debit',\n 'amex',\n 'discover',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Currency Mapping (from checkout project)\n// ---------------------------------------------------------------------------\n\n/** Country code to currency information mapping. */\nexport const CURRENCY_MAP: Record<string, CurrencyInfo> = {\n // EUR (VAT applies)\n AT: { currency: 'EUR', symbol: '\\u20AC', country: 'Austria', countryCode: 'AT', tax: 1 },\n BE: { currency: 'EUR', symbol: '\\u20AC', country: 'Belgium', countryCode: 'BE', tax: 1 },\n CY: { currency: 'EUR', symbol: '\\u20AC', country: 'Cyprus', countryCode: 'CY', tax: 1 },\n DE: { currency: 'EUR', symbol: '\\u20AC', country: 'Germany', countryCode: 'DE', tax: 1 },\n EE: { currency: 'EUR', symbol: '\\u20AC', country: 'Estonia', countryCode: 'EE', tax: 1 },\n ES: { currency: 'EUR', symbol: '\\u20AC', country: 'Spain', countryCode: 'ES', tax: 1 },\n FI: { currency: 'EUR', symbol: '\\u20AC', country: 'Finland', countryCode: 'FI', tax: 1 },\n FR: { currency: 'EUR', symbol: '\\u20AC', country: 'France', countryCode: 'FR', tax: 1 },\n GR: { currency: 'EUR', symbol: '\\u20AC', country: 'Greece', countryCode: 'GR', tax: 1 },\n HR: { currency: 'EUR', symbol: '\\u20AC', country: 'Croatia', countryCode: 'HR', tax: 1 },\n IE: { currency: 'EUR', symbol: '\\u20AC', country: 'Ireland', countryCode: 'IE', tax: 1 },\n IT: { currency: 'EUR', symbol: '\\u20AC', country: 'Italy', countryCode: 'IT', tax: 1 },\n LT: { currency: 'EUR', symbol: '\\u20AC', country: 'Lithuania', countryCode: 'LT', tax: 1 },\n LU: { currency: 'EUR', symbol: '\\u20AC', country: 'Luxembourg', countryCode: 'LU', tax: 1 },\n LV: { currency: 'EUR', symbol: '\\u20AC', country: 'Latvia', countryCode: 'LV', tax: 1 },\n MT: { currency: 'EUR', symbol: '\\u20AC', country: 'Malta', countryCode: 'MT', tax: 1 },\n NL: { currency: 'EUR', symbol: '\\u20AC', country: 'Netherlands', countryCode: 'NL', tax: 1 },\n PT: { currency: 'EUR', symbol: '\\u20AC', country: 'Portugal', countryCode: 'PT', tax: 1 },\n SI: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovenia', countryCode: 'SI', tax: 1 },\n SK: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovakia', countryCode: 'SK', tax: 1 },\n BG: { currency: 'EUR', symbol: '\\u20AC', country: 'Bulgaria', countryCode: 'BG', tax: 1 },\n RO: { currency: 'EUR', symbol: '\\u20AC', country: 'Romania', countryCode: 'RO', tax: 1 },\n CZ: { currency: 'EUR', symbol: '\\u20AC', country: 'Czech Republic', countryCode: 'CZ', tax: 1 },\n SE: { currency: 'EUR', symbol: '\\u20AC', country: 'Sweden', countryCode: 'SE', tax: 1 },\n DK: { currency: 'EUR', symbol: '\\u20AC', country: 'Denmark', countryCode: 'DK', tax: 1 },\n PL: { currency: 'EUR', symbol: '\\u20AC', country: 'Poland', countryCode: 'PL', tax: 1 },\n HU: { currency: 'EUR', symbol: '\\u20AC', country: 'Hungary', countryCode: 'HU', tax: 1 },\n // GBP (VAT applies)\n GB: { currency: 'GBP', symbol: '\\u00A3', country: 'United Kingdom', countryCode: 'GB', tax: 1 },\n // USD (no VAT)\n US: { currency: 'USD', symbol: '$', country: 'United States', countryCode: 'US', tax: 0 },\n // CAD (no VAT)\n CA: { currency: 'CAD', symbol: 'CA$', country: 'Canada', countryCode: 'CA', tax: 0 },\n // NZD (no VAT)\n NZ: { currency: 'NZD', symbol: 'NZ$', country: 'New Zealand', countryCode: 'NZ', tax: 0 },\n // AUD (no VAT)\n AU: { currency: 'AUD', symbol: 'AU$', country: 'Australia', countryCode: 'AU', tax: 0 },\n};\n\n/** Default currency info when country is unknown. */\nexport const DEFAULT_CURRENCY: CurrencyInfo = {\n currency: 'USD',\n symbol: '$',\n country: 'United States',\n countryCode: 'US',\n tax: 0,\n};\n\n// ---------------------------------------------------------------------------\n// Postal Code Labels\n// ---------------------------------------------------------------------------\n\n/** Returns the correct postal code label for a country code (ISO 3166-1 alpha-2). */\nexport function getPostalCodeLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'ZIP Code';\n case 'GB': return 'Postcode';\n case 'CA': return 'Postal Code';\n case 'AU':\n case 'NZ': return 'Postcode';\n case 'IE': return 'Eircode';\n default: return 'Postal Code';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Country List (ISO 3166-1 alpha-2)\n// ---------------------------------------------------------------------------\n\nconst regionNames = new Intl.DisplayNames(['en'], { type: 'region' });\n\nfunction codeToFlag(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Priority countries shown first in dropdowns. */\nconst PRIORITY_CODES = ['US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'DE', 'FR'];\n\nconst ALL_CODES = [\n 'AD', 'AE', 'AF', 'AG', 'AL', 'AM', 'AO', 'AR', 'AT', 'AU',\n 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ',\n 'BN', 'BO', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CD',\n 'CF', 'CG', 'CH', 'CI', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',\n 'CV', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',\n 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FM', 'FR', 'GA',\n 'GB', 'GD', 'GE', 'GH', 'GM', 'GN', 'GQ', 'GR', 'GT', 'GW',\n 'GY', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IQ',\n 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI',\n 'KM', 'KN', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',\n 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',\n 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MR', 'MT', 'MU', 'MV',\n 'MW', 'MX', 'MY', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NL', 'NO',\n 'NP', 'NR', 'NZ', 'OM', 'PA', 'PE', 'PG', 'PH', 'PK', 'PL',\n 'PT', 'PW', 'PY', 'QA', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB',\n 'SC', 'SD', 'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'SO',\n 'SR', 'SS', 'ST', 'SV', 'SY', 'SZ', 'TD', 'TG', 'TH', 'TJ',\n 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',\n 'UG', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VN', 'VU', 'WS',\n 'XK', 'YE', 'ZA', 'ZM', 'ZW',\n] as const;\n\nfunction buildCountryOption(code: string): CountryOption {\n return { code, name: regionNames.of(code) ?? code, flag: codeToFlag(code) };\n}\n\nconst prioritySet = new Set(PRIORITY_CODES);\nconst rest = ALL_CODES.filter((c) => !prioritySet.has(c));\n\n/** All countries for dropdown select, priority countries first. */\nexport const COUNTRY_OPTIONS: CountryOption[] = [\n ...PRIORITY_CODES.map(buildCountryOption),\n ...rest.map(buildCountryOption),\n];\n\n/** Look up a country option by ISO 3166-1 alpha-2 code. */\nexport function getCountryByCode(code: string): CountryOption | undefined {\n return COUNTRY_OPTIONS.find((c) => c.code === code);\n}\n\n// ---------------------------------------------------------------------------\n// AVS Configuration Helpers\n// ---------------------------------------------------------------------------\n\n/** Default AVS config when `enableAVS: true` (backward compatible — country + postal code). */\nconst DEFAULT_AVS_CONFIG: AVSFieldConfig = {\n country: true,\n postal_code: true,\n};\n\n/**\n * Normalize `enableAVS` to a resolved config object.\n * - `false` / `undefined` → `null` (AVS disabled)\n * - `true` → default config (country + postal_code)\n * - `AVSFieldConfig` → returned as-is\n */\nexport function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFieldConfig | null {\n if (!enableAVS) return null;\n if (enableAVS === true) return DEFAULT_AVS_CONFIG;\n return enableAVS;\n}\n\n/**\n * Check if an AVS field should be visible for the given country.\n * - `undefined` / `false` → hidden\n * - `true` → visible for all countries\n * - `string[]` → visible only for listed country codes\n */\nexport function isAVSFieldVisible(\n field: boolean | string[] | undefined,\n country: string,\n): boolean {\n if (field === undefined || field === false) return false;\n if (field === true) return true;\n const normalizedCountry = country.trim().toUpperCase();\n return field.some((code) => code.trim().toUpperCase() === normalizedCountry);\n}\n\n/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */\nexport function isAVSEnabled(enableAVS?: boolean | AVSFieldConfig): boolean {\n const config = resolveAVSConfig(enableAVS);\n if (!config) return false;\n return Object.values(config).some(\n (v) => v === true || (Array.isArray(v) && v.length > 0),\n );\n}\n\n// ---------------------------------------------------------------------------\n// US States & CA Provinces\n// ---------------------------------------------------------------------------\n\nexport interface StateOption {\n code: string;\n name: string;\n}\n\nexport const US_STATES: StateOption[] = [\n { code: 'AL', name: 'Alabama' },\n { code: 'AK', name: 'Alaska' },\n { code: 'AZ', name: 'Arizona' },\n { code: 'AR', name: 'Arkansas' },\n { code: 'CA', name: 'California' },\n { code: 'CO', name: 'Colorado' },\n { code: 'CT', name: 'Connecticut' },\n { code: 'DE', name: 'Delaware' },\n { code: 'DC', name: 'District of Columbia' },\n { code: 'FL', name: 'Florida' },\n { code: 'GA', name: 'Georgia' },\n { code: 'HI', name: 'Hawaii' },\n { code: 'ID', name: 'Idaho' },\n { code: 'IL', name: 'Illinois' },\n { code: 'IN', name: 'Indiana' },\n { code: 'IA', name: 'Iowa' },\n { code: 'KS', name: 'Kansas' },\n { code: 'KY', name: 'Kentucky' },\n { code: 'LA', name: 'Louisiana' },\n { code: 'ME', name: 'Maine' },\n { code: 'MD', name: 'Maryland' },\n { code: 'MA', name: 'Massachusetts' },\n { code: 'MI', name: 'Michigan' },\n { code: 'MN', name: 'Minnesota' },\n { code: 'MS', name: 'Mississippi' },\n { code: 'MO', name: 'Missouri' },\n { code: 'MT', name: 'Montana' },\n { code: 'NE', name: 'Nebraska' },\n { code: 'NV', name: 'Nevada' },\n { code: 'NH', name: 'New Hampshire' },\n { code: 'NJ', name: 'New Jersey' },\n { code: 'NM', name: 'New Mexico' },\n { code: 'NY', name: 'New York' },\n { code: 'NC', name: 'North Carolina' },\n { code: 'ND', name: 'North Dakota' },\n { code: 'OH', name: 'Ohio' },\n { code: 'OK', name: 'Oklahoma' },\n { code: 'OR', name: 'Oregon' },\n { code: 'PA', name: 'Pennsylvania' },\n { code: 'RI', name: 'Rhode Island' },\n { code: 'SC', name: 'South Carolina' },\n { code: 'SD', name: 'South Dakota' },\n { code: 'TN', name: 'Tennessee' },\n { code: 'TX', name: 'Texas' },\n { code: 'UT', name: 'Utah' },\n { code: 'VT', name: 'Vermont' },\n { code: 'VA', name: 'Virginia' },\n { code: 'WA', name: 'Washington' },\n { code: 'WV', name: 'West Virginia' },\n { code: 'WI', name: 'Wisconsin' },\n { code: 'WY', name: 'Wyoming' },\n];\n\nexport const CA_PROVINCES: StateOption[] = [\n { code: 'AB', name: 'Alberta' },\n { code: 'BC', name: 'British Columbia' },\n { code: 'MB', name: 'Manitoba' },\n { code: 'NB', name: 'New Brunswick' },\n { code: 'NL', name: 'Newfoundland and Labrador' },\n { code: 'NS', name: 'Nova Scotia' },\n { code: 'NT', name: 'Northwest Territories' },\n { code: 'NU', name: 'Nunavut' },\n { code: 'ON', name: 'Ontario' },\n { code: 'PE', name: 'Prince Edward Island' },\n { code: 'QC', name: 'Quebec' },\n { code: 'SK', name: 'Saskatchewan' },\n { code: 'YT', name: 'Yukon' },\n];\n\n/**\n * Get state/province options for a country.\n * Returns a list for US and CA, or `null` for countries where a free-text input is appropriate.\n */\nexport function getStateOptions(country: string): StateOption[] | null {\n switch (country.toUpperCase()) {\n case 'US': return US_STATES;\n case 'CA': return CA_PROVINCES;\n default: return null;\n }\n}\n\n/** Returns the appropriate label for the state/province field based on country. */\nexport function getStateLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'State';\n case 'CA': return 'Province';\n case 'GB': return 'County';\n case 'AU': return 'State / Territory';\n default: return 'State / Province / Region';\n }\n}\n","import type { CheckoutSession } from './types.js';\n\n/** A single line item formatted for display in the checkout UI. */\nexport interface DisplayLineItem {\n name: string;\n quantity: number;\n /** Price per unit in the session's currency (major units, e.g. 24.95). */\n price: number;\n /** Original price per unit before any discount (major units). */\n originalPrice: number;\n}\n\n/** Computed display data for rendering an order summary. */\nexport interface CheckoutDisplayData {\n /** Individual items/subscriptions with names, prices, and quantities. */\n items: DisplayLineItem[];\n /** ISO 4217 currency code (uppercase). */\n currency: string;\n /** Total amount due after discounts (major units, e.g. 24.95). */\n total: number;\n /** Sum of original prices before discounts (major units). */\n originalTotal: number;\n /** Total savings (originalTotal - total), clamped to >= 0. */\n totalSave: number;\n /** Discount percentage (0–100). */\n discountPercent: number;\n}\n\n/**\n * Builds display data from a `CheckoutSession` for rendering an order summary.\n *\n * Matches the display logic in checkout/CheckoutModal exactly:\n * - Subscriptions are always shown\n * - Items are hidden when the session has both subscriptions AND items\n * - `overrideAmount` (when not null/undefined) is the discounted price\n * - Plan name \"4-WEEK PLAN\" with price <= 1 is renamed to \"7-DAY TRIAL: FULL ACCESS\"\n * - Discount percentage and savings are computed from the difference\n *\n * All amounts are in **major currency units** (dollars, not cents).\n *\n * @example\n * ```ts\n * import { buildCheckoutDisplayData } from '@flopay/shared';\n *\n * const display = buildCheckoutDisplayData(session);\n * // display.items → [{ name: 'Starter', price: 24.95, originalPrice: 24.95, quantity: 1 }]\n * // display.total → 24.95\n * // display.currency → 'EUR'\n * ```\n */\nexport function buildCheckoutDisplayData(session: CheckoutSession): CheckoutDisplayData {\n const itemsList: DisplayLineItem[] = [];\n let currency = 'USD';\n\n const subscriptions = session.subscriptions ?? [];\n const items = session.items ?? [];\n\n // Subscriptions\n for (const sub of subscriptions) {\n const originalPrice = sub.totalAmount;\n const discountedPrice = sub.overrideAmount ?? originalPrice;\n\n // Match checkout/CheckoutModal: rename \"4-WEEK PLAN\" to \"7-DAY TRIAL: FULL ACCESS\"\n // when the discounted price is $1 or less\n let name = sub.providerPlanName || 'Subscription';\n if (name === '4-WEEK PLAN' && discountedPrice <= 1) {\n name = '7-DAY TRIAL: FULL ACCESS';\n }\n\n itemsList.push({\n name,\n quantity: sub.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (sub.currency) currency = sub.currency.toUpperCase();\n }\n\n // Items — hidden when session has both subscriptions and items\n // (matches checkout/CheckoutModal: hideItems logic)\n const hideItems = subscriptions.length > 0 && items.length > 0;\n\n if (!hideItems) {\n for (const item of items) {\n const originalPrice = item.totalAmount;\n const discountedPrice = item.overrideAmount ?? originalPrice;\n\n itemsList.push({\n name: item.providerItemName || 'Item',\n quantity: item.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (item.currency) currency = item.currency.toUpperCase();\n }\n }\n\n // Fallback if session has no items/subscriptions\n if (itemsList.length === 0) {\n itemsList.push({\n name: 'Purchase',\n quantity: 1,\n price: session.amount / 100,\n originalPrice: session.amount / 100,\n });\n currency = session.currency?.toUpperCase() ?? 'USD';\n }\n\n const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);\n const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);\n const totalSave = Math.max(0, originalTotal - total);\n const discountPercent = originalTotal > 0\n ? Math.round((totalSave / originalTotal) * 100)\n : 0;\n\n return {\n items: itemsList,\n currency,\n total,\n originalTotal,\n totalSave,\n discountPercent,\n };\n}\n","import type { CurrencyInfo } from './types.js';\nimport { CURRENCY_MAP, DEFAULT_CURRENCY } from './constants.js';\n\n/**\n * Look up currency information by ISO 3166-1 alpha-2 country code.\n * Falls back to USD when the country is not in the map.\n */\nexport function getCurrencyByCountry(countryCode: string): CurrencyInfo {\n return CURRENCY_MAP[countryCode.toUpperCase()] ?? DEFAULT_CURRENCY;\n}\n\n/** Returns `true` if the string looks like a Stripe publishable key. */\nexport function isValidPublishableKey(key: string): boolean {\n return /^pk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n\n/** Returns `true` if the string looks like a Stripe secret key. */\nexport function is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UAAU,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC;AACxE,QAAM,YAAY,KAAK,IAAI,GAAG,gBAAgB,KAAK;AACnD,QAAM,kBAAkB,gBAAgB,IACpC,KAAK,MAAO,YAAY,gBAAiB,GAAG,IAC5C;AAEJ,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACtHO,SAAS,qBAAqB,aAAmC;AACtE,SAAO,aAAa,YAAY,YAAY,CAAC,KAAK;AACpD;AAGO,SAAS,sBAAsB,KAAsB;AAC1D,SAAO,gCAAgC,KAAK,GAAG;AACjD;AAGO,SAAS,iBAAiB,KAAsB;AACrD,SAAO,gCAAgC,KAAK,GAAG;AACjD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/config.ts","../src/constants.ts","../src/postal-code-lookup.ts","../src/display.ts","../src/validation.ts"],"sourcesContent":["/** Discriminated error types returned by the FloPay SDK. */\nexport type FloPayErrorType =\n | 'validation_error'\n | 'api_error'\n | 'authentication_error'\n | 'rate_limit_error'\n | 'network_error';\n\n/**\n * Custom error class for all FloPay SDK errors.\n *\n * Extends the native `Error` and adds structured fields that mirror\n * Stripe-style error responses for familiarity.\n */\nexport class FloPayError extends Error {\n readonly type: FloPayErrorType;\n readonly code?: string;\n readonly declineCode?: string;\n readonly param?: string;\n\n constructor(\n message: string,\n type: FloPayErrorType,\n options?: { code?: string; declineCode?: string; param?: string },\n ) {\n super(message);\n this.name = 'FloPayError';\n this.type = type;\n this.code = options?.code;\n this.declineCode = options?.declineCode;\n this.param = options?.param;\n\n // Restore prototype chain (required when extending built-ins)\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error Factories\n// ---------------------------------------------------------------------------\n\n/** Create a validation error (e.g. missing required field). */\nexport function validationError(\n message: string,\n param?: string,\n): FloPayError {\n return new FloPayError(message, 'validation_error', { param });\n}\n\n/** Create an API error (e.g. upstream provider returned an error). */\nexport function apiError(\n message: string,\n code?: string,\n): FloPayError {\n return new FloPayError(message, 'api_error', { code });\n}\n\n/** Create an authentication error (e.g. invalid publishable key). */\nexport function authenticationError(message: string): FloPayError {\n return new FloPayError(message, 'authentication_error');\n}\n\n/** Create a rate limit error. */\nexport function rateLimitError(message: string): FloPayError {\n return new FloPayError(message, 'rate_limit_error');\n}\n\n/** Create a network error (e.g. fetch failed). */\nexport function networkError(message: string): FloPayError {\n return new FloPayError(message, 'network_error');\n}\n","/** FloPay environment — determines which billing API URL is used. */\nexport type FloPayEnvironment = 'staging' | 'production' | 'local';\n\nconst ENV_URL_MAP: Record<FloPayEnvironment, string> = {\n local: 'https://flo.ngrok.pro',\n staging: 'https://api.stage.flopay.com',\n production: 'https://api.flopay.com',\n};\n\nlet globalEnvironment: FloPayEnvironment = 'staging';\n\n/**\n * Configure the FloPay SDK globally. Call once at app startup.\n *\n * The environment determines which billing API URL is used for all\n * FloPay operations (session creation, payment processing, etc.).\n *\n * @example\n * ```ts\n * import { configureFlopay } from '@flopay/shared';\n *\n * // In production\n * configureFlopay({ environment: 'production' });\n *\n * // In staging/development\n * configureFlopay({ environment: 'staging' });\n * ```\n *\n * Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable\n * to `'staging'` or `'production'` — the SDK reads it automatically.\n */\nexport function configureFlopay(config: { environment: FloPayEnvironment }): void {\n globalEnvironment = config.environment;\n}\n\n/** Get the billing API URL for the currently configured environment. */\nexport function getConfiguredBillingApiUrl(): string {\n return ENV_URL_MAP[globalEnvironment];\n}\n\n/** Get the current configured environment. */\nexport function getFloPayEnvironment(): FloPayEnvironment {\n return globalEnvironment;\n}\n","import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CountryOption, CurrencyInfo, FloPayAppearance } from './types.js';\n\nimport type { FloPayEnvironment } from './config.js';\nimport { getConfiguredBillingApiUrl } from './config.js';\n\n// ---------------------------------------------------------------------------\n// SDK Version & API\n// ---------------------------------------------------------------------------\n\n/** Current SDK version. */\nexport const SDK_VERSION = '0.5.3';\n\n/** Billing API URL for staging environment. */\nexport const BILLING_API_URL_STAGING = 'https://api.stage.flopay.com';\n\n/** Billing API URL for production environment. */\nexport const BILLING_API_URL_PRODUCTION = 'https://api.flopay.com';\n\n/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */\nexport const DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;\n\n/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */\nexport const BILLING_API_URL = BILLING_API_URL_STAGING;\n\n/**\n * Resolve the billing API URL from available configuration.\n *\n * Priority:\n * 1. Explicit `billingApiUrl` (prop/param override)\n * 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)\n * 3. `configureFlopay()` global environment setting\n * 4. Fallback: staging URL\n *\n * @example\n * ```ts\n * import { resolveBillingApiUrl } from '@flopay/shared';\n *\n * // Reads from env var or configureFlopay() — no args needed\n * const url = resolveBillingApiUrl();\n *\n * // Explicit override takes priority\n * const url = resolveBillingApiUrl('https://custom.example.com');\n * ```\n */\nexport function resolveBillingApiUrl(billingApiUrl?: string): string {\n if (billingApiUrl) return billingApiUrl;\n\n // Environment variable (works in Next.js and bundlers that inline process.env)\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_FLOPAY_ENV) {\n const env = process.env.NEXT_PUBLIC_FLOPAY_ENV as FloPayEnvironment;\n if (env === 'production') return BILLING_API_URL_PRODUCTION;\n return BILLING_API_URL_STAGING;\n }\n\n // Global config from configureFlopay()\n return getConfiguredBillingApiUrl();\n}\n\n/** Default API version header value. */\nexport const DEFAULT_API_VERSION = '2024-01-01';\n\n// ---------------------------------------------------------------------------\n// Default Themes\n// ---------------------------------------------------------------------------\n\n/** The default appearance applied when no custom appearance is provided. */\nexport const DEFAULT_APPEARANCE: FloPayAppearance = {\n theme: 'default',\n variables: {\n colorPrimary: '#4A49FF',\n colorBackground: '#FFFFFF',\n colorText: '#262833',\n colorDanger: '#DF1B41',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n/** Flat theme — minimal borders and shadows. */\nexport const FLAT_APPEARANCE: FloPayAppearance = {\n theme: 'flat',\n variables: {\n ...DEFAULT_APPEARANCE.variables,\n borderRadius: '4px',\n },\n};\n\n/** Night theme — dark background. */\nexport const NIGHT_APPEARANCE: FloPayAppearance = {\n theme: 'night',\n variables: {\n colorPrimary: '#7B7BFF',\n colorBackground: '#1A1A2E',\n colorText: '#E0E0E0',\n colorDanger: '#FF6B6B',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Buttons Layout Theme Presets\n// ---------------------------------------------------------------------------\n\n/** Default buttons layout — white card button, neutral borders. */\nexport const BUTTONS_LAYOUT_DEFAULT: ButtonsLayoutStyles = {};\n\n/** Minimal buttons layout — borderless, subtle hover. */\nexport const BUTTONS_LAYOUT_MINIMAL: ButtonsLayoutStyles = {\n cardButton: {\n border: 'none',\n backgroundColor: '#f9fafb',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#f9fafb',\n border: 'none',\n },\n cardInputBorder: '#e5e7eb',\n backButtonIcon: {\n backgroundColor: '#e5e7eb',\n },\n submitButton: {\n borderRadius: '6px',\n },\n};\n\n/** Rounded buttons layout — large border radius, soft shadows. */\nexport const BUTTONS_LAYOUT_ROUNDED: ButtonsLayoutStyles = {\n cardButton: {\n borderRadius: '9999px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 1px 3px rgba(0,0,0,0.06)',\n },\n cardFormContainer: {\n borderRadius: '16px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 2px 8px rgba(0,0,0,0.06)',\n },\n cardInputBorder: '#d1d5db',\n submitButton: {\n borderRadius: '9999px',\n },\n backButtonIcon: {\n backgroundColor: '#f3f4f6',\n },\n};\n\n/** Dark buttons layout — dark backgrounds, light text. */\nexport const BUTTONS_LAYOUT_DARK: ButtonsLayoutStyles = {\n cardButton: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n border: '1px solid #374151',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#111827',\n border: '1px solid #374151',\n },\n cardInputBorder: '#4b5563',\n cardInputColor: '#f9fafb',\n cardInputPlaceholderColor: '#6b7280',\n cardInputBackground: '#1f2937',\n nameInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n backButton: {\n color: '#9ca3af',\n },\n backButtonIcon: {\n backgroundColor: '#374151',\n },\n submitButton: {\n backgroundColor: '#6366f1',\n },\n title: {\n color: '#f9fafb',\n },\n countrySelect: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n zipInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n};\n\n/** Resolve a buttons layout theme name to its style preset. */\nexport function resolveButtonsLayoutTheme(theme?: ButtonsLayoutTheme): ButtonsLayoutStyles {\n switch (theme) {\n case 'minimal': return BUTTONS_LAYOUT_MINIMAL;\n case 'rounded': return BUTTONS_LAYOUT_ROUNDED;\n case 'dark': return BUTTONS_LAYOUT_DARK;\n default: return BUTTONS_LAYOUT_DEFAULT;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Supported Element Types\n// ---------------------------------------------------------------------------\n\n/** All supported element type identifiers. */\nexport const ELEMENT_TYPES = [\n 'payment',\n 'card',\n 'cardNumber',\n 'cardExpiry',\n 'cardCvc',\n 'address',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Supported Card Brands\n// ---------------------------------------------------------------------------\n\nexport const SUPPORTED_CARD_BRANDS = [\n 'visa',\n 'mastercard',\n 'mastercard_debit',\n 'amex',\n 'discover',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Currency Mapping (from checkout project)\n// ---------------------------------------------------------------------------\n\n/** Country code to currency information mapping. */\nexport const CURRENCY_MAP: Record<string, CurrencyInfo> = {\n // EUR (VAT applies)\n AT: { currency: 'EUR', symbol: '\\u20AC', country: 'Austria', countryCode: 'AT', tax: 1 },\n BE: { currency: 'EUR', symbol: '\\u20AC', country: 'Belgium', countryCode: 'BE', tax: 1 },\n CY: { currency: 'EUR', symbol: '\\u20AC', country: 'Cyprus', countryCode: 'CY', tax: 1 },\n DE: { currency: 'EUR', symbol: '\\u20AC', country: 'Germany', countryCode: 'DE', tax: 1 },\n EE: { currency: 'EUR', symbol: '\\u20AC', country: 'Estonia', countryCode: 'EE', tax: 1 },\n ES: { currency: 'EUR', symbol: '\\u20AC', country: 'Spain', countryCode: 'ES', tax: 1 },\n FI: { currency: 'EUR', symbol: '\\u20AC', country: 'Finland', countryCode: 'FI', tax: 1 },\n FR: { currency: 'EUR', symbol: '\\u20AC', country: 'France', countryCode: 'FR', tax: 1 },\n GR: { currency: 'EUR', symbol: '\\u20AC', country: 'Greece', countryCode: 'GR', tax: 1 },\n HR: { currency: 'EUR', symbol: '\\u20AC', country: 'Croatia', countryCode: 'HR', tax: 1 },\n IE: { currency: 'EUR', symbol: '\\u20AC', country: 'Ireland', countryCode: 'IE', tax: 1 },\n IT: { currency: 'EUR', symbol: '\\u20AC', country: 'Italy', countryCode: 'IT', tax: 1 },\n LT: { currency: 'EUR', symbol: '\\u20AC', country: 'Lithuania', countryCode: 'LT', tax: 1 },\n LU: { currency: 'EUR', symbol: '\\u20AC', country: 'Luxembourg', countryCode: 'LU', tax: 1 },\n LV: { currency: 'EUR', symbol: '\\u20AC', country: 'Latvia', countryCode: 'LV', tax: 1 },\n MT: { currency: 'EUR', symbol: '\\u20AC', country: 'Malta', countryCode: 'MT', tax: 1 },\n NL: { currency: 'EUR', symbol: '\\u20AC', country: 'Netherlands', countryCode: 'NL', tax: 1 },\n PT: { currency: 'EUR', symbol: '\\u20AC', country: 'Portugal', countryCode: 'PT', tax: 1 },\n SI: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovenia', countryCode: 'SI', tax: 1 },\n SK: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovakia', countryCode: 'SK', tax: 1 },\n BG: { currency: 'EUR', symbol: '\\u20AC', country: 'Bulgaria', countryCode: 'BG', tax: 1 },\n RO: { currency: 'EUR', symbol: '\\u20AC', country: 'Romania', countryCode: 'RO', tax: 1 },\n CZ: { currency: 'EUR', symbol: '\\u20AC', country: 'Czech Republic', countryCode: 'CZ', tax: 1 },\n SE: { currency: 'EUR', symbol: '\\u20AC', country: 'Sweden', countryCode: 'SE', tax: 1 },\n DK: { currency: 'EUR', symbol: '\\u20AC', country: 'Denmark', countryCode: 'DK', tax: 1 },\n PL: { currency: 'EUR', symbol: '\\u20AC', country: 'Poland', countryCode: 'PL', tax: 1 },\n HU: { currency: 'EUR', symbol: '\\u20AC', country: 'Hungary', countryCode: 'HU', tax: 1 },\n // GBP (VAT applies)\n GB: { currency: 'GBP', symbol: '\\u00A3', country: 'United Kingdom', countryCode: 'GB', tax: 1 },\n // USD (no VAT)\n US: { currency: 'USD', symbol: '$', country: 'United States', countryCode: 'US', tax: 0 },\n // CAD (no VAT)\n CA: { currency: 'CAD', symbol: 'CA$', country: 'Canada', countryCode: 'CA', tax: 0 },\n // NZD (no VAT)\n NZ: { currency: 'NZD', symbol: 'NZ$', country: 'New Zealand', countryCode: 'NZ', tax: 0 },\n // AUD (no VAT)\n AU: { currency: 'AUD', symbol: 'AU$', country: 'Australia', countryCode: 'AU', tax: 0 },\n};\n\n/** Default currency info when country is unknown. */\nexport const DEFAULT_CURRENCY: CurrencyInfo = {\n currency: 'USD',\n symbol: '$',\n country: 'United States',\n countryCode: 'US',\n tax: 0,\n};\n\n// ---------------------------------------------------------------------------\n// Postal Code Labels\n// ---------------------------------------------------------------------------\n\n/** Returns the correct postal code label for a country code (ISO 3166-1 alpha-2). */\nexport function getPostalCodeLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'ZIP Code';\n case 'GB': return 'Postcode';\n case 'CA': return 'Postal Code';\n case 'AU':\n case 'NZ': return 'Postcode';\n case 'IE': return 'Eircode';\n default: return 'Postal Code';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Country List (ISO 3166-1 alpha-2)\n// ---------------------------------------------------------------------------\n\nconst regionNames = new Intl.DisplayNames(['en'], { type: 'region' });\n\nfunction codeToFlag(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Priority countries shown first in dropdowns. */\nconst PRIORITY_CODES = ['US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'DE', 'FR'];\n\nconst ALL_CODES = [\n 'AD', 'AE', 'AF', 'AG', 'AL', 'AM', 'AO', 'AR', 'AT', 'AU',\n 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ',\n 'BN', 'BO', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CD',\n 'CF', 'CG', 'CH', 'CI', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',\n 'CV', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',\n 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FM', 'FR', 'GA',\n 'GB', 'GD', 'GE', 'GH', 'GM', 'GN', 'GQ', 'GR', 'GT', 'GW',\n 'GY', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IQ',\n 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI',\n 'KM', 'KN', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',\n 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',\n 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MR', 'MT', 'MU', 'MV',\n 'MW', 'MX', 'MY', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NL', 'NO',\n 'NP', 'NR', 'NZ', 'OM', 'PA', 'PE', 'PG', 'PH', 'PK', 'PL',\n 'PT', 'PW', 'PY', 'QA', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB',\n 'SC', 'SD', 'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'SO',\n 'SR', 'SS', 'ST', 'SV', 'SY', 'SZ', 'TD', 'TG', 'TH', 'TJ',\n 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',\n 'UG', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VN', 'VU', 'WS',\n 'XK', 'YE', 'ZA', 'ZM', 'ZW',\n] as const;\n\nfunction buildCountryOption(code: string): CountryOption {\n return { code, name: regionNames.of(code) ?? code, flag: codeToFlag(code) };\n}\n\nconst prioritySet = new Set(PRIORITY_CODES);\nconst rest = ALL_CODES.filter((c) => !prioritySet.has(c));\n\n/** All countries for dropdown select, priority countries first. */\nexport const COUNTRY_OPTIONS: CountryOption[] = [\n ...PRIORITY_CODES.map(buildCountryOption),\n ...rest.map(buildCountryOption),\n];\n\n/** Look up a country option by ISO 3166-1 alpha-2 code. */\nexport function getCountryByCode(code: string): CountryOption | undefined {\n return COUNTRY_OPTIONS.find((c) => c.code === code);\n}\n\n// ---------------------------------------------------------------------------\n// AVS Configuration Helpers\n// ---------------------------------------------------------------------------\n\n/** Default AVS config when `enableAVS: true` (backward compatible — country + postal code). */\nconst DEFAULT_AVS_CONFIG: AVSFieldConfig = {\n country: true,\n postal_code: true,\n};\n\n/**\n * Normalize `enableAVS` to a resolved config object.\n * - `false` / `undefined` → `null` (AVS disabled)\n * - `true` → default config (country + postal_code)\n * - `AVSFieldConfig` → returned as-is\n */\nexport function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFieldConfig | null {\n if (!enableAVS) return null;\n if (enableAVS === true) return DEFAULT_AVS_CONFIG;\n return enableAVS;\n}\n\n/**\n * Check if an AVS field should be visible for the given country.\n * - `undefined` / `false` → hidden\n * - `true` → visible for all countries\n * - `string[]` → visible only for listed country codes\n */\nexport function isAVSFieldVisible(\n field: boolean | string[] | undefined,\n country: string,\n): boolean {\n if (field === undefined || field === false) return false;\n if (field === true) return true;\n const normalizedCountry = country.trim().toUpperCase();\n return field.some((code) => code.trim().toUpperCase() === normalizedCountry);\n}\n\n/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */\nexport function isAVSEnabled(enableAVS?: boolean | AVSFieldConfig): boolean {\n const config = resolveAVSConfig(enableAVS);\n if (!config) return false;\n return Object.values(config).some(\n (v) => v === true || (Array.isArray(v) && v.length > 0),\n );\n}\n\n// ---------------------------------------------------------------------------\n// US States & CA Provinces\n// ---------------------------------------------------------------------------\n\nexport interface StateOption {\n code: string;\n name: string;\n}\n\nexport const US_STATES: StateOption[] = [\n { code: 'AL', name: 'Alabama' },\n { code: 'AK', name: 'Alaska' },\n { code: 'AZ', name: 'Arizona' },\n { code: 'AR', name: 'Arkansas' },\n { code: 'CA', name: 'California' },\n { code: 'CO', name: 'Colorado' },\n { code: 'CT', name: 'Connecticut' },\n { code: 'DE', name: 'Delaware' },\n { code: 'DC', name: 'District of Columbia' },\n { code: 'FL', name: 'Florida' },\n { code: 'GA', name: 'Georgia' },\n { code: 'HI', name: 'Hawaii' },\n { code: 'ID', name: 'Idaho' },\n { code: 'IL', name: 'Illinois' },\n { code: 'IN', name: 'Indiana' },\n { code: 'IA', name: 'Iowa' },\n { code: 'KS', name: 'Kansas' },\n { code: 'KY', name: 'Kentucky' },\n { code: 'LA', name: 'Louisiana' },\n { code: 'ME', name: 'Maine' },\n { code: 'MD', name: 'Maryland' },\n { code: 'MA', name: 'Massachusetts' },\n { code: 'MI', name: 'Michigan' },\n { code: 'MN', name: 'Minnesota' },\n { code: 'MS', name: 'Mississippi' },\n { code: 'MO', name: 'Missouri' },\n { code: 'MT', name: 'Montana' },\n { code: 'NE', name: 'Nebraska' },\n { code: 'NV', name: 'Nevada' },\n { code: 'NH', name: 'New Hampshire' },\n { code: 'NJ', name: 'New Jersey' },\n { code: 'NM', name: 'New Mexico' },\n { code: 'NY', name: 'New York' },\n { code: 'NC', name: 'North Carolina' },\n { code: 'ND', name: 'North Dakota' },\n { code: 'OH', name: 'Ohio' },\n { code: 'OK', name: 'Oklahoma' },\n { code: 'OR', name: 'Oregon' },\n { code: 'PA', name: 'Pennsylvania' },\n { code: 'RI', name: 'Rhode Island' },\n { code: 'SC', name: 'South Carolina' },\n { code: 'SD', name: 'South Dakota' },\n { code: 'TN', name: 'Tennessee' },\n { code: 'TX', name: 'Texas' },\n { code: 'UT', name: 'Utah' },\n { code: 'VT', name: 'Vermont' },\n { code: 'VA', name: 'Virginia' },\n { code: 'WA', name: 'Washington' },\n { code: 'WV', name: 'West Virginia' },\n { code: 'WI', name: 'Wisconsin' },\n { code: 'WY', name: 'Wyoming' },\n];\n\nexport const CA_PROVINCES: StateOption[] = [\n { code: 'AB', name: 'Alberta' },\n { code: 'BC', name: 'British Columbia' },\n { code: 'MB', name: 'Manitoba' },\n { code: 'NB', name: 'New Brunswick' },\n { code: 'NL', name: 'Newfoundland and Labrador' },\n { code: 'NS', name: 'Nova Scotia' },\n { code: 'NT', name: 'Northwest Territories' },\n { code: 'NU', name: 'Nunavut' },\n { code: 'ON', name: 'Ontario' },\n { code: 'PE', name: 'Prince Edward Island' },\n { code: 'QC', name: 'Quebec' },\n { code: 'SK', name: 'Saskatchewan' },\n { code: 'YT', name: 'Yukon' },\n];\n\n/**\n * Get state/province options for a country.\n * Returns a list for US and CA, or `null` for countries where a free-text input is appropriate.\n */\nexport function getStateOptions(country: string): StateOption[] | null {\n switch (country.toUpperCase()) {\n case 'US': return US_STATES;\n case 'CA': return CA_PROVINCES;\n default: return null;\n }\n}\n\n/** Returns the appropriate label for the state/province field based on country. */\nexport function getStateLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'State';\n case 'CA': return 'Province';\n case 'GB': return 'County';\n case 'AU': return 'State / Territory';\n default: return 'State / Province / Region';\n }\n}\n","/**\n * Postal-code → state derivation for AVS.\n *\n * Used when the form configuration shows `address_line_1` but hides the\n * `state` input — we still want to populate `billing_details.address.state`\n * so Stripe Radar gets a richer address signal. Currently supports US and CA;\n * other countries return `null` (caller should fall back to omitting state).\n */\n\n/**\n * US 3-digit ZIP-prefix ranges → state code (USPS Sectional Center Facility).\n * Sourced from the public USPS SCF table. Each entry is `[startPrefix, endPrefix, stateCode]`,\n * inclusive on both ends. Coverage is contiguous within a state; gaps in the table\n * (e.g. unused 3-digit prefixes) are intentional and resolve to `null`.\n */\nconst US_ZIP_PREFIX_RANGES: ReadonlyArray<readonly [number, number, string]> = [\n [5, 5, 'NY'],\n [10, 27, 'MA'],\n [28, 29, 'RI'],\n [30, 38, 'NH'],\n [39, 49, 'ME'],\n [50, 59, 'VT'],\n [60, 69, 'CT'],\n [70, 89, 'NJ'],\n [100, 149, 'NY'],\n [150, 196, 'PA'],\n [197, 199, 'DE'],\n [200, 205, 'DC'],\n [206, 219, 'MD'],\n [220, 246, 'VA'],\n [247, 268, 'WV'],\n [270, 289, 'NC'],\n [290, 299, 'SC'],\n [300, 319, 'GA'],\n [320, 349, 'FL'],\n [350, 369, 'AL'],\n [370, 385, 'TN'],\n [386, 397, 'MS'],\n [398, 399, 'GA'],\n [400, 427, 'KY'],\n [430, 459, 'OH'],\n [460, 479, 'IN'],\n [480, 499, 'MI'],\n [500, 528, 'IA'],\n [530, 549, 'WI'],\n [550, 567, 'MN'],\n [570, 577, 'SD'],\n [580, 588, 'ND'],\n [590, 599, 'MT'],\n [600, 629, 'IL'],\n [630, 658, 'MO'],\n [660, 679, 'KS'],\n [680, 693, 'NE'],\n [700, 714, 'LA'],\n [716, 729, 'AR'],\n [730, 749, 'OK'],\n [750, 799, 'TX'],\n [800, 816, 'CO'],\n [820, 831, 'WY'],\n [832, 838, 'ID'],\n [840, 847, 'UT'],\n [850, 865, 'AZ'],\n [870, 884, 'NM'],\n [889, 898, 'NV'],\n [900, 961, 'CA'],\n [967, 968, 'HI'],\n [970, 979, 'OR'],\n [980, 994, 'WA'],\n [995, 999, 'AK'],\n];\n\n/**\n * CA postal-code first letter → province code (Forward Sortation Area).\n * The first letter of every Canadian postal code identifies the province\n * uniquely, except `X` which is shared by Northwest Territories and Nunavut\n * — we resolve it to `NT` because the volume strongly favours NT.\n */\nconst CA_FSA_FIRST_LETTER_TO_PROVINCE: Readonly<Record<string, string>> = {\n A: 'NL',\n B: 'NS',\n C: 'PE',\n E: 'NB',\n G: 'QC',\n H: 'QC',\n J: 'QC',\n K: 'ON',\n L: 'ON',\n M: 'ON',\n N: 'ON',\n P: 'ON',\n R: 'MB',\n S: 'SK',\n T: 'AB',\n V: 'BC',\n X: 'NT',\n Y: 'YT',\n};\n\nfunction deriveUsState(zip: string): string | null {\n const digits = zip.replace(/\\D/g, '');\n if (digits.length < 5) return null;\n const prefix = Number.parseInt(digits.slice(0, 3), 10);\n if (!Number.isFinite(prefix)) return null;\n\n for (const [start, end, code] of US_ZIP_PREFIX_RANGES) {\n if (prefix >= start && prefix <= end) return code;\n }\n return null;\n}\n\nfunction deriveCaProvince(postalCode: string): string | null {\n const compact = postalCode.replace(/\\s+/g, '').toUpperCase();\n if (!/^[A-Z]\\d[A-Z]\\d[A-Z]\\d$/.test(compact)) return null;\n const firstLetter = compact[0] ?? '';\n return CA_FSA_FIRST_LETTER_TO_PROVINCE[firstLetter] ?? null;\n}\n\n/**\n * Resolve a state / province code from a postal code for the given country.\n *\n * - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).\n * - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).\n * - All other countries: `null`.\n *\n * Returns `null` when the postal code is malformed or falls in an unmapped\n * range. Callers should treat `null` as \"skip — don't derive\".\n */\nexport function getStateFromPostalCode(\n country: string,\n postalCode: string,\n): string | null {\n if (!country || !postalCode) return null;\n const normalizedCountry = country.trim().toUpperCase();\n const normalizedZip = postalCode.trim();\n if (!normalizedZip) return null;\n\n switch (normalizedCountry) {\n case 'US':\n return deriveUsState(normalizedZip);\n case 'CA':\n return deriveCaProvince(normalizedZip);\n default:\n return null;\n }\n}\n","import type { CheckoutSession } from './types.js';\n\n/** A single line item formatted for display in the checkout UI. */\nexport interface DisplayLineItem {\n name: string;\n quantity: number;\n /** Price per unit in the session's currency (major units, e.g. 24.95). */\n price: number;\n /** Original price per unit before any discount (major units). */\n originalPrice: number;\n}\n\n/** Computed display data for rendering an order summary. */\nexport interface CheckoutDisplayData {\n /** Individual items/subscriptions with names, prices, and quantities. */\n items: DisplayLineItem[];\n /** ISO 4217 currency code (uppercase). */\n currency: string;\n /** Total amount due after discounts (major units, e.g. 24.95). */\n total: number;\n /** Sum of original prices before discounts (major units). */\n originalTotal: number;\n /** Total savings (originalTotal - total), clamped to >= 0. */\n totalSave: number;\n /** Discount percentage (0–100). */\n discountPercent: number;\n}\n\n/**\n * Builds display data from a `CheckoutSession` for rendering an order summary.\n *\n * Matches the display logic in checkout/CheckoutModal exactly:\n * - Subscriptions are always shown\n * - Items are hidden when the session has both subscriptions AND items\n * - `overrideAmount` (when not null/undefined) is the discounted price\n * - Plan name \"4-WEEK PLAN\" with price <= 1 is renamed to \"7-DAY TRIAL: FULL ACCESS\"\n * - Discount percentage and savings are computed from the difference\n *\n * All amounts are in **major currency units** (dollars, not cents).\n *\n * @example\n * ```ts\n * import { buildCheckoutDisplayData } from '@flopay/shared';\n *\n * const display = buildCheckoutDisplayData(session);\n * // display.items → [{ name: 'Starter', price: 24.95, originalPrice: 24.95, quantity: 1 }]\n * // display.total → 24.95\n * // display.currency → 'EUR'\n * ```\n */\nexport function buildCheckoutDisplayData(session: CheckoutSession): CheckoutDisplayData {\n const itemsList: DisplayLineItem[] = [];\n let currency = 'USD';\n\n const subscriptions = session.subscriptions ?? [];\n const items = session.items ?? [];\n\n // Subscriptions\n for (const sub of subscriptions) {\n const originalPrice = sub.totalAmount;\n const discountedPrice = sub.overrideAmount ?? originalPrice;\n\n // Match checkout/CheckoutModal: rename \"4-WEEK PLAN\" to \"7-DAY TRIAL: FULL ACCESS\"\n // when the discounted price is $1 or less\n let name = sub.providerPlanName || 'Subscription';\n if (name === '4-WEEK PLAN' && discountedPrice <= 1) {\n name = '7-DAY TRIAL: FULL ACCESS';\n }\n\n itemsList.push({\n name,\n quantity: sub.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (sub.currency) currency = sub.currency.toUpperCase();\n }\n\n // Items — hidden when session has both subscriptions and items\n // (matches checkout/CheckoutModal: hideItems logic)\n const hideItems = subscriptions.length > 0 && items.length > 0;\n\n if (!hideItems) {\n for (const item of items) {\n const originalPrice = item.totalAmount;\n const discountedPrice = item.overrideAmount ?? originalPrice;\n\n itemsList.push({\n name: item.providerItemName || 'Item',\n quantity: item.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (item.currency) currency = item.currency.toUpperCase();\n }\n }\n\n // Fallback if session has no items/subscriptions\n if (itemsList.length === 0) {\n itemsList.push({\n name: 'Purchase',\n quantity: 1,\n price: session.amount / 100,\n originalPrice: session.amount / 100,\n });\n currency = session.currency?.toUpperCase() ?? 'USD';\n }\n\n const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);\n const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);\n const totalSave = Math.max(0, originalTotal - total);\n const discountPercent = originalTotal > 0\n ? Math.round((totalSave / originalTotal) * 100)\n : 0;\n\n return {\n items: itemsList,\n currency,\n total,\n originalTotal,\n totalSave,\n discountPercent,\n };\n}\n","import type { CurrencyInfo } from './types.js';\nimport { CURRENCY_MAP, DEFAULT_CURRENCY } from './constants.js';\n\n/**\n * Look up currency information by ISO 3166-1 alpha-2 country code.\n * Falls back to USD when the country is not in the map.\n */\nexport function getCurrencyByCountry(countryCode: string): CurrencyInfo {\n return CURRENCY_MAP[countryCode.toUpperCase()] ?? DEFAULT_CURRENCY;\n}\n\n/** Returns `true` if the string looks like a Stripe publishable key. */\nexport function isValidPublishableKey(key: string): boolean {\n return /^pk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n\n/** Returns `true` if the string looks like a Stripe secret key. */\nexport function isValidSecretKey(key: string): boolean {\n return /^sk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n"],"mappings":";AAcO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAMrC,YACE,SACA,MACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO,SAAS;AACrB,SAAK,cAAc,SAAS;AAC5B,SAAK,QAAQ,SAAS;AAGtB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAOO,SAAS,gBACd,SACA,OACa;AACb,SAAO,IAAI,YAAY,SAAS,oBAAoB,EAAE,MAAM,CAAC;AAC/D;AAGO,SAAS,SACd,SACA,MACa;AACb,SAAO,IAAI,YAAY,SAAS,aAAa,EAAE,KAAK,CAAC;AACvD;AAGO,SAAS,oBAAoB,SAA8B;AAChE,SAAO,IAAI,YAAY,SAAS,sBAAsB;AACxD;AAGO,SAAS,eAAe,SAA8B;AAC3D,SAAO,IAAI,YAAY,SAAS,kBAAkB;AACpD;AAGO,SAAS,aAAa,SAA8B;AACzD,SAAO,IAAI,YAAY,SAAS,eAAe;AACjD;;;ACnEA,IAAM,cAAiD;AAAA,EACrD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AACd;AAEA,IAAI,oBAAuC;AAsBpC,SAAS,gBAAgB,QAAkD;AAChF,sBAAoB,OAAO;AAC7B;AAGO,SAAS,6BAAqC;AACnD,SAAO,YAAY,iBAAiB;AACtC;AAGO,SAAS,uBAA0C;AACxD,SAAO;AACT;;;ACjCO,IAAM,cAAc;AAGpB,IAAM,0BAA0B;AAGhC,IAAM,6BAA6B;AAGnC,IAAM,uBAAuB;AAG7B,IAAM,kBAAkB;AAsBxB,SAAS,qBAAq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