NativeScript Mpesa
Nativescript-Mpesa provides a wrapper that incorporate payments using Mpesa from within your {N} applications. The integration is achieved using the Android M-Pesa Daraja SDK libraries. Hence, has full support for Android.
Usage
Setup
First import package into the main-page's model or app.component as the case may be for either {N} Core or {N} w/ Angular
;
Then create an instance of Mpesa.
const mpesa = ;
Initialize the instance with the CustomerKey,CustomerSecret gotten from Safaricom and Env
Note Env could be SANDBOX
or PRODUCTION
mpesa
Making Payment
const mpesa = ; const lnmExpress = BusinessShortCode: "174379" PassKey: "bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919" Type: "CustomerPayBillOnline" Amount: "100" PartyA: "254708374149" PartyB: "174379" PhoneNumber: "254708374149" CallBackURL: "http://mycallbackurl.com/checkout.php" AccountReference: "001ABC" TransactionDesc: "Goods Payment" ; mpesa ; }
Lipa na M-Pesa Online Payment API
The following table highlights the requirements needed by Daraja, as described in the Safaricom Developer API Page
Name | Description | Parameter Type | Possible Values |
---|---|---|---|
BusinessShortCode | The organization shortcode used to receive the transaction | Numeric | Shortcode (6 digits) |
Passkey | Lipa Na Mpesa Online PassKey | Alpha-Numeric | |
Amount | The amount to be transacted | Numeric | 100 |
PartyA | The entity sending the funds | Numeric | MSISDN (12 digits) |
PartyB | The organization receiving the funds | Numeric | Shortcode (6 digits) |
PhoneNumber | The MSISDN sending the funds | Numeric | MSISDN (12 digits) |
CallBackURL | Call Back URL | URL | https://ip or domain:port/path |
AccountReference | Account Reference | Alpha-Numeric | Any combinations of letters and numbers |
TransactionDesc | Description of the transaction | String | any string of less then 20 characters |
Get the Pass Key Here : https://developer.safaricom.co.ke/test_credentials
Response Signature
Success Response
License
Apache License Version 2.0, January 2004