Menu

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 and live 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 and monthly_credits fields as credit benefits, with free definition of plan benefits through benefits_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

  1. pricing_plans - Pricing plans table
  • Stores all pricing plan configurations
  • Supports multi-language and benefits definition
  • Environment isolation (test/live)
  1. orders - Orders table
  • Records all payment transactions
  • Supports multiple order types
  • Complete payment information tracking
  1. subscriptions - Subscriptions table
  • Syncs Stripe subscription status
  • Subscription lifecycle management
  • Billing cycle tracking
  1. usage - Usage table
  • User credit balance management
  • Supports multiple credit types
  • Real-time balance updates

Key Components

Backend Components

  • lib/stripe/ - Stripe core processing logic
  • actions/prices/ - Pricing plan management
  • actions/usage/ - Credit management

Frontend Components

  • components/home/Pricing.tsx - Pricing display
  • components/home/PricingCTA.tsx - Purchase button
  • app/[locale]/(protected)/dashboard/(admin)/prices/ - Admin dashboard
  • app/[locale]/(protected)/dashboard/(user)/subscription/ - User subscription management