Turn off all references and API calls to billing if the feature is disabled
This commit is contained in:
parent
c374e8146a
commit
19a20a6c94
12 changed files with 135 additions and 62 deletions
|
@ -4,13 +4,14 @@ from flask import request
|
|||
|
||||
from endpoints.api import (resource, nickname, ApiResource, validate_json_request, log_action,
|
||||
related_user_resource, internal_only, Unauthorized, NotFound,
|
||||
require_user_admin)
|
||||
require_user_admin, show_if, hide_if)
|
||||
from endpoints.api.subscribe import subscribe, subscription_view
|
||||
from auth.permissions import AdministerOrganizationPermission
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from data import model
|
||||
from data.plans import PLANS
|
||||
|
||||
import features
|
||||
|
||||
def carderror_response(e):
|
||||
return {'carderror': e.message}, 402
|
||||
|
@ -79,6 +80,7 @@ def get_invoices(customer_id):
|
|||
|
||||
|
||||
@resource('/v1/plans/')
|
||||
@show_if(features.BILLING)
|
||||
class ListPlans(ApiResource):
|
||||
""" Resource for listing the available plans. """
|
||||
@nickname('listPlans')
|
||||
|
@ -91,6 +93,7 @@ class ListPlans(ApiResource):
|
|||
|
||||
@resource('/v1/user/card')
|
||||
@internal_only
|
||||
@show_if(features.BILLING)
|
||||
class UserCard(ApiResource):
|
||||
""" Resource for managing a user's credit card. """
|
||||
schemas = {
|
||||
|
@ -132,6 +135,7 @@ class UserCard(ApiResource):
|
|||
@resource('/v1/organization/<orgname>/card')
|
||||
@internal_only
|
||||
@related_user_resource(UserCard)
|
||||
@show_if(features.BILLING)
|
||||
class OrganizationCard(ApiResource):
|
||||
""" Resource for managing an organization's credit card. """
|
||||
schemas = {
|
||||
|
@ -178,6 +182,7 @@ class OrganizationCard(ApiResource):
|
|||
|
||||
@resource('/v1/user/plan')
|
||||
@internal_only
|
||||
@show_if(features.BILLING)
|
||||
class UserPlan(ApiResource):
|
||||
""" Resource for managing a user's subscription. """
|
||||
schemas = {
|
||||
|
@ -234,6 +239,7 @@ class UserPlan(ApiResource):
|
|||
@resource('/v1/organization/<orgname>/plan')
|
||||
@internal_only
|
||||
@related_user_resource(UserPlan)
|
||||
@show_if(features.BILLING)
|
||||
class OrganizationPlan(ApiResource):
|
||||
""" Resource for managing a org's subscription. """
|
||||
schemas = {
|
||||
|
@ -294,6 +300,7 @@ class OrganizationPlan(ApiResource):
|
|||
|
||||
@resource('/v1/user/invoices')
|
||||
@internal_only
|
||||
@show_if(features.BILLING)
|
||||
class UserInvoiceList(ApiResource):
|
||||
""" Resource for listing a user's invoices. """
|
||||
@require_user_admin
|
||||
|
@ -310,6 +317,7 @@ class UserInvoiceList(ApiResource):
|
|||
@resource('/v1/organization/<orgname>/invoices')
|
||||
@internal_only
|
||||
@related_user_resource(UserInvoiceList)
|
||||
@show_if(features.BILLING)
|
||||
class OrgnaizationInvoiceList(ApiResource):
|
||||
""" Resource for listing an orgnaization's invoices. """
|
||||
@nickname('listOrgInvoices')
|
||||
|
@ -323,4 +331,4 @@ class OrgnaizationInvoiceList(ApiResource):
|
|||
|
||||
return get_invoices(organization.stripe_id)
|
||||
|
||||
raise Unauthorized()
|
||||
raise Unauthorized()
|
||||
|
|
Reference in a new issue