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

@iamshabell/waafipay-sdk

v0.1.1

Published

This is a TypeScript version of this previous [waafipay-sdk-node](https://www.npmjs.com/package/waafipay-sdk-node) package.

Downloads

3

Readme

WaafiPay SDK Guide

This is a TypeScript version of this previous waafipay-sdk-node package.

If you’re new to TypeScript, checkout this handy cheatsheet

Installing

To install waafi-pay-sdk, use:

npm intall waafi-pay-sdk # or yarn add waafi-pay-sdk

There are two methods available in this sdk is apiPurchase and creditAccount. In order to use this methods, you need to have api credentials from waafi pay(API KEY,API USER ID,MERCHANT KEY).

Api Purchase

This method is for Getting Money From Customers. You will need to pass the customer's information, including phone number, amount, currency, description.

An example of Api Purchasing with express:

...
import { WaafiAPI } from "waafi-pay-sdk";

const app: Express = express();
const port = 3001;

const waafipay = new WaafiAPI(
  "API_KEY",
  "API_USER_ID",
  "MERCHANT_KEY",
  true, //--> isTestMode -> true is production : false is test
  );


app.post("/purchase", async (req: Request, res: Response, next) => {
  try {
    const { accountNo, amount, currency, description } = req.body;

    const result = await waafipay.apiPurchase({
      accountNo: accountNo,
      amount: amount,
      currency: currency,
      description: description,
    });

    console.log("result: " + JSON.stringify(result));
    res.status(200).json(JSON.stringify(result));
  } catch (e) {
    console.log(e);

    res.status(400).send(e);
  }
});

...

And here is an example of the request body:

{
    "accountNo": "2526XXXXXX", //-> customer's phone number
    "amount": 1,
    "currency": "USD", //-> optional, default is USD. It also takes (SLSH)
    "description": "test"
}

When it is success, it will return this:

{
    "schemaVersion": "1.0",
    "timestamp": "2022-2-22 22:22:22.22",
    "requestId": "45231213",
    "sessionId": null,
    "responseCode": "2001",
    "errorCode": "0",
    "responseMsg": "RCS_SUCCESS",
    "params": {
        "issuerApprovalCode": "",
        "accountNo": "2526*********",
        "accountType": "MWALLET_ACCOUNT",
        "accountholder": "",
        "state": "APPROVED",
        "merchantCharges": "111",
        "customerCharges": "0.0",
        "referenceId": "455656",
        "transactionId": "465656",
        "accountExpDate": "",
        "issuerTransactionId": "23156231",
        "txAmount": "0"
    }
}

If everything gone through success, responseCode will be 2001. If there are other problems:

User Aborted(canceled):

  • responseCode: 5206
  • responseMsg: "RCS_TRAN_FAILED_AT_ISSUER_SYSTEM (STATE: rejected, ERRCODE: 4004 - User Aborted, TransactionId: 465656)"

User Insufficient:

  • responseCode: 5206
  • responseMsg: "RCS_TRAN_FAILED_AT_ISSUER_SYSTEM (STATE: declined, ERRCODE: 8001 - Hadhaagaagu kuguma filna. Hadhaagaagu waa {SENDERBALANCE}, TransactionId: 465656)"

Credit Account

This method is for when you want to withdraw your money from Waafi to your account. Your account is either regular account or merchant account

An example of Crediting to Account :

...
app.post("/credit", async (req: Request, res: Response, next) => {
  try {
    const { accountNo, accountName, amount, currency, description, accountType } = req.body;

    const response = await waafipay.creditAccount({
      accountNo: accountNo,
      accountHolder: accountName,
      amount: amount,
      currency: currency,
      description: description,
      accountType: accountType,
    });

    console.log("response: " + JSON.stringify(response));
    res.status(200).json(JSON.stringify(response));
  } catch (e) {
    console.log(e);

    res.status(400).send(e);
  }
});
...

And here is an example of the body:

{
    "accountNo": "2526XXXXXX", //-> reciever's phone number
    "accountName": "GEEDI", // -> reciever's name,
    "accountType": "CUSTOMER", // -> recievers account type, it als could be (MERCHANT)
    "amount": 1,
    "currency": "USD", //-> optional, default is USD. It also takes (SLSH)
    "description": "test"
}

When it is success, it will return this:

{
    "schemaVersion": "1.0",
    "timestamp": "2022-2-22 22:22:22.22",
    "requestId": "45231213",
    "sessionId": null,
    "responseCode": "2001",
    "errorCode": "0",
    "responseMsg": "RCS_SUCCESS",
    "params": {
        "issuerApprovalCode": "",
        "accountNo": "2526*********",
        "accountType": "MWALLET_ACCOUNT",
        "accountholder": "GEEDI",
        "state": "APPROVED",
        "merchantCharges": "111",
        "customerCharges": "0.0",
        "referenceId": "455656",
        "transactionId": "465656",
        "accountExpDate": "",
        "issuerTransactionId": "23156231",
        "txAmount": "0"
    }
}

If everything gone through success, responseCode will be 2001. If there are other problems:

Your Account(Waafi) has insufficient money:

  • responseCode: 50333
  • responseMsg: "RCS_ACC_INSUFFICIENT_BALANCE"

Support

This packages will be open source, feel free to contribute.