Skip to content

Commit

Permalink
respond with 200s on error cases to avoid retries for client errs
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Smith committed Dec 17, 2023
1 parent ff197d3 commit 943e1cf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/api/webhooks/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

transaction_id = notification["txn_id"]
if (
Expand All @@ -148,7 +148,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

donation_currency = notification["mc_currency"]
if donation_currency not in ACCEPTED_CURRENCIES:
Expand All @@ -161,7 +161,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

custom_fields = dict(urllib.parse.parse_qsl(notification["custom"]))

Expand All @@ -177,7 +177,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

if user is None:
logging.error(
Expand All @@ -188,7 +188,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

user_id = user["id"]
username = user["username"]
Expand Down Expand Up @@ -221,7 +221,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

donation_amount = float(notification["mc_gross"])
if donation_amount != calculated_price:
Expand All @@ -234,7 +234,7 @@ async def process_notification(
"request_id": x_request_id,
},
)
return Response(status_code=400)
return Response(status_code=200)

privileges = user["privileges"]
donor_seconds_remaining = max(user["donor_expire"], time.time()) - time.time()
Expand Down

0 comments on commit 943e1cf

Please sign in to comment.