#covalenta_ubb-complex

1 messages ยท Page 1 of 1 (latest)

north crescentBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

tame helm
#

covalenta_ubb-complex

north crescentBOT
ancient adder
#

Hi there, yes you can create a subscription with prices associated with different meters (i.e., GB/s + vCPU/s)

#

So your billing model contains 3 prices

  • A flat fee - fixed monthly recurring amount
  • GB/s fee - metered
  • vCPU/s - metered
dusty coral
#

Just to be on the same page, this would be an example:

Customer A, at the end of the month with:
Usage:

  • 10 000 GB/s = $10 (0.001$/s)
  • 10 000 vCPU/s = $10 (0.001$/s)

Pro tier subscription:

  • $100

Starting credits:

  • $50

The bill they would get:
$10 + $10, deducted from credits = $0 to pay (now they have $30 credits left)
$50 for the subscription

Total: $100

EDIT: Fixed total

ancient adder
#

To clarify, if the credits start with $50, shouldn't the remaining credits be $30? (i.e., 50-10-10)

dusty coral
#

(You are right, I accidentally used the actual numbers we use in prod just for the subtraction)

ancient adder
dusty coral
#

That would be great.

So you issue the credit not in a way that it is only counted towards specific meters/items?

ancient adder
#

No, the credits will be applied to all invoices generated for the customer.

dusty coral
#

Yeah, that would be a problem for us.
We want to always provide starting credits for the usage, but if you subscribe to the Pro tier we don't want the credits to apply to that.

ancient adder
#

Then you can manage the credits yourself and give discounts to your customer by creating negative amount invoice item to the newly created invoice.

dusty coral
#

Is there a way to get the values of meters from Stripe API to calculate the values without aggregating all the usage over the month ourselves?

ancient adder
dusty coral
#

We would probably need to implement logic for advancing/finalizing the invoice so we can schedule the credits calculation after the invoice draft with usage is done, but before it allowed to collect, right?

ancient adder
#

I don't quite understand why you want to finalize the invoice earlier, can you elaborate?

dusty coral
#

I might be confusing some terms (I was not implementing this logic for us so far), basically is this the flow that would work:

  1. At the end of the month Stripe will create an invoice draft that includes the usage and subscription that would be billed
  2. (Based on the previous event โ€” caught by webhook?) We then need to add a negative amount to this invoice by calling Stripe API for getting the metered usage and the using the credits managed by us. We need to do this after the invoice draft is created otherwise the numbers won't match the usage and credit deduction
  3. Then we manually change the invoice status from draft to open so it can be paid
ancient adder
#

OK, for step 2, you don't need to rely on previous event, you can listen to invoice.created event to get notified when a draft invoice is created, and you can just add negative invoice item on this draft invoice, and finalize it.