Stripe is Lovable's only natively supported payment processor. Connect it via Settings → Connectors → Shared connectors, add your API keys in Cloud → Secrets, then describe the payment features you need in chat. Lovable auto-generates Edge Functions, database tables with RLS policies, and checkout UI — no manual wiring required. Note: Stripe features only work in deployed mode, not in Lovable's preview.
Stripe is the only payment processor with chat-driven setup in Lovable
Of all 17 shared connectors available in Lovable, Stripe is the only payment processor with a fully AI-assisted setup flow. When Stripe is active, Lovable's AI understands Stripe's API, pricing model, and database requirements well enough to generate complete payment features from a single sentence. Describing 'add three subscription tiers — Basic, Pro, and Enterprise' triggers Lovable to create Stripe price objects in your dashboard, generate Edge Functions for checkout session creation and webhook handling, build database tables with proper RLS policies for tracking purchases and subscriptions, and wire up the checkout UI — all automatically.
This stands in contrast to other payment processors like PayPal or Square, which have no shared connector and require manually building every piece: Edge Functions, webhook verification, database schema, and UI — with no AI-assisted scaffolding. The practical difference is setup time: Stripe goes from zero to working checkout in about 15 minutes; other processors typically take several hours and are reported as a common pain point in the Lovable community.
One important constraint to understand upfront: Stripe only works in deployed mode. Lovable's preview panel runs inside an iframe environment that cannot complete Stripe checkout flows. You need to deploy your app first (via the Publish button or GitHub integration), then test payment flows on the live URL. This is not a limitation of your code — it is a deliberate browser security restriction around how Stripe's JavaScript loads in cross-origin iframes. Plan your testing workflow around the deployed URL rather than the preview panel.
Integration method
Stripe is a Lovable shared connector — activated once in Settings → Connectors, it gives the AI full context to auto-generate Edge Functions, database tables, RLS policies, and payment UI from plain-language prompts.
Prerequisites
- A Lovable account with at least one project created
- A Stripe account (free to create at stripe.com — no upfront fees)
- Your Stripe publishable key and secret key from the Stripe Dashboard → Developers → API keys
- Your Stripe webhook signing secret (created after you add a webhook endpoint in Stripe Dashboard)
- A deployed Lovable app URL for testing (Stripe will not work in Lovable's preview mode)
Step-by-step guide
Activate the Stripe shared connector
Activate the Stripe shared connector
The first step is enabling Stripe as a shared connector in your Lovable workspace. Shared connectors are workspace-level integrations, meaning once you activate Stripe here, it becomes available across all projects in your workspace and all workspace members can use it. To activate the connector, open your Lovable project and click the Settings icon in the top-right corner of the editor. In the Settings panel, navigate to Connectors → Shared connectors. You will see a list of all available connectors. Find Stripe in the Payment category and click the toggle or 'Connect' button next to it. Lovable will display a prompt asking you to confirm activation. Click 'Enable'. At this point, the Stripe connector is active but not yet configured with your API credentials — that happens in the next step via Cloud → Secrets. Activating the connector tells Lovable's AI that Stripe is in scope for this workspace, which unlocks AI-assisted Stripe code generation. Without the connector activated, Lovable will not suggest Stripe-specific patterns or auto-generate Stripe Edge Functions when you describe payment features. If you are on a team workspace, note that connectors are workspace-wide settings, not per-project. Any team member with workspace admin access can activate or deactivate connectors. Non-admin members can use active connectors but cannot change connector settings.
Expected result: The Stripe connector shows as active (green toggle or checkmark) in Settings → Connectors → Shared connectors. No API keys are stored yet — that happens in the next step.
Add your Stripe API keys in Cloud → Secrets
Add your Stripe API keys in Cloud → Secrets
With the connector activated, the next step is storing your Stripe API keys securely in Lovable's Cloud Secrets panel. Secrets are encrypted environment variables accessible only from Edge Functions — they are never exposed to client-side code, never stored in your GitHub repository, and never visible in Lovable's chat history. To access the Secrets panel, click the '+' icon at the top of the editor next to the Preview label. This opens a panel with multiple tabs including Database, Auth, Storage, Edge Functions, AI, Secrets, Logs, and Usage. Click the Secrets tab. Click 'Add new secret' and add the following secrets one at a time: - Name: STRIPE_SECRET_KEY — Value: your Stripe secret key (starts with sk_test_ for test mode or sk_live_ for production) - Name: STRIPE_PUBLISHABLE_KEY — Value: your Stripe publishable key (starts with pk_test_ or pk_live_) - Name: STRIPE_WEBHOOK_SECRET — Value: your webhook signing secret (starts with whsec_ — you will generate this in Step 4) You can find your Stripe API keys in the Stripe Dashboard at Dashboard → Developers → API Keys. Start with test mode keys (sk_test_ / pk_test_) while building — switch to live keys only when you are ready to accept real payments. Critical: Never paste API keys directly into Lovable's chat prompt. On the free tier, Lovable chat history is publicly visible. Even on paid tiers, keys pasted in chat can end up in your Git commit history where they are recoverable. Always use the Secrets panel for credential storage. Lovable's security system blocks approximately 1,200 hardcoded API keys per day, but the safest approach is to never give the system a chance to catch the mistake.
Expected result: Three secrets — STRIPE_SECRET_KEY, STRIPE_PUBLISHABLE_KEY, and STRIPE_WEBHOOK_SECRET — appear in the Cloud → Secrets panel with masked values. Lovable Edge Functions can now access these credentials via Deno.env.get('STRIPE_SECRET_KEY').
Generate your payment features using Lovable's chat
Generate your payment features using Lovable's chat
Now that Stripe is connected and credentials are stored, you can describe the payment features you need in Lovable's chat and let the AI handle the implementation. This is where the native connector's advantage over manual integration becomes clear — the AI generates Edge Functions, database tables, RLS policies, and UI components as a single coordinated unit, not as separate pieces you wire together. The key to effective prompting is specificity. Instead of saying 'add payments', describe exactly what your business model looks like. Lovable will interpret your pricing model and generate the correct Stripe configuration, database schema to track customers and purchases, and UI components for checkout. For a subscription-based SaaS product, paste this prompt into Lovable's chat: 'Add Stripe subscription billing with three plans: Basic at $9/month (up to 5 projects), Pro at $29/month (up to 25 projects), and Enterprise at $99/month (unlimited projects). Generate a pricing page with a plan comparison table and Stripe Checkout buttons for each tier. After a successful payment, update the user's subscription status in the database and redirect them to the dashboard. Also add a billing portal link so users can manage or cancel their subscription.' For a one-time payment or digital product sale, use a prompt like: 'Add a Stripe checkout button that charges $49 for a lifetime license to my app. After successful payment, mark the user as a paid customer in the database and unlock the premium features. Show a success page after checkout completes.' Lovable will generate: a Stripe checkout session Edge Function, a webhook handler Edge Function for payment confirmation, database columns or a purchases table to record transactions, RLS policies so users can only see their own purchase records, and React components for the pricing UI and post-payment flow. Review the generated code in the Code panel before deploying — check that the price amounts match your intent and the database schema aligns with your existing tables.
Add Stripe subscription billing with three plans: Basic at $9/month (up to 5 projects), Pro at $29/month (up to 25 projects), and Enterprise at $99/month (unlimited projects). Generate a pricing page with a plan comparison table and Stripe Checkout buttons for each tier. After a successful payment, update the user's subscription status in the database and redirect them to the dashboard. Also add a billing portal link so users can manage or cancel their subscription.
Paste this in Lovable chat
Expected result: Lovable generates a pricing page component, at least two Edge Functions (one for creating checkout sessions, one for webhook handling), and a subscriptions or purchases table in the database. The Code panel shows the new files. The AI may ask you to confirm the database schema if it needs to create new tables.
Register your webhook endpoint in Stripe Dashboard
Register your webhook endpoint in Stripe Dashboard
Stripe webhooks are how your app learns about events that happen outside the user's browser session — payment completions, subscription renewals, cancellation requests, and failed charges. Lovable generates a webhook handler Edge Function automatically, but you must register the endpoint URL in your Stripe Dashboard so Stripe knows where to send events. First, deploy your Lovable app if you have not already. Click the Publish button in the top-right corner of the Lovable editor. Once deployed, your app has a live URL like https://your-app-name.lovable.app. Your webhook endpoint will follow the pattern: https://your-app-name.lovable.app/functions/v1/stripe-webhook (the exact path is visible in the generated Edge Function code in the Code panel). Next, go to your Stripe Dashboard at dashboard.stripe.com. Navigate to Developers → Webhooks → Add endpoint. Enter your webhook endpoint URL. Under 'Select events to listen to', choose the events relevant to your use case. For subscriptions, select: checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.payment_succeeded, invoice.payment_failed. For one-time payments, select: checkout.session.completed, payment_intent.succeeded. Click 'Add endpoint'. Stripe will generate a webhook signing secret (starts with whsec_). Copy this value and go back to Lovable Cloud → Secrets. Update the STRIPE_WEBHOOK_SECRET value with this signing secret. The generated Edge Function uses constructEventAsync() — the async webhook verification method required by Deno. This is different from the constructEvent() method used in Node.js environments. If you review the generated code and see constructEvent() (synchronous), prompt Lovable to fix it: 'Update the Stripe webhook handler to use constructEventAsync() instead of constructEvent() — the Deno runtime requires the async version for webhook signature verification.'
Update the Stripe webhook handler to use constructEventAsync() instead of constructEvent() — the Deno runtime requires the async version for webhook signature verification.
Paste this in Lovable chat
1// supabase/functions/stripe-webhook/index.ts2import Stripe from 'https://esm.sh/stripe@14?target=deno';3import { createClient } from 'https://esm.sh/@supabase/supabase-js@2';45const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!, {6 apiVersion: '2023-10-16',7 httpClient: Stripe.createFetchHttpClient(),8});910Deno.serve(async (req) => {11 const signature = req.headers.get('stripe-signature');12 const body = await req.text();13 const webhookSecret = Deno.env.get('STRIPE_WEBHOOK_SECRET')!;1415 let event: Stripe.Event;16 try {17 // Deno requires the async version — constructEvent() will fail18 event = await stripe.webhooks.constructEventAsync(body, signature!, webhookSecret);19 } catch (err) {20 return new Response(`Webhook signature verification failed: ${err.message}`, { status: 400 });21 }2223 const supabase = createClient(24 Deno.env.get('SUPABASE_URL')!,25 Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!26 );2728 if (event.type === 'checkout.session.completed') {29 const session = event.data.object as Stripe.Checkout.Session;30 const customerId = session.customer as string;31 const subscriptionId = session.subscription as string;3233 await supabase34 .from('subscriptions')35 .upsert({36 stripe_customer_id: customerId,37 stripe_subscription_id: subscriptionId,38 status: 'active',39 updated_at: new Date().toISOString(),40 }, { onConflict: 'stripe_customer_id' });41 }4243 return new Response(JSON.stringify({ received: true }), {44 headers: { 'Content-Type': 'application/json' },45 });46});Expected result: The webhook endpoint is registered in Stripe Dashboard and shows as active. The STRIPE_WEBHOOK_SECRET is updated in Cloud → Secrets. In Stripe Dashboard you can click 'Send test webhook' to verify the endpoint responds with a 200 status.
Deploy and test your Stripe integration
Deploy and test your Stripe integration
Stripe integration cannot be tested in Lovable's preview panel — the preview runs inside an iframe environment, and Stripe's JavaScript intentionally blocks loading in cross-origin iframes for security reasons. This is a browser security constraint, not a bug in your code. All Stripe testing must happen on your deployed app URL. If you have not deployed yet, click the Publish button in the top-right corner of the Lovable editor. Wait for the deployment to complete (typically 30–60 seconds). Your live app URL will be shown — it follows the pattern https://your-app-name.lovable.app. Open the deployed URL in a new browser tab. Navigate to the pricing page or checkout flow you generated. Click a checkout button. Stripe's hosted checkout page should open. Use Stripe's test card number 4242 4242 4242 4242 with any future expiry date and any 3-digit CVC. Enter any billing address. Click 'Subscribe' or 'Pay'. You should be redirected to your success page. To verify the webhook fired correctly, go to Stripe Dashboard → Developers → Webhooks → your endpoint → Recent deliveries. You should see a checkout.session.completed event with a green 200 status. Then check your Lovable database by opening Cloud → Database in the Cloud tab and looking at the subscriptions or purchases table — the new record should appear with the customer's details. If the webhook shows as delivered in Stripe but the database was not updated, check Cloud → Logs in the Cloud tab for Edge Function error messages. Common causes are a mismatched STRIPE_WEBHOOK_SECRET value or a code error in the webhook handler. Use Lovable's 'Try to fix' button on any error message — it reads the logs automatically and resolves roughly 60% of issues without consuming credits.
The Stripe checkout is working but the database is not updating after payment. Check the stripe-webhook Edge Function logs and fix any errors. Make sure the webhook handler correctly updates the subscriptions table when a checkout.session.completed event fires.
Paste this in Lovable chat
Expected result: Clicking a checkout button on the deployed URL opens Stripe's hosted checkout page. After entering test card details, you are redirected to your success page. The Stripe Dashboard shows the webhook delivered successfully (green 200). The database contains a new subscription or purchase record.
Common use cases
Generate your payment features using Lovable's chat
Use Stripe with Lovable to generate your payment features using lovable's chat. This is one of the most common use cases when integrating Stripe into your Lovable application.
Add Stripe subscription billing with three plans: Basic at $9/month (up to 5 projects), Pro at $29/month (up to 25 projects), and Enterprise at $99/month (unlimited projects). Generate a pricing page with a plan comparison table and Stripe Checkout buttons for each tier. After a successful payment, update the user's subscription status in the database and redirect them to the dashboard. Also add a billing portal link so users can manage or cancel their subscription.
Copy this prompt to try it in Lovable
Register your webhook endpoint in Stripe Dashboard
Take your Stripe integration further by register your webhook endpoint in stripe dashboard. This builds on the basic setup to create a more complete experience.
Update the Stripe webhook handler to use constructEventAsync() instead of constructEvent() — the Deno runtime requires the async version for webhook signature verification.
Copy this prompt to try it in Lovable
Deploy and test your Stripe integration
Prepare your Stripe integration for production by deploy and test your stripe integration. Ensures your integration works reliably for real users.
The Stripe checkout is working but the database is not updating after payment. Check the stripe-webhook Edge Function logs and fix any errors. Make sure the webhook handler correctly updates the subscriptions table when a checkout.session.completed event fires.
Copy this prompt to try it in Lovable
Troubleshooting
Stripe checkout button does nothing or shows an error in the preview panel
Cause: Stripe's JavaScript is intentionally blocked from running inside cross-origin iframes, which is exactly how Lovable's preview panel works. This is a browser security restriction, not a code error.
Solution: Deploy your app using the Publish button in the top-right corner of the Lovable editor, then test using your live URL (https://your-app-name.lovable.app). Stripe will always work on the deployed URL. Do not attempt to debug Stripe flows in the preview panel — the behavior there is not representative of your actual application.
Webhook events show 400 error in Stripe Dashboard with message 'Webhook signature verification failed'
Cause: Two common causes: (1) the STRIPE_WEBHOOK_SECRET in Cloud → Secrets does not match the signing secret shown in Stripe Dashboard for that endpoint, or (2) the webhook handler uses the synchronous constructEvent() instead of the async constructEventAsync() required by Deno.
Solution: First, verify the webhook secret. Go to Stripe Dashboard → Developers → Webhooks → your endpoint → Signing secret → Reveal. Copy the value exactly (including the whsec_ prefix) and update STRIPE_WEBHOOK_SECRET in Cloud → Secrets. Second, check the Edge Function code in the Code panel and confirm it uses await stripe.webhooks.constructEventAsync() — not constructEvent(). If it uses the synchronous version, prompt Lovable: 'Update the Stripe webhook handler to use constructEventAsync() instead of constructEvent().' Redeploy after making changes.
Checkout session creation fails with error 'No such price: price_xxx' or the wrong amount is charged
Cause: Lovable may have generated hardcoded test price IDs that do not exist in your Stripe account, or the generated code references environment variable names for price IDs that have not been set in Cloud → Secrets.
Solution: Go to Stripe Dashboard → Products and check whether the products and prices Lovable generated actually exist. If not, either create them manually in Stripe Dashboard and update your code with the correct price IDs, or prompt Lovable: 'Recreate the Stripe products and prices for my three subscription tiers and update the checkout Edge Function to use the correct price IDs from my Stripe account.' Then add any required STRIPE_PRICE_* secret values in Cloud → Secrets.
Best practices
- Always use test mode keys (sk_test_ / pk_test_) during development — switch to live keys only when you are ready to accept real money. Keep both sets of keys in Cloud → Secrets under different names like STRIPE_SECRET_KEY_TEST and STRIPE_SECRET_KEY.
- Store all Stripe API keys and webhook secrets in Cloud → Secrets, not in your source code or Lovable chat. Never paste an sk_live_ key anywhere visible — Lovable's free tier chat history is publicly accessible.
- Register your webhook endpoint in Stripe Dashboard for the specific events your app needs. Avoid subscribing to all events — each unnecessary webhook delivery is a request your Edge Function must handle and log.
- Use constructEventAsync() in every Stripe webhook handler. The Deno runtime used by Lovable Edge Functions requires the async version of webhook signature verification. The synchronous constructEvent() will either throw or silently fail on Deno.
- Test your full payment flow on the deployed URL before sharing with users. Stripe cannot be tested in Lovable's preview panel. Create a simple test checklist: checkout opens, test card is accepted, success redirect works, webhook fires, database updates.
- Separate your Stripe customer ID from your app user ID in the database. Store both: the Stripe customer ID (cus_xxx) and your internal user ID on the subscription record. This makes it easy to look up a user's subscription status from either direction.
- Set up Stripe's billing portal for subscription management instead of building a custom cancellation flow. Prompt Lovable: 'Add a link to Stripe's customer billing portal so users can manage, upgrade, or cancel their subscription without leaving the app.' Lovable will generate the portal session Edge Function automatically.
- Review the auto-generated RLS policies on your subscriptions and purchases tables before going live. Lovable creates them automatically, but verify that users can only read their own records and that only server-side code (via the service role key) can write to these tables.
Alternatives
Choose Stripe Connect if you are building a marketplace or platform where you need to pay out money to other businesses or individuals — for example, a freelance marketplace that collects payment from buyers and distributes to sellers.
Choose PayPal Payouts if your users specifically request PayPal as a payout option — note that PayPal has no shared connector in Lovable and requires manual Edge Function setup, making it significantly more complex than Stripe.
Choose Square if you also need in-person point-of-sale hardware alongside your online payments, or if your target market strongly prefers Square's ecosystem over Stripe.
Choose Shopify if you are building a product storefront with inventory management, shipping, and a full e-commerce catalog — Shopify handles the entire commerce layer so you do not need to manage products and orders yourself.
Frequently asked questions
Why does Stripe not work in Lovable's preview panel?
Lovable's preview runs inside an iframe, and Stripe's JavaScript intentionally blocks execution in cross-origin iframes as a browser security measure to prevent clickjacking and phishing attacks. This is not a bug in your code or Lovable's implementation — it is how Stripe works everywhere. Always test Stripe flows on your deployed app URL, which you get after clicking the Publish button. The preview panel is fine for testing layout and non-payment features.
Do I need to write any code to add Stripe to my Lovable app?
No. When the Stripe shared connector is active, Lovable's AI generates all the required code from your chat description — Edge Functions for checkout session creation and webhook handling, database tables for recording purchases and subscriptions, RLS policies for data security, and UI components for the payment flow. You do need to add your API keys manually in Cloud → Secrets, and you need to register your webhook endpoint in Stripe Dashboard, but no manual code writing is required. Lovable handles the implementation.
What is the difference between the Stripe connector and Stripe Connect in Lovable?
The standard Stripe connector (this page) covers accepting payments from your users — one-time purchases, subscriptions, and checkout flows where money flows from a customer into your account. Stripe Connect is a separate integration for marketplace and platform scenarios where you collect money and then pay it out to other businesses or individuals, such as a freelance marketplace distributing earnings to contractors. If you are building a SaaS product or e-commerce store, you want the standard Stripe connector. If you are building a platform where third parties earn money through your app, look at the Stripe Connect guide.
Can I use Stripe in test mode while my app is live?
Yes, and it is the recommended approach during development. Store your test keys (sk_test_ / pk_test_) in Cloud → Secrets and use Stripe's test card numbers (4242 4242 4242 4242 for Visa) to simulate payments. Real users will not be charged with test keys. When you are ready for production, replace the secret and publishable keys in Cloud → Secrets with your live keys (sk_live_ / pk_live_) and update your Stripe webhook endpoint to use the live mode version. No code changes are required — only the key values change.
How do I handle failed payments and subscription cancellations?
Prompt Lovable to handle the specific events you care about. For failed payments, describe: 'When a subscription payment fails, update the user's subscription status to past_due in the database and send them an email notification.' For cancellations, describe: 'When a subscription is cancelled in Stripe, update the user's status to cancelled and restrict their access to premium features.' Lovable will add the relevant event handlers (invoice.payment_failed, customer.subscription.deleted) to your webhook handler Edge Function. For complex subscription lifecycle management, RapidDev's team can help design the full state machine and database schema.
Where can I see if a Stripe webhook actually fired and what it sent?
Check two places. In Stripe Dashboard, go to Developers → Webhooks → your endpoint → Recent deliveries. Each delivery shows the event type, timestamp, response status code, and full request and response body — this is the authoritative source for whether Stripe sent the event and what your server returned. In Lovable, go to Cloud → Logs in the Cloud tab to see the Edge Function execution logs, including any errors thrown during webhook processing. If the Stripe Dashboard shows a 200 response but your database did not update, the issue is in your Edge Function logic — check the Lovable logs for error messages.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation