Gero Posmyk-Leinemann 05e18a58ea
Remove BillingMode.Chargebee (#17269)
* [dashboard] Remove usage of BillingMode.canSetWorkspaceClass/.showTeamSubscriptionUI

* [server] Cleanup remaining BillingMode.Chargebee usages

* [server] Remove BillingMode.Chargebee
2023-04-18 20:13:50 +08:00

42 lines
1.4 KiB
TypeScript

/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License.AGPL.txt in the project root for license information.
*/
/**
* BillingMode is used to answer the following questions:
* - Should UI piece x be displayed for this user/team? (getBillingModeForUser/Team)
* - What model should be used to limit this workspace's capabilities (mayStartWorkspace, setTimeout, workspace class, etc...) (getBillingMode(workspaceInstance.attributionId))
* - How is a workspace session charged for? (getBillingMode(workspaceInstance.attributionId))
*/
export type BillingMode = None | UsageBased;
export namespace BillingMode {
export const NONE: None = {
mode: "none",
};
/** Incl. upgrade and status */
export function showUsageBasedBilling(billingMode?: BillingMode): boolean {
return billingMode?.mode === "usage-based";
}
export function canSetCostCenter(billingMode: BillingMode): boolean {
// if has any Stripe Subscription, either directly or per team
return billingMode.mode === "usage-based";
}
}
/** Payment is disabled */
interface None {
mode: "none";
}
/** Session is handld with new usage-based logic */
interface UsageBased {
mode: "usage-based";
/** True iff this is a team, and is based on a paid plan. Currently only set for teams! */
paid?: boolean;
}