I have a custom payment module. When the user select this payment method at checkout, he is redirected to custom module controller, which redirects him to payment gateway. Then he fills his credit card info and is redirected back to custom module controller. Here I process the gateway reply to see if payment was success or not and update the order status. But currently, the user stays on this page.
How do I redirect him to Checkout Success page (where the order ID tracking and create account buttons are displayed)? It works if I simply redirect him to /checkout/onepage/success, but is this a correct way how to do it?
And how do I redirect him to Checkout failed page? In Magento 1, I restored the cart and redirected him to cart view with error message like this:
//restore cart $session = Mage::getSingleton('checkout/session'); $lastQuoteId = $session->getLastQuoteId(); $quote = Mage::getModel('sales/quote')->load($lastQuoteId); $quote->setIsActive(true)->save(); //redirect to cart with error message $failMsg = $this->__('Payment failed. Please try again.') . " " . $orderReplyStatus->resultText; Mage::getSingleton('core/session')->addError($failMsg); $this->_redirect('checkout/cart');
Do I have to do the same in Magento 2 or does Magento 2 have a checkout failed page?