From 1679d1ecf4704e48f363e0c3b1771f38d6766adc Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 16 Mar 2024 15:49:02 +0800 Subject: [PATCH] Fix a problem of unsuccessful payment when shipping invoice is paid first before storage invoice appear --- .../Processors/CallbackBillplzProcessor.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php index 79b81452..b5909cf1 100644 --- a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php +++ b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php @@ -80,12 +80,13 @@ class CallbackBillplzProcessor if ($group) { foreach ($group->groupTransactions as $groupTransaction) { $invoice = $groupTransaction->transaction; + if($invoice->status !== ApprovalStatus::COMPLETED){ + $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); - $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); - - if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ - $pL = $invoice->owner; - $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); + if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ + $pL = $invoice->owner; + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); + } } } @@ -111,7 +112,9 @@ class CallbackBillplzProcessor foreach ($group->groupTransactions as $groupTransaction) { $invoice = $groupTransaction->transaction; - $totalAmountToBePaid += $invoice->amount; + if($invoice->status !== ApprovalStatus::COMPLETED){ + $totalAmountToBePaid += $invoice->amount; + } } if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){