Skip to content

Commit

Permalink
fix error on /account if stripe account not found
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Feb 29, 2024
1 parent 7396c83 commit 88f50db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app_users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ def search_stripe_customer(self) -> stripe.Customer | None:
if not self.uid:
return None
if self.stripe_customer_id:
return stripe.Customer.retrieve(self.stripe_customer_id)
try:
return stripe.Customer.retrieve(self.stripe_customer_id)
except stripe.error.InvalidRequestError as e:
if e.http_status != 404:
raise
try:
customer = stripe.Customer.search(
query=f'metadata["uid"]:"{self.uid}"'
Expand Down

0 comments on commit 88f50db

Please sign in to comment.