glass-sdk
v1.0.1
Published
A Node.js SDK for Glass payment services
Maintainers
Readme
Glass SDK for Node.js
A TypeScript-based Node.js SDK for seamless integration with Glass payment services. This SDK provides a simple and intuitive interface to handle payments, transaction queries, and webhook verification.
📦 Installation
npm install glass-sdk
# or
yarn add glass-sdk
# or
pnpm add glass-sdk🚀 Quick Start Basic Usage
import Glass from 'glass-sdk';
async function main() {
// Initialize the client
const client = new Glass({
merchantCode: 'your-merchant-code',
clientSecret: 'your-client-secret',
integrationKey: 'your-integration-key'
});
await client.init();
// Prepare payment data
const initPayment = {
amount: 100,
currency: 'NGN',
merchantRef: `${Math.floor(Math.random() * 100000 + 2967897)}`,
narration: "Test on SDK",
callBackUrl: "",
splitCode: '',
shouldTokenizeCard: true,
merchantDescriptor: '',
mcc: 0,
notificationUrl: '',
returnUrl: '',
channels: ["Card", "BankTransfer", "USSD"],
paymentType: '',
customer: {
customerId: "csg",
customerLastName: "Chams",
customerFirstName: "Switch",
customerEmail: "[email protected]",
customerPhoneNumber: "08043434343",
customerAddress: "",
customerCity: "",
customerStateCode: "",
customerPostalCode: "",
customerCountryCode: "NG"
}
}
//Create a paymentAdvice
const checkout = await client.initiateCheckout(initPayment)
console.log(`checkout ==>`, checkout)
// Checkout response
{
requestSuccessful: true,
responseData: {
currency: 'NGN',
adviceReference: 'f8e6a790-edef-42ee-9547-d99986a52f6f',
merchantRef: '3012513',
amount: 100,
narration: 'Test on SDK',
customerId: '1094459',
charge: 1.2,
status: 'Pending',
customerFullName: 'Switch Chams',
merchantName: 'Naira.com',
merchantCode: 'Nai0000319',
merchantId: '391503484029826',
paymentUrl: 'https://payment.pelpay.ng/checkout?adviceReference=f8e6a790-edef-42ee-9547-d99986a52f6f',
channels: [ 'Card', 'BankTransfer', 'USSD' ],
channel: [ 'Card', 'BankTransfer', 'USSD' ],
customerCharge: 1.2,
merchantCharge: 1.5,
vatCharge: 0
}
}
// Check paymentAdvice Properties
const adviceProps = await client.getTransactionByAdviceReference(checkout.responseData.adviceReference)
console.log(`advice reference ==>`, adviceProps)
//adviceProps response
{
requestSuccessful: true,
responseData: {
currency: 'NGN',
adviceReference: 'f8e6a790-edef-42ee-9547-d99986a52f6f',
merchantRef: '3012513',
amount: 100,
narration: 'Test on SDK',
customerId: '1094459',
charge: 0,
status: 'Pending',
customerFullName: 'Switch Chams',
merchantName: 'Naira.com',
merchantCode: 'Nai0000319',
merchantId: '391503484029826',
paymentUrl: 'https://payment.pelpay.ng/pay?adviceReference=f8e6a790-edef-42ee-9547-d99986a52f6f',
channels: [ 'Card', 'BankTransfer', 'USSD' ],
channel: [ 'Card', 'BankTransfer', 'USSD' ],
merchantCustomizations: {
merchantCode: 'Nai0000319',
brandColor: '#ffffff',
cloudLogoUrl: 'https://res.cloudinary.com/dsdkmnf0b/image/upload/v1764698524/GLASS/merchant_Jay0000463_logo/yq1ehmpesqgf44bybodb.jpg',
localLogoUrl: '/usr/applications/glassmerchantservice/dist/Files/Uploads/1-12-2025-13-29-15-merchantLogo',
tokenizationStatus: true,
id: 0,
isActive: true,
createdDate: '2026-02-05T21:33:17.8734715+01:00'
},
customerCharge: 0,
merchantCharge: 1.5,
vatCharge: 0
}
}
// Check Transaction Details
const transactionDetails = await client.getTransactionDetails('2f00d525e063472486c74c4caa71f2ec')
console.log(`transactionDetails ==>`, transactionDetails)
// transactionDetails response
{
requestSuccessful: true,
responseData: {
merchantCode: 'Nai0000319',
paymentReference: '2f00d525e063472486c74c4caa71f2ec',
merchantReference: 'Friday-03-16:06-1',
amount: 100,
amountCollected: 0,
transactionStatus: 'Failed',
currencyCode: 'NGN',
narration: 'Test on SDK',
comment: '',
env: 'Live',
callBackUrl: '?adviceReference=e52cc414-2a6f-4583-b8f9-dbc6c34a1746&paymentReference=2f00d525e063472486c74c4caa71f2ec',
returnUrl: '?advicereference=e52cc414-2a6f-4583-b8f9-dbc6c34a1746&paymentreference=2f00d525e063472486c74c4caa71f2ec'
},
message: 'Successful',
responseCode: '00'
}
}
main();