-
Notifications
You must be signed in to change notification settings - Fork 19
Bill
With the Flutterwave API, you can pay for several kinds of bills (including airtime, data, electricity and cable TV) from your Flutterwave wallet.
This helps developers to retrieve the information for each Biller. These information are important as they are required for the bill payment attempt. You can filter your query by biller type and biller_code.
use Flutterwave\Service\Bill;
$service = new Bill($config);
$request = $service->getCategories();
This allows you how to validate services like DSTV Smart Card Number, Meter number etc using the item_code. This code is returned from the getCategories as data[i].item_code, where i is the index in the data array contained in the response object.
use Flutterwave\Service\Bill;
$item_code = "AT099";
$service = new Bill($config);
$request = $service->validateService($item_code);
This allows you to initiate the bill payment. You can create Airtime, Data, Cable, Power, Toll and other bill payment you need. Kindly note that your balance should be funded as your wallet would be debited.
use Flutterwave\Payload;
use Flutterwave\Service\Bill;
$payload = new Payload();
$payload->set("country", "NG");
$payload->set("customer", "+2349067985861");
$payload->set("amount", "2000");
$payload->set("type", "AIRTIME");
$payload->set("reference", "TEST_".uniqid().uniqid());
$service = new Bill($config);
$request = $service->createPayment($payload);
This shows you how to create bulk bills payment.
use Flutterwave\Service\Bill;
$payload = json_decode('{
bulk_reference: "edf-12de5223d2f32",
callback_url: "https://webhook.site/5f9a659a-11a2-4925-89cf-8a59ea6a019a",
bulk_data: [
{
country: "NG",
customer: "+23490803840303",
amount: 500,
recurrence: "WEEKLY",
type: "AIRTIME",
reference: "930049200929",
},
{
country: "NG",
customer: "+23490803840304",
amount: 500,
recurrence: "WEEKLY",
type: "AIRTIME",
reference: "930004912332",
},
],
}', TRUE);
$service = new Bill($config);
$request = $service->createBulkPayment($payload);
print_r($request);
This shows you how to get the status of a bill purchase.
use Flutterwave\Service\Bill;
$reference = "9300049404444"; // bill reference.
$service = new Bill($config);
$request = $service->getBillStatus($reference);
print_r($request);
This shows you how to retrieve a history of all purchased bill services including commission earned.
use Flutterwave\Service\Bill;
$service = new Bill($config);
$request = $service->getBillPayments();
print_r($request);