#brian_best-practices
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/1463394250954641479
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi! Are you planning to do this as a subscription or standalone Invoices?
Standalone, but some customers may also be subscribed to a subscription plan
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.
Awesome! I have a few more questions:
- 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
- What's the best way to figure out how much to provision as a response to the webhook event?
- 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
This docs also provides more info on what i explained above https://docs.stripe.com/invoicing/integration/workflow-transitions#emails
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?
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?
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
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:
- 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.
- 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
what's the best way to distinguish between the two different types of invoices,
For one off Invoices, they do not have a Subscription associated to it, the fieldlines.data.parent.subscription_item_details.subscriptionin the webhook event would be empty. Whereas for a Invoice generated from a Subscription cycle, the field would have the Subscription ID