Files
shipping-portal/app/Console/Commands/ShowBillplzPaymentStatus.php
T
edmondlang e7c0e17ee4 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into multi-payment-final
# Conflicts:
# app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php
# app/Classes/ValueObjects/Constants/TransactionType.php
# routes/api.php
# routes/web.php
2023-04-28 18:20:42 +08:00

70 lines
1.8 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Transaction;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
class ShowBillplzPaymentStatus extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'billplz-payment-status {billplz_id}` ';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Show Billplz payment status';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
ini_set('memory_limit', '-1');
$this->info(Carbon::now() . ' : Show Billplz payment status started.');
$start = new Carbon();
$billplz_id = $this->argument('billplz_id');
$billplz_id = explode(",", $billplz_id);
foreach ($billplz_id as $payment) {
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment);
if($response->successful()){
$data = $response->json();
dump($data);
}else{
$this->info("billplz error</br>");
}
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
$this->info(Carbon::now() . ' : Done Showing Billplz payment status. ElapsedTime: ' . $elapsedTime);
}
}