1.0.9 • Published 2 years ago

vtpassnodejs v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

vtpassnodejs

A Package to interact with vtpass api using nodejs

Vtpass documentation

Response codes

Webook

how to generate request id

#installation You can install the package via npm :

npm install vtpassnodejs

#Usage Please note that for the below examples the classes are initiated in sandbox mode, to intiate the vtpass class in production mode , you will do as shown below

//for production mode
 const vtPassClass = new vtpass('production', 'your username', 'your password');
 
//for test mode
const vtPassClass = new vtpass();
   //recharge airtime
   const vtPassClass = require('vtpassnodejs');
  (async function(){
    const vtPassClass = new vtpass();
	const phone = 08011111111 //this works for test mode 
	const amount = 200;
	const network = 'mtn'; //you can have mtn, airtel, etisalat, glo, smile
	const request_id = 'your unique request id'; // if not passed , one is generated for you automatically by the package
    const buyAirtime = await vtPassClass.airtime.rechargeAirtime(network, amount, phone, variationCode, request_id);
    console.log(buyAirtime);
})();
   //get variation codes for subscriptions for network provider
   const vtPassClass = require('vtpassnodejs');
   (async function(){
    const vtPassClass = new vtpass();
	const provider = 'mtn' //you can have mtn, airtel, etisalat, glo, smile
    const variationCodes = await vtPassClass.data.getVariationCodes('mtn');
    console.log(variationCodes);
})();
   //subscribe data
     const vtPassClass = require('vtpassnodejs');
  (async function(){
    const vtPassClass = new vtpass();
    const variationCode = 'mtn-10mb-100';
    const phone = 08011111111;
    const network = 'mtn'; //you can have mtn, airtel, etisalat, glo, smile
	const request_id = 'your unique request id'; // if not passed , one is generated for you automatically by the package, [how to generate request id] (https://www.vtpass.com/documentation/how-to-generate-request-id/)
    const buyData = await vtPassClass.data.buyData(phone, network, variationCode, request_id);
    console.log(buyData);
})();
   //verify smile phone number
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
	const phone = 2348011111111;
    const verifyPhone = await vtPassClass.data.verifySmilePhoneNumber(phone);
    console.log(verifyPhone);
})();
   //verify smile email
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
	const email = 'tester@sandbox.com';
    const verifyEmail = await vtPassClass.data.verifySmileEmail(email);
    console.log(verifyEmail);
})();
   //get variation codes for tvn subscriptions
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
	const provider = 'dstv'; //dstv, gotv, startimes
    const varationCodes = await vtPassClass.tv.getVariationCodes(provider);
    console.log(varationCodes);
})();
   //verify smart card number
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
    const provider = 'dstv';
    const billersCode = 1212121212;
    const verifySmartCard = await vtPassClass.tv.verifySmartCard(provider, billersCode);
    console.log(verifySmartCard);
})();
   //subscribe tv
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
    const smartCard = 1212121212;
    const provider = 'dstv';
    const phone = 08011111111;
    const variationCode = 'dstv-padi';
    const amount = ''; //amount can be empty, if amount is not empty, the account is topped up the amount
	const request_id = 'your unique request id'; // if not passed , one is generated for you automatically by the package
    const verifySmartCard = await vtPassClass.tv.subscribeTv(smartCard, provider, phone, variationCode, amount, request_id);
    console.log(verifySmartCard);
})();
   //verify electricity meter number
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
    const provider = 'ikeja-electric';
    const meterNumber = 1111111111111;
    const type = 'prepaid'; //can be prepaid or postpaid
    const verifyMeter = await vtPassClass.electricity.verifyMeterNumber(meterNumber, provider, type)
    console.log(verifyMeter);
})();
   //buy electricity token
     const vtPassClass = require('vtpassnodejs');
(async function(){
    const vtPassClass = new vtpass();
    const provider = 'ikeja-electric'; // ikeja-electric, eko-electric, kano-electric, portharcourt-electric, jos-electric, ibadan-electric, kaduna-electric, abuja-electric
    const meterNumber = 1111111111111;
    const meterType = 'prepaid';
    const amount = 5000;
    const phone = '08011111111';
	const request_id = 'your unique request id'; // if not passed , one is generated for you automatically by the package
    const rechargeLight = await vtPassClass.electricity.rechargeLight(meterNumber, provider, amount, phone, meterType, request_id);
    console.log(rechargeLight);
})();
//get variation codes for educational services 
(async function(){
    const vtPassClass = new vtpass();
	const service = 'waec-registration'; //waec-registration, waec waec-registration is for waec registration, waec option is for result checking service
    const varationCodes = await vtPassClass.educational.getVariationCodes(service);
    console.log(varationCodes);
})();
//purchase token for an educational service
(async function(){
    const vtPassClass = new vtpass();
    const service = 'waec-registration';  //waec-registration, waec waec-registration is for waec registration, waec option is for result checking service
    const amount = 14450; //this is gotten from variation amount on the get variation codes point
    const phone = 08011111111;
    const variation_code = 'waec-registraion'; //this is the variation code gotten from the method above for the service that it belongs 
	const request_id = 'your unique request id'; // if not passed , one is generated for you automatically by the packag
    const registerService = await vtPassClass.educational.registerService(service, amount, phone, variation_code, request_id);
    console.log(registerService);
})();
//requery transaction status
(async function(){
    const vtPassClass = new vtpass();
    const request_id = 'llmOt7lzlOVKQCavfD3U6887';
    const requeryService = await vtPassClass.requeryTransaction(request_id)
    console.log(requeryService);
})();
//get list of banks
(async function(){
    const vtPassClass = new vtpass();
    const banks = await vtPassClass.bank.getVariationCodes();
    console.log(banks);
})();
//verify account number
(async function(){
    const vtPassClass = new vtpass();
    const bank = 'zenith-mobile'; //gotten from bank varation codes
    const accountNumber = 1234567890;
    const bankDetail = await vtPassClass.bank.verifyAccountNumber(bank, accountNumber);
    console.log(bankDetail);
})();
//send money across to banks, please also setup webhooks for this service 
(async function(){
    const vtPassClass = new vtpass();
    const bank = 'zenith-mobile'; //gotten from bank variation codes
    const accountNumber = 1234567890;
    const amount = 100000;
    const phone = '08011111111';
	const request_id = 'your unique request id';
    const deposit = await vtPassClass.bank.deposit(accountNumber, bank, amount, phone, request_id);
    console.log(deposit);
})();

License: ISC

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago