URL: /api/electricapi
Methods: POST
, GET
This API endpoint allows users to purchase electric credits.
To access this endpoint, users must include their API key and secret key in the request headers.
See usage example in the code snippets below:
POST request to purchase electricity:
Content-Type: application/json api-key: your-api-key secret-key: your-secret-key { "number": "0000000000", "firstLevel": "IKEDC", "secondLevel": "prepaid", "amount": 1000 }
Response:
- Status Code: 200 { "message": "Transaction successful", "electricHistory": { "transactionId": "1234567890", "email": "user@example.com", "activity": "IKEDC", "message": "prepaid", "status": "Success", "recipient": "0000000000", "token": "12234323464565434", "unit": "11110", "amount": 1000, "amountUsed": 990, "initialBalance": 5000, "finalBalance": 4010 "Method": API, } } - The `amountUsed` field represents the actual amount deducted from the user's balance based on user level.
{ "error": "Transaction failed", "electricHistory": { "transactionId": "1234567890", "email": "user@example.com", "activity": "IKEDC", "message": "prepaid", "status": "Failed", "recipient": "0000000000", "amount": 1000, "initialBalance": 5000, "finalBalance": 5000 "Method": API, } }
See usage example in the code snippets below:
GET request for available firstLevel and secondLevel:
Content-Type: application/json api-key: your-api-key secret-key: your-secret-key
Response:
- Status Code: 200 { "IKEDC": { "available": true, "secondLevel": [ "prepaid", "postpaid" ], "amount": [ 100, 100 ] } } - The `amount` field represents the percentage of the actual amount deducted from the user's balance based on user level.