From efb909555e0a3edbf15eb95083a1b5a4994400e4 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 1 Mar 2024 14:28:52 +0800 Subject: [PATCH 1/7] debug payment not showing issue --- routes/web.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/routes/web.php b/routes/web.php index a6590c17..1fb2878f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -866,3 +866,55 @@ Route::get('/invoice/{marking}/{started_at}/{ended_at}/fix', function($marking, } ); })->name('invoice.fix.byCustomerMarking'); + +Route::get('/transfer/{marking}/payment-details', function ($marking) { + $booking = Booking::where('marking', $marking)->first(); + + $transactions = $booking->transactions()->withTrashed()->get(); + + $statusLabels = [ + 0 => 'PAYMENT_ATTEMPT', + 1 => 'PAYMENT', + 2 => 'INVOICE', + 3 => 'BILL', + 4 => 'PROFORMA', + 5 => 'TOP_UP', + 6 => 'REFUND', + 7 => 'PURCHASE_ORDER', + 8 => 'SUPPLIER_DELIVER', + 9 => 'CREDIT_NOTE', + 10 => 'WITHDRAW', + 11 => 'DEBIT_NOTE', + 12 => 'TRANSFER_FEE', + 13 => 'CASH_BACK', + ]; + + $ApprovalStatus = ApprovalStatus::APPROVAL_STATUS_ID; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + foreach ($transactions as $transaction) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo '
IDAmountTypeStatusCreated AtDeleted At
' . $transaction->id . '' . $transaction->amount . '' . $statusLabels[$transaction->type] . '' . $ApprovalStatus [$transaction->status] . '' . $transaction->created_at . '' . $transaction->deleted_at . '
'; +}); From 5cf55453fd690186aa03413add24a54d38805a3e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 1 Mar 2024 21:57:06 +0800 Subject: [PATCH 2/7] show-booking-expired for debug payment not showing --- app/Console/Kernel.php | 12 ++++---- routes/web.php | 70 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 5e9aa8a8..d1f54f52 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -44,13 +44,13 @@ class Kernel extends ConsoleKernel ->appendOutputTo(storage_path().'/logs/delete-bulk-download-files.log') ->withoutOverlapping(); - $schedule->command('booking:expired') - ->dailyAt('02:00') - ->withoutOverlapping(); + // $schedule->command('booking:expired') + // ->dailyAt('02:00') + // ->withoutOverlapping(); - $schedule->command('purchaseOrder:autoFill') - ->dailyAt('03:00') - ->withoutOverlapping(); + // $schedule->command('purchaseOrder:autoFill') + // ->dailyAt('03:00') + // ->withoutOverlapping(); } /** diff --git a/routes/web.php b/routes/web.php index 1fb2878f..44380046 100644 --- a/routes/web.php +++ b/routes/web.php @@ -872,6 +872,8 @@ Route::get('/transfer/{marking}/payment-details', function ($marking) { $transactions = $booking->transactions()->withTrashed()->get(); + $paymentMethods = PaymentMethodType::PAYMENT_METHODS_ID; + $statusLabels = [ 0 => 'PAYMENT_ATTEMPT', 1 => 'PAYMENT', @@ -898,6 +900,7 @@ Route::get('/transfer/{marking}/payment-details', function ($marking) { echo 'Amount'; echo 'Type'; echo 'Status'; + echo 'Payment Method'; echo 'Created At'; echo 'Deleted At'; echo ''; @@ -910,6 +913,7 @@ Route::get('/transfer/{marking}/payment-details', function ($marking) { echo '' . $transaction->amount . ''; echo '' . $statusLabels[$transaction->type] . ''; echo '' . $ApprovalStatus [$transaction->status] . ''; + echo '' . $paymentMethods [$transaction->payment_method] . ''; echo '' . $transaction->created_at . ''; echo '' . $transaction->deleted_at . ''; echo ''; @@ -917,4 +921,70 @@ Route::get('/transfer/{marking}/payment-details', function ($marking) { echo ''; echo ''; + + echo '
'; + echo 'Wallet Details'; + +})->name('booking.details.transactions'); + +Route::get('show-booking-expired', function () { + $transactions = Transaction::where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::EXPIRED) + ->whereDate('updated_at', '>=', '2024-02-16') + ->orderBy('updated_at', 'desc') + ->get(); + // print_r(count($transactions)); + + + $statusLabels = [ + 0 => 'PAYMENT_ATTEMPT', + 1 => 'PAYMENT', + 2 => 'INVOICE', + 3 => 'BILL', + 4 => 'PROFORMA', + 5 => 'TOP_UP', + 6 => 'REFUND', + 7 => 'PURCHASE_ORDER', + 8 => 'SUPPLIER_DELIVER', + 9 => 'CREDIT_NOTE', + 10 => 'WITHDRAW', + 11 => 'DEBIT_NOTE', + 12 => 'TRANSFER_FEE', + 13 => 'CASH_BACK', + ]; + + $ApprovalStatus = ApprovalStatus::APPROVAL_STATUS_ID; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $counter = 1; + + foreach ($transactions as $transaction) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo '
CounterIDBookingPaymentsAmountTypeStatusUpdated At
' . $counter++ . '' . $transaction->id . '' . ''.$transaction->owner->marking.'' . '' . 'Payments' . '' . $transaction->amount . '' . $statusLabels[$transaction->type] . '' . $ApprovalStatus [$transaction->status] . '' . $transaction->updated_at . '
'; }); From dfc2ddd09b8809b5db806139d92e4ddc333c2f6f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 1 Mar 2024 22:49:14 +0800 Subject: [PATCH 3/7] debug payment not showing issue --- routes/web.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index 44380046..ddc5ae7e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -922,8 +922,10 @@ Route::get('/transfer/{marking}/payment-details', function ($marking) { echo ''; echo ''; - echo '
'; - echo 'Wallet Details'; + echo '
----------------------------------------------------------------
'; + + echo 'Wallet Details'; + })->name('booking.details.transactions'); @@ -931,6 +933,7 @@ Route::get('show-booking-expired', function () { $transactions = Transaction::where('type', TransactionType::PAYMENT) ->where('status', ApprovalStatus::EXPIRED) ->whereDate('updated_at', '>=', '2024-02-16') + ->take(10) ->orderBy('updated_at', 'desc') ->get(); // print_r(count($transactions)); @@ -954,6 +957,8 @@ Route::get('show-booking-expired', function () { ]; $ApprovalStatus = ApprovalStatus::APPROVAL_STATUS_ID; + + $paymentMethods = PaymentMethodType::PAYMENT_METHODS_ID; echo ''; echo ''; @@ -965,6 +970,8 @@ Route::get('show-booking-expired', function () { echo ''; echo ''; echo ''; + echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -973,6 +980,23 @@ Route::get('show-booking-expired', function () { $counter = 1; foreach ($transactions as $transaction) { + + $billplz_status = null; + + if ($transaction->payment_method == PaymentMethodType::PAYMENT_GATEWAY) { + $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']) { + $billplz_status = 'Paid'; + } else { + $billplz_status = $transaction->id . " => Fraud"; + } + } else { + $billplz_status = $transaction->id . " => billplz error"; + } + } + echo ''; echo ''; echo ''; @@ -981,6 +1005,8 @@ Route::get('show-booking-expired', function () { echo ''; echo ''; echo ''; + echo ''; + echo ''; echo ''; echo ''; } From b2dd34106ccfea281d1bad2a6fde0e4a2a266a57 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 1 Mar 2024 22:51:56 +0800 Subject: [PATCH 4/7] debug payment not showing issue --- routes/web.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/web.php b/routes/web.php index ddc5ae7e..bc6730f5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -973,6 +973,7 @@ Route::get('show-booking-expired', function () { echo ''; echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -1008,6 +1009,7 @@ Route::get('show-booking-expired', function () { echo ''; echo ''; echo ''; + echo ''; echo ''; } From 42a399999a8edb965da5b5686467ea116f45bf4c Mon Sep 17 00:00:00 2001 From: JiaSheng Date: Fri, 1 Mar 2024 23:28:14 +0800 Subject: [PATCH 5/7] uncomment and log to specific file for booking expired command --- app/Console/Commands/ExpiredBookingCommand.php | 8 ++++---- app/Console/Kernel.php | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/ExpiredBookingCommand.php b/app/Console/Commands/ExpiredBookingCommand.php index 5779a9e9..2be39c15 100644 --- a/app/Console/Commands/ExpiredBookingCommand.php +++ b/app/Console/Commands/ExpiredBookingCommand.php @@ -62,14 +62,14 @@ class ExpiredBookingCommand extends Command foreach ($bookings as $booking) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - Log::info("Expired Booking without payment & purchase order, booking id: " . $booking->id); + $this->info("Expired Booking without payment & purchase order, booking id: " . $booking->id); $transactions = $booking->transactions; foreach ($transactions as $transaction) { $prevStatus = $transaction->status; $transaction->status = ApprovalStatus::EXPIRED; $transaction->save(); - Log::info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); + $this->info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); } } @@ -86,14 +86,14 @@ class ExpiredBookingCommand extends Command foreach ($bookings as $booking) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - Log::info("Expired Booking without payment but with purchase order, booking id: " . $booking->id); + $this->info("Expired Booking without payment but with purchase order, booking id: " . $booking->id); $transactions = $booking->transactions; foreach ($transactions as $transaction) { $prevStatus = $transaction->status; $transaction->status = ApprovalStatus::EXPIRED; $transaction->save(); - Log::info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); + $this->info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); } } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index d1f54f52..e455eea1 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -44,9 +44,10 @@ class Kernel extends ConsoleKernel ->appendOutputTo(storage_path().'/logs/delete-bulk-download-files.log') ->withoutOverlapping(); - // $schedule->command('booking:expired') - // ->dailyAt('02:00') - // ->withoutOverlapping(); + $schedule->command('booking:expired') + ->dailyAt('02:00') + ->appendOutputTo(storage_path().'/logs/expire-booking.log') + ->withoutOverlapping(); // $schedule->command('purchaseOrder:autoFill') // ->dailyAt('03:00') From 8b22b49937d5b66d1d6cf0c1b39f838e97c4e7a4 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 2 Mar 2024 00:25:00 +0800 Subject: [PATCH 6/7] remove testing code --- routes/web.php | 150 ------------------------------------------------- 1 file changed, 150 deletions(-) diff --git a/routes/web.php b/routes/web.php index bc6730f5..a6590c17 100644 --- a/routes/web.php +++ b/routes/web.php @@ -866,153 +866,3 @@ Route::get('/invoice/{marking}/{started_at}/{ended_at}/fix', function($marking, } ); })->name('invoice.fix.byCustomerMarking'); - -Route::get('/transfer/{marking}/payment-details', function ($marking) { - $booking = Booking::where('marking', $marking)->first(); - - $transactions = $booking->transactions()->withTrashed()->get(); - - $paymentMethods = PaymentMethodType::PAYMENT_METHODS_ID; - - $statusLabels = [ - 0 => 'PAYMENT_ATTEMPT', - 1 => 'PAYMENT', - 2 => 'INVOICE', - 3 => 'BILL', - 4 => 'PROFORMA', - 5 => 'TOP_UP', - 6 => 'REFUND', - 7 => 'PURCHASE_ORDER', - 8 => 'SUPPLIER_DELIVER', - 9 => 'CREDIT_NOTE', - 10 => 'WITHDRAW', - 11 => 'DEBIT_NOTE', - 12 => 'TRANSFER_FEE', - 13 => 'CASH_BACK', - ]; - - $ApprovalStatus = ApprovalStatus::APPROVAL_STATUS_ID; - - echo '
AmountTypeStatusPayment MethodBillPlz ResponseUpdated At
' . $counter++ . '' . $transaction->id . '' . $transaction->amount . '' . $statusLabels[$transaction->type] . '' . $ApprovalStatus [$transaction->status] . '' . $paymentMethods [$transaction->payment_method] . '' . $billplz_status . '' . $transaction->updated_at . '
Payment MethodBillPlz ResponseUpdated AtCreated At
' . $paymentMethods [$transaction->payment_method] . '' . $billplz_status . '' . $transaction->updated_at . '' . $transaction->created_at . '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - foreach ($transactions as $transaction) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - - echo ''; - echo '
IDAmountTypeStatusPayment MethodCreated AtDeleted At
' . $transaction->id . '' . $transaction->amount . '' . $statusLabels[$transaction->type] . '' . $ApprovalStatus [$transaction->status] . '' . $paymentMethods [$transaction->payment_method] . '' . $transaction->created_at . '' . $transaction->deleted_at . '
'; - - echo '
----------------------------------------------------------------
'; - - echo 'Wallet Details'; - - -})->name('booking.details.transactions'); - -Route::get('show-booking-expired', function () { - $transactions = Transaction::where('type', TransactionType::PAYMENT) - ->where('status', ApprovalStatus::EXPIRED) - ->whereDate('updated_at', '>=', '2024-02-16') - ->take(10) - ->orderBy('updated_at', 'desc') - ->get(); - // print_r(count($transactions)); - - - $statusLabels = [ - 0 => 'PAYMENT_ATTEMPT', - 1 => 'PAYMENT', - 2 => 'INVOICE', - 3 => 'BILL', - 4 => 'PROFORMA', - 5 => 'TOP_UP', - 6 => 'REFUND', - 7 => 'PURCHASE_ORDER', - 8 => 'SUPPLIER_DELIVER', - 9 => 'CREDIT_NOTE', - 10 => 'WITHDRAW', - 11 => 'DEBIT_NOTE', - 12 => 'TRANSFER_FEE', - 13 => 'CASH_BACK', - ]; - - $ApprovalStatus = ApprovalStatus::APPROVAL_STATUS_ID; - - $paymentMethods = PaymentMethodType::PAYMENT_METHODS_ID; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - $counter = 1; - - foreach ($transactions as $transaction) { - - $billplz_status = null; - - if ($transaction->payment_method == PaymentMethodType::PAYMENT_GATEWAY) { - $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']) { - $billplz_status = 'Paid'; - } else { - $billplz_status = $transaction->id . " => Fraud"; - } - } else { - $billplz_status = $transaction->id . " => billplz error"; - } - } - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - - echo ''; - echo '
CounterIDBookingPaymentsAmountTypeStatusPayment MethodBillPlz ResponseUpdated AtCreated At
' . $counter++ . '' . $transaction->id . '' . ''.$transaction->owner->marking.'' . '' . 'Payments' . '' . $transaction->amount . '' . $statusLabels[$transaction->type] . '' . $ApprovalStatus [$transaction->status] . '' . $paymentMethods [$transaction->payment_method] . '' . $billplz_status . '' . $transaction->updated_at . '' . $transaction->created_at . '
'; -}); From 2d5bbac3b1f5d21889f3a7846ae33e7f4b32a010 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 2 Mar 2024 00:32:55 +0800 Subject: [PATCH 7/7] update ExpiredBookingCommand logging - add timestamp --- app/Console/Commands/ExpiredBookingCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/ExpiredBookingCommand.php b/app/Console/Commands/ExpiredBookingCommand.php index 2be39c15..fe4f260e 100644 --- a/app/Console/Commands/ExpiredBookingCommand.php +++ b/app/Console/Commands/ExpiredBookingCommand.php @@ -62,14 +62,14 @@ class ExpiredBookingCommand extends Command foreach ($bookings as $booking) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - $this->info("Expired Booking without payment & purchase order, booking id: " . $booking->id); + $this->info(Carbon::now() . " : Expired Booking without payment & purchase order, booking id: " . $booking->id); $transactions = $booking->transactions; foreach ($transactions as $transaction) { $prevStatus = $transaction->status; $transaction->status = ApprovalStatus::EXPIRED; $transaction->save(); - $this->info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); + $this->info(Carbon::now() . " : Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); } } @@ -86,14 +86,14 @@ class ExpiredBookingCommand extends Command foreach ($bookings as $booking) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - $this->info("Expired Booking without payment but with purchase order, booking id: " . $booking->id); + $this->info(Carbon::now() . " : Expired Booking without payment but with purchase order, booking id: " . $booking->id); $transactions = $booking->transactions; foreach ($transactions as $transaction) { $prevStatus = $transaction->status; $transaction->status = ApprovalStatus::EXPIRED; $transaction->save(); - $this->info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); + $this->info(Carbon::now() . " : Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); } } }