Skip to main content

Stripe Configuration

CleverThis uses Stripe for payment processing: credit top-ups, customer portal sessions, and webhook-driven balance updates. You need a Stripe account and three configuration values.

1. Create a Stripe account

Go to stripe.com and create an account. Activate your account to access live mode keys. Use test mode keys (sk_test_...) during initial setup.

2. Get your API keys

From the Stripe Dashboard → Developers → API Keys:

  • Copy the Secret key (sk_live_... or sk_test_...) → set as STRIPE_SECRET_KEY
  • Copy the Publishable key (pk_live_... or pk_test_...) → set as STRIPE_PUBLISHABLE_KEY

3. Configure the webhook

CleverThis needs to receive Stripe webhook events to process completed payments and update wallet balances.

  1. In the Stripe Dashboard → Developers → Webhooks, click Add endpoint.
  2. Set the endpoint URL to: https://your-domain.com/api/billing/stripe/webhook
  3. Select the following events to listen for:
    • checkout.session.completed
    • customer.subscription.deleted
    • invoice.payment_succeeded
    • invoice.payment_failed
  4. Click Add endpoint, then reveal the Signing secret → set as STRIPE_WEBHOOK_SECRET.

4. Set environment variables

STRIPE_SECRET_KEY=sk_live_...
STRIPE_PUBLISHABLE_KEY=pk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...

Testing webhooks locally

Use the Stripe CLI to forward webhooks to your local dev server:

stripe listen --forward-to localhost:8000/api/billing/stripe/webhook

The CLI prints a temporary webhook signing secret to use for local development.

Coming soon

Subscription-based plan tier management (Pro, Enterprise plans billed via Stripe subscriptions) is being added.