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

Long redirect #14

Open
pbritka opened this issue May 12, 2023 · 9 comments
Open

Long redirect #14

pbritka opened this issue May 12, 2023 · 9 comments

Comments

@pbritka
Copy link

pbritka commented May 12, 2023

Has anyone experienced this problem?

When a user is redirected to the gateway (with QR code), there's a status javascript request that checks the status of the payment every 2 s. That is hardcoded in the BTC pay server, so not much we can do about it.

The user pays and the browser starts redirecting back to Magento btcpay/redirect/returnafterpayment (that's the URL ending with 61eaf8365c3629985bf582ad4a5d8e18c2c4ecf4). This redirects to checkout/onepage/success. However, these requests take more than 2 s. In the meantime, the status script sends another request back to Magento.

The result is that the browser tries redirecting for about 10 min, until it finally gives up and the user is redirected back to the success page.

Can we solve it somehow?

@woutersamaey
Copy link
Collaborator

Can you explain differently? It doesn't make much sense. If it redirecting or not? Why 10 minutes if it's only taking 2sec?

@pbritka
Copy link
Author

pbritka commented May 12, 2023

Screenshot 2023-05-12 at 14 27 17

Sorry, I forgot to attach a screenshot.

Because the redirection hasn't finished and the status script initiated another redirect.

@woutersamaey
Copy link
Collaborator

So BTCPay is redirecting you every 2 seconds forever? is that what you are saying?
If so, this would be a BTCPay issue and not a Magento issue.

@pbritka
Copy link
Author

pbritka commented May 12, 2023

Yes, however there's nothing I can do with the BTC server. I just did a test on Magento side where in the ReturnAfterPayment controller I added simple exit() and it works for me. So a solution would be if I could process the whole request below 2 s. I'm just asking if anyone has faced a similar issue.

@woutersamaey
Copy link
Collaborator

Any idea why it is taking longer than 2 sec? Is it trying to connect to BTCPay API and getting a timeout perhaps? Not sure how long it should take, but 2sec may be an indication something is off.
That said, Magento 2 can be very slow at times...

@pbritka
Copy link
Author

pbritka commented May 12, 2023

Not at the moment. I'm going to look at the issue. It might be not related to BTC pay at all. Was just curious.

@pbritka
Copy link
Author

pbritka commented May 15, 2023

I've fixed this issue. If anyone is interested, this is how I did it.

I've created a plugin for Storefront\BTCPay\Model\BTCPay\BTCPayService where I defined a different return after payment URL. This URL is just a simple controller with a template in our Magento installation. All it does is it shows a message "The payment is processing, don't close this window". There's a javascript on DOM load that redirects the customer to the original btcpay/redirect/returnafterpayment with all the needed params.

The purpose of this custom URL is that it sends out the response very quickly. It takes less than a second, which cause the status check script (which runs every 2 s) not to execute anymore and our customer is shown the checkout success page with all the code that needs to execute there.

@woutersamaey
Copy link
Collaborator

We just released v 2.0.6. Does this help your case?

@pbritka
Copy link
Author

pbritka commented Jun 16, 2023

Thanks for the info. From the quick look in diff probably not, but I'll have a look when I work with this extension on our code next time. However the solution I posted last month solves the issue.

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