Overview
This section outlines the recommended flow for integrating Airtime Subscription services on the @jannah_opt('site_name') RESTful API.
Available Endpoints
To integrate the @jannah_opt('site_name') Airtime Subscription Payment RESTful API, the following parameters apply:
- network - The network provider
- phone - The recipient's phone number
- plan_type - The type of airtime plan (e.g., VTU)
- amount - The amount of airtime
Purchase Product
To purchase airtime, use a POST request with the endpoint below:
@jannah_opt('site_url')/api/topup
Code Sample
$payload = array(
'network' => 1,
'phone' => '0801*****11',
'plan_type' => 'VTU',
'amount' => 100,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '@jannah_opt('site_url')/api/topup');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
"Authorization: Bearer {{ $user->api_token }}",
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
Expected Response
{
"status": "success",
"message": "Successfully purchased MTN VTU for 0701*****88, ₦100",
}