From 6ad7752871cb446c46ade72987914ad7d118caab Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 4 Nov 2024 13:22:33 +0100 Subject: [PATCH 1/7] Add missing ^6.0 supported versions for Symfony UID component --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ff7c68a..0d430bd4 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "symfony/http-foundation": "5.4.* || ^6.0", "symfony/http-kernel": "5.4.* || ^6.0", "symfony/routing": "5.4.* || ^6.0", - "symfony/uid": "5.4.*", + "symfony/uid": "5.4.* || ^6.0", "tpay-com/tpay-openapi-php": "^1.8" }, "conflict": { From 46db7af8e0540dc3a579c6a9f3757d68dce86f1a Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 4 Nov 2024 17:45:52 +0100 Subject: [PATCH 2/7] Remove dependency to the App namespace --- src/Tpay/Provider/ValidTpayChannelListProvider.php | 2 +- tests/Unit/Tpay/Provider/ValidTpayChannelListProviderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tpay/Provider/ValidTpayChannelListProvider.php b/src/Tpay/Provider/ValidTpayChannelListProvider.php index b5ea46ee..6d6d050f 100644 --- a/src/Tpay/Provider/ValidTpayChannelListProvider.php +++ b/src/Tpay/Provider/ValidTpayChannelListProvider.php @@ -4,7 +4,6 @@ namespace CommerceWeavers\SyliusTpayPlugin\Tpay\Provider; -use App\Repository\PaymentMethodRepositoryInterface; use CommerceWeavers\SyliusTpayPlugin\Payum\Exception\UnableToGetBankListException; use CommerceWeavers\SyliusTpayPlugin\Tpay\PayGroup; use CommerceWeavers\SyliusTpayPlugin\Tpay\PaymentType; @@ -13,6 +12,7 @@ use Sylius\Bundle\PayumBundle\Model\GatewayConfigInterface; use Sylius\Component\Channel\Context\ChannelContextInterface; use Sylius\Component\Core\Model\PaymentMethodInterface; +use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface; use Webmozart\Assert\Assert; final class ValidTpayChannelListProvider implements ValidTpayChannelListProviderInterface diff --git a/tests/Unit/Tpay/Provider/ValidTpayChannelListProviderTest.php b/tests/Unit/Tpay/Provider/ValidTpayChannelListProviderTest.php index 744af090..036f072e 100644 --- a/tests/Unit/Tpay/Provider/ValidTpayChannelListProviderTest.php +++ b/tests/Unit/Tpay/Provider/ValidTpayChannelListProviderTest.php @@ -4,8 +4,8 @@ namespace Tests\CommerceWeavers\SyliusTpayPlugin\Unit\Tpay\Provider; -use App\Repository\PaymentMethodRepositoryInterface; use CommerceWeavers\SyliusTpayPlugin\Payum\Exception\UnableToGetBankListException; +use CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodRepositoryInterface; use CommerceWeavers\SyliusTpayPlugin\Tpay\Provider\AvailableTpayChannelListProviderInterface; use CommerceWeavers\SyliusTpayPlugin\Tpay\Provider\ValidTpayChannelListProvider; use Payum\Core\Security\CypherInterface; From 19a52876b3ef5a096cacd608e342229c941f944f Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 4 Nov 2024 18:16:00 +0100 Subject: [PATCH 3/7] Fix extending PaymentMethodRepository --- ...FindByChannelWithGatewayConfigTraitInterface.php | 13 ------------- .../Repository/PaymentMethodRepositoryInterface.php | 4 +++- ...atewayConfigTrait.php => PaymentMethodTrait.php} | 2 +- .../src/Repository/PaymentMethodRepository.php | 5 +++-- 4 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 src/Repository/FindByChannelWithGatewayConfigTraitInterface.php rename {tests/Application/src => src}/Repository/PaymentMethodRepositoryInterface.php (83%) rename src/Repository/{FindByChannelWithGatewayConfigTrait.php => PaymentMethodTrait.php} (95%) diff --git a/src/Repository/FindByChannelWithGatewayConfigTraitInterface.php b/src/Repository/FindByChannelWithGatewayConfigTraitInterface.php deleted file mode 100644 index 7ca1f239..00000000 --- a/src/Repository/FindByChannelWithGatewayConfigTraitInterface.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Mon, 4 Nov 2024 18:22:11 +0100 Subject: [PATCH 4/7] Remove Tpay logger setup --- src/Payum/Action/Api/BaseApiAwareAction.php | 1 - tests/Application/public/index.php | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Payum/Action/Api/BaseApiAwareAction.php b/src/Payum/Action/Api/BaseApiAwareAction.php index 5d54aa3e..3ae72209 100644 --- a/src/Payum/Action/Api/BaseApiAwareAction.php +++ b/src/Payum/Action/Api/BaseApiAwareAction.php @@ -21,7 +21,6 @@ abstract class BaseApiAwareAction implements ActionInterface, ApiAwareInterface public function __construct() { $this->apiClass = TpayApi::class; - Logger::setLogPath(dirname(__DIR__, 4) . '/tests/Application/var/log/'); } protected function do(callable $func, callable $onSuccess, callable $onFailure): void diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 9bcfadc6..5adff0e7 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -3,6 +3,7 @@ declare(strict_types=1); use App\Kernel; +use Tpay\OpenApi\Utilities\Logger; $_SERVER['APP_RUNTIME_OPTIONS'] = [ 'project_dir' => dirname(__DIR__), @@ -11,5 +12,10 @@ require_once dirname(__DIR__, 3).'/vendor/autoload_runtime.php'; return function (array $context) { - return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); + + // set up Tpay logger + Logger::setLogPath(sprintf('%s/tpay_open_api_', $kernel->getLogDir())); + + return $kernel; }; From 81bcd17102554ebe0e07be9fed25e9d88026eac7 Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 4 Nov 2024 18:35:41 +0100 Subject: [PATCH 5/7] Set up Tpay logger in DI extension --- .../CommerceWeaversSyliusTpayExtension.php | 9 +++++++++ tests/Application/public/index.php | 8 +------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php b/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php index fd3dc611..16b3b97a 100644 --- a/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php +++ b/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php @@ -11,6 +11,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; +use Tpay\OpenApi\Utilities\Logger; final class CommerceWeaversSyliusTpayExtension extends AbstractResourceExtension implements PrependExtensionInterface { @@ -43,6 +44,7 @@ public function prepend(ContainerBuilder $container): void $container, ); + $this->setUpTpayLogger($container); $this->prependDoctrineMigrations($container); $this->prependDoctrineMapping($container); } @@ -105,4 +107,11 @@ private function getCurrentConfiguration(ContainerBuilder $container): array return $this->processConfiguration($configuration, $configs); } + + private function setUpTpayLogger(ContainerBuilder $container): void + { + if ($container->hasParameter('kernel.logs_dir')) { + Logger::setLogPath(sprintf('%s/tpay_open_api_', $container->getParameter('kernel.logs_dir'))); + } + } } diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 5adff0e7..9bcfadc6 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -3,7 +3,6 @@ declare(strict_types=1); use App\Kernel; -use Tpay\OpenApi\Utilities\Logger; $_SERVER['APP_RUNTIME_OPTIONS'] = [ 'project_dir' => dirname(__DIR__), @@ -12,10 +11,5 @@ require_once dirname(__DIR__, 3).'/vendor/autoload_runtime.php'; return function (array $context) { - $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); - - // set up Tpay logger - Logger::setLogPath(sprintf('%s/tpay_open_api_', $kernel->getLogDir())); - - return $kernel; + return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); }; From 048ae1c632a2a8a07112bd7d9ef008ca16639612 Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 4 Nov 2024 18:41:14 +0100 Subject: [PATCH 6/7] Require Sylius Refund Plugin in composer dependecies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0d430bd4..8d8779df 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "firebase/php-jwt": "^6.10", "payum/core": "^1.7", "sylius/core-bundle": "^1.12", + "sylius/refund-plugin": "^1.5", "sylius/resource-bundle": "^1.10", "symfony/config": "5.4.* || ^6.0", "symfony/dependency-injection": "5.4.* || ^6.0", @@ -50,7 +51,6 @@ "polishsymfonycommunity/symfony-mocker-container": "^1.0", "shipmonk/composer-dependency-analyser": "^1.7", "sylius-labs/coding-standard": "^4.2", - "sylius/refund-plugin": "^1.5", "sylius/sylius": "^1.12", "symfony/browser-kit": "^5.4 || ^6.0", "symfony/debug-bundle": "^5.4 || ^6.0", From 58ac9c5611dfe220d3281f8fe43789eedc297ebd Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 4 Nov 2024 19:54:46 +0100 Subject: [PATCH 7/7] Fix static analysys --- .../CommerceWeaversSyliusTpayExtension.php | 12 ++++++++++-- src/Payum/Action/Api/BaseApiAwareAction.php | 1 - src/Tpay/Provider/ValidTpayChannelListProvider.php | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php b/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php index 16b3b97a..ea1a7da1 100644 --- a/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php +++ b/src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php @@ -110,8 +110,16 @@ private function getCurrentConfiguration(ContainerBuilder $container): array private function setUpTpayLogger(ContainerBuilder $container): void { - if ($container->hasParameter('kernel.logs_dir')) { - Logger::setLogPath(sprintf('%s/tpay_open_api_', $container->getParameter('kernel.logs_dir'))); + if (!$container->hasParameter('kernel.logs_dir')) { + return; + } + + $logsDir = $container->getParameter('kernel.logs_dir'); + + if (!is_string($logsDir)) { + return; } + + Logger::setLogPath(sprintf('%s/tpay_open_api_', $logsDir)); } } diff --git a/src/Payum/Action/Api/BaseApiAwareAction.php b/src/Payum/Action/Api/BaseApiAwareAction.php index 3ae72209..b77fe6b8 100644 --- a/src/Payum/Action/Api/BaseApiAwareAction.php +++ b/src/Payum/Action/Api/BaseApiAwareAction.php @@ -8,7 +8,6 @@ use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; use Payum\Core\ApiAwareTrait; -use Tpay\OpenApi\Utilities\Logger; use Tpay\OpenApi\Utilities\TpayException; /** diff --git a/src/Tpay/Provider/ValidTpayChannelListProvider.php b/src/Tpay/Provider/ValidTpayChannelListProvider.php index 6d6d050f..652e7f57 100644 --- a/src/Tpay/Provider/ValidTpayChannelListProvider.php +++ b/src/Tpay/Provider/ValidTpayChannelListProvider.php @@ -5,6 +5,7 @@ namespace CommerceWeavers\SyliusTpayPlugin\Tpay\Provider; use CommerceWeavers\SyliusTpayPlugin\Payum\Exception\UnableToGetBankListException; +use CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodRepositoryInterface; use CommerceWeavers\SyliusTpayPlugin\Tpay\PayGroup; use CommerceWeavers\SyliusTpayPlugin\Tpay\PaymentType; use Payum\Core\Security\CryptedInterface; @@ -12,11 +13,14 @@ use Sylius\Bundle\PayumBundle\Model\GatewayConfigInterface; use Sylius\Component\Channel\Context\ChannelContextInterface; use Sylius\Component\Core\Model\PaymentMethodInterface; -use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface; +use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface as BasePaymentMethodRepositoryInterface; use Webmozart\Assert\Assert; final class ValidTpayChannelListProvider implements ValidTpayChannelListProviderInterface { + /** + * @param BasePaymentMethodRepositoryInterface&PaymentMethodRepositoryInterface $paymentMethodRepository + */ public function __construct( private readonly AvailableTpayChannelListProviderInterface $availableTpayApiBankListProvider, private readonly PaymentMethodRepositoryInterface $paymentMethodRepository,