Stripe Setup Guide
A step-by-step guide to configuring your Stripe account for AInstein.
This guide provides comprehensive instructions for setting up your Stripe Dashboard to work seamlessly with the AInstein subscription system. Following these steps will ensure that all products, prices, webhooks, and features are correctly configured.
Step 1: Create Products and Prices
First, you need to define your subscription plans and any add-ons as products in Stripe. Each product will have one or more prices associated with it (e.g., monthly and yearly).
Lookup Keys are Essential: The AInstein backend uses these lookup keys to identify prices. Ensure they are unique and match the configuration in your code.
Step 2: Configure Webhooks
Webhooks are essential for Stripe to communicate real-time events (like successful payments or cancellations) back to your application.
- In your Stripe Dashboard, go to Developers → Webhooks.
- Click + Add endpoint.
- Set the Endpoint URL to
https://<your-domain>/api/stripe/webhooks. - Click + Select events and add the following:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
- After creating the endpoint, find the Signing secret and copy it.
- Add this secret to your environment variables as
STRIPE_WEBHOOK_SECRET.
Step 3: Set Up Stripe Connect (for Resellers)
If you plan to support resellers or affiliates who earn a commission, you must configure Stripe Connect.
- Go to the Connect section in your Stripe Dashboard and complete the platform profile setup.
- Choose the Express account type for a streamlined onboarding experience for your resellers.
- In your Connect settings, you can configure details like application fees and branding.
Step 4: Configure the Customer Portal
The Stripe Customer Portal allows your users to manage their subscriptions, update payment methods, and view their invoice history without requiring you to build a custom interface.
- Go to Billing → Customer portal.
- Activate and configure the portal with your branding.
- Enable the actions you want to allow, such as:
- Updating subscriptions (upgrading/downgrading plans).
- Canceling subscriptions.
- Updating payment methods.
- Viewing invoice history.
Step 5: Get Price IDs for Environment
Your application needs the specific Price IDs from Stripe to create checkout sessions.
- Navigate to the Products section.
- For each product, you will see a list of associated prices.
- Copy the ID for each price (it will start with
price_...). - Add these IDs to your application's environment variables, mapping them to descriptive names, for example:
# Base Plans - Monthly NEXT_PUBLIC_PRICE_GROWTH_MONTHLY=price_1P... # Base Plans - Yearly NEXT_PUBLIC_PRICE_GROWTH_YEARLY=price_1P... # Add-ons - Monthly NEXT_PUBLIC_PRICE_MULTILINGUAL_MONTHLY=price_1P...
Step 6: Test Your Integration
Always test your integration thoroughly in Test mode before going live.
Use Test Cards
Stripe provides a set of test card numbers to simulate various payment scenarios, including successful payments and failures.
Verify Webhook Events
Use the Events tab in the Stripe Dashboard to monitor incoming webhook events and ensure your application is processing them correctly.
Once you have completed and tested these steps, you can switch to Live mode and repeat the process with your live API keys and product information.