0.1.6 • Published 2 months ago

mpw-node v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

The library simplifies interaction with Moipayway APIs in your Node applications. It streamlines the process of integration, eliminating the need to deal with intricate details, and facilitates rapid API calls. Key features includes:

  • Wallets: creating and managing wallets (fiat, crypto).
  • Making transfers, single/bulk. Fiat (NGN, GBP, EUR, USD) & Crypto.
  • Manage virtual accounts.
  • Tokens: create and manage token, such as; NFT, fungible token, stable coins, storage token, etc.
  • Verification: running identity checks, credit checks etc.
  • AI: verify document image (drivers license NIN, BVN, etc), Face Comparison.
  • Lookups: Document validity check, CAC, etc.

Requirements

  1. Node 14 or higher.

Installation

npm install mpw-node

Initialization

import { MoiPayWay } from "mpw-node"

const mpw = new MoiPayWay("secret_token");

try {
    console.log(await mpw.misc.countries())
} catch (e) {
    console.log(e)
}

Authenticate

Refer to the documentation linked below to understand how to generate secret tokens for authenticating the Moipayway SDK.

Authentication

Sending requests with payload

Some endpoint requires additional data to be included in the request payload. Below is an example demonstrating sending requests with payload:

import { MoiPayWay } from "mpw-node"

const mpw = new MoiPayWay("secret_token");

try {
    const response = await mpw.wallet.create.fiat({
        code: "***",
        meta: {
            name: "***",
            user_id: "***" 
        }
    });
    console.log(response)
} catch (e) {
    console.log(e)
}

Furthermore, your IDE may offer payload suggestions to facilitate the process. Each response has a return type which will also aid in consuming the data received.

Preview

Error handling

You can catch request errors by wrapping the method in a try / catch block.

...

const mpw = new MoiPayWay("invalid_api_secret_key");

try {
    const response = await mpw.token.multi.mint(payload);
    console.log(response)
} catch (e) {
    console.log(e)
}

Response :

BadRequestError {
  name: 'BadRequestError',
  status: 400,
  message: 'Invalid authorization bearer'
}

More usage documentation

Testing

Prior to running tests, ensure you have renamed the .env.example file to .env and populated it with a test key (testSecretKey). Then, execute the following command:

npm test

License

MIT

0.1.6

2 months ago

0.1.5

2 months ago

0.1.4

3 months ago

0.1.0

3 months ago

0.1.2

3 months ago

0.1.1

3 months ago

0.1.3

3 months ago

0.0.13

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago