#robbycarter_webhooks

1 messages ¡ Page 1 of 1 (latest)

clear badgeBOT
#

👋 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/1376913630599319622

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

zealous zephyr
#

Hey there, using customer.subscription.updated is a good event here, and you can check if the billing period has advanced forward by referring to previous_attributes (this gets trickier for basil versions and beyond).

#

You can also use invoice.paid and reference the subscription attribute on the invoice

#

Note that invoices can also be generated out of cycle when triggered by you or certain updates.

pseudo horizon
#

currently trying out using the invoice.paid and then expanding parent.subscription_details.subscription to get the plan

 const invoice_details = await stripe.invoices.retrieve(id, {
    expand: [
        'customer',
        'parent.subscription_details.subscription'
    ]
})

I feel there is much better way to have this done

clear badgeBOT
zealous zephyr
#

If your goal is to track plan/pricing changes, then customer.subscription.updated is likely the best choice, since it is a more direct path to that info and should include the updated items already if changed

pseudo horizon
#

I am not allowing the customer to change plan or price from stripe end but from our system.
Just trying to get the plan that was renewed and the start and end period.

I will check out the customer.subscription.updated and see how that looks and if it works for what i need

#

With the code snippet i shared above
on the subscription object, i have plan available but due to typescript errors. I cannot get that.
But when i log the subsciption, the plan object exists

bleak haven
#

You may have to suppress the typescript errors, I don't think our library has any special typing abilities

pseudo horizon
#

I was hopping to avoid that but yeah
Let me try using the customer.subscription.updated approach and see if thats smoother.

As long as its triggered when a customer makes payment for a new subscription or a customer is charged for a subscription renewal. It would work perfectly