rotsiapi
v1.1.2
Published
The official ROTSI node.js API wrapper
Downloads
20
Maintainers
Readme
ROTSI API Node.js SDK
The wrapper provides convenient access to the ROTSI API from applications written for Node.js.
Install
You can install the package from npm by running:
$ npm i rotsiapi
Usage
The package needs to be configured with your app username and secret_key, which you can get from the dashboard.
// Import the npm package
const Rotsi = require('rotsiapi');
const username = 'xxxxxxxx';
const secretKey = 'xxxxxxxxxxxxxxxxxxxxxxx';
// Set additional options if needed
const credentials = {
secretKey: username,
username: secretKey,
};
const rotsiInstance = Rotsi(credentials);
const stkParams = {
amount: 1,
phone: '254711222333',
};
rotsiInstance.STK.initiateSTK(stkParams)
.then(response => {
console.log('STK initiated successfully:', response);
})
.catch(error => {
console.error('Error initiating STK: ', error.response ? error.response.data : error.message);
});
Initialization
Initialize the SDK as a requirement by doing require('rotsiapi')(credentials)
. After initialization, you can get instances of offered services as follows:
SMS Service :
Rotsi.STK
KRA REMIT TAX Service :
Rotsi.KRA
B2C Service :
Rotsi.B2C
SINGLE INVOICE Service :
Rotsi.SINGLEINVOICE
BUYGOODS Service :
Rotsi.BUYGOODS
PAYBILL Service :
Rotsi.PAYBILL
CANCEL SINGLE INVOICE Service :
Rotsi.CANCELSINGLEINVOICE
Development
Run all tests:
$ npm install
$ npm test
or on Windows...
$ npm install
$ npm run test-windows
Issues
If you find a bug, please file an issue on our issue tracker on GitHub.