From 1140cc9d3d1edbacf00632d5e438df194660463e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 15 Mar 2023 19:43:51 +0800 Subject: [PATCH] debug billplz payment --- app/Classes/ValueObjects/Constants/ApprovalStatus.php | 11 +++++++++++ app/Console/Commands/debugBillplzFailedPayment.php | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Classes/ValueObjects/Constants/ApprovalStatus.php b/app/Classes/ValueObjects/Constants/ApprovalStatus.php index 154db2ca..ba7660d4 100644 --- a/app/Classes/ValueObjects/Constants/ApprovalStatus.php +++ b/app/Classes/ValueObjects/Constants/ApprovalStatus.php @@ -19,4 +19,15 @@ final class ApprovalStatus { public const EXPIRED = 6; public const REFUNDED = 7; + + public const APPROVAL_STATUS_ID = [ + self::PENDING_SUBMISSION => "Pending Submission", + self::PENDING_VERIFICATION => "Pending Verification", + self::APPROVED => "Approved", + self::COMPLETED => "Completed", + self::REJECTED => "Rejected", + self::SUSPENDED => "Suspended", + self::EXPIRED => "Expired", + self::REFUNDED => "Refunded", + ]; } diff --git a/app/Console/Commands/debugBillplzFailedPayment.php b/app/Console/Commands/debugBillplzFailedPayment.php index 26ddc176..027cc0ba 100644 --- a/app/Console/Commands/debugBillplzFailedPayment.php +++ b/app/Console/Commands/debugBillplzFailedPayment.php @@ -55,18 +55,23 @@ class debugBillplzFailedPayment extends Command $data = $response->json(); if($data['paid']){ if (!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) { - $this->info('Paid transaction - id: '. $transaction->id . '. Booking Marking: '. $transaction->owner->marking . ' - Date: '.$transaction->created_at->format('d-m-Y').' - Amount: '. $transaction->amount); + $this->returnLog('Paid transaction', $transaction); } } // else { // $totalAmount += $transaction->amount; - // $this->info('Unpaid Transaction - id:' . $transaction->id . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount); + // $this->returnLog('Unpaid Transaction', $transaction); // } }else{ - $this->info('billplz error - id: '. $transaction->id . ' - Date: '.$transaction->created_at->format('d-m-Y')); + $this->returnLog('billplz error', $transaction); } } echo 'Total: ' . $totalAmount; } + + public function returnLog($text, $transaction) { + $approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID; + $this->info($text . ' - id: '. $transaction->id . '. Booking Marking: '. $transaction->owner->marking . ' - Date: '.$transaction->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Current Status: ' . $approvalStatusArray[$transaction->status]); + } }