Skip to content

Commit 567076b

Browse files
committed
Fix internal error that could happen if makeradmin had not detected that a stripe subscription no longer exists.
1 parent 505bab0 commit 567076b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

api/src/shop/stripe_subscriptions.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,18 @@ def resume_paused_subscription(
322322
# We can just wait for it to start as normal
323323
return False
324324

325-
subscription = retry(lambda: stripe.Subscription.retrieve(subscription_id))
325+
try:
326+
subscription = retry(lambda: stripe.Subscription.retrieve(subscription_id))
327+
except InvalidRequestError as e:
328+
if e.code == "resource_missing":
329+
# The subscription was deleted.
330+
# We might have missed the webhook to delete the reference from the member.
331+
# Or the webhook might be on its way.
332+
# Treat this as if there is no subscription.
333+
return False
334+
else:
335+
raise
336+
326337
# If the subscription is not paused, we can just do nothing.
327338
if subscription["pause_collection"] is None:
328339
return False

0 commit comments

Comments
 (0)