Introduction
This document serves as the technical reference for integrating the NABRoll Payment Gateway. It is designed to assist developers in collecting payments, processing transactions, and handling automated revenue splits.
Authentication
Security is handled via a hashing mechanism. Every request that modifies state or requests sensitive data requires a Hash field.
const crypto = require('crypto');
const CONFIG = {
publicApiKey: "PK_TEST_...",
secretApiKey: "SK_TEST_..."
};
function generateHash(dataString) {
return crypto.createHmac('sha256', CONFIG.secretApiKey)
.update(dataString)
.digest('hex');
}
Hash Generator Playground
Interactive// 1. String to Hash
// 2. Generated HMAC-SHA256
// 3. Payload Preview
...
Initiate Transaction
POSTGenerates a unique Transaction Reference (NTR) and a payment code.
Hashing Logic
Concatenate these values in order, then hash.
Key Parameters
- PayerRefNo Your unique order ID.
- Amount Transaction amount (e.g., "200.00").
- ResponseUrl (Optional) Redirect URL after payment.
- MetaData (Optional) Extra data or split config.
Example Request
async function initiateTransaction(payerData) {
const { payerRefNo, amount } = payerData;
// 1. Generate Hash
const str = `${payerRefNo}${amount}${CONFIG.publicApiKey}`;
const hash = generateHash(str);
// 2. Payload
const payload = {
ApiKey: CONFIG.publicApiKey,
Hash: hash,
Amount: amount,
PayerRefNo: payerRefNo,
PayerName: payerData.name,
// ... other fields
};
// 3. Send
const res = await fetch(`${CONFIG.baseUrl}/transactions/initiate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
return await res.json();
}
Verify Transaction
POSTConfirm the status of a transaction before giving value to the user.
Hashing Logic
async function verifyTransaction(payerRefNo, amount, transactionRef) {
const str = `${payerRefNo}${amount}${transactionRef}${CONFIG.publicApiKey}`;
const hash = generateHash(str);
const payload = {
ApiKey: CONFIG.publicApiKey,
Hash: hash,
"Transaction Ref": transactionRef // Note the space in the key
};
const res = await fetch(`${CONFIG.baseUrl}/transactions/verify`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
return await res.json();
}
Re-Generate Reference
POSTUse this endpoint if you need to re-issue a reference for an existing order/payerRefNo.
The implementation is identical to Initiate Transaction, using the same hash logic (payerRefNo + amount + publicApiKey).
Web Checkout Flow
Upon successful initiation, redirect the user to:
Handling the Return
The user is redirected back to your ResponseUrl with these query parameters:
tokenTransaction RefMsg
Token Validation
You must validate the returned token to ensure the request is genuine.
const str = payerRefNo + paymentCode + amount;
const calculated = md5(str);
if (calculated === token) { /* Valid */ }
Transaction Split
NABRoll allows you to programmatically split settlements between different bank accounts or wallets. This is configured by passing a JSON string in the MetaData field during initiation.
Structure
Split Types
- bank_account: Requires Bank Code & Account No.
- wallet: Requires Wallet ID.
Deduction Types
- Fixed: Exact amount (e.g., "50.00").
- Percentage: Rate without symbol (e.g., "5.0").
Implementation Code
const splitConfig = {
"transaction_split": [
{
"split_type": "bank_account",
"deduction_type": "Fixed",
"rate": "250.40",
"bank_code": "058", // GTBank
"account_no": "0011223344",
"account_name": "Developer One"
}
]
};
// Add to Initiate Payload
payload.MetaData = JSON.stringify(splitConfig);
Split JSON Generator
{}
Webhooks & Callbacks
NABRoll pushes payment notifications to your server in real-time.
Retry Policy
The system will retry the notification 4 times within an hour if your server does not respond with HTTP 200.
Response Dictionary
Standard fields returned in API responses.
| Field | Type | Description |
|---|---|---|
| status | String | Transaction status (e.g., "SUCCESSFUL") |
| code | String | Response code ("00" for success) |
| TransactionRef | String | Unique NABRoll reference ID |
| PaymentCode | String | Unique code for web checkout identification |
| amount | String | The amount processed (formatted as decimal) |
| paymentDate | String | Timestamp (YYYY-MM-DD HH:mm:ss) |
Troubleshooting
Common response codes and errors you might encounter.
| Status Code | Description | Solution |
|---|---|---|
| 00 | Transaction Successful | Proceed to update your database. |
| 401 | Unauthorized / Invalid Hash | Check your API Key and ensure Hash generation is correct. |
| 400 | Bad Request | Check if all mandatory fields (PayerRefNo, Amount, Mobile) are present. |
Appendix: CBN Bank Codes
| Code | Bank Name | Code | Bank Name |
|---|---|---|---|
| 044 | Access Bank | 082 | Keystone Bank |
| 023 | Citi Bank | 014 | Mainstreet Bank |
| 050 | Ecobank | 100004 | OPAY |
| 070 | Fidelity Bank | 076 | Polaris Bank |
| 011 | First Bank | 221 | Stanbic IBTC |
| 214 | FCMB | 232 | Sterling Bank |
| 058 | GTBank | 033 | UBA |
| 030 | Heritage Bank | 057 | Zenith Bank |