Nourishing Pizza Microservice
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@dapi-co/dapi-node

1.0.1 • Public • Published

dapi-node

A node.js client library for the dapi API.

Table of Contents

Install

$ npm i @dapi-co/dapi-node

Getting started

The module supports all dapi API endpoints. For complete information about the API, you can check out the docs here.

APP_KEY, APP_SECRET, and APP_ENV must be provided for successful creation of the dapi api client.

const Dapi = require('dapi')
 
const client = new Dapi({
  appKey: process.env.APP_KEY,
  appSecret: process.env.APP_SECRET,
  appEnv: process.env.APP_ENV || 'sandbox',
  webhooks: ['http://localhost:3000/webhook'],
})

The appEnv parameter dictates which dapi API environment you will access. Values are:

  • sandbox: Sandbox environment, connects to sandbox.dapi.co
  • production: Production environment, connects to production.dapi.co

The webhooks parameter is optional. By default, if not provided, when a notification is to be sent, it'll be sent to all your registered webhook urls for that app on the developer dashboard. If provided, a notification will be sent, only to the these webhook urls. They have to match the ones set in the developer dashboard.

Methods

A job is created on each of the methods, except the exchangeToken method. The result of the job will be returned via webhooks. For more information, read the docs

Once an instance of the client has been created you use the following methods:

const access_code =
  'access code should be optained from dapi-connect and passed to your app'
const access_token = await client.ExchangeToken(access_code)
 
const identity = await client.Identity()
const user_accounts = await client.UserAccounts()
const account_balance = await client.AccountBalance()
const transactions = await client.Transactions()
const beneficiary_list = await client.BeneficiaryList()
const payment_job_id = await client.InitiatePayment({
  amount: 10,
  beneficiary: 'dapi_user2',
})
await client.ResumePayment({ payment_job_id, otp: '123456' })
 

Promises

All methods are async and are wrapped in promises. You can try/catch all of them, or chain them using .then() and .catch()

Support

Open an issue!

License

MIT

Install

npm i @dapi-co/dapi-node

DownloadsWeekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

6.72 kB

Total Files

6

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar