#akashpatil7596_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1225364259991719948
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- akashpatil7596_api, 24 minutes ago, 49 messages
- akashpatil7596_api, 17 hours ago, 10 messages
- akashpatil7596_api, 20 hours ago, 32 messages
- akash_subscription-refund, 21 hours ago, 37 messages
- akashpatil7596_api, 23 hours ago, 14 messages
- akashpatil7596_webhooks, 1 day ago, 72 messages
and 2 more
No I know about refund, I'm asking how can I know how much the remaining amount is.
e.g. If $999.99/year cancels after six month -> 499.99
If $999.99/year cancels after seven month -> ?
How can I know what is the remaining amount ?
that's something that you'll have to compute yourself. something like amount_paid - (number_of_days_the_subscription_was_used / total_number_of_days) * amount_paid
But some other from your team told me that I'll get the remaining amount in latest_invoice after I cancel the subscription.
And It seems true, after I cancel the subscription , I see invoice.created and look at this,
Can I share sub_XXX ID ?
that's correct the amount is computed by Stripe. I think the simplest option to find it is to look a the Customer object, there should be a balance property with the amount.
No ,the customer balance is empty.
can you share the Subscription ID (sub_xxx)?
sub_1P1m2YIoZDVxPDhe8mKd93QD
thanks! give me a few minutes to look into this.
Okay sure
there's no balance yet because the Invoice is still in Draft. as soon as the Invoice will finalize, the balance of the customer will be updated, and you can use that amount for the refund.
So, how It will be finalize ? cause I have to refund as soon as customer cancels the subscription
by default it finalize after one hour. but you can finalize it yourself if you don't want to wait for one hour.
Okay, How can I finalize it?
Which API?
const invoice = await stripe.invoices.finalizeInvoice('in_1MtGmCLkdIwHu7ix6PgS6g8S');
This'll work?
yep
Okay so,
1). cancel subscription
2). get latest_invoice ID from response
3). finalize that invoice
4). check customer's balance
5). refund the balance
6). update customer with 0 balance, right? (is this part necessary? Or stripe will reset to 0 automatically?)
yep that looks correct (including step 6).
Okay, thanks man
Hey Hey, wait a minute
For refund I have to pass charge_id , now in this case how or from where I'm gonna get charge_id?
no you can pass payment_intent, which you can find in the Invoice object.
Nope. in response of finalize.invoice Both charge and paymentIntent are null
that's normal, that invoice has no payments. you need to find the previous invoice.
May I ask, how?
you can list all invoice of a Subscription: https://docs.stripe.com/api/invoices/list
Okay