mpesalib is a Node.js library for Safaricom Daraja API Made for OOP developers with love. You don't need to know the architecture of the Daraja API, just import the functions and pass correct arguments to the function and implement a method that returns a response from function.instance.
- Node v10+ recommended.
- npm v6
- ES7/ES6 foundation
You need the following for the .env file all are optional as you can pass them directly as arguments:
- Consumer Key and Consume Secret
- Test Credentials
- API prefix which is the environment
- Certificate Path
- Short Code, Phone Number and anything that can be passed to the configuration file
Download the source code and install locally using npm Use the node package manager to install mpesalib
npm install mpesalib
'use strict';
var Mpesa = require('mpesalib');
//create a new instance
var MpesaApp = new Mpesa();
await MpesaApp.MpesaC2Bs(901292, 254798283876, 1000, 'ref-id');
'use strict';
//imports the b2b mpesa api
var Mpesa = require('mpesalib').MpesaB2B;
- Tests
- Detailed Documentation
- Data validation
- Code Refactoring
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
I did not write tests so if you wish you can include tests for existing functions. Please make sure to update tests as appropriate.