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

Correct way to fire event when payment has been processed #499

Open
grekpg opened this issue Nov 1, 2019 · 2 comments
Open

Correct way to fire event when payment has been processed #499

grekpg opened this issue Nov 1, 2019 · 2 comments

Comments

@grekpg
Copy link

grekpg commented Nov 1, 2019

I'm looking simple and correct way to run my process when payment is finish - captured, cancelled.
I think it's a typical requirement.

I don't want to do this in done page - it in my payment method is pending and its user fired. I want when payment gate sends payment finish - background way.

But this is not easy in this bundle.

Events is not fired - so
1 . Add Symfony Events

payum.extension.event_dispatcher:
  class: Payum\Core\Bridge\Symfony\Extension\EventDispatcherExtension
  arguments: ["@event_dispatcher"]
  public: true
  tags:
    - { name: payum.extension, all: true, prepend: true }

documentation has an error - when prepend is true it works when false - here is error
Payum/Payum#821

  1. I cannot found the correct event name - we have only 3 events
    const GATEWAY_PRE_EXECUTE = 'payum.gateway.pre_execute';

    const GATEWAY_EXECUTE = 'payum.gateway.execute';

    const GATEWAY_POST_EXECUTE = 'payum.gateway.post_execute';

I add listener PayumEvents::GATEWAY_POST_EXECUTE

I see that almost every operation in this bundle executes some action so before user finish payment my event is fired many times.

in ExecuteEvent I don't know what is happen - i get_class $event->getContext()->getRequest() and have 7 times event fired

 Payum\Core\Request\GetHttpRequest
Payum\Paypal\ExpressCheckout\Nvp\Request\Api\SetExpressCheckout
 Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetExpressCheckoutDetails
 Payum\Core\Request\Sync
Payum\Paypal\ExpressCheckout\Nvp\Request\Api\AuthorizeToken
Payum\Core\Request\Capture
Payum\Core\Request\Capture

im just moved to paypal website....

ok i make payment - get next 10 times listener fired ?

Payum\Core\Request\GetHttpRequest
Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetExpressCheckoutDetails
 Payum\Core\Request\Sync
 Payum\Paypal\ExpressCheckout\Nvp\Request\Api\DoExpressCheckoutPayment
Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetExpressCheckoutDetails
Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetTransactionDetails
Payum\Core\Request\Sync
 Payum\Core\Request\Capture
 Payum\Core\Request\Capture
Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetExpressCheckoutDetails

uggh...

please help me - in how I can make a decision when i really get paymentDetails status change.

I just need to fire my process when user paid or cancel payment ...

Maybe it should by new event - PayumEvents::PAYMENT_DONE ? (succeeded or not but we have response )

@jkabat
Copy link

jkabat commented Nov 4, 2019

What about using Symfony workflow component for payment status field?

Any status change will fire workflow event on which you can listen.

@Tetragramat
Copy link
Contributor

Use post execute event to get current status as writen here https://github.com/Payum/Payum/blob/master/docs/instant-payment-notification.md
and then use symfony workflow to switch status of your payment.

All you need then is to listen to workflow transition into place captured.

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