#landfight_webhooks
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. Thank you for your patience!
ā±ļø We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
š 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/1213017673076572180
š Have more to share? You can add more detail below, including code, screenshots, videos, etc.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- landfight, 6 days ago, 29 messages
hello! you would probably want to listen for the invoice.paid event : https://stripe.com/docs/billing/subscriptions/webhooks#events and check the billing_reason : https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason - subscription_cycle is probably what you want to check for
one more question @slim jetty would i implement that like this in the webhook code?
and so when the billing reason is subscription cycle, thats when i would add credits right?
if (stripeEvent.type === "invoice.created") {
const invoice = stripeEvent.data.object as Stripe.Invoice;
if (invoice.billing_reason === "subscription_cycle") {
// add credits here
}
}
yep, that looks right to me. You'll want to test it out to make sure it works as per what you expect though. in case you haven't seen this yet, you can use test clocks to mimic the passing of time : https://stripe.com/docs/billing/testing/test-clocks
didnt know this thanks!
oh wait wouldnt i be listening to invoice.paid instead according to what it says here? https://docs.stripe.com/billing/invoices/subscription#subscription-renewal
š¤¦āāļø oh yeah, sorry, totally missed that in your code