#tungtn1099
1 messages · Page 1 of 1 (latest)
Well you could check the previous_attributes hash on the payload. If it's a downgrade/upgrade then there'll likely be an items field in that hash
Weird, my event data object is missing that hash
Can you share an example?
Oh wait, should it be outside of the event.data.object?
Yes: event.data.previous_attributes (https://stripe.com/docs/api/events/object#event_object-data-previous_attributes)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Alright I see, thanks!
previous_attributes: {
billing_cycle_anchor: 1697861376,
current_period_end: 1713672576,
current_period_start: 1697861376,
items: [Object],
latest_invoice: <redacted>,
plan: [Object]
}
It says
Well that's just a TS compiler error because there's no fields in the interface: https://github.com/stripe/stripe-node/blob/5bfdacac2119cf262e3dede30173b41167456276/types/Events.d.ts#L101
Probably safe to just ts-ignore that
got it, thanks
Or feel free to type it yourself based on the fields you need to check
I think it creates a build error on deployment since we ignore node_modules no?