0.3.0 • Published 3 years ago

glide-nodejs-sdk v0.3.0

Weekly downloads
51
License
MIT
Repository
-
Last release
3 years ago

Glide NodeJS SDK

Nodejs SDK for Glide.

Installation

npm install glide-nodejs-sdk
or
yarn add glide-nodejs-sdk

Usage

// import the library
import Glide from "glide";

const glide = new Glide("your-secret-key", "your-public-key");

Introduction

Our goal is to give access to financial opportunity anywhere in emerging markets. Great products don’t make you think.

Examples

Glide SDK made use of the standard Javascript Promise. it support both then-catch syntax and async-await.

Using Then-Catch

glide.customer
	.getAll({ page: 1 })
	.then((response) => {
		console.log("Customer list: ", response.customers);
		console.log("Metadata: ", response.metadata);
	})
	.catch((error) => {
		console.log("An error occurred: ", error);
	});

Or you can use the Async-Await syntax

try {
	const response = await glide.customer.getAll({ page: 1 });

	console.log("Customer list: ", response.customers);
	console.log("Metadata: ", response.metadata);
} catch (error) {
	console.log("An error occurred: ", error);
}

Note: All examples in this documentation will make use of the async-await syntax.

BVN APIs

Resolve BVN details

Basic
const response = await glide.bvn.basic("12345678901");

console.log("Basic details: ", response);
With image and more details
const response = await glide.bvn.withImage("12345678901");

console.log("More details with image: ", response);

Customer APIs

To get list of all customers

const response = await glide.customer.getAll({ page: 1 });

console.log("Customer list: ", response.customers);
console.log("Metadata: ", response.metadata);

Update customer information

const updatedRecord = await glide.customer.update("customer-id", {
	firstName: "Updated",
	lastName: "Good",
});

console.log("Updated record", updatedRecord);

List all customer transactions

const response = await glide.customer.transactions({ customerId: "customer-id", page: 1, type: "CREDIT" });

console.log("Transaction list", response.transactions);
console.log("Metadata information about pagination", response.metadata);

Wallet APIs

To create a new customer wallet

/*
 * @params firstName First name
 * @params lastName Last name
 * @params phoneNumber Phone number.
 * @params dateOfBirth Date of birth
 * @params customerId The customer ID
 *
 * @params bvn Optional BVN.
 * @params metadata Optional metadata information.
 */

const response = await glide.wallet.createCustomerWallet({
	firstName: "Rilwan",
	lastName: "Customer",
	phoneNumber: "08030223345",
	dateOfBirth: "1991-09-13",
	bvn: "01234567890",
	customerId: "49d4ea6d-d3dc-490c-800d-7c50b89cf8ff", //optional: customer to be charged for the transaction
	metadata: {
		// optional
		"some-data": "some value",
		"more-data": "more value",
	},
});

console.log("Wallet: ", response.wallet);
console.log("Customer: ", response.customer);

To get the list of all customer wallets

const wallets = await glide.wallet.allCustomerWallets();
console.log("Customer wallets: ", wallets);

To get a customer wallet details

/*
 * @params customerId customer ID
 */
const response = await glide.wallet.getCustomerWallet("49d4ea6d-d3dc-490c-800d-7c50b89cf8ff");
console.log("Customer wallet details: ", response);

To credit customer wallet

/*
 * @params amount The amount to be transfered.
 * @params reference Optional reference number.
 * @params customerId Customer ID of the customer to be credited.
 * @params metadata Optional transaction metadata.
 */

const response = await glide.wallet.creditCustomerWallet({
	amount: 1000,
	reference: "13k34jk4j54234",
	customerId: "982c9510-24ef-4c85-aea4-fa2408e5ab0d",
	metadata: {
		"some-data": "sample data",
		"more-data": "any value here",
	},
});
console.log("Transaction details: ", response);

To debit customer wallet

/*
 * @params amount The amount to be transfered.
 * @params reference Optional reference number.
 * @params customerId Customer ID of the customer to be debited.
 * @params metadata Optional transaction metadata.

 */
const response = await glide.wallet.debitCustomerWallet({
	amount: 1000,
	reference: "13k34jk4j54234",
	customerId: "982c9510-24ef-4c85-aea4-fa2408e5ab0d",
	metadata: {
		"some-data": "sample data",
		"more-data": "any value here",
	},
});
console.log("Transaction details: ", response);

To set customer wallet transaction pin

const response = await glide.wallet.setWalletTransactionPin({
	pin: "1234",
	customerId: "982c9510-24ef-4c85-aea4-fa2408e5ab0d",
});
console.log(response.message);

Get wallet settle balance.

const balance = await glide.wallet.getSettlementBalance();
console.log("Total amount to balance customer wallets: ", balance);

Settle customer balances.

const completed = await glide.wallet.settleCustomerBalances();

console.log(completed ? "Settlement completed successfully" : "Unable to settle customer balances");

Freeze customer wallet.

/*
 * @params customerId
 */

const completed = await glide.wallet.closeCustomerWallet("982c9510-24ef-4c85-aea4-fa2408e5ab0d");

console.log(completed ? "Customer wallet successfully frozen" : "Unable to freeze customer wallet");

UnFreeze customer wallet.

/*
 * @params customerId
 */

const completed = await glide.wallet.enableCustomerWallet("982c9510-24ef-4c85-aea4-fa2408e5ab0d");

console.log(completed ? "Customer wallet successfully enabled" : "Unable to unfreeze customer wallet");

Perform wallet to wallet transfer.

/*
 * @params amount The amount to be transfered.
 * @params toCustomerId Customer ID of the customer to be credited.
 * @params fromCustomerId Customer ID of the customer to be debited.
 */

const completed = await glide.wallet.walletToWalletTransfer({
	amount: 270,
	toCustomerId: "982c9510-24ef-4c85-aea4-fa2408e5ab0d",
	fromCustomerId: "49d4ea6d-d3dc-490c-800d-7c50b89cf8ff",
});

console.log(completed ? "Transaction completed successfully." : "An error occurred while completing the transaction");

Make a batch transaction debitting multiple customer wallet simultaneously.

/*
 * @params batchReference A unique reference number for the batch.
 * @params amount The amount to be transfered.
 * @params reference A unique reference number for the individual transaction.
 * @params customerId Customer ID of the customer to be credited.
 */

const response = await glide.wallet.batchDebitCustomerWallets({
	batchReference: "88adsf8hssa43sefas8df8ahhjefasdff8",
	transactions: [
		{
			amount: 500,
			reference: "dkfajdfsdjjjssd23sfjasdfasdkfjds9",
			customerId: "f75774b0-6f99-4029-92a9-2dfe7e15d3f0",
		},
		{
			amount: 300,
			reference: "dkfajdfsdjjjdsfjasd45fssasdkfjds10",
			customerId: "de304d11-ca4e-491f-8851-9ca09a0084a3",
		},
	],
});

const { data, message } = response;

console.log(message);

console.log("Failed transactions: ", data.rejected);
console.log("Failed transactions: ", data.rejected);
console.log("Batch transaction reference: ", data.batchReference);

Make a batch transaction crediting multiple customer wallet simultaneously.

/*
 * @params batchReference A unique reference number for the batch.
 * @params amount The amount to be transfered.
 * @params reference A unique reference number for the individual transaction.
 * @params customerId Customer ID of the customer to be credited.
 */

const response = await glide.wallet.batchCreditCustomerWallets({
	batchReference: "8ede8w340dk3erowr3ef5",
	transactions: [
		{
			amount: 1000,
			reference: "okdrfadd3freaksd4f",
			customerId: "6c415ca9-0cc9-41cf-ac46-a79e3b6df8dc",
		},
		{
			amount: 50000,
			reference: "okdf3arded4faeksdfd",
			customerId: "33b18d9a-194f-4f36-a259-004e68fcd3fc",
		},
	],
});

const { data, message } = response;

console.log(message);

console.log("Failed transactions: ", data.rejected);
console.log("Failed transactions: ", data.rejected);
console.log("Batch transaction reference: ", data.batchReference);

Enable customer to perform batch transaction by crediting multiple customer wallet simultaneously.

/*
 * @params recipients The customers and amount to be credited.
 * @params customerId Customer ID of the customer initializing the transaction.
 */

const response = await glide.wallet.customerBatchCreditCustomerWallets({
	batchReference: "88adsf8hssasefas8df8ahhjefasdff8",
	customerId: "6c415ca9-0cc9-41cf-ac46-a79e3b6df8dc",
	recipients: [
		{
			amount: 200,
			reference: "dkfajdfsdjjjssdsfjasdfasdkfjds9",
			customerId: "c938a018-8987-4411-97c5-e456868741e8",
		},
		{
			amount: 300,
			reference: "dkfajdfsdjjjdsfjasdfssasdkfjds10",
			customerId: "33b18d9a-194f-4f36-a259-004e68fcd3fc",
		},
	],
});

const { data, message } = response;

console.log(message);

console.log("Failed transactions: ", data.rejected);
console.log("Failed transactions: ", data.rejected);
console.log("Batch transaction reference: ", data.batchReference);

Reverse batch transaction

/*
 * @params customerId Customer ID of the customer initializing the transaction.
 */

const response = await glide.wallet.reverseBatchTransaction("88adsf8hssa43sefas8df8ahhjefasdff8");

const { data, message } = response;

console.log(message);

console.log("Failed transactions: ", data.rejected);
console.log("Failed transactions: ", data.rejected);
console.log("Batch transaction reference: ", data.batchReference);

Merchant APIs

Get merchant profile information

const profile = await glide.merchant.profile();

console.log("Profile information: ", profile);

Update merchant details

const completed = await glide.merchant.updateProfile({
	canLogin: true,
	sendEmail: true,
	businessType: "FINANCIAL-SERVICES",
	callbackURL: "https://product.com/callback/glide",
	sandboxCallbackURL: "http://testing.com/callback/glide",
});

console.log(completed ? "Profile successfully updated" : "An error occurred while completing profile update");

Get merchant wallet information

const wallet = await glide.merchant.getWallet();

console.log("The wallet informmation: ", wallet);

Get merchant transaction information

const response = await glide.merchant.getTransactions({
	page: 1,
	type: "ALL",
});

console.log("Transaction informmation: ", response.transactions);
console.log("Page metadata/pagination information: ", response.metadata);

Card Service APIs

Create a new card for the customer

const response = await glide.card.create({
	address1: "20 Cresent Road, Ogba, Lagos",
	address2: "20 Adewale Street, Surulere, Lagos",
	customerId: "c938a018-8987-4411-97c5-e456868741e8",
});

console.log("Card successfully created.");

Activate card

const response = await glide.card.activate({
	last6: "000352",
	customerId: "c938a018-8987-4411-97c5-e456868741e8",
});

console.log("Card activated");

Fund card

const response = await glide.card.fund({
	amount: 2000,
	customerId: "c938a018-8987-4411-97c5-e456868741e8",
});

console.log("Card funded");

Get card balance

const balance = await glide.card.getBalance("customer-wallet-id");

console.log("Card balance: ", balance);
0.3.0

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago