Changed payment error place, changed message source to Stripe errors handler

This commit is contained in:
Siarhei Puhach 2017-08-04 11:01:32 +03:00
parent 34acf2310b
commit 29fb771afb
2 changed files with 18 additions and 16 deletions

View file

@ -427,7 +427,7 @@ class OrderConfirmationView(DetailView):
stripe_utils = StripeUtils() stripe_utils = StripeUtils()
card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token')) card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token'))
if not card_details.get('response_object') and not card_details.get('paid'): if not card_details.get('response_object') and not card_details.get('paid'):
msg = _('Currently its not possible to make payments. Please try later.') msg = card_details.get('error')
messages.add_message(self.request, messages.ERROR, msg, extra_tags='failed_payment') messages.add_message(self.request, messages.ERROR, msg, extra_tags='failed_payment')
return HttpResponseRedirect(reverse('datacenterlight:payment')) return HttpResponseRedirect(reverse('datacenterlight:payment'))
context = { context = {

View file

@ -49,15 +49,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="help-block with-errors">
{% for message in messages %}
{% if 'failed_payment' in message.tags %}
<ul class="list-unstyled"><li>
<p class="alert alert-danger">{{ message|safe }}</p>
</li></ul>
{% endif %}
{% endfor %}
</div>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 dcl-billing-sec"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 dcl-billing-sec">
<div class="col-xs-12 col-sm-5 col-md-6 billing dcl-billing"> <div class="col-xs-12 col-sm-5 col-md-6 billing dcl-billing">
@ -139,12 +130,23 @@
<div id="card-errors" role="alert"></div> <div id="card-errors" role="alert"></div>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<p class="card-warning-content"> {% if not messages %}
{% blocktrans %} <p class="card-warning-content">
You are not making any payment yet. After submitting your card {% blocktrans %}
information, you will be taken to the Confirm Order Page. You are not making any payment yet. After submitting your card
{% endblocktrans %} information, you will be taken to the Confirm Order Page.
</p> {% endblocktrans %}
</p>
{% endif %}
<div class="help-block with-errors">
{% for message in messages %}
{% if 'failed_payment' in message.tags %}
<ul class="list-unstyled"><li>
<p class="alert alert-danger">{{ message|safe }}</p>
</li></ul>
{% endif %}
{% endfor %}
</div>
</div> </div>
<div class="col-xs-12"> <div class="col-xs-12">
<div class="col-xs-6 pull-right"> <div class="col-xs-6 pull-right">