-
Notifications
You must be signed in to change notification settings - Fork 458
⚠️ Add strongly typed EventNotifications #1538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
[skip ci]
[skip ci]
xavdid-stripe
commented
Aug 29, 2025
(ignore red CI; docker hub is having a problem so all tests are down. Everything besides compat was good before i merged master back into this and trigger the CI run.) |
jar-stripe
approved these changes
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple comments/questions but otherwise good to go!
ramya-stripe
added a commit
that referenced
this pull request
Sep 25, 2025
* wip generating push payload events [skip ci] * improve generation [skip ci] * generate related object method * Return a union from parse thin event & add UnknownThinEvent * fix unused import * fix related_object generation and add big test * Some name cleanup * rename thin_event * small fixes * export UnknownEventNotification * fix reason parsing * rename thin_event * fix example & re-export event notifications * move some imports * swap event fetch_related_object to stripe-context * update docstring * update comment Co-authored-by: David Brownman <[email protected]> Co-authored-by: Ramya Rao <[email protected]>
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.
Why?
As part of the Next-Gen Event Handling project, we're adding fully typed classes to represent all the
thin eventsEvent Notifications a user could receive. There are also helper methods that help with the event handling experience.What?
just test-one
recipeTHIN_EVENT_CLASSES
from_json
static constructor toEventNotification
See Also
DEVSDK-2662
Changelog
We've overhauled how V2 Events are handled in the SDK! This approach should provide a lot more information at authoring and compile time, leading to more robust integrations. As part of this process, there are a number of changes to be aware of.
EventNotification
classes to every v2Event
. For example, there's now aV1BillingMeterErrorReportTriggeredEventNotification
to match the existingV1BillingMeterErrorReportTriggeredEvent
. Each notification class defines afetch_event()
method to retrieve its corresponding event. For events with related objects, there's afetch_related_object()
method that performs the API call and casts the response to the correct type.StripeClient.parse_thin_event
toStripeClient.parse_event_notification
and remove theStripe.ThinEvent
class.stripe.v2.core.EventNotification
(which is the shared base class that all of the more specificstripe.events.*EventNotification
classes share) instead ofStripe.ThinEvent
. When applicable, these event notifications will have therelated_object
property and afetch_related_object()
function. They also have afetch_()
method to retrieve their correspondingstripe.events.*Event
instance.Stripe.Events.UnknownEventNotification
instead of a more specific type. It has both therelatedObject
property and theFetchRelatedObject()
function (but they may be/returnnull
)