From fa4cfc0d75795aa9d5fdca6179732c6ade0a7d28 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 8 Oct 2023 23:53:39 +0800 Subject: [PATCH] debug billplz --- routes/web.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 36fd793f..a5e89df4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1078,7 +1078,8 @@ Route::get('/wallet/audit', function (Request $request) { foreach ($wallet->transactions as $transaction){ if(!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue; - if((int) $transaction->type === TransactionType::TOP_UP) { + if((int) $transaction->type === TransactionType::TOP_UP || (int) $transaction->type === TransactionType::GROUP_PAYMENT) { + // if((int) $transaction->type === TransactionType::TOP_UP) { $topups += (float) $transaction->amount; } if((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount; @@ -1191,4 +1192,20 @@ Route::get('/duplicate-package-clean-up', function(){ Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download'); +Route::get('/check-successful-payment-or-topup', function () { + $sum = 0 ; + $transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get(); + foreach ($transactions as $transaction){ + $response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference); + + if($response->successful()){ + $sum += $transaction->amount; + dump($transaction->payment_reference . 'Amount : ' . $transaction->amount); + }else{ + dump("billplz error
"); + } + } + + dump("Sum is : " . $sum); +});