Stripe Subscriptions

    One time payment flow or you can use our subscription

    Let's create a Stripe Checkout to set up a subscription and let our webhook handle the logic to provision access to the user.

    You need to have Stripe and a database set up.
    Setup
    1. In yourStripe dashboard, Click [More +] > [Product Catalog] > [+ Add Product]. Set a name and a monthly price (or anything according to your business model). Then click [Save Product].
    2. In the [Pricing] section, copy the product price ID (starts withprice_) and add it to the first plan in thedata.pricing_card.priceIdarraycomponents/Pricing.tsxandconfig.ts
    3. In /components/PricingSection.tsx, change the price ID to the one you copied in step 2:

    /components/PricingSection.tsx

  1. 'use client';
  2. import { Check } from 'lucide-react';
  3. import CheckoutButton from './CheckoutButton';
  4. export default function PricingSection() {
  5. return (
  6. <section className="py-16 bg-gray-50">
  7. <div className="container mx-auto px-4">
  8. <div className="grid md:grid-cols-2 gap-8 max-w-4xl mx-auto">
  9. {/* Monthly Plan */}
  10. <div className="bg-white rounded-lg shadow-md p-8">
  11. <CheckoutButton priceId="YOUR_PRICE_ID" />
  12. </div>
  13. {/* Annual Plan */}
  14. <div className="bg-white rounded-lg shadow-md p-8 border-4 border-blue-500 relative">
  15. <CheckoutButton priceId="YOUR_PRICE_ID" />
  16. </div>
  17. </div>
  18. </div>
  19. </section>
  20. );
  21. }
  22. 4. In /config.ts, change the price ID to the one you copied in step 2 and the product ID to the one you copied in step 1:

    /config.ts

  23. products: [
  24. {
  25. type: 'subscription',
  26. period: 'month',
  27. title: 'Month',
  28. productId: 'YOUR_PRODUCT_ID',
  29. subtitle: 'Per month price',
  30. price: 25,
  31. isBest: true,
  32. linkTitle: 'PAY MOTHERFUCKER',
  33. featuresTitle: 'Features',
  34. priceId: 'YOUR_PRICE_ID',
  35. features: [
  36. {
  37. title: 'Feature 1',
  38. disabled: false,
  39. },
  40. {
  41. title: 'Feature 2',
  42. disabled: true,
  43. },
  44. ],
  45. },
  46. {
  47. type: 'subscription',
  48. period: 'year',
  49. productId: 'YOUR_PRODUCT_ID',
  50. title: 'Year',
  51. subtitle: 'Per year price',
  52. price: 25,
  53. linkTitle: 'PAY MOTHERFUCKER YEAR',
  54. featuresTitle: 'Features VIP',
  55. priceId: 'YOUR_PRICE_ID',
  56. features: [
  57. {
  58. title: 'Feature 1',
  59. disabled: false,
  60. },
  61. {
  62. title: 'Feature 2',
  63. disabled: false,
  64. },
  65. ],
  66. },
  67. ],
  68. 5. Open http://localhost:3000/dashboardin your browser, log-in and click the button to make a payment with the credit card number 4242 4242 4242 4242.
    You need to have aStripe local endpointrunning on your computer for this to work in dev mode.
    6. You can add your own logic in/api/webhook/stripe/route.ts like sending abandoned cart emails, remove credits, etc.