PayU-EMEA / openpayu_php

OpenPayu SDK
http://developers.payu.com
Apache License 2.0
187 stars 86 forks source link

OauthCacheFile constructor doesn't work #98

Open thomas2411 opened 6 years ago

thomas2411 commented 6 years ago

I try to set file Cache for OAuth like this: OpenPayU_Configuration::setOauthTokenCache(new OauthCacheFile('/home/user/domains/mydomain.com/public_html/var/payu_cache'));

But I got error like this:

Cache directory [/home/user/domains/mydomain.com/public_html/vendor/openpayu/openpayu
/lib/OpenPayU/Oauth/Cache/../../../Cache] not exist or not writable 

So it seems like the code doesn't take $directory into account.

See the code of OauthCacheFile :

public function __construct($directory = null)
    {
        //1
        if ($directory === null) {
            $directory = dirname(__FILE__).'/../../../Cache';
        }
        //2
        if (!is_dir($directory) || !is_writable($directory)) {
            //3
            throw new OpenPayU_Exception_Configuration('Cache directory [' . $directory . '] not exist or not writable.');
        }

        $this->directory = $directory . (substr($directory, -1) != '/' ? '/' : '');
    }

I have echoed $directory and in: 1 it is OK, 2 it is OK, 3 it is OK

and then OpenPayU_Exception_Configuration throws error like this:

Cache directory [/home/user/domains/mydomain.com/public_html/vendor/openpayu/openpayu /lib/OpenPayU/Oauth/Cache/../../../Cache] not exist or not writable

Why this is not working? How on earth OpenPayU_Exception_Configuration takes default $directory as a parameter of the error message instead of the one passed as constructor parameter?

matisiekpl commented 2 years ago

Any updates?