Magento – How to send post data with redirect from magento 2 for a payment gateway

magento2paymentpayment-methodspost-dataredirect

we use magento2/app/code/Paymentgateway/Example/Controller/Standard/Redirect.php

public function execute()
{
    $order = $this->getOrder();
    if ($order->getBillingAddress())
    {
        $this->getResponse()->setRedirect(
            $this->getExampleModel()->buildExampleRequest($order)
        );
    } 

Any suggestions??

Best Answer

Create a custom hidden from this submit and using window.load function submit form.

  • Create a form with required fields and value to payment gateway.
  • Make all fields as hidden type
  • Then make this form action url to your pg
  • And using window.load submit this form
Related Topic