API Documentation for Payout V2 Functionality
This documentation provides step-by-step guidance for developers to integrate functionalities for payout V2 using PHP cURL or NodeJs. Each section includes the method, endpoint, request parameters, and sample responses.
GET https://mybundlepay.com/ng/api/initiatePayout
HEADERS
Authorization* string
Pass your {secret_key} as a bearer token in the request header to authorize this call
Accept application/json
REQUEST PARAMETERS*
The request body parameters for initiating a payout include:
1. amount (integer): Represents the withdrawal amount in the smallest currency unit. For example, 100000 = NGN 1000 (amount in kobo).
2. destinationBankCode (string): The bank code from the fetch banks endpoint that identifies the recipient's bank.
3. destinationAccountNumber (string): The recipient's bank account number where the payout will be made.
4. narration (string): A custom narration for the transaction, such as "Payment for services" or any other relevant description.
Notes for Developers
1. API Key Security: Ensure the API key is stored securely, such as in environment variables.
2. Error Handling: Always implement error handling for failed requests or invalid responses.
3. Rate Limits: Check the API provider’s documentation for rate limits and implement retry mechanisms if needed.
4. Currency Unit: The amounts are typically in the smallest currency unit (e.g., kobo for NGN). Ensure proper conversions.
5. Test vs. Live: Use test API keys for development and testing, and ensure live keys are only used in production.
< ?php
// Data to be sent as query parameters
$data = [
"amount" => 100000, // Amount in kobo (e.g., 100000 = NGN 1000)
"destinationBankCode" => "033", // Bank code (replace with actual bank code)
"destinationAccountNumber" => "2093XXXX", // Account number (replace with actual account number)
"narration" => "Payment for services" // Custom narration for the transaction
];
// Build the query string from the data array
$queryString = http_build_query($data);
// Set up the cURL session for GET
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://mybundlepay.com/ng/api/initiatePayout?" . $queryString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer {secret_key}', // Replace {secret_key} with your actual secret key
'Content-Type: application/json',
]);
// Execute the request
$response = curl_exec($ch);
// Check if the cURL request was successful
if ($response === false) {
// Handle error
echo "cURL Error: " . curl_error($ch);
} else {
// Parse and handle the response
$responseData = json_decode($response, true);
// Check the response status
if (isset($responseData['status']) && $responseData['status'] === 'success') {
// Successful response
echo "Payout initiated successfully!\n";
echo "Reference: " . $responseData['data']['reference'] . "\n";
echo "Amount: " . $responseData['data']['amount'] . " NGN\n";
echo "Fee: " . $responseData['data']['totalFee'] . " NGN\n";
echo "Destination Account: " . $responseData['data']['destinationAccountName'] . "\n";
echo "Destination Bank: " . $responseData['data']['destinationBankName'] . "\n";
echo "Transaction Status: " . $responseData['data']['status'] . "\n";
echo "Comment: " . $responseData['data']['comment'] . "\n";
echo "Date Created: " . $responseData['data']['dateCreated'] . "\n";
} else {
// Failed response
echo "Payout failed! Message: " . $responseData['message'] . "\n";
}
}
// Close the cURL session
curl_close($ch);
?>
const axios = require('axios');
// Data to be sent as query parameters
const data = {
amount: 100000, // Amount in kobo (e.g., 100000 = NGN 1000)
destinationBankCode: "033", // Bank code (replace with actual bank code from the fetch banks endpoint)
destinationAccountNumber: "2093XXXX", // Account number (replace with actual recipient's account number)
narration: "Payment for services" // Custom narration for the transaction
};
// Set up the request headers
const headers = {
'Authorization': 'Bearer {secret_key}', // Replace {secret_key} with your actual secret key
'Content-Type': 'application/json'
};
// Set up the request URL with query parameters
const url = `https://mybundlepay.com/ng/api/initiatePayout?${new URLSearchParams(data).toString()}`;
// Function to initiate the payout
async function initiatePayout() {
try {
const response = await axios.get(url, { headers });
// Handle successful response
if (response.data.status === 'success') {
console.log("Payout initiated successfully!");
console.log(`Reference: ${response.data.data.reference}`);
console.log(`Amount: ${response.data.data.amount} NGN`);
console.log(`Fee: ${response.data.data.totalFee} NGN`);
console.log(`Destination Account: ${response.data.data.destinationAccountName}`);
console.log(`Destination Bank: ${response.data.data.destinationBankName}`);
console.log(`Transaction Status: ${response.data.data.status}`);
console.log(`Comment: ${response.data.data.comment}`);
console.log(`Date Created: ${response.data.data.dateCreated}`);
} else {
// Handle failed response
console.log("Payout failed! Message: " + response.data.message);
}
} catch (error) {
// Handle error
console.error("Error during payout initiation: ", error);
}
}
// Call the function to initiate payout
initiatePayout();
Successful Request Response
{
Payout initiated successfully!
Reference: txn_67815ae1ecbad
Amount: 90 NGN
Fee: 10 NGN
Destination Account: MYBUNDLEPAY
Destination Bank: United Bank For Africa Plc
Transaction Status: SUCCESS
Comment: Transaction successful
Date Created: 2025-01-10T17:37:38.852+00:00
}
Error Response
{
"status": "failed",
"message": "Insufficient balance."
}