@swervpaydev/sdk
v0.0.23
Published
Official Swervpay Node.JS SDK
Downloads
163
Maintainers
Readme
Documentation
Installation
Install swervpay-node sdk into your new or existing NodeJS application using any of your favorite package manager.
$ npm install @swervpaydev/sdk
$ yarn add @swervpaydev/sdk
$ pnpm add @swervpaydev/sdk
$ bun install @swervpaydev/sdk
Usage
const swervpay = require("@swervpaydev/sdk");
const config = {
secretKey: "<SECRET_KEY>",
businessId: "<BUSINESS_ID>",
sandbox: false,
};
const swervpay = new swervpay.SwervpayClient(config);
// Set token manually
swervpay.client.setAccessToken(token)
// Get access token
const token = swervpay.client.getAccessToken
// Create a new customer
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,
});
// Create a new card
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
});
// Create a new payout
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,
});
Here, we initialize the Swervpay client with our secret key and business id. Then we create a new customer, card and payout.
See more examples