PHP code example of aimtoget / aimtoget-agent-lib

1. Go to this page and download the library: Download aimtoget/aimtoget-agent-lib 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/ */

    

aimtoget / aimtoget-agent-lib example snippets




use Aimtoget\Agent\Config;

$config = new Config('--Secret key--', '--Wallet Pin--');



use Aimtoget\Agent\Account;

$account = new Account($config);
echo $account->getBalance();



use Aimtoget\Agent\Airtime;

$airtime = new Airtime($config);

//Purchase NGN100 Airtime
$reference = $airtime->purchase([
    'phone' => '09061668519',
    'network_id' => 1,
    'amount' => 100
]);



use Aimtoget\Agent\Networks;

$networks = new Networks($config);
$all_networks = $networks->getAllNetworks();



use Aimtoget\Agent\Data;

$data = new Data($config);

//All Plans
$all = $data->getAllVariations();

//Retrieve plans for a certain network
$plans = $data->getNetworkVariations($network_id);

//Purchase 1GB of MTN data
$reference = $data->purchase([
    'phone' => '09061668519',
    'network_id' => 1,
    'variation' => 'M1024'
]);



use Aimtoget\Agent\Services;

$services = new Services($config);

//Get all services
$all = $services->getAll();

$service = $services->getService($service_id);

$verify = $services->verifyCustomer($service_id, $customer_id);

$reference = $service->pay($service_id, [
    'customer_id' => $customer_id,
    'amount' => $amount, //For services WITHOUT variations,
    'variation' => $variaiton, //For services WITH variations,
    'phone' => $customer_phone,
    'email' => $customer_email
 ]);



use Aimtoget\Agent\BankTransfer;

$bank = new BankTransfer($config);

//Get banks
$banks = $bank->getBanks();



use Aimtoget\Agent\BankTransfer;

$bank = new BankTransfer($config);
$account_name = $bank->resolveAccount('-bank code--', '-account number-');

echo $account_name;



use Aimtoget\Agent\BankTransfer;

$bank = new BankTransfer($config);
$reference = $bank->transfer([
    'amount' => 2000,
    'bank_code' => '00007',
    'account_number' => '0123456789',
    'description' => 'Transfer narration'
]);

echo $reference;



use Aimtoget\Agent\Transactions;

$transactions = new Transactions($config);
$list = $transactions->getTransactions(); //Fetches first 10 transactions

$details = $transactions->getTransaction($reference_code);