upgrade done
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user