#Ale_

1 messages · Page 1 of 1 (latest)

balmy sailBOT
frank stump
#

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?

gentle depot
#

I pretend to call /invoices/:id/pay for the last invoice of a subscription that failed

frank stump
#

You can only pay an invoice once it's open (aka finalized)

gentle depot
#

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?

frank stump
#

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.

gentle depot
#

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

frank stump
#

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

gentle depot
#

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

frank stump
#

OK, you can also listen to invoice.payment_failed. It tells you when a invoice payment fails

gentle depot
#

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

gentle depot
frank stump
gentle depot
#

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?

frank stump
#

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