我正在使用PayumBundle在我的网站中进行Paypal集成。
我已经按照如下所述设置了捆绑包
https://github.com/Payum/PayumBundle/blob/master/Resources/doc/get_it_started.md

并为payum安装了paypal express checkout nvp扩展。

这是我的控制器:

            $gatewayName = 'paypal-express-checkout-nvp';

            $storage = $this->get('payum')->getStorage(PaymentDetails::class);

            $details = $storage->create();
            $details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'CHF';
            $details['PAYMENTREQUEST_0_AMT'] = $amount;
            $storage->update($details);

            $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken(
                $gatewayName, $details, 'payment_done'
            );

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


这是配置文件:

payum:
  security:
    token_storage:
        MyBundle\Entity\PaymentToken: { doctrine: orm }

  storages:
    MyBundle\Entity\PaymentDetails: { doctrine: orm }

  gateways:
    paypal-express-checkout-nvp:
        factory: paypal_express_checkout
        username:  %paypal_user%
        password:  %paypal_password%
        signature: %paypal_signature%
        sandbox: true


但是,当我提交表格时,出现以下错误”

 Catchable Fatal Error: Argument 3 passed to Payum\Paypal\ExpressCheckout\Nvp\Api::__construct() must be an instance of Http\Message\MessageFactory, null given, called in vendor/payum/paypal-express-checkout-nvp/Payum/Paypal/ExpressCheckout/Nvp/PaypalExpressCheckoutGatewayFactory.php on line 89 and defined in vendor/payum/paypal-express-checkout-nvp/Payum/Paypal/ExpressCheckout/Nvp/Api.php at 317


我看了一下PaypalExpressCheckoutGatewayFactory类,其中在第89行的populateConfig函数中传递了配置,

 return new Api($paypalConfig, $config['payum.http_client'], $config['httplug.message_factory']);


键“ httplug.message_factory”未在任何地方定义?

堆栈跟踪:

 0 vendor/payum/paypal-express-checkout-nvp/Payum/Paypal/ExpressCheckout/Nvp/Api.php(317): Symfony\Component\Debug\ErrorHandler->handleError(4096, 'Argument 3 pass...', '...', 317, Array)
 1 vendor/payum/paypal-express-checkout-nvp/Payum/Paypal/ExpressCheckout/Nvp/PaypalExpressCheckoutGatewayFactory.php(89): Payum\Paypal\ExpressCheckout\Nvp\Api->__construct(Array, Object(Payum\Core\Bridge\Guzzle\HttpClient), NULL)
 2 [internal function]: Payum\Paypal\ExpressCheckout\Nvp\PaypalExpressCheckoutGatewayFactory->Payum\Paypal\ExpressCheckout\Nvp\{closure}(Object(Payum\Core\Bridge\Spl\ArrayObject))
 3 vendor/payum/core/Payum/Core/CoreGatewayFactory.php(123): call_user_func(Object(Closure), Object(Payum\Core\Bridge\Spl\ArrayObject))
 4 vendor/payum/core/Payum/Core/Bridge/Symfony/ContainerAwareCoreGatewayFactory.php(35): Payum\Core\CoreGatewayFactory->buildClosures(Object(Payum\Core\Bridge\Spl\ArrayObject))
 5 vendor/payum/core/Payum/Core/CoreGatewayFactory.php(40): Payum\Core\Bridge\Symfony\ContainerAwareCoreGatewayFactory->buildClosures(Object(Payum\Core\Bridge\Spl\ArrayObject))
 6 vendor/payum/core/Payum/Core/GatewayFactory.php(33): Payum\Core\CoreGatewayFactory->create(Array)
 7 vendor/payum/core/Payum/Core/PayumBuilder.php(422): Payum\Core\GatewayFactory->create(Array)
 8 app/cache/dev/appDevDebugProjectContainer.php(2209): Payum\Core\PayumBuilder->getPayum()
 9 vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php(316): appDevDebugProjectContainer->getPayumService()
 10 vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php(391): Symfony\Component\DependencyInjection\Container->get('payum')
 11 src/zenpme/BusinessBundle/Controller/PaymentController.php(74): Symfony\Bundle\FrameworkBundle\Controller\Controller->get('payum')
 12 [internal function]: BusinessBundle\Controller\PaymentController->indexAction(Object(Symfony\Component\HttpFoundation\Request))
 13 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(139): call_user_func_array(Array, Array)
 14 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(62): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
 15 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php(69): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 16 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(185): Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 17 web/app_dev.php(30): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
 18 {main}

最佳答案

确保您具有至少payum/core版本。


Payum库中的更改:https://github.com/Payum/Payum/pull/505
Payum捆绑包中的更改:https://github.com/Payum/PayumBundle/pull/353/files
相关的github问题:https://github.com/Payum/PayumBundle/issues/356

关于symfony - Symfony2.8集成Payum捆绑包,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36355133/

10-10 20:25