diff --git a/routes/web.php b/routes/web.php index a4619efc..c510eb1d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -955,3 +955,26 @@ Route::get('/packing-lists/delete-duplicated', function(Request $request){ } } }); + +Route::get('/billplz/audit', function (Request $request) { + $transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get(); + $i = 0; + $totalAmount = 0; + 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()){ + $data = $response->json(); + if($data['paid']){ + + } else { + $totalAmount += $transaction->amount; + echo $transaction->id." => Fraud." . $transaction->amount . "
"; + } + }else{ + echo "billplz error
"; + } + } + + echo 'Total: ' . $totalAmount; +}); \ No newline at end of file