Installation

Install swervpay-node sdk into your new or existing NodeJS application using any of your favorite package manager.

Shell
$ npm install @swervpaydev/sdk
$ yarn add @swervpaydev/sdk
$ pnpm add @swervpaydev/sdk
$ bun install @swervpaydev/sdk

Usage

Create swervpay instance with your Business ID and secret.

NodeJS
import { SwervpayClient } from "@swervpaydev/sdk";

const swervpay = new SwervpayClient({
  businessId: process.env.SWERVPAY_API_KEY!,
  secretKey: process.env.SWERVPAY_API_SECRET!,
  logLevel: "debug",
});

Create a Payout

Create a new payout

NodeJS
const payout = await swervpay.payout.create({
    amount: req.body.amount,
    currency: req.body.currency,
    bank_code: req.body.bank_code,
    account_number: req.body.account_number,
    naration: req.body.narration,
    email: req.body.email,
    reference: req.body.reference,
});

Get payout

Get a payout

NodeJS
const payout = await swervpay.payout.get(req.param.id);

Get transactions

Retrieve all transactions

NodeJS
const transactions = await swervpay.transaction.gets({
    limit: parseInt(req.query.limit as string),
    page: parseInt(req.query.page as string),
});

Get transaction

Get a transaction

NodeJS
const transaction = await swervpay.transaction.get(req.param.id);

Create a customer

Create a new customer

NodeJS
const customer = await swervpay.customer.create({
    firstname: req.body.first_name,
    lastname: req.body.last_name,
    email: req.body.email,
    middlename: "",
    country: req.body.country,
});

Update a customer

Update a customer

NodeJS
 const customer = await swervpay.customer.update(req.params.id, {
    email: req.body.email,
    phone_number: req.body.phone_number,
});

Complete customer KYC

Create/Update customer KYC

NodeJS
 const customer = await swervpay.customer.kyc(req.params.id, {
    tier: req.body.tier as "ONE" | "TWO" | "FULL",
    document: {
        document_type: req.body.document_type,
        document: req.body.document,
        passport: req.body.passport,
        document_number: req.body.document_number,
    },
    information: {
        address: req.body.address,
        city: req.body.city,
        bvn: req.body.bvn,
        state: req.body.state,
        country: req.body.country,
        postal_code: req.body.postal_code,
    },
});

Get customers

Retrieve all customers

NodeJS
const customers = await swervpay.customer.gets({
    limit: parseInt(req.query.limit as string),
    page: parseInt(req.query.page as string),
});

Get customer

Get a customer

NodeJS
const customer = await swervpay.customer.get(req.param.id);

Create a card

Create a new card

NodeJS
const card = await swervpay.card.create({
    amount: req.body.amount,
    currency: req.body.currency,
    customer_id: req.body.customer_id,
    type: req.body.type as "LITE" | "DEFAULT" | "COOPERATE",
    issuer: req.body.issuer as "MASTERCARD" | "VISA",
    name_on_card: req.body.name_on_card,
});

Get cards

Retrieve all cards

NodeJS
const cards = await swervpay.card.gets({
    limit: parseInt(req.query.limit as string),
    page: parseInt(req.query.page as string),
});

Get card

Get a card

NodeJS
const card = await swervpay.card.get(req.param.id);

Webhook test

Send a test webhook

NodeJS
await swervpay.webhook.test(req.params.id);

Webhook retry

Retry a webhook log

NodeJS
await swervpay.webhook.retry(req.params.id);

Get banks

Retrieve all banks

NodeJS
const banks = await swervpay.other.banks();

Resolve account number

Resolve an account number

NodeJS
const result = await swervpay.other.resolve_account_number({
    bank_code: req.body.bank_code as string,
    account_number: req.body.account_number as string,
});

FX rate

Get the current exchange rate

NodeJS
const result = await swervpay.fx.rate({
    from: req.body.bank_code as string,
    to: req.body.account_number as string,
    amount: req.body.amount as number,
});

FX Exchnage

Create a swap transaction

NodeJS
const result = await swervpay.fx.rate({
    from: req.body.bank_code as string,
    to: req.body.account_number as string,
    amount: req.body.amount as number,
});

Get wallet

Get a wallet

NodeJS
const wallet = await swervpay.wallet.get(req.params.id);

Get wallets

Retrieve all wallets

NodeJS
 const wallets = await swervpay.wallet.gets({
    limit: parseInt(req.query.limit as string),
    page: parseInt(req.query.page as string),
});

See more examples