Skip to content
This repository was archived by the owner on Oct 7, 2023. It is now read-only.

Commit 68b2610

Browse files
author
Mohammed Hammoud
committed
Add bad request status codes
1 parent 3cb986c commit 68b2610

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

payments/api/views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def post(self, request, *args, **kwargs):
8282

8383
return Response(subscription, status=status.HTTP_201_CREATED)
8484
else:
85-
return Response(serializer.errors)
85+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
8686
except stripe.StripeError as e:
8787
from django.utils.encoding import smart_str
8888

@@ -113,7 +113,7 @@ def post(self, request, *args, **kwargs):
113113

114114
return Response(validated_data, status=status.HTTP_201_CREATED)
115115
else:
116-
return Response(serializer.errors)
116+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
117117

118118
except stripe.CardError as e:
119119
error_data = {u'error': smart_str(e) or u'Unknown error'}
@@ -132,7 +132,7 @@ def post(self, request, *args, **kwargs):
132132
customer.cancel()
133133
return Response({'success': True}, status=status.HTTP_202_ACCEPTED)
134134
else:
135-
return Response(serializer.errors)
135+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
136136
except stripe.StripeError as e:
137137
error_data = {u'error': smart_str(e) or u'Unknown error'}
138138
return Response(error_data, status=status.HTTP_400_BAD_REQUEST)
@@ -223,7 +223,7 @@ def post(self, request, *args, **kwargs):
223223
error_data = {u'error': u'Webhook must contain id, type and livemode.'}
224224
return Response(error_data, status=status.HTTP_400_BAD_REQUEST)
225225
else:
226-
return Response(serializer.errors)
226+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
227227
except stripe.StripeError as e:
228228
error_data = {u'error': smart_str(e) or u'Unknown error'}
229229
return Response(error_data, status=status.HTTP_400_BAD_REQUEST)

0 commit comments

Comments
 (0)