#uber_code
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/1356443050783539383
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there, if I understand your implementation correctly, you encountered the limit error because there were 20 items in the subscriptions. Can you share with me more about how you hit the limit? is there a reason that you can't set a quantity for the items?
Hi.
So my users will create campaigns with multiple **daily ** budgets.
exemple:
region1 - 2$
region2 - 3$
etc (could be more than 20 budgets).
they chose an engagement lets say 1 month for this exmaple:
so total in invoice should be (2$ + 3$) * 30 days (1 month) = 150$ total
They created a campaign and they should be charged 150$ every month hence why a subscription.
In the invoice it would be ideal to display each region-budget that the campaign is made of (provided by user).
region1 2$
region2 3$
etc..
The problem is that a campaign could have more than 20 items. This is a stripe limit. I dont think its about quantity as each budgets provided by userin the plan could be treated as "items"
Here is a clearer description:
Business Logic:
My platform allows users to create campaigns.
Each campaign consists of multiple regional daily budgets (e.g., $100 for Region A, $200 for Region B).
Users select a billing period (e.g., monthly or quarterly).
The total of all regional budgets for that period becomes the recurring charge.
Issue:
Stripe limits subscriptions to 20 price items.
Since each region's budget is technically a separate price, campaigns with more than 20 regions hit this limit.
If I sum up the total instead, the invoice won't show individual regional breakdowns, which I need.
Goal:
Generate a single invoice that includes all regional budgets.
Ensure subscriptions remain within Stripe’s limits while maintaining breakdown details.
Avoid workarounds that create multiple separate subscriptions per campaign.
Any recommendations?
Sorry I still don't quite understand your business model.
Ive rewrote the business model right before your last message
Let me know if its still unclear
Hmm, so basically you want each subscription item to represent a dialy budget, is my understanding correct?
Exactly. Each daily-budget is an item.
Here is the only solution that comes to mind.
Combined all budgets into a single subscription item.
This will generate a subscription with a single subscription item in the invoice wich represent the total of all dailybudgets provided for the campain.
The downside is that the invoice will not have the breakdown of every budgets the user provided for the new campaign. It will just have a single item thats the total.
BUT from here i can take over and just create my own invoice and attach it to stripe generated invoice.
This way i can have more control over the break down of the different items.
Im just worried about ** Prorate Behavior**.
As mentionned earlier my user will have the possiblity to increase/decrease a dailybudget for a given region
On dailybudget increases, user will be charged right away.
On dailybudget decrease, its just applied next subscription cycle.
You can disable proration when changing the subscription https://docs.stripe.com/billing/subscriptions/prorations#disable-prorations
Does my suggestion makes sens to you?
Or do u think there is an easier/logical approach to this?
Hmm, so your idea is to add 20 invoice items to the draft invoice that the subscription creates?
An invoice item requires an amount, and adding invoice items has impact on the invoice's final aount.
I'd recommend adding the daily budgets in the invoice's [description] (https://docs.stripe.com/api/invoices/update#update_invoice-description) instead, what do you think?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Not really.
My idea is a one single subscription item that represent the total of every budget combined.
Then create my own invoice in my app that displays the actual break down of every budgets
I will take a look into this that could work except i wont have much control over the ui and dont know how it will fit compared to line items
Are you daily budgets fixed for each region? i..e, region 1 is always $2?
Well the user can change a region's budget at anytime.
If increase user is billed right away.
If decrease, user is not billed, the change takes effect next cycle.
So lets say current user campaign has:
region-1 :::: 2$ dailyBudget
halfway thru the month (assuming its a monthly subscription) he upgrades region1 to 3$.
He will be charge for the difference for the remaining time.
So 3$-2$ = 1$ increase for 15 days remaining , user should be charged 15$ right away
and next cycle will use most recent price (in this case 3$).
Decrease is similar except its not applied right away but instead next cycle. So if region1 is 2$ and he decrease to 1$ next renewal will use 1$
If I understand you correctly, you have multiple prices for the same region (i.e., $2 or $3 for region 1), and your customer can upgrade/downgrade the price during the subscription.
Technically i have a single dailybudget per region.
So a region has one budget.
A campaign has many of those.
region1 >> 1$
region2 >> 2$
etc..
However you can increase or decrease that budget for a given region.
region1 >> 1$ (current) >> increase to 2$, billed right away for the increase for remaining days in the cycle
or
region1 >> 1$ (current) >> decrease to 0$ nothing to bill as changes should only be applied next cycle. Next cycle should exclude this region budget (remove it)
Ok, so fixed price for each region, but customer can change the quantity. Is that correct?
I dont think so..
When creating a campaign, the user select regions and for each of those region he provides a budget.
So if he selects region1 and set a daily budget of 1$ and chooses a engagement period of 1 month thats should translate to :
region: region1 represent the selected region
dailyBudget: 1$ represent the **daily ** budget for that region
engagement period (cycle/interval): 1 month
We can represent it in two ways in the invoice:
One item of 30$ (1 quantity) wich would total to 30$
OR
One item of 1$ (30 quantity, 30 being the days ) wich would total to 30$
For the user there is no concept of quantity when he creates a campaign.
He simply select a region (or multiple)
and for each region he provides a dailybudget.
He also provide an engagement period (1 , 3 ,6 or 12 months).
Then i want to bill the user for his dailybudgets * engagement period
In an ideal world each region+budget is an item for a subscription but the limit of 20 makes everything complicated
Why not just $1 (unit_amount) x 30 (quantity) instead? It gives you the flexibity of changing the quantity so that you don't need to calculate the amount by yourself.
Yeah i think thts what i said here:
One item of 1$ (30 quantity, 30 being the days ) wich would total to 30$
but that doenst fix problems of multiple region/budget..
Lets say user select** region1 with a budget of 1$** and engagement period of 1 month (30 days)
That could be like you said:
region #1 >> unit amount 1$ (daily budget) >> quantity 30 (days representing the engagement period) = 30$
but i can only have 20 of those (subscription line items)
That's different, what I suggested is a subscription with one item with 20 quantity, instead of 20 items. have you tried this out?
Well my users provide a budget per region.
That budget can possibly differ.
region 1 >> 1$
region 2 >> 2$
You cant combine those into one item if they are priced differently.
one is an item at 2$ x quantity
other one is at 1$ x quantity
concept of quantity is on a single item same price no?
And that doesnt help my case where i want to have the break down of every budgets (items):
something like this:
Ideally thats what i would like to have in my invoice.
The break down of every regions+budget
and the total of the subscription.
This is an example that doesnt rly work.
Ive set a subcsription with a single item of 0 $
THEN i updated the generated invoice of that subscription to add the different budgets breakdown.
But because the subscription item is at 0$, it marks the subscription as active even tho the payment failed.
I need to step away for a while, will get back to you soon
Yeah its ok ty again
Thanks for waiting. Can you tell me why you can't use the same price for budge of the same unit amount (i.e., 30 days at $1/day x 30) instead of creating 30 items with 30 days at $1/day ?
I see what you're suggesting, but I don't control the budgets—users set them dynamically.
Your example assumes all budgets are the same, but in reality, users set different budgets for different regions.
For example:
Region 1 → $1
Region 2 → $2
Region 3 → $3
...
Region 30 → $30
Since each budget can be unique, they can't be merged into a single price.
The only case where I could combine them is if multiple regions share the exact same budget (e.g., Region 1 and Region 10 both at $1, then I could set quantity = 2). But that’s not always the case
Unless im missing something
Instead of daily, you'll want to call the monthly budget since your billing cycle is monthly.
So that that can you create a base price with $30 as its unit_amount and let your customer choose the multipiler . For example
Region 1 -> $30 x 1 = $30
Region 2 -> $30 x 2 = $60
Region 3 -> $30 x 3 = $90
If you allow your customer to choose a abitrary amount instead of $30, you can also create a ad-hoc price and use it to create a subscription.
Or you can remove the multipiler, and create a unit price for each subscription.
I understand your suggestion, but my users set arbitrary budgets per region—they don’t follow a fixed base price or a multiplier system.
Example of a real campaign setup:
Region 1 → $100
Region 2 → $250
Region 3 → $75
These numbers aren’t tied to a fixed base value like $30, so using a multiplier wouldn't work.
I need each region’s budget to appear as a separate line item on the invoice, since my users expect a detailed breakdown.
The issue is that Stripe limits subscriptions to 20 price items, which makes it impossible when a user has 30+ regions in their campaign. How do I handle this while keeping invoice clarity?
Another alternative you'll want to explore is using invoicing API directly and use your own cron job to schedule the invoice. The maximum number of invoice items is 250.
Okok so ditch subscription, use invoices and create my own schedule to simulate subscriptions right?
Yes you are right.
Ive tought of that i just wanted to see if there wasnt an "easier" approach using subscriptions but i guess not :/
that limit of 20 items is so random specially if an invoice can have many
Subscription is just a invoice thts recurent
So if an invoice can have n amount of items why cant that invoice be recuring haha
I might do the opposite. Stick with Subscription and ditch invoice
but create my own invoice
seems easier
Subscription will have a single item wich is the total of all budgets combined just to charge the user.
The custom invoice will be more details and will breakdown each price
Yes you can do that as well.
Okok so that makes sens to you ? Lookin for reinsurance as I wouldn't want to do something over complicated unnecessarily