Skip to Content
PaymentsVirtual AccountsGenerate Dynamic Account

Generate Dynamic Account

Generate a temporary virtual account for a customer payment. The generated account details can be shared with the customer, and the payment should be verified using the returned reference or verification link.

Endpoint

POST https://api.cashonrails.com/api/v1/banktransfer/initialize

Headers

HeaderTypeDescription
AuthorizationstringBearer token with your secret key
Content-Typestringapplication/json

Request Parameters

ParameterTypeRequiredDescription
emailstringYesCustomer’s email address
amountstringYesAmount the customer should pay
currencystringYesCurrency code, for example NGN
referencestringYesUnique transaction reference
providerstringYesProvider code from Get Dynamic Account Providers
first_namestringNoCustomer’s first name
last_namestringNoCustomer’s last name

Sample Payload for New Customers

{ "email": "ayomide.owolana@cashonrails.co.za", "first_name": "ayomide", "last_name": "fka", "amount": "100", "currency": "NGN", "reference": "ref_habibi_go_away", "provider": "wema" }

Sample Payload for Existing Customers

{ "email": "test@email.com", "amount": "100", "currency": "NGN", "reference": "ref_12121121", "provider": "wema" }

Sample Request

curl --location 'https://api.cashonrails.com/api/v1/banktransfer/initialize' \ --header 'Authorization: Bearer YOUR_SECRET_KEY' \ --header 'Content-Type: application/json' \ --data-raw '{ "email": "test@email.com", "amount": "100", "currency": "NGN", "reference": "ref_12121121", "provider": "wema" }'

Sample Response

{ "success": true, "message": "Account generated successfully", "data": { "total_amount": "101.6", "account_name": "ayomide fka", "account_number": "8880078297", "bank_name": "Wema Bank", "expires": "2025-04-05T09:01:51.8093947+00:00", "_links": { "url": "https://api.cashonrails.com/api/v1/checkout/verify-transaction/ref_habibi_go_away", "method": "GET" } } }

Error Response

{ "success": false, "message": "Reference Already Exist" }

Best Practices

  • Use a unique reference for every generated account.
  • Verify the transaction before confirming value to the customer.
  • Use provider codes returned by the providers endpoint.
  • Treat generated account details as temporary when an expires value is returned.
Last updated on