# Vend Electricity

## Buy Electricity

<mark style="color:green;">`POST`</mark> `{{base_url}}/electricity`

#### Headers

| Name                                            | Type        | Description                      |
| ----------------------------------------------- | ----------- | -------------------------------- |
| authorization<mark style="color:red;">\*</mark> | SECRET\_KEY | Set value to `Bearer SECRET_KEY` |

#### Request Body

| Name                                       | Type   | Description                                                                                                                           |
| ------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| meterno<mark style="color:red;">\*</mark>  | String | Meter holder number as returned by the [verify electricity](https://docs.1app.online/v1-1/electricity/verify-meter-number) endpoint   |
| provider<mark style="color:red;">\*</mark> | String | Disco/Provider                                                                                                                        |
| amount<mark style="color:red;">\*</mark>   | String | Amount to vend                                                                                                                        |
| vendtype<mark style="color:red;">\*</mark> | String | Vend type as seen on the [**verify electricity**](https://docs.1app.online/v1-1/electricity/verify-meter-number) endpoint             |
| pckgid<mark style="color:red;">\*</mark>   | String | As seen from the [**verify electricity**](https://docs.1app.online/v1-1/electricity/verify-meter-number) endpoint response            |
| address<mark style="color:red;">\*</mark>  | String | As seen from the [**verify electricity**](https://docs.1app.online/v1-1/electricity/verify-meter-number) endpoint response            |
| metername                                  | String | Meter holder name as returned by the [**verify electricity**](https://docs.1app.online/v1-1/electricity/verify-meter-number) endpoint |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": true,
    "message": "Success - Bills Payment  effected successfully - Token: 0283-6213-2450-8322-0153",
    "txref": "API2650280812e8401",
    "charged": 10030,
    "token": "Bills Payment  effected successfully - Token: 0283-6213-2450-8322-0153",
    "newbal": 300094.79
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might do this:

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request POST 'https://api.oneappgo.com//v1/electricity' \
--header 'Authorization: Bearer SECREY_KEY' \
--form 'meterno="62320094725"' \
--form 'metername="BRAHIM MARY OPE"' \
--form 'provider="IBADAN"' \
--form 'amount="10000"' \
--form 'vendtype="PREPAID"'
```

{% endtab %}

{% tab title="NodeJS" %}

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.oneappgo.com/v1/electricity',
  'headers': {
    'Authorization': 'Bearer SECREY_KEY'
  },
  formData: {
    'meterno': '62320094725',
    'metername': 'BRAHIM MARY OPE',
    'provider': 'IBADAN',
    'amount': '10000',
    'vendtype': 'PREPAID'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}

{% tab title="PHP - cURL" %}

```
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.oneappgo.com/v1/electricity',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('meterno' => '62320094725','metername' => 'BRAHIM MARY OPE','provider' => 'IBADAN','amount' => '10000','vendtype' => 'PREPAID'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer SECREY_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Python" %}

```
import requests

url = "https://api.oneappgo.com/v1/electricity"

payload={'meterno': '62320094725',
'metername': 'BRAHIM MARY OPE',
'provider': 'IBADAN',
'amount': '10000',
'vendtype': 'PREPAID'}
files=[

]
headers = {
  'Authorization': 'Bearer SECREY_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}

{% tab title="Dart" %}

```
var headers = {
  'Authorization': 'Bearer SECREY_KEY'
};
var request = http.MultipartRequest('POST', Uri.parse('https://api.oneappgo.com/v1/electricity'));
request.fields.addAll({
  'meterno': '62320094725',
  'metername': 'BRAHIM MARY OPE',
  'provider': 'IBADAN',
  'amount': '10000',
  'vendtype': 'PREPAID'
});

request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
}
else {
  print(response.reasonPhrase);
}

```

{% endtab %}
{% endtabs %}

### Sample Response

```json
{
    "status": true,
    "message": "Success - Bills Payment  effected successfully - Token: 0283-6213-2450-8322-0153",
    "txref": "API2650280812e8401",
    "charged": 10030,
    "token": "Bills Payment  effected successfully - Token: 0283-6213-2450-8322-0153",
    "newbal": 300094.79
}
```
