mpesa-nodejs-sdk
Version:
Node.Js wrapper for Safaricom's Mpesa API. Written in Typescript
37 lines (36 loc) • 2.1 kB
TypeScript
export declare class MpesaApi {
constructor(consumerKey: string, secret: string, shortcode: string, env?: string);
private consumerKey;
private secret;
private shortcode;
private url;
private token;
/**
* getAccessToken
* @returns a promise with the access token and success message.
*/
getAccessToken(): Promise<unknown>;
/**
* registerUrl
* Registers the confirmation and validation urls
* @param confirmationUrl - the receives the confirmation request from the API upon the
* payment completion
* @param validationUrl - receives the validation request from the API upon the payment
* submission. It is called only if the external validation on the registered shortcode is
* enabled.By default the external validation is disabled
* @param responseType - specifies what is to happen if for any reason the validation url is not
* reachable. It can only have two options 'Completed' or 'Cancelled'. Completed means Mpesa
* will automatically complete the transaction whereas cancelled means the transaction will be cancelled if the validation url is not reachable
* @returns a promise that contains the OriginatorConversationId, ConversationId and Response Description.
*/
registerUrl(confirmationUrl: string, validationUrl: string, responseType?: string): Promise<unknown>;
/**
* c2B - Make payment requests from Client to Business
* @param commandId - the unique identifier of the transaction type. Can either be CustomerPayBillOnline for paybill payments or CustomerBuyGoodsOnline for business shortcodes
* @param amount - The amount being transacted
* @param Msisdn - The phone number initiating the transaction
* @param BillRefNumber - Only used for CustomerPayBillOnline. It represents a unique bill identifier e.g. an account number
* @returns - a promise which contains originatorConversationId, conversationId and ResponseDescription
*/
c2B(commandId: string, amount: number, Msisdn: string, BillRefNumber?: string): Promise<unknown>;
}