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: