⚡ Electricity Vending

Purchase prepaid electricity tokens for any meter in Nigeria. Validate meters, purchase tokens, and track transactions.

Pricing

Operation Cost
Validate meter Free
Purchase token 0.5% of amount (minimum ₦5)
List transactions Free
Query token status Free

How It Works

  1. Validate meter → Get customer name and meter details
  2. Confirm with user → Show customer name before purchase
  3. Purchase token → Charge your wallet, get token
  4. Deliver token → Display to customer or send via notification

Step 1: Validate Meter

Always validate first to get customer details and confirm the meter exists.

POST /v1/vending/validate
{
  "meterNumber": "1234567890123"
}
Response
{
  "success": true,
  "data": {
    "meterNumber": "1234567890123",
    "customerName": "John Doe",
    "customerAddress": "123 Main Street, Lagos",
    "meterType": "PREPAID",
    "disco": "IKEDC",
    "minimumAmount": 500,
    "maximumAmount": 500000
  }
}
💡 Best Practice

Show the customer name to the user and ask them to confirm before proceeding with purchase. This prevents buying tokens for the wrong meter.

Step 2: Purchase Token

Purchase electricity for the validated meter. Costs 0.5% of amount (minimum ₦5).

POST /v1/vending/purchase
{
  "meterNumber": "1234567890123",
  "amount": 5000,
  "estateId": "est_abc123",
  "reference": "my-unique-ref-123"  // Optional idempotency key
}
Response
{
  "success": true,
  "data": {
    "id": "txn_xyz789",
    "meterNumber": "1234567890123",
    "amount": 5000,
    "units": "25.5 kWh",
    "token": "1234-5678-9012-3456-7890",
    "customerName": "John Doe",
    "status": "SUCCESS",
    "reference": "VEN-20260323-ABC123",
    "createdAt": "2026-03-23T10:30:00Z"
  }
}

Request Fields

Field Required Description
meterNumber Yes 11-13 digit meter number
amount Yes Amount in Naira (₦500 - ₦500,000)
estateId Yes Estate ID where the meter is located
reference No Idempotency key to prevent duplicates
⚠️ Idempotency

Use the reference field to prevent duplicate purchases. If you retry with the same reference, you'll get the original transaction instead of a new one.

Code Example

Node.js / JavaScript
const API_KEY = 'vk_prod_xxxxxxxxxxxxx';
const BASE_URL = 'https://api.developers.venshack.io/v1';

async function purchaseElectricity(meterNumber, amount, estateId) {
  // Step 1: Validate meter
  const validateRes = await fetch(`${BASE_URL}/vending/validate`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ meterNumber })
  });
  
  const meter = await validateRes.json();
  
  if (!meter.success) {
    throw new Error(meter.error.message);
  }
  
  console.log(`Customer: ${meter.data.customerName}`);
  
  // Step 2: Purchase token
  const purchaseRes = await fetch(`${BASE_URL}/vending/purchase`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      meterNumber,
      amount,
      estateId,
      reference: `order-${Date.now()}`
    })
  });
  
  const result = await purchaseRes.json();
  
  if (result.success) {
    console.log(`Token: ${result.data.token}`);
    console.log(`Units: ${result.data.units}`);
    return result.data;
  } else {
    throw new Error(result.error.message);
  }
}

// Usage
purchaseElectricity('1234567890123', 5000, 'est_abc123');

Transaction History

List all vending transactions for your organization.

GET /v1/vending/transactions
GET /v1/vending/transactions?page=1&limit=20&meterNumber=1234567890123

Webhooks

Receive notifications when vending events happen:

Event Description
vending.completed Token purchased successfully
vending.failed Purchase failed

See Webhooks Guide for setup instructions.

Error Handling

Error Code Description
INVALID_METER Meter number not found or invalid
PAYMENT_REQUIRED Insufficient wallet balance
AMOUNT_TOO_LOW Amount below minimum (₦500)
AMOUNT_TOO_HIGH Amount above maximum (₦500,000)
PROVIDER_ERROR Electricity provider is unavailable