#dick-flair_best-practices

1 messages ยท Page 1 of 1 (latest)

valid treeBOT
#

๐Ÿ‘‹ 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/1316011060209123329

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

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.

empty oak
#

Hi there, let me type out the rest of my question

shadow brook
#

๐Ÿ‘‹ happy to help

empty oak
#

I was wondering what the best practice for my current issue. I am using stripe to integrate a payment system into my web portal. I am allowing monthly/yearly subscriptions and also allowing upgrade/downgrades. For downgrading, I use subscription schedules for this to update a subscription, i.e. decrease a quantity at the end of the currently billing cycle, i.e. if it's a monthly rolling subscription, the next month will be minus 1 in quantity. I am implementing webhooks so that this reflects on my database, i.e. if the quantity on the subscription is 4 then make sure the one in my DB is 4 as well. As for the upgrades, the upgrades act in a different way in that this change happens immediately to the subscription and the customer gets charged immediately, and as part of this, the quantity or whatever else I need to update in my DB also gets updated. I was utilising the customer.subscription.updated webhook event to mainly handle the downgrade but this also gets triggered when I do an upgrade but I don't need this to be updating on the upgrade update because I already handle that

#

I was initially trying out the subscription_schedule.released event not realising that this only gets triggered at the end of the phase, i.e. if in the middle of month 1, I decrease to qty of 4, month 2 comes and updates the subscription, the schedule does not get released until month 3 which doesn't quite work for what I need, as I would need to update my DB as soon as the subscription is updated

shadow brook
#

I think the best way to handle any subscription provisioning is using invoice.paid

#

this abstracts all of the different things happening in the background

empty oak
#

I'll take a look now and test but while I have you, would this contain the subscription object/details?

shadow brook
#

once an invoice is generated and paid for a subscription you're a 100% sure that you can provision access to your services

shadow brook
empty oak
#

Sorry, 1 more question. If I was also using stripe indenpdently to create invoices that has nothing to do with the subscriptions, etc. I'm assuming this would still fire the event but it will not contain a subscription ID?

shadow brook
#

yes that's correct

#

but also relying on the billing_reason you can see the different scenarios whether this is related to a subscription or a manually created invoice

empty oak
#

Actually yep, that's perfect for what I need. I can work with this. Thanks tarzan