Skip to content

Commit

Permalink
dynamic pricing for redeem
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Kun committed Jun 1, 2016
1 parent 87e2a40 commit ab438e7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hello/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,24 @@ def _redeem(token):
return JsonResponse({'success': True, "message": "Thanks!"}, status=200)


def get_redeem_price(request):
try:
token = request.data['token']
except:
return JsonResponse({'error': 'POST data must include "token"'}, status=400)

try:
requested_token = Token.objects.get(value=token)
if requested_token.redeemed:
raise ValueError()
except:
return 100

return 0


@api_view(['POST'])
@payment.required(get_redeem_price)
def redeem(request):
try:
token = request.data['token']
Expand Down

0 comments on commit ab438e7

Please sign in to comment.