User Plan

Configure the user plans that an user can subscribe to. This can be configured from src/components/UserPlan.ts file. Each plan has details like price, credits, resetType and more.

Structure

enum PlanType {
  FREE
  SUBSCRIPTION
  ONE_TIME
}
 
type PlanResetType = "monthly" | "yearly" | "one-time" | "on-payment";
 
export type Plan = {
  id: string;
  name: string;
  price: number;
  type: PlanType;
 
  credits: number;
  resetType: PlanResetType;
};

id

The id of the plan. This is used to identify the plan in the database and in the frontend.

name

The name of the plan. This is used to display the plan in the frontend.

type

This tells what type of plan it is and helps in resetting the limits etc.

credits

The number of credits that the user gets when either activated or on reset of the credits.

resetType

This tells how periodically (if at all) the credits are reset.

You can find more about Credits here.

Default plans

You can find the default plans in the src/components/UserPlan.ts file. There are three plans out of the box, free, monthly and lifetime. You can customize/remove them as per your need. Example shown below.

export const PLAN_MONTHLY: Plan = {
  id: "monthly",
  name: "Monthly",
  price: 9,
  type: "SUBSCRIPTION",
  credits: 100,
  resetType: "on-payment",
};

Payment Providers

By nature the payment and the User Plan are two different entities. The payment provider is used to receive payments and the user plan is used to allocate credits to the user. We map the plans and the products from payment providers so that they get activated/deactivated on multiple events from the payment provider.

You can configure this mapping from Lemonsqueezy and Stripe routes respectively.


MIT 2024 Β© Nextra.