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

The "return to the store" link generates an error once the customer is redirected to the store #249

Closed
julienTroopers opened this issue Feb 12, 2024 · 6 comments

Comments

@julienTroopers
Copy link

Sylius version : 1.12.11
SyliusPayPlugPlugin version : 1.9.2

After a successful card payment on the payplug page :

  • if a customer waits to be redirected, they will return to the store through a sylius payment security token associated to the sylius_shop_order_after_pay route.
  • if a customer tries to use the link "return to the store", the same URL is used but the token is already consumed. This result in an error on the store.

I am unsure of how to proceed with this issue.
Should the plugin generate another token+URL to send to payplug for the "return to the store" link ? Is it possible ?

@TheGrimmChester
Copy link
Collaborator

Hello @julienTroopers , as far as I know from the API documentation, we can only provide a return URL.

The token is consumed automatically on the first visit (payum internal work), so we cannot re-use the initial URL. How do you manage to get redirected and then also use the return to the store link?

@julienTroopers
Copy link
Author

My guess is that the redirection call emanates from Payplug rather than the customer browser.
This results in a little bit of latency : the "return to the store" link is usable even after the redirection starts.

In any case, the store receives both requests, and the second one fails.

We'll look into setting up a demo with @gabrielmustiere

@TheGrimmChester
Copy link
Collaborator

I get it, it can happen if you click on the link right when the auto redirection starts, so the browser is making two requests, not PayPlug. I think that there is nothing to do on the plugin side because this is the standard way to handle it "sylius.controller.payum::afterCaptureAction()".

Maybe you could decorate this action to early redirect to another page if the token is already consumed?

@gabrielmustiere
Copy link

To complete the discussion, I tried to click on the redirection link right away, before the autoredirection started, and I still got a 500 error
error

@gabrielmustiere
Copy link

Well, I tried it on a brand new Sylius installation and ... I didn't notice the problem.

@julienTroopers
Copy link
Author

@TheGrimmChester is right, it can happen if you click on the link right when the auto redirection starts.

It also happens if the shop is too slow to respond : as long as the PayPlug page is visible, it can trigger the second redirection. Clicking the "return to the store" link on PayPlug does not cancel the countdown to 'their' redirection.

In our case, it happens as we have a few callbacks when the payment is confirmed. It also happens if I turn on the energy saving feature on my laptop running a brand new Sylius installation : it slows both the store and the browser, leading to more frequent issues :-)

I'll close the issue, thanks for your help.

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