#revathy_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/1266322822255607949
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- revathy_code, 1 hour ago, 18 messages
๐ happy to help
I'm working on implementing a per-seat subscription model using Stripe, and I need some guidance on handling proration correctly.
Scenario:
Initial User Subscription:
Start Date: July 1
End Date: August 1
Amount: $5 for one user
Adding Two Users:
Date: July 1
Total Amount: $10 (2 users * $5 each)
Adding One User:
Date: July 15
Prorated Amount: $2.50 (half the month)
Expected Charges:
Initial Payment (July 1): $5
Additional Users (July 1): $10
Prorated Charge (July 15): $2.50
Total: $17.50 for the period from July 1 to August 1
Current Implementation:
Creating Initial Subscription:
javascript
const stripe = require('stripe')('your-stripe-secret-key');
async function createInitialSubscription(customerId, priceId) {
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{ price: priceId, quantity: 1 }],
});
return subscription;
}
Updating Subscription for Additional Users:
javascript
async function updateSubscription(subscriptionId, subscriptionItemId, newQuantity, prorationDate) {
await stripe.subscriptions.update(subscriptionId, {
items: [{ id: subscriptionItemId, quantity: newQuantity }],
proration_behavior: 'create_prorations',
proration_date: prorationDate,
});
}
$17.50 for the period from July 1 to August 1
that won't be paid in one invoice though
proration_behavior: 'create_prorations',
instead usealways_invoice
Scenario:
Initial User Subscription:
Start Date: July 1
End Date: August 1
Amount: $5 for one user
Adding Two Users:
Date: July 1
Total Amount: $10 (2 users * $5 each)
Adding One User:
Date: July 15
Prorated Amount: $2.50 (half the month)
Expected Charges:
Initial Payment (July 1): $5
Additional Users (July 1): $10
Prorated Charge (July 15): $2.50
Total for July 1 - August 1: $17.50
but in my case i getting quantity*price + prorate as final amount
what sub_xxx ID is this screenshot from?
sub_1PgjBwDnKBG45FSNKU7JVr1F
what does
Adding One User:
Date: July 15
Prorated Amount: $2.50 (half the month)
mean? you created this subscription today and updated it 3 times in the last couple of hours, so all the proration is going to be based on those timestamps when you actually do the updates. So because the changes are so early in the subscription cycle, the proration is generally very large.
it is for my testing purpose, i just shared a sample data, in the above sample total amount = per-seat charge + prorate ,
my exact issue in total amount 30$ in my expectation is 20$ only
so you don't want there to be any proration at all(you don't want the two "prorated charge" items?)
I'm sorry, it's not really making sense to me.
this is how proration works in Stripe if it helps you calibrate your mental model:
When a customer moves from plan A to plan B in the middle of the billing cycle, we automatically calculate the proration to ensure that the customer pays what is expected. This is fairly detailed in our subscriptions guide where we cover upgrading and downgrading [1] so I would advise you to look into that documentation if you don't find my explanation clear enough!
Let's take an example where you have a customer subscribed to plan A for $50 monthly on the 1st of the month and then at the middle of the month you move him to plan B for $20/month we won't charge the customer immediately but we will calculate the proration for him and here's what would happen:
- The user paid $50 for the full month but he stops that plan mid month so so we create an invoice item indicating you owe him $25 (half a month).
- The user moved to plan B for half a month so he needs to pay for that time so we create an invoice item indicating he owes you $10 (half a month).
Those invoice items are then added to the upcoming invoice that would be created on the 1st of next month. Your customer would then owe you $20 + $10 and you owe him $25 so the invoice total would be $5.
[1] https://stripe.com/docs/subscriptions/upgrading-downgrading
For example user X created a subcription for one month (july 1 to aug 1) , that time total amount is 5$ , then X added other user Y on july 15 then increment the quantity subscription to 2 , and prorate to 2.5$ right?
no it would be like
- refund the "remaining time on 1x User" -> roughly $2.50 since it's halfway in the month
- charge the "remaining time on 2x User" -> ($5 x 2) / <remaining time (roughly half) > -> so about $5 total
so the next invoice on Aug 1 is
- -$2.50 // proration of old state
- +$5 // proration of new state
- +$10 // amount for the upcoming month
- ==> $7.50
if we add 3 users in july first itself then what amount owner need to pay, could you pls explain that part also , it make confuse me
it would be something like this
refund the "remaining time on 1x User" -> roughly $4.99 since it's the start of the month and ~99% of the time is remaining, let's say.
charge the "remaining time on 3x User" -> ($5 x 3) / <remaining time (roughly 99%) > -> so about $14.99 total
so the next invoice on Aug 1 is
-$4.99 // proration of old state
+$14.99 // proration of new state
+$15 // amount for the upcoming month
==> $25.00
for this case 20$ for next month and 10$ for new user in in current subscription right?
in that screenshot the $5 and the $5 are prorations, and the $20 is the amount for the next month(since they are "now" on 4x user). Remember this screenshot is the "upcoming invoice", so it includes the charge for the following month.