wl-online-payments-direct / sdk-php

Other
5 stars 5 forks source link

Wrong getErrors() method on ResponseExpeption #2

Closed ferran-romero closed 2 years ago

ferran-romero commented 2 years ago

Hi all,

I'm not sure if this is the best place to post this, but I'm just starting to use your library to integrate this payment system into our existing projects, and I think I found a bug into the method mentioned before.

Ok, so here's what this method looks like currently:

    /**
     * @return APIError[]
     */
    public function getErrors()
    {
        $responseVariables = (array)$this->getResponse()->toObject();
        if (!array_key_exists('errors', $responseVariables)) {
            return array();
        }
        $errors = $responseVariables['errors'];
        if (!is_array($errors)) {
            return array();
        }
        foreach ($errors as $error) {
            if (!($error instanceof APIError)) {
                return array();
            }
        }
        return $errors;
    }

The problem here is each of the $error contained in $errors is not an instante of APIError, but an instance of stdClass instead. Maybe the attached screenshot could help.

Please, feel free to ask if you need it.

Regards. Captura de pantalla 2022-06-09 a las 16 50 25

worldline-direct-support-team commented 2 years ago

Hello Ferran,

Thanks for the notice! We'll investigate this and get back to you soon.

Kind regards, Worldline support team

worldline-direct-support-team commented 2 years ago

Hi @ferran-romero,

It looks like we didn't get back to you yet. This issue has been fixed in version 4.0.0. Please let us know if you experience any other issues.

Kind regards, Worldline Direct Support Team