#jacobfinn
1 messages · Page 1 of 1 (latest)
Did you refund too little or too much?
too little I presume
So you should be able to create a second refund for the rest of the amount then
how do I calculate the prorated amount
# Retrieve the current date and the subscription billing period end date
current_date = datetime.now().date()
billing_period_end = datetime.fromtimestamp(sub.current_period_end).date()
# Calculate the remaining days in the billing period
remaining_days = (billing_period_end - current_date).days
amount = (5 / 30) * invoice.amount_paid
# In case of 31 day proration of a sub <1 old
if amount > invoice.amount_paid:
amount = invoice.amount_paid
Are you using subscriptions?
Yea
Well how can I undo all my refunds now
You can't. If you've already refunded, money may be already on the way to their bank
Unless this just happened
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Theres no way for stripe to write a script that does it for me?
how do I send a refund once I cancel the sub with prorated
How many subs are there?
a few hundred
Ah ok. Because if you do this via the dashboard, it's easy to refund
Otherwise via code you have to look at customer balance adjustment for the proration
Oh you've already cancelled all the subs?
yea
Did you prorate the cancellation? Can you share an example subscription id?
sub_1OeAP8AmkPjkxT8Nz4QcfRCQ
Basically just canceled the sub and sent what I incorrectly calculated to be a prorated refund
Oh yeah you didn't prorate the cancellation
So your only option at this point is to calculate the correct prorated amount yourself
Well how do I do that
How do you know that the amount you originally calculated is incorrect?
Customers angry
Ah
I figured it was remaining days * cost of sub per day
That seems right to me
Why are the customers saying that's incorrect?
That means you only charged them for the days they used
You can make the calculation more specific (ie prorate down to the second not day)
But your approach makes sense too. Really depends on how you want to do it
Our prorations are down to specific timestamps instead of the day
Can I still make refunds with a negative balance?
Or do I need to wait for the funds to hit
ok cool
How can I get the canceled subscription from retrieving a refund
I guess ill have to fetch all the refunds, and find the sub, calculate the correct proration, subtract the current refund and send another
You'd need to work your way back from the payment intent: https://stripe.com/docs/api/refunds/object#refund_object-payment_intent
That'll have an invoice: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice