#Galo
1 messages · Page 1 of 1 (latest)
Hi there! The proration amounts will ultimately depend on when a subscription is updated
I am creating a subscription in, stripe charges me a proration until the end of the month, that proration mathematically how is it calculated
In general, you'll need to calculate the percentage of the time that remains on a customer's current billing cycle. Then, use that percentage/decimal to determine whether there's a credit/debit for their current subscription; and whether there's a credit/debit for their new subscription
This is outlined here: https://stripe.com/docs/api/subscriptions/update
You can also see any prorations in action by looking at a customer's upcoming invoice for a given subscription: https://stripe.com/docs/billing/subscriptions/prorations#preview-proration
I understand but what I need to know is the mathematical calculation to calculate the prorate. In the invoice that I attach stripe charges a proration, in my system I calculate it but I do not agree with the calculation of stripe
That amount should be a percentage of the FULL GYM ACCESS price. the 10.90 amount should be essentially three days' worth of access (November 11 - 14)
ok I understand. My problem is that I have to show this in my system before I charge the customer for him to accept it. My calculation of proration does not matter to me as stripe, I have cents of difference and I also calculate the percentage of 11 -14. What I need to know is the exact mathematical calculation.
for example, membership cost usd 99
99/30=3.3 per day
day 11 12 13 14 = 4 days
4*3.3=13.20
that in my account
Stripe charges 10.90
Got it. Okay, let's start with previewing the upcoming invoice. I'll explain why: https://stripe.com/docs/billing/subscriptions/prorations#preview-proration
In order to calculate the fraction of the remaining time on a given subscription, you'll need to take the amount of time that's left on the billing cycle and divide that by the amount of time on the full cycle. I understand you're calculating based on days but you'll need to calculate down to the second.
So, when previewing an invoice, you'll want to look at the invoice lines, and the period.end and period.start timestamps
but when it is the first time that I register the client I do not have a next invoice, the client is not yet in stripe.
I'm calculating seconds too but it doesn't match
Could you share the invoice ID for the invoice in your screenshot?
Sorry for the delay!
Let me explain how this proration amount was calculated:
Since this invoice was triggered by the creation of a subscription, the time left in the period is calculated by subtracting the subscription's current_period_end from current_period_start
then, you'll divide that number by 2592000. this is the number of seconds in a month. we're using a month since your 99.00 price is for a monthly interval
That gives us 0.11007... To calculate the proration amount, we multiply this fraction by 99.00 to get 10.897, and round this up to 10.90
@opaque ice let me know if this helps!