_checkoutSession = $checkoutSession; $this->_orderFactory = $orderFactory; $this->_logger = $logger; $this->_payflowModelFactory = $payflowModelFactory; $this->_checkoutHelper = $checkoutHelper; $this->paymentFailures = $paymentFailures ?: $this->_objectManager->get( \Magento\Sales\Api\PaymentFailuresInterface::class ); } /** * Cancel order, return quote to customer * * @param string $errorMsg * @return false|string */ protected function _cancelPayment($errorMsg = '') { $errorMsg = trim(strip_tags($errorMsg)); $order = $this->_checkoutSession->getLastRealOrder(); if ($order->getId()) { $this->paymentFailures->handle((int)$order->getQuoteId(), $errorMsg); } $gotoSection = false; $this->_checkoutHelper->cancelCurrentOrder($errorMsg); if ($this->_checkoutSession->restoreQuote()) { //Redirect to payment step $gotoSection = 'paymentMethod'; } return $gotoSection; } }