downgrade notifications
This commit is contained in:
@@ -107,7 +107,7 @@ def make_payment(rower,data):
|
|||||||
else:
|
else:
|
||||||
return 0,''
|
return 0,''
|
||||||
|
|
||||||
def update_subscription(rower,data):
|
def update_subscription(rower,data,method='up'):
|
||||||
planid = data['plan']
|
planid = data['plan']
|
||||||
plan = PaidPlan.objects.get(id=planid)
|
plan = PaidPlan.objects.get(id=planid)
|
||||||
nonce_from_the_client = data['payment_method_nonce']
|
nonce_from_the_client = data['payment_method_nonce']
|
||||||
@@ -148,11 +148,13 @@ def update_subscription(rower,data):
|
|||||||
l = rower.user.last_name,
|
l = rower.user.last_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if method == 'up':
|
||||||
|
transactions = result.subscription.transactions
|
||||||
|
|
||||||
transactions = result.subscription.transactions
|
if transactions:
|
||||||
|
amount = transactions[0].amount
|
||||||
if transactions:
|
else:
|
||||||
amount = transactions[0].amount
|
amount = 0
|
||||||
else:
|
else:
|
||||||
amount = 0
|
amount = 0
|
||||||
|
|
||||||
@@ -164,7 +166,8 @@ def update_subscription(rower,data):
|
|||||||
plan.paymenttype == 'recurring',
|
plan.paymenttype == 'recurring',
|
||||||
plan.price,
|
plan.price,
|
||||||
amount,
|
amount,
|
||||||
result.subscription.billing_period_end_date.strftime('%Y-%m-%d'))
|
result.subscription.billing_period_end_date.strftime('%Y-%m-%d'),
|
||||||
|
method)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -721,6 +721,7 @@ class PlanSelectForm(forms.Form):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
paymentprocessor = kwargs.pop('paymentprocessor',None)
|
paymentprocessor = kwargs.pop('paymentprocessor',None)
|
||||||
rower = kwargs.pop('rower',None)
|
rower = kwargs.pop('rower',None)
|
||||||
|
includeall = kwargs.pop('includeall',False)
|
||||||
super(PlanSelectForm, self).__init__(*args, **kwargs)
|
super(PlanSelectForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['plan'].empty_label = None
|
self.fields['plan'].empty_label = None
|
||||||
if paymentprocessor:
|
if paymentprocessor:
|
||||||
@@ -731,7 +732,7 @@ class PlanSelectForm(forms.Form):
|
|||||||
).order_by(
|
).order_by(
|
||||||
"price","clubsize","shortname"
|
"price","clubsize","shortname"
|
||||||
)
|
)
|
||||||
if rower:
|
if rower and not includeall:
|
||||||
try:
|
try:
|
||||||
amount = rower.paidplan.price
|
amount = rower.paidplan.price
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@@ -743,6 +744,7 @@ class PlanSelectForm(forms.Form):
|
|||||||
).order_by(
|
).order_by(
|
||||||
"price","clubsize","shortname"
|
"price","clubsize","shortname"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CourseSelectForm(forms.Form):
|
class CourseSelectForm(forms.Form):
|
||||||
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())
|
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())
|
||||||
|
|||||||
@@ -797,14 +797,13 @@ def handle_send_email_failed_cancel(
|
|||||||
@app.task
|
@app.task
|
||||||
def handle_send_email_subscription_update(
|
def handle_send_email_subscription_update(
|
||||||
username, useremail, planname, recurring, price, amount,
|
username, useremail, planname, recurring, price, amount,
|
||||||
end_of_billing_period, **kwargs):
|
end_of_billing_period, method, **kwargs):
|
||||||
|
|
||||||
if 'debug' in kwargs:
|
if 'debug' in kwargs:
|
||||||
debug = kwargs['debug']
|
debug = kwargs['debug']
|
||||||
else:
|
else:
|
||||||
debug = True
|
debug = True
|
||||||
|
|
||||||
subject = "Rowsandall Payment Confirmation"
|
|
||||||
|
|
||||||
from_email = 'Rowsandall <admin@rowsandall.com>'
|
from_email = 'Rowsandall <admin@rowsandall.com>'
|
||||||
|
|
||||||
@@ -818,14 +817,23 @@ def handle_send_email_subscription_update(
|
|||||||
'end_of_billing_period': end_of_billing_period,
|
'end_of_billing_period': end_of_billing_period,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if method == 'down':
|
||||||
|
template_name = 'subscription_downgrade_email.html'
|
||||||
|
notification_template_name = 'subscription_downgrade_notification.html'
|
||||||
|
subject = "Rowsandall Change Confirmation"
|
||||||
|
else:
|
||||||
|
template_name = 'subscription_update_email.html'
|
||||||
|
notification_template_name = 'subscription_update_notification.html'
|
||||||
|
subject = "Rowsandall Payment Confirmation"
|
||||||
|
|
||||||
res = send_template_email(from_email,[useremail],
|
res = send_template_email(from_email,[useremail],
|
||||||
subject,
|
subject,
|
||||||
'subscription_update_email.html',
|
template_name,
|
||||||
d, **kwargs)
|
d, **kwargs)
|
||||||
|
|
||||||
res = send_template_email(from_email,['info@rowsandall.com'],
|
res = send_template_email(from_email,['info@rowsandall.com'],
|
||||||
'Subscription Update Notification',
|
'Subscription Update Notification',
|
||||||
'subscription_update_notification.html',
|
template_name,
|
||||||
d, **kwargs)
|
d, **kwargs)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
52
rowers/templates/downgrade.html
Normal file
52
rowers/templates/downgrade.html
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% block title %}Rowsandall Paid Membership{% endblock title %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h1>Downgrade</h1>
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_3">
|
||||||
|
<h2>Billing Details</h2>
|
||||||
|
<p>For tax reasons, we need your country of residence. You should
|
||||||
|
update this when it is incorrect.</p>
|
||||||
|
<table>
|
||||||
|
{{ billingaddressform.as_table }}
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
<li class="grid_3">
|
||||||
|
<h2>Choose your Plan</h2>
|
||||||
|
<table width="100%">
|
||||||
|
{{ planselectform.as_table }}
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>
|
||||||
|
Your downgrade will be effective immediately.
|
||||||
|
The price difference for the current billing cycle will
|
||||||
|
be credited to your next charge (prorated). For example,
|
||||||
|
when you downgrade from a 65€ plan to a 15€ plan
|
||||||
|
(50€ difference), in the 6th month of the 12 month
|
||||||
|
billing cycle, you will have a credit of 25€ which
|
||||||
|
will be used for the next billing cycles.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Looking for the <a href="/rowers/downgrade">downgrade</a> option?
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li class="grid_3">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="submit" value="Proceed">
|
||||||
|
You will be able to review your order before purchase.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_profile.html' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
26
rowers/templates/downgrade_completed.html
Normal file
26
rowers/templates/downgrade_completed.html
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% block title %}Rowsandall Paid Membership{% endblock title %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h1>Your Change was completed</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Thank you for changing to {{ user.rower.paidplan.name }}. You're all settled.
|
||||||
|
membership.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% if user.rower.paymenttype == 'recurring' %}
|
||||||
|
Your next payment will be automatically processed on {{ user.rower.planexpires }}
|
||||||
|
{% else %}
|
||||||
|
Your plan will end automatically on {{ user.rower.planexpires }}
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_profile.html' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
118
rowers/templates/downgradeconfirm.html
Normal file
118
rowers/templates/downgradeconfirm.html
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% block title %}Rowsandall Paid Membership{% endblock title %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h1>Confirm Your Changes</h1>
|
||||||
|
|
||||||
|
<h2>Order Overview</h2>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>
|
||||||
|
<table class="plantable shortpadded" width="80%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Plan</th><td>{{ plan.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Payment Type</th><td>{{ plan.paymenttype }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Billing Cycle</th><td>1 year</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total</th><td>€ {{ plan.price|currency }}
|
||||||
|
{% if plan.paymenttype == 'recurring' %}
|
||||||
|
/year
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<table class="plantable shortpadded" width="80%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Street Address</th><td>{{ user.rower.street_address }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>City</th><td>{{ user.rower.city }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Postal Code</th><td>{{ user.rower.postal_code }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Country</th><td>{{ user.rower.country }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>
|
||||||
|
<a href="/rowers/downgrade">Change Downgrade</a>
|
||||||
|
</li>
|
||||||
|
<li class="grid_4">
|
||||||
|
<form id="payment-form" method="post" action="/rowers/downgradecheckouts"
|
||||||
|
autocomplete="off">
|
||||||
|
<section>
|
||||||
|
<label for="amount">
|
||||||
|
<div class="input-wrapper amount-wrapper">
|
||||||
|
<input id="amount" name="amount" type="hidden" min="1" placeholder="Amount"
|
||||||
|
value="{{ plan.price }}" readonly>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<div class="bt-drop-in-wrapper">
|
||||||
|
<div id="bt-dropin"></div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<input type="hidden" id="nonce" name="payment_method_nonce" />
|
||||||
|
<input type="hidden" id="plan" name="plan" value="{{ plan.id }}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button type="submit" id="submit-button"><span>Downgrade to the € {{ plan.price|currency }} plan</span></button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_4">
|
||||||
|
<p>
|
||||||
|
Your downgrade will be effective immediately. You will not be charged.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<script src="https://js.braintreegateway.com/web/dropin/1.14.1/js/dropin.min.js"></script>
|
||||||
|
<script>
|
||||||
|
var form = document.querySelector('#payment-form');
|
||||||
|
var client_token = '{{ client_token }}';
|
||||||
|
braintree.dropin.create({
|
||||||
|
authorization: client_token,
|
||||||
|
container: '#bt-dropin',
|
||||||
|
paypal: {
|
||||||
|
flow: 'checkout'
|
||||||
|
}
|
||||||
|
}, function (createErr, instance) {
|
||||||
|
form.addEventListener('submit', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
instance.requestPaymentMethod(function (err, payload) {
|
||||||
|
if (err) {
|
||||||
|
console.log('Error', err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Add the nonce to the form and submit
|
||||||
|
document.querySelector('#nonce').value = payload.nonce;
|
||||||
|
form.submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_profile.html' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
62
rowers/templates/subscription_downgrade_email.html
Normal file
62
rowers/templates/subscription_downgrade_email.html
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Thank you. You have successfully changed your plan to "{{ planname }}".
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% if recurring %}
|
||||||
|
<p>
|
||||||
|
The subscription cost is €{{ price }} per year.
|
||||||
|
Your next charge is due on {{ end_of_billing_period }}. We will charge you automatically
|
||||||
|
on that date. Because you downgraded, you have a credit on your account which will be
|
||||||
|
used before charging your payment method.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The subscription will keep running until you change or stop it. At any point in time you
|
||||||
|
can change the automatically renewing subscription to a "one year only" subscription through
|
||||||
|
<a href="{{ siteurl}}/rowers/upgrade/">the upgrade page</a>. On this page, you can also
|
||||||
|
upgrade your subscription.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
The price of the subscription is €{{ price }}.
|
||||||
|
This one year subscription will automatically end on {{ end_of_billing_period }}. You can
|
||||||
|
renew your subscription after that. Because you downgraded, you have a credit on your
|
||||||
|
account which will be used for future subscriptions or upgrades.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
At any point in time, you can change your subscription to an automatically renewing subscription.
|
||||||
|
You can do this on <a href="{{ siteurl}}/rowers/upgrade/">the upgrade page</a>.
|
||||||
|
Here, you can also upgrade your subscription.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Upgrades in the middle of a billing cycle are charged pro-rated. For the current billing
|
||||||
|
cycle, you have only been charged for the price difference for the remaining fraction of the
|
||||||
|
billing cycle. If you downgraded to a lower cost subscription, the pro-rated difference will be
|
||||||
|
used as a credit, lowering the amount charged on the next billing cycle.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You can stop the subscription through
|
||||||
|
<a href="{{ siteurl }}/rowers/me/cancelsubscriptions">the subscription management page</a>. The
|
||||||
|
subscription will be stopped immediately without a refund.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Please contact our customer service by replying to this email if you have any further
|
||||||
|
questions regarding your subscription.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
26
rowers/templates/subscription_downgrade_notification.html
Normal file
26
rowers/templates/subscription_downgrade_notification.html
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>User <strong>{{ name }}</strong> has downgraded his subscription.</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
New plan: "{{ planname }}".
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% if recurring %}
|
||||||
|
<p>
|
||||||
|
The subscription cost is €{{ price }} per year.
|
||||||
|
The next charge is due on {{ end_of_billing_period }}. on that date.
|
||||||
|
</p>
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
The subscription cost is €{{ price }}. The subscription ends on {{ end_of_billing_period }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
@@ -440,14 +440,18 @@ urlpatterns = [
|
|||||||
url(r'^promembership', TemplateView.as_view(template_name='promembership.html'),name='promembership'),
|
url(r'^promembership', TemplateView.as_view(template_name='promembership.html'),name='promembership'),
|
||||||
url(r'^checkout/(?P<planid>\d+)$',views.payment_confirm_view),
|
url(r'^checkout/(?P<planid>\d+)$',views.payment_confirm_view),
|
||||||
url(r'^upgradecheckout/(?P<planid>\d+)$',views.upgrade_confirm_view),
|
url(r'^upgradecheckout/(?P<planid>\d+)$',views.upgrade_confirm_view),
|
||||||
|
url(r'^downgradecheckout/(?P<planid>\d+)$',views.downgrade_confirm_view),
|
||||||
url(r'^billing$',views.billing_view,name='billing'),
|
url(r'^billing$',views.billing_view,name='billing'),
|
||||||
url(r'^upgrade$',views.upgrade_view,name='upgrade'),
|
url(r'^upgrade$',views.upgrade_view,name='upgrade'),
|
||||||
|
url(r'^downgrade$',views.downgrade_view,name='downgrade'),
|
||||||
url(r'^paymentcompleted$',views.payment_completed_view),
|
url(r'^paymentcompleted$',views.payment_completed_view),
|
||||||
|
url(r'^downgradecompleted$',views.downgrade_completed_view),
|
||||||
url(r'^paidplans$',views.paidplans_view,name='paidplans'),
|
url(r'^paidplans$',views.paidplans_view,name='paidplans'),
|
||||||
url(r'^me/cancelsubscriptions$',views.plan_stop_view),
|
url(r'^me/cancelsubscriptions$',views.plan_stop_view),
|
||||||
url(r'^me/cancelsubscription/(?P<id>[\w\ ]+.*)$',views.plan_tobasic_view),
|
url(r'^me/cancelsubscription/(?P<id>[\w\ ]+.*)$',views.plan_tobasic_view),
|
||||||
url(r'^checkouts$',views.checkouts_view,name='checkouts'),
|
url(r'^checkouts$',views.checkouts_view,name='checkouts'),
|
||||||
url(r'^upgradecheckouts$',views.upgrade_checkouts_view,name='upgrade_checkouts'),
|
url(r'^upgradecheckouts$',views.upgrade_checkouts_view,name='upgrade_checkouts'),
|
||||||
|
url(r'^downgradecheckouts$',views.downgrade_checkouts_view,name='downgrade_checkouts'),
|
||||||
url(r'^planrequired',views.planrequired_view),
|
url(r'^planrequired',views.planrequired_view),
|
||||||
url(r'^starttrial$',views.start_trial_view),
|
url(r'^starttrial$',views.start_trial_view),
|
||||||
url(r'^startplantrial$',views.start_plantrial_view),
|
url(r'^startplantrial$',views.start_plantrial_view),
|
||||||
|
|||||||
112
rowers/views.py
112
rowers/views.py
@@ -1147,6 +1147,54 @@ def upgrade_view(request):
|
|||||||
'planselectform':planselectform,
|
'planselectform':planselectform,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def downgrade_view(request):
|
||||||
|
r = getrequestrower(request)
|
||||||
|
|
||||||
|
if r.subscription_id is None or r.subscription_id == '':
|
||||||
|
url = reverse(billing_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
billingaddressform = RowerBillingAddressForm(request.POST)
|
||||||
|
planselectform = PlanSelectForm(request.POST,paymentprocessor='braintree')
|
||||||
|
if billingaddressform.is_valid():
|
||||||
|
cd = billingaddressform.cleaned_data
|
||||||
|
for attr, value in cd.items():
|
||||||
|
setattr(r, attr, value)
|
||||||
|
r.save()
|
||||||
|
|
||||||
|
if planselectform.is_valid():
|
||||||
|
plan = planselectform.cleaned_data['plan']
|
||||||
|
|
||||||
|
if plan.price > r.paidplan.price:
|
||||||
|
nextview = upgrade_confirm_view
|
||||||
|
elif plan.price == r.paidplan.price:
|
||||||
|
messages.info(request,'You did not select a new plan')
|
||||||
|
url = reverse(downgrade_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
else:
|
||||||
|
nextview = downgrade_confirm_view
|
||||||
|
|
||||||
|
if billingaddressform.is_valid():
|
||||||
|
url = reverse(nextview,
|
||||||
|
kwargs={
|
||||||
|
'planid':plan.id
|
||||||
|
})
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
else:
|
||||||
|
billingaddressform = RowerBillingAddressForm(instance=r)
|
||||||
|
planselectform = PlanSelectForm(paymentprocessor='braintree',
|
||||||
|
rower=r,includeall=True, initial={'plan':r.paidplan})
|
||||||
|
|
||||||
|
return render(request,
|
||||||
|
'downgrade.html',
|
||||||
|
{'rower':r,
|
||||||
|
'billingaddressform':billingaddressform,
|
||||||
|
'planselectform':planselectform,
|
||||||
|
})
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def plan_stop_view(request):
|
def plan_stop_view(request):
|
||||||
r = getrequestrower(request)
|
r = getrequestrower(request)
|
||||||
@@ -1207,6 +1255,28 @@ def upgrade_confirm_view(request,planid = 0):
|
|||||||
'rower':r,
|
'rower':r,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def downgrade_confirm_view(request,planid = 0):
|
||||||
|
try:
|
||||||
|
plan = PaidPlan.objects.get(id=planid)
|
||||||
|
except PaidPlan.DoesNotExist:
|
||||||
|
messages.error(request,"Something went wrong. Please try again.")
|
||||||
|
url = reverse(billing_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
r = getrequestrower(request)
|
||||||
|
|
||||||
|
client_token = braintreestuff.get_client_token(r)
|
||||||
|
|
||||||
|
return render(request,
|
||||||
|
"downgradeconfirm.html",
|
||||||
|
{
|
||||||
|
'plan':plan,
|
||||||
|
'client_token':client_token,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def payment_confirm_view(request,planid = 0):
|
def payment_confirm_view(request,planid = 0):
|
||||||
try:
|
try:
|
||||||
@@ -1288,7 +1358,37 @@ def upgrade_checkouts_view(request):
|
|||||||
|
|
||||||
url = reverse(paidplans_view)
|
url = reverse(paidplans_view)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def downgrade_checkouts_view(request):
|
||||||
|
|
||||||
|
r = getrequestrower(request)
|
||||||
|
|
||||||
|
if request.method != 'POST':
|
||||||
|
url = reverse(paidplans_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
form = BillingForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
data = form.cleaned_data
|
||||||
|
success = braintreestuff.update_subscription(r,data,method='down')
|
||||||
|
if success:
|
||||||
|
messages.info(request,"Your plan has been updated")
|
||||||
|
url = reverse(downgrade_completed_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
else:
|
||||||
|
messages.error(request,"There was a problem with your transaction")
|
||||||
|
url = reverse(upgrade_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
else:
|
||||||
|
messages.error(request,"There was an error in the payment form")
|
||||||
|
url = reverse(upgrade_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
url = reverse(paidplans_view)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def payment_completed_view(request):
|
def payment_completed_view(request):
|
||||||
@@ -1300,6 +1400,16 @@ def payment_completed_view(request):
|
|||||||
'rower':r
|
'rower':r
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def downgrade_completed_view(request):
|
||||||
|
r = getrequestrower(request)
|
||||||
|
|
||||||
|
return render(request,
|
||||||
|
"downgrade_completed.html",
|
||||||
|
{
|
||||||
|
'rower':r
|
||||||
|
})
|
||||||
|
|
||||||
# User registration
|
# User registration
|
||||||
def rower_register_view(request):
|
def rower_register_view(request):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user