Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 667cfba

Browse files
cleanup
1 parent ce5a4cf commit 667cfba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

billing/views.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,19 @@ def invoice_payment_failed(self, invoice: stripe.Invoice) -> None:
9191
if invoice.default_payment_method is None:
9292
if invoice.payment_intent:
9393
payment_intent = stripe.PaymentIntent.retrieve(invoice.payment_intent)
94-
if payment_intent.status == "requires_action":
94+
if (
95+
payment_intent is not None
96+
and payment_intent.get("status") == "requires_action"
97+
and payment_intent.get("next_action", {}).get("type")
98+
== "verify_with_microdeposits"
99+
):
95100
log.info(
96101
"Invoice payment failed but still awaiting known customer action, skipping Delinquency actions",
97102
extra=dict(
98103
stripe_customer_id=invoice.customer,
99104
stripe_subscription_id=invoice.subscription,
105+
payment_intent_id=invoice.payment_intent,
100106
payment_intent_status=payment_intent.status,
101-
next_action=payment_intent.next_action,
102107
),
103108
)
104109
return
@@ -360,7 +365,8 @@ def _has_unverified_initial_payment_method(
360365
) -> bool:
361366
"""
362367
Helper method to check if a subscription's latest invoice has a payment intent
363-
that requires verification (e.g. ACH microdeposits)
368+
that requires verification (e.g. ACH microdeposits). This indicates that
369+
there is an unverified payment method from the initial CheckoutSession.
364370
"""
365371
latest_invoice = stripe.Invoice.retrieve(subscription.latest_invoice)
366372
if latest_invoice and latest_invoice.payment_intent:

0 commit comments

Comments
 (0)