#szy_subscription-update-events
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1292879378753130597
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
HI ๐
This webhook event has nothing to do with changing products/prices on a subscription. What information are you trying to get from it?
For all our .updated webhook events, the best way to identify what changed is to review the previous_attributes property.
In this case, it looks like the billing cycle updated and a new Invoice was generated since the attributes that were changed are billing cycle timestamps and invoice ID
previous_attributes: {
current_period_end: 1727799723,
current_period_start: 1725207723,
latest_invoice: "in_1PuGZkC5Vnk6f7u9NJh2bL3P"
}
Hey, In the end I want to get the name of the product I'm switching my subscription to.
No product was switched here
Do you have an example event where a product was changed?
Ultimately you will need to identify which subscription item was updated, then get the price ID from that subscription item and use it to retrieve the Price object with the Product information expanded from the API
But it can be helpful to talk through an example, so I'd like to see an event where the product changed so we can talk through it
I'm receiving a webhook whenever I switch plans in my application. I'm changing my subscription from "Basic" to "Premium".
Okay. Do you have an example ID of a customer.subscription.updated webhook event where you changed price/product ?
Thanks, taking a look
Nope sorry that isn't what happened here
The only thing changed was the billing cycle
Again, look at previous_attributes
"previous_attributes": {
"current_period_end": 1727799723,
"current_period_start": 1725207723,
"latest_invoice": "in_1PuGZkC5Vnk6f7u9NJh2bL3P"
}
If you changed products, there would be a price ID here
Okay here is a good one: https://dashboard.stripe.com/test/events/evt_1Q2ZnIC5Vnk6f7u9Cay3vCr2
If you look at the previous_attributes property, you will see that a Subscription Item has been updated
previous_attributes: {
items: {
data: [
{
id: "si_QuO9MuwLv5IHh0",
object: "subscription_item",
billing_thresholds: null,
.....
So, to get the product you are changing to, you would retrieve that Subscription Item from the data object you received.
items: {
object: "list",
data: [
{
id: "si_QuOaCl9fskbKHD",
object: "subscription_item",
billing_thresholds: null,
created: 1727188368,
discounts: [],
metadata: {},
plan: {
id: "price_1PGI2yC5Vnk6f7u9UdLD9SOs", // <- this is the ID you need
You then retrieve the Price object from the APi and pass 'product' in the Expand parameter
https://docs.stripe.com/api/prices/retrieve - retrieve a Price
https://docs.stripe.com/api/expanding_objects - expanding responses
Actually, you can get the Product ID from the price attribute and just retrieve that, if all you care about is the name
But generally, I find it helpful to have both Product and Price data
Sure thing, happy to help ๐