API Documentation for Buying Data Bundles
Overview
This endpoint allows fintech developers and businesses to purchase data bundles for Nigerian networks via MyBundlePay's API.Important: The
amount
must be passed as a string and correspond exactly to the price of the selected data bundle from the available bundles fetched via the /api/data-bundles
endpoint.
POST https://mybundlepay.com/ng/api/buy-databundle
HEADERS
Authorization* string
Pass your {secret_key}
as a Bearer token in the request header to authorize this call.
Content-Type* string
Must be set to application/json
BODY PARAMS
biller* string
The biller identifier for the data provider, e.g. mtn-data-ng
. Use billers from the /api/data-bundles
endpoint.
phone* string
The phone number to which the data bundle will be credited. Format as a local Nigerian number (e.g., 081xxxxxxxx
).
bundle* string
The bundle code from available bundles, e.g. 100_30
for a 100MB bundle valid 30 days.
amount* string
The price of the selected bundle as a string. This must exactly match the price
value from the bundle list (e.g., "10000"
).
REQUEST EXAMPLE
{
"biller": "mtn-data-ng",
"phone": "081xxxxxxxx",
"bundle": "100_30",
"amount": "10000",
"type": 2
}
RESPONSE
Success response example:
{
"status": "success",
"message": "Data purchase successful"
}
Error response examples:
{
"message": "Invalid token",
"status": "failed"
}
{
"message": "User not found",
"status": "failed"
}
{
"message": "Business not found",
"status": "failed"
}
{
"message": "KYC not approved",
"status": "failed"
}
{
"status": "failed",
"message": "Account balance is insufficient"
}
{
"status": "failed",
"message": "Failed to process request"
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://mybundlepay.com/ng/api/buy-databundle',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"biller": "mtn-data-ng",
"phone": "081xxxxxxxx",
"bundle": "100_30",
"amount": "10000",
"type": 2
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer {secret_key}'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
const axios = require('axios');
axios.post('https://mybundlepay.com/ng/api/buy-databundle', {
biller: 'mtn-data-ng',
phone: '081xxxxxxxx',
bundle: '100_30',
amount: '10000',
type: 2
}, {
headers: {
'Authorization': 'Bearer {secret_key}',
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response ? error.response.data : error.message);
});