1 import type { ADDON_NAMES, Currency, PLANS, PLAN_TYPES } from '@proton/payments';
3 import type { ProrationMode } from '../api/payments';
4 import type { CYCLE } from '../constants';
5 import type { Nullable } from './utils';
16 export interface CycleMapping<T> {
19 [CYCLE.TWO_YEARS]?: T;
20 // Not always included for all plans
27 export type Pricing = CycleMapping<number>;
29 export interface Offer {
33 Pricing: Partial<Pricing>;
36 export interface Plan {
38 ParentMetaPlanID: string;
41 Name: PLANS | ADDON_NAMES;
56 DefaultPricing?: Pricing;
57 PeriodEnd: CycleMapping<number>;
62 export interface StrictPlan extends Plan {
63 Type: PLAN_TYPES.PLAN;
67 export interface Addon extends Plan {
68 Type: PLAN_TYPES.ADDON;
72 export interface FreePlanDefault extends Plan {
74 Type: PLAN_TYPES.PLAN;
76 MaxDriveSpace: number;
77 MaxRewardSpace: number;
78 MaxDriveRewardSpace: number;
79 MaxBaseRewardSpace: number;
87 export enum External {
93 export enum BillingPlatform {
98 export interface SubscriptionPlan
99 extends Omit<Plan, 'ParentMetaPlanID' | 'PeriodEnd' | 'Pricing' | 'DefaultPricing' | 'Offers'> {
101 Offer?: 'default' | string;
104 export interface Subscription {
111 CouponCode: null | string;
115 RenewDiscount: number;
118 Plans: SubscriptionPlan[];
120 UpcomingSubscription?: Subscription | null;
122 * That's a V5 property. It's not available for V4.
126 * V5 property. Potentially isn't available in V4.
128 BillingPlatform?: BillingPlatform;
131 export interface SubscriptionModel extends Subscription {
132 isManagedByMozilla: boolean;
135 export type BasePlansMap<T extends Plan> = {
136 [planName in PLANS | ADDON_NAMES]: T;
139 export type PlansMap = Partial<BasePlansMap<Plan>>;
141 export interface Tax {
144 * Tax rate in percent. For example, value can be 8.5 for 8.5%.
148 * Tax amount in cents. It must be an integer.
153 export enum TaxInclusive {
158 export enum SubscriptionMode {
165 export type Coupon = Nullable<{
168 MaximumRedemptionsPerUser: number | null;
171 export interface SubscriptionCheckResponse {
175 CouponDiscount?: number;
177 UnusedCredit?: number;
184 TaxInclusive?: TaxInclusive;
185 SubscriptionMode?: SubscriptionMode;
186 optimistic?: boolean;
187 ProrationMode?: ProrationMode;
190 export enum Audience {