#brendon-upcoming-invoice
1 messages ยท Page 1 of 1 (latest)
I'm not entirely sure I follow your example
usually if you don't charge immediately you do a trial, is that what you are doing
Here is an example showing my scenario in stripe checkout.
The subscription is not included in the subtotal when setting it up because it gets billed at the end of the month. However the one time setup fee is billed immediatly.
yeah we don't support this in the API
you can preview the next invoice (first one) like the one you see
but we don't allow showing how much will be charged next month, you'll have to calculate this yourself
hmm. but i am simulating the first invoice.
Here is an example of the numbers i get back using the upcoming invoice api
You can see the subscription fee is added to the one-time setup fee.
Note this is for a subscription that has not been created yet
So im actually not seeing the same behavour from the Upcoming API as what happens in the stripe checkout.
Hey, stepping in on this. Catching up, one moment
Ex, thanks. This is how im calling the upcoming invoice api
{{baseUrl}}/v1/invoices/upcoming?automatic_tax[enabled]=true&customer=cus_Jq2wEWQ9wbTKId&expand[0]=total_tax_amounts.tax_rate&expand[1]=lines.data.discount_amounts.discount&invoice_items[0][price]=price_1JCKj7IOTlgpobjKQONyICqM&subscription_items[0][price]=price_1JS9m5IOTlgpobjKtZicV5Hy
I'm sorry I'm not sure I'm quite seeing the different behavior you want here. So you do not want that Starter plan to be included?
I would like to see the same subtotal come back from the api as I get in checkout.
So it should not include the starter plan price in the subtotal.
Are you adding a trial to that? If you don't want to charge them upfront for the subscription fee I think you need to do a trial
Though that would charge right at the end of the trial. How are you configuring it to charge at the end of the month?
Its a metered subscription which automatically charges at the end
Using a trial when simulating with the upcoming invoice api might be a workaround to get it to return the correct numbers. I could try that if there isnt another option
Do you have the ID for this subscription so I can make sure I am thinking of this right?
prod_K3MR0lgWrhHj9a - Metered Subscription product
This is the one-time fee product id prod_Jq0k47SscRUDQ8
Its working! I just tested using postman. and by setting the [subscription_trial_end] to some time in the future it is only including the setup fee in the subtotal
That actually might not be what you are looking for. Sorry I confused concepts a bit when reading this. If you trial the subscription the usage during the trial period will not be charged
So the goal is, upfront charge then at the end of the cycle the usage and recurring price are charged together?
Yeah. and that is how it works when using stripe checkout.
Oh so that is the behavior that you want?
Yes thats what I want and it works great for credit cards and using the stripe checkout.
But im currently implementing my own checkout to support BECS payments. And I want to use the Upcoming Invocie API to calculate the numbers for this new checkout page. (Before charging and actually creating the subscription)
Thats why I need the upcoming invoice numbers to work the same way checkout is.
Faking a free trial to get the upcoming invoice to look the same is obviously not ideal, Is there another way to get the api to act the same as checkout would?
Is the Quote API and Quote Line Items a better option for this scenario?
no I don't think the Quote API will help
ok.
The free trial trick is unfortunatly showing in the description
yeah you need to write code to ignore it
It unfortunatly also removed the rest of the product. Here is the example without the free trial hack
I'm sorry, I don't really understand waht you mean or are doing, you just show me some UI you built but not what your code does
Sure, Its just displaying the result from the Upcoming Invoice API. I can paste json if you prefer?
Do you understand the basic issue? Ie that the Upcoming invoice api is not returning the actual values that a user would be charged if I created a subscription with a one time setup fee
Please let me know how I can help explain this better.
sorry, didn't see your response, looking
And no I really don't understand the issue right now. The upcoming invoice returns exactly what someone would pay on their first invoice based on the parameters you are sending
Can you share your exact code?
The problem is it isnt what they would pay.
When you checkout with a metered subscription and a one time fee product. An invoice is immediately created for the one time fee and the user is charged. The subscription is created but no fee is charged until the end of the month which would be their second invoice.
So It does not seem correct that the upcoming invoice is including the cost of the subscripton. it should be $0
Can you share exact code and exact raw JSON?
yes no problem, ill get back to you shortly with a clear example with json.
Here is the json response from Upcoming invoice API from this url {{baseUrl}}/v1/invoices/upcoming?automatic_tax[enabled]=true&customer=cus_Jq2wEWQ9wbTKId&invoice_items[0][price]=price_1JCKj7IOTlgpobjKQONyICqM&subscription_items[0][price]=price_1JS9m5IOTlgpobjKtZicV5Hy
Here is a screenshot from the stripe checkout with the same products. Which has a different amount due.
Please let me know if there is something else I need to send in the request to get the upcoming invoice api to return the same result as checkout.
So where are you indicating there's a trial here?
did you forget to pass https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_trial_end @boreal tapir ?
No the trial is a hack. This clearly shows that the result is different between checkout and what the api returns
I'm really sorry, despite all the back and forth I don't understand at all what's different
You likely should write a detailed summary to our support team with exact code for both Checkout and the upcoming Invoice API, the exact parameter you send, the JSON for both resources because we're unfortunately not following each other
Look at the Amount due returned by the api 23980 and the amount due on checkout 10890
they should be the same right?
I know but I don't understand the difference, you sent that screenshot a few times with no info or example. I would need the exact objects, the line items for Checkout, etc.
But I have to run unfortunately and working with support will be your best bet here
like on your invoice you are clearly seeing that line item which is the third one
and different from Checkout which only has 2
These are the same products with the same customer. No its the same they are the same product
that product has 2 tiers of pricing
I can show you another screenshot of the same checkout but with the tiers expanded.
yeah sorry I have to run, and unfortunately we need more info. You clearly are super deep in this but you're not providing all the info in one place, including exact object ids
I know now, but that wasn't obvious to me at all before, you also didn't provide a simple Checkout Session example
I'm just trying to advise you to provide all pieces of information at once in your email to support to get some help
all the information is in the screenshot and the json response
How can I escalate this please?
screenshots are not really helpful
Please understand that you are creating real objects in the API, please share those exact object ids
and you would contact the support team here: https://support.stripe.com/contact/email
But now that I understand your question I do agree something is weird with the upcoming invoice
the price price_1JS9m5IOTlgpobjKtZicV5Hy appears twice with a quantity of 0 and the amount is not 0
Ok I appreciate you taking the time on this. yeah its been frustrating trying to explain the issue in a short enough manner.
yeah I'm sorry, I can be nitpicky to get information
I do think there's a 2 sentences explanation that you didn't really give and assumed we'd find it but you're deep in this for hours
Overall, you are using Checkout to start a subscription to a metered Price and adding a one-time setup fee on creation. Checkout charges you $108.90. When you use the Upcoming Invoice API to simulate that first invoice, that calculation is incorrect and returns the full price of the first tiers of the Price even though it's metered and wouldn't be charged upfront.
That's your problem right?
I'm curious: if you create a Subscription right now: do we charge the same as Checkout?
yeah
checkout is correct and generates an invoice that matches. And it works the same if I create the subscription using the api. Only upcoming seems to be different
now that I understand your ask, I see a jira internally about exactly that ๐
literally called Metered price with tiers returns different invoice than actual creation for upcoming invoice
boom
I'm so sorry, I didn't realize at all that's what you were asking earlier, I thought you were trying to reproduce the preview yourself and you had mentioned a trial
I was playing with trial to sort of hack the upcoming api call to return the right result but its not the right approach I think
yeah and fun fact: Checkout uses the same API (so that's why I was so confused)
and turns out we fixed it specifically in Checkout
thats good
I don't think we'll fix this soon
but now that I understand your ask: you could hack it by ignoring metered Price on the first upcoming invoice
you do have to redo part of the math yourself though which defeats the purpose
oh, any hints on what your workaround was for checkout. or was that it?
what I said mostly. We recalculate part of the upcoming invoice differently in our own code like I described above but then it makes it hard with discount/tax
im trying to avoid having to calculate taxes, discounts etc etc myself and getting a different result to you
yep I think if I were you I wouldn't give a detailed preview and send to Checkout. There's no alternative I can think of that would be reliable here (beyond us fixing it which we need to do)
I'd still recommend writing in, mention you spoke to me and that there's a bug with the upcoming invoice and tiered prices and that will get to someone who can chase the eng team (I flagged the jira clearly to be reprioritized at least)
I am doing that for my customers that use Credit card, My problem is that your checkout does not support BECS payments which im implementing now which is how I ended up here
I will write in. thanks
sure, sorry for the back and forth, it definitely didn't click for me until the last part of the convo and the fact that you mentioned you had 2 tiers and that's where the 3rd line item came from
ahhhh, ok cool that was the missing peice. sorry about that
Ok, thanks for your help. Ill try figure out a way around this for now and will message your support team.
Could you share the jira ticket number with me? I will include it with my support request if you can.
I can't really share this but mention my name (koopajah) and it will find me/my team