0

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();
}
2

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.

  • This one redirect to shopping cart page because there is no quote id do you any idea to load quote? – Jeeva Chezhiyan Nov 16 '17 at 8:55
  • As the order has been completed on users end and the items in cart are destroyed , i don't think you would be able to access it directly, but you can store quote id beforehand in session so you can directly load the quote object if you require it. – Vivek Kumar Nov 16 '17 at 9:05
  • Also please accept the answer if it solved your original question – Vivek Kumar Nov 16 '17 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.