Skip to content

Commit

Permalink
Fix payment method entity extension
Browse files Browse the repository at this point in the history
  • Loading branch information
peterojo committed Jun 9, 2021
1 parent 8758391 commit a678591
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Subscriber/Response/PaymentMethodRouteResponseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
use Adyen\Shopware\Service\PaymentMethodsFilterService;
use Adyen\Shopware\Service\PaymentMethodsService;
use Adyen\Shopware\Struct\AdyenPaymentMethodDataStruct;
use Shopware\Core\Checkout\Payment\PaymentMethodCollection;
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
use Shopware\Core\PlatformRequest;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -105,13 +107,25 @@ private function filterPaymentMethods(SalesChannelContext $context, ResponseEven
return;
}

$methods = $this->paymentMethodsFilterService->filterShopwarePaymentMethods(
$event->getResponse()->getPaymentMethods(),
/** @var EntitySearchResult $result */
$result = $event->getResponse()->getObject();
/** @var PaymentMethodCollection $paymentMethods */
$paymentMethods = $result->getEntities();
$filteredPaymentMethods = $this->paymentMethodsFilterService->filterShopwarePaymentMethods(
$paymentMethods,
$context,
$this->adyenPluginProvider->getAdyenPluginId()
);

$response = new PaymentMethodRouteResponse($methods);
$result = new EntitySearchResult(
'payment_method',
count($filteredPaymentMethods),
$filteredPaymentMethods,
$result->getAggregations(),
$result->getCriteria(),
$result->getContext()
);
$response = new PaymentMethodRouteResponse($result);
$event->setResponse($response);
}

Expand Down

0 comments on commit a678591

Please sign in to comment.