From 7d708cfbb685c655fdaaf0672e9df6cebb5fbde9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 May 2020 20:42:09 +0200 Subject: [PATCH] Fix empty vat number bug --- uncloud_django_based/uncloud/uncloud_pay/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/uncloud_django_based/uncloud/uncloud_pay/views.py b/uncloud_django_based/uncloud/uncloud_pay/views.py index 82b5787..59d310e 100644 --- a/uncloud_django_based/uncloud/uncloud_pay/views.py +++ b/uncloud_django_based/uncloud/uncloud_pay/views.py @@ -215,10 +215,11 @@ class BillingAddressViewSet(mixins.CreateModelMixin, # Validate VAT numbers. country = serializer.validated_data["country"] - vat_number = serializer.validated_data["vat_number"] # We ignore empty VAT numbers. - if vat_number != "": + if 'vat_number' in serializer.validated_data and serializer.validated_data["vat_number"] != "": + vat_number = serializer.validated_data["vat_number"] + if not validate_vat(country, vat_number): return Response( {'error': 'Malformed VAT number.'},