Redirect with POST and parameters in a controller I want to redirect to a url (Sermepa/Redsys) with POST and some form parameters in a Controller. The process is I submit a form that collect some data, and when the user submit this form, it redirect to my controller. In this controller I prepare the post data and then I want to redirect to bank gateway with POST.
&lt;?php

namespace Drupal\mymodule_sermepa_redsys\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\mymodule_sermepa_redsys\RedsysAPI;
use Drupal\node\NodeInterface;

/**
 * Class DoPaymentController.
 */
class DoPaymentController extends ControllerBase {

  public function doPayment(NodeInterface $node = null) {

    if ($node!==null) {
    
      $redsys = new RedsysAPI();
      $config = \Drupal::config('sermepa_redsys.settings');      

      // Completamos los datos para la petición
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_AMOUNT&quot;, $config-&gt;get('ammount'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_ORDER&quot;, $node-&gt;id());
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_MERCHANTCODE&quot;, $config-&gt;get('merchant_code'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_CURRENCY&quot;, $config-&gt;get('currency'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_TRANSACTIONTYPE&quot;, $config-&gt;get('transaction_type'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_TERMINAL&quot;, $config-&gt;get('terminal'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_MERCHANTURL&quot;, $config-&gt;get('url'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_URLOK&quot;, $config-&gt;get('merchant_url_ok'));
      $redsys-&gt;setParameter(&quot;DS_MERCHANT_URLKO&quot;, $config-&gt;get('merchant_url_ko'));

      $version= $config-&gt;get('version');
      $kc = $config-&gt;get('merchant_password');
      
      $params = $redsys-&gt;createMerchantParameters();
      $signature = $redsys-&gt;createMerchantSignature($kc);
      
      $post_data['Ds_SignatureVersion'] = $version;
      $post_data['Ds_MerchantParameters'] = $params;
      $post_data['Ds_Signature'] = $signature;
      
      $client = \Drupal::httpClient();          
      $response = $client-&gt;request('POST', $config-&gt;get('url_webservice'), ['form_params' =&gt; $post_data]);
      return $response;
      
    }
    else {
      return [
        '#markup' =&gt; t('Error. No nid'),
      ];
    }
  }
}

What I expected is after sumbit the form, controller was called, and then the user was redirected to bank payment page.
The form is a &quot;create node&quot; of a custom content type. In my .module file I have added a custom submit:
function mymodule_form_node_mycustomtype_form_alter(&amp;$form, FormStateInterface &amp;$form_state) {  
...
$form['actions']['submit']['#submit'][]  = '_mycustom_form_submit';
}

function _mycustom_form_submit(array &amp;$form, FormStateInterface $form_state) {
    $url = Url::fromRoute('mymodule_sermepa_redsys.payment_controller_doPayment');
    $url-&gt;setRouteParameters(array('node' =&gt; $form_state-&gt;getValue('nid')));
    $form_state-&gt;setRedirectUrl($url); 
}

My routing file:
mymodule_sermepa_redsys.payment_controller_doPayment:
  path: '/doPayment/{node}'
  defaults:
    _controller: '\Drupal\mymodule_sermepa_redsys\Controller\DoPaymentController::doPayment'
    _title: 'Do Payment'
  requirements:
    _permission: 'access content'

Note: The class RedsysAPI is a helper class to prepare the data to POST, but It's irrelevant in the context of this question.
You can't redirect with Post properties. You can only do a request, which you've done. The $response you've created in the controller will contain the results of your HTTP request to the remote service. You'll have to retrieve the the relevant data from that object, and do something with it. You are currently returning that from your function. $response is a Psr\Http\Message\ResponseInterface object. If you just return this, your controller will not know what to do with it.