Issue/2867 use async pos payments #2868
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Using an asynchronous call to initiate POS payment request, followed by synchronous status calls. Polls every ~2 seconds for the status until it's final.
Tested scenarios
a. Cancel payment, check result (OK)
b. Approve payment, check result (OK)
I've created functional tests for our PWA platform. Didn't test the Magento frontend. Since it's already checking for the "In Progress" string if the POS payment request fails, it should be working. Please add the necessary unit / functional tests if desired.
We could exchange the status requests for a request with a more reasonable timeout (e.g. 30 seconds) which gives a response as soon as the notification has been received by the webhook, or when it hits the timeout (in which case the client should retry). This would eliminate the 2 seconds delay and provide a quicker response. Since this requires more changes, I have left it at that for now.
Note: If I would have implemented the Adyen (POS) API directly in a custom module things would probably have been organized a bit different in order to create a more robust solution (see comments in the created issue).
Fixes #2867