rotsiapi
v1.1.2
Published
The official ROTSI node.js API wrapper
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 rotsiapiUsage
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.STKKRA REMIT TAX Service :
Rotsi.KRAB2C Service :
Rotsi.B2CSINGLE INVOICE Service :
Rotsi.SINGLEINVOICEBUYGOODS Service :
Rotsi.BUYGOODSPAYBILL Service :
Rotsi.PAYBILLCANCEL SINGLE INVOICE Service :
Rotsi.CANCELSINGLEINVOICE
Development
Run all tests:
$ npm install
$ npm testor on Windows...
$ npm install
$ npm run test-windowsIssues
If you find a bug, please file an issue on our issue tracker on GitHub.

