payracle
v1.0.1
Published
Official Node.js SDK for Payracle
Maintainers
Readme
Payracle Node.js SDK
The official Node.js SDK for integrating with the Payracle Payment Gateway.
Installation
npm install payracleInitialization
Initialize the SDK with your secret key (or public key, depending on what endpoints you are calling):
const { Payracle } = require('payracle');
const payracle = new Payracle({
secretKey: 'sk_live_...',
// publicKey: 'pk_live_...', // Optional depending on use case
});Features
Virtual Accounts
Create static virtual accounts for your customers.
const response = await payracle.virtualAccounts.create({
customer_name: 'John Doe',
bvn: '12345678901',
});
console.log(response.data.account_number);Checkout (Dynamic Accounts)
Initialize dynamic virtual accounts for specific transactions.
const response = await payracle.checkout.initialize({
amount: 5000,
email: '[email protected]',
reference: 'order_123',
});
console.log(response.data.checkout_url);Payouts
Transfer money out of your wallet to a recipient.
const response = await payracle.payouts.transfer({
amount: 5000,
bank_code: '058', // GTBank
account_number: '0123456789',
account_name: 'Jane Doe',
});Invoices
Create invoices.
const response = await payracle.invoices.create({
customer_email: '[email protected]',
customer_name: 'John Doe',
items: [
{ name: 'Item 1', quantity: 2, price: 1000 }
]
});Webhook Verification
Verify the HMAC signature of incoming webhooks to ensure they genuinely came from Payracle.
const rawPayload = JSON.stringify(req.body); // Ensure this is the raw string
const signature = req.headers['x-payracle-signature'];
const isValid = payracle.webhooks.verifySignature(rawPayload, signature);
if (!isValid) {
return res.status(401).send('Unauthorized webhook signature');
}TypeScript
This library is written in TypeScript and exports all API request and response interfaces.
import { Payracle, CreateVirtualAccountRequest } from 'payracle';
const request: CreateVirtualAccountRequest = {
customer_name: 'Jane',
bvn: '2222'
};