Creates a virtual bank account for a user using a supported provider.
{{base_url}}
/virtual-account/create
Parameter | Type | Details |
---|---|---|
firstName | string | User's First Name |
lastName | string | User's Last Name |
string | Valid Email Address | |
bank | string | One of: PALMPAY, 9PSB, SAFEHAVEN, PROVIDUS, BANKLY |
Request Example (cURL - Monielinks)
<?php
// Monielinks credentials
$clientId = 'YOUR_CLIENT_ID';
$secretKey = 'YOUR_SECRET_KEY';
// Step 1: Get access token
$authUrl = 'https://monielinks.com/pay/api/v1/authentication/token';
$authPayload = [
'client_id' => $clientId,
'secret_id' => $secretKey
];
$ch = curl_init($authUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($authPayload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json'
]);
$authResponse = curl_exec($ch);
curl_close($ch);
$authData = json_decode($authResponse, true);
if (!isset($authData['data']['access_token'])) {
die("❌ Failed to retrieve access token: " . $authResponse);
}
$accessToken = $authData['data']['access_token'];
echo "✅ Access Token: $accessToken\n";
// Step 2: Create virtual account
$createUrl = 'https://monielinks.com/pay/api/v1/virtual-account/create';
$virtualPayload = [
"email" => "ccccc@example.com",
"firstName" => "Johnwick",
"lastName" => "pans",
"bank" => "PALMPAY" // Options: PALMPAY, 9PSB, SAFEHAVEN, PROVIDUS, BANKLY
];
$ch = curl_init($createUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($virtualPayload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $accessToken",
'Content-Type: application/json',
'Accept: application/json'
]);
$createResponse = curl_exec($ch);
curl_close($ch);
echo "🎯 Virtual Account Response:\n";
print_r(json_decode($createResponse, true));
**Response: SUCCESS (200 OK)**
{
"message": [
"Virtual account created successfully"
],
"data": {
"account": {
"account_number": "6632388120",
"account_name": "John(ALFAHSUB)",
"bank": "PalmPay Bank",
"email": "customer@example.com",
"reference": "customer@example.com"
}
},
"type": "success"
}
**Response: ERROR (403 FAILED)**
{
"message": {
"code": 403,
"error": [
"Access denied! Token not found"
]
},
"data": [],
"type": "error"
}