From 0b9907867fec90e364ab1d2923d3539848793220 Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 22 Jul 2024 11:30:38 +0200 Subject: [PATCH 01/12] OP-366 - Add support for Sylius 1.13, drop support for Sylius 1.11 --- composer.json | 14 +- src/Client/ImojeApiClient.php | 66 +++++++--- .../ImojeClientConfigurationProvider.php | 3 +- src/Provider/ImojeClientProvider.php | 21 ++- src/Resources/config/services/providers.xml | 2 + .../Application/config/packages/security.yaml | 124 ------------------ .../config/packages/test/mailer.yaml | 7 + .../config/sylius/1.11/bundles.php | 8 -- .../1.11/packages/dev/jms_serializer.yaml | 12 -- .../sylius/1.11/packages/jms_serializer.yaml | 4 - .../1.11/packages/prod/jms_serializer.yaml | 10 -- .../sylius/1.11/packages/swiftmailer.yaml | 2 - .../1.11/packages/test/swiftmailer.yaml | 6 - .../packages/test_cached/swiftmailer.yaml | 6 - .../config/sylius/1.12/packages/security.yaml | 122 +++++++++++++++++ .../config/sylius/1.13/bundles.php | 7 + .../config/sylius/1.13/packages/security.yaml | 124 ++++++++++++++++++ ...package.json.~1.12.0.dist => package.json} | 0 tests/Application/package.json.~1.11.0.dist | 41 ------ 19 files changed, 333 insertions(+), 246 deletions(-) delete mode 100644 tests/Application/config/packages/security.yaml create mode 100644 tests/Application/config/packages/test/mailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/bundles.php delete mode 100644 tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml create mode 100644 tests/Application/config/sylius/1.12/packages/security.yaml create mode 100644 tests/Application/config/sylius/1.13/bundles.php create mode 100644 tests/Application/config/sylius/1.13/packages/security.yaml rename tests/Application/{package.json.~1.12.0.dist => package.json} (100%) delete mode 100755 tests/Application/package.json.~1.11.0.dist diff --git a/composer.json b/composer.json index f8097209..c4de486a 100644 --- a/composer.json +++ b/composer.json @@ -7,30 +7,30 @@ "php": "^8.0", "ext-json": "*", "sylius/refund-plugin": "^1.0", - "sylius/sylius": "~1.11.0 || ~1.12.0", + "sylius/sylius": "^1.12 || ^1.13", "twig/extra-bundle": "^3.4", "symfony/webpack-encore-bundle": "^1.16" }, "require-dev": { "behat/behat": "^3.7", "behat/mink-selenium2-driver": "^1.4", - "bitbag/coding-standard": "^1.0", + "bitbag/coding-standard": "^3.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-debug-extension": "^2.0.0", + "friends-of-behat/mink-debug-extension": "^2.0", "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/page-object-extension": "^0.3", "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", "phpspec/phpspec": "^7.0", - "doctrine/dbal": "^2.7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.85", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-doctrine": "^1.3", + "phpstan/phpstan-strict-rules": "^1.3.0", + "phpstan/phpstan-webmozart-assert": "^1.2.0", "phpunit/phpunit": "^9.5", "sylius-labs/coding-standard": "^4.0", "symfony/browser-kit": "^5.4 || ^6.0", diff --git a/src/Client/ImojeApiClient.php b/src/Client/ImojeApiClient.php index 991adf03..f3ee81c1 100644 --- a/src/Client/ImojeApiClient.php +++ b/src/Client/ImojeApiClient.php @@ -9,14 +9,16 @@ use BitBag\SyliusImojePlugin\Model\PaymentMethod\ServiceModelInterface; use BitBag\SyliusImojePlugin\Model\TransactionModelInterface; use BitBag\SyliusImojePlugin\Provider\RequestParams\RequestParamsProviderInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Exception\GuzzleException; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamFactoryInterface; use Symfony\Component\Serializer\Serializer; final class ImojeApiClient implements ImojeApiClientInterface { - private Client $httpClient; + private ClientInterface $httpClient; private RequestParamsProviderInterface $requestParamsProvider; @@ -26,30 +28,44 @@ final class ImojeApiClient implements ImojeApiClientInterface private Serializer $serializer; + private RequestFactoryInterface $requestFactory; + + private StreamFactoryInterface $streamFactory; + public function __construct( - Client $httpClient, + ClientInterface $httpClient, RequestParamsProviderInterface $requestParamsProvider, Serializer $serializer, string $token, - string $url + string $url, + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory ) { $this->httpClient = $httpClient; $this->requestParamsProvider = $requestParamsProvider; $this->token = $token; $this->url = $url; $this->serializer = $serializer; + $this->requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; } public function createTransaction( TransactionModelInterface $transactionModel ): ResponseInterface { $url = $this->url . self::TRANSACTION_ENDPOINT; - $parameters = $this->requestParamsProvider->buildRequestParams($transactionModel, $this->token); - try { - $response = $this->httpClient->post($url, $parameters); - } catch (GuzzleException $e) { + $request = $this->requestFactory + ->createRequest('POST', $url) + ->withHeader('Accept', 'application/json') + ->withHeader('Content-Type', 'application/json') + ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)) + ->withBody($this->streamFactory->createStream($parameters['body'])); + + $response = $this->httpClient->sendRequest($request); + + } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); } @@ -59,11 +75,14 @@ public function createTransaction( public function getShopInfo(string $serviceId): ServiceModelInterface { $url = $this->url . 'service/' . $serviceId; - $parameters = $this->requestParamsProvider->buildAuthorizeRequest($this->token); try { - $response = $this->httpClient->get($url, $parameters); - } catch (GuzzleException $e) { + $request = $this->requestFactory->createRequest('GET', $url) + ->withHeader('Accept', 'application/json') + ->withHeader('Content-Type', 'application/json') + ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)); + $response = $this->httpClient->sendRequest($request); + } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); } @@ -76,11 +95,14 @@ public function getShopInfo(string $serviceId): ServiceModelInterface public function getTransactionData(string $url): ResponseInterface { - $parameters = $this->requestParamsProvider->buildAuthorizeRequest($this->token); - try { - $response = $this->httpClient->get($url, $parameters); - } catch (GuzzleException $e) { + $request = $this->requestFactory->createRequest('GET', $url) + ->withHeader('Accept', 'application/json') + ->withHeader('Content-Type', 'application/json') + ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)); + + $response = $this->httpClient->sendRequest($request); + } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); } @@ -93,10 +115,16 @@ public function refundTransaction( int $amount ): ResponseInterface { $parameters = $this->requestParamsProvider->buildRequestRefundParams($this->token, $serviceId, $amount); - try { - $response = $this->httpClient->post($url, $parameters); - } catch (GuzzleException $e) { + $request = $this->requestFactory + ->createRequest('POST', $url) + ->withHeader('Accept', 'application/json') + ->withHeader('Content-Type', 'application/json') + ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)) + ->withBody($this->streamFactory->createStream($parameters['body'])); + + $response = $this->httpClient->sendRequest($request); + } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); } diff --git a/src/Provider/ImojeClientConfigurationProvider.php b/src/Provider/ImojeClientConfigurationProvider.php index 3d7312ef..b001b933 100644 --- a/src/Provider/ImojeClientConfigurationProvider.php +++ b/src/Provider/ImojeClientConfigurationProvider.php @@ -12,7 +12,8 @@ use Payum\Core\Model\GatewayConfigInterface; use Sylius\Component\Core\Model\PaymentMethodInterface; -final class ImojeClientConfigurationProvider implements ImojeClientConfigurationProviderInterface +final class +ImojeClientConfigurationProvider implements ImojeClientConfigurationProviderInterface { private PaymentMethodRepositoryInterface $paymentMethodRepository; diff --git a/src/Provider/ImojeClientProvider.php b/src/Provider/ImojeClientProvider.php index 05f2678d..384d9a1c 100644 --- a/src/Provider/ImojeClientProvider.php +++ b/src/Provider/ImojeClientProvider.php @@ -7,28 +7,37 @@ use BitBag\SyliusImojePlugin\Client\ImojeApiClient; use BitBag\SyliusImojePlugin\Factory\Serializer\SerializerFactoryInterface; use BitBag\SyliusImojePlugin\Provider\RequestParams\RequestParamsProviderInterface; -use GuzzleHttp\Client; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; final class ImojeClientProvider implements ImojeClientProviderInterface { private ImojeClientConfigurationProviderInterface $imojeClientConfigurationProvider; - private Client $httpClient; + private ClientInterface $httpClient; private RequestParamsProviderInterface $requestParamsProvider; private SerializerFactoryInterface $serializerFactory; + private RequestFactoryInterface $requestFactoryInterface; + private StreamFactoryInterface $streamFactoryInterface; + public function __construct( ImojeClientConfigurationProviderInterface $imojeClientConfigurationProvider, - Client $httpClient, - RequestParamsProviderInterface $requestParamsProvider, - SerializerFactoryInterface $serializerFactory + ClientInterface $httpClient, + RequestParamsProviderInterface $requestParamsProvider, + SerializerFactoryInterface $serializerFactory, + RequestFactoryInterface $requestFactoryInterface, + StreamFactoryInterface $streamFactoryInterface ) { $this->imojeClientConfigurationProvider = $imojeClientConfigurationProvider; $this->httpClient = $httpClient; $this->requestParamsProvider = $requestParamsProvider; $this->serializerFactory = $serializerFactory; + $this->requestFactoryInterface = $requestFactoryInterface; + $this->streamFactoryInterface = $streamFactoryInterface; } public function getClient(string $code): ImojeApiClient @@ -40,6 +49,6 @@ public function getClient(string $code): ImojeApiClient $completeUrl = \sprintf('%s/%s/', $url, $merchantId); - return new ImojeApiClient($this->httpClient, $this->requestParamsProvider, $this->serializerFactory->createSerializerWithNormalizer(), $token, $completeUrl); + return new ImojeApiClient($this->httpClient, $this->requestParamsProvider, $this->serializerFactory->createSerializerWithNormalizer(), $token, $completeUrl, $this->requestFactoryInterface, $this->streamFactoryInterface); } } diff --git a/src/Resources/config/services/providers.xml b/src/Resources/config/services/providers.xml index 1e112e23..f73d7645 100644 --- a/src/Resources/config/services/providers.xml +++ b/src/Resources/config/services/providers.xml @@ -16,6 +16,8 @@ + + ['all' => true], - -]; diff --git a/tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b1..00000000 --- a/tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc613..00000000 --- a/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml deleted file mode 100644 index c2881820..00000000 --- a/tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml deleted file mode 100644 index 80d780cc..00000000 --- a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)' \ No newline at end of file diff --git a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml deleted file mode 100644 index cf16fdfe..00000000 --- a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" \ No newline at end of file diff --git a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index cf16fdfe..00000000 --- a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" \ No newline at end of file diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml new file mode 100644 index 00000000..71d89cd9 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/security.yaml @@ -0,0 +1,122 @@ +security: + enable_authenticator_manager: true + providers: + sylius_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_api_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + + password_hashers: + Sylius\Component\User\Model\UserInterface: argon2i + firewalls: + admin: + switch_user: true + context: admin + pattern: "%sylius.security.admin_regex%" + provider: sylius_admin_user_provider + form_login: + provider: sylius_admin_user_provider + login_path: sylius_admin_login + check_path: sylius_admin_login_check + failure_path: sylius_admin_login + default_target_path: sylius_admin_dashboard + use_forward: false + use_referer: true + enable_csrf: true + csrf_parameter: _csrf_admin_security_token + csrf_token_id: admin_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + path: "/%sylius_admin.path_name%" + name: APP_ADMIN_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_admin_logout + target: sylius_admin_login + + new_api_admin_user: + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider + stateless: true + entry_point: jwt + json_login: + check_path: "%sylius.security.new_api_admin_route%/authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + jwt: true + + new_api_shop_user: + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider + stateless: true + entry_point: jwt + json_login: + check_path: "%sylius.security.new_api_shop_route%/authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + jwt: true + + shop: + switch_user: { role: ROLE_ALLOWED_TO_SWITCH } + context: shop + pattern: "%sylius.security.shop_regex%" + provider: sylius_shop_user_provider + form_login: + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler + provider: sylius_shop_user_provider + login_path: sylius_shop_login + check_path: sylius_shop_login_check + failure_path: sylius_shop_login + default_target_path: sylius_shop_homepage + use_forward: false + use_referer: true + enable_csrf: true + csrf_parameter: _csrf_shop_security_token + csrf_token_id: shop_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + name: APP_SHOP_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_shop_logout + target: sylius_shop_homepage + invalidate_session: false + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + access_control: + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + + - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } + - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php new file mode 100644 index 00000000..5d54121b --- /dev/null +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -0,0 +1,7 @@ + ['all' => true], +]; diff --git a/tests/Application/config/sylius/1.13/packages/security.yaml b/tests/Application/config/sylius/1.13/packages/security.yaml new file mode 100644 index 00000000..6745ae80 --- /dev/null +++ b/tests/Application/config/sylius/1.13/packages/security.yaml @@ -0,0 +1,124 @@ +security: + enable_authenticator_manager: true + providers: + sylius_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_api_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + + password_hashers: + Sylius\Component\User\Model\UserInterface: argon2i + firewalls: + admin: + switch_user: true + context: admin + pattern: "%sylius.security.admin_regex%" + provider: sylius_admin_user_provider + form_login: + provider: sylius_admin_user_provider + login_path: sylius_admin_login + check_path: sylius_admin_login_check + failure_path: sylius_admin_login + default_target_path: sylius_admin_dashboard + use_forward: false + use_referer: true + enable_csrf: true + csrf_parameter: _csrf_admin_security_token + csrf_token_id: admin_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + path: "/%sylius_admin.path_name%" + name: APP_ADMIN_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_admin_logout + target: sylius_admin_login + + new_api_admin_user: + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider + stateless: true + entry_point: jwt + json_login: + check_path: "%sylius.security.new_api_admin_route%/administrators/token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + jwt: true + + new_api_shop_user: + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider + stateless: true + entry_point: jwt + json_login: + check_path: "%sylius.security.new_api_shop_route%/customers/token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + jwt: true + + shop: + switch_user: { role: ROLE_ALLOWED_TO_SWITCH } + context: shop + pattern: "%sylius.security.shop_regex%" + provider: sylius_shop_user_provider + form_login: + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler + provider: sylius_shop_user_provider + login_path: sylius_shop_login + check_path: sylius_shop_login_check + failure_path: sylius_shop_login + default_target_path: sylius_shop_homepage + use_forward: false + use_referer: true + enable_csrf: true + csrf_parameter: _csrf_shop_security_token + csrf_token_id: shop_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + name: APP_SHOP_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_shop_logout + target: sylius_shop_homepage + invalidate_session: false + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + image_resolver: + pattern: ^/media/cache/resolve + security: false + + access_control: + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } + - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_route%/administrators/reset-password", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_admin_route%/administrators/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/customers/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } \ No newline at end of file diff --git a/tests/Application/package.json.~1.12.0.dist b/tests/Application/package.json similarity index 100% rename from tests/Application/package.json.~1.12.0.dist rename to tests/Application/package.json diff --git a/tests/Application/package.json.~1.11.0.dist b/tests/Application/package.json.~1.11.0.dist deleted file mode 100755 index 9ca35627..00000000 --- a/tests/Application/package.json.~1.11.0.dist +++ /dev/null @@ -1,41 +0,0 @@ -{ - "dependencies": { - "@babel/polyfill": "^7.0.0", - "chart.js": "^2.9.3", - "jquery": "^3.5.0", - "jquery.dirtyforms": "^2.0.0", - "lightbox2": "^2.9.0", - "semantic-ui-css": "^2.2.0", - "slick-carousel": "^1.8.1" - }, - "devDependencies": { - "@symfony/webpack-encore": "^1.6.1", - "babel-core": "^6.26.3", - "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-register": "^6.26.0", - "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "merge-stream": "^1.0.0", - "sass": "^1.39.2", - "sass-loader": "^12.1.0" - }, - "scripts": { - "dev": "yarn encore dev", - "watch": "yarn encore dev --watch", - "prod": "yarn encore prod", - "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" -} From e4d4f1f57dd0519ad251b819e0ed4c2eae59dc69 Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 22 Jul 2024 11:37:10 +0200 Subject: [PATCH 02/12] OP-366 - Update builds --- .github/workflows/build.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9a3f771..24f30b15 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,22 +14,25 @@ on: jobs: tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: ["8.0"] + php: [ "8.0", "8.1", "8.2", "8.3" ] symfony: ["^5.4", "^6.0"] - sylius: ["~1.11.0", "~1.12.0"] - node: ["14.x"] + sylius: ["^1.12", "^1.13"] + node: [ "18.x", "20.x" ] mysql: ["8.0"] exclude: - - sylius: ~1.11.0 - symfony: "^6.0" + - sylius: ^1.13 + php: 8.0 + - sylius: ^1.12 + php: 8.0 + symfony: ^6.4 env: APP_ENV: test @@ -126,11 +129,6 @@ jobs: restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- - - - name: Copy package.json.dist to package.json - if: matrix.sylius != '' - run: (cd tests/Application && cp package.json.\${{ matrix.sylius }}.dist package.json) - - name: Install JS dependencies run: (cd tests/Application && yarn install) @@ -185,7 +183,7 @@ jobs: name: Behat logs path: etc/build/ if-no-files-found: ignore - + - name: Failed build Slack notification uses: rtCamp/action-slack-notify@v2 if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} From dcd3b5c7e1a22458b7d3e7ba4509668de5585b19 Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 22 Jul 2024 11:48:47 +0200 Subject: [PATCH 03/12] OP-366 - Update PHPStan configuration --- .github/workflows/build.yml | 2 +- phpstan.neon => phpstan.neon.dist | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename phpstan.neon => phpstan.neon.dist (94%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24f30b15..bf0e9fda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -163,7 +163,7 @@ jobs: - name: Run PHPStan - run: vendor/bin/phpstan analyse -c phpstan.neon -l 6 src/ + run: vendor/bin/phpstan analyse -c phpstan.neon.dist -l 6 src/ - name: Run PHPSpec diff --git a/phpstan.neon b/phpstan.neon.dist similarity index 94% rename from phpstan.neon rename to phpstan.neon.dist index f7eee75f..c2519c25 100644 --- a/phpstan.neon +++ b/phpstan.neon.dist @@ -2,6 +2,7 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false + treatPhpDocTypesAsCertain: false excludes_analyse: # Makes PHPStan crash From be203d85bd39f8fb37b90a01aa33276cf5bf554a Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 22 Jul 2024 12:13:05 +0200 Subject: [PATCH 04/12] OP-368 - Upgrade ECS configuration --- ecs.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ecs.php b/ecs.php index b088160e..0e36d84e 100644 --- a/ecs.php +++ b/ecs.php @@ -1,16 +1,26 @@ import('vendor/bitbag/coding-standard/ecs.php'); +use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer; +use Symplify\EasyCodingStandard\Config\ECSConfig; - $parameters = $containerConfigurator->parameters(); - $parameters->set(Option::PATHS, [ +return static function (ECSConfig $ecsConfig): void { + $ecsConfig->paths([ __DIR__ . '/src', - __DIR__ . '/tests', + __DIR__ . '/tests/Behat', + __DIR__ . '/ecs.php', + ]); + + $ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php'); + + $ecsConfig->skip([ + VisibilityRequiredFixer::class => ['*Spec.php'], ]); }; From a2422692aab8a65352f76c12241e5041e85e4a48 Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 22 Jul 2024 12:16:09 +0200 Subject: [PATCH 05/12] OP-366 - Apply ECS fixes --- src/BitBagSyliusImojePlugin.php | 2 +- src/Bus/Dispatcher.php | 2 +- src/Bus/Handler/FinalizeOrderHandler.php | 2 +- .../Handler/GetBlikTransactionDataHandler.php | 12 ++++++------ src/Bus/Handler/GetResponseDataHandler.php | 12 ++++++------ src/Bus/Handler/GetTransactionDataHandler.php | 12 ++++++------ src/Bus/Handler/PaymentFinalizationHandler.php | 2 +- src/Bus/Handler/TakeOverPaymentHandler.php | 2 +- src/Bus/Query/GetBlikTransactionData.php | 2 +- src/Bus/Query/GetTransactionData.php | 2 +- src/Client/ImojeApiClient.php | 11 ++++++----- src/Client/ImojeApiClientInterface.php | 4 ++-- src/Configuration/ImojeClientConfiguration.php | 2 +- .../Shop/InitializePaymentController.php | 17 +++++++++-------- .../Shop/Oneclick/OneClickController.php | 8 ++++---- .../Oneclick/RedirectOneClickController.php | 6 +++--- src/Controller/Shop/RedirectController.php | 6 +++--- .../Shop/Webhook/WebhookController.php | 6 +++--- .../CompilerPass/MessageBusPolyfillPass.php | 2 +- src/Entity/ImojeTransaction.php | 2 +- .../AuthorizationSubscriber.php | 2 +- src/Exception/InvalidSignatureException.php | 2 +- .../MissingImojeTransactionException.php | 2 +- src/Exception/MissingPaymentException.php | 2 +- .../MissingPaymentMethodException.php | 2 +- .../Bus/PaymentFinalizationCommandFactory.php | 2 +- .../Model/TransactionBlikModelFactory.php | 16 ++++++++-------- .../TransactionBlikModelFactoryInterface.php | 12 ++++++------ src/Factory/Model/TransactionModelFactory.php | 14 +++++++------- .../Model/TransactionModelFactoryInterface.php | 10 +++++----- .../ReadyTransactionFactory.php | 4 ++-- .../ReadyTransactionFactoryInterface.php | 4 ++-- src/Factory/Refund/RefundModelFactory.php | 2 +- .../Refund/RefundModelFactoryInterface.php | 2 +- src/Factory/Request/RedirectFactory.php | 4 ++-- src/Factory/Serializer/SerializerFactory.php | 4 ++-- .../Status/StatusResponseModelFactory.php | 2 +- .../StatusResponseModelFactoryInterface.php | 2 +- .../Transaction/ImojeTransactionFactory.php | 2 +- .../ImojeTransactionFactoryInterface.php | 2 +- src/Filter/AvailablePaymentMethodsFilter.php | 2 +- .../AvailablePaymentMethodsFilterInterface.php | 2 +- src/Form/Extension/CompleteTypeExtension.php | 2 +- src/Form/Type/PaymentImojeType.php | 2 +- .../AggregateStatusBasedUrlGenerator.php | 4 ++-- ...gregateStatusBasedUrlGeneratorInterface.php | 2 +- .../Url/Status/CanceledStatusUrlGenerator.php | 4 ++-- .../Url/Status/FailedStatusUrlGenerator.php | 2 +- .../Status/SuccessfulStatusUrlGenerator.php | 2 +- src/Model/BillingModel.php | 2 +- src/Model/CustomerModel.php | 2 +- .../ReadyTransaction/ReadyTransactionModel.php | 4 ++-- src/Model/Refund/RefundModel.php | 2 +- src/Model/ShippingModel.php | 2 +- src/Model/Status/StatusResponseModel.php | 2 +- src/Model/TransactionBlikModel.php | 2 +- src/Model/TransactionModel.php | 2 +- .../Status/WebhookResponseProcessor.php | 6 +++--- .../ImojeClientConfigurationProvider.php | 7 +++---- src/Provider/ImojeClientProvider.php | 3 ++- .../RequestParams/RequestParamsProvider.php | 4 ++-- .../RequestParamsProviderInterface.php | 2 +- src/Refund/ImojeRefundStep.php | 8 ++++---- .../ImojeTransactionRepository.php | 2 +- src/Repository/PaymentMethodRepository.php | 5 +++-- .../GatewayCodeFromOrderResolver.php | 2 +- .../ImojeOneClickSignatureResolver.php | 2 +- src/Resolver/Order/OrderResolver.php | 2 +- .../Payment/ImojePaymentsMethodResolver.php | 2 +- .../ImojeTransactionPaymentResolver.php | 2 +- src/Resolver/Payment/OrderPaymentResolver.php | 2 +- .../Payment/TransactionPaymentDataResolver.php | 4 ++-- ...TransactionPaymentDataResolverInterface.php | 2 +- .../Signature/OwnSignatureResolver.php | 2 +- src/Resolver/Signature/SignatureResolver.php | 4 ++-- src/Resolver/TotalResolver/TotalResolver.php | 2 +- src/Resolver/Url/UrlResolver.php | 12 ++++++------ src/Resolver/Url/UrlResolverInterface.php | 4 ++-- .../Webhook/OneClickWebhookResolver.php | 18 +++++++++--------- 79 files changed, 173 insertions(+), 170 deletions(-) diff --git a/src/BitBagSyliusImojePlugin.php b/src/BitBagSyliusImojePlugin.php index 000b539c..403316b0 100644 --- a/src/BitBagSyliusImojePlugin.php +++ b/src/BitBagSyliusImojePlugin.php @@ -27,7 +27,7 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass( new MessageBusPolyfillPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, - 1 + 1, ); } } diff --git a/src/Bus/Dispatcher.php b/src/Bus/Dispatcher.php index 0b8c3396..af81d660 100644 --- a/src/Bus/Dispatcher.php +++ b/src/Bus/Dispatcher.php @@ -12,7 +12,7 @@ final class Dispatcher implements DispatcherInterface use HandleTrait; public function __construct( - MessageBusInterface $messageBus + MessageBusInterface $messageBus, ) { $this->messageBus = $messageBus; } diff --git a/src/Bus/Handler/FinalizeOrderHandler.php b/src/Bus/Handler/FinalizeOrderHandler.php index b62b3eb8..57131a17 100644 --- a/src/Bus/Handler/FinalizeOrderHandler.php +++ b/src/Bus/Handler/FinalizeOrderHandler.php @@ -26,7 +26,7 @@ final class FinalizeOrderHandler implements MessageHandlerInterface public function __construct( FactoryInterface $stateMachineFactory, RepositoryInterface $orderRepository, - MessageBusInterface $commandBus + MessageBusInterface $commandBus, ) { $this->stateMachineFactory = $stateMachineFactory; $this->orderRepository = $orderRepository; diff --git a/src/Bus/Handler/GetBlikTransactionDataHandler.php b/src/Bus/Handler/GetBlikTransactionDataHandler.php index 110f809f..887a4eb0 100644 --- a/src/Bus/Handler/GetBlikTransactionDataHandler.php +++ b/src/Bus/Handler/GetBlikTransactionDataHandler.php @@ -28,10 +28,10 @@ final class GetBlikTransactionDataHandler implements MessageHandlerInterface public function __construct( ImojeClientConfigurationProviderInterface $configurationProvider, - TransactionBlikModelFactoryInterface $transactionBlikModelFactory, - ImojeClientProviderInterface $imojeClientProvider, - ImojeTransactionFactoryInterface $imojeTransactionFactory, - TransactionDataResolverInterface $transactionDataResolver + TransactionBlikModelFactoryInterface $transactionBlikModelFactory, + ImojeClientProviderInterface $imojeClientProvider, + ImojeTransactionFactoryInterface $imojeTransactionFactory, + TransactionDataResolverInterface $transactionDataResolver, ) { $this->configurationProvider = $configurationProvider; $this->transactionBlikModelFactory = $transactionBlikModelFactory; @@ -52,7 +52,7 @@ public function __invoke(GetBlikTransactionData $query): ImojeTransactionInterfa $query->getPaymentMethod(), $query->getPaymentMethodCode(), $config->getServiceId(), - $query->getBlikModel() + $query->getBlikModel(), ); $response = $this->imojeClientProvider @@ -77,7 +77,7 @@ public function __invoke(GetBlikTransactionData $query): ImojeTransactionInterfa $paymentUrl, $serviceId, $orderId, - $query->getCode() + $query->getCode(), ); } } diff --git a/src/Bus/Handler/GetResponseDataHandler.php b/src/Bus/Handler/GetResponseDataHandler.php index 589802bd..a272bd7f 100644 --- a/src/Bus/Handler/GetResponseDataHandler.php +++ b/src/Bus/Handler/GetResponseDataHandler.php @@ -30,12 +30,12 @@ final class GetResponseDataHandler implements MessageHandlerInterface private UrlResolverInterface $urlResolver; public function __construct( - ImojeTransactionRepositoryInterface $imojeTransactionRepository, - ImojeClientProviderInterface $imojeClientProvider, + ImojeTransactionRepositoryInterface $imojeTransactionRepository, + ImojeClientProviderInterface $imojeClientProvider, ImojeClientConfigurationProviderInterface $configurationProvider, - ReadyTransactionFactoryInterface $readyTransactionFactory, - OrderRepository $orderRepository, - UrlResolverInterface $urlResolver + ReadyTransactionFactoryInterface $readyTransactionFactory, + OrderRepository $orderRepository, + UrlResolverInterface $urlResolver, ) { $this->imojeTransactionRepository = $imojeTransactionRepository; $this->imojeClientProvider = $imojeClientProvider; @@ -60,7 +60,7 @@ public function __invoke(GetResponseData $query): ReadyTransactionModelInterface return $this->readyTransactionFactory->createReadyTransaction( $response->getBody()->getContents(), $imojeTransaction, - $order + $order, ); } } diff --git a/src/Bus/Handler/GetTransactionDataHandler.php b/src/Bus/Handler/GetTransactionDataHandler.php index 30553b47..d77c52d2 100644 --- a/src/Bus/Handler/GetTransactionDataHandler.php +++ b/src/Bus/Handler/GetTransactionDataHandler.php @@ -28,10 +28,10 @@ final class GetTransactionDataHandler implements MessageHandlerInterface public function __construct( ImojeClientConfigurationProviderInterface $configurationProvider, - TransactionModelFactoryInterface $transactionModelFactory, - ImojeClientProviderInterface $imojeClientProvider, - ImojeTransactionFactoryInterface $imojeTransactionFactory, - TransactionDataResolverInterface $transactionDataResolver + TransactionModelFactoryInterface $transactionModelFactory, + ImojeClientProviderInterface $imojeClientProvider, + ImojeTransactionFactoryInterface $imojeTransactionFactory, + TransactionDataResolverInterface $transactionDataResolver, ) { $this->configurationProvider = $configurationProvider; $this->transactionModelFactory = $transactionModelFactory; @@ -51,7 +51,7 @@ public function __invoke(GetTransactionData $query): ImojeTransactionInterface $this->transactionModelFactory::SALE_TYPE, $query->getPaymentMethod(), $query->getPaymentMethodCode(), - $config->getServiceId() + $config->getServiceId(), ); $response = $this->imojeClientProvider @@ -76,7 +76,7 @@ public function __invoke(GetTransactionData $query): ImojeTransactionInterface $paymentUrl, $serviceId, $orderId, - $query->getCode() + $query->getCode(), ); } } diff --git a/src/Bus/Handler/PaymentFinalizationHandler.php b/src/Bus/Handler/PaymentFinalizationHandler.php index 277f0df0..a2d0f55e 100644 --- a/src/Bus/Handler/PaymentFinalizationHandler.php +++ b/src/Bus/Handler/PaymentFinalizationHandler.php @@ -18,7 +18,7 @@ final class PaymentFinalizationHandler implements MessageHandlerInterface public function __construct( FactoryInterface $stateMachineFactory, - RepositoryInterface $paymentRepository + RepositoryInterface $paymentRepository, ) { $this->stateMachineFactory = $stateMachineFactory; $this->paymentRepository = $paymentRepository; diff --git a/src/Bus/Handler/TakeOverPaymentHandler.php b/src/Bus/Handler/TakeOverPaymentHandler.php index 1a4ac88b..5e807b3d 100644 --- a/src/Bus/Handler/TakeOverPaymentHandler.php +++ b/src/Bus/Handler/TakeOverPaymentHandler.php @@ -21,7 +21,7 @@ final class TakeOverPaymentHandler implements MessageHandlerInterface public function __construct( PaymentMethodRepositoryInterface $paymentMethodRepository, PaymentMethodResolver $paymentMethodResolver, - RepositoryInterface $paymentRepository + RepositoryInterface $paymentRepository, ) { $this->paymentMethodRepository = $paymentMethodRepository; $this->paymentMethodResolver = $paymentMethodResolver; diff --git a/src/Bus/Query/GetBlikTransactionData.php b/src/Bus/Query/GetBlikTransactionData.php index dbe1cb63..2bbeeb55 100644 --- a/src/Bus/Query/GetBlikTransactionData.php +++ b/src/Bus/Query/GetBlikTransactionData.php @@ -24,7 +24,7 @@ public function __construct( string $code, string $paymentMethod, string $paymentMethodCode, - BlikModelInterface $blikModel + BlikModelInterface $blikModel, ) { $this->order = $order; $this->code = $code; diff --git a/src/Bus/Query/GetTransactionData.php b/src/Bus/Query/GetTransactionData.php index f2a73801..d4e04bc7 100644 --- a/src/Bus/Query/GetTransactionData.php +++ b/src/Bus/Query/GetTransactionData.php @@ -20,7 +20,7 @@ public function __construct( OrderInterface $order, string $code, string $paymentMethod, - string $paymentMethodCode + string $paymentMethodCode, ) { $this->order = $order; $this->code = $code; diff --git a/src/Client/ImojeApiClient.php b/src/Client/ImojeApiClient.php index f3ee81c1..6b09c44b 100644 --- a/src/Client/ImojeApiClient.php +++ b/src/Client/ImojeApiClient.php @@ -9,9 +9,9 @@ use BitBag\SyliusImojePlugin\Model\PaymentMethod\ServiceModelInterface; use BitBag\SyliusImojePlugin\Model\TransactionModelInterface; use BitBag\SyliusImojePlugin\Provider\RequestParams\RequestParamsProviderInterface; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; -use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamFactoryInterface; use Symfony\Component\Serializer\Serializer; @@ -39,7 +39,7 @@ public function __construct( string $token, string $url, RequestFactoryInterface $requestFactory, - StreamFactoryInterface $streamFactory + StreamFactoryInterface $streamFactory, ) { $this->httpClient = $httpClient; $this->requestParamsProvider = $requestParamsProvider; @@ -51,10 +51,11 @@ public function __construct( } public function createTransaction( - TransactionModelInterface $transactionModel + TransactionModelInterface $transactionModel, ): ResponseInterface { $url = $this->url . self::TRANSACTION_ENDPOINT; $parameters = $this->requestParamsProvider->buildRequestParams($transactionModel, $this->token); + try { $request = $this->requestFactory ->createRequest('POST', $url) @@ -64,7 +65,6 @@ public function createTransaction( ->withBody($this->streamFactory->createStream($parameters['body'])); $response = $this->httpClient->sendRequest($request); - } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); } @@ -112,9 +112,10 @@ public function getTransactionData(string $url): ResponseInterface public function refundTransaction( string $url, string $serviceId, - int $amount + int $amount, ): ResponseInterface { $parameters = $this->requestParamsProvider->buildRequestRefundParams($this->token, $serviceId, $amount); + try { $request = $this->requestFactory ->createRequest('POST', $url) diff --git a/src/Client/ImojeApiClientInterface.php b/src/Client/ImojeApiClientInterface.php index c26835f7..011f57e1 100644 --- a/src/Client/ImojeApiClientInterface.php +++ b/src/Client/ImojeApiClientInterface.php @@ -13,7 +13,7 @@ interface ImojeApiClientInterface public const TRANSACTION_ENDPOINT = 'transaction'; public function createTransaction( - TransactionModelInterface $transactionModel + TransactionModelInterface $transactionModel, ): ResponseInterface; public function getTransactionData(string $url): ResponseInterface; @@ -23,6 +23,6 @@ public function getShopInfo(string $serviceId): ServiceModelInterface; public function refundTransaction( string $url, string $serviceId, - int $amount + int $amount, ): ResponseInterface; } diff --git a/src/Configuration/ImojeClientConfiguration.php b/src/Configuration/ImojeClientConfiguration.php index bc9b8ee7..8eccb8a1 100644 --- a/src/Configuration/ImojeClientConfiguration.php +++ b/src/Configuration/ImojeClientConfiguration.php @@ -27,7 +27,7 @@ public function __construct( string $prodUrl, bool $isProd, string $serviceId, - string $shopKey + string $shopKey, ) { $this->token = $token; $this->merchantId = $merchantId; diff --git a/src/Controller/Shop/InitializePaymentController.php b/src/Controller/Shop/InitializePaymentController.php index 671757f7..5d18afd3 100644 --- a/src/Controller/Shop/InitializePaymentController.php +++ b/src/Controller/Shop/InitializePaymentController.php @@ -48,7 +48,7 @@ public function __construct( DispatcherInterface $dispatcher, BlikModelProviderInterface $blikModelProvider, TransactionPaymentDataResolverInterface $transactionPaymentDataResolver, - TranslatorInterface $translator + TranslatorInterface $translator, ) { $this->orderResolver = $orderResolver; $this->paymentResolver = $paymentResolver; @@ -62,7 +62,7 @@ public function __invoke( Request $request, ?string $orderId, ?string $paymentMethodCode, - ?string $blikCode + ?string $blikCode, ): Response { $order = $this->orderResolver->resolve($orderId); $this->dispatcher->dispatch(new AssignTokenValue($order, $request)); @@ -96,6 +96,7 @@ public function __invoke( $transactionPaymentData = $this->transactionPaymentDataResolver->resolve($paymentMethodCode, $payment, $blikCode); $isBlik = 'blik' === $transactionPaymentData->getPaymentMethod(); + try { $transactionData = $isBlik ? $this->getTransactionDataForBlik($order, $payment, $transactionPaymentData, $blikCode) : $this->getTransactionData($order, $payment, $transactionPaymentData); @@ -105,9 +106,9 @@ public function __invoke( return new RedirectResponse($transactionData->getPaymentUrl()); } catch (Throwable $e) { $this->addFlash('error', $this->translator->trans('bitbag_sylius_imoje_plugin.ui.payment_failed')); + return $this->redirectToRoute('sylius_shop_checkout_select_payment'); } - } private function getPaymentFromOrder(OrderInterface $order): PaymentInterface @@ -124,7 +125,7 @@ private function getPaymentFromOrder(OrderInterface $order): PaymentInterface private function getTransactionData( OrderInterface $order, PaymentInterface $payment, - PaymentDataModelInterface $transactionPaymentData + PaymentDataModelInterface $transactionPaymentData, ): ImojeTransactionInterface { return $this->dispatcher->dispatch( new GetTransactionData( @@ -132,7 +133,7 @@ private function getTransactionData( $payment->getMethod()->getCode(), $transactionPaymentData->getPaymentMethod(), $transactionPaymentData->getPaymentMethodCode(), - ) + ), ); } @@ -140,7 +141,7 @@ private function getTransactionDataForBlik( OrderInterface $order, PaymentInterface $payment, PaymentDataModelInterface $transactionPaymentData, - ?string $blikCode + ?string $blikCode, ): ImojeTransactionInterface { $blikModel = $this->blikModelProvider->provideDataToBlikModel($blikCode); @@ -150,8 +151,8 @@ private function getTransactionDataForBlik( $payment->getMethod()->getCode(), $transactionPaymentData->getPaymentMethod(), $transactionPaymentData->getPaymentMethodCode(), - $blikModel - ) + $blikModel, + ), ); } } diff --git a/src/Controller/Shop/Oneclick/OneClickController.php b/src/Controller/Shop/Oneclick/OneClickController.php index 9a2e8c5d..ee719b0c 100644 --- a/src/Controller/Shop/Oneclick/OneClickController.php +++ b/src/Controller/Shop/Oneclick/OneClickController.php @@ -7,13 +7,13 @@ use BitBag\SyliusImojePlugin\Factory\Request\RedirectFactoryInterface; use BitBag\SyliusImojePlugin\Resolver\GatewayCode\GatewayCodeFromOrderResolverInterface; use BitBag\SyliusImojePlugin\Resolver\ImojeOneClickSignature\ImojeOneClickSignatureResolverInterface; +use function strtoupper; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\Repository\OrderRepositoryInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Webmozart\Assert\Assert; -use function strtoupper; final class OneClickController { @@ -28,10 +28,10 @@ final class OneClickController private OrderRepositoryInterface $orderRepository; public function __construct( - GatewayCodeFromOrderResolverInterface $gatewayCodeFromOrderResolver, + GatewayCodeFromOrderResolverInterface $gatewayCodeFromOrderResolver, ImojeOneClickSignatureResolverInterface $signatureResolver, - RedirectFactoryInterface $redirectFactory, - OrderRepositoryInterface $orderRepository + RedirectFactoryInterface $redirectFactory, + OrderRepositoryInterface $orderRepository, ) { $this->gatewayCodeFromOrderResolver = $gatewayCodeFromOrderResolver; $this->signatureResolver = $signatureResolver; diff --git a/src/Controller/Shop/Oneclick/RedirectOneClickController.php b/src/Controller/Shop/Oneclick/RedirectOneClickController.php index 2080c821..aa68e724 100644 --- a/src/Controller/Shop/Oneclick/RedirectOneClickController.php +++ b/src/Controller/Shop/Oneclick/RedirectOneClickController.php @@ -33,7 +33,7 @@ public function __construct( PaymentFinalizationCommandFactoryInterface $commandFactory, AggregateStatusBasedUrlGeneratorInterface $aggregateStatusBasedUrlGenerator, PaymentRepositoryInterface $paymentRepository, - StatusResolverInterface $statusResolver + StatusResolverInterface $statusResolver, ) { $this->dispatcher = $dispatcher; $this->commandFactory = $commandFactory; @@ -45,7 +45,7 @@ public function __construct( public function __invoke( Request $request, string $status, - int $paymentId + int $paymentId, ): Response { /** @var PaymentInterface|null $payment */ $payment = $this->paymentRepository->find($paymentId); @@ -55,7 +55,7 @@ public function __invoke( $resolvedStatus = $this->statusResolver->resolve($status); $this->dispatcher->dispatch(new FinalizeOrder($order)); $this->dispatcher->dispatch( - $this->commandFactory->createNew($resolvedStatus, $payment) + $this->commandFactory->createNew($resolvedStatus, $payment), ); $url = $this->aggregateStatusBasedUrlGenerator->generate($order, $request, $resolvedStatus); diff --git a/src/Controller/Shop/RedirectController.php b/src/Controller/Shop/RedirectController.php index 96662678..6a804ee4 100644 --- a/src/Controller/Shop/RedirectController.php +++ b/src/Controller/Shop/RedirectController.php @@ -29,7 +29,7 @@ public function __construct( DispatcherInterface $dispatcher, PaymentFinalizationCommandFactoryInterface $commandFactory, AggregateStatusBasedUrlGeneratorInterface $aggregateStatusBasedUrlGenerator, - StatusResolverInterface $statusResolver + StatusResolverInterface $statusResolver, ) { $this->dispatcher = $dispatcher; $this->commandFactory = $commandFactory; @@ -40,7 +40,7 @@ public function __construct( public function __invoke( Request $request, string $status, - int $paymentId + int $paymentId, ): Response { /** @var ReadyTransactionModelInterface $readyTransaction */ $readyTransaction = $this->dispatcher->dispatch(new GetResponseData($paymentId)); @@ -54,7 +54,7 @@ public function __invoke( $paymentStatus = $this->statusResolver->resolve($readyTransaction->getStatus()); $this->dispatcher->dispatch( - $this->commandFactory->createNew($paymentStatus, $payment) + $this->commandFactory->createNew($paymentStatus, $payment), ); $url = $this->aggregateStatusBasedUrlGenerator->generate($order, $request, $paymentStatus); diff --git a/src/Controller/Shop/Webhook/WebhookController.php b/src/Controller/Shop/Webhook/WebhookController.php index 32fb5b96..340e2344 100644 --- a/src/Controller/Shop/Webhook/WebhookController.php +++ b/src/Controller/Shop/Webhook/WebhookController.php @@ -27,9 +27,9 @@ final class WebhookController public function __construct( ImojeTransactionPaymentResolverInterface $imojeTransactionPaymentResolver, - WebhookResolverInterface $webhookResolver, - WebhookResponseProcessorInterface $webhookResponseProcessor, - oneClickWebhookResolverInterface $oneClickWebhookResolver + WebhookResolverInterface $webhookResolver, + WebhookResponseProcessorInterface $webhookResponseProcessor, + oneClickWebhookResolverInterface $oneClickWebhookResolver, ) { $this->imojeTransactionPaymentResolver = $imojeTransactionPaymentResolver; $this->webhookResolver = $webhookResolver; diff --git a/src/DependencyInjection/CompilerPass/MessageBusPolyfillPass.php b/src/DependencyInjection/CompilerPass/MessageBusPolyfillPass.php index d86d2833..8853c322 100644 --- a/src/DependencyInjection/CompilerPass/MessageBusPolyfillPass.php +++ b/src/DependencyInjection/CompilerPass/MessageBusPolyfillPass.php @@ -21,7 +21,7 @@ private function setupDefaultCommandBus(array $buses, ContainerBuilder $containe $targetBusName = in_array('sylius.command_bus', $buses, true) ? 'sylius.command_bus' : 'sylius_default.bus'; $container->setAlias( self::COMMAND_BUS_TAG, - $targetBusName + $targetBusName, ); } diff --git a/src/Entity/ImojeTransaction.php b/src/Entity/ImojeTransaction.php index 32890c9f..6c93653a 100644 --- a/src/Entity/ImojeTransaction.php +++ b/src/Entity/ImojeTransaction.php @@ -33,7 +33,7 @@ public function __construct( ?string $paymentUrl, string $serviceId, string $orderId, - string $gatewayCode + string $gatewayCode, ) { $this->transactionId = $transactionId; $this->payment = $payment; diff --git a/src/EventSubscriber/AuthorizationSubscriber.php b/src/EventSubscriber/AuthorizationSubscriber.php index 80ebb273..1937aa29 100644 --- a/src/EventSubscriber/AuthorizationSubscriber.php +++ b/src/EventSubscriber/AuthorizationSubscriber.php @@ -23,7 +23,7 @@ final class AuthorizationSubscriber implements EventSubscriberInterface public function __construct( SignatureResolverInterface $signatureResolver, OwnSignatureResolverInterface $ownSignatureResolver, - SignatureCalculatorInterface $signatureCalculator + SignatureCalculatorInterface $signatureCalculator, ) { $this->signatureResolver = $signatureResolver; $this->ownSignatureResolver = $ownSignatureResolver; diff --git a/src/Exception/InvalidSignatureException.php b/src/Exception/InvalidSignatureException.php index 6619b0b0..b6278849 100644 --- a/src/Exception/InvalidSignatureException.php +++ b/src/Exception/InvalidSignatureException.php @@ -10,7 +10,7 @@ public function __construct(string $signature) { parent::__construct(\sprintf( 'Invalid signature: %s', - $signature + $signature, )); } } diff --git a/src/Exception/MissingImojeTransactionException.php b/src/Exception/MissingImojeTransactionException.php index 8df0295a..cb406ec3 100644 --- a/src/Exception/MissingImojeTransactionException.php +++ b/src/Exception/MissingImojeTransactionException.php @@ -9,7 +9,7 @@ final class MissingImojeTransactionException extends \InvalidArgumentException public function __construct(string $transactionId) { parent::__construct( - \sprintf('No Imoje transaction with id %s found.', $transactionId) + \sprintf('No Imoje transaction with id %s found.', $transactionId), ); } } diff --git a/src/Exception/MissingPaymentException.php b/src/Exception/MissingPaymentException.php index 245811ed..2da1ae61 100644 --- a/src/Exception/MissingPaymentException.php +++ b/src/Exception/MissingPaymentException.php @@ -9,7 +9,7 @@ final class MissingPaymentException extends \InvalidArgumentException implements public function __construct(string $transactionId) { parent::__construct( - \sprintf('Transaction %s has no payment associated with it.', $transactionId) + \sprintf('Transaction %s has no payment associated with it.', $transactionId), ); } } diff --git a/src/Exception/MissingPaymentMethodException.php b/src/Exception/MissingPaymentMethodException.php index daa000f0..923fcbb2 100644 --- a/src/Exception/MissingPaymentMethodException.php +++ b/src/Exception/MissingPaymentMethodException.php @@ -11,7 +11,7 @@ final class MissingPaymentMethodException extends \InvalidArgumentException public function __construct(PaymentInterface $payment) { parent::__construct( - \sprintf('Payment %s does not contain a valid payment method.', $payment->getId()) + \sprintf('Payment %s does not contain a valid payment method.', $payment->getId()), ); } } diff --git a/src/Factory/Bus/PaymentFinalizationCommandFactory.php b/src/Factory/Bus/PaymentFinalizationCommandFactory.php index 7cb62687..d103962f 100644 --- a/src/Factory/Bus/PaymentFinalizationCommandFactory.php +++ b/src/Factory/Bus/PaymentFinalizationCommandFactory.php @@ -29,7 +29,7 @@ public function createNew(string $status, PaymentInterface $payment): PaymentFin if (null === $class) { throw new \InvalidArgumentException( - \sprintf('Payment finalization command for status %s not found.', $status) + \sprintf('Payment finalization command for status %s not found.', $status), ); } diff --git a/src/Factory/Model/TransactionBlikModelFactory.php b/src/Factory/Model/TransactionBlikModelFactory.php index b8cb979f..39168191 100644 --- a/src/Factory/Model/TransactionBlikModelFactory.php +++ b/src/Factory/Model/TransactionBlikModelFactory.php @@ -25,7 +25,7 @@ public function __construct( CustomerModelFactoryInterface $customerFactory, BillingModelFactoryInterface $billingFactory, ShippingModelFactoryInterface $shippingFactory, - RedirectFactoryInterface $redirectModelFactory + RedirectFactoryInterface $redirectModelFactory, ) { $this->customerFactory = $customerFactory; $this->billingFactory = $billingFactory; @@ -34,13 +34,13 @@ public function __construct( } public function create( - OrderInterface $order, + OrderInterface $order, ImojeClientConfigurationInterface $imojeClientConfiguration, - string $type, - string $paymentMethod, - string $paymentMethodCode, - string $serviceId, - BlikModelInterface $blikModel + string $type, + string $paymentMethod, + string $paymentMethodCode, + string $serviceId, + BlikModelInterface $blikModel, ): TransactionModelInterface { $redirectModel = $this->redirectModelFactory->create($order->getLastPayment()); $amount = $order->getTotal(); @@ -70,7 +70,7 @@ public function create( $blikCode, $customer, $billing, - $shipping + $shipping, ); } } diff --git a/src/Factory/Model/TransactionBlikModelFactoryInterface.php b/src/Factory/Model/TransactionBlikModelFactoryInterface.php index f12c7df9..9b52603f 100644 --- a/src/Factory/Model/TransactionBlikModelFactoryInterface.php +++ b/src/Factory/Model/TransactionBlikModelFactoryInterface.php @@ -14,12 +14,12 @@ interface TransactionBlikModelFactoryInterface public const SALE_TYPE = 'sale'; public function create( - OrderInterface $order, + OrderInterface $order, ImojeClientConfigurationInterface $imojeClientConfiguration, - string $type, - string $paymentMethod, - string $paymentMethodCode, - string $serviceId, - BlikModelInterface $blikModel + string $type, + string $paymentMethod, + string $paymentMethodCode, + string $serviceId, + BlikModelInterface $blikModel, ): TransactionModelInterface; } diff --git a/src/Factory/Model/TransactionModelFactory.php b/src/Factory/Model/TransactionModelFactory.php index 8cc354bc..260a8c9b 100644 --- a/src/Factory/Model/TransactionModelFactory.php +++ b/src/Factory/Model/TransactionModelFactory.php @@ -24,7 +24,7 @@ public function __construct( CustomerModelFactoryInterface $customerFactory, BillingModelFactoryInterface $billingFactory, ShippingModelFactoryInterface $shippingFactory, - RedirectFactoryInterface $redirectModelFactory + RedirectFactoryInterface $redirectModelFactory, ) { $this->customerFactory = $customerFactory; $this->billingFactory = $billingFactory; @@ -33,12 +33,12 @@ public function __construct( } public function create( - OrderInterface $order, + OrderInterface $order, ImojeClientConfigurationInterface $imojeClientConfiguration, - string $type, - string $paymentMethod, - string $paymentMethodCode, - string $serviceId + string $type, + string $paymentMethod, + string $paymentMethodCode, + string $serviceId, ): TransactionModelInterface { $redirectModel = $this->redirectModelFactory->create($order->getLastPayment()); $amount = $order->getTotal(); @@ -64,7 +64,7 @@ public function create( $failureReturnUrl, $customer, $billing, - $shipping + $shipping, ); } } diff --git a/src/Factory/Model/TransactionModelFactoryInterface.php b/src/Factory/Model/TransactionModelFactoryInterface.php index 6704c5f4..7cdcdb55 100644 --- a/src/Factory/Model/TransactionModelFactoryInterface.php +++ b/src/Factory/Model/TransactionModelFactoryInterface.php @@ -17,11 +17,11 @@ interface TransactionModelFactoryInterface public const SALE_TYPE = 'sale'; public function create( - OrderInterface $order, + OrderInterface $order, ImojeClientConfigurationInterface $imojeClientConfiguration, - string $type, - string $paymentMethod, - string $paymentMethodCode, - string $serviceId + string $type, + string $paymentMethod, + string $paymentMethodCode, + string $serviceId, ): TransactionModelInterface; } diff --git a/src/Factory/ReadyTransaction/ReadyTransactionFactory.php b/src/Factory/ReadyTransaction/ReadyTransactionFactory.php index 08618d50..47adfe0e 100644 --- a/src/Factory/ReadyTransaction/ReadyTransactionFactory.php +++ b/src/Factory/ReadyTransaction/ReadyTransactionFactory.php @@ -12,9 +12,9 @@ final class ReadyTransactionFactory implements ReadyTransactionFactoryInterface { public function createReadyTransaction( - string $contents, + string $contents, ImojeTransactionInterface $imojeTransaction, - OrderInterface $order + OrderInterface $order, ): ReadyTransactionModel { /** @var array $transactionData */ $transactionData = json_decode($contents, true); diff --git a/src/Factory/ReadyTransaction/ReadyTransactionFactoryInterface.php b/src/Factory/ReadyTransaction/ReadyTransactionFactoryInterface.php index 778a6292..e5e49bd9 100644 --- a/src/Factory/ReadyTransaction/ReadyTransactionFactoryInterface.php +++ b/src/Factory/ReadyTransaction/ReadyTransactionFactoryInterface.php @@ -11,8 +11,8 @@ interface ReadyTransactionFactoryInterface { public function createReadyTransaction( - string $contents, + string $contents, ImojeTransactionInterface $imojeTransaction, - OrderInterface $order + OrderInterface $order, ): ReadyTransactionModel; } diff --git a/src/Factory/Refund/RefundModelFactory.php b/src/Factory/Refund/RefundModelFactory.php index 90b4ed73..64cdc094 100644 --- a/src/Factory/Refund/RefundModelFactory.php +++ b/src/Factory/Refund/RefundModelFactory.php @@ -12,7 +12,7 @@ final class RefundModelFactory implements RefundModelFactoryInterface public function create( string $type, string $serviceId, - int $amount + int $amount, ): RefundModelInterface { return new RefundModel($type, $serviceId, $amount); } diff --git a/src/Factory/Refund/RefundModelFactoryInterface.php b/src/Factory/Refund/RefundModelFactoryInterface.php index 54a7c27a..bf440ef8 100644 --- a/src/Factory/Refund/RefundModelFactoryInterface.php +++ b/src/Factory/Refund/RefundModelFactoryInterface.php @@ -11,6 +11,6 @@ interface RefundModelFactoryInterface public function create( string $type, string $serviceId, - int $amount + int $amount, ): RefundModelInterface; } diff --git a/src/Factory/Request/RedirectFactory.php b/src/Factory/Request/RedirectFactory.php index 03048737..1f157bf7 100644 --- a/src/Factory/Request/RedirectFactory.php +++ b/src/Factory/Request/RedirectFactory.php @@ -48,7 +48,7 @@ private function generateRedirectUrl(string $slug, int $id): string 'status' => $slug, 'paymentId' => $id, ], - Router::ABSOLUTE_URL + Router::ABSOLUTE_URL, ); } @@ -60,7 +60,7 @@ private function generateRedirectForOneClickUrl(string $slug, int $id): string 'status' => $slug, 'paymentId' => $id, ], - Router::ABSOLUTE_URL + Router::ABSOLUTE_URL, ); } } diff --git a/src/Factory/Serializer/SerializerFactory.php b/src/Factory/Serializer/SerializerFactory.php index 0fb81f91..1a0d753c 100644 --- a/src/Factory/Serializer/SerializerFactory.php +++ b/src/Factory/Serializer/SerializerFactory.php @@ -27,8 +27,8 @@ public function createSerializerWithNormalizer(): Serializer null, new PropertyInfoExtractor( [], - [new PhpDocExtractor(), new ReflectionExtractor()] - ) + [new PhpDocExtractor(), new ReflectionExtractor()], + ), ), ]; diff --git a/src/Factory/Status/StatusResponseModelFactory.php b/src/Factory/Status/StatusResponseModelFactory.php index 3385013a..7ed6e409 100644 --- a/src/Factory/Status/StatusResponseModelFactory.php +++ b/src/Factory/Status/StatusResponseModelFactory.php @@ -13,7 +13,7 @@ public function create( string $transactionId, string $paymentId, string $orderId, - string $status + string $status, ): StatusResponseModelInterface { return new StatusResponseModel($transactionId, $paymentId, $orderId, $status); } diff --git a/src/Factory/Status/StatusResponseModelFactoryInterface.php b/src/Factory/Status/StatusResponseModelFactoryInterface.php index 6fc69cd5..7ac2cff4 100644 --- a/src/Factory/Status/StatusResponseModelFactoryInterface.php +++ b/src/Factory/Status/StatusResponseModelFactoryInterface.php @@ -12,6 +12,6 @@ public function create( string $transactionId, string $paymentId, string $orderId, - string $status + string $status, ): StatusResponseModelInterface; } diff --git a/src/Factory/Transaction/ImojeTransactionFactory.php b/src/Factory/Transaction/ImojeTransactionFactory.php index efc77c2d..97f940db 100644 --- a/src/Factory/Transaction/ImojeTransactionFactory.php +++ b/src/Factory/Transaction/ImojeTransactionFactory.php @@ -16,7 +16,7 @@ public function create( ?string $paymentUrl, string $serviceId, string $orderId, - string $gatewayCode + string $gatewayCode, ): ImojeTransactionInterface { return new ImojeTransaction($transactionId, $payment, $paymentUrl, $serviceId, $orderId, $gatewayCode); } diff --git a/src/Factory/Transaction/ImojeTransactionFactoryInterface.php b/src/Factory/Transaction/ImojeTransactionFactoryInterface.php index 76048300..8fe52e40 100644 --- a/src/Factory/Transaction/ImojeTransactionFactoryInterface.php +++ b/src/Factory/Transaction/ImojeTransactionFactoryInterface.php @@ -15,6 +15,6 @@ public function create( ?string $paymentUrl, string $serviceId, string $orderId, - string $gatewayCode + string $gatewayCode, ): ImojeTransactionInterface; } diff --git a/src/Filter/AvailablePaymentMethodsFilter.php b/src/Filter/AvailablePaymentMethodsFilter.php index 2f1733d0..1875027a 100644 --- a/src/Filter/AvailablePaymentMethodsFilter.php +++ b/src/Filter/AvailablePaymentMethodsFilter.php @@ -20,7 +20,7 @@ public function filter( string $code, string $serviceId, array $paymentMethods, - string $currency + string $currency, ): array { $paymentMethods = \array_keys($paymentMethods); diff --git a/src/Filter/AvailablePaymentMethodsFilterInterface.php b/src/Filter/AvailablePaymentMethodsFilterInterface.php index 49dc4163..6f3ab662 100644 --- a/src/Filter/AvailablePaymentMethodsFilterInterface.php +++ b/src/Filter/AvailablePaymentMethodsFilterInterface.php @@ -16,6 +16,6 @@ public function filter( string $code, string $serviceId, array $paymentMethods, - string $currency + string $currency, ): array; } diff --git a/src/Form/Extension/CompleteTypeExtension.php b/src/Form/Extension/CompleteTypeExtension.php index 0b2b6150..07fb7ed0 100644 --- a/src/Form/Extension/CompleteTypeExtension.php +++ b/src/Form/Extension/CompleteTypeExtension.php @@ -24,7 +24,7 @@ final class CompleteTypeExtension extends AbstractTypeExtension public function __construct( OrderResolverInterface $orderResolver, - OrderPaymentResolverInterface $paymentResolver + OrderPaymentResolverInterface $paymentResolver, ) { $this->orderResolver = $orderResolver; $this->paymentResolver = $paymentResolver; diff --git a/src/Form/Type/PaymentImojeType.php b/src/Form/Type/PaymentImojeType.php index 4954102c..609840ca 100644 --- a/src/Form/Type/PaymentImojeType.php +++ b/src/Form/Type/PaymentImojeType.php @@ -14,7 +14,7 @@ final class PaymentImojeType extends AbstractType private ImojePaymentsMethodResolverInterface $methodResolver; public function __construct( - ImojePaymentsMethodResolverInterface $methodResolver + ImojePaymentsMethodResolverInterface $methodResolver, ) { $this->methodResolver = $methodResolver; } diff --git a/src/Generator/Url/Status/AggregateStatusBasedUrlGenerator.php b/src/Generator/Url/Status/AggregateStatusBasedUrlGenerator.php index ca6f9242..4656d5d4 100644 --- a/src/Generator/Url/Status/AggregateStatusBasedUrlGenerator.php +++ b/src/Generator/Url/Status/AggregateStatusBasedUrlGenerator.php @@ -18,7 +18,7 @@ final class AggregateStatusBasedUrlGenerator implements AggregateStatusBasedUrlG public function __construct( iterable $processors, - UrlGeneratorInterface $urlGenerator + UrlGeneratorInterface $urlGenerator, ) { $this->generators = $processors; $this->urlGenerator = $urlGenerator; @@ -27,7 +27,7 @@ public function __construct( public function generate( OrderInterface $order, Request $request, - string $status + string $status, ): string { /** @var StatusBasedUrlGeneratorInterface $generator */ foreach ($this->generators as $generator) { diff --git a/src/Generator/Url/Status/AggregateStatusBasedUrlGeneratorInterface.php b/src/Generator/Url/Status/AggregateStatusBasedUrlGeneratorInterface.php index 9985ad58..2ec81050 100644 --- a/src/Generator/Url/Status/AggregateStatusBasedUrlGeneratorInterface.php +++ b/src/Generator/Url/Status/AggregateStatusBasedUrlGeneratorInterface.php @@ -12,6 +12,6 @@ interface AggregateStatusBasedUrlGeneratorInterface public function generate( OrderInterface $order, Request $request, - string $status + string $status, ): string; } diff --git a/src/Generator/Url/Status/CanceledStatusUrlGenerator.php b/src/Generator/Url/Status/CanceledStatusUrlGenerator.php index aa62840c..fae0ce9c 100644 --- a/src/Generator/Url/Status/CanceledStatusUrlGenerator.php +++ b/src/Generator/Url/Status/CanceledStatusUrlGenerator.php @@ -22,7 +22,7 @@ final class CanceledStatusUrlGenerator implements StatusBasedUrlGeneratorInterfa public function __construct( TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator + UrlGeneratorInterface $urlGenerator, ) { $this->translator = $translator; $this->urlGenerator = $urlGenerator; @@ -43,7 +43,7 @@ public function generate(Request $request, OrderInterface $order): string return $this->urlGenerator->generate( self::SYLIUS_SHOP_ORDER_SHOW, - ['tokenValue' => $order->getTokenValue()] + ['tokenValue' => $order->getTokenValue()], ); } } diff --git a/src/Generator/Url/Status/FailedStatusUrlGenerator.php b/src/Generator/Url/Status/FailedStatusUrlGenerator.php index 61ca5d3c..ecce9d49 100644 --- a/src/Generator/Url/Status/FailedStatusUrlGenerator.php +++ b/src/Generator/Url/Status/FailedStatusUrlGenerator.php @@ -41,7 +41,7 @@ public function generate(Request $request, OrderInterface $order): string return $this->urlGenerator->generate( self::SYLIUS_SHOP_ORDER_SHOW, - ['tokenValue' => $order->getTokenValue()] + ['tokenValue' => $order->getTokenValue()], ); } } diff --git a/src/Generator/Url/Status/SuccessfulStatusUrlGenerator.php b/src/Generator/Url/Status/SuccessfulStatusUrlGenerator.php index fd7bee0d..05475b12 100644 --- a/src/Generator/Url/Status/SuccessfulStatusUrlGenerator.php +++ b/src/Generator/Url/Status/SuccessfulStatusUrlGenerator.php @@ -33,7 +33,7 @@ public function generate(Request $request, OrderInterface $order): string return $this->urlGenerator->generate( self::SYLIUS_SHOP_ORDER_THANK_YOU, - ['tokenValue' => $order->getTokenValue()] + ['tokenValue' => $order->getTokenValue()], ); } } diff --git a/src/Model/BillingModel.php b/src/Model/BillingModel.php index 83fd37ee..0b57aa08 100644 --- a/src/Model/BillingModel.php +++ b/src/Model/BillingModel.php @@ -27,7 +27,7 @@ public function __construct( ?string $street, ?string $city, ?string $region, - ?string $postalCode + ?string $postalCode, ) { $this->firstName = $firstName; $this->lastName = $lastName; diff --git a/src/Model/CustomerModel.php b/src/Model/CustomerModel.php index ce7550b5..0ed48ab4 100644 --- a/src/Model/CustomerModel.php +++ b/src/Model/CustomerModel.php @@ -27,7 +27,7 @@ public function __construct( ?string $company, ?string $phone, string $email, - ?string $locale + ?string $locale, ) { $this->firstName = $firstName; $this->lastName = $lastName; diff --git a/src/Model/ReadyTransaction/ReadyTransactionModel.php b/src/Model/ReadyTransaction/ReadyTransactionModel.php index 410a1ef3..e2769a32 100644 --- a/src/Model/ReadyTransaction/ReadyTransactionModel.php +++ b/src/Model/ReadyTransaction/ReadyTransactionModel.php @@ -16,9 +16,9 @@ final class ReadyTransactionModel implements ReadyTransactionModelInterface private OrderInterface $order; public function __construct( - string $status, + string $status, ImojeTransactionInterface $imojeTransaction, - OrderInterface $order + OrderInterface $order, ) { $this->status = $status; $this->imojeTransaction = $imojeTransaction; diff --git a/src/Model/Refund/RefundModel.php b/src/Model/Refund/RefundModel.php index cab4b8f3..2dec48ad 100644 --- a/src/Model/Refund/RefundModel.php +++ b/src/Model/Refund/RefundModel.php @@ -15,7 +15,7 @@ final class RefundModel implements RefundModelInterface public function __construct( string $type, string $serviceId, - int $amount + int $amount, ) { $this->type = $type; $this->serviceId = $serviceId; diff --git a/src/Model/ShippingModel.php b/src/Model/ShippingModel.php index acfac4c8..8b5340d9 100644 --- a/src/Model/ShippingModel.php +++ b/src/Model/ShippingModel.php @@ -27,7 +27,7 @@ public function __construct( ?string $street, ?string $city, ?string $region, - ?string $postalCode + ?string $postalCode, ) { $this->firstName = $firstName; $this->lastName = $lastName; diff --git a/src/Model/Status/StatusResponseModel.php b/src/Model/Status/StatusResponseModel.php index 8620ea94..1ae42988 100644 --- a/src/Model/Status/StatusResponseModel.php +++ b/src/Model/Status/StatusResponseModel.php @@ -18,7 +18,7 @@ public function __construct( string $transactionId, string $paymentId, string $orderId, - string $status + string $status, ) { $this->transactionId = $transactionId; $this->paymentId = $paymentId; diff --git a/src/Model/TransactionBlikModel.php b/src/Model/TransactionBlikModel.php index e10ae78f..6e249921 100644 --- a/src/Model/TransactionBlikModel.php +++ b/src/Model/TransactionBlikModel.php @@ -51,7 +51,7 @@ public function __construct( ?string $blikCode, CustomerModelInterface $customer, ?BillingModelInterface $billing, - ?ShippingModelInterface $shipping + ?ShippingModelInterface $shipping, ) { $this->type = $type; $this->serviceId = $serviceId; diff --git a/src/Model/TransactionModel.php b/src/Model/TransactionModel.php index 362c8ac0..a585310c 100644 --- a/src/Model/TransactionModel.php +++ b/src/Model/TransactionModel.php @@ -45,7 +45,7 @@ public function __construct( string $failureReturnUrl, CustomerModelInterface $customer, ?BillingModelInterface $billing, - ?ShippingModelInterface $shipping + ?ShippingModelInterface $shipping, ) { $this->type = $type; $this->serviceId = $serviceId; diff --git a/src/Processor/Webhook/Status/WebhookResponseProcessor.php b/src/Processor/Webhook/Status/WebhookResponseProcessor.php index 0ebed605..21ece444 100644 --- a/src/Processor/Webhook/Status/WebhookResponseProcessor.php +++ b/src/Processor/Webhook/Status/WebhookResponseProcessor.php @@ -27,7 +27,7 @@ public function __construct( PaymentFinalizationCommandFactoryInterface $commandFactory, DispatcherInterface $dispatcher, LoggerInterface $logger, - StatusResolverInterface $statusResolver + StatusResolverInterface $statusResolver, ) { $this->commandFactory = $commandFactory; $this->dispatcher = $dispatcher; @@ -45,7 +45,7 @@ public function process(StatusResponseModelInterface $response, PaymentInterface } $this->logger->debug( - \sprintf('Dispatching payment finalization command for status: %s', $response->getStatus()) + \sprintf('Dispatching payment finalization command for status: %s', $response->getStatus()), ); $this->finalizeOrderIfNotAlreadyComplete($payment); @@ -60,7 +60,7 @@ private function logOnError(string $transactionId, string $statusCode): void $this->logger->error(\sprintf( 'Got failure for transaction [%s]. Payment status code: [%s]', $transactionId, - $statusCode + $statusCode, )); } diff --git a/src/Provider/ImojeClientConfigurationProvider.php b/src/Provider/ImojeClientConfigurationProvider.php index b001b933..4b68016b 100644 --- a/src/Provider/ImojeClientConfigurationProvider.php +++ b/src/Provider/ImojeClientConfigurationProvider.php @@ -12,8 +12,7 @@ use Payum\Core\Model\GatewayConfigInterface; use Sylius\Component\Core\Model\PaymentMethodInterface; -final class -ImojeClientConfigurationProvider implements ImojeClientConfigurationProviderInterface +final class ImojeClientConfigurationProvider implements ImojeClientConfigurationProviderInterface { private PaymentMethodRepositoryInterface $paymentMethodRepository; @@ -21,7 +20,7 @@ final class public function __construct( PaymentMethodRepositoryInterface $paymentMethodRepository, - ConfigurationResolverInterface $configurationResolver + ConfigurationResolverInterface $configurationResolver, ) { $this->paymentMethodRepository = $paymentMethodRepository; $this->configurationResolver = $configurationResolver; @@ -33,7 +32,7 @@ public function getPaymentMethodConfiguration(string $code): ImojeClientConfigur if (null === $paymentMethod) { throw new ImojeNotConfiguredException( - \sprintf('Payment method with code %s is not configured', $code) + \sprintf('Payment method with code %s is not configured', $code), ); } diff --git a/src/Provider/ImojeClientProvider.php b/src/Provider/ImojeClientProvider.php index 384d9a1c..c01f35dc 100644 --- a/src/Provider/ImojeClientProvider.php +++ b/src/Provider/ImojeClientProvider.php @@ -22,6 +22,7 @@ final class ImojeClientProvider implements ImojeClientProviderInterface private SerializerFactoryInterface $serializerFactory; private RequestFactoryInterface $requestFactoryInterface; + private StreamFactoryInterface $streamFactoryInterface; public function __construct( @@ -30,7 +31,7 @@ public function __construct( RequestParamsProviderInterface $requestParamsProvider, SerializerFactoryInterface $serializerFactory, RequestFactoryInterface $requestFactoryInterface, - StreamFactoryInterface $streamFactoryInterface + StreamFactoryInterface $streamFactoryInterface, ) { $this->imojeClientConfigurationProvider = $imojeClientConfigurationProvider; $this->httpClient = $httpClient; diff --git a/src/Provider/RequestParams/RequestParamsProvider.php b/src/Provider/RequestParams/RequestParamsProvider.php index efc48515..1ab541c2 100644 --- a/src/Provider/RequestParams/RequestParamsProvider.php +++ b/src/Provider/RequestParams/RequestParamsProvider.php @@ -16,7 +16,7 @@ final class RequestParamsProvider implements RequestParamsProviderInterface public function __construct( SerializerFactoryInterface $serializerFactory, - RefundModelFactoryInterface $refundModelFactory + RefundModelFactoryInterface $refundModelFactory, ) { $this->serializerFactory = $serializerFactory; $this->refundModelFactory = $refundModelFactory; @@ -39,7 +39,7 @@ public function buildAuthorizeRequest(string $token): array public function buildRequestRefundParams( string $token, string $serviceId, - int $amount + int $amount, ): array { $serializer = $this->serializerFactory->createSerializerWithNormalizer(); $request = $this->addAuthorizationHeaders($token); diff --git a/src/Provider/RequestParams/RequestParamsProviderInterface.php b/src/Provider/RequestParams/RequestParamsProviderInterface.php index 5e38a5bc..fbc0d7b2 100644 --- a/src/Provider/RequestParams/RequestParamsProviderInterface.php +++ b/src/Provider/RequestParams/RequestParamsProviderInterface.php @@ -15,6 +15,6 @@ public function buildAuthorizeRequest(string $token): array; public function buildRequestRefundParams( string $token, string $serviceId, - int $amount + int $amount, ): array; } diff --git a/src/Refund/ImojeRefundStep.php b/src/Refund/ImojeRefundStep.php index 74d9390e..588e3b16 100644 --- a/src/Refund/ImojeRefundStep.php +++ b/src/Refund/ImojeRefundStep.php @@ -27,11 +27,11 @@ final class ImojeRefundStep implements UnitsRefundedProcessStepInterface private RefundUrlResolverInterface $refundUrlResolver; public function __construct( - ImojeClientProviderInterface $imojeClientProvider, - OrderRepositoryInterface $orderRepository, - GatewayFactoryNameResolverInterface $gatewayFactoryNameResolver, + ImojeClientProviderInterface $imojeClientProvider, + OrderRepositoryInterface $orderRepository, + GatewayFactoryNameResolverInterface $gatewayFactoryNameResolver, ImojeClientConfigurationProviderInterface $imojeClientConfigurationProvider, - RefundUrlResolverInterface $refundUrlResolver + RefundUrlResolverInterface $refundUrlResolver, ) { $this->imojeClientProvider = $imojeClientProvider; $this->orderRepository = $orderRepository; diff --git a/src/Repository/ImojeTransaction/ImojeTransactionRepository.php b/src/Repository/ImojeTransaction/ImojeTransactionRepository.php index 48ddc81b..e95fc908 100644 --- a/src/Repository/ImojeTransaction/ImojeTransactionRepository.php +++ b/src/Repository/ImojeTransaction/ImojeTransactionRepository.php @@ -20,7 +20,7 @@ public function getByPaymentId(int $paymentId): ImojeTransaction ->setParameter('paymentId', $paymentId) ->getQuery() ->getResult() - ; + ; if (null === $transaction) { throw new NoTransactionException('Could not find transaction'); diff --git a/src/Repository/PaymentMethodRepository.php b/src/Repository/PaymentMethodRepository.php index 780bc496..7a24bb96 100644 --- a/src/Repository/PaymentMethodRepository.php +++ b/src/Repository/PaymentMethodRepository.php @@ -28,7 +28,7 @@ public function findOneForImojeCode(string $code): ?PaymentMethodInterface ->setParameter('code', $code) ->getQuery() ->getOneOrNullResult() - ; + ; } public function findOneForImoje(): ?PaymentMethodInterface @@ -39,7 +39,8 @@ public function findOneForImoje(): ?PaymentMethodInterface ->setParameter('factoryName', self::FACTORY_NAME) ->getQuery() ->getResult() - ; + ; + return $result[0]; } } diff --git a/src/Resolver/GatewayCode/GatewayCodeFromOrderResolver.php b/src/Resolver/GatewayCode/GatewayCodeFromOrderResolver.php index b3f8a568..936b5735 100644 --- a/src/Resolver/GatewayCode/GatewayCodeFromOrderResolver.php +++ b/src/Resolver/GatewayCode/GatewayCodeFromOrderResolver.php @@ -17,7 +17,7 @@ final class GatewayCodeFromOrderResolver implements GatewayCodeFromOrderResolver public function __construct( ImojeClientConfigurationProviderInterface $imojeClientConfigurationProvider, - OrderPaymentResolverInterface $orderPaymentResolver + OrderPaymentResolverInterface $orderPaymentResolver, ) { $this->imojeClientConfigurationProvider = $imojeClientConfigurationProvider; $this->orderPaymentResolver = $orderPaymentResolver; diff --git a/src/Resolver/ImojeOneClickSignature/ImojeOneClickSignatureResolver.php b/src/Resolver/ImojeOneClickSignature/ImojeOneClickSignatureResolver.php index 6b742cc2..707ec890 100644 --- a/src/Resolver/ImojeOneClickSignature/ImojeOneClickSignatureResolver.php +++ b/src/Resolver/ImojeOneClickSignature/ImojeOneClickSignatureResolver.php @@ -19,7 +19,7 @@ public function resolve(array $orderData, ImojeClientConfigurationInterface $con private function prepareData( array $data, - string $prefix = '' + string $prefix = '', ): string { \ksort($data); $hashData = []; diff --git a/src/Resolver/Order/OrderResolver.php b/src/Resolver/Order/OrderResolver.php index fb71bb9b..59e68481 100644 --- a/src/Resolver/Order/OrderResolver.php +++ b/src/Resolver/Order/OrderResolver.php @@ -18,7 +18,7 @@ final class OrderResolver implements OrderResolverInterface public function __construct( CartContextInterface $cartContext, - OrderRepositoryInterface $orderRepository + OrderRepositoryInterface $orderRepository, ) { $this->cartContext = $cartContext; $this->orderRepository = $orderRepository; diff --git a/src/Resolver/Payment/ImojePaymentsMethodResolver.php b/src/Resolver/Payment/ImojePaymentsMethodResolver.php index 7d308e25..c14ebe30 100644 --- a/src/Resolver/Payment/ImojePaymentsMethodResolver.php +++ b/src/Resolver/Payment/ImojePaymentsMethodResolver.php @@ -25,7 +25,7 @@ public function __construct( PaymentMethodRepositoryInterface $paymentMethodRepository, AvailablePaymentMethodsFilterInterface $paymentMethodsFilter, TotalResolverInterface $totalResolver, - CartContextInterface $cartContext + CartContextInterface $cartContext, ) { $this->paymentMethodRepository = $paymentMethodRepository; $this->paymentMethodsFilter = $paymentMethodsFilter; diff --git a/src/Resolver/Payment/ImojeTransactionPaymentResolver.php b/src/Resolver/Payment/ImojeTransactionPaymentResolver.php index 2813a4c4..80f496cc 100644 --- a/src/Resolver/Payment/ImojeTransactionPaymentResolver.php +++ b/src/Resolver/Payment/ImojeTransactionPaymentResolver.php @@ -12,7 +12,7 @@ final class ImojeTransactionPaymentResolver implements ImojeTransactionPaymentRe private ImojeTransactionRepositoryInterface $transactionRepository; public function __construct( - ImojeTransactionRepositoryInterface $transactionRepository + ImojeTransactionRepositoryInterface $transactionRepository, ) { $this->transactionRepository = $transactionRepository; } diff --git a/src/Resolver/Payment/OrderPaymentResolver.php b/src/Resolver/Payment/OrderPaymentResolver.php index 3090a268..18e47cee 100644 --- a/src/Resolver/Payment/OrderPaymentResolver.php +++ b/src/Resolver/Payment/OrderPaymentResolver.php @@ -18,7 +18,7 @@ public function resolve(OrderInterface $order): PaymentInterface if (null === $payment) { throw new \InvalidArgumentException( - \sprintf('Order #%d has no payable transaction associated with it.', (int) $order->getId()) + \sprintf('Order #%d has no payable transaction associated with it.', (int) $order->getId()), ); } diff --git a/src/Resolver/Payment/TransactionPaymentDataResolver.php b/src/Resolver/Payment/TransactionPaymentDataResolver.php index d4375d40..70f4dcd5 100644 --- a/src/Resolver/Payment/TransactionPaymentDataResolver.php +++ b/src/Resolver/Payment/TransactionPaymentDataResolver.php @@ -17,7 +17,7 @@ final class TransactionPaymentDataResolver implements TransactionPaymentDataReso public function __construct( PaymentDataModelFactoryInterface $paymentDataModelFactory, - PaymentMethodByCodeResolver $paymentMethodByCodeResolver + PaymentMethodByCodeResolver $paymentMethodByCodeResolver, ) { $this->paymentDataModelFactory = $paymentDataModelFactory; $this->paymentMethodByCodeResolver = $paymentMethodByCodeResolver; @@ -26,7 +26,7 @@ public function __construct( public function resolve( ?string $paymentMethodCode, PaymentInterface $payment, - ?string $blikCode + ?string $blikCode, ): PaymentDataModelInterface { if (null === $blikCode) { $isBlik = 'blik' === implode($payment->getDetails()); diff --git a/src/Resolver/Payment/TransactionPaymentDataResolverInterface.php b/src/Resolver/Payment/TransactionPaymentDataResolverInterface.php index 8b319082..a6e5d3f7 100644 --- a/src/Resolver/Payment/TransactionPaymentDataResolverInterface.php +++ b/src/Resolver/Payment/TransactionPaymentDataResolverInterface.php @@ -12,6 +12,6 @@ interface TransactionPaymentDataResolverInterface public function resolve( ?string $paymentMethodCode, PaymentInterface $payment, - ?string $blikCode + ?string $blikCode, ): PaymentDataModelInterface; } diff --git a/src/Resolver/Signature/OwnSignatureResolver.php b/src/Resolver/Signature/OwnSignatureResolver.php index d8ce15d8..6446046b 100644 --- a/src/Resolver/Signature/OwnSignatureResolver.php +++ b/src/Resolver/Signature/OwnSignatureResolver.php @@ -19,7 +19,7 @@ final class OwnSignatureResolver implements OwnSignatureResolverInterface public function __construct( RequestStack $requestStack, GatewayCodeResolverInterface $gatewayCodeResolver, - ImojeClientConfigurationProviderInterface $configurationProvider + ImojeClientConfigurationProviderInterface $configurationProvider, ) { $this->requestStack = $requestStack; $this->gatewayCodeResolver = $gatewayCodeResolver; diff --git a/src/Resolver/Signature/SignatureResolver.php b/src/Resolver/Signature/SignatureResolver.php index 9170d907..1a3ca593 100644 --- a/src/Resolver/Signature/SignatureResolver.php +++ b/src/Resolver/Signature/SignatureResolver.php @@ -22,7 +22,7 @@ public function resolve(): string if (!\preg_match(self::SIGNATURE_REGEX, $headerSignature, $matches)) { throw new InvalidSignatureException( - \sprintf('Invalid signature: [%s]', $headerSignature) + \sprintf('Invalid signature: [%s]', $headerSignature), ); } @@ -31,7 +31,7 @@ public function resolve(): string if (self::SIGNATURE_ALG !== $alg) { throw new InvalidSignatureException( - \sprintf('Invalid hash algorithm: [%s]', $headerSignature) + \sprintf('Invalid hash algorithm: [%s]', $headerSignature), ); } diff --git a/src/Resolver/TotalResolver/TotalResolver.php b/src/Resolver/TotalResolver/TotalResolver.php index 6849702b..778586e0 100644 --- a/src/Resolver/TotalResolver/TotalResolver.php +++ b/src/Resolver/TotalResolver/TotalResolver.php @@ -20,7 +20,7 @@ final class TotalResolver implements TotalResolverInterface public function __construct( CartContextInterface $cartContext, RequestStack $requestStack, - OrderRepositoryInterface $orderRepository + OrderRepositoryInterface $orderRepository, ) { $this->cartContext = $cartContext; $this->requestStack = $requestStack; diff --git a/src/Resolver/Url/UrlResolver.php b/src/Resolver/Url/UrlResolver.php index abac24f8..cc9f577b 100644 --- a/src/Resolver/Url/UrlResolver.php +++ b/src/Resolver/Url/UrlResolver.php @@ -13,9 +13,9 @@ final class UrlResolver implements UrlResolverInterface { public function resolve( - ImojeTransactionInterface $imojeTransaction, + ImojeTransactionInterface $imojeTransaction, ImojeClientConfigurationProviderInterface $imojeClientConfiguration, - ImojeClientProviderInterface $imojeClientProvider + ImojeClientProviderInterface $imojeClientProvider, ): string { $code = $imojeTransaction->getGatewayCode(); $config = $imojeClientConfiguration->getPaymentMethodConfiguration($code); @@ -26,8 +26,8 @@ public function resolve( private function createUrl( ImojeClientConfigurationInterface $config, - ImojeTransactionInterface $imojeTransaction, - ImojeApiClientInterface $client + ImojeTransactionInterface $imojeTransaction, + ImojeApiClientInterface $client, ): string { if ($config->isProd()) { return \sprintf( @@ -35,7 +35,7 @@ private function createUrl( $config->getProdUrl(), $config->getMerchantId(), $client::TRANSACTION_ENDPOINT, - $imojeTransaction->getTransactionId() + $imojeTransaction->getTransactionId(), ); } @@ -44,7 +44,7 @@ private function createUrl( $config->getSandboxUrl(), $config->getMerchantId(), $client::TRANSACTION_ENDPOINT, - $imojeTransaction->getTransactionId() + $imojeTransaction->getTransactionId(), ); } } diff --git a/src/Resolver/Url/UrlResolverInterface.php b/src/Resolver/Url/UrlResolverInterface.php index e7f1e678..2c713384 100644 --- a/src/Resolver/Url/UrlResolverInterface.php +++ b/src/Resolver/Url/UrlResolverInterface.php @@ -11,8 +11,8 @@ interface UrlResolverInterface { public function resolve( - ImojeTransactionInterface $imojeTransaction, + ImojeTransactionInterface $imojeTransaction, ImojeClientConfigurationProviderInterface $imojeClientConfiguration, - ImojeClientProviderInterface $imojeClientProvider + ImojeClientProviderInterface $imojeClientProvider, ): string; } diff --git a/src/Resolver/Webhook/OneClickWebhookResolver.php b/src/Resolver/Webhook/OneClickWebhookResolver.php index 2472055b..e0f84a49 100644 --- a/src/Resolver/Webhook/OneClickWebhookResolver.php +++ b/src/Resolver/Webhook/OneClickWebhookResolver.php @@ -38,15 +38,15 @@ final class OneClickWebhookResolver implements oneClickWebhookResolverInterface private WebhookResponseProcessorInterface $webhookResponseProcessor; public function __construct( - RequestStack $requestStack, - ImojeTransactionFactoryInterface $imojeTransactionFactory, - OrderRepositoryInterface $orderRepository, + RequestStack $requestStack, + ImojeTransactionFactoryInterface $imojeTransactionFactory, + OrderRepositoryInterface $orderRepository, ImojeClientConfigurationProviderInterface $imojeClientConfigurationProvider, - DispatcherInterface $dispatcher, - PaymentMethodResolverInterface $paymentMethodResolver, - OrderPaymentResolverInterface $orderPaymentResolver, - StatusResponseModelFactoryInterface $statusResponseModelFactory, - WebhookResponseProcessorInterface $webhookResponseProcessor + DispatcherInterface $dispatcher, + PaymentMethodResolverInterface $paymentMethodResolver, + OrderPaymentResolverInterface $orderPaymentResolver, + StatusResponseModelFactoryInterface $statusResponseModelFactory, + WebhookResponseProcessorInterface $webhookResponseProcessor, ) { $this->requestStack = $requestStack; $this->imojeTransactionFactory = $imojeTransactionFactory; @@ -96,7 +96,7 @@ public function resolve(): bool null, $config->getServiceId(), $orderId, - $gatewayCode + $gatewayCode, ); $this->dispatcher->dispatch(new SaveTransaction($transaction)); From 080c67cbdea43efdb0d8aad6c980042ec54ab7ba Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Tue, 23 Jul 2024 11:17:03 +0200 Subject: [PATCH 06/12] OP-366 - Add fix for phpUnit tests --- tests/Unit/Client/ImojeApiClientTest.php | 115 +++++++++++++++++++---- 1 file changed, 98 insertions(+), 17 deletions(-) diff --git a/tests/Unit/Client/ImojeApiClientTest.php b/tests/Unit/Client/ImojeApiClientTest.php index 8225f922..0b90aa9e 100644 --- a/tests/Unit/Client/ImojeApiClientTest.php +++ b/tests/Unit/Client/ImojeApiClientTest.php @@ -12,11 +12,19 @@ use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; +use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\StreamInterface; use Symfony\Component\Serializer\Serializer; final class ImojeApiClientTest extends TestCase { - private Client $httpClient; + private ClientInterface $httpClient; private RequestParamsProviderInterface $requestParamsProvider; @@ -31,26 +39,33 @@ final class ImojeApiClientTest extends TestCase protected function setUp(): void { // I'm using a mockBuilder because these methods are added via annotations - $this->httpClient = $this->getMockBuilder(Client::class)->addMethods(['post'])->getMock(); + $this->httpClient = $this->getMockBuilder(ClientInterface::class)->getMock(); $this->requestParamsProvider = $this->createMock(RequestParamsProviderInterface::class); $this->serializer = $this->createMock(Serializer::class); + $this->requestFactory = $this->createMock(RequestFactoryInterface::class); + $this->streamFactory = $this->createMock(StreamFactoryInterface::class); $this->imojeApiClient = new ImojeApiClient( $this->httpClient, $this->requestParamsProvider, $this->serializer, self::TOKEN, - self::URL + self::URL, + $this->requestFactory, + $this->streamFactory ); } public function testCreateTransaction(): void { $transactionModel = $this->createMock(TransactionModelInterface::class); + $request = $this->createMock(RequestInterface::class); + $stream = $this->createMock(StreamInterface::class); + $response = $this->createMock(ResponseInterface::class); $parameters['body'] = 'model'; $parameters['headers'] = [ - 'Accept' => 'application/json', + 'Accept'=> 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Bearer token', ]; @@ -60,39 +75,105 @@ public function testCreateTransaction(): void ->method('buildRequestParams') ->willReturn($parameters); + $this->streamFactory + ->expects(self::once()) + ->method('createStream') + ->with($parameters['body']) + ->willReturn($stream); + + $request + ->expects(self::exactly(3)) + ->method('withHeader') + ->withConsecutive( + ['Accept', 'application/json'], + ['Content-Type', 'application/json'], + ['Authorization', 'Bearer token'] + ) + ->willReturnSelf(); + + $request + ->expects(self::once()) + ->method('withBody') + ->with($stream) + ->willReturnSelf(); + + $this->requestFactory + ->expects(self::once()) + ->method('createRequest') + ->with('POST', 'url/transaction') + ->willReturn($request); + + $response + ->expects($this->once()) + ->method('getStatusCode') + ->willReturn(200); + $this->httpClient ->expects($this->once()) - ->method('post') - ->with('url/transaction', $parameters) - ->willReturn(new Response()); + ->method('sendRequest') + ->with($request) + ->willReturn($response); $result = $this->imojeApiClient->createTransaction($transactionModel); - self::assertEquals($result->getStatusCode(), 200); + self::assertEquals(200, $result->getStatusCode()); } + public function testCreateTransactionWithException(): void { $transactionModel = $this->createMock(TransactionModelInterface::class); - $exception = $this->createMock(GuzzleException::class); + $exception = $this->createMock(ClientExceptionInterface::class); + $request = $this->createMock(RequestInterface::class); + $stream = $this->createMock(StreamInterface::class); + + $parameters = [ + 'body' => 'model', + 'headers' =>[ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + 'Authorization' => 'Bearer token', + ] - $parameters['body'] = 'model'; - $parameters['headers'] = [ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'Authorization' => 'Bearer token', ]; $this->requestParamsProvider ->expects($this->once()) ->method('buildRequestParams') ->willReturn($parameters); + $this->streamFactory + ->expects(self::once()) + ->method('createStream') + ->with($parameters['body']) + ->willReturn($stream); + + $request + ->expects(self::exactly(3)) + ->method('withHeader') + ->withConsecutive( + ['Accept', 'application/json'], + ['Content-Type', 'application/json'], + ['Authorization', 'Bearer token'] + ) + ->willReturnSelf(); + + $request + ->expects(self::once()) + ->method('withBody') + ->with($stream) + ->willReturnSelf(); + + $this->requestFactory + ->expects(self::once()) + ->method('createRequest') + ->with('POST', 'url/transaction') + ->willReturn($request); $this->httpClient ->expects($this->once()) - ->method('post') - ->with('url/transaction', $parameters) - ->will($this->throwException($exception)); + ->method('sendRequest') + ->with($request) + ->willThrowException($exception); $this->expectException(ImojeBadRequestException::class); From 9c76faccdab9b380c168ecab516385edd8dd2aac Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Tue, 23 Jul 2024 11:17:30 +0200 Subject: [PATCH 07/12] OP-366 - Apply ECS Fixes --- tests/Unit/Client/ImojeApiClientTest.php | 18 ++++++------------ .../Resolver/Customer/CustomerResolverTest.php | 1 - .../Unit/Resolver/Order/OrderResolverTest.php | 2 +- .../Payment/ImojePaymentMethodResolverTest.php | 12 +++++------- .../Signature/OwnSignatureResolverTest.php | 2 +- .../TransactionDataResolverTest.php | 4 +--- .../TransactionMethodResolverTest.php | 4 ++-- tests/Unit/Resolver/Url/UrlResolverTest.php | 4 ++-- .../Resolver/Webhook/WebhookResolverTest.php | 4 ++-- 9 files changed, 20 insertions(+), 31 deletions(-) diff --git a/tests/Unit/Client/ImojeApiClientTest.php b/tests/Unit/Client/ImojeApiClientTest.php index 0b90aa9e..c41c3a06 100644 --- a/tests/Unit/Client/ImojeApiClientTest.php +++ b/tests/Unit/Client/ImojeApiClientTest.php @@ -8,11 +8,7 @@ use BitBag\SyliusImojePlugin\Exception\ImojeBadRequestException; use BitBag\SyliusImojePlugin\Model\TransactionModelInterface; use BitBag\SyliusImojePlugin\Provider\RequestParams\RequestParamsProviderInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Exception\GuzzleException; -use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; @@ -51,7 +47,7 @@ protected function setUp(): void self::TOKEN, self::URL, $this->requestFactory, - $this->streamFactory + $this->streamFactory, ); } @@ -65,7 +61,7 @@ public function testCreateTransaction(): void $parameters['body'] = 'model'; $parameters['headers'] = [ - 'Accept'=> 'application/json', + 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Bearer token', ]; @@ -87,7 +83,7 @@ public function testCreateTransaction(): void ->withConsecutive( ['Accept', 'application/json'], ['Content-Type', 'application/json'], - ['Authorization', 'Bearer token'] + ['Authorization', 'Bearer token'], ) ->willReturnSelf(); @@ -119,7 +115,6 @@ public function testCreateTransaction(): void self::assertEquals(200, $result->getStatusCode()); } - public function testCreateTransactionWithException(): void { $transactionModel = $this->createMock(TransactionModelInterface::class); @@ -129,12 +124,11 @@ public function testCreateTransactionWithException(): void $parameters = [ 'body' => 'model', - 'headers' =>[ + 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Bearer token', - ] - + ], ]; $this->requestParamsProvider @@ -153,7 +147,7 @@ public function testCreateTransactionWithException(): void ->withConsecutive( ['Accept', 'application/json'], ['Content-Type', 'application/json'], - ['Authorization', 'Bearer token'] + ['Authorization', 'Bearer token'], ) ->willReturnSelf(); diff --git a/tests/Unit/Resolver/Customer/CustomerResolverTest.php b/tests/Unit/Resolver/Customer/CustomerResolverTest.php index aff88418..286fe958 100644 --- a/tests/Unit/Resolver/Customer/CustomerResolverTest.php +++ b/tests/Unit/Resolver/Customer/CustomerResolverTest.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\TestCase; use Sylius\Component\Core\Model\AddressInterface; use Sylius\Component\Core\Model\Customer; -use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Core\Model\OrderInterface; final class CustomerResolverTest extends TestCase diff --git a/tests/Unit/Resolver/Order/OrderResolverTest.php b/tests/Unit/Resolver/Order/OrderResolverTest.php index 0f0481e2..214e14d2 100644 --- a/tests/Unit/Resolver/Order/OrderResolverTest.php +++ b/tests/Unit/Resolver/Order/OrderResolverTest.php @@ -31,7 +31,7 @@ protected function setUp(): void $this->resolver = new OrderResolver( $this->context, - $this->repository + $this->repository, ); } diff --git a/tests/Unit/Resolver/Payment/ImojePaymentMethodResolverTest.php b/tests/Unit/Resolver/Payment/ImojePaymentMethodResolverTest.php index ee03cc7a..3dc36225 100644 --- a/tests/Unit/Resolver/Payment/ImojePaymentMethodResolverTest.php +++ b/tests/Unit/Resolver/Payment/ImojePaymentMethodResolverTest.php @@ -74,7 +74,7 @@ public function testResolveWithNewPayment(): void ->willReturn([ 'pbl' => 'pbl', 'ing' => 'ing', - 'ipko' => 'ipko' + 'ipko' => 'ipko', ]); $paymentMethod = new PaymentMethod(); @@ -112,7 +112,7 @@ public function testResolveWithNewPayment(): void $this->paymentMethodRepository, $this->paymentMethodsFilter, $this->totalResolver, - $this->cartContext + $this->cartContext, ); self::assertEqualsCanonicalizing($finalConfig, $imojePaymentsMethodResolver->resolve()); @@ -143,15 +143,15 @@ public function testResolveEmptyPaymentException(): void ->method('findOneForImoje') ->willReturn(null); - $imojePaymentsMethodResolver = new ImojePaymentsMethodResolver( $this->paymentMethodRepository, $this->paymentMethodsFilter, $this->totalResolver, - $this->cartContext + $this->cartContext, ); $imojePaymentsMethodResolver->resolve(); } + public function testResolveEmptyConfigException(): void { $this->expectException(ImojeNotConfiguredException::class); @@ -169,7 +169,6 @@ public function testResolveEmptyConfigException(): void ->method('getCart') ->willReturn($order); - $order ->expects(self::once()) ->method('getCurrencyCode') @@ -183,7 +182,6 @@ public function testResolveEmptyConfigException(): void ->method('findOneForImoje') ->willReturn($paymentMethod); - $paymentMethodMock ->method('getGatewayConfig') ->willReturn(null); @@ -192,7 +190,7 @@ public function testResolveEmptyConfigException(): void $this->paymentMethodRepository, $this->paymentMethodsFilter, $this->totalResolver, - $this->cartContext + $this->cartContext, ); $imojePaymentsMethodResolver->resolve(); } diff --git a/tests/Unit/Resolver/Signature/OwnSignatureResolverTest.php b/tests/Unit/Resolver/Signature/OwnSignatureResolverTest.php index 10641cd1..b2f75ff5 100644 --- a/tests/Unit/Resolver/Signature/OwnSignatureResolverTest.php +++ b/tests/Unit/Resolver/Signature/OwnSignatureResolverTest.php @@ -35,7 +35,7 @@ protected function setUp(): void $this->ownSignatureResolver = new OwnSignatureResolver( $this->requestStack, $this->gatewayCodeResolver, - $this->configurationProvider + $this->configurationProvider, ); } diff --git a/tests/Unit/Resolver/TransactionData/TransactionDataResolverTest.php b/tests/Unit/Resolver/TransactionData/TransactionDataResolverTest.php index 3fc34283..56df00ee 100644 --- a/tests/Unit/Resolver/TransactionData/TransactionDataResolverTest.php +++ b/tests/Unit/Resolver/TransactionData/TransactionDataResolverTest.php @@ -6,7 +6,6 @@ use BitBag\SyliusImojePlugin\Resolver\TransactionData\TransactionDataResolver; use BitBag\SyliusImojePlugin\Resolver\TransactionData\TransactionDataResolverInterface; -use GuzzleHttp\Psr7\Stream; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; @@ -35,10 +34,9 @@ public function testResolveStatus(): void self::TRANSACTION_ID, self::SERVICE_ID, self::ORDER_ID, - self::TRANSACTION_URL + self::TRANSACTION_URL, ); - $response = $this->createMock(ResponseInterface::class); $stream = $this->createMock(StreamInterface::class); diff --git a/tests/Unit/Resolver/TransactionMethod/TransactionMethodResolverTest.php b/tests/Unit/Resolver/TransactionMethod/TransactionMethodResolverTest.php index 76f80851..5768c155 100644 --- a/tests/Unit/Resolver/TransactionMethod/TransactionMethodResolverTest.php +++ b/tests/Unit/Resolver/TransactionMethod/TransactionMethodResolverTest.php @@ -38,8 +38,8 @@ public function statusProvider() return [ [['status' => 'blik'], 'blik'], [['status' => 'card'], 'card'], - [['status'=> 'ing'], 'ing'], - [['status'=> 'pbl'], 'pbl'], + [['status' => 'ing'], 'ing'], + [['status' => 'pbl'], 'pbl'], ]; } } diff --git a/tests/Unit/Resolver/Url/UrlResolverTest.php b/tests/Unit/Resolver/Url/UrlResolverTest.php index 451453cc..f534b0bb 100644 --- a/tests/Unit/Resolver/Url/UrlResolverTest.php +++ b/tests/Unit/Resolver/Url/UrlResolverTest.php @@ -50,7 +50,7 @@ protected function setUp(): void /** * @dataProvider dataToUrlProvider */ - public function testResolveUrl(bool $isProd,string $url,string $result): void + public function testResolveUrl(bool $isProd, string $url, string $result): void { $configuration = $this->createMock(ImojeClientConfigurationInterface::class); $client = $this->createMock(ImojeApiClientInterface::class); @@ -91,7 +91,7 @@ public function testResolveUrl(bool $isProd,string $url,string $result): void self::assertEquals( $result, - $this->urlResolver->resolve($this->imojeTransaction,$this->imojeClientConfiguration,$this->imojeClientProvider) + $this->urlResolver->resolve($this->imojeTransaction, $this->imojeClientConfiguration, $this->imojeClientProvider), ); } diff --git a/tests/Unit/Resolver/Webhook/WebhookResolverTest.php b/tests/Unit/Resolver/Webhook/WebhookResolverTest.php index 46e02a4b..f17a89a7 100644 --- a/tests/Unit/Resolver/Webhook/WebhookResolverTest.php +++ b/tests/Unit/Resolver/Webhook/WebhookResolverTest.php @@ -29,7 +29,7 @@ protected function setUp(): void public function testResolveStatus(): void { - $statusModel = new StatusResponseModel('9d5287d4','191dbb245c5f','145','settled'); + $statusModel = new StatusResponseModel('9d5287d4', '191dbb245c5f', '145', 'settled'); $requestMock = $this->createMock(Request::class); $content = @@ -46,7 +46,7 @@ public function testResolveStatus(): void $this->statusResponseModelFactory ->method('create') - ->with('9d5287d4','191dbb245c5f','145','settled') + ->with('9d5287d4', '191dbb245c5f', '145', 'settled') ->willReturn($statusModel); $result = $this->webhookResolver->resolve(); From 51c6a12afe2a4ab2495ab412839158c25fa3424a Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Tue, 23 Jul 2024 11:21:34 +0200 Subject: [PATCH 08/12] OP-366 - Add ECS to builds, drop PHP 8.0 for sylius 1.12 --- .github/workflows/build.yml | 13 ++++--------- composer.json | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf0e9fda..89f87b13 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,19 +21,12 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.0", "8.1", "8.2", "8.3" ] + php: [ "8.1", "8.2", "8.3" ] symfony: ["^5.4", "^6.0"] sylius: ["^1.12", "^1.13"] node: [ "18.x", "20.x" ] mysql: ["8.0"] - exclude: - - sylius: ^1.13 - php: 8.0 - - sylius: ^1.12 - php: 8.0 - symfony: ^6.4 - env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -173,7 +166,9 @@ jobs: name: Run PHPUnit run: vendor/bin/phpunit --colors=always -# todo add behat test if necessary + - + name: Run ECS + run: vendor/bin/ecs - name: Upload Behat logs diff --git a/composer.json b/composer.json index c4de486a..848a3227 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Implementation imoje api to sylius store", "license": "MIT", "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", "sylius/refund-plugin": "^1.0", "sylius/sylius": "^1.12 || ^1.13", From d72153c444168d48c8744c48a507109808798b7c Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Fri, 26 Jul 2024 15:20:39 +0200 Subject: [PATCH 09/12] OP-366 - Add CR Fixes on Client, add support for PHP 8.0, fix for Sylius 1.12 --- .github/workflows/build.yml | 9 ++++-- composer.json | 6 ++-- src/Client/ImojeApiClient.php | 36 ++++++++++----------- src/Resources/config/services/providers.xml | 7 ++-- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89f87b13..60fb364b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,12 +21,17 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.1", "8.2", "8.3" ] + php: [ "8.0", "8.1", "8.2", "8.3" ] symfony: ["^5.4", "^6.0"] sylius: ["^1.12", "^1.13"] node: [ "18.x", "20.x" ] mysql: ["8.0"] - + exclude: + - sylius: ^1.13 + php: 8.0 + - sylius: ^1.12 + php: 8.0 + symfony: ^6.4 env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/composer.json b/composer.json index fabc2613..cccf2129 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Implementation imoje api to sylius store", "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.0", "ext-json": "*", "sylius/refund-plugin": "^1.0", "sylius/sylius": "^1.12 || ^1.13", @@ -17,7 +17,7 @@ "bitbag/coding-standard": "^3.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", - "doctrine/dbal": "^2.7.0", + "doctrine/dbal": "^2.7 || ^3.0", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", "friends-of-behat/mink-debug-extension": "^2.0", @@ -47,7 +47,7 @@ "vimeo/psalm": "4.27.0" }, "conflict": { - "symfony/validator": "^6.4.7" + "symfony/validator": "~6.4.7" }, "config": { "sort-packages": true, diff --git a/src/Client/ImojeApiClient.php b/src/Client/ImojeApiClient.php index 6b09c44b..5431e0fb 100644 --- a/src/Client/ImojeApiClient.php +++ b/src/Client/ImojeApiClient.php @@ -12,6 +12,7 @@ use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamFactoryInterface; use Symfony\Component\Serializer\Serializer; @@ -57,13 +58,10 @@ public function createTransaction( $parameters = $this->requestParamsProvider->buildRequestParams($transactionModel, $this->token); try { - $request = $this->requestFactory + $httpRequest = $this->requestFactory ->createRequest('POST', $url) - ->withHeader('Accept', 'application/json') - ->withHeader('Content-Type', 'application/json') - ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)) ->withBody($this->streamFactory->createStream($parameters['body'])); - + $request = $this->setRequestHeaders($httpRequest); $response = $this->httpClient->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); @@ -77,10 +75,8 @@ public function getShopInfo(string $serviceId): ServiceModelInterface $url = $this->url . 'service/' . $serviceId; try { - $request = $this->requestFactory->createRequest('GET', $url) - ->withHeader('Accept', 'application/json') - ->withHeader('Content-Type', 'application/json') - ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)); + $httpRequest = $this->requestFactory->createRequest('GET', $url); + $request = $this->setRequestHeaders($httpRequest); $response = $this->httpClient->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); @@ -96,11 +92,8 @@ public function getShopInfo(string $serviceId): ServiceModelInterface public function getTransactionData(string $url): ResponseInterface { try { - $request = $this->requestFactory->createRequest('GET', $url) - ->withHeader('Accept', 'application/json') - ->withHeader('Content-Type', 'application/json') - ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)); - + $httpRequest = $this->requestFactory->createRequest('GET', $url); + $request = $this->setRequestHeaders($httpRequest); $response = $this->httpClient->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); @@ -117,13 +110,10 @@ public function refundTransaction( $parameters = $this->requestParamsProvider->buildRequestRefundParams($this->token, $serviceId, $amount); try { - $request = $this->requestFactory + $httpRequest = $this->requestFactory ->createRequest('POST', $url) - ->withHeader('Accept', 'application/json') - ->withHeader('Content-Type', 'application/json') - ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)) ->withBody($this->streamFactory->createStream($parameters['body'])); - + $request = $this->setRequestHeaders($httpRequest); $response = $this->httpClient->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new ImojeBadRequestException($e->getMessage()); @@ -131,4 +121,12 @@ public function refundTransaction( return $response; } + + private function setRequestHeaders(RequestInterface $request): RequestInterface + { + return $request + ->withHeader('Accept', 'application/json') + ->withHeader('Content-Type', 'application/json') + ->withHeader('Authorization', \sprintf('Bearer %s', $this->token)); + } } diff --git a/src/Resources/config/services/providers.xml b/src/Resources/config/services/providers.xml index f73d7645..afb4dfb5 100644 --- a/src/Resources/config/services/providers.xml +++ b/src/Resources/config/services/providers.xml @@ -2,6 +2,9 @@ + + + @@ -16,8 +19,8 @@ - - + + Date: Mon, 29 Jul 2024 07:27:04 +0200 Subject: [PATCH 10/12] OP-366 - Add fix for httpclient for Sylius 1.12 --- composer.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index cccf2129..24b3dd96 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "php": "^8.0", "ext-json": "*", "sylius/refund-plugin": "^1.0", - "sylius/sylius": "^1.12 || ^1.13", + "sylius/sylius": "~1.12", "twig/extra-bundle": "^3.4", "symfony/webpack-encore-bundle": "^1.16" }, @@ -17,7 +17,7 @@ "bitbag/coding-standard": "^3.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", - "doctrine/dbal": "^2.7 || ^3.0", + "doctrine/dbal": "^2.7", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", "friends-of-behat/mink-debug-extension": "^2.0", @@ -44,7 +44,9 @@ "symfony/mailer": "^5.4 || ^6.0", "symfony/maker-bundle": "^1.53", "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "vimeo/psalm": "4.27.0" + "vimeo/psalm": "4.27.0", + "nyholm/psr7": "^1.8", + "symfony/http-client": "^5.4 || ^6.0" }, "conflict": { "symfony/validator": "~6.4.7" From c9223efa54e64e6896e75a0eb8e3ab0b9ec20bf7 Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 29 Jul 2024 07:32:35 +0200 Subject: [PATCH 11/12] OP-366 - Add fix for dependencies --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 24b3dd96..b14fdbc4 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "php": "^8.0", "ext-json": "*", "sylius/refund-plugin": "^1.0", - "sylius/sylius": "~1.12", + "sylius/sylius": "^1.12 || ^1.13", "twig/extra-bundle": "^3.4", "symfony/webpack-encore-bundle": "^1.16" }, @@ -17,7 +17,7 @@ "bitbag/coding-standard": "^3.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", - "doctrine/dbal": "^2.7", + "doctrine/dbal": "^2.7 || ^3.0", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", "friends-of-behat/mink-debug-extension": "^2.0", @@ -42,7 +42,6 @@ "symfony/dotenv": "^5.4 || ^6.0", "symfony/intl": "^5.4 || ^6.0", "symfony/mailer": "^5.4 || ^6.0", - "symfony/maker-bundle": "^1.53", "symfony/web-profiler-bundle": "^5.4 || ^6.0", "vimeo/psalm": "4.27.0", "nyholm/psr7": "^1.8", From e576d40bd07b61b6f3d85b9b19673863f7165a9b Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Mon, 29 Jul 2024 07:35:59 +0200 Subject: [PATCH 12/12] OP-366 - Apply ECS fixes --- src/Controller/Shop/InitializePaymentController.php | 3 ++- src/DependencyInjection/BitBagSyliusImojeExtension.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controller/Shop/InitializePaymentController.php b/src/Controller/Shop/InitializePaymentController.php index fbf41792..860343dd 100644 --- a/src/Controller/Shop/InitializePaymentController.php +++ b/src/Controller/Shop/InitializePaymentController.php @@ -52,7 +52,7 @@ public function __construct( BlikModelProviderInterface $blikModelProvider, TransactionPaymentDataResolverInterface $transactionPaymentDataResolver, TranslatorInterface $translator, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->orderResolver = $orderResolver; $this->paymentResolver = $paymentResolver; @@ -123,6 +123,7 @@ private function getPaymentFromOrder(OrderInterface $order): PaymentInterface $payment = $this->paymentResolver->resolve($order); } catch (\InvalidArgumentException $e) { $this->logger->error($e->getMessage()); + throw new ImojeNotConfiguredException('Payment method not found'); } diff --git a/src/DependencyInjection/BitBagSyliusImojeExtension.php b/src/DependencyInjection/BitBagSyliusImojeExtension.php index 272fc6d6..64d91f13 100644 --- a/src/DependencyInjection/BitBagSyliusImojeExtension.php +++ b/src/DependencyInjection/BitBagSyliusImojeExtension.php @@ -4,17 +4,18 @@ namespace BitBag\SyliusImojePlugin\DependencyInjection; +use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait; final class BitBagSyliusImojeExtension extends Extension implements PrependExtensionInterface { use PrependDoctrineMigrationsTrait; + public function load(array $configs, ContainerBuilder $container): void { $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));