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

Add an exception if Omnikassa is unavailable #21

Open
GErpeldinger opened this issue Dec 8, 2022 · 0 comments
Open

Add an exception if Omnikassa is unavailable #21

GErpeldinger opened this issue Dec 8, 2022 · 0 comments

Comments

@GErpeldinger
Copy link

GErpeldinger commented Dec 8, 2022

Hello,

We use omnikassa in our application, and sometimes the sandbox environment is unavailable, the problem is that the error that is send when the service is unavaible doesn't speak for itself. We hava a Warning: Trying to access array offset on value of type null send from the class AccessToken line 48.

Maybe a fix can be to see if the access token contain an error message before creating the access token from the json in the method retrieveNewToken in the class ApiConnector like this:

    /**
     * @return AccessToken
     */
    private function retrieveNewToken()
    {
        $refreshToken = $this->tokenProvider->getRefreshToken();

        $this->restTemplate->setToken($refreshToken);
        $accessTokenJson = $this->restTemplate->get('gatekeeper/refresh');

        if (str_contains($accessTokenJson, 'Tijdelijk niet beschikbaar')) {
            throw new \HttpException('OmniKassa is temporarily unavailable', 503);
        }

        return AccessToken::fromJson($accessTokenJson);
    }

What do you think?

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