diff --git a/spec/Resolver/PagolightPaymentMethodsResolverSpec.php b/spec/Resolver/PagolightPaymentMethodsResolverSpec.php index 1267962..72404c6 100644 --- a/spec/Resolver/PagolightPaymentMethodsResolverSpec.php +++ b/spec/Resolver/PagolightPaymentMethodsResolverSpec.php @@ -44,9 +44,9 @@ public function let( $payment->getOrder()->willReturn($order); $payment->getMethod()->willReturn($pagolightPaymentMethod); - $pagolightGatewayConfig->getGatewayName()->willReturn(PagolightApi::PAGOLIGHT_GATEWAY_CODE); - $pagolightProGatewayConfig->getGatewayName()->willReturn(PagolightApi::PAGOLIGHT_PRO_GATEWAY_CODE); - $otherGatewayConfig->getGatewayName()->willReturn('other'); + $pagolightGatewayConfig->getFactoryName()->willReturn(PagolightApi::PAGOLIGHT_GATEWAY_CODE); + $pagolightProGatewayConfig->getFactoryName()->willReturn(PagolightApi::PAGOLIGHT_PRO_GATEWAY_CODE); + $otherGatewayConfig->getFactoryName()->willReturn('other'); $pagolightPaymentMethod->getCode()->willReturn('PAGOLIGHT_PAYMENT_METHOD_CODE'); $pagolightPaymentMethod->getGatewayConfig()->willReturn($pagolightGatewayConfig); diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index 1138724..939e906 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -42,6 +42,7 @@ public function statusAction(mixed $paymentId): Response if (!$paymentGatewayConfig instanceof GatewayConfigInterface) { throw $this->createAccessDeniedException(); } + /** @psalm-suppress DeprecatedMethod */ if (!in_array($paymentGatewayConfig->getFactoryName(), [PagolightApi::PAGOLIGHT_GATEWAY_CODE, PagolightApi::PAGOLIGHT_PRO_GATEWAY_CODE], true)) { throw $this->createAccessDeniedException(); } diff --git a/src/Resolver/PagolightPaymentMethodsResolver.php b/src/Resolver/PagolightPaymentMethodsResolver.php index 1486a6c..8da4475 100644 --- a/src/Resolver/PagolightPaymentMethodsResolver.php +++ b/src/Resolver/PagolightPaymentMethodsResolver.php @@ -57,6 +57,7 @@ static function (PaymentMethodInterface $paymentMethod) use ($billingAddress, $s if ($gatewayConfig === null) { return false; } + /** @psalm-suppress DeprecatedMethod */ if (!in_array($gatewayConfig->getFactoryName(), [PagolightApi::PAGOLIGHT_GATEWAY_CODE, PagolightApi::PAGOLIGHT_PRO_GATEWAY_CODE], true)) { return true; } @@ -69,6 +70,7 @@ static function (PaymentMethodInterface $paymentMethod) use ($billingAddress, $s if (!in_array($currencyCode, Config::ALLOWED_CURRENCY_CODES, true)) { return false; } + /** @psalm-suppress DeprecatedMethod */ if ($orderAmount <= (Config::PAGOLIGHT_PRO_MINIMUM_AMOUNT * 100) && $gatewayConfig->getFactoryName() === PagolightApi::PAGOLIGHT_PRO_GATEWAY_CODE ) { diff --git a/src/Validator/PagolightPaymentMethodUniqueValidator.php b/src/Validator/PagolightPaymentMethodUniqueValidator.php index f244307..60a6183 100644 --- a/src/Validator/PagolightPaymentMethodUniqueValidator.php +++ b/src/Validator/PagolightPaymentMethodUniqueValidator.php @@ -35,6 +35,7 @@ public function validate(mixed $value, Constraint $constraint): void } $gatewayConfig = $value->getGatewayConfig(); + /** @psalm-suppress DeprecatedMethod */ if ($gatewayConfig === null || !in_array($gatewayConfig->getFactoryName(), [ PagolightApi::PAGOLIGHT_GATEWAY_CODE, @@ -44,10 +45,12 @@ public function validate(mixed $value, Constraint $constraint): void return; } + /** @var PaymentMethodInterface[] $paymentMethods */ $paymentMethods = $this->paymentMethodRepository->findAll(); + /** @psalm-suppress DeprecatedMethod */ $paymentMethodsWithSameGatewayConfig = array_filter( $paymentMethods, - static fn (PaymentMethodInterface $paymentMethod) => $paymentMethod->getGatewayConfig()?->getFactoryName() === $gatewayConfig->getFactoryName() + static fn (PaymentMethodInterface $paymentMethod) => $paymentMethod->getGatewayConfig()?->getFactoryName() === $gatewayConfig->getFactoryName(), ); if (count($paymentMethodsWithSameGatewayConfig) > 1 || (count($paymentMethodsWithSameGatewayConfig) === 1 && reset($paymentMethodsWithSameGatewayConfig) !== $value)