/** * Configuration for SimpliPay Checkout */ export interface SimpliPayConfig { /** Your SimpliPay public key */ publicKey: string; /** Environment: 'development' | 'production' */ environment?: 'development' | 'production'; /** Custom API base URL (optional) */ baseUrl?: string; } /** * Payment data for checkout */ export interface PaymentData { /** Organization ID from SimpliPay */ organizationId: string; /** Customer email address */ email: string; /** Customer phone number (with country code, e.g., +2348012345678) */ phone: string; /** Payment amount */ amount: number; /** Currency code (e.g., 'NGN') */ currency: string; /** Unique transaction reference */ transactionRef: string; /** Your customer's unique identifier */ customerId: string; /** Service ID for the payment */ serviceId?: string; /** Payment narration/description */ narration?: string; /** Merchant/business name to display */ merchantName?: string; /** Additional metadata */ metadata?: Record; } /** * Callback functions for checkout events */ export interface CheckoutCallbacks { /** Called when payment is successful */ onSuccess: (result: TransactionResult) => void; /** Called when payment fails */ onError: (error: TransactionError) => void; /** Called when user closes the checkout */ onClose: () => void; /** Called before payment initiation (optional) */ onBeforePayment?: () => void | Promise; } /** * Transaction result on successful payment */ export interface TransactionResult { success: true; transactionRef: string; message: string; amount: number; currency: string; paymentMethod: string; responseCode?: string; } /** * Transaction error */ export interface TransactionError { success: false; message: string; code?: string; transactionRef?: string; } /** * Props for SimpliPayCheckout component */ export interface SimpliPayCheckoutProps { /** Whether to show the checkout modal */ isOpen: boolean; /** Payment data */ paymentData: PaymentData; /** SimpliPay configuration */ config: SimpliPayConfig; /** Callback functions */ callbacks: CheckoutCallbacks; } /** * Internal checkout state */ export type CheckoutStep = 'card' | 'pin' | 'otp' | 'success' | 'error'; export interface CardDetails { pan: string; expiryDate: string; cvv: string; } export interface TransactionRequest { organizationId: string; transactionRef: string; customerId: string; customerEmail: string; customerPhone: string; amount: number; currency: string; paymentMethod: 'CARD' | 'BANK' | 'USSD'; serviceId?: string; authData: string; narration?: string; } export interface OtpAuthRequest { transactionRef: string; otp: string; } export interface ApiResponse { success: boolean; message: string; data?: any; responseCode?: string; }