<commit_before><?php
namespace Acme\PayexBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints\Range;

use Sensio\Bundle\FrameworkExtraBundle\Configuration as Extra;

use Payum\Registry\RegistryInterface;
use Payum\Payex\Api\OrderApi;
use Payum\Payex\Model\PaymentDetails;
use Payum\Bundle\PayumBundle\Service\TokenManager;

class PurchaseExamplesController extends Controller
{
    /**
     * @Extra\Route(
     *   "/prepare_simple_purchase", 
     *   name="acme_payex_prepare_simple_purchase"
     * )
     * 
     * @Extra\Template
     */
    public function prepareAction(Request $request)
    {
        $paymentName = 'payex';
        
        $form = $this->createPurchaseForm();
        if ('POST' === $request->getMethod()) {
            $form->bind($request);
            if ($form->isValid()) {
                $data = $form->getData();
                
                $storage = $this->getPayum()->getStorageForClass(
                    'Acme\PayexBundle\Model\PaymentDetails',
                    $paymentName
                );

//                'price' => 1000,
//            'priceArgList' => '',
//            'vat' => 0,
//            'currency' => 'NOK',
//            'orderID' => 123,
//            'productNumber' => 123,
//            'purchaseOperation' => OrderApi::PURCHASEOPERATION_AUTHORIZATION,
//            'view' => OrderApi::VIEW_CREDITCARD,
//            'description' => 'a description',
//            'additionalValues' => '',
//            'returnUrl' => 'http://example.com/a_return_url',
//            'cancelUrl' => 'http://example.com/a_cancel_url',
//            'externalID' => '',
//            'clientIPAddress' => '127.0.0.1',
//            'clientIdentifier' => 'USER-AGENT=cli-php',
//            'agreementRef' => '',
//            'clientLanguage' => 'en-US',

                /** @var $paymentDetails PaymentDetails */
                $paymentDetails = $storage->createModel();
                $paymentDetails->setPrice($data['amount'] * 100);
                $paymentDetails->setPriceArgList('');
                $paymentDetails->setVat(0);
                $paymentDetails->setCurrency($data['currency']);
                $paymentDetails->setOrderId(123);
                $paymentDetails->setProductNumber(123);
                $paymentDetails->setPurchaseOperation(OrderApi::PURCHASEOPERATION_AUTHORIZATION);
                $paymentDetails->setView(OrderApi::VIEW_CREDITCARD);
                $paymentDetails->setDescription('a desc');
                $paymentDetails->setClientIPAddress($request->getClientIp());
                $paymentDetails->setClientIdentifier('');
                $paymentDetails->setAdditionalValues('');
                $paymentDetails->setAgreementRef('');
                $paymentDetails->setClientLanguage('en-US');
                
                $storage->updateModel($paymentDetails);
                
                $captureToken = $this->getTokenManager()->createTokenForCaptureRoute(
                    $paymentName,
                    $paymentDetails,
                    'acme_payment_details_view'<commit_msg>[payex] remove commented out code.<commit_after><?php
namespace Acme\PayexBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints\Range;

use Sensio\Bundle\FrameworkExtraBundle\Configuration as Extra;

use Payum\Registry\RegistryInterface;
use Payum\Payex\Api\OrderApi;
use Payum\Payex\Model\PaymentDetails;
use Payum\Bundle\PayumBundle\Service\TokenManager;

class PurchaseExamplesController extends Controller
{
    /**
     * @Extra\Route(
     *   "/prepare_simple_purchase", 
     *   name="acme_payex_prepare_simple_purchase"
     * )
     * 
     * @Extra\Template
     */
    public function prepareAction(Request $request)
    {
        $paymentName = 'payex';
        
        $form = $this->createPurchaseForm();
        if ('POST' === $request->getMethod()) {
            $form->bind($request);
            if ($form->isValid()) {
                $data = $form->getData();
                
                $storage = $this->getPayum()->getStorageForClass(
                    'Acme\PayexBundle\Model\PaymentDetails',
                    $paymentName
                );

                /** @var $paymentDetails PaymentDetails */
                $paymentDetails = $storage->createModel();
                $paymentDetails->setPrice($data['amount'] * 100);
                $paymentDetails->setPriceArgList('');
                $paymentDetails->setVat(0);
                $paymentDetails->setCurrency($data['currency']);
                $paymentDetails->setOrderId(123);
                $paymentDetails->setProductNumber(123);
                $paymentDetails->setPurchaseOperation(OrderApi::PURCHASEOPERATION_AUTHORIZATION);
                $paymentDetails->setView(OrderApi::VIEW_CREDITCARD);
                $paymentDetails->setDescription('a desc');
                $paymentDetails->setClientIPAddress($request->getClientIp());
                $paymentDetails->setClientIdentifier('');
                $paymentDetails->setAdditionalValues('');
                $paymentDetails->setAgreementRef('');
                $paymentDetails->setClientLanguage('en-US');
                
                $storage->updateModel($paymentDetails);
                
                $captureToken = $this->getTokenManager()->createTokenForCaptureRoute(
                    $paymentName,
                    $paymentDetails,
                    'acme_payment_details_view'
{'fraction_non_alphanumeric': 0.13210526315789473, 'fraction_numerical': 0.006491228070175438, 'mean_word_length': 2.0866269626421223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '2403082', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1449, 'n_words': 186}