Fix duplicates in payment method creation
This commit is contained in:
parent
b10cae472e
commit
7bbc729b87
1 changed files with 3 additions and 3 deletions
|
@ -56,7 +56,6 @@ class PaymentMethodViewSet(viewsets.ModelViewSet):
|
||||||
def create(self, request):
|
def create(self, request):
|
||||||
serializer = self.get_serializer(data=request.data)
|
serializer = self.get_serializer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
payment_method = PaymentMethod.objects.create(owner=request.user, **serializer.validated_data)
|
|
||||||
|
|
||||||
if serializer.validated_data['source'] == "stripe":
|
if serializer.validated_data['source'] == "stripe":
|
||||||
# Retrieve Stripe customer ID for user.
|
# Retrieve Stripe customer ID for user.
|
||||||
|
@ -83,8 +82,9 @@ class PaymentMethodViewSet(viewsets.ModelViewSet):
|
||||||
payment_method.uuid)
|
payment_method.uuid)
|
||||||
stripe_registration_url = reverse('api-root', request=request) + path
|
stripe_registration_url = reverse('api-root', request=request) + path
|
||||||
return Response({'please_visit': stripe_registration_url})
|
return Response({'please_visit': stripe_registration_url})
|
||||||
|
else:
|
||||||
return Response(serializer.data)
|
serializer.save(owner=request.user, **serializer.validated_data)
|
||||||
|
return Response(serializer.data)
|
||||||
|
|
||||||
@action(detail=True, methods=['post'])
|
@action(detail=True, methods=['post'])
|
||||||
def charge(self, request, pk=None):
|
def charge(self, request, pk=None):
|
||||||
|
|
Loading…
Reference in a new issue