Repository navigation
Accept Stripe webhook events from any API version - #879
Open
KrzysztofPajak wants to merge 1 commit into
Open
KrzysztofPajak wants to merge 1 commit into
KrzysztofPajak wants to merge 1 commit into
Conversation
The webhook endpoint sends events in the account's default API version, which rarely matches the version Stripe.net pins. ConstructEvent rejected those events, so successful payments were never recorded. The fields read from the PaymentIntent are stable across versions, so the version check is turned off. A failed verification was also swallowed: the controller still answered 200, Stripe considered the event delivered and never retried. The exception is now rethrown, the webhook answers 400 and the failure is visible and retried in the Stripe dashboard.
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.
Type: bugfix
Issue
The Stripe Checkout webhook (
PaymentStripeCheckout/WebHook) did not mark orders as paid.The webhook endpoint configured in the Stripe dashboard sends events in the API version set on that endpoint, which by default is the account's default version. That version often differs from the one pinned by Stripe.net 52.4.2 (
2026-08-26.dahlia).EventUtility.ConstructEventthrows on the mismatch by default, so everypayment_intent.succeededevent was rejected and no payment transaction was created.The failure was also silent.
WebHookProcessPaymentcaught theStripeException, logged it and returnedfalse, and the controller still answered200 OK. Stripe therefore considered the event delivered, showed no error and never retried it.Fix by configuration (works without this PR)
Setting the webhook endpoint's API version to
2026-08-26.dahlia(Stripe dashboard → Developers → Webhooks → the endpoint → API version) makes the events match Stripe.net, and the webhook works on the current code. This was confirmed on a live store.The configuration has to be repeated whenever a GrandNode release upgrades Stripe.net, and nothing tells the store owner when it falls out of step. This PR removes that dependency and makes such failures visible.
Solution
ConstructEventis called withthrowOnApiVersionMismatch: false. The signature is still verified. The fields read from thePaymentIntent(amount, currency, metadata with the order id) are stable across API versions.catchin the controller answers400. Stripe then shows the failed delivery and retries it.tryblock. Its logic is unchanged.Breaking changes
None. The public interface
IStripeCheckoutServiceis unchanged. The only behaviour change is that the webhook returns 400 instead of 200 when the signature cannot be verified.Testing
/PaymentStripeCheckout/WebHook(or usestripe listen --forward-to). Set the endpoint's API version to something other than2026-08-26.dahlia.4242 4242 4242 4242.