Create orders via webhook when necessary#139
Merged
duncanmcclean merged 21 commits into1.xfrom Feb 20, 2026
Merged
Conversation
|
Released as part of v1.1.0. |
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.
This pull request fixes an issue where orders wouldn't be created unless the customer reaches the payment gateway's "callback URL".
This could happen for a number of reasons -- but specifically in #137, customers were closing the tab after seeing BLIK's confirmation page.
Solution
This PR fixes the issue by creating orders via webhooks if they don't already exist.
I've extracted the logic out of the
CheckoutController(the callback URL) into an action, so it can be re-used when processing webhooks.When the Stripe/Mollie webhooks can't find an order, they'll attempt to find a cart and create an order from it before continuing with the rest of their logic.
If the callback URL is hit while the webhook is creating the order (or vice versa), they'll need to wait on the order being created in the other request before continuing.
If the order can't be created - for example: there's no address, or there's not enough stock available to fulfil the order - the order will be created, immediately cancelled and the payment will be reversed. It's not the best UX right now, but I'm planning on circling back to it in the future.
Fixes #137