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

[BUG] Unable to generate a URL for the named route #2

Open
raphaelvigee opened this issue Dec 21, 2015 · 3 comments
Open

[BUG] Unable to generate a URL for the named route #2

raphaelvigee opened this issue Dec 21, 2015 · 3 comments

Comments

@raphaelvigee
Copy link

Hello !

I'm using Payum for Silex for a while, but after a composer update, I get this error :

RouteNotFoundException in UrlGenerator.php line 130:
Unable to generate a URL for the named route "/app_dev.php/subscribe/done/k6w6agnZu1N4PlgOggMkUICJiVH5zxh-fbuyme2duds" as such route does not exist.
in UrlGenerator.php line 130
at UrlGenerator->generate('/app_dev.php/subscribe/done/k6w6agnZu1N4PlgOggMkUICJiVH5zxh-fbuyme2duds', array(), '1') in TokenFactory.php line 36
at TokenFactory->generateUrl('/app_dev.php/subscribe/done/k6w6agnZu1N4PlgOggMkUICJiVH5zxh-fbuyme2duds', array()) in AbstractTokenFactory.php line 59
at AbstractTokenFactory->createToken('paypal_ec', object(Payment), 'payum_capture_do', array(), '/app_dev.php/subscribe/done/k6w6agnZu1N4PlgOggMkUICJiVH5zxh-fbuyme2duds', array()) in GenericTokenFactory.php line 40
at GenericTokenFactory->createToken('paypal_ec', object(Payment), 'payum_capture_do', array(), '/app_dev.php/subscribe/done/k6w6agnZu1N4PlgOggMkUICJiVH5zxh-fbuyme2duds') in GenericTokenFactory.php line 58
at GenericTokenFactory->createCaptureToken('paypal_ec', object(Payment), 'SiteSubscribeDone') in Adherent.php line 136
at Adherent->preparePayment('27', array(### SECRET DATA ###)) in subscribe.php line 85
at {closure}(object(Request))
at call_user_func_array(object(Closure), array(object(Request))) in HttpKernel.php line 139
at HttpKernel->handleRaw(object(Request), '1') in HttpKernel.php line 62
at HttpKernel->handle(object(Request), '1', true) in Application.php line 586
at Application->handle(object(Request)) in Application.php line 563
at Application->run() in app_dev.php line 18

Can you help me ?

Thanks ;)

@raphaelvigee
Copy link
Author

I found a workaround; in vendor/payum/core/Payum/Core/Bridge/Symfony/Security/TokenFactory.php :

    protected function generateUrl($path, array $parameters = array())
    {
        if(strpos($path,'/') === false){
            return $this->urlGenerator->generate($path, $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
        }else{
            return 'http://my-url.com'.$path;
        }
    }

But it looks like a bigger problem, because the value generated for example for RETURNURL (Paypal Express Checkout) is a path, and not an URL :

"RETURNURL": "/app_dev.php/payment/capture/vPfCCiCHwPvOd37wlZNbOkfACOthL5mUKpZ22Jee2LQ",

_EDIT :_ The workaround is the solution, but not clean at all.

@makasim
Copy link
Member

makasim commented Dec 21, 2015

Could you post the code of the method Adherent->preparePayment? How did you created a done url: /app_dev.php/subscribe/done/k6w6agnZu1N4PlgOggMkUICJiVH5zxh-fbuyme2duds?

@raphaelvigee
Copy link
Author

The done url only gets the payment status and makes changes in the database. I followed the documentation.

Here is the content of the preparePayment function :

    public function preparePayment($clientId, $clientData){
        $storage = $this->app['payum']->getStorage('Payum\Core\Model\Payment');

        $payment = $storage->create();
        $payment->setNumber($clientData['payment_invoice']);
        $payment->setCurrencyCode('EUR');
        $payment->setTotalAmount($this->app['cout_adhesion']*100);
        $payment->setClientId($clientId);
        $payment->setClientEmail($clientData['email']);

        $payment->setDetails(array(
            'CANCELURL' => $this->app['url_generator']->generate('SiteSubscribeCancel', [], UrlGeneratorInterface::ABSOLUTE_URL),
            'L_PAYMENTREQUEST_0_AMT0' => $this->app['cout_adhesion'],
            'L_PAYMENTREQUEST_0_NAME0' => 'Adhésion',
            'L_PAYMENTREQUEST_0_NUMBER0' => $clientData['payment_invoice'],
            'ALLOWNOTE' => false,
            'LOCALECODE' => 'FR',
            'NOSHIPPING' => true,
        ));

        $storage->update($payment);

        $captureToken = $this->app['payum.security.token_factory']->createCaptureToken('paypal_ec', $payment, 'SiteSubscribeDone');

        return new RedirectResponse($captureToken->getTargetUrl());
    }

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

2 participants