import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode } from 'react'; /** Minimal ReactNode-compatible type to avoid hard dependency on @types/react */ type ReevitReactNode = ReactNode; type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer' | 'apple_pay' | 'google_pay'; type MobileMoneyNetwork = 'mtn' | 'telecel' | 'airteltigo'; /** Payment source type - indicates where the payment originated from */ type PaymentSource = 'payment_link' | 'api' | 'subscription'; interface ReevitCheckoutConfig { /** Your Reevit public key (required for API-created intents; omit for payment links) */ publicKey?: string; /** Server-created checkout session secret. Prefer this for browser checkouts. */ sessionSecret?: string; /** Amount in the smallest currency unit (e.g., pesewas for GHS). Required unless sessionSecret or initialPaymentIntent is provided. */ amount?: number; /** Currency code (e.g., 'GHS', 'NGN', 'USD'). Required unless sessionSecret or initialPaymentIntent is provided. */ currency?: string; /** Customer email address */ email?: string; /** Customer phone number (required for mobile money) */ phone?: string; /** Customer name (optional, used for payment links) */ customerName?: string; /** Unique reference for this transaction */ reference?: string; /** Optional idempotency key to safely retry or dedupe intent creation */ idempotencyKey?: string; /** Additional metadata to attach to the payment */ metadata?: Record; /** Custom fields for payment links (if applicable) */ customFields?: Record; /** Payment link code (for public checkout flows) */ paymentLinkCode?: string; /** Payment methods to display */ paymentMethods?: PaymentMethod[]; /** Optional existing payment intent to use instead of creating a new one */ initialPaymentIntent?: PaymentIntent; } interface ReevitCheckoutCallbacks { /** Called when payment is successful */ onSuccess?: (result: PaymentResult) => void; /** Called when payment fails */ onError?: (error: PaymentError) => void; /** Called when user closes the checkout */ onClose?: () => void; /** Called when checkout state changes */ onStateChange?: (state: CheckoutState) => void; } interface ReevitCheckoutProps extends ReevitCheckoutConfig, ReevitCheckoutCallbacks { /** Custom trigger element */ children?: ReevitReactNode; /** Whether to open automatically */ autoOpen?: boolean; /** Controlled open state */ isOpen?: boolean; /** Callback for open state changes */ onOpenChange?: (isOpen: boolean) => void; /** Custom theme */ theme?: ReevitTheme; /** Custom API base URL (for testing or self-hosted deployments) */ apiBaseUrl?: string; /** Delay (ms) before calling onSuccess and closing after a successful payment */ successDelayMs?: number; } type CheckoutState = 'idle' | 'loading' | 'ready' | 'method_selected' | 'processing' | 'success' | 'failed' | 'closed'; interface PaymentResult { /** Unique payment ID from Reevit */ paymentId: string; /** Reference provided or generated */ reference: string; /** Amount paid in smallest currency unit */ amount: number; /** Currency code */ currency: string; /** Payment method used */ paymentMethod: PaymentMethod; /** PSP that processed the payment */ psp: string; /** PSP's transaction reference */ pspReference: string; /** Payment status */ status: 'success' | 'pending'; /** Any additional data from the PSP */ metadata?: Record; /** Payment source type (payment_link, api, subscription) */ source?: PaymentSource; /** ID of the source (payment link ID, subscription ID, etc.) */ sourceId?: string; /** Human-readable description of the source (e.g., payment link name) */ sourceDescription?: string; } interface PaymentError { /** Error code */ code: string; /** Human-readable error message */ message: string; /** Whether the error is recoverable (user can retry) */ recoverable?: boolean; /** Original error from PSP if available */ originalError?: unknown; /** Additional error details */ details?: Record; } interface ReevitTheme { /** Primary color (main text, headings, important elements) */ primaryColor?: string; /** Primary foreground color (sub text, descriptions, muted elements) */ primaryForegroundColor?: string; /** Button background color */ buttonBackgroundColor?: string; /** Button text color */ buttonTextColor?: string; /** Background color (applies to entire checkout: header, body, footer) */ backgroundColor?: string; /** Border color (borders, dividers) */ borderColor?: string; /** Border radius for inputs and buttons */ borderRadius?: string; /** Whether to use dark mode */ darkMode?: boolean; /** Custom logo URL to display in checkout header */ logoUrl?: string; /** Company or organization name to display in checkout header */ companyName?: string; /** PSP selector background color */ pspSelectorBgColor?: string; /** PSP selector text color */ pspSelectorTextColor?: string; /** PSP selector border color */ pspSelectorBorderColor?: string; /** Use border-only style for PSP selector (no filled background) */ pspSelectorUseBorder?: boolean; /** Selected PSP background color */ selectedBackgroundColor?: string; /** Selected PSP primary text color */ selectedTextColor?: string; /** Selected PSP description/muted text color */ selectedDescriptionColor?: string; /** Selected PSP border color */ selectedBorderColor?: string; } interface CheckoutProviderOption { provider: string; name: string; methods: PaymentMethod[]; countries?: string[]; /** Brand colors for selected state styling */ branding?: { /** Background color when selected */ backgroundColor?: string; /** Primary/accent color */ primaryColor?: string; /** Text color on primary background */ primaryForegroundColor?: string; }; } interface MobileMoneyFormData { phone: string; network: MobileMoneyNetwork; } interface PaymentIntent { /** Unique payment intent ID */ id: string; /** Client secret for authenticating client-side operations */ clientSecret: string; /** PSP's public key for client-side SDK initialization */ pspPublicKey?: string; /** PSP-specific credentials for client-side checkout (e.g., Hubtel's merchantAccount, basicAuth) */ pspCredentials?: { /** Hubtel merchant account number */ merchantAccount?: string | number; /** Hubtel basic auth header value */ basicAuth?: string; /** Any other PSP-specific credential fields */ [key: string]: unknown; }; /** Amount in smallest currency unit */ amount: number; /** Currency code */ currency: string; /** Payment status */ status: 'pending' | 'requires_action' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'cancelled'; /** Recommended PSP based on routing rules */ recommendedPsp: 'paystack' | 'hubtel' | 'flutterwave' | 'monnify' | 'mpesa' | 'stripe'; /** Available payment methods for this intent */ availableMethods: PaymentMethod[]; /** Provider transaction reference returned by Reevit */ providerRefId?: string; /** Reference provided or generated */ reference?: string; /** Organization ID (from Reevit backend, required for webhook routing) */ orgId?: string; /** Connection ID (from Reevit backend) */ connectionId?: string; /** Provider name (from backend) */ provider?: string; /** Fee amount charged by PSP */ feeAmount?: number; /** Fee currency */ feeCurrency?: string; /** Net amount after fees */ netAmount?: number; /** Additional metadata */ metadata?: Record; /** Available PSPs for this checkout session */ availableProviders?: CheckoutProviderOption[]; /** Brand theme from checkout settings */ branding?: ReevitTheme; } interface ReevitContextValue { publicKey: string; amount: number; currency: string; } declare function useReevitContext(): ReevitContextValue; declare function ReevitCheckout({ publicKey, sessionSecret, amount, currency, email, phone, customerName, reference, metadata, customFields, paymentLinkCode, paymentMethods, initialPaymentIntent, onSuccess, onError, onClose, onStateChange, children, autoOpen, isOpen: controlledIsOpen, onOpenChange, theme, apiBaseUrl, successDelayMs, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element; interface PaymentMethodSelectorProps { methods: PaymentMethod[]; selectedMethod: PaymentMethod | null; onSelect: (method: PaymentMethod) => void; disabled?: boolean; provider?: string; layout?: 'grid' | 'list'; showLabel?: boolean; /** Country code for dynamic logos (e.g., 'GH', 'NG', 'KE') */ country?: string; /** Selected theme colors for method items */ selectedTheme?: { backgroundColor?: string; textColor?: string; descriptionColor?: string; borderColor?: string; }; } declare function PaymentMethodSelector({ methods, selectedMethod, onSelect, disabled, provider, layout, showLabel, country, selectedTheme, }: PaymentMethodSelectorProps): react_jsx_runtime.JSX.Element; interface MobileMoneyFormProps { onSubmit: (data: MobileMoneyFormData) => void; onCancel?: () => void; isLoading?: boolean; initialPhone?: string; hideCancel?: boolean; } declare function MobileMoneyForm({ onSubmit, onCancel, isLoading, initialPhone, hideCancel, }: MobileMoneyFormProps): react_jsx_runtime.JSX.Element; /** * useReevit hook * Core hook for managing Reevit checkout state and API interactions */ interface UseReevitOptions { config: ReevitCheckoutConfig; onSuccess?: (result: PaymentResult) => void; onError?: (error: PaymentError) => void; onClose?: () => void; onStateChange?: (state: CheckoutState) => void; /** Custom API base URL (for testing or self-hosted deployments) */ apiBaseUrl?: string; } declare function useReevit(options: UseReevitOptions): { status: CheckoutState; paymentIntent: PaymentIntent | null; selectedMethod: PaymentMethod | null; error: PaymentError | null; result: PaymentResult | null; initialize: (method?: PaymentMethod, options?: { preferredProvider?: string; allowedProviders?: string[]; }) => Promise; selectMethod: (method: PaymentMethod) => void; processPayment: (paymentData: Record) => Promise; handlePspSuccess: (pspData: Record) => Promise; handlePspError: (error: PaymentError) => void; reset: () => Promise; close: () => Promise; isLoading: boolean; isReady: boolean; isComplete: boolean; canRetry: boolean; }; declare global { interface Window { PaystackPop?: PaystackPopupInterface; } } interface PaystackPopupInterface { setup: (config: PaystackConfig) => { openIframe: () => void; }; } interface PaystackConfig { key: string; email: string; phone?: string; amount?: number; currency?: string; ref?: string; access_code?: string; metadata?: Record; channels?: string[]; callback: (response: PaystackResponse) => void; onClose: () => void; } interface PaystackResponse { reference: string; trans: string; status: string; message: string; transaction: string; trxref: string; } interface PaystackBridgeProps { publicKey: string; email: string; phone?: string; amount: number; currency?: string; reference?: string; accessCode?: string; metadata?: Record; channels?: ('card' | 'bank' | 'ussd' | 'qr' | 'mobile_money' | 'bank_transfer')[]; onSuccess: (result: PaymentResult) => void; onError: (error: PaymentError) => void; onClose: () => void; autoStart?: boolean; } declare function loadPaystackScript(): Promise; declare function PaystackBridge({ publicKey, email, phone, amount, currency, reference, accessCode, metadata, channels, onSuccess, onError, onClose, autoStart, }: PaystackBridgeProps): react_jsx_runtime.JSX.Element; interface HubtelBridgeProps { paymentId: string; publicKey?: string; merchantAccount: string | number; amount: number; currency?: string; reference?: string; email?: string; phone?: string; description?: string; callbackUrl?: string; apiBaseUrl?: string; clientSecret?: string; /** Session token from server (triggers session fetch) */ hubtelSessionToken?: string; /** Base64 basic auth credential (legacy - credentials exposed) */ basicAuth?: string; preferredMethod?: PaymentMethod; onSuccess: (result: PaymentResult) => void; onError: (error: PaymentError) => void; onClose: () => void; autoStart?: boolean; } declare function HubtelBridge({ paymentId, publicKey, merchantAccount, amount, currency, reference, email, phone, description, callbackUrl, apiBaseUrl, clientSecret, hubtelSessionToken, basicAuth, preferredMethod, onSuccess, onError, onClose, autoStart, }: HubtelBridgeProps): react_jsx_runtime.JSX.Element; /** * Opens Hubtel checkout modal directly * Uses the @hubteljs/checkout npm package */ declare function openHubtelPopup(config: { merchantAccount: string | number; description: string; amount: number; clientReference?: string; callbackUrl?: string; apiBaseUrl?: string; customerPhoneNumber?: string; basicAuth?: string; preferredMethod?: PaymentMethod; onSuccess?: (data: Record) => void; onError?: (data: Record) => void; onClose?: () => void; }): void; declare global { interface Window { FlutterwaveCheckout?: (config: FlutterwaveConfig) => void; } } interface FlutterwaveConfig { public_key: string; tx_ref: string; amount: number; currency: string; payment_options?: string; customer: { email: string; phone_number?: string; name?: string; }; customizations?: { title?: string; description?: string; logo?: string; }; meta?: Record; callback: (response: FlutterwaveResponse) => void; onclose: () => void; } interface FlutterwaveResponse { status: 'successful' | 'failed' | 'cancelled'; transaction_id: number; tx_ref: string; flw_ref: string; amount: number; currency: string; charged_amount: number; payment_type: string; } interface FlutterwaveBridgeProps { publicKey: string; amount: number; currency?: string; reference?: string; email: string; phone?: string; name?: string; paymentOptions?: string; title?: string; description?: string; logo?: string; metadata?: Record; onSuccess: (result: PaymentResult) => void; onError: (error: PaymentError) => void; onClose: () => void; autoStart?: boolean; } declare function loadFlutterwaveScript(): Promise; declare function FlutterwaveBridge({ publicKey, amount, currency, reference, email, phone, name, paymentOptions, title, description, logo, metadata, onSuccess, onError, onClose, autoStart, }: FlutterwaveBridgeProps): react_jsx_runtime.JSX.Element; /** * StripeBridge.tsx * React component for Stripe payment integration */ declare global { interface Window { Stripe?: (publishableKey: string) => StripeInstance; } } interface StripeInstance { elements: (options?: { clientSecret: string; appearance?: StripeAppearance; }) => StripeElements; confirmPayment: (options: { elements: StripeElements; confirmParams?: { return_url?: string; }; redirect?: 'if_required'; }) => Promise<{ error?: StripeError; paymentIntent?: { id: string; status: string; }; }>; } interface StripeElements { create: (type: 'payment' | 'card', options?: Record) => StripeElement; getElement: (type: string) => StripeElement | null; submit: () => Promise<{ error?: StripeError; }>; } interface StripeElement { mount: (selector: string | HTMLElement) => void; unmount: () => void; on: (event: string, handler: (e: any) => void) => void; destroy: () => void; } interface StripeError { type: string; message: string; code?: string; } interface StripeAppearance { theme?: 'stripe' | 'night' | 'flat'; variables?: Record; rules?: Record>; } interface StripeBridgeProps { publishableKey: string; clientSecret: string; amount: number; currency: string; appearance?: StripeAppearance; onSuccess: (result: { paymentIntentId: string; status: string; }) => void; onError: (error: { code: string; message: string; }) => void; onReady?: () => void; onCancel?: () => void; } declare function loadStripeScript(): Promise; declare function StripeBridge({ publishableKey, clientSecret, amount, currency, appearance, onSuccess, onError, onReady, onCancel, }: StripeBridgeProps): react_jsx_runtime.JSX.Element; /** * MonnifyBridge.tsx * React component for Monnify payment integration (Nigeria) */ declare global { interface Window { MonnifySDK?: { initialize: (config: MonnifyConfig) => void; }; } } interface MonnifyConfig { amount: number; currency: string; reference: string; customerName: string; customerEmail: string; customerMobileNumber?: string; apiKey: string; contractCode: string; paymentDescription?: string; isTestMode?: boolean; metadata?: Record; onComplete: (response: MonnifyResponse) => void; onClose: () => void; } interface MonnifyResponse { status: 'SUCCESS' | 'FAILED' | 'PENDING'; message: string; transactionReference: string; paymentReference: string; authorizedAmount?: number; paymentStatus?: string; } interface MonnifyBridgeProps { apiKey: string; contractCode: string; amount: number; currency: string; reference: string; customerName: string; customerEmail: string; customerPhone?: string; paymentDescription?: string; isTestMode?: boolean; metadata?: Record; autoOpen?: boolean; onSuccess: (result: { transactionReference: string; paymentReference: string; amount: number; }) => void; onError: (error: { code: string; message: string; }) => void; onClose?: () => void; } declare function loadMonnifyScript(): Promise; declare function MonnifyBridge({ apiKey, contractCode, amount, currency, reference, customerName, customerEmail, customerPhone, paymentDescription, isTestMode, metadata, autoOpen, onSuccess, onError, onClose, }: MonnifyBridgeProps): react_jsx_runtime.JSX.Element | null; /** * MPesaBridge.tsx * React component for M-Pesa STK Push integration (Kenya/Tanzania) * * Note: M-Pesa uses server-to-server STK Push initiated by the backend. * This component handles the UI flow while the customer approves on their phone. */ interface MPesaBridgeProps { /** API endpoint to initiate STK Push (your backend) */ apiEndpoint: string; /** Customer phone number in format 254XXXXXXXXX */ phoneNumber: string; /** Amount to charge */ amount: number; /** Currency (KES or TZS) */ currency: string; /** Unique transaction reference */ reference: string; /** Payment description */ description?: string; /** Called when STK Push is successfully sent */ onInitiated?: (checkoutRequestId: string) => void; /** Called when payment is confirmed (via webhook/polling) */ onSuccess: (result: { transactionId: string; reference: string; }) => void; /** Called on error */ onError: (error: { code: string; message: string; }) => void; /** Custom headers for API calls (e.g., authorization) */ headers?: Record; } declare function MPesaBridge({ apiEndpoint, phoneNumber, amount, currency, reference, description, onInitiated, onSuccess, onError, headers, }: MPesaBridgeProps): react_jsx_runtime.JSX.Element | null; /** * Hook for M-Pesa payment status polling * Use this to check payment status after STK Push is initiated */ declare function useMPesaStatusPolling(statusEndpoint: string, checkoutRequestId: string | null, options: { interval?: number; maxAttempts?: number; headers?: Record; onSuccess: (result: { transactionId: string; }) => void; onFailed: (error: { message: string; }) => void; onTimeout: () => void; }): { startPolling: () => Promise; }; /** * Reevit API Client * * Handles communication with the Reevit backend for payment operations. */ interface PaymentIntentResponse { id: string; org_id?: string; connection_id: string; provider: string; provider_ref_id?: string; status: string; client_secret: string; session_secret?: string; psp_public_key?: string; psp_credentials?: { merchantAccount?: string | number; basicAuth?: string; [key: string]: unknown; }; amount: number; currency: string; fee_amount: number; fee_currency: string; net_amount: number; reference?: string; available_psps?: Array<{ provider: string; name: string; methods: string[]; countries?: string[]; }>; branding?: Record; } interface CheckoutSessionResponse { id: string; client_secret: string; session_secret: string; payment_intent: PaymentIntentResponse; expires_at?: string; } /** * Response from creating a Hubtel session token. * The token provides secure, short-lived access to Hubtel checkout without exposing credentials. */ interface HubtelSessionResponse { /** Short-lived session token for Hubtel checkout */ token: string; /** Hubtel merchant account number */ merchantAccount: string; /** Base64 basic auth for Hubtel checkout (exposes credentials) */ basicAuth?: string; /** Token expiry time in seconds */ expiresInSeconds: number; /** Unix timestamp when the token expires */ expiresAt: number; } interface PaymentDetailResponse { id: string; connection_id: string; provider: string; method: string; status: string; amount: number; currency: string; fee_amount: number; fee_currency: string; net_amount: number; customer_id?: string; client_secret: string; provider_ref_id?: string; metadata?: Record; created_at: string; updated_at: string; /** Payment source type (payment_link, api, subscription) */ source?: 'payment_link' | 'api' | 'subscription'; /** ID of the source (payment link ID, subscription ID, etc.) */ source_id?: string; /** Human-readable description of the source (e.g., payment link name) */ source_description?: string; } interface ReevitAPIClientConfig { /** Your Reevit public key */ publicKey?: string; /** Base URL for the Reevit API (defaults to production) */ baseUrl?: string; /** Request timeout in milliseconds */ timeout?: number; } /** * Reevit API Client */ declare class ReevitAPIClient { private readonly publicKey; private readonly baseUrl; private readonly timeout; constructor(config: ReevitAPIClientConfig); /** * Makes an authenticated API request * @param idempotencyKey Optional deterministic idempotency key for the request */ private request; /** * Creates a payment intent */ createPaymentIntent(config: ReevitCheckoutConfig, method?: PaymentMethod, country?: string, options?: { preferredProviders?: string[]; allowedProviders?: string[]; }): Promise<{ data?: PaymentIntentResponse; error?: PaymentError; }>; /** * Retrieves a payment intent by ID */ getPaymentIntent(paymentId: string): Promise<{ data?: PaymentDetailResponse; error?: PaymentError; }>; /** * Retrieves a server-created checkout session using its public session secret. */ getCheckoutSession(sessionSecret: string): Promise<{ data?: CheckoutSessionResponse; error?: PaymentError; }>; /** * Confirms a payment intent after PSP callback (public endpoint) */ confirmPaymentIntent(paymentId: string, clientSecret: string): Promise<{ data?: PaymentDetailResponse; error?: PaymentError; }>; /** * Confirms a payment after PSP callback (authenticated endpoint) */ confirmPayment(paymentId: string): Promise<{ data?: PaymentDetailResponse; error?: PaymentError; }>; /** * Cancels a payment intent */ cancelPaymentIntent(paymentId: string): Promise<{ data?: PaymentDetailResponse; error?: PaymentError; }>; /** * Creates a Hubtel session token for secure checkout. * This endpoint generates a short-lived token that maps to Hubtel credentials server-side, * avoiding exposure of sensitive credentials to the client. * * @param paymentId - The payment intent ID for Hubtel checkout * @returns Hubtel session with token, merchant account, and expiry information */ createHubtelSession(paymentId: string, clientSecret?: string): Promise<{ data?: HubtelSessionResponse; error?: PaymentError; }>; /** * Maps SDK payment method to backend format */ private mapPaymentMethod; } /** * Creates a new Reevit API client instance */ declare function createReevitClient(config: ReevitAPIClientConfig): ReevitAPIClient; /** * Format amount for display */ declare function formatAmount(amount: number, currency: string): string; /** * Validate phone number for mobile money */ declare function validatePhone(phone: string, network?: string): boolean; /** * Format phone number for display */ declare function formatPhone(phone: string): string; /** * Detect mobile money network from a Ghana phone number. * Accepts local (0XXXXXXXXX) and international (233… / +233…) formats, * then matches the two-digit operator code. */ declare function detectNetwork(phone: string): string | null; export { type CheckoutState, FlutterwaveBridge, HubtelBridge, MPesaBridge, type MPesaBridgeProps, MobileMoneyForm, type MobileMoneyFormData, type MobileMoneyNetwork, MonnifyBridge, type MonnifyBridgeProps, type PaymentDetailResponse, type PaymentError, type PaymentIntent, type PaymentIntentResponse, type PaymentMethod, PaymentMethodSelector, type PaymentResult, type PaymentSource, PaystackBridge, ReevitAPIClient, type ReevitAPIClientConfig, ReevitCheckout, type ReevitCheckoutCallbacks, type ReevitCheckoutConfig, type ReevitCheckoutProps, type ReevitTheme, StripeBridge, type StripeBridgeProps, createReevitClient, detectNetwork, formatAmount, formatPhone, loadFlutterwaveScript, loadMonnifyScript, loadPaystackScript, loadStripeScript, openHubtelPopup, useMPesaStatusPolling, useReevit, useReevitContext, validatePhone };