Reputation: 120
I am struggling to find the exact date of subscription upgrade/downgrade changes date of a customer using API. I use Stripe pricing table and allow customers update their plan using customer portal. I can see the current plan and price data but couldn't locate the actual subscription change dates of a customer.
webhooks are ok but since webhooks can be missed I need to be able to query the subscription changes of a customer periodically. Let's say a customer created a subscription and 5 days later updated to another tier. How can I query this second tier change date? Invoices seems to be a way but they are not exactly pointing the subscription change dates. I am using Go library but it doesn't seem to be issue. I couldn't find what I am looking for through the API requests either.
Upvotes: 0
Views: 379
Reputation: 120
I wanted to comment this but code block doesn't look beautiful. Looks like Stripe Event API can be useful for this. Code example in Golang would be like this to iterate in the events.
eventParams := &stripe.EventListParams{
Type: stripe.String("subscription.updated"),
CreatedRange: &stripe.RangeQueryParams{
GreaterThanOrEqual: <lastQueryDate>,
},
}
events := event.List(eventParams)
Upvotes: 0