3

I am using PayumBundle for paypal integration in my site. I have setup the bundle, as described in https://github.com/Payum/PayumBundle/blob/master/Resources/doc/get_it_started.md

and installed paypal express checkout nvp extension for payum.

This is my controller:

            $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());

Here is config file:

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

However When i submit the form I'm getting following error"

 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

I had a look at PaypalExpressCheckoutGatewayFactory class where config is passed inside populateConfig function at line 89,

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

key 'httplug.message_factory' is not defined anywhere?

STACK TRACE:

 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}

2 Answers2

0

Make sure you have payum/core at least 1.3 version.

Paweł Mikołajczuk
  • 3,692
  • 25
  • 32
0

I got the same problem in Symfony3. To workaround add the array key => value:

httplug.message_factory' => new GuzzleMessageFactory()

in the PaypalExpressCheckoutGatewayFactory config-array. I'll try to find a better solution and update the post later.

You also have to add this use statement:

use Http\Message\MessageFactory\GuzzleMessageFactory;

EDIT I finally got it to work without changing the libraries but I actually don't know how. I installed the application on my server and did the php composer.phar install -o and it works.

This is my composer.json:

 "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.0.*",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "beberlei/DoctrineExtensions": "^1.0",
        "payum/payum-bundle": "^2.0",
        "payum/paypal-express-checkout-nvp": "^1.3"
    },
codeneuss
  • 905
  • 4
  • 12
  • i can not find GuzzleMessageFactory class anywhere. Do I have to install any library for it? This is my current composer.json "payum/payum-bundle": "^2.0", "payum/paypal-express-checkout-nvp": "^1.3", "php-http/guzzle6-adapter": "^1.0" – Tejas Gosai Apr 07 '16 at 04:51
  • Well, I give up. I'm using Paypal's PHP APIs in my application. However I'm keeping this question open. If you find answer please post it, so that someone else can get solution if they are stuck in same error. – Tejas Gosai Apr 07 '16 at 08:36
  • My Composer.json looks like this: "payum/payum-bundle": "^2.0", "payum/paypal-express-checkout-nvp": "^1.3" and nothing else (except standard symfony). – codeneuss Apr 11 '16 at 06:36