Private
Public Access
1
0

upgrade done

This commit is contained in:
Sander Roosendaal
2018-12-19 22:53:07 +01:00
parent a0a03a90df
commit 3ff114a307
7 changed files with 324 additions and 8 deletions

View File

@@ -85,6 +85,49 @@ def make_payment(rower,data):
else:
return 0,''
def update_subscription(rower,data):
planid = data['plan']
plan = PaidPlan.objects.get(id=planid)
nonce_from_the_client = data['payment_method_nonce']
amount = data['amount']
amount = '{amount:.2f}'.format(amount=amount)
print amount,'aap'
gatewaydata = {
"price": amount,
"plan_id": plan.external_id,
"payment_method_nonce": nonce_from_the_client,
"options": {
"prorate_charges":True,
},
}
if plan.paymenttype == 'single':
gatewaydata['number_of_billing_cycles'] = 1
else:
gatewaydata['never_expires'] = True
result = gateway.subscription.update(
rower.subscription_id,
gatewaydata
)
if result.is_success:
rower.paidplan = plan
rower.planexpires = result.subscription.billing_period_end_date
rower.teamplanexpires = result.subscription.billing_period_end_date
rower.clubsize = plan.clubsize
rower.paymenttype = plan.paymenttype
rower.rowerplan = plan.shortname
rower.subscription_id = result.subscription.id
rower.save()
return True
else:
return False
return False
def create_subscription(rower,data):
planid = data['plan']
plan = PaidPlan.objects.get(id=planid)