<i id='vbBXm'><tr id='vbBXm'><dt id='vbBXm'><q id='vbBXm'><span id='vbBXm'><b id='vbBXm'><form id='vbBXm'><ins id='vbBXm'></ins><ul id='vbBXm'></ul><sub id='vbBXm'></sub></form><legend id='vbBXm'></legend><bdo id='vbBXm'><pre id='vbBXm'><center id='vbBXm'></center></pre></bdo></b><th id='vbBXm'></th></span></q></dt></tr></i><div id='vbBXm'><tfoot id='vbBXm'></tfoot><dl id='vbBXm'><fieldset id='vbBXm'></fieldset></dl></div>

  1. <tfoot id='vbBXm'></tfoot>
    <legend id='vbBXm'><style id='vbBXm'><dir id='vbBXm'><q id='vbBXm'></q></dir></style></legend>
    • <bdo id='vbBXm'></bdo><ul id='vbBXm'></ul>

    1. <small id='vbBXm'></small><noframes id='vbBXm'>

      使用 Symfony2 设置 Payum Bundle 出现错误

      时间:2023-06-24
        <tbody id='OiQx1'></tbody>
        <tfoot id='OiQx1'></tfoot>
      • <i id='OiQx1'><tr id='OiQx1'><dt id='OiQx1'><q id='OiQx1'><span id='OiQx1'><b id='OiQx1'><form id='OiQx1'><ins id='OiQx1'></ins><ul id='OiQx1'></ul><sub id='OiQx1'></sub></form><legend id='OiQx1'></legend><bdo id='OiQx1'><pre id='OiQx1'><center id='OiQx1'></center></pre></bdo></b><th id='OiQx1'></th></span></q></dt></tr></i><div id='OiQx1'><tfoot id='OiQx1'></tfoot><dl id='OiQx1'><fieldset id='OiQx1'></fieldset></dl></div>
          <legend id='OiQx1'><style id='OiQx1'><dir id='OiQx1'><q id='OiQx1'></q></dir></style></legend>

              <bdo id='OiQx1'></bdo><ul id='OiQx1'></ul>

              <small id='OiQx1'></small><noframes id='OiQx1'>

                本文介绍了使用 Symfony2 设置 Payum Bundle 出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 Symfony 2.6 并尝试设置 PayumBundle(paypal express checkout),但出现错误

                I am working with Symfony 2.6 and trying to setup PayumBundle (paypal express checkout) and I am getting an error

                InvalidConfigurationException in BaseNode.php line 313: Invalid configuration for path "payum.security.token_storage": The storage entry must be a valid model class. It is set AcmefeaturesBundleEntityPaymentToken
                

                我正在按照文档

                这就是我的 config.yml 的样子

                    doctrine:
                        orm:
                            auto_generate_proxy_classes: "%kernel.debug%"
                            entity_managers:
                                default:
                                    auto_mapping: true
                                    mappings:
                                        payum:
                                            is_bundle: false
                                            type: xml
                                            dir: %kernel.root_dir%/../vendor/payum/core/Payum/Core/Bridge/Doctrine/Resources/mapping
                                            prefix: PayumCoreModel
                
                    payum:
                        security:
                            token_storage:
                                AcmefeaturesBundleEntityPaymentToken: { doctrine: orm }
                
                        storages:
                            AcmefeaturesBundleEntityPaymentDetails: { doctrine: orm }
                
                        contexts:
                            paypal:
                                paypal_express_checkout_nvp:
                                    username: 'asdasd'
                                    password: 'adsasd'
                                    signature: 'asdasdasd'
                                    sandbox: true
                

                这是我的实体 PaymentToken

                namespace AcmefeaturesBundleEntity;
                
                use DoctrineORMMapping as ORM;
                use PayumCoreModelToken;
                
                /**
                 * @ORMTable
                 * @ORMEntity
                 */
                class PaymentToken extends Token
                {
                
                }
                

                这是实体PaymentDetails

                namespace AcmefeaturesBundleEntity;
                
                use DoctrineORMMapping as ORM;
                use PayumCoreModelOrder as BaseOrder;
                
                /**
                 * @ORMTable
                 * @ORMEntity
                 */
                class PaymentDetails extends BaseOrder
                {
                    /**
                     * @ORMColumn(name="id", type="integer")
                     * @ORMId
                     * @ORMGeneratedValue(strategy="IDENTITY")
                     *
                     * @var integer $id
                     */
                    protected $id;
                }
                

                我已经浏览了很多在线文档和其他帖子,例如 this 但我不明白为什么我会收到这个错误.

                I have gone through alot of documentation online and other posts like this but I dont understand why I am getting this error.

                The storage entry must be a valid model class. It is set AcmefeaturesBundleEntityPaymentToken
                

                我什至无法进入控制器,所以有些东西告诉我是 Payum 的 config.yml 配置设置不正确.我一遍又一遍地浏览文档,但似乎找不到我做错了什么.

                I cant even get to the controller so something tells me it is the config.yml configuration of Payum that is not set correctly. I have gone through the documentation over and over and over and I cant seem to find what am I doing wrong.

                我将非常感谢您通过此错误获得的任何帮助.

                I will really appreciate any help in getting pass this error.

                推荐答案

                我终于完成了.

                我需要 4 个文件

                1. 支付控制器
                2. 订单(实体)
                3. PaymentToken(实体)
                4. 订单(模型)

                这是我的 PaymentController 看起来像

                <?php
                
                namespace ClickTeckfeaturesBundleController;
                
                use ClickTeckfeaturesBundleEntityOrders;
                use SymfonyBundleFrameworkBundleControllerController;
                use PayumPaypalExpressCheckoutNvpApi;
                use PayumCoreRegistryRegistryInterface;
                use PayumCoreRequestGetHumanStatus;
                use PayumCoreSecurityGenericTokenFactoryInterface;
                use SymfonyComponentHttpFoundationRequest;
                use SymfonyComponentHttpFoundationJsonResponse;
                use SensioBundleFrameworkExtraBundleConfiguration as Extra;
                
                
                    class PaymentController extends Controller
                    {
                        public function preparePaypalExpressCheckoutPaymentAction(Request $request)
                        {
                            $paymentName = 'paypal';
                            $eBook = array(
                                'author' => 'Jules Verne',
                                'name' => 'The Mysterious Island',
                                'description' => 'The Mysterious Island is a novel by Jules Verne, published in 1874.',
                                'price' => 8.64,
                                'currency_symbol' => '$',
                                'currency' => 'USD',
                                'clientId' => '222',
                                'clientemail' => 'xyz@abc.com'
                            );
                
                
                
                            $storage = $this->get('payum')->getStorage('ClickTeckfeaturesBundleEntityOrders');
                            /** @var $paymentDetails Orders */
                            $paymentDetails = $storage->create();
                
                            $paymentDetails->setNumber(uniqid());
                            $paymentDetails->setCurrencyCode($eBook['currency']);
                            $paymentDetails->setTotalAmount($eBook['price']);
                            $paymentDetails->setDescription($eBook['description']);
                            $paymentDetails->setClientId($eBook['clientId']);
                            $paymentDetails->setClientEmail($eBook['clientemail']);
                
                
                            $paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = $eBook['currency'];
                            $paymentDetails['PAYMENTREQUEST_0_AMT'] = $eBook['price'];
                            $paymentDetails['NOSHIPPING'] = Api::NOSHIPPING_NOT_DISPLAY_ADDRESS;
                            $paymentDetails['REQCONFIRMSHIPPING'] = Api::REQCONFIRMSHIPPING_NOT_REQUIRED;
                            $paymentDetails['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = Api::PAYMENTREQUEST_ITERMCATEGORY_DIGITAL;
                            $paymentDetails['L_PAYMENTREQUEST_0_AMT0'] = $eBook['price'];
                            $paymentDetails['L_PAYMENTREQUEST_0_NAME0'] = $eBook['author'].'. '.$eBook['name'];
                            $paymentDetails['L_PAYMENTREQUEST_0_DESC0'] = $eBook['description'];
                            $storage->update($paymentDetails);
                            $captureToken = $this->getTokenFactory()->createCaptureToken(
                                $paymentName,
                                $paymentDetails,
                                'payment_done'
                            );
                            $paymentDetails['INVNUM'] = $paymentDetails->getId();
                            $storage->update($paymentDetails);
                            return $this->redirect($captureToken->getTargetUrl());
                
                
                        }
                
                        public function doneAction(Request $request)
                        {
                
                            $token = $this->get('payum.security.http_request_verifier')->verify($request);
                
                            $payment = $this->get('payum')->getPayment($token->getPaymentName());
                
                            // you can invalidate the token. The url could not be requested any more.
                            // $this->get('payum.security.http_request_verifier')->invalidate($token);
                
                            // Once you have token you can get the model from the storage directly.
                            //$identity = $token->getDetails();
                            //$order = $payum->getStorage($identity->getClass())->find($identity);
                
                            // or Payum can fetch the model for you while executing a request (Preferred).
                            $payment->execute($status = new GetHumanStatus($token));
                            $order = $status->getFirstModel();
                
                            // you have order and payment status
                            // so you can do whatever you want for example you can just print status and payment details.
                
                            return new JsonResponse(array(
                                'status' => $status->getValue(),
                                'response' => array(
                                    'order' => $order->getTotalAmount(),
                                    'currency_code' => $order->getCurrencyCode(),
                                    'details' => $order->getDetails(),
                                ),
                            ));
                
                        }
                
                        /**
                         * @return RegistryInterface
                         */
                        protected function getPayum()
                        {
                            return $this->get('payum');
                        }
                        /**
                         * @return GenericTokenFactoryInterface
                         */
                        protected function getTokenFactory()
                        {
                            return $this->get('payum.security.token_factory');
                        }
                
                    }
                

                这是我的订单实体

                <?php
                
                namespace ClickTeckfeaturesBundleEntity;
                
                use DoctrineORMMapping as ORM;
                use ClickTeckfeaturesBundleModelOrders as BasePaymentDetails;
                
                /**
                 * Orders
                 */
                class Orders extends BasePaymentDetails
                {
                    /**
                     * @var integer
                     */
                    protected $id;
                
                    private $number;
                
                    private $description;
                
                    private $client_email;
                
                    private $client_id;
                
                    private $total_amount;
                
                    private $currency_code;
                
                    protected $details;
                
                
                
                    /**
                     * Get id
                     *
                     * @return integer 
                     */
                    public function getId()
                    {
                        return $this->id;
                    }
                
                    /**
                     * Set number
                     *
                     * @param integer $number
                     * @return Orders
                     */
                    public function setNumber($number)
                    {
                        $this->number = $number;
                
                        return $this;
                    }
                
                    /**
                     * Get number
                     *
                     * @return integer 
                     */
                    public function getNumber()
                    {
                        return $this->number;
                    }
                
                    /**
                     * Set description
                     *
                     * @param string $description
                     * @return Orders
                     */
                    public function setDescription($description)
                    {
                        $this->description = $description;
                
                        return $this;
                    }
                
                    /**
                     * Get description
                     *
                     * @return string 
                     */
                    public function getDescription()
                    {
                        return $this->description;
                    }
                
                    /**
                     * Set client_email
                     *
                     * @param string $clientEmail
                     * @return Orders
                     */
                    public function setClientEmail($clientEmail)
                    {
                        $this->client_email = $clientEmail;
                
                        return $this;
                    }
                
                    /**
                     * Get client_email
                     *
                     * @return string 
                     */
                    public function getClientEmail()
                    {
                        return $this->client_email;
                    }
                
                    /**
                     * Set client_id
                     *
                     * @param string $clientId
                     * @return Orders
                     */
                    public function setClientId($clientId)
                    {
                        $this->client_id = $clientId;
                
                        return $this;
                    }
                
                    /**
                     * Get client_id
                     *
                     * @return string 
                     */
                    public function getClientId()
                    {
                        return $this->client_id;
                    }
                
                    /**
                     * Set total_amount
                     *
                     * @param float $totalAmount
                     * @return Orders
                     */
                    public function setTotalAmount($totalAmount)
                    {
                
                        $this->total_amount = $totalAmount;
                        return $this;
                    }
                
                    /**
                     * Get total_amount
                     *
                     * @return float
                     */
                    public function getTotalAmount()
                    {
                        return $this->total_amount;
                    }
                
                    /**
                     * Set currency_code
                     *
                     * @param string $currencyCode
                     * @return Orders
                     */
                    public function setCurrencyCode($currencyCode)
                    {
                        $this->currency_code = $currencyCode;
                
                        return $this;
                    }
                
                    /**
                     * Get currency_code
                     *
                     * @return string 
                     */
                    public function getCurrencyCode()
                    {
                        return $this->currency_code;
                    }
                
                    /**
                     * Set details
                     *
                     * @param string $details
                     * @return Orders
                     */
                    public function setDetails($details)
                    {
                        $this->details = $details;
                
                        return $this;
                    }
                
                    /**
                     * Get details
                     *
                     * @return string 
                     */
                    public function getDetails()
                    {
                        return $this->details;
                    }
                }
                

                这是我的PaymentToken实体

                <?php
                
                namespace ClickTeckfeaturesBundleEntity;
                
                use DoctrineORMMapping as ORM;
                use PayumCoreModelToken;
                
                /**
                 * PaymentToken
                 */
                class PaymentToken extends Token
                {
                
                }
                

                这是我的订单模型

                <?php
                
                namespace ClickTeckfeaturesBundleModel;
                
                use PayumCoreModelArrayObject;
                
                    class Orders extends ArrayObject
                    {
                        protected $id;
                        /**
                         * @return int
                         */
                        public function getId()
                        {
                            return $this->id;
                        }
                    }
                

                1. 现在当我调用 Action 时preparePaypalExpressCheckoutPaymentAction 通过路由
                2. 我被重定向到付款
                3. 我可以在 doneAction
                4. 中看到响应
                1. Now when I call the Action preparePaypalExpressCheckoutPaymentAction via route
                2. I get redirected to make the payment
                3. I can see the response in doneAction

                非常整洁的图书馆.我花了一段时间才弄明白,我很高兴它现在有效.我相信我还有很多关于 Payum 的知识要学习,我希望有人能确认这是否是正确的方法 :)

                Very neat library. Took me a while to figure it out and I am glad it works now. I am sure i have alot more to learn about Payum and I hope someone can confirm if this is the right way :)

                这篇关于使用 Symfony2 设置 Payum Bundle 出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Paypal 支付 pro 和 pci 合规性 下一篇:贝宝直接付款不起作用

                相关文章

                  <bdo id='D23Ua'></bdo><ul id='D23Ua'></ul>

                  <i id='D23Ua'><tr id='D23Ua'><dt id='D23Ua'><q id='D23Ua'><span id='D23Ua'><b id='D23Ua'><form id='D23Ua'><ins id='D23Ua'></ins><ul id='D23Ua'></ul><sub id='D23Ua'></sub></form><legend id='D23Ua'></legend><bdo id='D23Ua'><pre id='D23Ua'><center id='D23Ua'></center></pre></bdo></b><th id='D23Ua'></th></span></q></dt></tr></i><div id='D23Ua'><tfoot id='D23Ua'></tfoot><dl id='D23Ua'><fieldset id='D23Ua'></fieldset></dl></div>

                  <tfoot id='D23Ua'></tfoot>

                  <small id='D23Ua'></small><noframes id='D23Ua'>

                  <legend id='D23Ua'><style id='D23Ua'><dir id='D23Ua'><q id='D23Ua'></q></dir></style></legend>