Merge remote-tracking branch 'origin/master' into swaggerlikeus
Conflicts: data/database.py endpoints/api.py endpoints/common.py templates/base.html test/data/test.db test/specs.py
This commit is contained in:
commit
c93c62600d
59 changed files with 4636 additions and 216 deletions
|
@ -2,6 +2,7 @@ import logging
|
|||
import stripe
|
||||
|
||||
from endpoints.api import request_error, log_action, NotFound
|
||||
from endpoints.common import check_repository_usage
|
||||
from data import model
|
||||
from data.plans import PLANS
|
||||
|
||||
|
@ -58,6 +59,7 @@ def subscribe(user, plan, token, require_business_plan):
|
|||
cus = stripe.Customer.create(email=user.email, plan=plan, card=card)
|
||||
user.stripe_id = cus.id
|
||||
user.save()
|
||||
check_repository_usage(user, plan_found)
|
||||
log_action('account_change_plan', user.username, {'plan': plan})
|
||||
except stripe.CardError as e:
|
||||
return carderror_response(e)
|
||||
|
@ -74,6 +76,7 @@ def subscribe(user, plan, token, require_business_plan):
|
|||
# We only have to cancel the subscription if they actually have one
|
||||
cus.cancel_subscription()
|
||||
cus.save()
|
||||
check_repository_usage(user, plan_found)
|
||||
log_action('account_change_plan', user.username, {'plan': plan})
|
||||
|
||||
else:
|
||||
|
@ -89,6 +92,7 @@ def subscribe(user, plan, token, require_business_plan):
|
|||
return carderror_response(e)
|
||||
|
||||
response_json = subscription_view(cus.subscription, private_repos)
|
||||
check_repository_usage(user, plan_found)
|
||||
log_action('account_change_plan', user.username, {'plan': plan})
|
||||
|
||||
return response_json, status_code
|
||||
|
|
Reference in a new issue