cancel
Showing results for 
Search instead for 
Did you mean: 

External URL post redirect without intermediate page (white page) in Magento 1.9.x

Highlighted

External URL post redirect without intermediate page (white page) in Magento 1.9.x

Is there any possibility from the shop-system to perform a post redirection while clicking on the 'Place Order' button? We have tried posting the form data using the function getOrderPlaceRedirectUrl and there is an intermediate page (a blank page). Is it possible to eliminate such a page and perform a redirection (to the third-party site) while posting the values from the shop?

 

As an additional info, in the function getOrderPlaceRedirectUrl, we are using the internal controller URL with custom block like what have been followed with the PayPal Standard Payment.

3 REPLIES 3
Highlighted

Re: External URL post redirect without intermediate page (white page) in Magento 1.9.x

Hi @prakashkpv,

Yes. You can do by using observer event sales_place_order_after. In that observer you can post the data & submit the form with action url.


Issue solved? give kudos & accept as solution

Best regards
Madhuresan
Bootsgrid

Highlighted

Re: External URL post redirect without intermediate page (white page) in Magento 1.9.x

Hi Madhuresan,

 

Thanks for your suggestion. Could you please confirm the event (checkout_submit_all_after) and if possible give some examples how to handle in observer (perform a redirection while submitting the post values)?

 

Regards,

Prakash K

Highlighted

Re: External URL post redirect without intermediate page (white page) in Magento 1.9.x

Hi @prakashkpv,
Redirecting an HTTP POST request is heavily discouraged and proper support for it is spotty, at best. To accomplish what seems to be your end goal, there are a few ways to implement this type of functionality, some better than others. If you're only interested in redirecting customers on the frontend, it might make more sense to use a controller event, specifically checkout_onepage_controller_success_action. Take a look at this answer on Magento StackExchange, which you can use as a template to get started.

In the observer method, you will essentially proxy the POST request. This can be accomplished with Zend\Http\Request and Zend\Http\Client. Take a look at this guide to see some basic examples. Once you've received the response, you can set the redirect URL.

  use Magento\Framework\App\ActionInterface;
  use Magento\Framework\Controller\ResultFactory;

  class YourClass implements ActionInterface
  {
    const REDIRECT_URL = 'https://example.com/index.html';

    protected $resultRedirect;

    public function __construct(\Magento\Framework\Controller\ResultFactory $result)
    {
      $this->resultRedirect = $result;
    }

    public function execute()
    {
      $resultRedirect = $this->resultRedirect->create(ResultFactory::TYPE_REDIRECT);
      $resultRedirect->setUrl(self::REDIRECT_URL);

      return $resultRedirect;
    }
  }