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

node-wipay

v0.3.6

Published

This is a node wrapper for the WiPay Caribbean V1 API.

Downloads

4

Readme

Node WiPay

This is a Node Wrapper for the WiPay Caribbean V1 API written in TypeScript.

Getting Started

Installation

This package is available on the Node Package Manager and be installed with the following commands:

npm install node-wipay
yarn add node-wipay

Basic Use

To use this package you must import it using the CommonJs or Es6 Module import statement.

import * as WiPay from 'node-wipay'
const WiPayAuth = require('node-wipay').WiPayAuth;

Creating an Auth instance

const auth = WiPayAuth({
    AccountNumber: Number,
    API_Key: String,
});

Testing in Sandbox Mode

auth.LiveMode = false;

Making Voucher API Call.

const handler = new WiPayVoucher(auth);
handler.check(voucher:String)
    .then((result:WiPayVoucherResponse) => {
        console.log(result);
    })
    .catch((error:WiPayVoucherResponse) => {
        console.log(error);
    });

WiPayAuth

This class is designed as a singleton object in order to create an immutable and fault-tolerant instance of the required WiPay configuration information.

WiPayAuthConfig

This configuration interface defines the required configuration information for a WiPay authentication instance to be sucessful.

interface WiPayAuthConfig {
    AccountNumber: Number,
    API_Key: String,
}

Using this format you can initialise an authorisation object by doing the following:

const config;
const wipay_auth = WiPayAuth.getInstance(config:WiPayAuthConfig);
wipay_auth.LiveMode = false or true; // LiveMode is true by default

It is important to note that the _config of the WiPayAuth is immutable and cannot be modified, although the LiveMode:Boolean can be toggled for Live and Sandbox. Also as a Singleton object, the typical class constructor is private to prevent unwanted duplication.

Voucher API

The WiPayVoucher functions returns a Promise<WiPayVoucherResponse>. The structure of the response is as follows.

interface WiPayVoucherResponse {
    status: String,
    msg: String,
    trxn_id?: String,
    value?: Number,
}

Before any calls can be made to the object, it needs to be initialised witha valid authorisation object.

const handler = new WiPayVoucher(auth:WiPayAuth);

Check

handler.check(voucher:String)
    .then((result:WiPayVoucherResponse) => {
        console.log(result);
    })
    .catch((error:WiPayVoucherResponse) => {
        console.log(error);
    });

Pay

handler.pay(voucher:String, total:Number, details?:String)
    .then((result:WiPayVoucher) => {
        console.log(`Transaction ID is ${result.trxn_id}`);
    })
    .catch((error:WiPayVoucherResponse) => {
        console.log(`Payment failed due to: [${error.msg}]`);
    })