#Pete100

1 messages · Page 1 of 1 (latest)

devout roverBOT
safe totem
#

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.

stark mural
#

Okay so my understanding is to do the following:

  1. call PUT subscriptions with modified items. Set pause_collection[behaviour]=keep_as_draft
  2. GET upcoming invoices
  3. 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_...?

calm thorn
#

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)?

stark mural
#

I mean upcoming invoice...how do i cancel it?

calm thorn
#

you can't cancel an upcoming invoice. An upcoming invoice is a preview. Nothing is actually created yet

stark mural
#

I see, so when i update a subscription, what's the flow for upcoming invoices -> actual invoice. I don't quite understand

safe totem
stark mural
#

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) ?

Learn about prorations.

safe totem
#

Yes you are right. You can consider the preview like a dry-run before committing the change to the subscription.

stark mural
#

Okay, I'll play around with it and see how I go. Thank you for your help