ssheduardo / sermepa

Clase para utilizar la pasarela de pagos redsys, sermepa.
MIT License
191 stars 59 forks source link

PHP8 - Error @tpv.php - line 774 // required parameters after optional parameters #72

Closed kornerson closed 3 years ago

kornerson commented 3 years ago

In the function

public function check($key='', $postData)

you get an error when trying to run the code on Php8.

To fix this, just rewrite the function like this:

public function check(string $key, $postData)
    {
        if (!isset($postData)) {
            throw new TpvException("Add data return of bank");
        }

        $parameters = $postData["Ds_MerchantParameters"];
        $signatureReceived = $postData["Ds_Signature"];
        $signature = $this->generateMerchantSignatureNotification($key==null?"":$key, $parameters);

        return ($signature === $signatureReceived);
    }

Would be better to have the key at the end, but I have no time to get deeper into the code to check where this is called.

Take this as a quick fix until is patched in the source code.

ssheduardo commented 3 years ago

Fixed to PHP 8.0