#brian_best-practices

1 messages ¡ Page 1 of 1 (latest)

west lionBOT
#

👋 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/1463394250954641479

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

raw python
#

Hi! Are you planning to do this as a subscription or standalone Invoices?

west lionBOT
onyx hill
#

Standalone, but some customers may also be subscribed to a subscription plan

fresh oyster
#

Hey! Stepping in for Sam here, you should be listening for the invoice.paid event instead, and then allocating the appropriate credits after

Sent when the invoice is successfully paid. You can provision access to your product when you receive this event and the subscription status is active.
This applies for both standalone Invoices or Invoices from Subscriptions.

#

The invoice.finalized event is sent when an invoice is successfully finalized and ready to be paid, not when it is paid.

onyx hill
#

Awesome! I have a few more questions:

  1. Around how long does it take for invoices to be paid after they are created via the API (stripe.invoices.finalizeInvoice)? Assuming that the customer already has a credit card attached
  2. What's the best way to figure out how much to provision as a response to the webhook event?
fresh oyster
#
  1. Around how long does it take for invoices to be paid after they are created via the API (stripe.invoices.finalizeInvoice)? Assuming that the customer already has a credit card attached
    The timing depends on the collection method [0] specified on the Invoice object.

If it is charge_automatically, Stripe will attempt to pay this invoice immediately using the default payment method (or card in your case) attached to the customer.

If it is send_invoiceStripe will email this invoice to the customer with payment instructions. The timing to when the Invoice gets paid then depends on how long the Customer takes to receive and open the Invoice to completes payment

[0] https://docs.stripe.com/api/invoices/object?api-version=2025-12-15.preview&rds=1#invoice_object-collection_method

#

What's the best way to figure out how much to provision as a response to the webhook event?
What do you mean by how much to provision?

Do you mean what values and data are returned in the event payload?

onyx hill
#

I'm setting up a combination of plan-based subscriptions (which also send invoice.paid events), and credit topup invoices. My question is what's the best way to distinguish between the two different types of invoices, as well as for credit topup invoices, how do I know how many credits I should be correctly assigning to my customers?

fresh oyster
#

Before providing an answer, could I confirm that these credit are configured and exists within your application and are not related to Stripe's Credit balance? or credit notes

fresh oyster
#

how do I know how many credits I should be correctly assigning to my customers?
If these credits are configured and exists within your application,

Then you can consider the following options:

  1. Create products and prices

Create products and prices [0] that represent the options (e.g. Credits for $10 dollars) available for your customers. The Price ID can then be specified when Creating a Subscription [1]. The same Price IDs can also be specified for one-off invoices in this field [2].

The subsequent invoice.paid event after a successful invoice payment will contain these price details, which you can use to determine how much credit to assign to your customers.

  1. Metadata

If you already have subscriptions configured and simply want to add additional data that will be reflected in your webhook events, you can consider using metadata [3]. The same approach can be applied when creating one-off invoices by using the metadata field [4].

The subsequent invoice.paid event after a successful invoice payment will contain the metadata specified which you can use to determine how much credit to assign to your customers.

[0] https://docs.stripe.com/products-prices/how-products-and-prices-work#one-time-and-recurring-payments
[1] https://docs.stripe.com/api/subscriptions/create#create_subscription-items-price
[2] https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-pricing-price
[3] https://docs.stripe.com/metadata#exceptions
[4] https://docs.stripe.com/api/invoices/create?api-version=2025-12-15.preview&rds=1#create_invoice-metadata