#Codex-invoice-advancement

1 messages · Page 1 of 1 (latest)

polar parcel
#

Hello! Do you ahve an example invoice I can take a look at

stray pendant
#

Yes, I can DM you

polar parcel
#

It's safe to share the Invoice ID (in_xxx) here

stray pendant
#

in_0Ke5L3uagHrUveG4NFxKyhFO

#

We noticed that we were not receiving the invoice.payment_failed webhook event for some failed invoices. And it looks like the "auto_advance" field was changed, which may have been something to do with it?

polar parcel
#

For that particular invoice auto_advance was set to false because the Subscription that created it was canceled (which will set auto_advance: false for any open invoices on the subscription). Let me dig a bit more tosee why invoice.payment_failed wasn't sent

stray pendant
#

Ahh alright, I see.

#

And yes, thank you, invoice.payment_failed is what we are trying to find out mainly

polar parcel
#

I also see why the invoice.payment_failed event wasn't sent for that invoice - the payment attempt that failed was triggere through a server-side call to the /v1/invoices/in_xxx/pay endpoint. We only send invoice.payment_failed events when payment fails as part of the payment attempts that stripe automatically makes (like during subscription renewal or payment retries).

stray pendant
#

Oh I see. It does look like the card was declined, and it was a first-time subscription purchase (not a renewal)

#

So then invoice.payment_failed is only applicable to renewal events?

polar parcel
#

Just went and double checked - so you can also get the invoice.payment_failed event from subscription creation failure. It's just the explicit requests to the "pay invoice" endpoint that won't trigger the event

stray pendant
#

Is the "pay invoice" endpoint being triggered on Stripe's side automatically?

polar parcel
#

No, the pay invoice endpoint is something that you're specifically hitting. We pay invoices through other internal engines, not through the external "pay invoice" endpoint

stray pendant
#

Alright, I see. Is there any way to trigger invoice.payment_failed in this case, when our side hits the /pay endpoint?

polar parcel
#

No, there isn't any way for you to force an invoice.payment_failed event to be triggered - but it should still trigger a payment_intent.payment_failed event if that helps. You should also know from the response back from stripe whether the payment failed or not

stray pendant
#

That's true. Then in what case does invoice.payment_failed event send from subscription creation failure?

#

As in, if the payment intent succeeds, how can the invoice fail? (and then send that webhook)?

polar parcel
#

If the payment intent is successful there's no way for the invoice to fail

stray pendant
polar parcel
#

Can you rephrase your question - I think I'm not understanding exactly what you're trying to ask, so rephrasing it may help

stray pendant
#

Yes, sorry. You mentioned that "you can also get the invoice.payment_failed event from subscription creation failure"

#

If the payment intent is successful, what cases can the subscription creation fail?

polar parcel
#

If the paymet intent is successful that means the subscription was also successfully created. What I meant is that during subscription creation if things like authentication failed, or the card was declined, you'd get both a invoice.payment_failed and a payment_intent.payment_failed event. Does that make sense?

stray pendant
#

Ahh okay, that makes sense. Thanks for all your help