TransfersInitiate Transfer

Initiate Bank Transfer

The Initiate Bank Transfer endpoint allows you to start a bank transfer by providing the necessary details, such as the recipient’s bank account information and the amount to be transferred.

Step 1: Set Up Request Headers

Include the following headers in your request:

HeaderTypeDescription
AuthorizationstringBearer token with your encryption key
SignaturestringHMAC 512 signature using your encryption key as the hashing key

Step 2: Generate Signature

To generate the HMAC 512 signature, use your encryption key as the hashing key and the request payload as the message.

Sample Node.js Code

const crypto = require('crypto');
 
const secretKey = 'YOUR_SECRET_KEY';
const payload = JSON.stringify({
    account_number: "0123456789",
    account_name: "John",
    bank_code: "000013",
    amount: "100",
    currency: "NGN",
    sender_name: "John",
    narration: "John",
    reference: "x01234yz"
});
 
const signature = crypto.createHmac('sha512', secretKey).update(payload).digest('hex');
console.log(signature);

Step 3: Prepare Request Body

Include the following parameters in your request body:

ParameterTypeDescription
account_numberstringThe bank account number of the recipient
account_namestringThe name of the recipient
bank_codestringThe bank code of the recipient’s bank
amountstringThe amount to be transferred
currencystringThe currency code (e.g. NGN, ZAR)
sender_namestringThe name of the sender
narrationstringA description or note for the transfer
referencestringYour unique identifier for the transfer (recommended to start with your business shortname)
typestringRequired for ZAR only. Transfer type: EFT or RTC. Defaults to RTC if not provided

Step 4: Sample Request

Here is an example of how your request body should look:

{
    "account_number": "0123456789",
    "account_name": "John",
    "bank_code": "000013",
    "amount": "100",
    "currency": "NGN",
    "sender_name": "John",
    "narration": "John",
    "reference": "x01234yz"
}

For ZAR transfers, include the type parameter:

{
    "account_number": "1234567890",
    "account_name": "Jane Doe",
    "bank_code": "632005",
    "amount": "500",
    "currency": "ZAR",
    "sender_name": "John Smith",
    "narration": "Transfer to Jane",
    "reference": "zar_transfer_001",
    "type": "EFT" // 'EFT' or 'RTC'
}

Step 5: Sample cURL Request

Use the following cURL command to initiate the transfer:

curl -X POST https://mainapi.cashonrails.com/api/v1/bank_transfer \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Signature: YOUR_HMAC_SIGNATURE" \
-d '{
  "account_number": "0123456789",
  "account_name": "John",
  "bank_code": "000013",
  "amount": "100",
  "currency": "NGN",
  "sender_name": "John",
  "narration": "John",
  "reference": "x01234yz"
}'

For ZAR transfers:

curl -X POST https://mainapi.cashonrails.com/api/v1/bank_transfer \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Signature: YOUR_HMAC_SIGNATURE" \
-d '{
  "account_number": "1234567890",
  "account_name": "Jane Doe",
  "bank_code": "632005",
  "amount": "500",
  "currency": "ZAR",
  "sender_name": "John Smith",
  "narration": "Transfer to Jane",
  "reference": "zar_transfer_001",
  "type": "EFT"
}'

Step 6: Sample Response

Here is an example of a successful response:

{
    "success": true,
    "status": "00",
    "message": "Transfer Initiated Successfully",
    "data": {
        "transfer_id": "12345",
        "reference": "x01234yz",
        "status": "pending"
    }
}

Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful
statusstringStatus code of the request
messagestringMessage describing the result
dataobjectContains the transfer details
transfer_idstringUnique identifier for the transfer
referencestringYour unique identifier for the transfer
statusstringThe status of the transfer

Use this endpoint to initiate a bank transfer, ensuring that all necessary details are provided for a successful transaction.