Skip to content

Feature/KUSTOM 92 push controller refactoring#10

Open
jooname wants to merge 12 commits into
mainfrom
feature/KUSTOM-92-push-controller-refactoring
Open

Feature/KUSTOM 92 push controller refactoring#10
jooname wants to merge 12 commits into
mainfrom
feature/KUSTOM-92-push-controller-refactoring

Conversation

@jooname

@jooname jooname commented May 27, 2026

Copy link
Copy Markdown
Contributor

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/confirmation controller 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.

jooname added 10 commits May 6, 2026 09:42
…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
@jooname jooname requested a review from vaimohe May 27, 2026 12:28
jooname added 2 commits June 8, 2026 09:55
…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.
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

Successfully merging this pull request may close these issues.

2 participants