UNPKG

react-native-kora-checkout

Version:

A React Native SDK for integrating the Kora payment gateway, enabling secure and seamless payment processing in mobile applications. This SDK provides an easy-to-use interface for initializing payments, managing transaction events, and customizing payment

74 lines (66 loc) 1.76 kB
export interface koraCustomer { name: string; email: string; } export interface koraMetadata { [key: string]: string; } export type KoraPaymentChannel = | 'card' | 'bank_transfer' | 'mobile_money' | 'pay_with_bank' | 'ussd'; export type MobileMoneyCurrency = 'KES' | 'GHS' | 'XAF' | 'XOF' | 'EGP'; export interface koraConfig { publicKey: string; reference: string; amount: number; currency?: string; customer: koraCustomer; notification_url?: string; narration?: string; channels?: KoraPaymentChannel[]; default_channel?: KoraPaymentChannel; metadata?: koraMetadata; containerId?: string; merchant_bears_cost?: boolean; } export interface koraCallbacks { onClose?: () => void; onSuccess?: (data: any) => void; onFailed?: (data: any) => void; onTokenized?: (data: any) => void; onPending?: (data: any) => void; } export const createMobileMoneyConfig = ( baseConfig: Omit<koraConfig, 'channels' | 'default_channel'>, currency: MobileMoneyCurrency ): koraConfig => ({ ...baseConfig, currency, channels: ['mobile_money'], default_channel: 'mobile_money', }); export const MOBILE_MONEY_CONFIGS = { KENYA: { currency: 'KES' as MobileMoneyCurrency, supportedNetworks: ['M-Pesa', 'Airtel', 'Equitel'], }, GHANA: { currency: 'GHS' as MobileMoneyCurrency, supportedNetworks: ['MTN Momo', 'Airtel Tigo', 'Vodafone'], }, CAMEROON: { currency: 'XAF' as MobileMoneyCurrency, supportedNetworks: ['MTN', 'Orange'], }, EGYPT: { currency: 'EGP' as MobileMoneyCurrency, supportedNetworks: ['MTN', 'Orange', 'Moov', 'Wave'], }, IVORY_COAST: { currency: 'XOF' as MobileMoneyCurrency, supportedNetworks: ['Vodafone', 'Orange', 'Etisalat'], }, } as const;