Complete Guide to Pricing and Payment Module
Nexty.dev provides a complete SaaS pricing and payment solution built on the Stripe payment gateway and Supabase database. The code design follows SaaS product payment functionality best practices, supporting both one-time purchase and subscription payment models, with comprehensive user benefits management, credit system, and multi-language support.
Key Features
- ✅ Dual Payment Models: One-time purchase + Subscription
- ✅ Credit System: One-time credits + Subscription credits management
- ✅ Stripe Integration: Complete payment flow and Webhook handling
- ✅ Multi-language Support: Internationalization for pricing plans
- ✅ Admin Dashboard: Visual pricing plan management
- ✅ Benefits Management: Flexible user benefits configuration
- ✅ Refund Processing: Automated refunds and benefits recovery
Core Functionality
Pricing Plan Management
- Environment Isolation: Supports
test
andlive
environments, linked to Stripe environments to avoid data confusion - Multi-language Configuration: Multi-language support through
lang_jsonb
field with one-click translation - Benefits Definition: Default
one_time_credits
andmonthly_credits
fields as credit benefits, with free definition of plan benefits throughbenefits_jsonb
field - Display Control: Supports highlighting, sorting, and activation status control
- Real-time Preview: Real-time preview of card modifications with secure and controllable pricing card display content
Payment Flow
One-time Purchase Flow
Loading diagram...
Subscription Flow
Loading diagram...
Credit System
Nexty.dev's credit system provides the following out-of-the-box features:
- One-time Credits: Permanently valid after purchase, supports cumulative calculation
- Subscription Credits: Reset each billing cycle, allocated monthly/annually
- Deduction Strategy: Supports multiple deduction priority strategies
- Balance Management: Real-time balance queries and updates
For simple SaaS products, you can directly use the built-in logic. If you need a more complex credit system and processing logic, you can freely extend through the benefits_jsonb
field and develop corresponding logic according to subsequent tutorials.
Database Design
Core Table Structure
- pricing_plans - Pricing plans table
- Stores all pricing plan configurations
- Supports multi-language and benefits definition
- Environment isolation (test/live)
- orders - Orders table
- Records all payment transactions
- Supports multiple order types
- Complete payment information tracking
- subscriptions - Subscriptions table
- Syncs Stripe subscription status
- Subscription lifecycle management
- Billing cycle tracking
- usage - Usage table
- User credit balance management
- Supports multiple credit types
- Real-time balance updates
Key Components
Backend Components
lib/stripe/
- Stripe core processing logicactions/prices/
- Pricing plan managementactions/usage/
- Credit management
Frontend Components
components/home/Pricing.tsx
- Pricing displaycomponents/home/PricingCTA.tsx
- Purchase buttonapp/[locale]/(protected)/dashboard/(admin)/prices/
- Admin dashboardapp/[locale]/(protected)/dashboard/(user)/subscription/
- User subscription management