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