Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EcommercePaymentResponse -- Double encoded url #66

Open
GlenCarlier opened this issue Sep 29, 2016 · 0 comments
Open

EcommercePaymentResponse -- Double encoded url #66

GlenCarlier opened this issue Sep 29, 2016 · 0 comments

Comments

@GlenCarlier
Copy link

GlenCarlier commented Sep 29, 2016

For a while I've had the trouble of EcommercePaymentResponse objects not being valid using:
if($ecommercePaymentResponse->isValid($shaComposer) && $ecommercePaymentResponse->isSuccessful())

The problem here was that the redirect url (that I get from Ogone was double encoded).
Ex.
dot was '%252E' instead of '%2E'

This resulted in the $shaString being incorrect so it wouldnt be the same as the shaSign I got with the request (and thus isValid resulting in false).

It might have been a misconfiguration of Ogone on my part but for now I fixed it by urldecoding all the values from the request before creating the EcommercePaymentResponse.

A quick fix might be to do the following:
AllParametersShaComposer.php

public function compose(array $parameters)
    {
        foreach($this->parameterFilters as $parameterFilter) {
            $parameters = $parameterFilter->filter($parameters);
        }

        ksort($parameters);

        // compose SHA string
        $shaString = '';
        foreach($parameters as $key => $value) {
            $shaString .= $key . '=' . urldecode($value) . $this->passphrase;
        }

        return strtoupper(hash($this->hashAlgorithm, $shaString));
    }

instead of

public function compose(array $parameters)
    {
        foreach($this->parameterFilters as $parameterFilter) {
            $parameters = $parameterFilter->filter($parameters);
        }

        ksort($parameters);

        // compose SHA string
        $shaString = '';
        foreach($parameters as $key => $value) {
            $shaString .= $key . '=' . $value . $this->passphrase;
        }

        return strtoupper(hash($this->hashAlgorithm, $shaString));
    }

I don't know what the implication of this "fix" are, just wanted to give you guys an update on this particular problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant