Jump to content

Cannot get _Post parameters On Prestashop module Controller


Recommended Posts

I am new to Prestashop and I am trying to build a payment gateway module.
It all works fine until I try and get the parameters for the return URL. For some reason the post parameters always comeback as blank or none as existent. I have tried checking on the browser debugger to see if it was actually sending something and all the required data is there.
 
Here is the code:


post-1442345-0-80157300-1505911987_thumb.png

 

Here is the output:
post-1442345-0-85381200-1505911415_thumb.png
 
This is the return URL:
..."index.php?fc=module&module=cashu&controller=fail"

 

PS: I am running on a Local Host.

Edited by _theLion (see edit history)
Link to comment
Share on other sites

Try using php filter_input and see if it's working instead of Tools::getValue
 

$errorCode = filter_input(INPUT_POST, 'errorCode');

based on Tools:getValue method from their source code:

public static function getValue($key, $default_value = false)

{
if (!isset($key) || empty($key) || !is_string($key)) {
return false;
}
if (getenv('kernel.environment') === 'test' && self::$request instanceof Request) {
$value = self::$request->request->get($key, self::$request->query->get($key, $default_value));
} else {
$value = (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $default_value));
}
if (is_string($value)) {
return stripslashes(urldecode(preg_replace('/((\%5C0+)|(\%00+))/i', '', urlencode($value))));
}
return $value;
}

try to debug your module and see where what is not reading the parameter.. maybe has something to do with $_POST[$key]

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...