node-pesa
node-pesa copied to clipboard
Pesa SDK
Node pesa
Integration that simplifies access to M-Pesa's OpenAPI for developers to build applications/ software by providing easy access to services like Customer to Business (C2B), Query, and more.
π§ Documentation
Take a look at the API docs here.
π Getting Started
-
Sign up for OpenAPI Portal β Before you begin, you need to sign up for an account and retrieve your credentials.
-
Minimum requirements β To run the SDK, your system will need to meet the minimum requirements, including having Node >= 10.1.
-
Install the SDK β Using NPM is the recommended way to install the Pesa SDK for JS. The SDK is available via [NPM] under the
openpesa/pesa-js
package. You can run the following in the base directory of your project to add the SDK as a dependency:npm install openpesa/pesa-js
Please see the Installation section of the User Guide for more detailed information about installing the SDK through Composer and other means.
-
Using the SDK β The best way to become familiar with how to use the SDK is to read the User Guide.
πΌ Usage
import { Pesa } from '@openpesa/pesa-js';
// Populate the credentials
const api_key = 'your_api_key';
const public_key = 'the_public_key';
// Intiate with credentials
let pesa = new Pesa({ api_key, public_key });
// Setup the transaction
let data = {
input_Amount: 10000,
// ..
};
// Execute the transaction
pesa.c2b(data)
.then((data) => {
// Print results
console.log(data);
})
.catch((e) => {
console.log('err: ' + e);
});
π§ͺ Test
npm test
πΊοΈ Road Map
- Validate data input using Regex before the API call.
- If fields are not provided then generate a random string for "input_ThirdPartyConversationID" and "input_TransactionReference"
- Allow optional input for not required fields in a request.
- Check and Throw an error when used outside of Node.js due to security reasons, Advice on use outside Node.js.
- Validate Secret Keys length and format.
- Allow user use custom sessionID on any/each transaction. (Portal allow for seesion with several hours of validity)
- Add and improve documentation and examples(example will include expressjs app)
π Changelog
Please see CHANGELOG for more information on what has changed recently.
π€ Contributing
Please see CONTRIBUTING for details.
π Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
π₯ Credits
- All Contributors
π License
The MIT License (MIT). Please see License File for more information.