UNPKG

np-payment-sdk

Version:

Unified Payment SDK for Nepal (eSewa, Khalti, ConnectIPS, IME Pay, Mobile Banking)

82 lines (81 loc) 2.83 kB
import { EsewaConfig } from './gateways/esewa'; import { KhaltiConfig } from './gateways/khalti'; import { ConnectIPSConfig } from './gateways/connectips'; import { IMEPayConfig } from './gateways/imepay'; import { MobileBankingConfig } from './gateways/mobilebanking'; import { PaymentParams, PaymentResult } from './types'; import { TransactionRecord } from './utils/transactionStore'; import { IPaymentGateway } from './types/gateway'; import { eventBus } from './utils/eventBus'; import { VerifyParams, RefundParams, SubscriptionParams, InvoiceParams, WalletParams, SubscriptionResult, InvoiceResult, WalletResult } from './types/gateway'; export declare enum GatewayType { ESEWA = "esewa", KHALTI = "khalti", CONNECTIPS = "connectips", IMEPAY = "imepay", MOBILEBANKING = "mobilebanking", STRIPE = "stripe", PAYPAL = "paypal", RAZORPAY = "razorpay", CASHFREE = "cashfree", FLUTTERWAVE = "flutterwave", PAYSTACK = "paystack" } export interface PaymentSDKConfig { mode: 'sandbox' | 'production'; gateways: { esewa?: EsewaConfig; khalti?: KhaltiConfig; connectips?: ConnectIPSConfig; imepay?: IMEPayConfig; mobilebanking?: MobileBankingConfig; stripe?: { apiKey: string; }; paypal?: { clientId: string; clientSecret: string; }; razorpay?: { keyId: string; keySecret: string; }; cashfree?: { clientId: string; clientSecret: string; environment?: 'TEST' | 'PROD'; }; flutterwave?: { publicKey: string; secretKey: string; encryptionKey: string; }; paystack?: { secretKey: string; }; [key: string]: unknown; }; customProviders?: { [key: string]: IPaymentGateway; }; } export declare class PaymentSDK { private config; private gateways; constructor(config: PaymentSDKConfig); /** * Register a new payment provider at runtime */ registerProvider(key: string, provider: IPaymentGateway): void; pay(params: PaymentParams): Promise<PaymentResult>; verify(params: VerifyParams): Promise<PaymentResult>; refund(params: RefundParams): Promise<PaymentResult>; subscribe(params: SubscriptionParams): Promise<SubscriptionResult>; createInvoice(params: InvoiceParams): Promise<InvoiceResult>; wallet(params: WalletParams): Promise<WalletResult>; addTransaction(record: TransactionRecord): void; updateTransaction(transactionId: string, updates: Partial<TransactionRecord>): void; getTransaction(transactionId: string): TransactionRecord | undefined; listTransactions(): TransactionRecord[]; } export { eventBus };