Skip to content

Integrate Stripe Payments for Pro Tier Upgrades #1

Description

@Sumedh-6504

Description

Implement Stripe subscription integration so that users can upgrade their account status from "free" to "pro" ($5/month) directly from the /plans page.

User Story

As a LexGuard Free user,
I want to upgrade my account to the Pro tier via a secure payment interface,
So that I can unlock unlimited analyses and full 3-agent worst-case scenarios.

Technical Tasks

  • Install @stripe/stripe-js on the Next.js frontend and stripe SDK on the backend.
  • Create a secure Next.js API endpoint /api/billing/checkout to generate a Stripe Checkout session.
  • Wire the "Upgrade to Pro" buttons on /plans to redirect the user to the Stripe Checkout page.
  • Create a robust Stripe webhook handler at /api/webhooks/stripe to handle events:
    • checkout.session.completed -> Update user plan to "pro" in Supabase.
    • customer.subscription.deleted -> Revert user plan to "free" in Supabase.
  • Store the customer's Stripe Customer ID in a new column on the users table to maintain billing history.

Database Updates

ALTER TABLE users ADD COLUMN IF NOT EXISTS stripe_customer_id TEXT;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions