Validate VAT number only if it is set

This commit is contained in:
PCoder 2019-12-25 22:40:57 +05:30
parent 3b654f1c49
commit b15ece7088

View file

@ -542,22 +542,24 @@ class PaymentOrderView(FormView):
else: else:
request.session['customer'] = customer request.session['customer'] = customer
validate_result = validate_vat_number( vat_number = address_form.cleaned_data.get('vat_number').strip()
stripe_customer_id=request.session['customer'], if vat_number:
vat_number=address_form.cleaned_data.get('vat_number') validate_result = validate_vat_number(
) stripe_customer_id=request.session['customer'],
vat_number=address_form.cleaned_data.get('vat_number')
if 'response_object' in validate_result:
messages.add_message(
request, messages.ERROR, validate_result["error"],
extra_tags='vat_error'
)
return HttpResponseRedirect(
reverse('datacenterlight:payment') + '#vat_error'
) )
request.session["vat_validation_status"] = validate_result["status"] if 'response_object' in validate_result:
request.session["vat_validated_on"] = validate_result["validated_on"] messages.add_message(
request, messages.ERROR, validate_result["error"],
extra_tags='vat_error'
)
return HttpResponseRedirect(
reverse('datacenterlight:payment') + '#vat_error'
)
request.session["vat_validation_status"] = validate_result["status"]
request.session["vat_validated_on"] = validate_result["validated_on"]
# For generic payment we take the user directly to confirmation # For generic payment we take the user directly to confirmation
if ('generic_payment_type' in request.session and if ('generic_payment_type' in request.session and