From 104ac0db15b96e9729afeb85d08bd68604cd8c3f Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Wed, 25 Aug 2021 15:01:55 +0200 Subject: [PATCH 1/2] Fix status not being set for ignoreB2BInvoice. --- Controller/Checkout/Exchange.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index ef09dc51..66c312eb 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -343,6 +343,8 @@ private function processPaidOrder(Transaction $transaction, Order $order) $order->setTotalPaid($order->getGrandTotal()); $order->setBaseTotalPaid($order->getBaseGrandTotal()); + $newStatus = ($transaction->isAuthorized()) ? $this->config->getAuthorizedStatus($paymentMethod) : $this->config->getPaidStatus($paymentMethod); + $order->setStatus(!empty($newStatus) ? $newStatus : Order::STATE_PROCESSING); $order->addStatusHistoryComment(__('B2B Setting: Skipped creating invoice')); $this->orderRepository->save($order); return $this->result->setContents("TRUE| " . $message . " (B2B: No invoice created)"); @@ -356,13 +358,8 @@ private function processPaidOrder(Transaction $transaction, Order $order) $payment->registerCaptureNotification($paidAmount, $this->config->isSkipFraudDetection()); } - if ($transaction->isAuthorized()) { - $statusAuthorized = $this->config->getAuthorizedStatus($paymentMethod); - $order->setStatus(!empty($statusAuthorized) ? $statusAuthorized : Order::STATE_PROCESSING); - } else { - $statusPaid = $this->config->getPaidStatus($paymentMethod); - $order->setStatus(!empty($statusPaid) ? $statusPaid : Order::STATE_PROCESSING); - } + $newStatus = ($transaction->isAuthorized()) ? $this->config->getAuthorizedStatus($paymentMethod) : $this->config->getPaidStatus($paymentMethod); + $order->setStatus(!empty($newStatus) ? $newStatus : Order::STATE_PROCESSING); $this->orderRepository->save($order); From 7c2f0d625d3947f487bb3c75406db9946d86eea8 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Wed, 25 Aug 2021 15:51:38 +0200 Subject: [PATCH 2/2] remove double code --- Controller/Checkout/Exchange.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 66c312eb..984a13f8 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -326,6 +326,8 @@ private function processPaidOrder(Transaction $transaction, Order $order) $order->addStatusHistoryComment(__('New order email sent'))->setIsCustomerNotified(true)->save(); } + $newStatus = ($transaction->isAuthorized()) ? $this->config->getAuthorizedStatus($paymentMethod) : $this->config->getPaidStatus($paymentMethod); + # Skip creation of invoice for B2B if enabled if ($this->config->ignoreB2BInvoice($paymentMethod)) { $orderCompany = $order->getBillingAddress()->getCompany(); @@ -342,8 +344,6 @@ private function processPaidOrder(Transaction $transaction, Order $order) # Change amount paid manually $order->setTotalPaid($order->getGrandTotal()); $order->setBaseTotalPaid($order->getBaseGrandTotal()); - - $newStatus = ($transaction->isAuthorized()) ? $this->config->getAuthorizedStatus($paymentMethod) : $this->config->getPaidStatus($paymentMethod); $order->setStatus(!empty($newStatus) ? $newStatus : Order::STATE_PROCESSING); $order->addStatusHistoryComment(__('B2B Setting: Skipped creating invoice')); $this->orderRepository->save($order); @@ -358,7 +358,6 @@ private function processPaidOrder(Transaction $transaction, Order $order) $payment->registerCaptureNotification($paidAmount, $this->config->isSkipFraudDetection()); } - $newStatus = ($transaction->isAuthorized()) ? $this->config->getAuthorizedStatus($paymentMethod) : $this->config->getPaidStatus($paymentMethod); $order->setStatus(!empty($newStatus) ? $newStatus : Order::STATE_PROCESSING); $this->orderRepository->save($order);