From 0c23b6eeb55d80d83f2bc17e4abe64d33a601eeb Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Fri, 1 Jul 2022 12:35:59 -0400 Subject: [PATCH] Handling missing subscription when canceling paypal. --- apps/profile/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/profile/models.py b/apps/profile/models.py index c745cc785..d924dc97d 100644 --- a/apps/profile/models.py +++ b/apps/profile/models.py @@ -868,10 +868,12 @@ class Profile(models.Model): continue url = f"/v1/billing/subscriptions/{paypal_id}/suspend" - response = paypal_api.post(url, { - 'reason': f"Cancelled on {today}" - }) - # logging.user(self.user, f"response: {response}") + try: + response = paypal_api.post(url, { + 'reason': f"Cancelled on {today}" + }) + except paypalrestsdk.ResourceNotFound as e: + logging.user(self.user, f"~FRCouldn't find paypal response during ~FB~SB{paypal_id}~SN~FR profile suspend: ~SB~FB{e}") logging.user(self.user, "~FRCanceling Paypal subscription: %s" % paypal_id) return paypal_id