/** * InflowPay Payment SDK * * Minimal CardElement SDK for embedded payment flows. * Provides a secure, pre-built card payment form with direct API integration. * * @packageDocumentation */ declare interface ButtonStyle { /** Base button styles */ base?: Partial; /** Hover state styles */ hover?: Partial; /** Disabled state styles */ disabled?: Partial; /** Loader animation color */ loaderColor?: string; } export declare interface CardData { /** Card number (without spaces or dashes) */ number: string; /** Expiration month (1-12) */ expiration_month: string; /** Expiration year (4 digits, e.g., 2025) */ expiration_year: string; /** Card security code (CVV/CVC) */ cvc: string; } export declare class CardElement { private container; private options; private config; private state; private mounted; private renderer; private validator; private paymentClient; private uiController; constructor(config: SDKConfig & { environment: 'sandbox' | 'production' | 'development'; }, options: CardElementOptions); /** * Mount the element into the DOM */ mount(): void; /** * Submit payment (tokenizes card and confirms payment) * Payment must already be created with billing information */ submit(): Promise; /** * Destroy the element and clean up */ destroy(): void; private setupEventListeners; private validateAndUpdate; private applyStyles; private getCardNumber; private getExpiryMonth; private getExpiryYear; private getCvc; } export declare interface CardElementOptions { /** Container element or CSS selector where the card element will be mounted */ container: string | HTMLElement; /** Payment ID for this transaction */ paymentId: string; /** Custom styling for the card element */ style?: CSSProperties; /** Custom button text (default: "Complete Payment") */ buttonText?: string; /** Custom button styling - can be flat CSS properties or structured with states */ buttonStyle?: Partial | ButtonStyle; /** Custom placeholder text for inputs */ placeholders?: { cardNumber?: string; expiry?: string; cvc?: string; }; /** Callback when card input state changes */ onChange?: (state: CardElementState) => void; /** Callback when payment completes */ onComplete?: (result: PaymentResult) => void; /** Callback when an error occurs */ onError?: (error: PaymentError) => void; } export declare interface CardElementState { /** Whether all card fields are valid and complete */ complete: boolean; /** Whether all card fields are empty */ empty: boolean; /** Field-specific error messages */ errors: { cardNumber?: string; expiry?: string; cvc?: string; }; } export declare interface CSSProperties { inputContainer?: InputContainerStyles; input?: InputStyles; fontFamily?: string; light?: ThemeStyles; dark?: ThemeStyles; } declare interface InputContainerStyles { backgroundColor?: string; border?: string; borderRadius?: string; } declare interface InputStyles { border?: string; borderRadius?: string; color?: string; fontWeight?: string; placeholder?: { color?: string; }; } /** * InflowPay Payment SDK Type Definitions */ export declare type Locale = 'en' | 'de' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'; export declare interface PaymentError { /** Machine-readable error code */ code: string; /** Human-readable error message */ message: string; /** Whether this error is retryable (user can fix and retry) */ retryable?: boolean; /** HTTP status code (if applicable) */ statusCode?: number; /** Field name (for validation errors) */ field?: string; /** Documentation URL */ docs?: string; /** Additional error details */ details?: Record; } export declare interface PaymentResult { /** Payment status */ status: PaymentStatus; /** Error details (if status is 'failed') */ error?: PaymentError; /** Indicates if this payment was already processed (duplicate submission attempt) */ alreadyProcessed?: boolean; } export declare class PaymentSDK { private config; /** * Initialize the InflowPay Payment SDK * * @param config - SDK configuration options * @param config.apiKey - InflowPay public API key (required, must start with "inflow_pub_") * @param config.timeout - Request timeout in milliseconds (defaults to 30000) * @param config.debug - Enable debug logging (defaults to false) * * @throws {Error} If API key is missing or invalid * * @example * ```typescript * // Production environment (auto-detected from key prefix) * const sdk = new PaymentSDK({ * apiKey: 'inflow_pub_prod_xxx' * }); * * // Development environment (auto-detected from key prefix) * const sdk = new PaymentSDK({ * apiKey: 'inflow_pub_dev_xxx' * }); * * // Sandbox/local development (auto-detected from key prefix) * const sdk = new PaymentSDK({ * apiKey: 'inflow_pub_local_xxx' * }); * ``` */ constructor(config: SDKConfig); /** * Create a CardElement for embedded payment UI * * @param options - CardElement configuration * @returns CardElement instance * * @example * ```typescript * const cardElement = sdk.createCardElement({ * container: '#card-container', * paymentId: 'pay_123', * onComplete: (result) => console.log('Payment complete:', result) * }); * * cardElement.mount(); * ``` */ createCardElement(options: CardElementOptions): CardElement; /** * Get the current status of a payment * * Useful for polling payment status after 3DS authentication or * checking the final state of a payment after redirect. * * @param paymentId - The payment ID to check * @returns Payment status information * * @example * ```typescript * // After user returns from 3DS authentication * const status = await sdk.getPaymentStatus('pay_123'); * * if (status.status === 'PAYMENT_SUCCESS') { * console.log('Payment completed!'); * } else if (status.status === 'PAYMENT_FAILED') { * console.log('Payment failed:', status.error); * } * ``` */ getPaymentStatus(paymentId: string): Promise; /** * Internal logging (respects debug flag) */ private log; } /** * Payment status enum matching the actual API values * Flow: INITIATION -> CHECKOUT_PENDING -> CHECKOUT_SUCCESS -> PAYMENT_RECEIVED -> PAYMENT_SUCCESS * Payment is considered successful from CHECKOUT_SUCCESS onwards */ export declare enum PaymentStatus { INITIATION = "INITIATION", CHECKOUT_PENDING = "CHECKOUT_PENDING",// when the payer is preparing the payment CHECKOUT_SUCCESS = "CHECKOUT_SUCCESS",// when the payer has successfully paid CHECKOUT_CANCELED = "CHECKOUT_CANCELED", CANCELED = "CANCELED", PAYMENT_RECEIVED = "PAYMENT_RECEIVED",// fiat funds received by the onramp provider PAYMENT_SUCCESS = "PAYMENT_SUCCESS",// the user wallet received the crypto sent by the onramp provider PAYMENT_FAILED = "PAYMENT_FAILED" } /** * Payment status response from /sdk/payment/:id * Matches SdkGetPaymentResponseDto from API */ declare interface PaymentStatusResponse { paymentId: string; status: PaymentStatus; amount: number; amountTaxesIncluded: number | null; currency: string; customerEmail: string | null; depositStatus: string | null; error: string | null; createdAt: Date; updatedAt: Date; challengeUrl?: string; lastDepositAttempt?: { status: string; amount: number; paymentMethod: string; error: string | null; attemptedAt: string; }; } export declare interface SDKConfig { /** * InflowPay public API key (required) * * The environment and URLs are automatically determined from your API key: * - inflow_pub_prod_xxx → Production (https://api.inflowpay.xyz) * - inflow_pub_dev_xxx → Development (https://dev.api.inflowpay.com) * - inflow_pub_local_xxx → Sandbox (http://localhost:3001) */ apiKey: string; /** * Locale for UI text (default: auto-detected from browser, falls back to 'en') * Supported: 'en', 'de', 'es', 'fr', 'it', 'nl', 'pl', 'pt' */ locale?: Locale; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; /** Enable debug logging (default: false) */ debug?: boolean; } declare interface ThemeStyles { inputContainer?: InputContainerStyles; input?: InputStyles; } /** * SDK version */ export declare const VERSION = "0.7.0"; export { }