mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
## Description Add support for enterprise billing plans. Enterprise billing plans by default get access to everything early adopters do: - Unlimited teams - Unlimited documents They will also get additional features in the future. ## Notes Pending webhook updates to support enterprise onboarding. Rolled back env changes `NEXT_PUBLIC_PROJECT` since it doesn't seem to work.
19 lines
624 B
TypeScript
19 lines
624 B
TypeScript
import type { STRIPE_PLAN_TYPE } from '@documenso/lib/constants/billing';
|
|
import { stripe } from '@documenso/lib/server-only/stripe';
|
|
|
|
type PlanType = (typeof STRIPE_PLAN_TYPE)[keyof typeof STRIPE_PLAN_TYPE];
|
|
|
|
export const getPricesByPlan = async (plan: PlanType | PlanType[]) => {
|
|
const planTypes = typeof plan === 'string' ? [plan] : plan;
|
|
|
|
const query = planTypes.map((planType) => `metadata['plan']:'${planType}'`).join(' OR ');
|
|
|
|
const { data: prices } = await stripe.prices.search({
|
|
query,
|
|
expand: ['data.product'],
|
|
limit: 100,
|
|
});
|
|
|
|
return prices.filter((price) => price.type === 'recurring');
|
|
};
|