npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

glide-nodejs-sdk

v0.3.0

Published

Glide NodeJS SDK

Downloads

25

Readme

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);