Report test webhook errors in the live environment as warnings #3696
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.
Stripe sends both test and live webhooks to the live endpoint (docs). However signature validation here does not account for this, so test mode events fail validation and get logged as errors. On WPCOM we have alerts that trigger on these errors, which for test events are spurious.
This patch changes the log severity level to
debug
for errors in test mode events.A further improvement would be to change
validate_request
to account for test mode events, but this is a bigger change. It also doesn't solve the current problem -- test mode signatures would be successfully validated, but any other test mode errors would still get reported as production errors.Testing
To test manually, we'll need the event ID of a test mode webhook sent to the live site. All test events are sent to the live site so any should work; I'm using
setup_intent.succeeded
because that was the event type that instigated this PR). There is a log of these at https://dashboard.stripe.com/test/events.I then redirected stripe
setup_intent.succeeded
webhooks to a dev site using a stripe CLI command like this (change the event type and site domain as needed):We can resend an event with a command like this (use your own event ID):
I think the event can also be resent from the stripe admin from the dot menu on an attempt log entry like this one:
If that worked the CLI should report something like this:
Since this was a test mode event, it should fail validation and get logged at debug level.
changelog.txt
andreadme.txt
(or does not apply)Post merge