Indie Kit DocsIndie Kit Docs
Tutorials

Create One-Time Payment

Learn how to implement one-time payments in your Indie Kit application

Create One-Time Payment 💰

Let's implement one-time payments in your Indie Kit application! 🚀

Prerequisites ✅

  1. Set up a payment gateway:

  2. Create a plan in the database:

    • Go to /super-admin/plans
    • Add plan details (name, features, quotas)
    • Enable one-time pricing (hasOnetimePricing: true)
    • Add one-time price ID from your payment gateway

Implementation 🛠️

Use the getSubscribeUrl helper with PlanType.ONETIME:

import getSubscribeUrl, { PlanType, PlanProvider } from '@/lib/plans/getSubscribeUrl'
 
// Example: One-time payment with Stripe
const stripeOneTimeUrl = getSubscribeUrl({
  codename: "lifetime",
  type: PlanType.ONETIME,
  provider: PlanProvider.STRIPE,
})
 
// Example: One-time payment with LemonSqueezy
const lemonOneTimeUrl = getSubscribeUrl({
  codename: "lifetime",
  type: PlanType.ONETIME,
  provider: PlanProvider.LEMON_SQUEEZY,
})

Usage Example 📝

Here's a complete example of a one-time payment button component:

function LifetimeAccessButton({ plan }) {
  if (!plan.hasOnetimePricing) return null;
 
  return (
    <div className="pricing-card">
      <h2>{plan.name}</h2>
      <p className="text-xl font-bold">
        ${plan.onetimePrice / 100} - Lifetime Access
      </p>
      
      <Link
        href={getSubscribeUrl({
          codename: plan.codename,
          type: PlanType.ONETIME,
          provider: PlanProvider.STRIPE,
        })}
      >
        <Button className="w-full">
          Buy Lifetime Access
        </Button>
      </Link>
      
      <p className="text-sm text-muted-foreground mt-2">
        One-time payment, lifetime access
      </p>
    </div>
  )
}

Best Practices 💡

  1. Plan Configuration

    • Set appropriate lifetime value
    • Keep price competitive with subscription
    • Clear feature list
    • Proper price ID mapping
  2. User Experience

    • Clear pricing display
    • Highlight lifetime value
    • Show feature comparison
    • Clear payment process
  3. Testing

    • Test payment flow
    • Verify access after payment
    • Check webhook handling
    • Test with both payment gateways

Common Use Cases 🎯

  • Lifetime access to software
  • Digital product sales
  • Course access
  • Premium features unlock

Now you can implement one-time payments in your Indie Kit application! 🎉

On this page