Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling capture method #522

Open
tsdevelopment opened this issue Jan 31, 2021 · 2 comments
Open

Error when calling capture method #522

tsdevelopment opened this issue Jan 31, 2021 · 2 comments

Comments

@tsdevelopment
Copy link

When I install the bundle with a fresh Symfony 5.2 installation I got the following error:

Attempted to load class "MergeQuery" from namespace "League\Uri\Modifiers".
Did you forget a "use" statement for another namespace?

My configuration:

payum:
    storages:
        App\Entity\Payment: { doctrine: orm }

    security:
        token_storage:
            App\Entity\PaymentToken: { doctrine: orm }

    gateways:
        paypal_express_checkout:
            factory: paypal_express_checkout
            username: ****
            password: ****
            signature: ****
<?php

namespace App\Controller;

use App\Entity\Payment;
use Payum\Core\Payum;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class PaymentController extends AbstractController
{
    private Payum $payum;

    public function __construct(Payum $payum)
    {
        $this->payum = $payum;
    }

    #[Route('/payment', name: 'payment')]
    public function index(): Response
    {
        $storage = $this->payum->getStorage(Payment::class);

        /** @var Payment $payment */
        $payment = $storage->create();
        $payment->setNumber(uniqid());
        $payment->setCurrencyCode('EUR');
        $payment->setTotalAmount(123); // 1.23 EUR
        $payment->setDescription('A description');
        $payment->setClientId('anId');
        $payment->setClientEmail('foo@example.com');

        $storage->update($payment);

        $captureToken = $this->payum->getTokenFactory()->createCaptureToken(
            'paypal_express_checkout',
            $payment,
            'done' // the route to redirect after capture
        );

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

Seems to be a problem with the https://github.com/thephpleague/uri package that is used in payum/payumb/c the packages changed and moved the methodes in it's own packages. Currently the bundle is not useable :(

@tsdevelopment tsdevelopment changed the title Error when calling capure method Error when calling capture method Jan 31, 2021
@pierredup
Copy link
Member

@tsdevelopment What version of payum/core do you have?

Can you please try changing your composer.json to use

{
    "require": {
        "payum/core": "dev-master"
    }
}

and run composer update payum/core?

In the master branch, there has been some changed to thephpleague/uri to support the latest version, so maybe that can fix your issue.

@guivincent16
Copy link

guivincent16 commented Feb 18, 2021

Hello, I have the same problem on Symfony 5.2.

Attempted to load class "MergeQuery" from namespace "League\Uri\Modifiers".
Did you forget a "use" statement for another namespace?

========
#vendor\payum\paypal-express-checkout-nvp\Payum\Paypal\ExpressCheckout\Nvp\Action\PurchaseAction.php (line 70)

  if ($details['CANCELURL']) {
      $cancelUri = HttpUri::createFromString($details['CANCELURL']);
      $modifier = new MergeQuery('cancelled=1');
      $cancelUri = $modifier->process($cancelUri);
      $details['CANCELURL'] = (string) $cancelUri;
  }

My composer.json :
"require": {
...
"league/uri": "^6.4",
"payum/core": "dev-master",
"payum/offline": "^1.6",
"payum/paypal-express-checkout-nvp": "^1.6",
"payum/payum-bundle": "^2.4",
"php-http/guzzle6-adapter": "^2.0",
...
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants