PHP code example of henryejemuta / php-vtung-vtu

1. Go to this page and download the library: Download henryejemuta/php-vtung-vtu library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

henryejemuta / php-vtung-vtu example snippets


use HenryEjemuta\Vtung\Client;

// Option 1: Authenticate with username and password
$client = new Client();
$response = $client->authenticate('your_username', 'your_password');
$token = $response['token'];

// Option 2: Instantiate with existing token
$client = new Client('your_jwt_token');

$balance = $client->getBalance();
print_r($balance);

// $requestId should be a unique identifier for the transaction
$requestId = uniqid();
$result = $client->purchaseAirtime('mtn', '08012345678', 100, $requestId);
print_r($result);

// Get Data Variations
$variations = $client->getDataVariations('mtn');
print_r($variations);

// Purchase Data
$requestId = uniqid();
$result = $client->purchaseData('mtn', '08012345678', 'variation_id', $requestId);
print_r($result);

// Electricity
$customer = $client->verifyCustomer('12345678901', 'ikeja-electric', 'prepaid');

// Cable TV
$customer = $client->verifyCustomer('1234567890', 'dstv');

$requestId = uniqid();
$result = $client->purchaseElectricity($requestId, '12345678901', 'ikeja-electric', 'prepaid', 1000);

$requestId = uniqid();
$result = $client->purchaseCableTV($requestId, '1234567890', 'dstv', 'variation_id');
bash
composer