#Rohit89

1 messages ยท Page 1 of 1 (latest)

strange cedarBOT
faint parrot
#

Hello ๐Ÿ‘‹
Can you share the exact response you're seeing?

spring spoke
#

Subscription is sub_1MWHIwLv5rdhLZWUiDLiSlhF

#

in test mode

#

[440] pry(main)> items
=> [{:id=>"si_NGowyycauQIYBK", :price=>"price_1LUYZpLv5rdhLZWUxenJy1U1", :quantity=>1}]

#

invoice = Stripe::Invoice.upcoming({
subscription: "sub_1MWHIwLv5rdhLZWUiDLiSlhF,
subscription_items: items,
subscription_proration_date: proration_date
})

#

The above case is when subscription has only one item.

urban ether
#

Hi there ๐Ÿ‘‹ taking a look

spring spoke
#

When I try with subscription having 2 items then it always returns 2 items which is correct.

urban ether
#

It looks like this is happening because of prorations. Since the Customer had already paid for the billing period, and is then having the Price they're subscribed to being changed in the middle of the billing period, you're seeing items that:

  1. Provide a credit based on the Customer's previous payment for the unused time they'd paid for.
  2. Charge the Customer for the remainder of the billing period based on the new Price
  3. Charge the Customer for the new Price for the next billing period
spring spoke
#

When I try with subscription having 2 items then it always returns 2 items

#

sub_1MeC3tLv5rdhLZWUK9ZRBvbS

#

[467] pry(main)> items
=> [{:id=>"si_NP7JDZR9yaE9oy", :price=>"price_1LUYZpLv5rdhLZWUxenJy1U1", :quantity=>1}]

#

[471] pry(main)> invoice = Stripe::Invoice.upcoming({
subscription: subscription,
subscription_items: items,
subscription_proration_date: proration_date
})

#

it will return 2 items

urban ether
#

Can you share the output?

spring spoke
#

sure

#

items = [
{
id: subscription.items.data[1].id,
price: "price_1LUYZpLv5rdhLZWUxenJy1U1",
quantity: 1
}
]

#

subscription has 2 items

urban ether
#

Hm, it doesn't look like there are any prorations included there.

spring spoke
#

I run the same thing

[481] pry(main)> invoice = Stripe::Invoice.upcoming({
subscription: subscription,
subscription_items: items,
subscription_proration_date: proration_date

urban ether
#

It looks like prorations aren't present here because the Subscription is still in a trial phase so there is no previous payment that the customer should be credited for. Taking another look at the previous sub to see if it's different than this one.

spring spoke
#

yes this sub is different than first one. It has two items.

#

due to trial period it returns exactly 2/

#

?

urban ether
#

Okay, the first Subscription you shared was no longer in a trial, so prorations were kicking in to account for the Customer's previous payment.

spring spoke
#

I see

urban ether
#

Are you trying to avoid having prorations calculated on your Subscription changes?

spring spoke
#

No I want prorations

#

I want to show user how much amount will be deducted

#

Do I need to pass proration on invoice api or I need to pass inside items?

#

If subscription is not in trial period. But has 2 items. And I will update 1, for upcoming invoice api then also it will return 3 items

  1. Provide a credit based on the Customer's previous payment for the unused time they'd paid for.
  2. Charge the Customer for the remainder of the billing period based on the new Price
  3. Charge the Customer for the new Price for the next billing period
urban ether
#

It should return 4

#

2 for the next billing period, 2 per proration calculation

spring spoke
#

How I can fetch the item Charge the Customer for the remainder of the billing period based on the new Price from 4?

#

All the items has same subscription item

urban ether
#

I'm not sure I understand the question, retrieving the upcoming Invoice is the correct way to see the estimated next payment amount for a Subscription.

spring spoke
#

will the order be same so that I fetch the second one

#

Ok, let me test