From b88dfa4bfe63cd5ff35e8d34d72f3588df367d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Thu, 5 Mar 2020 11:28:43 +0100 Subject: [PATCH] Fix payment update updates --- uncloud/uncloud_pay/serializers.py | 5 +++++ uncloud/uncloud_pay/views.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/uncloud/uncloud_pay/serializers.py b/uncloud/uncloud_pay/serializers.py index bfbe0da..46ceab2 100644 --- a/uncloud/uncloud_pay/serializers.py +++ b/uncloud/uncloud_pay/serializers.py @@ -31,6 +31,11 @@ class PaymentMethodSerializer(serializers.ModelSerializer): model = PaymentMethod fields = ['uuid', 'source', 'description', 'primary', 'stripe_card_last4', 'active'] +class UpdatePaymentMethodSerializer(serializers.ModelSerializer): + class Meta: + model = PaymentMethod + fields = ['description', 'primary'] + class ChargePaymentMethodSerializer(serializers.Serializer): amount = serializers.DecimalField(max_digits=10, decimal_places=2) diff --git a/uncloud/uncloud_pay/views.py b/uncloud/uncloud_pay/views.py index 08e94a0..6b54214 100644 --- a/uncloud/uncloud_pay/views.py +++ b/uncloud/uncloud_pay/views.py @@ -41,6 +41,8 @@ class PaymentMethodViewSet(viewsets.ModelViewSet): def get_serializer_class(self): if self.action == 'create': return CreatePaymentMethodSerializer + elif self.action == 'update': + return UpdatePaymentMethodSerializer elif self.action == 'charge': return ChargePaymentMethodSerializer else: