Documentation

Stripe

Stripe is a leading global online payment platform supporting 100+ payment methods, subscription billing, and fraud protection

Quick Start

Create a Stripe Account

Go to Stripe and sign up for an account.

Get API Keys

  1. Open the Stripe Dashboard, click DevelopersAPI Keys Stripe API Keys
  2. Create a key Stripe Create API
  3. Copy the keys to .env Stripe Create API
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_xxx
STRIPE_SECRET_KEY=sk_test_xxx

You can also enter them in the admin config panel: Stripe API Keys

Warning

STRIPE_SECRET_KEY is sensitive information — do not commit it to your code repository.

Configure Webhook

Stripe Create Webhook Listen for the following events:

  • checkout.session.completed
  • invoice.payment_succeeded
  • invoice.payment_failed
  • customer.subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted Stripe Webhook Events Enter your callback URL:
https://your-domain.com/api/payment/webhook/stripe

Stripe Webhook Path

Copy the Webhook Secret to .env, or configure it in the admin panel: Stripe Webhook Secret

STRIPE_WEBHOOK_SECRET=whsec_xxx

For local development, use sandbox mode — see below.

Sandbox Mode

Used for local testing — no real charges are made.

Stripe Sandbox

  1. Switch to Test Mode in the Dashboard and get the test environment's Publishable Key and Secret Key
  2. Download the Stripe CLI and start local forwarding:
stripe listen --forward-to localhost:3377/api/payment/webhook/stripe
  1. Copy the Webhook Secret from the terminal output to .env, or configure it in the admin panel: Stripe Webhook Secret
STRIPE_WEBHOOK_SECRET=whsec_xxx

Once configured, you can test payments locally using test cards: Stripe Test Cards

Testing Live Payments with a Reverse Proxy

Visit Ngrok

Go to Ngrok and sign up for an account

Download and Configure Ngrok

Follow the official setup guide to download and configure Ngrok

Start Ngrok

ngrok http 3377

Copy the public URL from the terminal output Ngrok Public URL Your callback URL will be:

https://xxx.app/api/payment/webhook/stripe

Warning

Do not use ngrok in production. The public URL changes each time ngrok restarts — you'll need to update the callback URL. For a static URL, get a fixed domain from ngrok and use --url= to specify it.

Verify Configuration

Open the homepage, scroll down to the pricing section, and click the purchase button. If it redirects to the Stripe Checkout page, the configuration is successful. Pricing

Configure Pricing

  1. Create a Product in the Stripe Dashboard and add a Price Stripe Product

  2. Copy the Price ID (format price_xxx) to .env Stripe Price

  3. Copy the Price ID (format price_xxx) to .env. You can rename the environment variables as needed, but they must match the code:

VITE_STRIPE_PRO_MONTHLY_PRICE_ID=price_xxx
VITE_STRIPE_PRO_YEARLY_PRICE_ID=price_xxx
VITE_STRIPE_LIFETIME_PRICE_ID=price_xxx
  1. Modify src/config/payment-config.ts — amounts and intervals must match the Stripe Dashboard:
export const paymentConfig: PlanWithPrice[] = [
  {
    id: "pro",                    // Plan identifier, used in code
    planType: "subscription",     // free | subscription | lifetime
    credit: {
      amount: 100,                // Credits granted per payment
      expireDays: 31,             // Credit expiration days
    },
    prices: [
      {
        priceId: import.meta.env.VITE_STRIPE_PRO_MONTHLY_PRICE_ID!,
        amount: 990,              // In cents, 990 = $9.90
        currency,                 // Currency, read from VITE_CURRENCY
        interval: "month",        // month | year
        trialPeriodDays: 7,       // Trial days (optional)
      },
      {
        priceId: import.meta.env.VITE_STRIPE_PRO_YEARLY_PRICE_ID!,
        amount: 9900,
        currency,
        interval: "year",
      },
    ],
    display: {
      isRecommended: true,        // Show "Recommended" label
      group: "subscription",      // Group, used for UI display
    },
  },
  {
    id: "lifetime",
    planType: "lifetime",         // One-time purchase
    prices: [
      {
        priceId: import.meta.env.VITE_STRIPE_LIFETIME_PRICE_ID!,
        amount: 19900,
        currency,
      },
    ],
    display: {
      originalPrice: 29900,       // Original price (strikethrough)
      group: "one-time",
    },
  },
]

Field Reference

FieldDescription
idPlan identifier, used to look up the plan in code
planTypefree / subscription / lifetime
credit.amountCredits granted when subscription activates
credit.expireDaysCredit expiration days, omit for no expiration
priceIdStripe Price ID, copied from Dashboard
amountPrice in cents, 990 = $9.90
intervalBilling cycle, month or year
trialPeriodDaysFree trial days
display.isRecommendedWhether to show the recommended label
display.originalPriceOriginal price for strikethrough display
display.groupGroup identifier for UI categorization

On this page