Skip to content

Better manage failed payment #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Api/Service.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
use Magento\Quote\Model\QuoteFactory;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Api\OrderManagementInterface;

class Service implements ServiceInterface
{
@@ -34,7 +35,6 @@ class Service implements ServiceInterface
*/
private $serializer;


/**
* @var QuoteFactory
*/
@@ -45,6 +45,11 @@ class Service implements ServiceInterface
*/
private $orderRepository;

/**
* @var OrderManagementInterface
*/
protected $orderManagement;

/**
* @var Order
*/
@@ -69,6 +74,7 @@ public function __construct(
Registry $registry,
QuoteFactory $quoteFactory,
OrderRepositoryInterface $orderRepository,
OrderManagementInterface $orderManagement,
Order $order
) {
$this->checkoutHelper = $checkoutHelper;
@@ -78,6 +84,7 @@ public function __construct(
$this->quoteFactory = $quoteFactory;
$this->orderRepository = $orderRepository;
$this->order = $order;
$this->orderManagement = $orderManagement;
}

public function deleteLastRealOrder()
@@ -88,6 +95,7 @@ public function deleteLastRealOrder()
}

$order = $this->order->loadByIncrementId($lastRealOrderId);
$this->orderManagement->cancel($order->getId());
$this->orderRepository->delete($order);
}