Payment error was unified

This commit is contained in:
Siarhei Puhach 2017-08-07 17:23:58 +03:00
parent a71ccbc566
commit 72ddfd96ab
3 changed files with 8 additions and 7 deletions

View file

@ -441,7 +441,7 @@ class OrderConfirmationView(DetailView):
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 = card_details.get('error') 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') + '#dcl_payment_error') return HttpResponseRedirect(reverse('datacenterlight:payment') + '#payment_error')
context = { context = {
'site_url': reverse('datacenterlight:index'), 'site_url': reverse('datacenterlight:index'),
@ -472,7 +472,7 @@ class OrderConfirmationView(DetailView):
if not charge_response.get('response_object') and not charge_response.get('paid'): if not charge_response.get('response_object') and not charge_response.get('paid'):
msg = charge_response.get('error') msg = charge_response.get('error')
messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error') messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error')
return HttpResponseRedirect(reverse('datacenterlight:payment') + '#dcl_payment_error') return HttpResponseRedirect(reverse('datacenterlight:payment') + '#payment_error')
charge = charge_response.get('response_object') charge = charge_response.get('response_object')

View file

@ -93,7 +93,7 @@
{% endblocktrans %} {% endblocktrans %}
</p> </p>
{% endif %} {% endif %}
<div id='hosting_payment_error'> <div id='payment_error'>
{% for message in messages %} {% for message in messages %}
{% if 'failed_payment' or 'make_charge_error' in message.tags %} {% if 'failed_payment' or 'make_charge_error' in message.tags %}
<ul class="list-unstyled"><li> <ul class="list-unstyled"><li>
@ -153,7 +153,7 @@
{% endblocktrans %} {% endblocktrans %}
</p> </p>
{% endif %} {% endif %}
<div id='dcl_payment_error'> <div id='payment_error'>
{% for message in messages %} {% for message in messages %}
{% if 'failed_payment' or 'make_charge_error' in message.tags %} {% if 'failed_payment' or 'make_charge_error' in message.tags %}
<ul class="list-unstyled"><li> <ul class="list-unstyled"><li>

View file

@ -547,8 +547,9 @@ class PaymentVMView(LoginRequiredMixin, FormView):
customer = StripeCustomer.get_or_create(email=owner.email, customer = StripeCustomer.get_or_create(email=owner.email,
token=token) token=token)
if not customer: if not customer:
form.add_error("__all__", "Invalid credit card") msg = _("Invalid credit card")
return self.render_to_response(self.get_context_data(form=form)) messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error')
return HttpResponseRedirect(reverse('hosting:payment') + '#payment_error')
# Create Billing Address # Create Billing Address
billing_address = form.save() billing_address = form.save()
@ -562,7 +563,7 @@ class PaymentVMView(LoginRequiredMixin, FormView):
if not charge_response.get('response_object') and not charge_response.get('paid'): if not charge_response.get('response_object') and not charge_response.get('paid'):
msg = charge_response.get('error') msg = charge_response.get('error')
messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error') messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error')
return HttpResponseRedirect(reverse('hosting:payment') + '#hosting_payment_error') return HttpResponseRedirect(reverse('hosting:payment') + '#payment_error')
charge = charge_response.get('response_object') charge = charge_response.get('response_object')