61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class BillplzTransactionReviewController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$date = request()->selectedDate ?? Carbon::now()->toDateString();
|
|
|
|
try {
|
|
$response = Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review', ['date' => $date]);
|
|
|
|
if ($response->failed()) {
|
|
throw new \Exception('ArrahnPay portal returned ' . $response->status());
|
|
}
|
|
|
|
[$pkbTransactionsReview, $kopkbTransactionsReview] = $response->json();
|
|
} catch (\Exception $e) {
|
|
Log::error('Billplz transaction review index failed', [
|
|
'date' => $date,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
|
|
return redirect()->back()->with('errormessage', 'Portal ArrahnPay kemungkinan tidak beroperasi. Waktu Operasi Portal ArrahnPay adalah dari 7.30 AM hingga 11.30 PM');
|
|
}
|
|
|
|
return view('online.billplz-transaction-review.index', compact('pkbTransactionsReview', 'kopkbTransactionsReview', 'date'));
|
|
}
|
|
public function show($bill_id)
|
|
{
|
|
try {
|
|
$response = Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review/' . $bill_id);
|
|
|
|
if ($response->failed()) {
|
|
throw new \Exception('ArrahnPay portal returned ' . $response->status());
|
|
}
|
|
|
|
$billPlzTransactionReview = $response->json();
|
|
$billPlzTransactionReview = array_filter($billPlzTransactionReview, fn($x) => $x[0]['billplz_latest_transaction'] !== null);
|
|
$billPlzTransactionReview = array_pop($billPlzTransactionReview) ?? [];
|
|
} catch (\Exception $e) {
|
|
Log::error('Billplz transaction review show failed', [
|
|
'bill_id' => $bill_id,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
|
|
return redirect()->back()->with('errormessage', 'Portal ArrahnPay kemungkinan tidak beroperasi. Waktu Operasi Portal ArrahnPay adalah dari 7.30 AM hingga 11.30 PM');
|
|
}
|
|
|
|
return view('online.billplz-transaction-review.show', compact('billPlzTransactionReview', 'bill_id'));
|
|
}
|
|
|
|
}
|