#txie_api

1 messages · Page 1 of 1 (latest)

hot valveBOT
#

đź‘‹ 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/1443028301311643800

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

half delta
#

The flow works like this:

The user chooses a new base plan tier, picks monthly or yearly billing for it, and adjusts add-on quantities.

I show them a simple summary of what they picked.

Then I call Stripe’s preview invoice API to get the actual upcoming charge based on those changes.

After the user confirms, I apply the update using subscriptions.update() (or schedule it) so the subscription changes go live with correct billing and proration rules.
I have three tiers for the base plan and the add-ons are strictly monthly.
My main rules for changes: upgrades should apply immediately with proration; downgrades of the base or tiers should apply at the end of the billing period; add-on increases immediately, add-on decreases next cycle.
I’m using the Create Preview Invoice API endpoint (/v1/invoices/create_preview). I send a payload like:

{
"customer": "cus_XXX",
"subscription": "sub_YYY",
"subscription_details": {
"items": [
{ "price": "price_base_new", "quantity": 1 },
{ "price": "price_addon_employeeSeats", "quantity": 10 },
{ "price": "price_addon_moduleSlots", "quantity": 4 }
],
"proration_behavior": "always_invoice"
}
}

The problems I’m seeing: when downgrading the base plan (especially from yearly or from highest tier), I sometimes get an immediate credit or charge instead of the change waiting until period end. I’m not confident my logic is correctly separating “immediate updates” (upgrades/add-on increases) from “scheduled updates” (downgrades) especially when mixing base plan changes, interval changes and add-on quantity changes.
Could you confirm if this architecture — one subscription with base plan + add-ons + preview → confirm → apply flow — is recommended for Stripe, and advise on how to properly handle scheduled downgrades and edge-cases?

hot valveBOT
half delta
#

The remaining of

What are you working on?

I’m building a backend and frontend for a SaaS billing system where users can change their base plan (monthly or yearly), change add-on quantities (monthly only), see a preview of final charges before confirmation, and have changes applied correctly according to proration and scheduling rules.

empty path
#

hello! gimme a while to go through what you shared

#

can you share an example request id where you downgraded the base plan and get an immediate credit or charge? The request id has a prefix of req_

half delta
#

req_GygXp6ifwy1V4j

empty path
#

hmmmm, maybe I'm mis-seeing something, but that upcoming invoice will be generated on the 6 of december right?

half delta
#

My goal is for the client to see an order-summary preview of what will be charged on the next billing anchor (which in this case is December 6). I want to confirm that the preview invoice reflects the correct amount for that cycle and that no immediate charge or credit happens after the change (unless it’s an upgrade). I’m using that “upcoming invoice” preview to power the UI before the user clicks confirm.

empty path
#

yep, but you were mentioning that for certain cases, you get an immediate charge or credit?

#

I'm looking for an example request where you are getting an immediate charge or credit, which you didn't expect to happen

half delta
#

I’m aiming to show a preview of what will be charged now (if any), the new monthly rate, and next billing date upgrades happen immediately with proration, downgrades should take effect at period end with no immediate credit or charge

empty path
#

to clarify, you mentioned this :

The problems I’m seeing: when downgrading the base plan (especially from yearly or from highest tier), I sometimes get an immediate credit or charge instead of the change waiting until period end.

Can you share an example request for ^?

#

I understand what you're trying to achieve, I want to look into why you get an immediate credit or charge instead of the change waiting until period end. - I need an example to refer to

half delta
#

I dont have a specific req_… id handy at this very moment where I got an unexpected immediate credit/charge instead of waiting until period end

empty path
#

ok, I think all I can do is make a guess, that's likely happening if you change the billing interval e.g. from yearly to monthly

#

if the billing interval changes, we'll charge immediately

half delta
#

If the billing interval changes it should charge immediately. So monthly > yearly but not yearly > monthly (that i want scheduled next billing anchor for the base plan and not the addon)

empty path
#

with Subscription Schedules, you can schedule the change to happen exactly at the end of the billing period

half delta
#

I understand the schedule part just trying to figure out how I can like show on the client view the summary of the changes being made before they initiate it

#

Like this is what i have on my ui

empty path
#

if the user chooses not to upgrade / downgrade, you'll need to release the schedule

half delta
#

so in that invoicePreview for downgrades use schedule_details and then for upgrades just add them to subscription items (that take affect immediately instead of next billing anchor).

empty path
#

yep, but give it a try to make sure it fits your requirements

half delta
#

okay i'll try that. apperiate it sorry for the confussion im not the best at explaing