Multi-Provider Architecture
ShipFree implements a unified payment adapter pattern that provides a consistent interface across all payment providers. This means you can switch providers or support multiple providers without rewriting your application logic.How It Works
All payment operations go through a centralPaymentAdapter interface defined in src/lib/payments/types.ts. Each provider (Stripe, Polar, Lemon Squeezy) implements this interface:
PAYMENT_PROVIDER environment variable and accessed through getPaymentAdapter() in src/lib/payments/service.ts.
Payment Plans
ShipFree comes with four pre-configured pricing tiers defined insrc/config/payments.ts:
Free Plan
- Price: $0
- Features:
- Up to 3 projects
- Basic analytics
- Community support
- Standard templates
Starter Plan
- Price: 99/year
- Trial: 14 days
- Features:
- Up to 10 projects
- Advanced analytics
- Email support
- Premium templates
- Custom integrations
Pro Plan (Recommended)
- Price: 299/year
- Trial: 14 days
- Seat-based: Yes (up to 50 seats)
- Features:
- Unlimited projects
- Real-time analytics
- Priority support
- White-label options
- Advanced integrations
- Team collaboration
- Custom workflows
Enterprise Plan
- Price: 999/year
- Trial: 30 days
- Seat-based: Yes (unlimited seats)
- Features:
- Everything in Pro
- Dedicated account manager
- Custom contracts
- SLA guarantees
- Advanced security
- Unlimited seats
- Custom integrations
- On-premise deployment
Customizing Plans
To modify the pricing plans, editsrc/config/payments.ts:
Choosing a Payment Provider
Stripe
Best for: Established businesses, global markets, maximum flexibility Pros:- Industry standard with extensive documentation
- Powerful billing portal for customers
- Advanced features (metered billing, usage-based pricing)
- Excellent fraud protection
- Global payment methods
- Higher fees (2.9% + $0.30 per transaction)
- More complex setup
- Requires careful webhook handling
Polar
Best for: Developer tools, open-source projects, GitHub-integrated products Pros:- Built for developers selling to developers
- GitHub integration
- Simple pricing
- Modern API
- Developer-friendly portal
- Newer platform (less mature than Stripe)
- Limited payment methods compared to Stripe
- Smaller ecosystem
Lemon Squeezy
Best for: Digital products, SaaS, indie hackers, simplified tax handling Pros:- Merchant of Record (handles VAT/sales tax for you)
- Simple setup and pricing
- Great for digital products
- No need for business entity in multiple countries
- Built-in fraud protection
- Higher fees (5% + payment processing)
- Less customization than Stripe
- Merchant of Record means they’re the seller (legal implications)
Common Patterns
Creating a Checkout Session
Opening Customer Portal
Checking Subscription Status
Client-Side React Hooks
ShipFree provides React hooks for common payment operations:Webhooks
All payment providers send webhooks to notify your application of events (subscription created, payment succeeded, etc.). Webhook endpoint:POST /api/webhooks/payments
The webhook handler in src/app/api/webhooks/payments/route.ts:
- Validates the webhook signature
- Processes the event through the adapter
- Updates the database (customers, subscriptions, payments)
Database Schema
Payment data is stored in three main tables:Customers
Stores customer records linked to users:Subscriptions
Stores subscription information:Payments
Stores individual payment records:Next Steps
- Choose your payment provider
- Set up your provider account and get API keys
- Configure webhooks
- Test in development mode
- Go live!