Show vat error in payment page

This commit is contained in:
PCoder 2019-12-25 22:27:14 +05:30
parent de0fe77779
commit 110459b38d
2 changed files with 16 additions and 1 deletions

View file

@ -13,6 +13,15 @@
<!-- Credit card form -->
<div class="dcl-order-container">
<div class="payment-container">
<div id='payment_error'>
{% for message in messages %}
{% if 'vat_error' in message.tags %}
<ul class="list-unstyled">
<li><p class="card-warning-content card-warning-error">An error occurred while validating VAT number: {{ message|safe }}</p></li>
</ul>
{% endif %}
{% endfor %}
</div>
<div class="dcl-payment-grid">
<div class="dcl-payment-box">
<div class="dcl-payment-section">

View file

@ -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"]