1.0.0 • Published 12 months ago

orange-sonatel v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Orange Sonatel API Wrapper

This is a JavaScript wrapper for the Orange Sonatel API. It provides methods to interact with the Orange Sonatel API for various operations such as getting access tokens, retrieving retailer balances, performing cash-ins, and retrieving customer profiles.

Installation

To use this wrapper, you need to have Node.js installed. Then, you can install the package using npm:

npm install orangesonatel

Usage

Import the Orangesonatel class from the package and create an instance by providing the required parameters: client_id, client_secret, and encrypted_pincode.

const Orangesonatel = require('orangesonatel');

const client_id = 'your_client_id';
const client_secret = 'your_client_secret';
const encrypted_pincode = 'your_encrypted_pincode';

const orangeSonatel = new Orangesonatel(client_id, client_secret, encrypted_pincode);

Getting Access Token

To get an access token, use the get_access_token method. Pass the mode parameter as 'sandbox' or 'production' to specify the environment.

const mode = 'sandbox'; // or 'production'

orangeSonatel.get_access_token(mode)
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle the error
    console.error(error);
  });

Getting Retailer Balance

To retrieve the retailer balance, use the get_retailer_balance method. Provide the mobile_number of the retailer, access_token obtained from the previous step, and the mode parameter.

const mobile_number = 'retailer_mobile_number';
const access_token = 'access_token';
const mode = 'sandbox'; // or 'production'

orangeSonatel.get_retailer_balance(mobile_number, access_token, mode)
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle the error
    console.error(error);
  });

Cash-in

To perform a cash-in transaction, use the cashin method. Provide the retailer's mobile_number, customer's mobile_number, amount, access_token, and the mode parameter.

const retailer_mobile_number = 'retailer_mobile_number';
const customer_mobile_number = 'customer_mobile_number';
const amount = 100; // Amount in XOF
const access_token = 'access_token';
const mode = 'sandbox'; // or 'production'

orangeSonatel.cashin(retailer_mobile_number, customer_mobile_number, amount, access_token, mode)
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle the error
    console.error(error);
  });

Getting Customer Profile

To retrieve the customer's profile, use the get_customer_profile method. Provide the access_token, customer's mobile_number, and the mode parameter.

const access_token = 'access_token';
const customer_mobile_number = 'customer_mobile_number';
const mode = 'sandbox'; // or 'production'

orangeSonatel.get_customer_profile(access_token, customer_mobile_number, mode)
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle the error
    console.error(error);
  });

Contributing Contributions are welcome! If you find any issues or want to add new features, please

1.0.0

12 months ago