Payments
Multi-provider payment system (Stripe, LemonSqueezy) with subscription management. Automatically adapts to user-based or organization-based auth.
Installation
Install the Package
Add Payments to your project using the Tailar CLI:
Set Environment Variables
Create a `.env` file in the root of your project and add the following environment variables:
1# Stripe Configuration2STRIPE_SECRET_KEY=sk_test_...3STRIPE_WEBHOOK_SECRET=whsec_...4NEXT_PUBLIC_APP_URL=http://localhost:3000Preview
Explore representative UI flows and snippets generated for this module (same previews as on the home page modules section).
Choose a plan
Select the perfect plan for your needs
Solo
For developers building their own products.
One-time payment · Lifetime access
- 1 seat
- Unlimited projects
- All available modules
- UI Blocks
- Future updates included
- MIT. Code is yours, no attribution
- Creating on behalf of clients
Team
For small product teams. The foundation is generated and shared.
One-time payment · Lifetime access
- Everything in Solo
- Up to 5 developer seats
- Unlimited projects across all seats
- Consistent setup across the team
- Creating on behalf of clients
Agency
For agencies building on behalf of clients. Commercial use is explicit.
One-time payment · Lifetime access
- Everything in Team
- Unlimited seats for your whole studio
- Commercial use for client work
File Tree
The following files are installed when you add Payments:
1├─ app/2│ ├─ (protected)/3│ │ ├─ choose-plan/4│ │ │ └─ page.tsx5│ │ └─ (app)/6│ │ └─ settings/7│ │ └─ plan/8│ │ └─ page.tsx9│ ├─ api/10│ │ └─ stripe/11│ │ └─ webhook/12│ │ └─ route.ts13│ └─ payment/14│ └─ success/15│ └─ page.tsx16├─ components/17│ ├─ payments/18│ │ ├─ choose-plan-form.tsx19│ │ ├─ payment-card.tsx20│ │ ├─ payment-icons.tsx21│ │ ├─ plan-card.tsx22│ │ ├─ plan-settings-form.tsx23│ │ └─ price-card.tsx24│ └─ settings/25│ └─ setting-tabs.tsx26├─ lib/27│ ├─ auth/28│ │ └─ actions/29│ │ └─ deletion-rules.ts30│ └─ payments/31│ ├─ config.ts32│ ├─ types.ts33│ ├─ plans.ts34│ ├─ plan-tier.ts35│ ├─ index.ts36│ ├─ hooks.ts37│ └─ actions.ts38├─ messages/39│ ├─ en.json40│ ├─ es.json41│ └─ fr.json42└─ prisma/43 └─ schema/44 └─ payments.prismaUsage
Once you've installed Payments, you can start using the following actions:
getActivePrices
Get all active pricing plans from Stripe.
1import { getActivePrices } from '@/lib/payments'2 3const prices = await getActivePrices()getPrice
Get a specific price by ID from Stripe.
1import { getPrice } from '@/lib/payments'2 3const price = await getPrice(priceId)subscribeToPlan
Subscribe the current user/organization to a billing plan. Returns a redirect URL for paid plans or success status for free plans.
1import { subscribeToPlan } from '@/lib/payments'2 3const result = await subscribeToPlan(priceId)4if (result.status === 'redirect') {5 redirect(result.url)6}getSubscription
Get the current user's/organization's active subscription.
1import { getSubscription } from '@/lib/payments'2 3const subscription = await getSubscription()getSubscriptionDetails
Get detailed subscription information including payment method and billing period (organization-based only).
1import { getSubscriptionDetails } from '@/lib/payments'2 3const details = await getSubscriptionDetails()cancelSubscription
Cancel the current subscription. Access continues until the end of the billing period.
1import { cancelSubscription } from '@/lib/payments'2 3await cancelSubscription()usePaymentActions
React hook for payment operations in client components. Provides subscribe method and loading states.
1import { usePaymentActions } from '@/lib/payments/hooks'2 3function PlanCard() {4 const { subscribe, isLoading } = usePaymentActions()5 6 const handleSubscribe = async () => {7 await subscribe(priceId)8 }9}