Skip to content

Conversation

@xavdid-stripe
Copy link
Member

@xavdid-stripe xavdid-stripe commented Aug 29, 2025

]### Why?

As part of the Next-Gen Event Handling project, we're adding fully typed classes to represent all the thin events Event Notifications a user could receive. There are also helper methods that help with the event handling experience.

What?

  • (see changelog below for user-facing changes)
  • add tests
  • add getMode helper for ApiMode
  • fix doc typos

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.

  • Added matching EventNotification classes to every v2 Event. For example, there's now a V1BillingMeterErrorReportTriggeredEventNotification to match the existing V1BillingMeterErrorReportTriggeredEvent. Each notification class defines a fetchEvent() method to retrieve its corresponding event. For events with related objects, there's a fetchRelatedObject() method that performs the API call and casts the response to the correct type.
  • ⚠️ Rename function StripeClient.parseThinEvent to StripeClient.parseEventNotification and remove the Stripe.ThinEvent class.
    • This function now returns a Stripe.V2.Core.EventNotification (which is the shared base class that all of the more specific Stripe.Events.*EventNotification classes share) instead of Stripe.ThinEvent. When applicable, these event notifications will have the relatedObject property and a fetchRelatedObject() function. They also have a fetchEvent() method to retrieve their corresponding Stripe.Event.*Event instance.
    • If you parse an event the SDK doesn't have types for (e.g. it's newer than the SDK you're using), you'll get an instance of Stripe.Events.UnknownEventNotification instead of a more specific type. It has both the relatedObject property and the fetchRelatedObject() function (but they may be/return null)

@xavdid-stripe xavdid-stripe changed the title Devsdk 2662 Add strongly typed Thin Event push payloads Aug 29, 2025
@xavdid-stripe xavdid-stripe changed the title Add strongly typed Thin Event push payloads Add strongly typed EventNotifications Aug 29, 2025
@xavdid-stripe xavdid-stripe changed the title Add strongly typed EventNotifications ⚠️ Add strongly typed EventNotifications Aug 29, 2025
@xavdid-stripe xavdid-stripe marked this pull request as ready for review September 24, 2025 01:51
@xavdid-stripe xavdid-stripe requested a review from a team as a code owner September 24, 2025 01:51
@xavdid-stripe xavdid-stripe removed the request for review from a team September 24, 2025 01:51
Copy link
Contributor

@jar-stripe jar-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments; nothing at all major but we should address them before merging.

@xavdid-stripe
Copy link
Member Author

(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.)

@xavdid-stripe xavdid-stripe enabled auto-merge (squash) September 25, 2025 02:03
@xavdid-stripe xavdid-stripe merged commit 79b31f5 into master Sep 25, 2025
22 of 36 checks passed
@xavdid-stripe xavdid-stripe deleted the DEVSDK-2662 branch September 25, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants