From 6277f092963a973c85c5e76fda0f1bcda6a4db04 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Fri, 15 Jul 2022 13:57:45 -0400 Subject: [PATCH] corporate: Fix type annotations for payment failed handler. When being called, the wrapped function is passed `PaymentIntent` (the `content_object` of `Event`). With that, since `customer` can be `None`, an assertion is also required. Signed-off-by: Zixuan James Li --- corporate/lib/stripe_event_handler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/corporate/lib/stripe_event_handler.py b/corporate/lib/stripe_event_handler.py index 5a05011b13..9ca2453d99 100644 --- a/corporate/lib/stripe_event_handler.py +++ b/corporate/lib/stripe_event_handler.py @@ -161,11 +161,12 @@ def handle_payment_intent_succeeded_event( @error_handler def handle_payment_intent_payment_failed_event( - stripe_payment_intent: stripe.PaymentIntent, payment_intent: Event + stripe_payment_intent: stripe.PaymentIntent, payment_intent: PaymentIntent ) -> None: payment_intent.status = PaymentIntent.get_status_integer_from_status_text( stripe_payment_intent.status ) + assert payment_intent.customer.realm is not None billing_logger.info( "Stripe payment intent failed: %s %s %s %s", payment_intent.customer.realm.string_id,