import * as react from 'react'; /** Card brand codes as returned by Nuvei (Paymentez). */ type CardBrand = "vi" | "mc" | "ax" | "di" | "dc" | "up" | "cs" | "unknown"; /** Card type. Nuvei returns this for known BINs. */ type CardType = "credit" | "debit" | "prepaid" | "unknown"; /** Card carrier (Ecuador-specific: Datafast vs Medianet processor). */ type CardCarrier = "datafast" | "medianet" | "both" | "unknown"; /** BIN lookup result — full info about a card's issuer and processing path. */ interface BinInfo { bank: string; brand: CardBrand; type: CardType; carrier: CardCarrier; requiresOtp: boolean; } /** BIN database structure. Keyed by 6-8 digit BIN prefix. */ interface BinDatabase { data: Record; version: string; count: number; updatedAt?: string; } /** Bank color palette for rendering branded card visuals. */ interface BankPalette { /** Primary brand color (hex) */ primary: string; /** Optional secondary for gradients */ secondary?: string; } /** Saved card as returned by Nuvei /v2/card/list. */ interface SavedCard { bin: string; status: "valid" | "review" | "pending" | "rejected"; token: string; holder_name: string; expiry_year: string; expiry_month: string; transaction_reference: string; /** Brand code: "vi", "mc", "ax", "di", "dc", etc. */ type: string; /** Last 4 digits of the card number. */ number: string; } /** Brand name display map. */ declare const CARD_BRAND_NAMES: Record; /** Card type display map (Spanish). */ declare const CARD_TYPE_NAMES: Record; interface CardVisualProps { bin?: string; brand: string; last4: string; holderName: string; expiryMonth: string; expiryYear: string; /** Compact = mini real-card thumbnail (Rappi/PayPal style). Full = larger card. */ variant?: "compact" | "full"; /** Pre-resolved BIN info. If provided, no network lookup is performed. Useful * for server-rendered scenarios or when the consumer already cached lookups. */ binInfo?: BinInfo; /** Path of the consumer's BIN database endpoint. Default: "/api/bins". * Set to null to disable network lookup entirely (component will fall back * to brand network colors). */ binDatabaseEndpoint?: string | null; } declare function CardVisual({ bin, brand, last4, holderName, expiryMonth, expiryYear, variant, binInfo: preResolvedBinInfo, binDatabaseEndpoint, }: CardVisualProps): react.JSX.Element; /** Largo del CVC de una tarjeta: 4 para American Express, 3 para el resto. */ declare const cvcLength: (card: { type?: string; }) => 4 | 3; /** true cuando el CVC tiene todos sus dígitos. Solo entonces la tienda debería habilitar su botón de pagar. * Sirve para tarjetas guardadas y para la recién tokenizada (su TokenizedCardInfo.type). */ declare const isCvcComplete: (card: { type?: string; }, cvc: string) => boolean; interface SavedCardsProps { /** * Se llama cuando cambia la tarjeta elegida: al cargar la lista (elige sola la primera válida), al * hacer clic, al borrar la elegida y al verificar una. Nunca trae el CVC: al elegir otra tarjeta, su CVC * empieza vacío, así que la tienda debe olvidar el CVC que tenía guardado. * **No cobres desde aquí:** la lista elige una tarjeta sola al montarse. El cobro va detrás de un * botón de la tienda. */ onSelect?: (card: SavedCard) => void; /** * Se llama con cada tecla del CVC de la tarjeta elegida. `complete` dice si ya tiene todos sus * dígitos: úsalo para habilitar el botón de pagar, no para cobrar. */ onCvcChange?: (card: SavedCard, cvc: string, complete: boolean) => void; /** * @deprecated Usa `onSelect` y `onCvcChange`. Mezcla los dos avisos: se llama al montarse (con CVC * ""), al borrar, al verificar y con CADA tecla del CVC. Conectarlo a un cobro cobra solo al abrir * la lista (pasó en Tálou y en Well Me). Sigue funcionando igual; se quita en la 2.0.0. */ onSelectCard?: (card: SavedCard, cvc: string) => void; selectedToken: string | null; onAddNewCard: () => void; /** Path of the consumer's BIN database endpoint, forwarded to CardVisual. * Default: "/api/bins". Set to null to disable bank-color lookups. */ binDatabaseEndpoint?: string | null; } declare function SavedCards({ onSelect, onCvcChange, onSelectCard, selectedToken, onAddNewCard, binDatabaseEndpoint, }: SavedCardsProps): react.JSX.Element; interface TokenizedCardInfo { type?: string; number?: string; expiry_year?: string; expiry_month?: string; } interface NuveiPaymentFormProps { uid: string; email: string; onTokenSuccess: (token: string, cardInfo: TokenizedCardInfo, saveCard: boolean) => void; /** @deprecated Errors are rendered inline by the component. This callback is * preserved as optional for API compatibility but is never invoked. * For telemetry, listen for the relevant DOM events or wrap setError yourself. */ onTokenError?: (error: string) => void; /** Forces the submit button to disabled state (in addition to processing). */ disabled?: boolean; /** Override button text (default: "Agregar Tarjeta" / "Continuar con pago") */ buttonLabel?: string; /** Hide "Guardar tarjeta" checkbox — forces saveCard=false (guest flows) */ showSaveCardCheckbox?: boolean; /** Text shown during processing (default: "Verificando…") */ processingLabel?: string; /** Nuvei client app code. Default: NEXT_PUBLIC_NUVEI_CLIENT_APP_CODE env var. */ nuveiAppCode?: string; /** Nuvei client app key. Default: NEXT_PUBLIC_NUVEI_CLIENT_APP_KEY env var. */ nuveiAppKey?: string; /** Nuvei environment. Default: NEXT_PUBLIC_NUVEI_ENV env var, falling back to "stg". */ nuveiEnv?: "prod" | "stg"; /** ISO-3 country code for the SDK form. Default: "ECU". */ defaultCountry?: string; /** Allowed card brand codes for tokenization (Paymentez). Default: ["vi","mc","ax","di"]. */ exclusiveCardTypes?: string[]; /** Hex color for the SDK form icons. Default: reads var(--color-primary) from the DOM. */ iconColor?: string; } declare function NuveiPaymentForm({ uid, email, onTokenSuccess, disabled, buttonLabel, showSaveCardCheckbox, processingLabel, nuveiAppCode, nuveiAppKey, nuveiEnv, defaultCountry, exclusiveCardTypes, iconColor, }: NuveiPaymentFormProps): react.JSX.Element; /** * Loads the BIN database. Uses memory cache → localStorage cache → network. * Returns null if no database is available (lookup will return null silently). * * @param endpoint URL serving the BIN database as JSON. Default: "/api/bins". */ declare function getBinDatabase(endpoint?: string): Promise; /** * Looks up a BIN for a given card number string. Tries 8, 7, 6 digit prefixes. * Returns null if no match or database not loaded yet. */ declare function lookupBinSync(cardNumber: string, db: BinDatabase | null): BinInfo | null; /** Async helper that loads the DB if needed and looks up the BIN. */ declare function lookupBin(cardNumber: string, endpoint?: string): Promise; /** * Bank brand colors for Ecuadorian banks and cooperativas. * Each bank can have different colors per card type (credit / debit / prepaid). * * Lookup is by normalized bank name (lowercase, no accents, alphanumeric). * Falls back to brand network colors when no match. */ /** * Lookup the palette for a bank, optionally by card type. * Strategy: * 1. Find the bank's BankByType by normalized name (or substring match). * 2. Try to return the palette for the requested type. * 3. Fall back to credit → debit → first available type. */ declare function lookupBankPalette(bankName: string | undefined, cardType?: CardType): BankPalette | null; export { type BankPalette, type BinDatabase, type BinInfo, CARD_BRAND_NAMES, CARD_TYPE_NAMES, type CardBrand, type CardCarrier, type CardType, CardVisual, NuveiPaymentForm, type SavedCard, SavedCards, type TokenizedCardInfo, cvcLength, getBinDatabase, isCvcComplete, lookupBankPalette, lookupBin, lookupBinSync };