UNPKG

@johntad/m-pesa

Version:

A TypeScript SDK for integrating M-Pesa mobile payment services into applications, enabling seamless money transfers and transactions.

51 lines (50 loc) 1.56 kB
/** * Represents the response from the B2C Pay Out API. */ export type B2CResponseType = { ConversationID: string; OriginatorConversationID: string; ResponseCode: string; ResponseDescription: string; }; /** * Represents the payload required for the B2C Pay Out request. */ export type B2CPayloadType = { InitiatorName: string; SecurityCredential: string; CommandID: 'BusinessPayment' | 'SalaryPayment' | 'PromotionPayment'; Amount: number; PartyA: number; PartyB: string; Remarks: string; QueueTimeOutURL: string; ResultURL: string; Occassion: string; }; /** * Represents the response object from the B2C Pay Out API. */ export declare class B2CResponse { ConversationID: string; OriginatorConversationID: string; ResponseCode: string; ResponseDescription: string; constructor(ConversationID: string, OriginatorConversationID: string, ResponseCode: string, ResponseDescription: string); /** * Factory method to create an instance from API response data. * @param data - The raw response data from the API. * @returns An instance of B2CResponse. */ static fromApiResponse(data: B2CResponseType): B2CResponse; /** * Determines if the response indicates success. * @returns True if the response was successful, false otherwise. */ isSuccess(): boolean; /** * Returns a formatted string for logging or displaying the response. * @returns A formatted string summarizing the response. */ toString(): string; }