#mangle8582
1 messages · Page 1 of 1 (latest)
You'd need to pass the prorated amount: https://stripe.com/docs/api/refunds/create#create_refund-amount
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Is there a option to calculate this automatically? Or i need to calculate it on backend based on time passed?
Just to clarify, why are you refunding partially in this scenario?
What's the use-case exactly?
So user is buying subscription monthly, it's 5 dollars let's say.
By law, you need to give him a 14 day interval so he can refund his money.
Meanwhile he used the servers, he cannot get 5 full dollars back after 14 days. Because he can stay in a unlimited refunding and he won't pay any money while using the servers.
So i need to prorate him, after 13-14 days if he wishes to refund, he will get money based on how much time he used of subscription plan.
So if it's a 5 dollar subscription monthly and he stayed 14 days, he will get like 2.60 dollars something like that, if he wants to refund
after 14 days he cannot refund anymore
Got it
And are you cancelling the subscription after refund, or want to keep billing them?
cancel the subscription and refund yes at the same time
So if you cancel and prorate their credit balance will be the amount you need to refund them
You can then adjust their credit balance back to 0 since you refunded them the funds
Before he presses the Refund button i will need to show him how much money he will get back, so i will do an invoice call from stripe
is invoice_now a boolean?
Will i need to use await stripe.refund.create if i pass the invoice_now param to stripe.subscriptions.cancel?
Or i can remove it
yep
That depends on if you want them to get a credit to their customer balance or if you want to send funds back to the payment method they paid with.
I want to send the funds back to the payment method yea
So you would create the refund with the code you mentioned above, then adjust the customer balance back to 0
Do i get the remaining proration on await stripe.subscriptions.cancel with invoice_now on the response? So i can pass it to stripe.refund.create({ amount: ??
The Invoice created in this case would have the amount you're looking for, which you could get from the Subscription object that gets returned after subscription.cancel()
Oh nice nice, and if i pass it to await stripe.refund.create({ amount }); Then it will send the funds back to their payment method i suppose.
But then how do i reset the customer balance?
Yup. This doc mentions how to adjust the credit balance: https://stripe.com/docs/billing/customer/balance#:~:text=You can modify a customer's,from the Customer's detail page.
Err, oops. That's the Dashboard version, if you scroll down here it has the API method: https://stripe.com/docs/billing/customer/balance#api
Why do i need to reset the balance to 0? It doens't get automatically reseted after refund is done?
It does not
Yup!
Thank you!