diff --git a/src/Bridge/OpenPayUBridge.php b/src/Bridge/OpenPayUBridge.php index 3d6da13..341643c 100644 --- a/src/Bridge/OpenPayUBridge.php +++ b/src/Bridge/OpenPayUBridge.php @@ -12,12 +12,21 @@ namespace BitBag\SyliusPayUPlugin\Bridge; +use OauthCacheFile; use OpenPayU_Configuration; use OpenPayU_Order; use OpenPayU_Result; final class OpenPayUBridge implements OpenPayUBridgeInterface { + /*** @var string|null */ + private $cacheDir; + + public function __construct(string $cacheDir = null) + { + $this->cacheDir = $cacheDir; + } + public function setAuthorizationData( string $environment, string $signatureKey, @@ -34,6 +43,8 @@ public function setAuthorizationData( //set Oauth Client Id and Oauth Client Secret (from merchant admin panel) OpenPayU_Configuration::setOauthClientId($clientId); OpenPayU_Configuration::setOauthClientSecret($clientSecret); + + OpenPayU_Configuration::setOauthTokenCache(new OauthCacheFile($this->cacheDir)); } public function create(array $order): ?OpenPayU_Result diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index ea24ed8..83d409f 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -4,6 +4,10 @@ + + %kernel.project_dir%/var/cache/%env(APP_ENV)% + + diff --git a/src/Resources/config/services/bridge.xml b/src/Resources/config/services/bridge.xml index 1522a74..02607fb 100644 --- a/src/Resources/config/services/bridge.xml +++ b/src/Resources/config/services/bridge.xml @@ -4,6 +4,8 @@ - + + %bitbag_open_payu_cache_dir% +