merged master
This commit is contained in:
commit
6802e2fdbc
26 changed files with 294 additions and 395 deletions
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-09-28 18:36+0530\n"
|
||||
"POT-Creation-Date: 2017-10-03 18:54+0530\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -374,24 +374,6 @@ msgstr "Weiter"
|
|||
msgid "Enter your credit card number"
|
||||
msgstr "Deine Kreditkartennummer"
|
||||
|
||||
msgid "Confirm Order"
|
||||
msgstr "Bestellung Bestätigen"
|
||||
|
||||
msgid "Date"
|
||||
msgstr "Datum"
|
||||
|
||||
msgid "Billed To:"
|
||||
msgstr "Rechnungsadresse"
|
||||
|
||||
msgid "Payment Method:"
|
||||
msgstr "Bezahlmethode"
|
||||
|
||||
msgid "ending in"
|
||||
msgstr "endend in"
|
||||
|
||||
msgid "Order summary"
|
||||
msgstr "Bestellungsübersicht"
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"By clicking \"Place order\" this plan will charge your credit card account "
|
||||
|
|
@ -403,21 +385,6 @@ msgstr ""
|
|||
msgid "Place order"
|
||||
msgstr "Bestellen"
|
||||
|
||||
msgid "Processing..."
|
||||
msgstr "Abarbeitung..."
|
||||
|
||||
msgid "Hold tight, we are processing your request"
|
||||
msgstr "Bitte warten - wir verbeiten Deine Anfrage gerade"
|
||||
|
||||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
msgid "Some problem encountered. Please try again later."
|
||||
msgstr "Ein Problem ist aufgetreten. Bitte versuche es später noch einmal."
|
||||
|
||||
msgid "Thank you for order! Our team will contact you via email"
|
||||
msgstr ""
|
||||
"Vielen Dank für die Bestellung. Unser Team setzt sich sobald wie möglich mit "
|
||||
|
|
@ -511,6 +478,9 @@ msgstr "Ungültige RAM-Grösse"
|
|||
msgid "Invalid storage size"
|
||||
msgstr "Ungültige Speicher-Grösse"
|
||||
|
||||
msgid "Confirm Order"
|
||||
msgstr "Bestellung Bestätigen"
|
||||
|
||||
msgid "Error."
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -518,6 +488,8 @@ msgid ""
|
|||
"There was a payment related error. On close of this popup, you will be "
|
||||
"redirected back to the payment page."
|
||||
msgstr ""
|
||||
"Es ist ein Fehler bei der Zahlung betreten. Du wirst nach dem Schliessen vom "
|
||||
"Popup zur Bezahlseite weitergeleitet."
|
||||
|
||||
msgid "Thank you for the order."
|
||||
msgstr "Danke für Deine Bestellung."
|
||||
|
|
@ -529,6 +501,30 @@ msgstr ""
|
|||
"Deine VM ist gleich bereit. Wir senden Dir eine Bestätigungsemail, sobald Du "
|
||||
"auf sie zugreifen kannst."
|
||||
|
||||
#~ msgid "Processing..."
|
||||
#~ msgstr "Abarbeitung..."
|
||||
|
||||
#~ msgid "Hold tight, we are processing your request"
|
||||
#~ msgstr "Bitte warten - wir verbeiten Deine Anfrage gerade"
|
||||
|
||||
#~ msgid "Some problem encountered. Please try again later."
|
||||
#~ msgstr "Ein Problem ist aufgetreten. Bitte versuche es später noch einmal."
|
||||
|
||||
#~ msgid "Date"
|
||||
#~ msgstr "Datum"
|
||||
|
||||
#~ msgid "Billed To:"
|
||||
#~ msgstr "Rechnungsadresse"
|
||||
|
||||
#~ msgid "Payment Method:"
|
||||
#~ msgstr "Bezahlmethode"
|
||||
|
||||
#~ msgid "ending in"
|
||||
#~ msgstr "endend in"
|
||||
|
||||
#~ msgid "Order summary"
|
||||
#~ msgstr "Bestellungsübersicht"
|
||||
|
||||
#~ msgid "We are cutting down the costs significantly!"
|
||||
#~ msgstr "Wir sorgen dafür, dass die Kosten für Dich signifikant abnehmen"
|
||||
|
||||
|
|
|
|||
|
|
@ -1501,6 +1501,8 @@ tech-sub-sec h2 {
|
|||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
letter-spacing: 2px;
|
||||
line-height: 24px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.content-section-a {
|
||||
|
|
|
|||
|
|
@ -51,15 +51,20 @@ def retry_task(task, exception=None):
|
|||
@app.task(bind=True, max_retries=settings.CELERY_MAX_RETRIES)
|
||||
def create_vm_task(self, vm_template_id, user, specs, template,
|
||||
stripe_customer_id, billing_address_data,
|
||||
billing_address_id,
|
||||
charge, cc_details):
|
||||
stripe_subscription_id, cc_details):
|
||||
logger.debug(
|
||||
"Running create_vm_task on {}".format(current_task.request.hostname))
|
||||
vm_id = None
|
||||
try:
|
||||
final_price = specs.get('price')
|
||||
billing_address = BillingAddress.objects.filter(
|
||||
id=billing_address_id).first()
|
||||
billing_address = BillingAddress(
|
||||
cardholder_name=billing_address_data['cardholder_name'],
|
||||
street_address=billing_address_data['street_address'],
|
||||
city=billing_address_data['city'],
|
||||
postal_code=billing_address_data['postal_code'],
|
||||
country=billing_address_data['country']
|
||||
)
|
||||
billing_address.save()
|
||||
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
||||
|
||||
if 'pass' in user:
|
||||
|
|
@ -112,8 +117,7 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
billing_address_user_form.save()
|
||||
|
||||
# Associate an order with a stripe subscription
|
||||
charge_object = DictDotLookup(charge)
|
||||
order.set_subscription_id(charge_object, cc_details)
|
||||
order.set_subscription_id(stripe_subscription_id, cc_details)
|
||||
|
||||
# If the Stripe payment succeeds, set order status approved
|
||||
order.set_approved()
|
||||
|
|
@ -185,7 +189,8 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
public_keys]
|
||||
if len(keys) > 0:
|
||||
logger.debug(
|
||||
"Calling configure on {host} for {num_keys} keys".format(
|
||||
"Calling configure on {host} for "
|
||||
"{num_keys} keys".format(
|
||||
host=new_host, num_keys=len(keys)))
|
||||
# Let's delay the task by 75 seconds to be sure
|
||||
# that we run the cdist configure after the host
|
||||
|
|
@ -214,32 +219,3 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
return
|
||||
|
||||
return vm_id
|
||||
|
||||
|
||||
class DictDotLookup(object):
|
||||
"""
|
||||
Creates objects that behave much like a dictionaries, but allow nested
|
||||
key access using object '.' (dot) lookups.
|
||||
"""
|
||||
|
||||
def __init__(self, d):
|
||||
for k in d:
|
||||
if isinstance(d[k], dict):
|
||||
self.__dict__[k] = DictDotLookup(d[k])
|
||||
elif isinstance(d[k], (list, tuple)):
|
||||
l = []
|
||||
for v in d[k]:
|
||||
if isinstance(v, dict):
|
||||
l.append(DictDotLookup(v))
|
||||
else:
|
||||
l.append(v)
|
||||
self.__dict__[k] = l
|
||||
else:
|
||||
self.__dict__[k] = d[k]
|
||||
|
||||
def __getitem__(self, name):
|
||||
if name in self.__dict__:
|
||||
return self.__dict__[name]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.__dict__.keys())
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<hr class="intro-divider">
|
||||
<ul class="list-inline intro-social-buttons">
|
||||
<li>
|
||||
<a class="btn btn-default btn-lg btn-transparent url" href="#how"><i class="#Services"></i> <span class="network-name">{% trans "Highlights" %}</span></a>
|
||||
<a class="btn btn-default btn-lg btn-transparent url" href="#how"><span class="network-name">{% trans "Highlights" %}</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-lg page-scroll url" href="#price"><span class="network-name">{% trans "I want it!" %}</span></a>
|
||||
|
|
|
|||
|
|
@ -1,143 +1,24 @@
|
|||
{% extends "hosting/base_short.html" %}
|
||||
{% load staticfiles bootstrap3 %}
|
||||
{% extends "hosting/order_detail.html" %}
|
||||
{% load i18n %}
|
||||
{% load custom_tags %}
|
||||
|
||||
{% block navbar %}
|
||||
{% include "datacenterlight/includes/_navbar.html" %}
|
||||
{% endblock navbar %}
|
||||
|
||||
{% block content %}
|
||||
{% block submit_btn %}
|
||||
<form id="virtual_machine_create_form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<div class="dcl-place-order-text">{% blocktrans with vm_price=request.session.specs.price %}By clicking "Place order" this plan will charge your credit card account with the fee of {{ vm_price }}CHF/month{% endblocktrans %}.</div>
|
||||
</div>
|
||||
<div class="col-sm-4 order-confirm-btn text-right">
|
||||
<button class="btn choice-btn" id="btn-create-vm"
|
||||
data-toggle="modal" data-target="#createvm-modal">
|
||||
{% trans "Place order" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock submit_btn %}
|
||||
|
||||
<div class="order-detail-container">
|
||||
{% if messages %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-8 col-md-offset-2">
|
||||
<br/>
|
||||
<div class="alert alert-warning">
|
||||
{% for message in messages %}
|
||||
<span>{{ message }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if not error %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-8 col-md-offset-2">
|
||||
<div class="invoice-title">
|
||||
<h2>{% trans "Confirm Order"%}</h2>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6 pull-right order-confirm-date">
|
||||
<address>
|
||||
<strong>{% trans "Date"%}:</strong><br>
|
||||
<span id="order-created_at">{% now "Y-m-d H:i" %}</span><br><br>
|
||||
</address>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<address>
|
||||
<h3><b>{% trans "Billed To:"%}</b></h3>
|
||||
{% with billing_address_data as billing_address %}
|
||||
{{billing_address.cardholder_name}}<br> {{billing_address.street_address}}, {{billing_address.postal_code}}<br>
|
||||
{{billing_address.city}}, {{billing_address.country}}.
|
||||
{% endwith %}
|
||||
</address>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<address>
|
||||
<strong>{% trans "Payment Method:"%}</strong><br>
|
||||
{{cc_brand}} {% trans "ending in" %} **** {{cc_last4}}<br>
|
||||
{{request.session.user.email}}
|
||||
</address>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<h3><b>{% trans "Order summary"%}</b></h3>
|
||||
<hr>
|
||||
<div class="content">
|
||||
{% with request.session.specs as vm %}
|
||||
<p><b>{% trans "Cores"%}</b> <span class="pull-right">{{vm.cpu}}</span></p>
|
||||
<hr>
|
||||
<p><b>{% trans "Memory"%}</b> <span class="pull-right">{{vm.memory}} GB</span></p>
|
||||
<hr>
|
||||
<p><b>{% trans "Disk space"%}</b> <span class="pull-right">{{vm.disk_size}} GB</span></p>
|
||||
<hr>
|
||||
<p><b>{% trans "Configuration"%}</b> <span class="pull-right">{{request.session.template.name}}</span></p>
|
||||
<hr>
|
||||
<h4>{% trans "Total"%}<p class="pull-right"><b>{{vm.price}} CHF</b><span class="dcl-price-month"> /{% trans "Month" %}</span></p></h4>
|
||||
{% endwith %}
|
||||
</div>
|
||||
<br/>
|
||||
<form method="post" id="virtual_machine_create_form">
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<p class="dcl-place-order-text">{% blocktrans with vm_price=request.session.specs.price %}By clicking "Place order" this plan will charge your credit card account with the fee of {{ vm_price }}CHF/month{% endblocktrans %}.</p>
|
||||
</div>
|
||||
<div class="col-sm-4 content">
|
||||
<button class="btn btn-info pull-right"
|
||||
id="btn-create-vm"
|
||||
data-href="{% url 'hosting:order-confirmation' %}"
|
||||
data-toggle="modal"
|
||||
data-target="#createvm-modal">
|
||||
{% trans "Place order"%}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<!-- Create VM Modal -->
|
||||
<div class="modal fade" id="createvm-modal" tabindex="-1" role="dialog"
|
||||
aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close hidden" data-dismiss="modal"
|
||||
aria-label="create-vm-close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="modal-icon">
|
||||
<i class="fa fa-cog fa-spin fa-3x fa-fw"></i>
|
||||
<span class="sr-only">{% trans "Processing..." %}</span>
|
||||
</div>
|
||||
<h4 class="modal-title" id="createvm-modal-title">
|
||||
</h4>
|
||||
<div class="modal-text" id="createvm-modal-body">
|
||||
{% trans "Hold tight, we are processing your request" %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a id="createvm-modal-done-btn" class="btn btn-success btn-ok btn-wide hide" href="">{% trans "OK" %}</a>
|
||||
<button id="createvm-modal-close-btn" type="button" class="btn btn-danger btn-ok btn-wide hide" data-dismiss="modal" aria-label="create-vm-close">{% trans "Close" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- / Create VM Modal -->
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
{% trans "Some problem encountered. Please try again later." as err_msg %}
|
||||
var create_vm_error_message = '{{err_msg|safe}}.';
|
||||
|
||||
window.onload = function () {
|
||||
var locale_date = moment.utc(document.getElementById("order-created_at").textContent,'YYYY-MM-DD HH:mm').toDate();
|
||||
locale_date = moment(locale_date).format("YYYY-MM-DD h:mm:ss a");
|
||||
document.getElementById('order-created_at').innerHTML = locale_date;
|
||||
};
|
||||
|
||||
</script>
|
||||
{%endblock%}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from datacenterlight.tasks import create_vm_task
|
|||
from membership.models import StripeCustomer
|
||||
from opennebula_api.serializers import VMTemplateSerializer
|
||||
from utils.hosting_utils import get_vm_price
|
||||
from utils.models import BillingAddress
|
||||
from utils.stripe_utils import StripeUtils
|
||||
|
||||
|
||||
|
|
@ -75,21 +74,12 @@ class CeleryTaskTestCase(TestCase):
|
|||
stripe_customer.stripe_id,
|
||||
self.token)
|
||||
card_details_dict = card_details.get('response_object')
|
||||
billing_address = BillingAddress(
|
||||
cardholder_name=self.customer_name,
|
||||
postal_code='1232',
|
||||
country='CH',
|
||||
street_address='Monty\'s Street',
|
||||
city='Hollywood')
|
||||
billing_address.save()
|
||||
billing_address_data = {'cardholder_name': self.customer_name,
|
||||
'postal_code': '1231',
|
||||
'country': 'CH',
|
||||
'token': self.token,
|
||||
'street_address': 'Monty\'s Street',
|
||||
'city': 'Hollywood'}
|
||||
|
||||
billing_address_id = billing_address.id
|
||||
vm_template_id = template_data.get('id', 1)
|
||||
|
||||
cpu = specs.get('cpu')
|
||||
|
|
@ -125,8 +115,7 @@ class CeleryTaskTestCase(TestCase):
|
|||
template_data,
|
||||
stripe_customer.id,
|
||||
billing_address_data,
|
||||
billing_address_id,
|
||||
stripe_subscription_obj,
|
||||
stripe_subscription_obj.id,
|
||||
card_details_dict)
|
||||
new_vm_id = 0
|
||||
res = None
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from hosting.forms import HostingUserLoginForm
|
|||
from membership.models import CustomUser, StripeCustomer
|
||||
from opennebula_api.serializers import VMTemplateSerializer
|
||||
from utils.forms import (
|
||||
BillingAddressForm, BillingAddressFormSignup, UserBillingAddressForm
|
||||
BillingAddressForm, BillingAddressFormSignup
|
||||
)
|
||||
from utils.hosting_utils import get_vm_price
|
||||
from utils.mailer import BaseEmail
|
||||
|
|
@ -348,6 +348,11 @@ class PaymentOrderView(FormView):
|
|||
form_kwargs.update({
|
||||
'instance': self.request.user.billing_addresses.first()
|
||||
})
|
||||
if 'billing_address_data' in self.request.session:
|
||||
billing_address_data = self.request.session['billing_address_data']
|
||||
form_kwargs.update({
|
||||
'initial': billing_address_data
|
||||
})
|
||||
return form_kwargs
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
|
@ -379,14 +384,40 @@ class PaymentOrderView(FormView):
|
|||
email=this_user.get('email'),
|
||||
token=token)
|
||||
else:
|
||||
user_email = form.cleaned_data.get('email')
|
||||
user_name = form.cleaned_data.get('name')
|
||||
this_user = {
|
||||
'email': form.cleaned_data.get('email'),
|
||||
'name': form.cleaned_data.get('name')
|
||||
'email': user_email,
|
||||
'name': user_name
|
||||
}
|
||||
customer = StripeCustomer.create_stripe_api_customer(
|
||||
email=this_user.get('email'),
|
||||
token=token,
|
||||
customer_name=form.cleaned_data.get('name'))
|
||||
try:
|
||||
custom_user = CustomUser.objects.get(email=user_email)
|
||||
customer = StripeCustomer.objects.filter(
|
||||
user_id=custom_user.id).first()
|
||||
if customer is None:
|
||||
logger.debug(
|
||||
("User {email} is already registered with us."
|
||||
"But, StripeCustomer does not exist for {email}."
|
||||
"Hence, creating a new StripeCustomer.").format(
|
||||
email=user_email
|
||||
)
|
||||
)
|
||||
customer = StripeCustomer.create_stripe_api_customer(
|
||||
email=user_email,
|
||||
token=token,
|
||||
customer_name=user_name)
|
||||
except CustomUser.DoesNotExist:
|
||||
logger.debug(
|
||||
("StripeCustomer does not exist for {email}."
|
||||
"Hence, creating a new StripeCustomer.").format(
|
||||
email=user_email
|
||||
)
|
||||
)
|
||||
customer = StripeCustomer.create_stripe_api_customer(
|
||||
email=user_email,
|
||||
token=token,
|
||||
customer_name=user_name)
|
||||
|
||||
request.session['billing_address_data'] = form.cleaned_data
|
||||
request.session['user'] = this_user
|
||||
# Get or create stripe customer
|
||||
|
|
@ -395,8 +426,10 @@ class PaymentOrderView(FormView):
|
|||
return self.render_to_response(
|
||||
self.get_context_data(form=form))
|
||||
request.session['token'] = token
|
||||
request.session[
|
||||
'customer'] = customer.id if request.user.is_authenticated() else customer
|
||||
if type(customer) is StripeCustomer:
|
||||
request.session['customer'] = customer.stripe_id
|
||||
else:
|
||||
request.session['customer'] = customer
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:order_confirmation'))
|
||||
else:
|
||||
|
|
@ -415,14 +448,7 @@ class OrderConfirmationView(DetailView):
|
|||
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
||||
if 'token' not in request.session:
|
||||
return HttpResponseRedirect(reverse('datacenterlight:payment'))
|
||||
stripe_customer_id = request.session.get('customer')
|
||||
if request.user.is_authenticated():
|
||||
customer = StripeCustomer.objects.filter(
|
||||
id=stripe_customer_id).first()
|
||||
stripe_api_cus_id = customer.stripe_id
|
||||
else:
|
||||
stripe_api_cus_id = stripe_customer_id
|
||||
|
||||
stripe_api_cus_id = request.session.get('customer')
|
||||
stripe_utils = StripeUtils()
|
||||
card_details = stripe_utils.get_card_details(stripe_api_cus_id,
|
||||
request.session.get(
|
||||
|
|
@ -437,6 +463,8 @@ class OrderConfirmationView(DetailView):
|
|||
'site_url': reverse('datacenterlight:index'),
|
||||
'cc_last4': card_details.get('response_object').get('last4'),
|
||||
'cc_brand': card_details.get('response_object').get('brand'),
|
||||
'vm': request.session.get('specs'),
|
||||
'page_header_text': _('Confirm Order'),
|
||||
'billing_address_data': request.session.get('billing_address_data')
|
||||
}
|
||||
return render(request, self.template_name, context)
|
||||
|
|
@ -445,15 +473,8 @@ class OrderConfirmationView(DetailView):
|
|||
template = request.session.get('template')
|
||||
specs = request.session.get('specs')
|
||||
user = request.session.get('user')
|
||||
stripe_customer_id = request.session.get('customer')
|
||||
if request.user.is_authenticated():
|
||||
customer = StripeCustomer.objects.filter(
|
||||
id=stripe_customer_id).first()
|
||||
stripe_api_cus_id = customer.stripe_id
|
||||
else:
|
||||
stripe_api_cus_id = stripe_customer_id
|
||||
stripe_api_cus_id = request.session.get('customer')
|
||||
vm_template_id = template.get('id', 1)
|
||||
|
||||
stripe_utils = StripeUtils()
|
||||
card_details = stripe_utils.get_card_details(stripe_api_cus_id,
|
||||
request.session.get(
|
||||
|
|
@ -498,8 +519,8 @@ class OrderConfirmationView(DetailView):
|
|||
'response_object').stripe_plan_id}])
|
||||
stripe_subscription_obj = subscription_result.get('response_object')
|
||||
# Check if the subscription was approved and is active
|
||||
if stripe_subscription_obj is None or \
|
||||
stripe_subscription_obj.status != 'active':
|
||||
if (stripe_subscription_obj is None
|
||||
or stripe_subscription_obj.status != 'active'):
|
||||
msg = subscription_result.get('error')
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='failed_payment')
|
||||
|
|
@ -546,10 +567,10 @@ class OrderConfirmationView(DetailView):
|
|||
password=password)
|
||||
login(request, new_user)
|
||||
else:
|
||||
customer = StripeCustomer.objects.filter(
|
||||
id=stripe_customer_id).first()
|
||||
custom_user = customer.user
|
||||
stripe_customer_id = customer.id
|
||||
# We assume that if the user is here, his/her StripeCustomer
|
||||
# object already exists
|
||||
stripe_customer_id = request.user.stripecustomer.id
|
||||
custom_user = request.user
|
||||
|
||||
# Save billing address
|
||||
billing_address_data = request.session.get('billing_address_data')
|
||||
|
|
@ -557,12 +578,6 @@ class OrderConfirmationView(DetailView):
|
|||
billing_address_data.update({
|
||||
'user': custom_user.id
|
||||
})
|
||||
billing_address_user_form = UserBillingAddressForm(
|
||||
instance=custom_user.billing_addresses.first(),
|
||||
data=billing_address_data)
|
||||
billing_address = billing_address_user_form.save()
|
||||
billing_address_id = billing_address.id
|
||||
logger.debug("billing address id = {}".format(billing_address_id))
|
||||
user = {
|
||||
'name': custom_user.name,
|
||||
'email': custom_user.email,
|
||||
|
|
@ -574,8 +589,7 @@ class OrderConfirmationView(DetailView):
|
|||
|
||||
create_vm_task.delay(vm_template_id, user, specs, template,
|
||||
stripe_customer_id, billing_address_data,
|
||||
billing_address_id,
|
||||
stripe_subscription_obj, card_details_dict)
|
||||
stripe_subscription_obj.id, card_details_dict)
|
||||
for session_var in ['specs', 'template', 'billing_address',
|
||||
'billing_address_data',
|
||||
'token', 'customer']:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue