#Rohit89
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Can you share the exact response you're seeing?
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.
Hi there ๐ taking a look
When I try with subscription having 2 items then it always returns 2 items which is correct.
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:
- Provide a credit based on the Customer's previous payment for the unused time they'd paid for.
- Charge the Customer for the remainder of the billing period based on the new Price
- Charge the Customer for the new Price for the next billing period
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
Can you share the output?
sure
items = [
{
id: subscription.items.data[1].id,
price: "price_1LUYZpLv5rdhLZWUxenJy1U1",
quantity: 1
}
]
subscription has 2 items
Hm, it doesn't look like there are any prorations included there.
I run the same thing
[481] pry(main)> invoice = Stripe::Invoice.upcoming({
subscription: subscription,
subscription_items: items,
subscription_proration_date: proration_date
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.
yes this sub is different than first one. It has two items.
due to trial period it returns exactly 2/
?
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.
I see
Are you trying to avoid having prorations calculated on your Subscription changes?
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
- Provide a credit based on the Customer's previous payment for the unused time they'd paid for.
- Charge the Customer for the remainder of the billing period based on the new Price
- Charge the Customer for the new Price for the next billing period
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
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.