Indie Kit DocsIndie Kit Docs

LemonSqueezy Integration

Learn how to set up LemonSqueezy payments in your Indie Kit application

LemonSqueezy Integration 🍋

Let's set up LemonSqueezy payments for your Indie Kit application! 🚀

Initial Setup ⚡

  1. Create a LemonSqueezy account

  2. Set up your store details

  3. Add these environment variables to your .env file:

    # LemonSqueezy Configuration
    LEMON_SQUEEZY_API_KEY=your-api-key
    LEMON_SQUEEZY_STORE_ID=your-store-id
    LEMON_SQUEEZY_WEBHOOK_SECRET=your-webhook-secret
    

    🔒 Security Note: Never commit these keys to your repository. In production, add them securely to your hosting platform's environment variables.

Product Configuration 🛍️

In your LemonSqueezy Dashboard:

  1. Create Products with variants:

    • Monthly subscriptions
    • Yearly subscriptions
    • One-time payments
  2. For each product:

    • Set up pricing
    • Configure billing cycles
    • Add product descriptions
    • Set up trial periods (if needed)

Webhook Setup 🔌

  1. Add your webhook endpoint in LemonSqueezy Dashboard:

    https://your-domain.com/api/webhooks/lemonsqueezy
  2. Enable these webhook events:

    • subscription_created
    • subscription_updated
    • subscription_cancelled
    • subscription_resumed
    • order_created

Plan Mapping 🗺️

  1. Go to your super admin dashboard: /super-admin/plans
  2. For each plan, add the corresponding LemonSqueezy Product IDs:
    • monthlyLemonSqueezyProductId
    • yearlyLemonSqueezyProductId
    • onetimeLemonSqueezyProductId

💡 Tip: Find Product IDs in LemonSqueezy Dashboard under Products → Select Product → Variants

Adding Subscribe Buttons 🔘

Use the getSubscribeUrl helper to create subscription links:

import getSubscribeUrl, { PlanType, PlanProvider } from '@/lib/plans/getSubscribeUrl'
 
function PricingCard({ plan }) {
  // Monthly subscription with 7-day trial
  const monthlyUrl = getSubscribeUrl({
    codename: plan.codename,
    type: PlanType.MONTHLY,
    provider: PlanProvider.LEMON_SQUEEZY,
    trialPeriodDays: 7
  })
 
  // Yearly subscription with 14-day trial
  const yearlyUrl = getSubscribeUrl({
    codename: plan.codename,
    type: PlanType.YEARLY,
    provider: PlanProvider.LEMON_SQUEEZY,
    trialPeriodDays: 14
  })
 
  // One-time payment
  const onetimeUrl = getSubscribeUrl({
    codename: plan.codename,
    type: PlanType.ONETIME,
    provider: PlanProvider.LEMON_SQUEEZY
  })
 
  return (
    <div className="pricing-card">
      <h2>{plan.name}</h2>
      <div className="buttons">
        {plan.hasMonthlyPricing && (
          <Link href={monthlyUrl}>
            <Button>Subscribe Monthly</Button>
          </Link>
        )}
        {plan.hasYearlyPricing && (
          <Link href={yearlyUrl}>
            <Button>Subscribe Yearly</Button>
          </Link>
        )}
        {plan.hasOnetimePricing && (
          <Link href={onetimeUrl}>
            <Button>Buy Lifetime</Button>
          </Link>
        )}
      </div>
    </div>
  )
}

Features Available 🎯

  • 🔄 Automatic plan upgrades/downgrades
  • 💳 LemonSqueezy-managed billing
  • 🏪 Customer portal access
  • ⚡ Webhook handling
  • 🔍 Payment tracking
  • 📊 Usage monitoring

Best Practices 💡

  1. Testing

    • Use test mode in LemonSqueezy
    • Test all subscription flows
    • Verify webhook events
    • Test upgrade/downgrade paths
  2. Production

    • Configure proper webhook security
    • Monitor webhook events
    • Set up email notifications
    • Keep product IDs in sync
  3. Customer Experience

    • Clear pricing information
    • Smooth checkout flow
    • Easy access to billing portal
    • Clear trial period information

Advantages of LemonSqueezy 🌟

  • Simple setup process
  • Built-in EU VAT handling
  • Modern checkout experience
  • Lower transaction fees
  • Excellent developer experience
  • Quick payouts

Now your Indie Kit application is ready to accept payments and manage subscriptions through LemonSqueezy! 🎉

On this page