When working with Reloadly’s utility payments API, one key action you will perform repeatedly is paying a bill. In this guide, you will learn how to pay an electricity bill via the API. The steps involved in this guide are
- Getting your access token for the utility payment service
- Getting the list of electricity billers available
- Getting the biller ID of your preferred utility biller
- Paying a utility bill
You can get your access token by following the steps in this quickstart.
Getting the list of electricity billers available
Assuming you are located in Kenya and wanted to make a local electricity bill payment, your first step would be to make a request to the API to view a list of all the available electricity billers on Reloadly. The cURL code snippet below shows how this can be achieved
curl -i -X GET \
'https://utilities-sandbox.reloadly.com/billers?id=0&name=string&type=ELECTRICITY_BILL_PAYMENT&serviceType=string&countryISOCode=string&page=0&size=0' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
If successful, you will receive a JSON snippet with details of every biller Reloadly has access to
[
{
"id": 1,
"name": "Ikeja Electricity Postpaid",
"countryCode": "NG",
"countryName": "Nigeria",
"type": "ELECTRICITY_BILL_PAYMENT",
"serviceType": "POSTPAID",
"localAmountSupported": true,
"localTransactionCurrencyCode": "NGN",
"minLocalTransactionAmount": 1000,
"maxLocalTransactionAmount": 300000,
"localTransactionFee": 1184.61536,
"localTransactionFeeCurrencyCode": "NGN",
"localDiscountPercentage": 0,
"internationalAmountSupported": true,
"internationalTransactionCurrencyCode": "NGN",
"minInternationalTransactionAmount": 1000,
"maxInternationalTransactionAmount": 300000,
"internationalTransactionFee": 1184.61536,
"internationalTransactionFeeCurrencyCode": "NGN",
"internationalDiscountPercentage": 0,
"fx": {
"rate": 1,
"currencyCode": "NGN"
}
},
{
"id": 19,
"name": "Kenya Electricity Prepaid",
"countryCode": "KE",
"countryName": "Kenya",
"type": "ELECTRICITY_BILL_PAYMENT",
"serviceType": "PREPAID",
"localAmountSupported": true,
"localTransactionCurrencyCode": "KES",
"minLocalTransactionAmount": 10,
"maxLocalTransactionAmount": 1000000,
"localTransactionFee": 336.55649,
"localTransactionFeeCurrencyCode": "KES",
"localDiscountPercentage": 0,
"internationalAmountSupported": true,
"internationalTransactionCurrencyCode": "NGN",
"minInternationalTransactionAmount": 41.565453,
"maxInternationalTransactionAmount": 3197343.2,
"internationalTransactionFee": 1246.9635,
"internationalTransactionFeeCurrencyCode": "NGN",
"internationalDiscountPercentage": 0,
"fx": {
"rate": 0.269900824,
"currencyCode": "NGN"
}
}
]
Getting the biller ID of your preferred utility biller
In the JSON response that contains all the utility billers available on Reloadly, scan for the Kenyan utility biller you want to use. Once you find it, take note of its id value. Let’s take a moment to understand what this means:
- id: This is the unique identification number of each biller. It uniquely identifies the biller servicing the utility.
From the response, our preferred Kenyan biller is Kenya Electricity Prepaid. The key details for this biller are
{
“id”: 19,
“name”: “Kenya Electricity Prepaid”,
“countryCode”: “KE”,
“type”: “ELECTRICITY_BILL_PAYMENT”,
“serviceType”: “PREPAID”
}
Making your electricity bill payment
Once you have identified the biller details, the next step is to make your bill payment. This can be done by placing a request to Reloadly’s Utility Payments API using the following parameters:
subscriberAccountNumber
: This indicates the account / reference / card number of the subscriber / recipient of the electricity bill payment.
amount
: This indicates the amount to be paid for the bill.
id
: The identification number of the Kenyan biller.
useLocalAmount
: Indicates if the amount being presented is in the local currency of the biller. If this parameter is not provided or is set to false, then the payment will be presented in the user’s wallet currency.
referenceId
: A unique string that you may choose to provide. If you provide one, it will be tied to the transaction. You can query back your transaction with this referenceId as well.
The cURL snippet below shows how an electricity bill is paid using the API
curl -i -X POST \
https://utilities-sandbox.reloadly.com/pay \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"subscriberAccountNumber": "4223568280",
"amount": 1000,
"billerId": "19",
"useLocalAmount": false,
"referenceId": "may-electricity-bill"
}'
If successful, a JSON response containing details of your utility bill payment will be returned
{
"id": 108,
"status": "PROCESSING",
"referenceId": "may-electricity-bill",
"code": "PAYMENT_PROCESSING_IN_PROGRESS",
"message": "The payment is being processed, status will be updated when biller processes the payment.",
"submittedAt": "2022-07-05 12:28:07",
"finalStatusAvailabilityAt": "2022-07-06 12:28:07"
}
The id
property in the response refers to the identification number of the utility payment transaction.