> ## Documentation Index
> Fetch the complete documentation index at: https://developer.novacpayment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Purchase Electricity

> Learn how to validate and pay for electricity bills.

## Overview

The Electricity Bills API allows you to validate a customer’s meter number and complete an electricity purchase across supported service providers.

Before initiating a purchase, you must first validate the customer’s meter number using the validate meter number endpoint. Once validated, you can proceed to purchase electricity using the generated details.

<Warning>
  Ensure your integration uses the correct `serviceId` for the electricity provider you intend to process payments for.
</Warning>

## Validate Meter Number

Use this endpoint to verify a customer’s meter details before initiating a purchase.\
You’ll need to pass the service provider ID (`serviceId`) and the customer’s meter number as (`customerAccountId`).

```bash Request theme={null}
curl --request POST \
  --url https://integrations.novacpayment.com/api/v1/BillsPayment/validatemeternumber \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "serviceId": "string",
    "customerAccountId": "string"
  }'
```

```json Response theme={null}
{
    "code": 200,
    "status": "success",
    "message": "Successful",
    "data": {
        "statusCode": "00",
        "statusDescription": "Successful",
        "detail": {
            "name": "Test.",
            "address": "test",
            "meterNumber": "1234567890",
            "accountId": "1234567890",
            "providerRef": "1234567890",
            "minimumAmount": 1000
        },
        "isSuccessful": true,
        "message": "Successful",
        "processingProvider": ""
    }
}
```

If the validation is successful, the API returns the customer’s name, address, and other meter details.
You’ll use these details in the Purchase Electricity request.

## Purchase Electricity

After successfully validating the meter number, send a POST request to this endpoint `api/v1/BillsPayment/initiateelectricitypurchase` to complete the electricity bill payment.

Provide the customer’s meter information, `amount`, and `meterType` which can be "prepaid" or "postpaid". If you don’t include a `reference`.

<Note>
  Novac uses a reference to track transactions, so it's important to include it; if you don't, we will generate one.
</Note>

```bash expandable Request theme={null}
curl --request POST \
  --url https://integrations.novacpayment.com/api/v1/BillsPayment/initiateelectricitypurchase \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
        "serviceId": "string",
        "amount": 1000,
        "reference": "" 
        "customerName": "Test",
        "customerAddress": "Test",
        "customerAccountId": "1234567890",
        "meterType": "prepaid|postpaid"
  }'
```

```json expandable Response theme={null}
{
    "code": 200,
    "status": "success",
    "message": "Your transaction is in progress.",
    "data": {
        "token": "string",
        "units": "10",
        "meterType": "prepaid|postpaid",
        "amount": 2000,
        "customerAccountId": "1234567890",
        "status": "pending",
        "message": "Your transaction is in progress.",
        "reference": "reference",
        "domain": "live",
        "fee": 100.00
    }
}
```

If the purchase is successful, you’ll receive details like the token, units, and transaction status.
You can display the token and units to your customer or send them via SMS or email.
