Feature/KUSTOM 92 push controller refactoring#10
Open
jooname wants to merge 12 commits into
Open
Conversation
…th different Magento versions
…currently occurring errors related to premature order cancelling based on very generic exception throwing
…te order state updates and order creation flows, removed also cancelling of orders when encountering LocalizedException
…ws, refactored the logic to remove the overlap
…bose, as the API logger only adds data to database which we can't necessarily grab in scope of test pipelines
… the logic flow in 2.4.5 and 2.4.6 test executions
… in order to get around the issue in more strict region validations in 2.4.5 and 2.4.6 in tests
…ce we may not at the moment support region_id information in the first place, only region field
vaimohe
approved these changes
May 28, 2026
… included in next release
…ller as in the push controller to solve issue with unnecessary cancellations. Updated also the checks for already created orders in case of hitting LocalizedException to be more certain about correctly recognizing the created order, as previously we relied on a class property value which wasn't necessarily even set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Contains also changes from #8 since this branch was started from there: easier to run test automations when blockers for running the tests are solved as well.
The changes here address the root cause for calls to the push controller prematurely cancelling orders. In previous releases we have implemented hotfixes to the matter, but this should deal with the cancellations altogether. The root cause: the push controller is not meant to cancel orders in the first place, so I removed the logic to do this. If the push controller call fails, errors will be logged and returned, but order is left in it's original state or however far the process reached. Only situation where cancellation can still happen is if we get Kustom APIs to return cancellation state, although my understanding is in this sort of case we're not going to receive push notification in the first place. I left this still be since it's not behind the premature cancelling cases.
Additionally I did some refactoring in the controller to make the two main logic flows in the controller more clear (order creation and order acknowledgment), as previously these logic flows were controlled by exceptions getting thrown, which only increases the amount of possible mistakes done in the controller. Exceptions thrown are after all not fully in control of the module, so anything can come up and result in wrong behavior. This is still relatively minor change since the logic beyond the controller is more or less the same.
There's also some tests to the push controller, previously there were none. The tests pass in Magento versions from 2.4.5 to 2.4.8 and against both Commerce and Community editions.
Update on 10.6: turns out
checkout/klarna/confirmationcontroller was suffering from similar issues. This controller is accessed when the order gets successfully placed; it's where Kustom redirects the user to continue their activities. So cancelling at this point should not be relevant at all. This has been removed and other error handling has been also adjusted to take the user to success page instead of showing an error in cart, if for example the order was already created by another concurrent request.