#akashpatil7596_api

1 messages ¡ Page 1 of 1 (latest)

gleaming burrowBOT
#

👋 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.

graceful forgeBOT
#

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.

stray coral
#

No

#

Assign me someone

graceful forgeBOT
plush sparrow
#

hi there!

stray coral
#

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 ?

plush sparrow
#

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

stray coral
#

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 ?

plush sparrow
#

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.

stray coral
#

No ,the customer balance is empty.

plush sparrow
#

can you share the Subscription ID (sub_xxx)?

stray coral
#

sub_1P1m2YIoZDVxPDhe8mKd93QD

plush sparrow
#

thanks! give me a few minutes to look into this.

stray coral
#

Okay sure

plush sparrow
#

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.

stray coral
#

So, how It will be finalize ? cause I have to refund as soon as customer cancels the subscription

plush sparrow
#

by default it finalize after one hour. but you can finalize it yourself if you don't want to wait for one hour.

stray coral
#

Okay, How can I finalize it?

#

Which API?

#

const invoice = await stripe.invoices.finalizeInvoice('in_1MtGmCLkdIwHu7ix6PgS6g8S');

This'll work?

plush sparrow
#

yep

stray coral
#

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?)

plush sparrow
#

yep that looks correct (including step 6).

stray coral
#

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?

plush sparrow
#

no you can pass payment_intent, which you can find in the Invoice object.

stray coral
#

Nope. in response of finalize.invoice Both charge and paymentIntent are null

plush sparrow
#

that's normal, that invoice has no payments. you need to find the previous invoice.

stray coral
#

May I ask, how?

plush sparrow
stray coral
#

Okay