Symfony2 Payum Bundle - 不支持请求 SecuredCaptureRequestmodel: Payment

Posted

技术标签:

【中文标题】Symfony2 Payum Bundle - 不支持请求 SecuredCaptureRequestmodel: Payment【英文标题】:Symfony2 Payum Bundle - Request SecuredCaptureRequestmodel: Payment is not supportedSymfony2 Payum Bundle - 不支持请求 SecuredCaptureRequestmodel: Payment 【发布时间】:2014-07-27 20:00:27 【问题描述】:

我刚刚安装并配置了 payum 捆绑包。我有一个例外:

不支持请求 SecuredCaptureRequestmodel: Payment。

它发生在重定向之后在 PaymentController 中的 preparePaypalExpressCheckoutPaymentAction 中。

支付配置:

payum:
    contexts:
        payment_with_paypal_express:
            storages:
                Service\Bundle\PaymentBundle\Entity\Payment:
                    doctrine:
                        driver: orm
            paypal_express_checkout_nvp:
                api:
                    options:
                        username:  %paypal.express.username%
                        password:  %paypal.express.password%
                        signature: %paypal.express.signature%
                        sandbox:   %paypal.express.sandbox%
    security:
        token_storage:
            Service\Bundle\PaymentBundle\Entity\PayumSecurityToken:
                doctrine:
                    driver: orm

支付控制器:

class PaymentController extends HelperController

    public function preparePaypalExpressCheckoutPaymentAction()
    
        $paymentName = 'payment_with_paypal_express';

        $storage = $this->get('payum')->getStorageForClass(
            'Service\Bundle\PaymentBundle\Entity\Payment',
            $paymentName
        );
        # ---- Set payment details below

        $package = $this->getPackageRepository()->loadOneByAliasAndDuration(Package::TYPE_SUBSCRIPTION,1);
        $accountPackages = new ArrayCollection();
        $accountPackages->add((new AccountPackage())->setPackage($package)->setQuantity(1));

        /**
         * @var Payment $payment
         */
        $payment = $storage->createModel();
        # Account must be set first, packages must be set before paid attribute
        $payment->setAccount($this->getAccount())
                ->setPackages($accountPackages)
                ->setPaid(false);

        # ---- Set payment details above

        $storage->updateModel($payment);

        $captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
            $paymentName,
            $payment,
            'service_payment_done' // the route to redirect after capture;
        );

        $payment->setReturnUrl($captureToken->getTargetUrl())
                ->setCancelUrl($captureToken->getTargetUrl());

        $storage->updateModel($payment);

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

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

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

        # $paymentDetails = $token->getDetails();

        $status = new BinaryMaskStatusRequest($token);

        $payment->execute($status);

        if ($status->isSuccess()) 
            $this->getUser()->addCredits(100);
            $this->get('session')->getFlashBag()->set(
                'notice',
                'Payment success. Credits were added'
            );
        
        else if ($status->isPending()) 
            $this->get('session')->getFlashBag()->set(
                'notice',
                'Payment is still pending. Credits were not added'
            );
        
        else 
            $this->get('session')->getFlashBag()->set('error', 'Payment failed');
        

        return $this->redirect('service_home');
    

有人提示我做错了什么吗?在官方文档中,付款详细信息以对象/数组的形式呈现(有点混乱),但在我的控制器中,我将其设为对象,有什么想法吗?

【问题讨论】:

【参考方案1】:

我解决了。忘记使用 Payum 中的 ArrayObject 扩展我的付款详细信息:)

【讨论】:

或者,您也可以只将 'implements \ArrayAccess, \IteratorAggregate' 添加到您的类中

以上是关于Symfony2 Payum Bundle - 不支持请求 SecuredCaptureRequestmodel: Payment的主要内容,如果未能解决你的问题,请参考以下文章

覆盖 Payum Stripe Bundle 模板

Payum Bundle 的配置如何工作?

Symfony2 模板不支持“bundle”参数

如何在本地使用 wamp 时摆脱 payum“SSL 证书问题:无法获取本地颁发者证书”错误

使用 Sylius 0.16 和 Payum 实施异地支付网关时如何完成订单

在 Symfony2 中访问与 Bundle 相关的文件