feat: unlimited billing pages (#2777)

Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
This commit is contained in:
Anshuman Pandey
2024-06-19 14:14:45 +05:30
committed by GitHub
parent a473719eee
commit 3b08b718ff
3 changed files with 63 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
import { redirect } from "next/navigation";
import { STRIPE_PRICE_LOOKUP_KEYS } from "@formbricks/lib/constants";
import { getOrganizationByEnvironmentId } from "@formbricks/lib/organization/service";
import { upgradePlanAction } from "../actions";
const Page = async ({ params }) => {
const organization = await getOrganizationByEnvironmentId(params.environmentId);
if (!organization) {
throw new Error("Organization not found");
}
const { status, newPlan, url } = await upgradePlanAction(
organization.id,
params.environmentId,
STRIPE_PRICE_LOOKUP_KEYS.UNLIMITED_99
);
if (status != 200) {
throw new Error("Something went wrong");
}
if (newPlan && url) {
redirect(url);
} else if (!newPlan) {
redirect(`/billing-confirmation?environmentId=${params.environmentId}`);
} else {
throw new Error("Something went wrong");
}
};
export default Page;

View File

@@ -0,0 +1,30 @@
import { redirect } from "next/navigation";
import { STRIPE_PRICE_LOOKUP_KEYS } from "@formbricks/lib/constants";
import { getOrganizationByEnvironmentId } from "@formbricks/lib/organization/service";
import { upgradePlanAction } from "../actions";
const Page = async ({ params }) => {
const organization = await getOrganizationByEnvironmentId(params.environmentId);
if (!organization) {
throw new Error("Organization not found");
}
const { status, newPlan, url } = await upgradePlanAction(
organization.id,
params.environmentId,
STRIPE_PRICE_LOOKUP_KEYS.UNLIMITED_199
);
if (status != 200) {
throw new Error("Something went wrong");
}
if (newPlan && url) {
redirect(url);
} else if (!newPlan) {
redirect(`/billing-confirmation?environmentId=${params.environmentId}`);
} else {
throw new Error("Something went wrong");
}
};
export default Page;

View File

@@ -193,6 +193,8 @@ export enum STRIPE_PRICE_LOOKUP_KEYS {
STARTUP_YEARLY = "formbricks_startup_yearly",
SCALE_MONTHLY = "formbricks_scale_monthly",
SCALE_YEARLY = "formbricks_scale_yearly",
UNLIMITED_99 = "formbricks_unlimited_99",
UNLIMITED_199 = "formbricks_unlimited_199",
}
export const BILLING_LIMITS = {
@@ -208,4 +210,4 @@ export const BILLING_LIMITS = {
RESPONSES: 5000,
MIU: 20000,
},
};
} as const;