#Eranga-subscriptions

1 messages ยท Page 1 of 1 (latest)

normal fulcrum
dire sierra
#

Assume the customer is reducing the quantity

#

That means the user will be credited

#

Will it show the amount user actually need to pay, and the subscription value seperately?

#

For the future line item

normal fulcrum
#

it's the upcoming invoice, which means it is basically what will be on the next recurring invoice. So at the base level, that's the recurring item that has been switched to. Plus, any proration items, as those get pulled into the invoice. If switching to something cheaper, there is a proration item for a negative amount called "unused time on X" and it would be on that invoice as a line item yes

#

if the overall proration amount is negative what will happen if you use always_invoice is that an invoice will be created and immediately marked as paid(since the amount owed is less than $0), and that negative balance gets added to the customer's balance(which is then offset against future payments)

sleek valve
#

what's up?

dire sierra
#

Thank you for unarchiving

#

I did the following request

https://api.stripe.com/v1/invoices/upcoming?customer=cus_KHFsCni0TZ8c6m&subscription=sub_1Jd9v2C8JGuaUdU6hiAGRouQ&subscription_items[0][id]=si_KHjN5NQe1r9kBh&subscription_items[0][quantity]=20&subscription_proration_behavior=always_invoice
#

To get the upcoming invoice of a subscription with proration behaviour set to always_invoice

#

And setting the quantity from 10 -> 20

#

In the response I have two line items

#

One for the earlier one, the second one for the newer one

#

Now my question is, how can I show what the customer would be paying for the upcoming month. This invoice will show what he will have to pay now. But how to get the next month amount (with discounts and taxes)?

sleek valve
#

because you are using always_invoice, the invoice shows the amount that user need to pay now immediately

dire sierra
#

Yes, correct

#

Should I create another API call and change the setting to proration

#

I mean create_prorations ?

#

I just call the API again with create_prorations and then I get 3 line items. The third one's type is subscription and it has the next month's data.

#

Can I use this data to show what the next month's amount would be? And does this means I have to call the API two times for showing the amount the customer has to pay now (using always_invoice), and amount the customer has to pay next month onwards (using create_prorations) ? ๐Ÿ™‚

normal fulcrum
#

Can I use this data to show what the next month's amount would be?
yes, that's what the third item is

#

you only need to call the endpoint once, it shows you the upcoming invoice, which always includes the upcoming month

#

and you can show them what they'll pay next month by showing them the other lines

dire sierra
#

Give me a sec to process this ๐Ÿ™

#

Ah ha. So what you suggest is:

-> Call the upcoming invoice API endpoint with create_prorations as proration behavior
-> filter the "type": "invoiceitem" AND proration: true and calculate the sum of amount values
-> Show that sum to the user as the payable now
-> filter the "type": "subscription" AND proration: false and get the amount value
-> Show that as the next months amount
-> Then call the update subscription endpoint with always_invoice and the proration_date (or similar property)

normal fulcrum
#

yep, that's it

dire sierra
#

Great, that will do it

#

One more question

#

Assume the customer is reducing the quantity which results in crediting the customer

#

We also need to show them that we will owe them X amount

#

How can we show that if we use create_prorations in upcoming invoice?

normal fulcrum
#

the invoice items will be negative in that case

dire sierra
#

Nice, let's assume a more complex scenario.

#

Let's say we already owe the customer

#

Now from the next change we are going to owe the customer more

#

In this scenario, will we have to call and get the customer object so that we can show how much we owe them?

normal fulcrum
#

I'd highly suggest testing it , it makes a lot more sense when you have some code to play with

dire sierra
#

Sure, I'll do a little more testing on my own. Before conclude, can I ask

  • "type": "invoiceitem" AND proration: false -> The invoice line items that the customer has already paid or finalized
  • "type": "invoiceitem" AND proration: true -> The proration invoice items which is not yet paid
  • "type": "subscription" AND proration: false -> The future plan based on the change the customer is about to do
#

Am I correct to assume this?

normal fulcrum
dire sierra
#

The first type is when the customer has done updates to the subscription in this cycle more than once

normal fulcrum
#

you'd have to take that into account in showing the amounts to the customer because that balance will apply to the invoice created when calling the update with always_invoice, yes

#

it's best to test the exact scenarios you have in mind and see what the API returns

#

and sure, type:invoiceitems that are not also proration:true are other items that might have been created prior to the preview/update you're making

dire sierra
#

Great, I think I have the basic idea on what invoice line items are and how can I use them to prorate the subscription now. I will play with them now.