#aaaa-stripe-refund
1 messages ยท Page 1 of 1 (latest)
hi
Have you listed the refunds for that charge using https://stripe.com/docs/api/refunds/list#list_refunds-charge?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ah actually
You don't need to do that
You just retrieve the charge itself
And look at amount_refunded: https://stripe.com/docs/api/charges/object#charge_object-amount_refunded
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I use this reference
https://stripe.com/docs/billing/subscriptions/prorations
after that I calculate the amount
I'm sorry I don't really understand what you are saying/asking at this point.
Can you give me way more details?
Do you have any example objects I can look at?
What are you trying to do with this?
Like let's back up
What exactly is your goal here?
You want to create a refund, but why? When? What is the situation exactly?
ok so as per situation
I have 1 year subscription plan
I want to refund the amount if a customer wants to cancel the subscription at some point
So I guess the amount which I got after calculation is fine but after calling refund .create I got error
StripeInvalidRequestError: Refund amount ($----) is greater than unrefunded amount on charge ($11.90)
So you want to refund the full amount that was paid at the beginning of the year? Or you are looking to refund the prorated amount?
refund the prorated amount
And how are you performing the Subscription cancelation?
Are you setting prorate: true?
I am cancelling it after refund
no I have not set prorate:true
for cancellation
const deletedSubscription = await stripe.subscriptions.del(
req.body.subscritpionId
);
Gotcha. Calculating proration yourself is pretty tricky
You could just have us calculate it via the credit and then delete that credit after issuing the refund
That would be much easier imo
So if you set prorate: true then an invoice item will be added to the customer as a credit. See: https://stripe.com/docs/api/subscriptions/cancel#cancel_subscription-prorate
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That invoice item will be the proration amount
So you can refund that amount and then delete the invoice item using https://stripe.com/docs/api/invoiceitems/delete
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I'd recommend testing out cancelling the Sub using prorate: true and see what that behavior looks like