Skip to content

Commit

Permalink
Add transaction ID to failure logs (#4)
Browse files Browse the repository at this point in the history
We could also add the user id; but just doing a quick improvement here from web browser
  • Loading branch information
cmyui authored Mar 27, 2024
1 parent 26c1e56 commit 865f92c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/api/webhooks/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,28 @@ async def process_notification(
pass

notification = dict(request_params)
transaction_id = notification["txn_id"]

if notification["payment_status"] != "Completed":
logging.warning(
"Failed to process IPN notification",
extra={
"reason": "incomplete_payment",
"payment_status": notification["payment_status"],
"transaction_id": transaction_id,
"request_id": x_request_id,
},
)
schedule_failure_webhook(
fields={
"Reason": "incomplete_payment",
"Payment Status": notification["payment_status"],
"Transaction ID": transaction_id,
"Request ID": x_request_id,
},
)
return Response(status_code=200)

transaction_id = notification["txn_id"]
if (
settings.SHOULD_ENFORCE_UNIQUE_PAYMENTS
and await notifications.already_processed(transaction_id)
Expand Down

0 comments on commit 865f92c

Please sign in to comment.