UNPKG

@tecafrik/africa-payment-sdk

Version:

A single SDK to integrate all african payment providers seamlessly

116 lines 4.05 kB
/// <reference types="node" /> import { MobileMoneyCheckoutOptions, CheckoutResult, PaymentProvider, RefundOptions, RefundResult, CreditCardCheckoutOptions, MobileMoneyPayoutOptions, PayoutResult, RedirectCheckoutOptions } from "../payment-provider.interface"; import EventEmitter2 from "eventemitter2"; import { PaymentFailedEvent, PaymentSuccessfulEvent } from "../payment-events"; export declare enum TaarihTransactionStatus { PENDING = "PENDING", COMPLETED = "COMPLETED", FAILED = "FAILED" } declare class TaarihPaymentProvider implements PaymentProvider { private config; private api; private eventEmitter?; constructor(config: TaarihPaymentProviderConfig); useEventEmitter(eventEmitter: EventEmitter2): void; private getTaarihPaymentMethod; login(): Promise<SignEndUserSuccessResponse>; checkout(options: MobileMoneyCheckoutOptions | CreditCardCheckoutOptions): Promise<CheckoutResult>; checkoutMobileMoney(options: MobileMoneyCheckoutOptions): Promise<CheckoutResult>; checkoutCreditCard(options: CreditCardCheckoutOptions): Promise<CheckoutResult>; checkoutRedirect(options: RedirectCheckoutOptions): Promise<CheckoutResult>; refund(options: RefundOptions): Promise<RefundResult>; payoutMobileMoney(options: MobileMoneyPayoutOptions): Promise<PayoutResult>; handleWebhook(rawBody: Buffer | string | Record<string, unknown>): Promise<PaymentSuccessfulEvent | PaymentFailedEvent | null>; callback(internalId: string, timeInterval?: number, maxAttempts?: number): Promise<Pick<TaarihTransactionStatusSuccessResponse, "status" | "currency" | "amount" | "bankAccountSender">>; } export type TaarihPaymentProviderConfig = { phoneNumber: string; password: string; mode: "test" | "live"; visitorId: string; callingCode: string; }; export type SignEndUserOtpRequiredResponse = { otpRequired: boolean; message: string; token: string; }; export type SignEndUserSuccessResponse = { token: string; id: number; legalEntityId: number; legalEntityName: string; refreshToken: string; firstName: string; lastName: string; phoneNumber: string; userBankAccounts: { id: number; commercial_name: string; technical_name: string; }[]; }; export type TaarihApiErrorResponse = { statusCode: number; timestamp: string; path: string; message: string; invalidData: Record<string, string> | null; }; export type TaarihCheckoutSuccessResponse = { externalId: string; payment_link: string; internalId: string; }; export type TaarihCreditCardCheckoutSuccessResponse = { results?: TaarihCheckoutSuccessResponse[]; }; export type TaarihCheckoutPreAuthSuccessResponse = { amount: number; fees: number; totalAmount: number; paymentMethod: string; }; export type TaarihPaymentWebhookBody = { transactionId: string; maxAttempts: number; timeInterval: number; }; export type TaarihTransactionStatusSuccessResponse = { status: string; amount: number; currency: string; bankAccountSender: string | null; bankAccount: { id: number; refId: string; commercial_name: string; technical_name: string; type: string; mainAccountNumber: string; subAccountNumber: ({ subAccountNumber: string; financialSubAccount: string; } | { subAccountNumber: string; financialSubAccount: string; }[])[]; externalId: string | null; lettrable: any | null; rules: any | null; active: boolean; createdAt: string; updatedAt: string; accountOwnerId: number | null; legalEntityOwnerId: number; technicalAccountType: string; balance: number; attributions: any[]; partnerAccountNumber: string | null; financialProductId: number; status: string; }; }; export default TaarihPaymentProvider; //# sourceMappingURL=taarih.d.ts.map