Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2 Paypal Express结账详细信息_Php_Symfony_Paypal - Fatal编程技术网

Php Symfony2 Paypal Express结账详细信息

Php Symfony2 Paypal Express结账详细信息,php,symfony,paypal,Php,Symfony,Paypal,我正在使用基于payum网站文档的paypal express结账,我对结账详细信息有问题这是我的PaymentController代码: class PaymentController extends Controller{ public function processRequestAction (Request $request) { $options = $this->get('doctrine.orm.entity_manager')

我正在使用基于payum网站文档的paypal express结账,我对结账详细信息有问题这是我的PaymentController代码:

class PaymentController extends Controller{

    public function processRequestAction (Request $request) {
        $options = $this->get('doctrine.orm.entity_manager')
            ->getRepository('AdminBundle:Options')->getOption('admin_options');
        $credits = $request->request->get('wizardPayment')['Credits'];
        $total = $credits*$options['credits-rate'];
        $user = $this->get('security.token_storage')->getToken()->getUser();

        $paymentName = 'paypal_express_checkout';

        $storage = $this->get('payum')->getStorage('Magnetomedia\AdminBundle\Entity\PaymentDetails');
        $order = $storage->create();
        $order->setCurrencyCode($options['currency']['code']);
        $order->setTotalAmount($total);
        $order->setDescription('Buy credits from verifyme.email');
        $order->setClientId($user->getId());
        $order->setClientEmail($user->getEmail());

        $order->setDetails(array(
            "SOLUTIONTYPE" => 'Sole',
            "LANDINGPAGE" => 'Billing'
        ));
        $storage->update($order);
        $order->setNumber($order->getId().rand(1,10000));
        $storage->update($order);
        $captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
            $paymentName,
            $order,
            'payment_response' // the route to redirect after capture;
        );

       return $this->redirect($captureToken->getTargetUrl());
    }

        public function paymentResponseAction(Request $request){
            $token = $this->get('payum.security.http_request_verifier')->verify($request);

            $payment = $this->get('payum')->getPayment($token->getPaymentName());

            $entityManager = $this->get('doctrine')->getManager();
            $options = $entityManager->getRepository('AdminBundle:Options')->getOption('admin_options');

            try {
                $payment->execute(new Sync($token));
            } catch (RequestNotSupportedException $e) {}

            $payment->execute($status = new GetHumanStatus($token));

            $refundToken = null;

            if ($status->isCaptured() || $status->isAuthorized()) {
                $refundToken = array(
                    'status' => $status->getValue(),
                    'order' => array(
                        'client' => array(
                            'id' => $status->getFirstModel()->getClientId(),
                            'email' => $status->getFirstModel()->getClientEmail(),
                        ),
                        'number' => $status->getFirstModel()->getNumber(),
                        'description' => $status->getFirstModel()->getCurrencyCode(),
                        'total_amount' => $status->getFirstModel()->getTotalAmount(),
                        'currency_code' => $status->getFirstModel()->getCurrencyCode(),
                        'details' => $status->getFirstModel()->getDetails(),
                    ),
                );
                $user = $entityManager->find('AdminBundle:User',$refundToken['order']['client']['id']);

                $userOrder = new UserOrder();
                $userOrder->setStatus($refundToken['status']);
                $userOrder->setUser($user);
                $userOrder->setDate(new \DateTime());
                $userOrder->setInfo(json_encode($refundToken['order']));
                $entityManager->persist($userOrder);

                $user->addCredits($refundToken['order']['total_amount']/$options['credits-rate']);
                $entityManager->persist($user);
                $this->addFlash(
                    "paymentMessage",
                    'Payment was successfully accepted, you got '
                    .$refundToken['order']['total_amount']/$options['credits-rate'].' Credits'
                );
                $paymentStatus = 'success';
            } elseif(!$status->isCaptured()) {
                $userOrder = new UserOrder();
                $userOrder->setStatus($status->getValue());
                $userOrder->setUser(
                    $entityManager->find('AdminBundle:User',$refundToken['order']['client']['id'])
                );
                $userOrder->setDate(new \DateTime());
                $entityManager->persist($userOrder);

                $paymentStatus ='danger';
                $this->addFlash("paymentMessage",'We are sorry there was an error during the payment process , please try again later or contact us');

            }
            $entityManager->flush();

            return $this->redirectToRoute('profile_page',array('paymentStatus'=>$paymentStatus));
        }
    }
我被重定向到Paypal,但即使我指定了金额和说明,Paypal仍会在“当前购买”中列出说明和价格。当我更改此选项时:

$order->setDetails(array(
                "SOLUTIONTYPE" => 'Sole',
                "LANDINGPAGE" => 'Billing'
            ));
致:

它会生成一个异常:

Myapp\AdminBundle\Entity\User查询缺少标识符id 在第294行的vendor/doctrine/orm/lib/doctrine/orm/ORMException.php中

堆栈跟踪:

 at ORMException ::missingIdentifierField ('Myapp\AdminBundle\Entity\User',     'id') 
in vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php at line 403   
at EntityManager ->find ('AdminBundle:User', null, null, null) 
in app/cache/dev/jms_diextra/doctrine/EntityManager_5613ae163997a.php at   line 336   
at EntityManager ->find ('AdminBundle:User', null) 
in src/Myapp/AdminBundle/Controller/PaymentController.php at line 107   
at PaymentController ->paymentResponseAction (object(Request)) 
at call_user_func_array (array(object(PaymentController),   'paymentResponseAction'), array(object(Request))) 
in app/bootstrap.php.cache at line 3020   
at HttpKernel ->handleRaw (object(Request), '1') 
in app/bootstrap.php.cache at line 2982   
at HttpKernel ->handle (object(Request), '1', true) 
in app/bootstrap.php.cache at line 3131   
at ContainerAwareHttpKernel ->handle (object(Request), '1', true) 
in app/bootstrap.php.cache at line 2376   
at Kernel ->handle (object(Request)) 
in httpdocs/app_dev.php at line 28   

有什么想法吗?

你解决过我遇到的类似问题吗?你解决过我遇到的类似问题吗。
 at ORMException ::missingIdentifierField ('Myapp\AdminBundle\Entity\User',     'id') 
in vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php at line 403   
at EntityManager ->find ('AdminBundle:User', null, null, null) 
in app/cache/dev/jms_diextra/doctrine/EntityManager_5613ae163997a.php at   line 336   
at EntityManager ->find ('AdminBundle:User', null) 
in src/Myapp/AdminBundle/Controller/PaymentController.php at line 107   
at PaymentController ->paymentResponseAction (object(Request)) 
at call_user_func_array (array(object(PaymentController),   'paymentResponseAction'), array(object(Request))) 
in app/bootstrap.php.cache at line 3020   
at HttpKernel ->handleRaw (object(Request), '1') 
in app/bootstrap.php.cache at line 2982   
at HttpKernel ->handle (object(Request), '1', true) 
in app/bootstrap.php.cache at line 3131   
at ContainerAwareHttpKernel ->handle (object(Request), '1', true) 
in app/bootstrap.php.cache at line 2376   
at Kernel ->handle (object(Request)) 
in httpdocs/app_dev.php at line 28