diff --git a/bd_api/apps/payment/webhooks.py b/bd_api/apps/payment/webhooks.py index a3e838cd..993e2d6a 100644 --- a/bd_api/apps/payment/webhooks.py +++ b/bd_api/apps/payment/webhooks.py @@ -114,10 +114,10 @@ def subscribe(event: Event, **kwargs): @webhooks.handler("customer.subscription.deleted") def unsubscribe(event: Event, **kwargs): """Remove customer from allowed google groups""" - subscription = get_subscription(event) - remove_user(event.customer.email) - subscription.is_active = False - subscription.save() + if subscription := get_subscription(event): + remove_user(event.customer.email) + subscription.is_active = False + subscription.save() # Reference