#scott-riley_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1318956498004611176
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
Give me a few to read through the question and get back
Hi, while we're lookinkg, can you share the specific invoice id where you don't see this breakdown please? How can I reproduce this on my end? Can you share exact steps please?
Sure thing, so for example we have invoice 4C966452-0004 which is "upcoming" in January i guess because we're usage based on the meter.
In the image you can see that we have a single line item which is based on the total quantity.
What we're trying to do is pass multiple line items to the Meter / Invoice so that it should something like:
Inside Agent Per User per Month = 150 @ $1.00
- Customer A = 40 @ $0.00
- Customer B = 110 @ $0.00
Total charge would be $150
OR
Customer A = 40 @ $1.00
Customer B = 110 @ $1.00
Total Charge would be $150 but.... super important to ensure that the line item charge matches the tiered volume pricing for each line item i.e. they should ALL be the same price
Here's what I'm trying at the moment
await stripe.billing.meterEvents.create({
event_name: "inside_agent_users",
identifier: `${customerId}_${Date.now()}`,
payload: {
stripe_customer_id: customerId,
value: totalUsers.toString()
}
});
// Add breakdown items directly
for (const company of breakdown) {
await stripe.invoiceItems.create({
customer: customerId,
description: `${company.name}: ${company.users} users`,
amount: 0,
currency: 'gbp'
});
}
return NextResponse.json({
success: true,
totalUsers
});
} catch (error) {
console.error('Stripe usage update error:', error);
return NextResponse.json({ error: error.message }, { status: 400 });
}
}
But to be super duper clear, I'm brand new to Stripe so there's probably a doc, link showing how to do this that I just can't find. OR there's a blindingly easy way to do this and I've overcomplicated it ๐
Can you share the invoice id please?
We typically use the product name on the description: https://docs.stripe.com/products-prices/how-products-and-prices-work
So you might need to create separate products to surface the breakdown like you imagined for each line item
I do see in the API that the description of the invoice item, https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-description would be used.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Can you share the specific invoice id?
It starts with in_
In the meantime, I'm trying to reproduce this
Ah yeah, I think the challenge I have is our client A will have somewhere between 50 and 150 clients. so we'd be adding potentially thousands of products. I don't if there's a limit but that's definitely an option. I did actually get that to work but worried about hitting some kind of limit, or it just being a really inefficient way to do it.
But genuinely happy if that's an option ๐
I can't seem to get an invoice ID because it's only on the "upcoming invoice" for January that I can see anything as it's metered and triggered for billing at the end of the period.
The only live invoice ID I have is this one in_1QXLIFRunMEj650HHf0agIwn but that was setup when the subscription was created so it's a $0 invoice
You can use Test Clocks: https://docs.stripe.com/billing/testing/test-clocks in Test mode to test stuff like this
Ahhh ok
Let me try this flow on muy end, hang tight
There is not a limit of how many products you can create. You can create these products, and re-use them each month so that is not 'inefficient'.
We also talk about the different pricing models here: https://docs.stripe.com/products-prices/pricing-models
Awesome OK, I think the multiple products might not be such a bad idea then. And you're right the same clients will mostly have the same sub-clients each month so that would work.
So long as it all totals up to the volume / tiered pricing then we should be good there.
I'll have a read on that last link you shared.
We're on metered just now but we can easily go back to regular charges
Sounds good, I think the above documents will give you enough to test multiple things and see what fits your business model the most. Using Test Clocks will solve many of these 'upcoming invoice' issues as well