diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index ef09dc51..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,7 +344,7 @@ private function processPaidOrder(Transaction $transaction, Order $order) # Change amount paid manually $order->setTotalPaid($order->getGrandTotal()); $order->setBaseTotalPaid($order->getBaseGrandTotal()); - + $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,7 @@ 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); - } + $order->setStatus(!empty($newStatus) ? $newStatus : Order::STATE_PROCESSING); $this->orderRepository->save($order);