<commit_before><?php

/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\Controller\Payment;

use Sylius\Bundle\ApiBundle\Provider\CompositePaymentConfigurationProviderInterface;
use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Webmozart\Assert\Assert;

/** @experimental */
final class GetPaymentConfiguration
{
    public function __construct(
        private PaymentRepositoryInterface $paymentRepository,
        private CompositePaymentConfigurationProviderInterface $compositePaymentConfigurationProvider,
    ) {
    }

    public function __invoke(Request $request): JsonResponse
    {
        /** @var PaymentInterface|null $payment */
        $payment = $this->paymentRepository->findOneByOrderToken(
            $request->attributes->get('paymentId'),
            $request->attributes->get('id'),
        );

        Assert::notNull($payment);

        return new JsonResponse($this->compositePaymentConfigurationProvider->provide($payment));
    }
}<commit_msg>Use tokenValue instead of id<commit_after><?php

/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\Controller\Payment;

use Sylius\Bundle\ApiBundle\Provider\CompositePaymentConfigurationProviderInterface;
use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Webmozart\Assert\Assert;

/** @experimental */
final class GetPaymentConfiguration
{
    public function __construct(
        private PaymentRepositoryInterface $paymentRepository,
        private CompositePaymentConfigurationProviderInterface $compositePaymentConfigurationProvider,
    ) {
    }

    public function __invoke(Request $request): JsonResponse
    {
        /** @var PaymentInterface|null $payment */
        $payment = $this->paymentRepository->findOneByOrderToken(
            $request->attributes->get('paymentId'),
            $request->attributes->get('tokenValue'),
        );

        Assert::notNull($payment);

        return new JsonResponse($this->compositePaymentConfigurationProvider->provide($payment));
    }
}
{'fraction_non_alphanumeric': 0.09856564913571166, 'fraction_numerical': 0.000735564545788893, 'mean_word_length': 4.322896281800391, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '984517', 'n_tokens_mistral': 689, 'n_tokens_neox': 679, 'n_words': 152}