vendor/shopware/core/Checkout/Payment/SalesChannel/SortedPaymentMethodRoute.php line 39
<?php declare(strict_types=1);
namespace Shopware\Core\Checkout\Payment\SalesChannel;
use Shopware\Core\Checkout\Payment\Hook\PaymentMethodRouteHook;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Script\Execution\ScriptExecutor;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
#[Route(defaults: ['_routeScope' => ['store-api']])]
#[Package('checkout')]
class SortedPaymentMethodRoute extends AbstractPaymentMethodRoute
{
/**
* @internal
*/
public function __construct(
private readonly AbstractPaymentMethodRoute $decorated,
private readonly ScriptExecutor $scriptExecutor
) {
}
public function getDecorated(): AbstractPaymentMethodRoute
{
return $this->decorated;
}
#[Route(path: '/store-api/payment-method', name: 'store-api.payment.method', methods: ['GET', 'POST'], defaults: ['_entity' => 'payment_method'])]
public function load(Request $request, SalesChannelContext $context, Criteria $criteria): PaymentMethodRouteResponse
{
$response = $this->getDecorated()->load($request, $context, $criteria);
$response->getPaymentMethods()->sortPaymentMethodsByPreference($context);
$this->scriptExecutor->execute(new PaymentMethodRouteHook(
$response->getPaymentMethods(),
$request->query->getBoolean('onlyAvailable') || $request->request->getBoolean('onlyAvailable'),
$context
));
return $response;
}
}