#rnluu

1 messages · Page 1 of 1 (latest)

untold steppeBOT
lethal folio
potent ledge
#

Hmm what do you mean by that?

#

There is no status on the invoice that shows failed payment

#
for invoices.Next() {
        i := invoices.Invoice()
        // For failed payment invoices, status is open.
        if i.Status == stripe.InvoiceBillingStatusOpen {
            // TODO: not sure if we need another check
            // for the payment intent because we want to
            // specifically find invoices that failed payment.
            pi := i.PaymentIntent
            if pi != nil && pi.Status == stripe.PaymentIntentStatusRequiresPaymentMethod {
                // Then this means that it failed payment.
            }
        }
    }
#

Would this work by the way?

#

If I look at the payment intent status === requires payment method (indicates it failed right) ?

lethal folio
#

Oh, you're looking for invoices that had failed payments. Looking

potent ledge
#

Yep exactly

#

Invoices that had failed payments

#

Actually more precisely, invoices where latest payment failed.

lethal folio
potent ledge
#

Ok so I list all invoices

#

And I'm iterating through them

#

Then what can I do to see if they failed payment?

#

open can be open for various reasons, not just failed invoices

#

Right now I'm iterating through and looking for open invoices that have payment intent status === requires_payment_method

#

Would that suffice?

lethal folio
#

Yes, that would work.

potent ledge
#

Ok is there a better status to look at?

#

Or does require_payment_method basically indicate that it's a failed payment?

lethal folio
#

Yes, when the payment fails, you'd see requires_payment_method and that is what you'd filter through.