PHP code example of henryejemuta / laravel-megasubplug
1. Go to this page and download the library: Download henryejemuta/laravel-megasubplug 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-megasubplug example snippets bash
php artisan megasubplug:init
php
use HenryEjemuta\LaravelMegaSubPlug\Facades\MegaSubPlug;
use HenryEjemuta\LaravelMegaSubPlug\Classes\MegaSubPlugResponse;
...
//To buy Airtime
try{
$response = MegaSubPlugFacade::buyAirtime(NetworkEnum::getNetwork('mtn'), 100, '08134567890');
} catch (MegaSubPlugErrorException $exception) {
Log::error($exception->getMessage() . "\n\r" . $exception->getCode());
}
//A dump of the MegaSubPlugResponse on successful airtime purchase
HenryEjemuta\LaravelMegaSubPlug\Classes\MegaSubPlugResponse {#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 = MegaSubPlugFacade::buyData(MegaSubPlugNetworkEnum::getNetwork("mtn"), 7, "08134567890");
} catch (MegaSubPlugErrorException $exception) {
Log::error($exception->getMessage() . "\n\r" . $exception->getCode());
}
//A dump of the MegaSubPlugResponse on successful data purchase
HenryEjemuta\LaravelMegaSubPlug\Classes\MegaSubPlugResponse {#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
}
}
...