#brendon-upcoming-invoice

1 messages ยท Page 1 of 1 (latest)

vast nimbus
#

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

boreal tapir
#

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.

vast nimbus
#

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

boreal tapir
#

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.

pulsar pond
#

Hey, stepping in on this. Catching up, one moment

boreal tapir
#

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
pulsar pond
#

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?

boreal tapir
#

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.

pulsar pond
#

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?

boreal tapir
#

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

pulsar pond
#

Do you have the ID for this subscription so I can make sure I am thinking of this right?

boreal tapir
#

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

pulsar pond
#

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?

boreal tapir
#

Yeah. and that is how it works when using stripe checkout.

pulsar pond
#

Oh so that is the behavior that you want?

boreal tapir
#

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?

boreal tapir
#

Is the Quote API and Quote Line Items a better option for this scenario?

vast nimbus
#

no I don't think the Quote API will help

boreal tapir
#

ok.

The free trial trick is unfortunatly showing in the description

vast nimbus
#

yeah you need to write code to ignore it

boreal tapir
#

It unfortunatly also removed the rest of the product. Here is the example without the free trial hack

vast nimbus
#

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

boreal tapir
#

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.

vast nimbus
#

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?

boreal tapir
#

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

vast nimbus
#

Can you share exact code and exact raw JSON?

boreal tapir
#

yes no problem, ill get back to you shortly with a clear example with json.

boreal tapir
#

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.

vast nimbus
#

So where are you indicating there's a trial here?

boreal tapir
#

No the trial is a hack. This clearly shows that the result is different between checkout and what the api returns

vast nimbus
#

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

boreal tapir
#

Look at the Amount due returned by the api 23980 and the amount due on checkout 10890

#

they should be the same right?

vast nimbus
#

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

boreal tapir
#

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.

vast nimbus
#

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

boreal tapir
#

They are in the request url

#

same parameters are passed to checkoutsession

vast nimbus
#

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

boreal tapir
#

all the information is in the screenshot and the json response

#

How can I escalate this please?

vast nimbus
#

screenshots are not really helpful

#

Please understand that you are creating real objects in the API, please share those exact object ids

#

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

boreal tapir
#

Ok I appreciate you taking the time on this. yeah its been frustrating trying to explain the issue in a short enough manner.

vast nimbus
#

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

boreal tapir
#

yeah thats probably ture

#

*true

vast nimbus
#

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?

boreal tapir
#

Exactly!

#

๐Ÿ™‚

vast nimbus
#

I'm curious: if you create a Subscription right now: do we charge the same as Checkout?

boreal tapir
#

yeah

vast nimbus
#

basically is Checkout incorrect, or the upcoming invoice?

#

grmbl

boreal tapir
#

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

vast nimbus
#

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

boreal tapir
#

boom

vast nimbus
#

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

boreal tapir
#

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

vast nimbus
#

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

boreal tapir
#

thats good

vast nimbus
#

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

boreal tapir
#

oh, any hints on what your workaround was for checkout. or was that it?

vast nimbus
#

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

boreal tapir
#

im trying to avoid having to calculate taxes, discounts etc etc myself and getting a different result to you

vast nimbus
#

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)

boreal tapir
#

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

vast nimbus
#

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

boreal tapir
#

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.

vast nimbus
#

I can't really share this but mention my name (koopajah) and it will find me/my team