-
Notifications
You must be signed in to change notification settings - Fork 47
Wrong HMAC calculation when using multiple forms #84
Description
Hi,
I found a small issue when I tried to generate several forms for one page (one form per payment type), the field PBX_HMAC is not regenerated for each form.
It seems that once the service has been called and a form generated, this parameter is set for the execution lifetime, due to this if condition in Lexik\Bundle\PayboxBundle\Paybox\System\Base\Request (line 129-133) :
/**
* Returns all parameters set for a payment.
*
* @return array
*/
public function getParameters()
{
// This condition prevent the generation of a new PBX_HMAC
if (null === $this->getParameter('PBX_HMAC')) {
$this->setParameter('PBX_TIME', date('c'));
$this->setParameter('PBX_HMAC', strtoupper($this->computeHmac()));
}
$resolver = new ParameterResolver($this->globals['currencies']);
return $resolver->resolve($this->parameters);
}To overcome this, I extended this class in my app by adding this parameter
parameters:
lexik_paybox.request_handler.class: 'Path\To\Custom\Request'And commented the condition like this :
/**
* Returns all parameters set for a payment.
*
* @return array
*/
public function getParameters()
{
//if (null === $this->getParameter('PBX_HMAC')) {
$this->setParameter('PBX_TIME', date('c'));
$this->setParameter('PBX_HMAC', strtoupper($this->computeHmac()));
//}
$resolver = new ParameterResolver($this->globals['currencies']);
return $resolver->resolve($this->parameters);
}It works well :)
Btw, I also had to extend \Lexik\Bundle\PayboxBundle\Paybox\System\Base\ParameterResolver for another reason, the value "ANCV" was not allowed in the PBX_TYPECARTE options, since the ParameterResolver is manually instanciated in Request::getParameters().
Yondz