diff --git a/Controller/Adminhtml/Action/MarkAsPaid.php b/Controller/Adminhtml/Action/MarkAsPaid.php index ce366aa34d4..5a57316fd3e 100644 --- a/Controller/Adminhtml/Action/MarkAsPaid.php +++ b/Controller/Adminhtml/Action/MarkAsPaid.php @@ -110,9 +110,10 @@ public function execute() $order = $this->recreateOrder($originalOrder); $invoice = $this->createInvoiceFor($order); - $this->cancelOriginalOrder($originalOrder, $order->getIncrementId()); + $this->cancelOriginalOrder($originalOrder); $this->transaction->save(); + $this->addCommentHistoryOriginalOrder($originalOrder, $order->getIncrementId()); $this->sendInvoice($invoice, $order); $this->messageManager->addSuccessMessage( @@ -152,15 +153,22 @@ private function recreateOrder(OrderInterface $originalOrder) return $order; } + /** + * @param OrderInterface $originalOrder + */ + private function cancelOriginalOrder(OrderInterface $originalOrder) + { + $originalOrder->cancel(); + } + /** * @param OrderInterface $originalOrder * @param string $newIncrementId */ - private function cancelOriginalOrder(OrderInterface $originalOrder, $newIncrementId) + private function addCommentHistoryOriginalOrder(OrderInterface $originalOrder, $newIncrementId) { $comment = __('We created a new order with increment ID: %1', $newIncrementId); - $originalOrder->addCommentToStatusHistory($comment); - $originalOrder->cancel(); + $this->orderCommentHistory->add($originalOrder, $comment, false); } private function createInvoiceFor(OrderInterface $order) @@ -187,7 +195,7 @@ private function sendInvoice(InvoiceInterface $invoice, OrderInterface $order) $this->orderCommentHistory->add($order, $message, true); } catch (\Throwable $exception) { $message = __('Unable to send the invoice: %1', $exception->getMessage()); - $this->orderCommentHistory->add($order, $message, true); + $this->orderCommentHistory->add($order, $message, false); } } } diff --git a/Model/Methods/Reorder.php b/Model/Methods/Reorder.php index 088a56e3c60..c2fb4cad392 100644 --- a/Model/Methods/Reorder.php +++ b/Model/Methods/Reorder.php @@ -6,7 +6,6 @@ namespace Mollie\Payment\Model\Methods; -use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Api\ExtensionAttributesFactory; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -18,7 +17,6 @@ use Magento\Payment\Helper\Data; use Magento\Payment\Model\Method\AbstractMethod; use Magento\Payment\Model\Method\Logger; -use Mollie\Payment\Model\Mollie; /** * Class Reorder @@ -71,8 +69,7 @@ public function __construct( RequestInterface $request, AbstractResource $resource = null, AbstractDb $resourceCollection = null, - array $data = [], - DirectoryHelper $directory = null + array $data = [] ) { $this->request = $request; @@ -86,8 +83,7 @@ public function __construct( $logger, $resource, $resourceCollection, - $data, - $directory + $data ); }