1.1.2 • Published 3 months ago

rotsiapi v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

ROTSI API Node.js SDK

NPM

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:

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.