npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webirr

v1.0.3

Published

Official JavaScript Client Library for WeBirr Payment Gateway APIs

Downloads

17

Readme

Official JavaScript Client Library for WeBirr Payment Gateway APIs

This Client Library provides convenient access to WeBirr Payment Gateway APIs from JavaScript/Node/ReactNative Apps.

Requires Javascript engine in browser or Node

Install

run the following command to install webirr client library

With npm

$ npm install webirr

With yarn

$ yarn add webirr

With bower

$ bower install webirr

Usage

The library needs to be configured with a merchant Id & API key. You can get it by contacting webirr.com

You can use this library for production or test environments. you will need to set isTestEnv=true for test, and false for production apps when creating objects of class WeBirrClient

Example

Creating a new Bill / Updating an existing Bill on WeBirr Servers


const webirr = require('webirr');

async function main() 
{
  const apiKey = 'YOUR_API_KEY';
  const merchantId = 'YOUR_MERCHANT_ID';

  var api = new webirr.WeBirrClient(apiKey, true);

  let bill = {
    amount: '270.90',
    customerCode: 'cc01',  // it can be email address or phone number if you dont have customer code
    customerName: 'Elias Haileselassie',
    time: '2021-07-22 22:14',   // your bill time, always in this format
    description: 'hotel booking',
    billReference: 'drt/2021/131', // your unique reference number
    merchantID: merchantId,
  };

  console.log('Creating Bill...');
  var res = await api.createBill(bill);
  
  if (!res.error) {
    // success
    let paymentCode = res.res;  // returns paymentcode such as 429 723 975
    console.log( `Payment Code = ${paymentCode}`); // we may want to save payment code in local db.

  } else {
    // fail
    console.log(`error: ${res.error}`);
    console.log(
        `errorCode: ${res.errorCode}`); // can be used to handle specific busines error such as ERROR_INVLAID_INPUT_DUP_REF
  }

  // update existing bill if it is not paid
  bill.amount = "278.00";
  bill.customerName = 'Elias javascript';
  //bill.billReference = "WE CAN NOT CHANGE THIS";

  console.log('Updating Bill...');
  res = await api.updateBill(bill);

  if (!res.error) {
    // success
    console.log('bill is updated succesfully'); //res.res will be 'OK'  no need to check here!
  } else {
    // fail
    console.log(`error: ${res.error}`);
    console.log(`errorCode: ${res.errorCode}`); // can be used to handle specific busines error such as ERROR_INVLAID_INPUT
  }

}

main();

Getting Payment status of an existing Bill from WeBirr Servers


const webirr = require('webirr');

async function main() 
{
  const apiKey = 'YOUR_API_KEY';
  
  var api = new webirr.WeBirrClient(apiKey, true);

  var paymentCode = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL';  // suchas as '141 263 782';
  
  console.log('Getting Payment Status...');
  var r = await api.getPaymentStatus('624549955');

  if (!r.error) {
    // success
    if (r.res.status == 2) {
      console.log('bill is paid');
      console.log('bill payment detail');
      console.log(`Bank: ${r.res.data.bankID}`);
      console.log(`Bank Reference Number: ${r.res.data.paymentReference}`);
      console.log('Amount Paid: ${r.res?.data?.amount}');
    } else
      console.log('bill is pending payment');
  } else {
    // fail
    console.log(`error: ${r.error}`);
    console.log( `errorCode: ${r.errorCode}`); // can be used to handle specific busines error such as ERROR_INVLAID_INPUT
  }

}

main();

Sample object returned from getPaymentStatus()

{
  error: null,
  res: {
    status: 2,
    data: {
      id: 111112347,
      paymentReference: '8G3303GHJN',      
      confirmed: true,
      confirmedTime: '2021-07-03 10:25:35',
      bankID: 'cbe_birr',
      time: '2021-07-03 10:25:33',
      amount: '4.60',
      wbcCode: '624 549 955'
    }
  },
  errorCode: null
}

Deleting an existing Bill from WeBirr Servers (if it is not paid)


const webirr = require('webirr');

async function main() 
{
  const apiKey = 'YOUR_API_KEY';

  var api = new webirr.WeBirrClient(apiKey, true);

  var paymentCode = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL';  // suchas as '141 263 782';
  
  console.log('Deleting Bill...');
  var res = await api.deleteBill(paymentCode);

  if (!res.error) {
    // success
    console.log('bill is deleted succesfully'); //res.res will be 'OK'  no need to check here!
  } else {
    // fail
    console.log(`error: ${res.error}`);
    console.log(`errorCode: ${res.errorCode}`); // can be used to handle specific bussines error such as ERROR_INVLAID_INPUT
  }
  
}  

main();