#Pete100
1 messages · Page 1 of 1 (latest)
Hi there, you've found the answer already, you can use the invoice preview API to achieve it.
The preview API doesn't modify the subscription, so you don't need to revert anything.
Okay so my understanding is to do the following:
- call PUT subscriptions with modified items. Set
pause_collection[behaviour]=keep_as_draft - GET upcoming invoices
- show invoice items on front end
4a. DELETE invoice...(in case of customer cancellation)
4b. PUT subscription resume payment collection...(in case of customer confirmation)
How do I perform 4a, when getting upcoming invoices doesn't return invoice Ids (i.e. starting with in_...?
what invoice are you trying to delete in 4a? you mean any existing invoice (if already created prior to the change you want to make)?
I mean upcoming invoice...how do i cancel it?
you can't cancel an upcoming invoice. An upcoming invoice is a preview. Nothing is actually created yet
I see, so when i update a subscription, what's the flow for upcoming invoices -> actual invoice. I don't quite understand
Hi @stark mural the preview step is optional. You can call the subscription update API to upgrade or downgrade a subscription https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
Thanks @safe totem I had a read. So I need to use a different API https://stripe.com/docs/billing/subscriptions/prorations#preview-proration to create the preview. Are the subscription_items the same as what I would put in a subscription update (https://stripe.com/docs/api/subscriptions/update#update_subscription-items) ?
Yes you are right. You can consider the preview like a dry-run before committing the change to the subscription.
Okay, I'll play around with it and see how I go. Thank you for your help