better error handling
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user