Send VAT to stripe only when it's defined
@@ -50,12 +50,17 @@ class GoldSubscriptionForm(StripeResourceMixin, StripeModelForm):
self.instance.business_vat_id = self.cleaned_data['business_vat_id']
def get_customer_kwargs(self):
- return {
+ data = {
'description': self.customer.get_full_name() or self.customer.username,
'email': self.customer.email,
'id': self.instance.stripe_id or None,
- 'business_vat_id': self.cleaned_data['business_vat_id'] or None,
}
+ business_vat_id = self.cleaned_data.get('business_vat_id')
+ if business_vat_id:
+ data.update({
+ 'business_vat_id': self.cleaned_data['business_vat_id'],
+ })
+ return data
def get_subscription(self):
customer = self.get_customer()
