Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin-Magmodules committed Nov 26, 2019
1 parent dcdb2f3 commit 512487d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 13 additions & 5 deletions Controller/Adminhtml/Action/MarkAsPaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
}
8 changes: 2 additions & 6 deletions Model/Methods/Reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -86,8 +83,7 @@ public function __construct(
$logger,
$resource,
$resourceCollection,
$data,
$directory
$data
);
}

Expand Down

0 comments on commit 512487d

Please sign in to comment.