Skip to content

Commit fdda98a

Browse files
cleanup
1 parent b569e50 commit fdda98a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

billing/views.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,27 @@ def invoice_payment_failed(self, invoice: stripe.Invoice) -> None:
107107
card = (
108108
payment_intent.payment_method.card
109109
if payment_intent.payment_method
110-
and not isinstance(payment_intent.payment_method, str)
110+
and hasattr(payment_intent.payment_method, 'card')
111+
else None
112+
)
113+
us_bank_account = (
114+
payment_intent.payment_method.us_bank_account
115+
if payment_intent.payment_method
116+
and hasattr(payment_intent.payment_method, 'us_bank_account')
111117
else None
112118
)
113119
template_vars = {
114120
"amount": invoice.total / 100,
115-
"last_four": card.last4 if card else None,
116121
"cta_link": invoice.hosted_invoice_url,
117122
"date": datetime.now().strftime("%B %-d, %Y"),
118123
# card params
119124
"is_credit_card": True if card else False,
120125
"card_type": card.brand if card else None,
126+
"last_four": card.last4 if card else None,
121127
# us bank params
122-
"is_us_bank": True if payment_intent.payment_method and hasattr(payment_intent.payment_method, 'us_bank_account') else False,
123-
"bank_name": payment_intent.payment_method.us_bank_account.bank_name if payment_intent.payment_method and hasattr(payment_intent.payment_method, 'us_bank_account') else None,
128+
"is_us_bank": True if us_bank_account else False,
129+
"bank_name": us_bank_account.bank_name if us_bank_account else None,
130+
"bank_last_four": us_bank_account.last4 if us_bank_account else None,
124131
}
125132

126133
for admin in admins:

0 commit comments

Comments
 (0)