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

waafipay

v0.0.2

Published

WaafiPay's official node sdk

Downloads

76

Readme

WaafiPay Node SDK

The official Node SDK for interacting with the WaafiPay payment gateway

Installation

Install the package using npm:

npm i waafipay

Usage

Initialize the Client

To start using the package, you need to initialize the WaafiPayClient with your credentials and environment settings:

import { WaafiPayClient } from "waafipay";

const client = new WaafiPayClient({
  apiKey: "API-669892958AHX", // Your API key provided by WaafiPay
  storeId: 1000312, // Store ID / User ID provided by WaafiPay
  merchantUID: "M0912255", // Your unique merchant identifier provided by WaafiPay
  environment: "sandbox", // Use "production" for live environments
});

Create a Pamyent

You can create a payment by calling the createPayment method:

(async () => {
  try {
    const paymentResponse = await client.createPayment({
      accountNumber: "252615112233", // Mandatory, use international format without the leading "+" sign
      referenceId: "123456789", // Unique reference ID from your system
      amount: 10, // Required
      description: "Order payment for invoice #123", // Required
      paymentMethod: "WALLET", // Custom value, mapped internally to MWALLET_ACCOUNT
      // Optional fields:
      // invoiceId: "154",
      // currency: "EUR",
    });

    console.log("Payment Response:", paymentResponse);
  } catch (error) {
    console.error("Error:", error);
  }
})();

Example Payment Response

Here’s an example of the response you can expect from the createPayment method:

{
  "schemaVersion": "1.0",
  "timestamp": "2024-12-05 09:04:44.741",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "accountNo": "252615****2233",
    "accountType": "MWALLET_ACCOUNT",
    "state": "APPROVED",
    "merchantCharges": "0.1",
    "referenceId": "1234",
    "transactionId": "1268666",
    "issuerTransactionId": "ISR0011268666",
    "txAmount": "10.0"
  }
}

Configuration Options

The WaafiPayClient requires the following configuration options:

| Option | Type | Description | | ------------- | --------------------------- | ---------------------------------------------------------------------- | | apiKey | string | Your API key for authentication. | | merchantUID | string | Your unique merchant identifier. | | storeId | number | The store ID or User ID associated with your merchant account. | | environment | "sandbox" \| "production" | The environment to use (sandbox for testing, production for live). |

Features

  • Environment-Specific Endpoints: Automatically switches between sandbox and production environments.
  • Simplified Payment Requests: Create payments with minimal configuration.
  • Custom Payment Methods: Accepts WALLET and BANK as simplified payment methods and maps them to the required API values.
  • TypeScript Support: Strongly typed interfaces for easy development.

Roadmap

  • Implement the rest of WaafiPay APIs.
  • Include transaction history retrieval.
  • Expand error handling and reporting.

License

This project is licensed under the MIT License. See the LICENSE file for details.