diff --git a/rowers/braintreestuff.py b/rowers/braintreestuff.py
index 30fd6adb..01fda581 100644
--- a/rowers/braintreestuff.py
+++ b/rowers/braintreestuff.py
@@ -171,6 +171,17 @@ def update_subscription(rower,data,method='up'):
return True
else:
+ errors = result.errors.for_object("subscription")
+ codes = [str(e.code) for e in errors]
+ create_new = False
+ proceed_codes = ['81901','81910']
+ for c in codes:
+ if c in proceed_codes:
+ create_new = True
+
+ if create_new:
+ return create_subscription(rower,data)
+
return False
return False
@@ -237,7 +248,7 @@ def cancel_subscription(rower,id):
errormessages = []
try:
result = gateway.subscription.cancel(id)
- messages.append("Subscription canceled")
+ themessages.append("Subscription canceled")
except:
errormessages.append("We could not find the subscription record in our customer database. We have notified the site owner, who will contact you.")
@@ -250,7 +261,8 @@ def cancel_subscription(rower,id):
return False, themessages, errormessages
- rower.paidplan = None
+ basicplans = PaidPlan.objects.filter(price=0,paymentprocessor='braintree')
+ rower.paidplan = basicplans[0]
rower.teamplanexpires = timezone.now()
rower.planexpires = timezone.now()
rower.clubsize = 0
diff --git a/rowers/templates/braintreedropin.html b/rowers/templates/braintreedropin.html
new file mode 100644
index 00000000..9ffe456b
--- /dev/null
+++ b/rowers/templates/braintreedropin.html
@@ -0,0 +1,25 @@
+
+
diff --git a/rowers/templates/downgradeconfirm.html b/rowers/templates/downgradeconfirm.html
index c5bb79b2..f6dea839 100644
--- a/rowers/templates/downgradeconfirm.html
+++ b/rowers/templates/downgradeconfirm.html
@@ -83,31 +83,7 @@
-
-
+{% include 'braintreedropin.html' %}
{% endblock %}
diff --git a/rowers/templates/paymentconfirm.html b/rowers/templates/paymentconfirm.html
index 693d2588..f9748ccf 100644
--- a/rowers/templates/paymentconfirm.html
+++ b/rowers/templates/paymentconfirm.html
@@ -78,31 +78,7 @@
-
-
+{% include 'braintreedropin.html' %}
{% endblock %}
diff --git a/rowers/templates/upgradeconfirm.html b/rowers/templates/upgradeconfirm.html
index d4cc67ac..6d88470b 100644
--- a/rowers/templates/upgradeconfirm.html
+++ b/rowers/templates/upgradeconfirm.html
@@ -87,31 +87,8 @@
-
-
+{% include 'braintreedropin.html' %}
+
{% endblock %}
diff --git a/rowers/views.py b/rowers/views.py
index cbd35ca3..d44d47de 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -29,6 +29,7 @@ import re
import cgi
from icalendar import Calendar, Event
import rowers.braintreestuff as braintreestuff
+import rowers.payments as payments
from django.shortcuts import render
from django.template.loader import render_to_string
@@ -1074,6 +1075,10 @@ def paidplans_view(request):
def billing_view(request):
r = getrequestrower(request)
+ if payments.is_existing_customer(r):
+ url = reverse(upgrade_view)
+ return HttpResponseRedirect(url)
+
if request.method == 'POST':
billingaddressform = RowerBillingAddressForm(request.POST)
planselectform = PlanSelectForm(request.POST,paymentprocessor='braintree')