#vpmragu - subscription
1 messages · Page 1 of 1 (latest)
Hi Soma.. we are are trying to update the subscription and it is working fine. But the taxrate details are not updated in the latest_invoice.
we would like to know the ways to update these details.
Can you share the subscription ID?
So if I understand correctly:
- you updated the price of the subscription here: req_tsa9ZLpDogToMI to use price_1LPO1hKhQvshw5gFFfEHETNU
- but when looking at the latest invoice of the subscription (in_1LQ3R3KhQvshw5gFlcZUHeM7), you don't see this new price?
yes
The invoice was created on 2022-07-27 at 06:09:33 UTC
Then you updated the price of the subscription on 2022-07-27 at 06:10:09 UTC
So since you made the update to the subscription after the invoice was created, it's expected that the invoice still has the old price.
but it is there in upcoming invoice details
And yes, the upcoming invoice should have the new price.
since the invoice is in draft status, why it is not getting updated in the latest_invoice?
That's not how it works. Updating a subscription will only impact invoice that will be created in the future. Invoice already created, even in draft status, won't change.
ohh, What should we do in this case? What is your recommendation? we want to send the updated invoice only to our users.
The simplest option is to update the subscription before the new invoice is created. Otherwise you can try to update the invoice while it's still in draft.
whenever we are creating a subscription, invoice will get generated and it will be in draft state, right?
in my case also it is still draft state only.
see this image
For subscriptions with collection_method: "send_invoice", then all invoices will be created in draft.
Can you give more context on what you are trying to do exactly?
I have a one product which offers 2 different tier (basic, premium) and in each tier we have monthly and yearly plan... So for that i created one product in stripe and 4 different prices (2 price for each tier) in stripe.. As similar to this https://stripe.com/docs/products-prices/pricing-models#flat-rate
I have shown all the 4 plan to user and user selected one plan and came to checkout page where i will create subscription (with automatic_tax: true) for that selected one and display the amount and tax split up... Now user have option to switch to the different plan, so when user choose the different plan i am updating the subscription with new selected plan's prcieId and getting new amount and tax details that i will display that to user... Now the problem is when user choose the plan which has different term (monthly plan to yearly or vice-versa within same tier or different tier) the subscription update returning proper amount and tax details.. But when user selects the same term in another tier, subscription update not returning updated value.. For example user initially selected basic monthly plan but now in checkout user trying to switch to premium monthly plan Though i am updating subscription with new priceId, it still return the old amount and tax details in the latest invoice.. The latest invoice object in the subscription not getting updated ...
can you share a specific example? Like the Invoice ID in_xxx that you say has the old or wrong details.
refer this subscription sub_1LQ3R3KhQvshw5gFjVisrrCv which has latest and upcoming invoice details
That's just the original invoice
the problem is you assume that when you update the subscription to change the plan, it will always generate a new invoice, correct? But that's not the case.
so basically you updated, you looked at latest_invoice , but since there's no new invoice for this sort of update (monthly plan => a different month a plan), that hasn't changed and is still the first invoice.
No, my assumption is it will get updated in the latest_invoice. but it is not
so what is your recommendation to achieve this usecase?
we're saying the same thing
what's the use case? you want to change from the existing monthly plan, to the other monthly plan, and then charge an amount? What amount? after that is charged, when do you want to charge them again?
yes, we want to change from one monthly plan to another
but both plans come with different feature set
so different priceId and charges
can you answer the specific questions I asked?
when doing the update, you'd like charge an amount? What amount? after that is charged, when do you want to charge them again?
I ask because what you want is likely very possible and simple, but I need to know what your desired outcome is exactly so I can give you the correct advice.
before it charged we are updating the subscription
basically in the checkout flow, user chose one plan and created the subscription. before the first payment of that subscription, user changed the plan. here we are updating the subscription.
so we want to have the payment details as per latest selection
but the latest_invoice has previously selected plan's payment details
I'm really sorry but we're not communicating
what does that mean? I have no idea what that could mean. What are 'payment details'?
let's take an example
- you start a subscription on monthly plan $50/month on July 1
- 2 days later, you update to monthly plan $100/month on July 3
- would you like the customer to be charged at this time? <--- answer this please
- if so, what amount should they be charged? <--- answer this please
- when is the next date after this that the customer the customer should be charged, and for how much? <--- answer this please
like , the details on the actual invoice will not ever change. They're frozen. Just because you change the subscription later, that invoice will not change. A new invoice might be generated when you change the subscription depending on how you perform the update exactly(which is what I'm trying to ask you about to understand), but the actual paid invoices themselves don't ever change.
let me explain:
- choose a monthly plan $10, calculated the tax and created a subscription - didn't pay for that subscription
- in the same checkout flow, chose another monthly plan which costs $20 and want to update this amount into the subscription.
- updated it with latest priceId and calculated the tax(via
automatic_tax) - subscription got updated but not the invoice. here only i am paying for the initial subscription fee
in any step, i haven't completed the payment. and still subscription state is not active
that doesn't make sense, you would create a new Subscription in that case, you wouldn't update the new one
so, your recommendation is always create a new subscription even a tier change?
that's my advice! if the user picks a different plan, create a different subscription!
my recommendation is don't create the subscription in the Stripe API until after the user has picked what they want in your own user interface, and then create it with the right details.
if you want to show them a preview of what they would pay, use https://stripe.com/docs/api/invoices/upcoming and pass parameters matching what you want; don't create an actual Subscription.
But i need to show the tax details in the checkout page. without creating subscription, how to calculate the tax?
okay. I can use the details from upcoming invoice. then what is the status of the latest_invoice.
since i am using { paid_out_of_band: true } for payment complete, which invoice to update for payment complete?
await stripe.invoices.pay(subscription.latest_invoice, { paid_out_of_band: true });
there's no latest_invoice yet since you haven't created a subscription yet
the one for the subscription you create after the customer has picked all the options in your UI and after you showed them the previews during that process.
👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
I have created a subscription already
is there any way to calculate tax automatically without creating subscription?
I believe you can calculate the tax by using the upcoming invoice API with the automatic_tax field
okay, let me go through the upcoming invoice API doc.