#jonthecoder_best-practices
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/1366895922101092474
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi! Subscription cancellation won't result in a refund, it will only cancel the subscription and optionally prorate things.
You can read all about doing what you want to do here: https://docs.stripe.com/billing/subscriptions/cancel?dashboard-or-api=api#prorate-for-usage-based-billing
So setting prorate to true in the API call just generates a credit rather than a refund, then?
Correct, and then (per the last paragraph of that section) you can refund the credit and adjust their balance.
Okay, so, if I wanted to do this in a single action for our admins in our UI, the flow would be to
- retrieve target subscriptions' latest invoice ID
- cancel via subcription.cancel()
- if successful, call refund against invoice
Not necessarily; why are you retrieving th invoice first?
Oh, I see.
So if I cancel mid-month, you give me half my money back?
Actually, no, that's not how you'd do it. The 'how' is described in that document.
Create a final invoice immediately using the invoice_now parameter. If you owe the customer a credit after cancellation, you can add the credit to their credit balance to apply to future invoices. To refund your customer, issue refunds [using the Refund API] and then adjust their account balance back to zero [using the Customer Balance functionality].
If you cancel mid-month, you've used my service for half the time, so you get the unused portion back. "Cancel at end of period" is the default and preferred route, but we want to offer those options for customer service courtesy or extraordinary circumstances
Awesome, gotcha. So ya, the process described in that earlier link is the way to go. I'd of course recommend testing to confirm it behaves the way you expect though.
Okay, thank you!
You're very welcome! Come and see us if you run into issues as you work through it! ๐