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'):
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')

View file

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

View file

@ -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')