#Galo

1 messages · Page 1 of 1 (latest)

faint muralBOT
half tiger
#

Hi there! The proration amounts will ultimately depend on when a subscription is updated

opaque ice
#

I am creating a subscription in, stripe charges me a proration until the end of the month, that proration mathematically how is it calculated

half tiger
#

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

opaque ice
#

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

half tiger
#

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)

opaque ice
#

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

half tiger
#

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

opaque ice
#

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

half tiger
#

Could you share the invoice ID for the invoice in your screenshot?

opaque ice
#

in_1M31HXDf4g8lWBtbvnLaSYle

#

test mode

half tiger
#

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!