#bryane_88036
1 messages · Page 1 of 1 (latest)
Event objects have previous_attributes that you can inspect to see what changed with that event: 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.
Yup that's exactly what I was thinking, however the only attribute that gets returned when a subscription transitions from an incomplete to active state is the default_payment_method
Is there a better way of being able to check against that status transition?
You should get a customer.subscription.updated event for every param changing
So you should get an event when status changes
Yup totally on the same page there, we get an customer.subscription.created event where the status is incomplete, then a customer.subscription.updated event where the status is now active. That's specifically what I'm trying to assert: that a subscription got created in one event, then it was updated to be active in a follow up event. There's lot's of reasons why a customer.subscription.updated is emitted, but I only want to perform a certain action when the customer.subscription.updatedevent is specifically a subscription transitioning to active
Can't you just check for the event where status became active and in previous_attributes you see status as incomplete?
Well that's the thing: the only attribute I see on a customer.subscription.updated event, where a sub turns to active, is the default_payment_method field.
Oh can you send an event id?
when a sub is cancelled, there's much more data
yup
@keen oriole can I dm you since the event id since this is a public channel
No we don't do dms. Event id's aren't sensitive data
are or aren't
So sorry haha
all good, I appreciate the help!
Ok so there's 2 subscription updated events fired. This is the one you'd want to action on: https://dashboard.stripe.com/test/events/evt_1Nso7TCi2Sw6UZ9JovtH9CvD
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Why two events? How would I be able to tell the difference?
You'd listen to all customer.subscription.updated events. Then only action ones where status changed from incomplete -> active
Just inspect status and previous_attributes for every event that comes in
Okay, that makes sense. I really appreciate it!