From 110459b38d238d721ee1b1dcfd77f838b9d84e5c Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 25 Dec 2019 22:27:14 +0530 Subject: [PATCH] Show vat error in payment page --- .../templates/datacenterlight/landing_payment.html | 9 +++++++++ datacenterlight/views.py | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/datacenterlight/templates/datacenterlight/landing_payment.html b/datacenterlight/templates/datacenterlight/landing_payment.html index 4e71eab9..66a0e63f 100644 --- a/datacenterlight/templates/datacenterlight/landing_payment.html +++ b/datacenterlight/templates/datacenterlight/landing_payment.html @@ -13,6 +13,15 @@
+
+ {% for message in messages %} + {% if 'vat_error' in message.tags %} +
    +
  • An error occurred while validating VAT number: {{ message|safe }}

  • +
+ {% endif %} + {% endfor %} +
diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 7110e7a8..3274c480 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -548,7 +548,13 @@ class PaymentOrderView(FormView): ) if 'response_object' in validate_result: - raise forms.ValidationError(validate_result["error"]) + 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"]