diff --git a/rowers/braintreestuff.py b/rowers/braintreestuff.py
index 4a2bc46e..30fd6adb 100644
--- a/rowers/braintreestuff.py
+++ b/rowers/braintreestuff.py
@@ -107,7 +107,7 @@ def make_payment(rower,data):
else:
return 0,''
-def update_subscription(rower,data):
+def update_subscription(rower,data,method='up'):
planid = data['plan']
plan = PaidPlan.objects.get(id=planid)
nonce_from_the_client = data['payment_method_nonce']
@@ -148,11 +148,13 @@ def update_subscription(rower,data):
l = rower.user.last_name,
)
+ if method == 'up':
+ transactions = result.subscription.transactions
- transactions = result.subscription.transactions
-
- if transactions:
- amount = transactions[0].amount
+ if transactions:
+ amount = transactions[0].amount
+ else:
+ amount = 0
else:
amount = 0
@@ -164,7 +166,8 @@ def update_subscription(rower,data):
plan.paymenttype == 'recurring',
plan.price,
amount,
- result.subscription.billing_period_end_date.strftime('%Y-%m-%d'))
+ result.subscription.billing_period_end_date.strftime('%Y-%m-%d'),
+ method)
return True
else:
diff --git a/rowers/forms.py b/rowers/forms.py
index 31d292de..f0145b7d 100644
--- a/rowers/forms.py
+++ b/rowers/forms.py
@@ -721,6 +721,7 @@ class PlanSelectForm(forms.Form):
def __init__(self, *args, **kwargs):
paymentprocessor = kwargs.pop('paymentprocessor',None)
rower = kwargs.pop('rower',None)
+ includeall = kwargs.pop('includeall',False)
super(PlanSelectForm, self).__init__(*args, **kwargs)
self.fields['plan'].empty_label = None
if paymentprocessor:
@@ -731,7 +732,7 @@ class PlanSelectForm(forms.Form):
).order_by(
"price","clubsize","shortname"
)
- if rower:
+ if rower and not includeall:
try:
amount = rower.paidplan.price
except AttributeError:
@@ -743,6 +744,7 @@ class PlanSelectForm(forms.Form):
).order_by(
"price","clubsize","shortname"
)
+
class CourseSelectForm(forms.Form):
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())
diff --git a/rowers/tasks.py b/rowers/tasks.py
index c354b25c..a848cd37 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -797,14 +797,13 @@ def handle_send_email_failed_cancel(
@app.task
def handle_send_email_subscription_update(
username, useremail, planname, recurring, price, amount,
- end_of_billing_period, **kwargs):
+ end_of_billing_period, method, **kwargs):
if 'debug' in kwargs:
debug = kwargs['debug']
else:
debug = True
- subject = "Rowsandall Payment Confirmation"
from_email = 'Rowsandall
+ Thank you for changing to {{ user.rower.paidplan.name }}. You're all settled.
+ membership.
+
+ {% 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 %}
+
+ Downgrade
+
+
+
+{% endblock %}
+
+{% block sidebar %}
+{% include 'menu_profile.html' %}
+{% endblock %}
+
diff --git a/rowers/templates/downgrade_completed.html b/rowers/templates/downgrade_completed.html
new file mode 100644
index 00000000..1fdde09b
--- /dev/null
+++ b/rowers/templates/downgrade_completed.html
@@ -0,0 +1,26 @@
+{% extends "newbase.html" %}
+{% block title %}Rowsandall Paid Membership{% endblock title %}
+{% load rowerfilters %}
+{% block main %}
+
+Your Change was completed
+
+Confirm Your Changes
+
+Order Overview
+
+
+
+
+
+
+
+ Plan {{ plan.name }}
+
+
+ Payment Type {{ plan.paymenttype }}
+
+
+ Billing Cycle 1 year
+
+
+
+ Total € {{ plan.price|currency }}
+ {% if plan.paymenttype == 'recurring' %}
+ /year
+ {% endif %}
+
+
+
| Street Address | {{ user.rower.street_address }} | +
|---|---|
| City | {{ user.rower.city }} | +
| Postal Code | {{ user.rower.postal_code }} | +
| Country | {{ user.rower.country }} + | +
+ Change Downgrade +
+ Your downgrade will be effective immediately. You will not be charged. +
+Dear {{ name }},
+ ++ Thank you. You have successfully changed your plan to "{{ planname }}". +
+ +{% if recurring %} ++ 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. +
+ ++ 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 + the upgrade page. On this page, you can also + upgrade your subscription. +
+ +{% else %} ++ 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. +
+ ++ At any point in time, you can change your subscription to an automatically renewing subscription. + You can do this on the upgrade page. + Here, you can also upgrade your subscription. +
+{% endif %} + ++ 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. +
+ ++ You can stop the subscription through + the subscription management page. The + subscription will be stopped immediately without a refund. +
+ ++ Please contact our customer service by replying to this email if you have any further + questions regarding your subscription. +
+ ++ Best Regards, the Rowsandall Team +
+{% endblock %} + diff --git a/rowers/templates/subscription_downgrade_notification.html b/rowers/templates/subscription_downgrade_notification.html new file mode 100644 index 00000000..dce13caf --- /dev/null +++ b/rowers/templates/subscription_downgrade_notification.html @@ -0,0 +1,26 @@ +{% extends "emailbase.html" %} + +{% block body %} +User {{ name }} has downgraded his subscription.
+ ++ New plan: "{{ planname }}". +
+ +{% if recurring %} ++ The subscription cost is €{{ price }} per year. + The next charge is due on {{ end_of_billing_period }}. on that date. +
+{% else %} ++ The subscription cost is €{{ price }}. The subscription ends on {{ end_of_billing_period }} +
+{% endif %} + + ++ Best Regards, the Rowsandall Team +
+{% endblock %} + diff --git a/rowers/urls.py b/rowers/urls.py index 646ac0cf..474946e3 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -440,14 +440,18 @@ urlpatterns = [ url(r'^promembership', TemplateView.as_view(template_name='promembership.html'),name='promembership'), url(r'^checkout/(?P