Add a visible free plan. Tweak the plans and pricing page. Move all plans to a central plans service to have a single point for editing. Support the free plan on the user admin page. Tweak the landing page.

This commit is contained in:
yackob03 2013-10-04 14:35:51 -04:00
parent 8d40f12165
commit 3eca5f65e1
7 changed files with 194 additions and 139 deletions

View file

@ -383,41 +383,43 @@ def subscribe():
else:
# Change the plan
cus = stripe.Customer.retrieve(user.stripe_id)
cus.plan = plan
# User may have been a previous customer who is resubscribing
if 'token' in request_data:
cus.card = request_data['token']
if plan == 'free':
cus.cancel_subscription()
cus.save()
cus.save()
return jsonify(subscription_view(cus.subscription, private_repos))
response_json = {
'plan': 'free',
'usedPrivateRepos': private_repos,
}
else:
cus.plan = plan
# User may have been a previous customer who is resubscribing
if 'token' in request_data:
cus.card = request_data['token']
cus.save()
response_json = subscription_view(cus.subscription, private_repos)
return jsonify(response_json)
@app.route('/api/user/plan', methods=['GET'])
@api_login_required
def get_subscription():
user = current_user.db_user
private_repos = model.get_private_repo_count(user.username)
if user.stripe_id:
private_repos = model.get_private_repo_count(user.username)
cus = stripe.Customer.retrieve(user.stripe_id)
if cus.subscription:
return jsonify(subscription_view(cus.subscription, private_repos))
abort(404)
@app.route('/api/user/plan', methods=['DELETE'])
@api_login_required
def cancel_subscription():
user = current_user.db_user
if user.stripe_id:
private_repos = model.get_private_repo_count(user.username)
cus = stripe.Customer.retrieve(user.stripe_id)
cus.cancel_subscription()
return make_response('Deleted', 204)
abort(404)
return jsonify({
'plan': 'free',
'usedPrivateRepos': private_repos,
});