Magento 2 : How to load the order success page
-
16-12-2020 - |
Question
I have worked custom payment and I've received the response from the payment I need to load the success page from my custom controller how can i do it. Whether I need to create own page or can I use core function to load success page in my custom controller is that possible please help me
public function execute()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\Order') ->loadByIncrementId($orderId);
$orderState = Order::STATE_PROCESSING;
$order->setState($orderState)->setStatus(Order::STATE_PROCESSING);
$order->save();
}
La solution
Add following code to your contoller after checking you've recieved response.
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('checkout/onepage/successs');
return $resultRedirect;
Note that you can directly use resultRedirectFactory, you don't need to inject it.
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange