PHP code example of henryejemuta / laravel-megasup
1. Go to this page and download the library: Download henryejemuta/laravel-megasup 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 / laravel-megasup example snippets bash
php artisan megasup:init
php
use HenryEjemuta\LaravelMegaSup\Facades\MegaSup;
use HenryEjemuta\LaravelMegaSup\Classes\MegaSupResponse;
...
//To buy Airtime
try{
$response = MegaSupFacade::buyAirtime(NetworkEnum::getNetwork('mtn'), 100, '08134567890');
} catch (MegaSupErrorException $exception) {
Log::error($exception->getMessage() . "\n\r" . $exception->getCode());
}
//A dump of the MegaSupResponse on successful airtime purchase
HenryEjemuta\LaravelMegaSup\Classes\MegaSupResponse {#1423 ▼
-message: ""
-hasError: false
-error: null
-code: 200
-body: {#1539 ▼
+"id": 167630
+"airtime_type": "VTU"
+"network": 1
+"paid_amount": "97.0"
+"mobile_number": "08134567890"
+"amount": "100"
+"plan_amount": "₦100"
+"plan_network": "MTN"
+"balance_before": "2892.6"
+"balance_after": "2795.6"
+"Status": "successful"
+"create_date": "2021-08-28T21:02:54.311846"
+"Ported_number": true
}
}
//To buy Data Bundle
try{
$response = MegaSupFacade::buyData(MegaSupNetworkEnum::getNetwork("mtn"), 7, "08134567890");
} catch (MegaSupErrorException $exception) {
Log::error($exception->getMessage() . "\n\r" . $exception->getCode());
}
//A dump of the MegaSupResponse on successful data purchase
HenryEjemuta\LaravelMegaSup\Classes\MegaSupResponse {#1423 ▼
-message: ""
-hasError: false
-error: null
-code: 200
-body: {#1539 ▼
+"id": 108602
+"network": 1
+"balance_before": "2698.6"
+"balance_after": "2459.6"
+"mobile_number": "08134567890"
+"plan": 7
+"Status": "successful"
+"plan_network": "MTN"
+"plan_name": "1.0GB"
+"plan_amount": "₦239.0"
+"create_date": "2021-08-28T21:27:41.169631"
+"Ported_number": true
}
}
...