feat(server): support lifetime subscription (#7405)

closes CLOUD-48

- [x] lifetime subscription quota
- [ ] tests
This commit is contained in:
forehalo
2024-07-08 07:41:26 +00:00
parent 7235779b02
commit de91027852
17 changed files with 446 additions and 164 deletions
@@ -38,6 +38,7 @@ enum DescriptionI18NKey {
Basic = 'com.affine.payment.billing-setting.current-plan.description',
Monthly = 'com.affine.payment.billing-setting.current-plan.description.monthly',
Yearly = 'com.affine.payment.billing-setting.current-plan.description.yearly',
Lifetime = 'com.affine.payment.billing-setting.current-plan.description.lifetime',
}
const INVOICE_PAGE_SIZE = 12;
@@ -204,7 +205,7 @@ const SubscriptionSettings = () => {
})}
/>
)}
{proSubscription.canceledAt ? (
{proSubscription.end && proSubscription.canceledAt ? (
<SettingRow
name={t['com.affine.payment.billing-setting.expiration-date']()}
desc={t[
+12 -9
View File
@@ -259,6 +259,7 @@ export enum ErrorNames {
BLOB_NOT_FOUND = 'BLOB_NOT_FOUND',
BLOB_QUOTA_EXCEEDED = 'BLOB_QUOTA_EXCEEDED',
CANT_CHANGE_WORKSPACE_OWNER = 'CANT_CHANGE_WORKSPACE_OWNER',
CANT_UPDATE_LIFETIME_SUBSCRIPTION = 'CANT_UPDATE_LIFETIME_SUBSCRIPTION',
COPILOT_ACTION_TAKEN = 'COPILOT_ACTION_TAKEN',
COPILOT_FAILED_TO_CREATE_MESSAGE = 'COPILOT_FAILED_TO_CREATE_MESSAGE',
COPILOT_FAILED_TO_GENERATE_TEXT = 'COPILOT_FAILED_TO_GENERATE_TEXT',
@@ -950,12 +951,14 @@ export interface SubscriptionPrice {
__typename?: 'SubscriptionPrice';
amount: Maybe<Scalars['Int']['output']>;
currency: Scalars['String']['output'];
lifetimeAmount: Maybe<Scalars['Int']['output']>;
plan: SubscriptionPlan;
type: Scalars['String']['output'];
yearlyAmount: Maybe<Scalars['Int']['output']>;
}
export enum SubscriptionRecurring {
Lifetime = 'Lifetime',
Monthly = 'Monthly',
Yearly = 'Yearly',
}
@@ -1027,8 +1030,8 @@ export interface UserSubscription {
__typename?: 'UserSubscription';
canceledAt: Maybe<Scalars['DateTime']['output']>;
createdAt: Scalars['DateTime']['output'];
end: Scalars['DateTime']['output'];
id: Scalars['String']['output'];
end: Maybe<Scalars['DateTime']['output']>;
id: Maybe<Scalars['String']['output']>;
nextBillAt: Maybe<Scalars['DateTime']['output']>;
/**
* The 'Free' plan just exists to be a placeholder and for the type convenience of frontend.
@@ -1213,7 +1216,7 @@ export type CancelSubscriptionMutation = {
__typename?: 'Mutation';
cancelSubscription: {
__typename?: 'UserSubscription';
id: string;
id: string | null;
status: SubscriptionStatus;
nextBillAt: string | null;
canceledAt: string | null;
@@ -1347,7 +1350,7 @@ export type EarlyAccessUsersQuery = {
recurring: SubscriptionRecurring;
status: SubscriptionStatus;
start: string;
end: string;
end: string | null;
} | null;
}>;
};
@@ -1834,11 +1837,11 @@ export type ResumeSubscriptionMutation = {
__typename?: 'Mutation';
resumeSubscription: {
__typename?: 'UserSubscription';
id: string;
id: string | null;
status: SubscriptionStatus;
nextBillAt: string | null;
start: string;
end: string;
end: string | null;
};
};
@@ -1955,12 +1958,12 @@ export type SubscriptionQuery = {
id: string;
subscriptions: Array<{
__typename?: 'UserSubscription';
id: string;
id: string | null;
status: SubscriptionStatus;
plan: SubscriptionPlan;
recurring: SubscriptionRecurring;
start: string;
end: string;
end: string | null;
nextBillAt: string | null;
canceledAt: string | null;
}>;
@@ -1990,7 +1993,7 @@ export type UpdateSubscriptionMutation = {
__typename?: 'Mutation';
updateSubscriptionRecurring: {
__typename?: 'UserSubscription';
id: string;
id: string | null;
plan: SubscriptionPlan;
recurring: SubscriptionRecurring;
nextBillAt: string | null;
@@ -941,6 +941,7 @@
"com.affine.payment.billing-setting.current-plan.description": "You are currently on the <1>{{planName}} plan</1>.",
"com.affine.payment.billing-setting.current-plan.description.monthly": "You are currently on the monthly <1>{{planName}} plan</1>.",
"com.affine.payment.billing-setting.current-plan.description.yearly": "You are currently on the yearly <1>{{planName}} plan</1>.",
"com.affine.payment.billing-setting.current-plan.description.lifetime": "You are currently on the believer <1>{{planName}} plan</1>.",
"com.affine.payment.billing-setting.expiration-date": "Expiration Date",
"com.affine.payment.billing-setting.expiration-date.description": "Your subscription is valid until {{expirationDate}}",
"com.affine.payment.billing-setting.history": "Billing history",