#phillip_ubb-upcoming

1 messages ยท Page 1 of 1 (latest)

lost timberBOT
#

๐Ÿ‘‹ 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/1291091152690352190

๐Ÿ“ 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.

stark hare
#

Hello @compact haven , let me know if my question is clear. Basically I'd like to know how to add the value for the usage just right before the amount gets charged.

compact haven
#

phillip_ubb-upcoming

#

@stark hare that will work but the "problem" you might have is that the Event is sent a while before the Subscription's period end (default of 3 days) so you might miss some reporting. If that's okay with you then your approach sounds fine

stark hare
#

3 days would be too early. Is there a way to set it to 2-3min before? Or somehow stop the charge event, set the value, and after it has been set by my function, continue with charging the credit card?

compact haven
#

No that's impossible. If we did 2/3 minutes before then any delay or downtime on your end would lead to no payment that entire cycle

#

would that fit your needs?

stark hare
#

This is a lot of information to take in and I'm not quite sure how this is supposed to work.

Am I understanding it correctly?

  1. Implement a webhook whenever an invoice was created in draft status
  2. Then, add the usage
  3. Then, finalize the invoice and charge the credit card
compact haven
#

Yep! sorry that's really the same as what you planned to do with invoice.upcoming, just you would listen to invoice.created instead and react accordingly to add the right usage

stark hare
#

Gotcha. So this means I would listen to the invoice.created webhook. I assume this webhook will return the drafted invoice with an invoice ID.

Then, I probably have to call
await stripe.invoices.finalizeInvoice('in_1MtGmCLkdIwHu7ix6PgS6g8S'); and I would pass amount_due?

I'm unsure how this is supposed to work. Because I have set up a meter for the usage billing. Not sure how to properly set the value

compact haven
#

You listen for invoice.created yes. Then you report usage usually that means creating a MeterEvent with the right information. You don't configure any amount due yourself no

stark hare
#

Ah, got it! This makes perfectly sense. I think I have all the right information for now.
Thanks for steering me in the right direction ๐Ÿ™