Private
Public Access
1
0

errors fixed

This commit is contained in:
Sander Roosendaal
2018-12-31 16:45:46 +01:00
parent 1968832eba
commit 117836a102
9 changed files with 30 additions and 15 deletions

View File

@@ -115,6 +115,7 @@ def update_subscription(rower,data,method='up'):
amount = data['amount'] amount = data['amount']
amount = '{amount:.2f}'.format(amount=amount) amount = '{amount:.2f}'.format(amount=amount)
gatewaydata = { gatewaydata = {
"price": amount, "price": amount,
"plan_id": plan.external_id, "plan_id": plan.external_id,
@@ -124,16 +125,19 @@ def update_subscription(rower,data,method='up'):
}, },
} }
if plan.paymenttype == 'single': if plan.paymenttype == 'single':
gatewaydata['number_of_billing_cycles'] = 1 gatewaydata['number_of_billing_cycles'] = 1
else: else:
gatewaydata['never_expires'] = True gatewaydata['never_expires'] = True
result = gateway.subscription.update( try:
rower.subscription_id, result = gateway.subscription.update(
gatewaydata rower.subscription_id,
) gatewaydata
)
except:
return False
if result.is_success: if result.is_success:
rower.paidplan = plan rower.paidplan = plan
@@ -164,7 +168,7 @@ def update_subscription(rower,data,method='up'):
handle_send_email_subscription_update, handle_send_email_subscription_update,
name, rower.user.email, name, rower.user.email,
plan.name, plan.name,
plan.paymenttype == 'recurring', plan.paymenttype,
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'),
@@ -225,7 +229,7 @@ def create_subscription(rower,data):
) )
recurring = plan.paymenttype == 'recurring', recurring = plan.paymenttype
job = myqueue( job = myqueue(
queuehigh, queuehigh,
@@ -268,6 +272,7 @@ def cancel_subscription(rower,id):
rower.planexpires = timezone.now() rower.planexpires = timezone.now()
rower.clubsize = 0 rower.clubsize = 0
rower.rowerplan = 'basic' rower.rowerplan = 'basic'
rower.subscription_id = None
rower.save() rower.save()
themessages.append("Your plan was reset to basic") themessages.append("Your plan was reset to basic")
@@ -309,7 +314,8 @@ def find_subscriptions(rower):
'plan_id': subscription.plan_id, 'plan_id': subscription.plan_id,
'price': subscription.price, 'price': subscription.price,
'id': subscription.id, 'id': subscription.id,
'plan': plan.name 'plan': plan.name,
'never_expires': subscription.never_expires
} }
result.append(thedict) result.append(thedict)

View File

@@ -852,6 +852,7 @@ def handle_send_email_subscription_create(
from_email = 'Rowsandall <admin@rowsandall.com>' from_email = 'Rowsandall <admin@rowsandall.com>'
d = { d = {
'name': username, 'name': username,
'siteurl': siteurl, 'siteurl': siteurl,

View File

@@ -8,7 +8,7 @@
subscription to the Rowsandall paid plan "{{ planname }}". subscription to the Rowsandall paid plan "{{ planname }}".
</p> </p>
{% if recurring %} {% if recurring=='recurring' %}
<p> <p>
Your next charge is due on {{ end_of_billing_period }}. We will charge your {{ paymentmethod }} Your next charge is due on {{ end_of_billing_period }}. We will charge your {{ paymentmethod }}
on that date. on that date.

View File

@@ -7,7 +7,7 @@
New plan: "{{ planname }}". New plan: "{{ planname }}".
</p> </p>
{% if recurring %} {% if recurring=='recurring'%}
<p> <p>
The subscription cost is &euro;{{ price }} per year. The subscription cost is &euro;{{ price }} per year.
The next charge is due on {{ end_of_billing_period }}. The next charge is due on {{ end_of_billing_period }}.

View File

@@ -7,7 +7,7 @@
Thank you. You have successfully changed your plan to "{{ planname }}". Thank you. You have successfully changed your plan to "{{ planname }}".
</p> </p>
{% if recurring %} {% if recurring=='recurring' %}
<p> <p>
The subscription cost is &euro;{{ price }} per year. The subscription cost is &euro;{{ price }} per year.
Your next charge is due on {{ end_of_billing_period }}. We will charge you automatically Your next charge is due on {{ end_of_billing_period }}. We will charge you automatically

View File

@@ -7,7 +7,7 @@
New plan: "{{ planname }}". New plan: "{{ planname }}".
</p> </p>
{% if recurring %} {% if recurring=='recurring' %}
<p> <p>
The subscription cost is &euro;{{ price }} per year. The subscription cost is &euro;{{ price }} per year.
The next charge is due on {{ end_of_billing_period }}. The next charge is due on {{ end_of_billing_period }}.

View File

@@ -9,7 +9,7 @@
You are now on the Rowsandall paid plan "{{ planname }}". You are now on the Rowsandall paid plan "{{ planname }}".
</p> </p>
{% if recurring %} {% if recurring=='recurring' %}
<p> <p>
The subscription cost is &euro;{{ price }} per year. The subscription cost is &euro;{{ price }} per year.
Your next charge is due on {{ end_of_billing_period }}. We will charge you automatically Your next charge is due on {{ end_of_billing_period }}. We will charge you automatically

View File

@@ -7,7 +7,7 @@
New plan: "{{ planname }}". New plan: "{{ planname }}".
</p> </p>
{% if recurring %} {% if recurring=='recurring' %}
<p> <p>
The subscription cost is &euro;{{ price }} per year. The subscription cost is &euro;{{ price }} per year.
The next charge is due on {{ end_of_billing_period }}. The next charge is due on {{ end_of_billing_period }}.

View File

@@ -12,7 +12,8 @@
<table class="plantable shortpadded" width="80%"> <table class="plantable shortpadded" width="80%">
<thead> <thead>
<tr> <tr>
<th>Subscription</th><th>Next Billing Date</th><th>Price</th><th>&nbsp;</th> <th>Subscription</th><th>Paid Until</th><th>Price</th>
<th>Subscription type</th><th>&nbsp;</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -27,6 +28,13 @@
<td> <td>
{{ subscription|lookup:"price" }} &euro; {{ subscription|lookup:"price" }} &euro;
</td> </td>
<td>
{% if subscription|lookup:"never_expires" %}
Recurring
{% else %}
Not recurring
{% endif %}
</td>
<td> <td>
<a href="/rowers/me/cancelsubscription/{{ subscription|lookup:'id' }}">Stop this plan</a> <a href="/rowers/me/cancelsubscription/{{ subscription|lookup:'id' }}">Stop this plan</a>
</td> </td>