Skip to content

Commit

Permalink
Use new clientName identification mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
s4ddly committed Jun 26, 2024
1 parent 2e41e2c commit 2cb5953
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.dev-tools/vendor/
/.dev-tools/.php-cs-fixer.cache
.idea/
vendor
composer.lock
3 changes: 1 addition & 2 deletions Model/ApiFacade/CardTransaction/CardOpen.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function __construct(TpayInterface $tpay, TpayConfigInterface $tpayConfig
$this->tpayConfig = $tpayConfig;
$this->tokensService = $tokensService;
$this->tpayService = $tpayService;
$this->tpayApi = new TpayApi($tpayConfig->getOpenApiClientId(), $tpayConfig->getOpenApiPassword(), !$tpayConfig->useSandboxMode());
$this->tpayApi->transactions()->setClientName($tpayConfig->buildMagentoInfo());
$this->tpayApi = new TpayApi($tpayConfig->getOpenApiClientId(), $tpayConfig->getOpenApiPassword(), !$tpayConfig->useSandboxMode(), 'read', null, $tpayConfig->buildMagentoInfo());

Check failure on line 37 in Model/ApiFacade/CardTransaction/CardOpen.php

View workflow job for this annotation

GitHub Actions / analyse

Class tpaySDK\Api\TpayApi constructor invoked with 6 parameters, 2-4 required.

Check failure on line 37 in Model/ApiFacade/CardTransaction/CardOpen.php

View workflow job for this annotation

GitHub Actions / analyse

Class tpaySDK\Api\TpayApi constructor invoked with 6 parameters, 2-4 required.
}

public function makeFullCardTransactionProcess(string $orderId, ?array $customerToken = null): string
Expand Down
5 changes: 3 additions & 2 deletions Model/ApiFacade/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ class OpenApi
public function __construct(TpayConfigInterface $tpay, CacheInterface $cache)
{
$this->cache = $cache;
$this->tpayApi = new TpayApi($tpay->getOpenApiClientId(), $tpay->getOpenApiPassword(), !$tpay->useSandboxMode());
$this->tpayApi = new TpayApi($tpay->getOpenApiClientId(), $tpay->getOpenApiPassword(), !$tpay->useSandboxMode(), 'read', null, $tpay->buildMagentoInfo());

Check failure on line 23 in Model/ApiFacade/OpenApi.php

View workflow job for this annotation

GitHub Actions / analyse

Class tpaySDK\Api\TpayApi constructor invoked with 6 parameters, 2-4 required.

Check failure on line 23 in Model/ApiFacade/OpenApi.php

View workflow job for this annotation

GitHub Actions / analyse

Class tpaySDK\Api\TpayApi constructor invoked with 6 parameters, 2-4 required.
$token = $this->cache->load($this->getAuthTokenCacheKey($tpay));

if ($token) {
$this->tpayApi->setCustomToken(unserialize($token));
}
$this->tpayApi->transactions()->setClientName($tpay->buildMagentoInfo());

if (!$token) {
$this->cache->save(serialize($this->tpayApi->getToken()), $this->getAuthTokenCacheKey($tpay));
}
Expand Down
34 changes: 8 additions & 26 deletions Provider/ConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Tpay\Magento2\Provider;

use Composer\InstalledVersions;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Locale\Resolver;
Expand Down Expand Up @@ -210,17 +211,13 @@ public function getMagentoVersion(): string

public function buildMagentoInfo(): string
{
$versions = $this->getPackagesVersions();

return implode(
'|',
[
'magento2:'.$this->getMagentoVersion(),
'tpay-com/tpay-openapi-php:'.$versions[0],
'tpay-com/tpay-php:'.$versions[1],
'magento2basic:'.$this->getTpayPluginVersion(),
'PHP:'.phpversion(),
]
return sprintf(
'magento2:%s|tpay-openapi-php:%s|tpay-php:%s|magento2basic:%s|PHP:%s',
$this->getMagentoVersion(),
InstalledVersions::getPrettyVersion('tpay-com/tpay-openapi-php'),
InstalledVersions::getPrettyVersion('tpay-com/tpay-php'),
$this->getTpayPluginVersion(),
phpversion()
);
}

Expand All @@ -238,21 +235,6 @@ public function isPlnPayment(): bool
return 'PLN' == $this->storeManager->getStore()->getBaseCurrencyCode() && 'PLN' == $this->storeManager->getStore()->getCurrentCurrencyCode();
}

private function getPackagesVersions(): array
{
$dir = __DIR__.'/../composer.json';
if (file_exists($dir)) {
$composerJson = json_decode(
file_get_contents(__DIR__.'/../composer.json'),
true
)['require'] ?? [];

return [$composerJson['tpay-com/tpay-openapi-php'], $composerJson['tpay-com/tpay-php']];
}

return ['n/a', 'n/a'];
}

private function getTpayPluginVersion(): string
{
$dir = __DIR__.'/../.version';
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": ">=7.1",
"ext-json": "*",
"magento/framework": "^102.0 || ^103.0",
"tpay-com/tpay-openapi-php": "^1.7.1",
"tpay-com/tpay-openapi-php": "^1.8.0",
"tpay-com/tpay-php": "^2.4.7"
},
"autoload": {
Expand Down

0 comments on commit 2cb5953

Please sign in to comment.