Skip to content

Commit

Permalink
Merge pull request #32 from TymekB/feature/custom-cache-path
Browse files Browse the repository at this point in the history
Add custom cache directory
  • Loading branch information
patrick477 authored Jul 27, 2021
2 parents f9704ef + 5120d20 commit e9e5682
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Bridge/OpenPayUBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<import resource="services/**/*.xml"/>
</imports>

<parameters>
<parameter key="bitbag_open_payu_cache_dir">%kernel.project_dir%/var/cache/%env(APP_ENV)%</parameter>
</parameters>

<services>
<defaults public="false" autoconfigure="false" autowire="false"/>

Expand Down
4 changes: 3 additions & 1 deletion src/Resources/config/services/bridge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<defaults public="true" autoconfigure="false" autowire="false"/>

<service id="bitbag.payu_plugin.bridge.open_payu" class="BitBag\SyliusPayUPlugin\Bridge\OpenPayUBridge"/>
<service id="bitbag.payu_plugin.bridge.open_payu" class="BitBag\SyliusPayUPlugin\Bridge\OpenPayUBridge">
<argument>%bitbag_open_payu_cache_dir%</argument>
</service>
</services>
</container>

0 comments on commit e9e5682

Please sign in to comment.