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

Slow POS payments cause proxy timeout #2867

Open
pmzandbergen opened this issue Jan 27, 2025 · 4 comments · May be fixed by #2869
Open

Slow POS payments cause proxy timeout #2867

pmzandbergen opened this issue Jan 27, 2025 · 4 comments · May be fixed by #2869
Labels
Bug report Indicates that issue has been marked as a possible bug

Comments

@pmzandbergen
Copy link
Contributor

Already working on a fix, please await the PR

Describe the bug
When initiating a POS payment using one of the following endpoints:

  • /V1/adyen/orders/guest-carts/:cartId/pos-payment
  • /V1/adyen/orders/carts/mine/pos-payment

The browser might receive a timeout if the POS payment takes a bit of time and the webserver (or proxy) is configured with a reasonable (shorter) timeout period. Cloudflare for example has a timeout of 100 seconds, a value which only can modified when using one of the Enterprise plans. This could be fixed using some kind of polling mechanism. Actually the frontend code already seems to include logic for this purpose:

if (response.responseText.indexOf("In Progress") > -1) {

When the browser encounters a (proxy) timeout the response will generally not include "In Progress" and this solution is also not working out-of-the-box for PWA's.

To Reproduce
Steps to reproduce the behavior:

  1. Ensure the webserver or proxy is configured with a timeout of, for example, 60 seconds
  2. Start a POS / terminal payment
  3. Wait for a minute before finishing the payment
  4. See error

Expected behavior
The payment should be polled as long as the POS payment status isn't final.

Magento version
2.4.7-p3

Plugin version
Tested on 9.6.0, the logic is the same at the current version (9.14.0).

Screenshots
Image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Firefox
  • Version: 134.0.2

Smartphone (please complete the following information):
N/A

Additional context
N/A

@pmzandbergen pmzandbergen added the Bug report Indicates that issue has been marked as a possible bug label Jan 27, 2025
@pmzandbergen
Copy link
Contributor Author

There is a config path for timeouts: payment/adyen_pos_cloud/total_timeout (default 120). This path currently isn't available at the Magento backend.

Testing how things are handled if configured.

@pmzandbergen
Copy link
Contributor Author

Lowering this timeout (10 seconds for testing) leads to an internal server error:

Adyen\ConnectionException: Could not connect to Adyen (https://terminal-api-test.adyen.com/sync).  Please check your internet connection and try again. in [...]/vendor/adyen/php-api-library/src/Adyen/HttpClient/CurlClient.php:203

Frontend receives the following response:

{"message":"Internal Error. Details are available in Magento log file. Report ID: webapi-[...]"}

Conclusion: Lowering the configured timeout alone will not resolve this issue. Digging in the code seems that we are using the sync API:

$response = $service->runTenderSync($request);

We probably should use the async instead:
https://docs.adyen.com/api-explorer/terminal-api/latest/overview

Working on a patch.

@pmzandbergen
Copy link
Contributor Author

It seems the POS implementation in the Adyen Magento module does not follow the guidelines as documented by Adyen:

https://docs.adyen.com/point-of-sale/design-your-integration/choose-your-architecture/cloud/

@pmzandbergen
Copy link
Contributor Author

Encountered a bug during testing:

$serviceID = date("dHis");

The ServiceID used in POS Cloud API requests is a timestamp. If multiple requests are created in the same second, you will get an error. I'll change this to a more unique value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug report Indicates that issue has been marked as a possible bug
Projects
None yet
1 participant