On the back of my work in DEVSDK-3085, we're adding support for non-verified webhook handing to the managed handlers. There were two key design stipulations:
It should be impossible to handle a webhook on the with-verification handler without supplying a signature header. As a result, we have to be very careful about overwriting/mixing our handle methods and if/when we call the signature verification methods.
The without-verification handler should feel like an implementation detail (where possible). Users should feel like they're interacting with "The" event notification handler
To that end, the main entrypoint for the non-verified handler is a new method on the client and a static method on the with-verification handler. The non-verified handlers are public in each language so users can interact with them normally, but the intention is that they're not something the user thinks much about on their own.
Design wise, the exact implementation varied between languages, but the general idea was the same. I moved all the generated on_* methods onto a private base class, then added sibling handlers for the "with" and "without" verification paths. That way they each have distinct handle methods and it's impossible for a caller to see the "wrong" one. If we had used inheritance, then the child would have the parent's handle signature exposed, which is confusing (even if we overrode it to always error).
What?
Add StripeEventNotificationHandlerWithoutVerification class and associated constructors, docstrings, and client methods
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
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.
Why?
On the back of my work in DEVSDK-3085, we're adding support for non-verified webhook handing to the managed handlers. There were two key design stipulations:
To that end, the main entrypoint for the non-verified handler is a new method on the client and a static method on the with-verification handler. The non-verified handlers are public in each language so users can interact with them normally, but the intention is that they're not something the user thinks much about on their own.
Design wise, the exact implementation varied between languages, but the general idea was the same. I moved all the generated on_* methods onto a private base class, then added sibling handlers for the "with" and "without" verification paths. That way they each have distinct handle methods and it's impossible for a caller to see the "wrong" one. If we had used inheritance, then the child would have the parent's handle signature exposed, which is confusing (even if we overrode it to always error).
What?
See Also