<commit_before><?php
namespace Payum\Be2Bill\Action;

use Payum\Request\CaptureRequest;
use Payum\Request\CreatePaymentInstructionRequest;
use Payum\Request\UserInputRequiredInteractiveRequest;
use Payum\Domain\InstructionAwareInterface;
use Payum\Domain\InstructionAggregateInterface;
use Payum\Exception\RequestNotSupportedException;
use Payum\Exception\LogicException;
use Payum\Be2Bill\PaymentInstruction;
use Payum\Be2Bill\Api;

class CaptureAction extends ActionPaymentAware
{
    /**
     * {inheritdoc}
     */
    public function execute($request)
    {
        /** @var $request CaptureRequest */
        if (false == $this->supports($request)) {
            throw RequestNotSupportedException::createActionNotSupported($this, $request);
        }
        
        if (null == $request->getModel()->getInstruction()) {
            $this->payment->execute(new CreatePaymentInstructionRequest($request->getModel()));
            
            if (false == $request->getModel()->getInstruction() instanceof PaymentInstruction) {
                throw new LogicException('Create payment instruction request should set expected instruction to the model');
            }
        }
        
        /** @var $instruction PaymentInstruction */
        $instruction = $request->getModel()->getInstruction();
        
        if (null === $instruction->getExeccode()) {
            if (false == ($instruction->getCardcode() && $instruction->getCardcvv() && $instruction->getCardvaliditydate())) {
                throw new UserInputRequiredInteractiveRequest(array(
                    'cardcode',
                    'cardcvv',
                    'cardvaliditydate'
                ));
            }
            
            $response = $this->payment->getApi()->payment($instruction->toParams());
            
            $instruction->fromParams((array) $response->getContentJson());
        }
    }

    /**
     * {inheritdoc}
     */
    public function supports($request)
    {
        return 
            $request instanceof CaptureRequest &&
            $request->getModel() instanceof InstructionAwareInterface &&
            $request->getModel() instanceof InstructionAggregateInterface &&
            (<commit_msg>handle correctly alias.<commit_after><?php
namespace Payum\Be2Bill\Action;

use Payum\Request\CaptureRequest;
use Payum\Request\CreatePaymentInstructionRequest;
use Payum\Request\UserInputRequiredInteractiveRequest;
use Payum\Domain\InstructionAwareInterface;
use Payum\Domain\InstructionAggregateInterface;
use Payum\Exception\RequestNotSupportedException;
use Payum\Exception\LogicException;
use Payum\Be2Bill\PaymentInstruction;
use Payum\Be2Bill\Api;

class CaptureAction extends ActionPaymentAware
{
    /**
     * {inheritdoc}
     */
    public function execute($request)
    {
        /** @var $request CaptureRequest */
        if (false == $this->supports($request)) {
            throw RequestNotSupportedException::createActionNotSupported($this, $request);
        }
        
        if (null == $request->getModel()->getInstruction()) {
            $this->payment->execute(new CreatePaymentInstructionRequest($request->getModel()));
            
            if (false == $request->getModel()->getInstruction() instanceof PaymentInstruction) {
                throw new LogicException('Create payment instruction request should set expected instruction to the model');
            }
        }
        
        /** @var $instruction PaymentInstruction */
        $instruction = $request->getModel()->getInstruction();
        
        if (null === $instruction->getExeccode()) {
            //instruction must have an alias set (e.g oneclick payment) or credit card info. 
            if ($instruction->getAlias() ||
                ($instruction->getCardcode() && $instruction->getCardcvv() && $instruction->getCardvaliditydate())
            ) {
                $response = $this->payment->getApi()->payment($instruction->toParams());

                $instruction->fromParams((array) $response->getContentJson());
            } else {
                throw new UserInputRequiredInteractiveRequest(array(
                    'cardcode',
                    'cardcvv',
                    'cardvaliditydate',
                    'cardfullname'
                ));
            }
        }
    }

    /**
     * {inheritdoc}
     */
    public function supports($request)
    {
        return 
            $request instanceof CaptureRequest &&
            $request->getModel() instanceof InstructionAwareInterface &&
            $request->getModel() instanceof InstructionAggregateInterface &&
            (
{'fraction_non_alphanumeric': 0.11520241171403962, 'fraction_numerical': 0.0012919896640826874, 'mean_word_length': 2.433111603843311, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '4812405', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1120, 'n_words': 213}