-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add caching on client id for purchases #1551
base: master
Are you sure you want to change the base?
Conversation
koutst
commented
Apr 25, 2024
•
edited
Loading
edited
- To prevent accidental double purchases such as tipping.
- All requests to this endpoint will require a client id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/purchase/views/purchase_view.py
Outdated
cached_client_id = cache.get(f"purchase_client_id_{client_id}") | ||
if cached_client_id: | ||
return Response( | ||
{ | ||
"detail": "This purchase has already been processed", | ||
}, | ||
status=400, | ||
) | ||
|
||
cache.set(f"purchase_client_id_{client_id}", True, timeout=60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It might be better to implement idempotent behavior and return the original transaction with a 2xx series response code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
8ccf11c
to
0112cfc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Paper contributions front end needs to be updated before deploying |