audit billplz

This commit is contained in:
edmondlang
2023-03-13 00:42:44 +08:00
parent 8277b9d0fd
commit 715384f4a4
+23
View File
@@ -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 . " </br>";
}
}else{
echo "billplz error</br>";
}
}
echo 'Total: ' . $totalAmount;
});