From 72ddfd96ab0fad277a1471ba3c723c6c5ff4fc45 Mon Sep 17 00:00:00 2001 From: Siarhei Puhach Date: Mon, 7 Aug 2017 17:23:58 +0300 Subject: [PATCH] Payment error was unified --- datacenterlight/views.py | 4 ++-- hosting/templates/hosting/payment.html | 4 ++-- hosting/views.py | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index b20b212f..929b0833 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -441,7 +441,7 @@ class OrderConfirmationView(DetailView): if not card_details.get('response_object') and not card_details.get('paid'): msg = card_details.get('error') 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 = { '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'): msg = charge_response.get('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') diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index 4c4ffa62..7bf84645 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -93,7 +93,7 @@ {% endblocktrans %}

{% endif %} -
+
{% for message in messages %} {% if 'failed_payment' or 'make_charge_error' in message.tags %}
  • @@ -153,7 +153,7 @@ {% endblocktrans %}

    {% endif %} -
    +
    {% for message in messages %} {% if 'failed_payment' or 'make_charge_error' in message.tags %}
    • diff --git a/hosting/views.py b/hosting/views.py index d1666b04..c5877ca2 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -547,8 +547,9 @@ class PaymentVMView(LoginRequiredMixin, FormView): customer = StripeCustomer.get_or_create(email=owner.email, token=token) if not customer: - form.add_error("__all__", "Invalid credit card") - return self.render_to_response(self.get_context_data(form=form)) + msg = _("Invalid credit card") + messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error') + return HttpResponseRedirect(reverse('hosting:payment') + '#payment_error') # Create Billing Address 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'): msg = charge_response.get('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')