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

Capture action when customer leave PayU after success payment #6

Open
wujku opened this issue Aug 11, 2016 · 11 comments
Open

Capture action when customer leave PayU after success payment #6

wujku opened this issue Aug 11, 2016 · 11 comments

Comments

@wujku
Copy link

wujku commented Aug 11, 2016

How to handle case when customer paid and leave PayU, not going back to the application?
I try handle this by event "payum.gateway.post_execute", but notify event with status "completed" no give my payment model (return ArrayObject with details).
Do you have the right way to resolve this?

@mkurzeja
Copy link
Contributor

State changes are handled by notification url (notification is sent in background by PayU), not by the return url itself. I will try to find and upload some code examples from our projects.

@wujku
Copy link
Author

wujku commented Aug 11, 2016

I'm looking forward to your answer

@mkurzeja
Copy link
Contributor

@wujku I'm not 100% sure but as far as I remember this gateway handles payment notifications. https://github.com/accesto/PayumPayU/blob/master/Action/NotifyAction.php handles the status change, and the post_execute event is triggered.

Just to make sure: are you testing this using a publicly accessible domain/url? Because this won't work for localhost, as PayU can't connect to your host.

@wujku
Copy link
Author

wujku commented Aug 11, 2016

@mkurzeja Yes, I used ngrok tunnel for tests. I saw PayU POST requests to notifyAction (with status PENDING and COMPLETED) and I catch post_execute events (by class which I paste below). But only CaptureAction (after user back from shop to application) give me a correct model (e.g. Acme\PaymentBundle\Entity\Payment). NotifyAction for $request->getFirstModel() returns ArrayObject with order details (includes 'completed' status).
I would like to modify related object with Acme\PaymentBundle\Entity\Payment after payment is completed.

<?php

namespace Acme\PaymentBundle\Event\Listener\UpdatePaymentStatus

use Payum\Core\Bridge\Symfony\Event\ExecuteEvent;
use Payum\Core\Request\Generic;
use Payum\Core\Request\GetStatusInterface;
use Acme\PaymentBundle\Entity\Payment;

class UpdatePaymentStatus
{
    public function updateStatus(ExecuteEvent $event)
    {
        $request = $event->getContext()->getRequest();

        if ($request instanceof GetStatusInterface && $request instanceof Generic) {
            $payment = $request->getFirstModel();
            if ($request->isCaptured() && $payment instanceof Payment) {
                // payment is completed and succeeded
                // do whatever you want
            }
        }
    }
}

@mkurzeja
Copy link
Contributor

@wujku did you succeed with this issue? If the notify url is executed by PayU then this should work. We would probably need to have the whole codebase of your project and go step by step with xdebug through it so probably it would be better if you could check where it stops.

Basically you need at least to have a breakpoint inside the notify action (action in controller, not Payum action) + inside our NotifyAction from this component + inside your listeners.

@mkurzeja
Copy link
Contributor

Short update: we managed to reproduce this issue on one of our projects and are working on a fix.

@wujku
Copy link
Author

wujku commented May 12, 2017

I have contact with PayU support at November, regarding issues with sandbox (very long wait for complete response etc.) and they turned it off. I did not check if they activated it back. @mkurzeja problem with notifyAction still exists.

@cve
Copy link

cve commented Nov 17, 2017

I have the same problem

@mkurzeja
Copy link
Contributor

@cve thanks bringing up this topic. We will take a deeper look at it early next month

@mkurzeja
Copy link
Contributor

@cve could you please try it again with current master?

@cve
Copy link

cve commented Nov 17, 2017

@mkurzeja ok, I will try it with next few days and report the results, thanks

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