Skip to content

Commit

Permalink
RATESWSX-318: fix reloading profile-config if legacy payment-methods …
Browse files Browse the repository at this point in the history
…are available
  • Loading branch information
rommelfreddy committed Oct 17, 2024
1 parent 7dfbf0a commit 0252e0f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0252e0f

Please sign in to comment.