Electricity
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer_id: '<string>', product_name: '<string>', reference: '<string>'})
};
fetch('https://app.datashop.africa/api/v2/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.datashop.africa/api/v2/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"product_name": "<string>",
"reference": "<string>"
}
'import requests
url = "https://app.datashop.africa/api/v2/purchase"
payload = {
"customer_id": "<string>",
"product_name": "<string>",
"reference": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.datashop.africa/api/v2/purchase",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '<string>',
'product_name' => '<string>',
'reference' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}Purchases
Electricity
Vend electricity for a meter.
POST
/
api
/
v2
/
purchase
Electricity
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer_id: '<string>', product_name: '<string>', reference: '<string>'})
};
fetch('https://app.datashop.africa/api/v2/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.datashop.africa/api/v2/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"product_name": "<string>",
"reference": "<string>"
}
'import requests
url = "https://app.datashop.africa/api/v2/purchase"
payload = {
"customer_id": "<string>",
"product_name": "<string>",
"reference": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.datashop.africa/api/v2/purchase",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '<string>',
'product_name' => '<string>',
'reference' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}Submit an electricity purchase after the meter and amount have been confirmed. Successful prepaid purchases may return the token, units, meter details, and customer name for the receipt.
Request body
string
required
Meter number or customer identifier for the electricity provider.
string
required
Electricity product selected from List products.
number
Required when the product has
amount_required: true.string
required
Unique transaction reference from your system. Must be 15 to 40 characters.
Request
{
"customer_id": "45705225097",
"product_name": "jos-electric-prepaid",
"amount": 1000,
"reference": "merchant-ref-8905fff6767"
}
Successful response
{
"status": true,
"message": "Purchase processed successfully.",
"data": {
"reference": "merchant-ref-8905fff6767",
"customer_id": "45705225097",
"service": "electricity",
"provider": "Jos Electric",
"product_name": "jos-electric-prepaid",
"quantity": 1000,
"paid_amount": 990,
"transaction_status": "successful",
"token": "7060-8360-1787-0933-6869",
"units": "4.5",
"meter_number": "45705225097",
"customer_name": "UMAR MOHD AWWAL",
"customer_address": "NEW MILE 3",
"disco": "Jos Electric - JED",
"remark": "7060-8360-1787-0933-6869\n\n(4.5 KWH)"
}
}
Processing response
{
"status": true,
"message": "Purchase is processing.",
"data": {
"reference": "merchant-ref-8905fff6767",
"customer_id": "45705225097",
"service": "electricity",
"provider": "Jos Electric",
"product_name": "jos-electric-prepaid",
"quantity": 1000,
"paid_amount": 990,
"transaction_status": "processing"
}
}
Failed response
{
"status": false,
"message": "Error message"
}
⌘I