<commit_before><?php
namespace Payum\Bundle\PayumBundle\Controller;

use Payum\Bundle\PayumBundle\Service\TokenizedTokenService;
use Payum\Model\TokenizedDetails;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\HttpException;

use Payum\Exception\InvalidArgumentException;
use Payum\Exception\RequestNotSupportedException;
use Payum\Request\CaptureRequest;
use Payum\Request\BinaryMaskStatusRequest;
use Payum\Bundle\PayumBundle\Registry\ContainerAwareRegistry;

class CaptureController extends Controller 
{
    public function doAction($paymentName, $token, Request $request)
    {
        try {
            if (false == $token instanceof TokenizedDetails) {
                if (false == $token = $this->getTokenizedTokenService()->findTokenizedDetailsByToken($paymentName, $token)) {
                    throw $this->createNotFoundException('The TokenizedDetails with requested token not found.');
                }
            }
            if ($paymentName !== $token->getPaymentName()) {
                throw new InvalidArgumentException(sprintf('The paymentName %s not match one %s set in the token.', $paymentName, $token->getPaymentName()));
            }
            //TODO not working with forward.
//            if (parse_url($request->getUri(), PHP_URL_PATH) != parse_url($token->getTargetUrl(), PHP_URL_PATH)) {
//                throw new InvalidArgumentException(sprintf('The current url %s not match target url %s set in the token.', $request->getRequestUri(), $token->getTargetUrl()));
//            }
            
            $status = new BinaryMaskStatusRequest($token);
            $this->getPayum()->getPayment($paymentName)->execute($status);
            if (false == $status->isNew()) {
                throw new HttpException(400, 'The model status must be new.');
            }
            
            $capture = new CaptureRequest($token);
            $this->getPayum()->getPayment($paymentName)->execute($capture);
            
            $this->getPayum()->getStorageForClass($token, $paymentName)->deleteModel($token);
            
            return $this->redirect($token->getAfterUrl());
        } catch (HttpException $e) {
            throw $e;<commit_msg>Revert "[capture] use token for capture and status requests."<commit_after><?php
namespace Payum\Bundle\PayumBundle\Controller;

use Payum\Bundle\PayumBundle\Service\TokenizedTokenService;
use Payum\Model\TokenizedDetails;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\HttpException;

use Payum\Exception\InvalidArgumentException;
use Payum\Exception\RequestNotSupportedException;
use Payum\Request\CaptureRequest;
use Payum\Request\BinaryMaskStatusRequest;
use Payum\Bundle\PayumBundle\Registry\ContainerAwareRegistry;

class CaptureController extends Controller 
{
    public function doAction($paymentName, $token, Request $request)
    {
        try {
            if (false == $token instanceof TokenizedDetails) {
                if (false == $token = $this->getTokenizedTokenService()->findTokenizedDetailsByToken($paymentName, $token)) {
                    throw $this->createNotFoundException('The TokenizedDetails with requested token not found.');
                }
            }
            if ($paymentName !== $token->getPaymentName()) {
                throw new InvalidArgumentException(sprintf('The paymentName %s not match one %s set in the token.', $paymentName, $token->getPaymentName()));
            }
            //TODO not working with forward.
//            if (parse_url($request->getUri(), PHP_URL_PATH) != parse_url($token->getTargetUrl(), PHP_URL_PATH)) {
//                throw new InvalidArgumentException(sprintf('The current url %s not match target url %s set in the token.', $request->getRequestUri(), $token->getTargetUrl()));
//            }
            
            $status = new BinaryMaskStatusRequest($token->getDetails());
            $this->getPayum()->getPayment($paymentName)->execute($status);
            if (false == $status->isNew()) {
                throw new HttpException(400, 'The model status must be new.');
            }
            
            $capture = new CaptureRequest($status->getModel());
            $this->getPayum()->getPayment($paymentName)->execute($capture);
            
            $this->getPayum()->getStorageForClass($token, $paymentName)->deleteModel($token);
            
            return $this->redirect($token->getAfterUrl());
        } catch (HttpException $e) {
            throw $e;
{'fraction_non_alphanumeric': 0.12116663092429766, 'fraction_numerical': 0.0012867252841518336, 'mean_word_length': 2.939189189189189, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, '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': '5979241', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1164, 'n_words': 259}