Subscription Payments
This guide explains how to configure recurring subscription payments in your SaaS using Stripe. Subscriptions are ideal for SaaS plans such as Pro and Business that charge users on a recurring basis (monthly or yearly).
Create Subscription Products in Stripe
- Log in to your Stripe Dashboard.
- Navigate to Products and click Add Product.
- Create two products:
- Pro
- Business
- For each product, create two prices:
- Monthly: recurring every month
- Yearly: recurring every year
- Save each price to generate a Price ID in Stripe.
Example:
price_1ProMonthlyXXXprice_1ProYearlyXXXprice_1BusinessMonthlyXXXprice_1BusinessYearlyXXX
Configure Environment Variables
Copy the generated Price IDs from Stripe and add them to your .env.local file:
NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PLAN_ID=price_1ProMonthlyXXX
NEXT_PUBLIC_STRIPE_PRO_YEARLY_PLAN_ID=price_1ProYearlyXXX
NEXT_PUBLIC_STRIPE_BUSINESS_MONTHLY_PLAN_ID=price_1BusinessMonthlyXXX
NEXT_PUBLIC_STRIPE_BUSINESS_YEARLY_PLAN_ID=price_1BusinessYearlyXXX
These variables allow to correctly reference each plan and billing interval.
Include SubscriptionsPricingSection in Landing Page
To display subscription options on your landing page, import and include the SubscriptionsPricingSection component in:
app/(public)/(landing)/page.tsx
Example usage:
import { SubscriptionsPricingSection } from "@/components/landing/SubscriptionsPricingSection"
export default function LandingPage() {
return (
<>
{/* Other landing sections */}
<SubscriptionsPricingSection />
</>
)
}
The component automatically pulls your environment variables to render pricing and checkout buttons for all plans and intervals.
Subscription Behavior
- Cancellation: When a user cancels a subscription, it remains active until the next billing period (next month for monthly, next year for yearly).
- Downgrades: If a user downgrades from a higher plan to a lower plan, the change also takes effect in the next billing period.
- Upgrades: When a user upgrades a subscription plan, the change takes effect immediately and billing is adjusted pro-rata by Stripe.
Configure Stripe Customer Portal
To allow users to manage their subscriptions (upgrade, downgrade, or cancel) directly:
- Go to Stripe Dashboard → Customer Portal.
- Enable the portal and configure which actions customers can take:
- Update payment methods
- Upgrade or downgrade subscription plans
- Cancel subscription (effective next billing period)
- Integrate your app with the Customer Portal session by generating a session server-side and redirecting users to the portal.
This ensures your customers can self-manage subscriptions without manual intervention.
Tips
- Always test subscriptions in Stripe test mode before going live.
- Ensure all Price IDs in
.env.localmatch the products and intervals in Stripe. - Customize the
SubscriptionsPricingSectionUI to match your branding and layout. - Use the Stripe Customer Portal to simplify subscription management and reduce support overhead.