From 0252e0fe8738d176720bb7384de6c5e7360cb220 Mon Sep 17 00:00:00 2001 From: Frederik Rommel Date: Thu, 17 Oct 2024 10:56:51 +0200 Subject: [PATCH] RATESWSX-318: fix reloading profile-config if legacy payment-methods are available --- .../Service/ProfileConfigResponseConverter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Components/ProfileConfig/Service/ProfileConfigResponseConverter.php b/src/Components/ProfileConfig/Service/ProfileConfigResponseConverter.php index 88c4ec0a..33872838 100644 --- a/src/Components/ProfileConfig/Service/ProfileConfigResponseConverter.php +++ b/src/Components/ProfileConfig/Service/ProfileConfigResponseConverter.php @@ -14,6 +14,7 @@ use RatePAY\Model\Response\ProfileRequest; use Ratepay\RpayPayments\Components\PaymentHandler\InstallmentPaymentHandler; use Ratepay\RpayPayments\Components\PaymentHandler\InstallmentZeroPercentPaymentHandler; +use Ratepay\RpayPayments\Components\PaymentHandler\LegacyPaymentHandler; use Ratepay\RpayPayments\Components\ProfileConfig\Model\ProfileConfigEntity; use Ratepay\RpayPayments\Components\ProfileConfig\Model\ProfileConfigMethodEntity; use Ratepay\RpayPayments\Components\ProfileConfig\Model\ProfileConfigMethodInstallmentEntity; @@ -24,6 +25,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; +use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter; use Shopware\Core\Framework\Uuid\Uuid; class ProfileConfigResponseConverter @@ -65,7 +67,12 @@ public function convert(ProfileRequest $response, string $profileId): array /** @var PaymentMethodEntity $paymentMethod */ foreach ($paymentMethods as $paymentMethod) { - $arrayKey = strtolower((string) constant($paymentMethod->getHandlerIdentifier() . '::RATEPAY_METHOD')); + $constantName = $paymentMethod->getHandlerIdentifier() . '::RATEPAY_METHOD'; + if (!defined($constantName)) { + continue; + } + + $arrayKey = strtolower((string) constant($constantName)); if (!isset($responseData['merchantConfig']['activation-status-' . $arrayKey]) || (((int) $responseData['merchantConfig']['activation-status-' . $arrayKey]) === 1)) { @@ -131,6 +138,7 @@ private function getPaymentMethods(): array $criteria = new Criteria(); $criteria->addAssociation('plugin'); $criteria->addFilter(new EqualsFilter('plugin.baseClass', RpayPayments::class)); + $criteria->addFilter(new NotFilter(NotFilter::CONNECTION_AND, [new EqualsFilter('handlerIdentifier', LegacyPaymentHandler::class)])); /** @var PaymentMethodEntity[] $paymentMethods */ $paymentMethods = $this->paymentMethodRepository->search($criteria, Context::createDefaultContext())->getElements(); $this->paymentMethods = $paymentMethods;