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

GeneralParameterFilter, array_walk -> trim #60

Open
gavro opened this issue Mar 16, 2016 · 1 comment
Open

GeneralParameterFilter, array_walk -> trim #60

gavro opened this issue Mar 16, 2016 · 1 comment

Comments

@gavro
Copy link

gavro commented Mar 16, 2016

Is this extra array_walk doing anything to the values? https://github.com/marlon-be/marlon-ogone/blob/master/lib/Ogone/ParameterFilter/GeneralParameterFilter.php#L19

As far as I can tell it's not changing any of the values as the trimmed values are not saved in the original values by trim().

Note: If you decide to fix this with a proper callback so that original values get changed, be careful to only trim values which are of type "string". Trimming int/float results in string and Ogone will fail when, for example, "AMOUNT" is a string.

Something like:

    public function filter(array $parameters)
    {
        $parameters = array_change_key_case($parameters, CASE_UPPER);

        array_walk($parameters, function (&$value) {
            $value = is_string($value) ? trim($value) : $value;
        });

        $parameters = array_filter($parameters, function ($value) {
            return (bool) strlen($value);
        });

        return $parameters;
    }
@gavro
Copy link
Author

gavro commented Mar 16, 2016

Note: If you are using the toArray() function (from AbstractRequest) to create your form, the returned parameters will not be trimmed, which will result in an incorrectly signed payment.

So I guess this trim function should just be removed, or the toArray() function should trim the values as well.

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