#Ale_
1 messages · Page 1 of 1 (latest)
Hi there, invoice.created is fired when the invoice is just created and still in draft mode.
Do you intent to save a draft invoice or finalized invoice?
I pretend to call /invoices/:id/pay for the last invoice of a subscription that failed
You can only pay an invoice once it's open (aka finalized)
so if invoice is created with invoice.created, if the payment of the invoice fails, I already have the reference to call the /pay endpoint for that invoice
an invoice in a "failed" status cannot be paid?
There's no "failed" status for an invoice.
I think most likely you were trying to pay and draft invoice and that's why the API request fails.
Nono, if an invoice payment fails, the label in the dashboard shows a "failed" at the side of the invoice, but the invice remains open
i just want to keep reference in my own database of the latest invoice, independent of either the payment failed or not
Maybe you can tell me what you want to achieve? so that I can help you with a solution.
I'd suggest you to listen to invoice.finalized events then
I have a scenario where a subscription is renewed monthly, then if at any time, one of those renewals fail, I want to have a button that tells the user "Pay invoice" that pay invoice must pay that latest invoice that failed
OK, you can also listen to invoice.payment_failed. It tells you when a invoice payment fails
for that i was thinking on keeping a track at every time an invoice is created, so I always know the latest invoice, and if the subscription is updated from stripe via webhook with an "unpaid" status, then I know which invoice to use to call the /pay endpoint
yeah this may be more precise
https://stripe.com/docs/billing/subscriptions/overview#settings btw Stripe will automatically retry a payment if it's failed, and you can manage the Smart retries through your Dashboard settings
Perfect, thank you! About my last question, Is the period_start and period_end of a subscription invoice the same as the current_period_start and current_period_end of the subscription itself?
example: susbcription starts May 1 and ends May 30, invoice is paid on May 10, the period_start of the invoice object is May 1 and the period_end is May 30?
If the invoice line_item is a subscription line item, then yes it matches with the current_period_start and current_period_end of the subscription