diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 0fa7e81b..7c2b2aee 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -1,28 +1,26 @@ -from datetime import datetime - -from django import forms -from django.conf import settings -from django.contrib import messages -from django.core.exceptions import ValidationError -from django.core.mail import EmailMessage -from django.core.urlresolvers import reverse -from django.http import HttpResponseRedirect -from django.shortcuts import redirect -from django.shortcuts import render -from django.utils.translation import ugettext_lazy as _ -from django.views.decorators.cache import cache_control from django.views.generic import FormView, CreateView, TemplateView, DetailView - +from django.http import HttpResponseRedirect +from .forms import BetaAccessForm +from .models import BetaAccess, BetaAccessVMType, BetaAccessVM, VMTemplate +from django.contrib import messages +from django.core.urlresolvers import reverse +from django.core.mail import EmailMessage +from utils.mailer import BaseEmail +from django.shortcuts import render +from django.shortcuts import redirect +from django import forms +from django.core.exceptions import ValidationError +from django.views.decorators.cache import cache_control +from django.conf import settings +from django.utils.translation import ugettext_lazy as _ +from utils.forms import BillingAddressForm, UserBillingAddressForm +from utils.models import BillingAddress from hosting.models import HostingOrder, HostingBill +from utils.stripe_utils import StripeUtils +from datetime import datetime from membership.models import CustomUser, StripeCustomer from opennebula_api.models import OpenNebulaManager from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer, VMTemplateSerializer -from utils.forms import BillingAddressForm, UserBillingAddressForm -from utils.mailer import BaseEmail -from utils.models import BillingAddress -from utils.stripe_utils import StripeUtils -from .forms import BetaAccessForm -from .models import BetaAccess, BetaAccessVMType, BetaAccessVM, VMTemplate class LandingProgramView(TemplateView): @@ -440,6 +438,11 @@ class OrderConfirmationView(DetailView): stripe_utils = StripeUtils() 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'): + msg = card_details.get('error') + messages.add_message(self.request, messages.ERROR, msg, extra_tags='failed_payment') + return HttpResponseRedirect(reverse('datacenterlight:payment') + '#payment_error') + context = { 'site_url': reverse('datacenterlight:index'), 'cc_last4': card_details.get('response_object').get('last4'), diff --git a/hosting/static/hosting/css/landing-page.css b/hosting/static/hosting/css/landing-page.css index d372a896..b2d673d7 100644 --- a/hosting/static/hosting/css/landing-page.css +++ b/hosting/static/hosting/css/landing-page.css @@ -557,6 +557,10 @@ a.unlink:hover { border-radius: 3px; padding: 5px; } +.card-warning-error { + border: 1px solid #EB4D5C; + color: #EB4D5C; +} .card-warning-addtional-margin { margin-top: 15px; diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index 237dffd1..7bf84645 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -59,7 +59,6 @@ {% csrf_token %} {% bootstrap_field field show_label=False type='fields'%} {% endfor %} - {% bootstrap_form_errors form type='non_fields'%}
- {% blocktrans %} - You are not making any payment yet. After submitting your card - information, you will be taken to the Confirm Order Page. - {% endblocktrans %} -
-+ {% blocktrans %} + You are not making any payment yet. After submitting your card + information, you will be taken to the Confirm Order Page. + {% endblocktrans %} +
+ {% endif %} +{{ message|safe }}
++ {{ error|escape }} +
+ {% endfor %} +- {% blocktrans %} - You are not making any payment yet. After submitting your card - information, you will be taken to the Confirm Order Page. - {% endblocktrans %} -
+ {% if not messages and not form.non_field_errors %} ++ {% blocktrans %} + You are not making any payment yet. After submitting your card + information, you will be taken to the Confirm Order Page. + {% endblocktrans %} +
+ {% endif %} +{{ message|safe }}
++ {{ error|escape }} +
+ {% endfor %} +- {% bootstrap_alert paymentError alert_type='danger' %} -
-