@tecafrik/africa-payment-sdk
Version:
A single SDK to integrate all african payment providers seamlessly
139 lines • 4.38 kB
TypeScript
/// <reference types="node" />
import { MobileMoneyCheckoutOptions, CheckoutResult, PaymentProvider, RefundOptions, RefundResult, CreditCardCheckoutOptions, MobileMoneyPayoutOptions, PayoutResult, RedirectCheckoutOptions } from "../payment-provider.interface";
import EventEmitter2 from "eventemitter2";
import { PaymentCancelledEvent, PaymentFailedEvent, PaymentSuccessfulEvent } from "../payment-events";
declare class PaydunyaPaymentProvider implements PaymentProvider {
private config;
private api;
private eventEmitter?;
private masterKeySha512Hash;
constructor(config: PaydunyaPaymentProviderConfig);
useEventEmitter(eventEmitter: EventEmitter2): void;
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 | PaymentCancelledEvent | null>;
}
export type PaydunyaPaymentProviderConfig = {
masterKey: string;
privateKey: string;
publicKey: string;
token: string;
mode: "test" | "live";
store: {
name: string;
};
callbackUrl: string;
};
export type PaydunyaCreateInvoiceSuccessResponse = {
response_code: "00";
response_text: string;
description: string;
token: string;
};
export type PaydunyaCreateInvoiceErrorResponse = {
response_code: Exclude<string, "00">;
response_text: string;
};
export type PaydunyaWavePaymentSuccessResponse = {
success: true;
message: string;
url: string;
};
export type PaydunyaWavePaymentErrorResponse = {
success: false | undefined;
message: string;
};
export type PaydunyaOrangeMoneyPaymentSuccessResponse = {
success: true;
message: string;
fees: number;
currency: string;
};
export type PaydunyaOrangeMoneyPaymentErrorResponse = {
success: false | undefined;
message: string;
};
export type PaydunyaPaymentWebhookBody = {
response_code: string;
response_text: string;
hash: string;
invoice: PaydunyaInvoice;
custom_data: Record<string, any>;
actions: {
cancel_url: string;
callback_url: string;
return_url: string;
};
mode: string;
status: string;
fail_reason: string;
customer: {
name: string;
phone: string;
email: string;
payment_method: string;
};
receipt_identifier: string;
receipt_url: string;
provider_reference: string;
};
export type PaydunyaInvoice = {
token: string;
pal_is_on: string;
total_amount: string;
total_amount_without_fees: string;
description: string;
expire_date: string;
};
export type PaydunyaGetInvoiceSuccessResponse = {
response_code: "00";
response_text: string;
hash: string;
invoice: PaydunyaInvoice;
custom_data: Record<string, any>;
actions: {
cancel_url: string;
callback_url: string;
return_url: string;
};
mode: string;
status: string;
fail_reason: string;
customer: {
name: string;
phone: string;
email: string;
payment_method: string;
};
receipt_url: string;
};
export type PaydunyaGetInvoiceErrorResponse = {
response_code: Exclude<string, "00">;
response_text: string;
};
export type PaydunyaCreateDisburseInvoiceSuccessResponse = {
response_code: "00";
response_text?: never;
disburse_token: string;
};
export type PaydunyaCreateDisburseInvoiceErrorResponse = {
response_code: Exclude<string, "00">;
response_text: string;
};
export type PaydunyaSubmitDisburseInvoiceSuccessResponse = {
response_code: "00";
response_text: string;
description: string;
transaction_id: string;
provider_ref?: string;
};
export type PaydunyaSubmitDisburseInvoiceErrorResponse = {
response_code: Exclude<string, "00">;
response_text: string;
};
export default PaydunyaPaymentProvider;
//# sourceMappingURL=paydunya.d.ts.map