vtu-ng
Version:
VTU NG package for buying and sending airtime, data, cable tv and electricity
119 lines (90 loc) • 1.95 kB
Markdown
A NodeJS wrapper for the [VTU NG](https://vtu.ng/api)
This project is an easy to use API to access VTU NG endpoints.
> Install from the NPM Registry
` $ npm install --save vtu-ng `
```
const vtu = require("vtu-ng");
require("dotenv").config();
// Using Promise
const response = vtu.getVTUBalance("balance", process.env.VTU_USERNAME, process.env.VTU_PASS);
response.then(function(result) {
return result;
});
// Using async/await
const checkBalance = async () => {
const response = await vtu.getVTUBalance(
"balance",
process.env.VTU_USERNAME,
process.env.VTU_PASS
);
return response;
}
const buyAirtime = async () => {
const response = await vtu.purchaseAirtime(
"balance",
process.env.VTU_USERNAME,
process.env.VTU_PASS,
phone,
network,
amount
);
return response;
}
const buyData = async () => {
const response = await vtu.purchaseData(
"balance",
process.env.VTU_USERNAME,
process.env.VTU_PASS,
phone,
network,
plan
);
return response;
}
const verifyCustomer = async () => {
const response = await vtu.verifyCustomer(
"balance",
process.env.VTU_USERNAME,
process.env.VTU_PASS,
customer,
service,
variation
);
return response;
}
const payCableTV = async () => {
const response = await vtu.subscribeCableTV(
"balance",
process.env.VTU_USERNAME,
process.env.VTU_PASS,
phone,
provider,
smartcard,
plan
);
return response;
}
const payElectricity = async () => {
const response = await vtu.subscribeElectricity(
"balance",
process.env.VTU_USERNAME,
process.env.VTU_PASS,
phone,
meter,
provider,
variation,
amount
);
return response;
}
```
MIT
[](https://twitter.com/celebritydev)
See the **[CONTRIBUTING.md](https://github.com/celebritydeveloper)** file for information.