From 0437442b4de658946efbc3d8edde72979569d3ce Mon Sep 17 00:00:00 2001 From: Afiq Hamzah Date: Sun, 16 Feb 2025 12:06:50 +0800 Subject: [PATCH] Fix billplz transaction review not working --- .../BillplzTransactionReviewController.php | 8 ++++---- app/Services/BillplzService.php | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/BillplzTransactionReviewController.php b/app/Http/Controllers/BillplzTransactionReviewController.php index 3aafd26..5160b32 100644 --- a/app/Http/Controllers/BillplzTransactionReviewController.php +++ b/app/Http/Controllers/BillplzTransactionReviewController.php @@ -14,8 +14,8 @@ class BillplzTransactionReviewController extends Controller $date = $request->date ?? Carbon::now()->toDateString(); $companyMapping = [ - CompanyStatus::COM_PKB, - // CompanyStatus::COM_KOOPPKB, + 'PKB', + 'KOPKB', ]; $billplzTransactionReview = array_map(function($company_code) use($date){ @@ -29,8 +29,8 @@ class BillplzTransactionReviewController extends Controller public function show(Request $request) { $companyMapping = [ - CompanyStatus::COM_PKB, - // CompanyStatus::COM_KOOPPKB, + 'PKB', + 'KOPKB', ]; $billplzTransactionReview = array_map(function($company_code) use($request){ diff --git a/app/Services/BillplzService.php b/app/Services/BillplzService.php index 0466a49..0c22e9b 100644 --- a/app/Services/BillplzService.php +++ b/app/Services/BillplzService.php @@ -109,7 +109,14 @@ class BillplzService $billplzID = collect($arrahnTransactions)->pluck('billplz_id')->unique()->values(); $billplzTransactions = collect($billplzID)->map(function ($billId) { - return $this->client->transaction()->get($billId)->toArray(); + try { + return $this->client->transaction()->get($billId)->toArray(); + } catch (\Exception $e) { + return []; + } + }) + ->filter(function ($transaction) { + return $transaction !== []; }) ->map(function ($data) { $latestTransaction = reset($data['transactions']) == false ? [] : reset($data['transactions']); @@ -126,7 +133,14 @@ class BillplzService $billplzID = collect([$billId]); $billplzTransactions = collect($billplzID)->map(function ($billId) { - return $this->client->transaction()->get($billId)->toArray(); + try { + return $this->client->transaction()->get($billId)->toArray(); + } catch (\Exception $e) { + return []; + } + }) + ->filter(function ($transaction) { + return $transaction !== []; }) ->map(function ($data) { $latestTransaction = reset($data['transactions']) == false ? [] : reset($data['transactions']);