feat: add platform plan pricing (#1505)

Add platform plan to the billing page.
This commit is contained in:
David Nguyen
2024-12-04 15:42:03 +09:00
committed by GitHub
parent a687064a42
commit f4b1e5104e
2 changed files with 5 additions and 4 deletions

View File

@ -12,10 +12,10 @@ export type GetPricesByIntervalOptions = {
/**
* Filter products by their meta 'plan' attribute.
*/
plan?: STRIPE_PLAN_TYPE.COMMUNITY | STRIPE_PLAN_TYPE.REGULAR;
plans?: STRIPE_PLAN_TYPE[];
};
export const getPricesByInterval = async ({ plan }: GetPricesByIntervalOptions = {}) => {
export const getPricesByInterval = async ({ plans }: GetPricesByIntervalOptions = {}) => {
let { data: prices } = await stripe.prices.search({
query: `active:'true' type:'recurring'`,
expand: ['data.product'],
@ -27,7 +27,8 @@ export const getPricesByInterval = async ({ plan }: GetPricesByIntervalOptions =
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const product = price.product as Stripe.Product;
const filter = !plan || product.metadata?.plan === plan;
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const filter = !plans || plans.includes(product.metadata?.plan as STRIPE_PLAN_TYPE);
// Filter out prices for products that are not active.
return product.active && filter;