Payout On Bank
API Endpoint:
This API for Payout on Bank will be a POST request.
{BaseUrl}/payouts/sendPayoutRequest
Description
The Payout on Bank API allows a user to initiate a payout to a customer's bank account. This is typically used to send payments directly to a customer's bank account.
Request:
Request Header
The request must include the following headers for authentication:
Request Header
{
"apiKey": "your api key",
"token": "your token"
}
- apiKey: Your unique API key provided by PayHub.
- token: A token that validates your session or request.
Request Body (Before Encryption)
The body of the request should include the following parameters before encryption:
Request Body
{
"amount": 100,
"customer_name": "customer's name",
"customer_email": "customer's email",
"customer_phone": "customer's phone",
"account_number": "customer's account number",
"bank_ifsc": "customer's bank IFSC code",
"account_name": "customer's Account Holder name",
"bank_name": "customer's bank name",
"orderId": "merchant order id",
"method":"bank",
"payment_mode":"mode of transfer", (Allowed modes: "NEFT", "IMPS", "RTGS")
}
Encryption Process
To enhance security, the request payload must be encrypted using AES-256-CBC before sending the request.
Step 1: Get Your Encryption Key
You need to get your encryption key from the PayHub Dashboard.
Step 2: Encrypt the Request Data
Use the following JavaScript (Node.js) code to encrypt your request data:
const CryptoJS = require('crypto-js');
const ENCRYPTION_KEY = 'your-encryption-key'; // Get from the dashboard
const IV_LENGTH = 16; // AES block size for CBC mode
// Function to derive a 32-byte key
function deriveKey(secret) {
return CryptoJS.SHA256(secret).toString(CryptoJS.enc.Hex).substring(0, 32);
}
// Generate a random IV
function generateIV() {
return CryptoJS.lib.WordArray.random(16).toString(CryptoJS.enc.Hex);
}
// Encrypt function
function encrypt(data, key) {
const iv = generateIV();
const cipherKey = CryptoJS.enc.Utf8.parse(deriveKey(key));
const ivHex = CryptoJS.enc.Hex.parse(iv);
const encrypted = CryptoJS.AES.encrypt(JSON.stringify(data), cipherKey, {
iv: ivHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return iv + ':' + encrypted.ciphertext.toString(CryptoJS.enc.Hex);
}
// Original request payload
const requestData = {
"amount": 100,
"customer_name": "customer's name",
"customer_email": "customer's email",
"customer_phone": "customer's phone",
"account_number": "customer's account number",
"bank_ifsc": "customer's bank IFSC code",
"account_name": "customer's Account Holder name",
"bank_name": "customer's bank name",
"orderId": "merchant order id"
"method": "bank",
"payment_mode":"mode of transfer", (Allowed modes: "NEFT", "IMPS", "RTGS")
};
// Encrypt the data
const encryptedData = encrypt(requestData, ENCRYPTION_KEY);
console.log("Encrypted Data:", encryptedData);
Step 3: Send Encrypted Data in Request
After encryption, send the request body as follows:
Encrypted Request Body
{
"encryptedData": "your-encrypted-string"
}
Possible Responses:
Success Response
Success Response
{
"responseCode": 200,
"responseMessage": "Success",
"responseData": {
"message": "Payment request submitted",
"transaction_id": 9811167405953,
"orderId":45676543
}
}
Invalid API Key Response
Invalid API Key
{
"responseCode": 403,
"responseMessage": "Invalid apiKey"
}
Error Response
Error Response
{
"responseCode": 400,
"responseMessage": "Failed to process transaction",
"responseData": "You don't have enough balance to process this transaction"
}
Notes
- You must use AES-256-CBC encryption before sending the request.
- Always retrieve your encryption key from the PayHub Dashboard.
- Ensure the encryptedData field is sent correctly in the request body.