Handle error whenever api query made to portal arrahnpay is made not in operating hours
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BillplzTransactionSummaryController extends Controller
|
||||
{
|
||||
@@ -31,7 +32,21 @@ class BillplzTransactionSummaryController extends Controller
|
||||
$transactionData = $this->processArrahnTransactions($transactionData);
|
||||
|
||||
$billIds = $transactionData->map(fn($x) => ['bill_id' => $x['bill_id'], 'account_own_by' => $x['account_own_by']]);
|
||||
$billplzBills = Http::get(config('api.url_arrahn_portal') . '/api/billplz', ['bill_ids' => json_encode($billIds)])->json();
|
||||
|
||||
$billplzBillsResponse = Http::get(config('api.url_arrahn_portal') . '/api/billplz', ['bill_ids' => json_encode($billIds)]);
|
||||
|
||||
if($billplzBillsResponse->failed()) {
|
||||
|
||||
Log::error("ArrahnPay Portal API request failed for URL: {$billplzBillsResponse->effectiveUri()->__toString()}", [
|
||||
'status' => $billplzBillsResponse->status(),
|
||||
'body' => $billplzBillsResponse->body(),
|
||||
]);
|
||||
|
||||
abort(404, 'Portal ArrahnPay kemungkinan tidak beroperasi. Waktu Operasi Portal ArrahnPay adalah dari 7.30 AM hingga 11.30 PM');
|
||||
|
||||
}
|
||||
|
||||
$billplzBills = $billplzBillsResponse->json();
|
||||
|
||||
$data = array_map(fn($x, $y) => $this->processBillplzBills($x, $y), $billplzBills, [$transactionDataKOOP, $transactionDataPKB]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user