Stripe is the cash register for your website. It handles credit cards, subscriptions, invoices, and payouts — so you can get paid online without building any payment logic yourself. Used by millions of businesses, from one-person shops to companies like Shopify and Amazon.
Stripe is a payment processing service. When someone buys something on your website — a product, a subscription, a digital download — Stripe handles the entire transaction. It collects the credit card info, charges the customer, and deposits the money into your bank account.
You never see or store anyone's credit card number. Stripe handles all the sensitive stuff so you don't have to worry about security. Think of it like having a professional cashier who handles every transaction and then hands you the money at the end of the day — minus a small fee.
The best part for AI coders: Stripe offers pre-built checkout pages. You don't need to design a payment form or figure out how credit cards work. You just send the customer to Stripe's checkout page, they pay, and Stripe tells your app "payment successful." Done.
Physical products, digital downloads, courses, templates — if you're charging money for it, Stripe handles the payment.
Charging monthly or yearly? Stripe handles recurring billing, plan upgrades, cancellations, and prorations automatically.
Building a software tool with pricing tiers? Stripe was made for this. Free trials, usage-based billing, seat-based pricing — it does it all.
Send professional invoices, accept payments, and track who's paid. No need for a separate invoicing tool.
Pricing: 2.9% + 30 cents per successful card transaction. No monthly fees, no setup fees, no hidden costs. You only pay when you actually get paid. For example, if someone pays $100, Stripe takes $3.20 and you get $96.80.
Go to stripe.com and sign up for free. You can start building immediately — you don't need to verify your identity until you're ready to accept real payments.
Stripe gives you two sets of keys: test keys (for fake payments) and live keys (for real money). Start with test keys so you can build without spending real money.
Ask your AI tool to install the 'stripe' package for your server and '@stripe/stripe-js' for your frontend. These connect your app to Stripe's service.
Go to the Products section in your Stripe dashboard and create a product with a price. For subscriptions, set the billing interval (monthly, yearly, etc.).
When a customer clicks 'Buy' on your site, your app creates a checkout session and redirects them to Stripe's hosted payment page. Stripe handles the rest.
After payment, Stripe redirects the customer back to your site and sends a webhook to confirm the payment. Your app updates accordingly — unlock the product, start the subscription, etc.
A pre-built, hosted payment page. No design work needed — just redirect customers to it and Stripe handles the rest, including mobile optimization.
Create a payment link in Stripe's dashboard without writing any code. Share it via email, social media, or embed it on your site. Perfect for quick sales.
Recurring billing that runs on autopilot. Set up monthly or yearly plans, handle upgrades, downgrades, cancellations, and free trials.
Send professional invoices to customers. They can pay online with a credit card. Track who's paid and send automatic reminders for overdue invoices.
A pre-built page where your customers can manage their own subscriptions — update payment method, change plans, download invoices, and cancel.
Get real-time notifications when things happen — a payment succeeds, a subscription renews, a charge fails. Your app can react automatically.
Embeddable payment form components. If you want the payment form on your own page instead of Stripe's hosted page, Elements gives you customizable card inputs.
Test everything with fake credit card numbers before going live. Stripe provides special test card numbers that simulate successful and failed payments.
A powerful web dashboard where you manage everything — view payments, track revenue, handle refunds, manage customers, and download financial reports.
Building a marketplace where sellers get paid? Connect handles splitting payments between your platform and your sellers, including tax reporting.
Copy these prompts into your AI tool to add Stripe payments to your app. Adjust the product names, prices, and features to match your project.
1. Basic Stripe Checkout
"Add Stripe payments to my Next.js app. Install the stripe and @stripe/stripe-js packages. Create an API route at /api/checkout that creates a Stripe Checkout session for a one-time payment of $49 for a product called 'Premium Template'. After payment, redirect to a /success page that shows a thank you message. Use environment variables for the Stripe keys."
2. Subscription billing
"Set up Stripe subscription billing in my Next.js app. Create a pricing page with three tiers: Starter ($9/month), Pro ($29/month), and Enterprise ($99/month). Each tier should have a list of features and a 'Subscribe' button that redirects to Stripe Checkout. After subscribing, redirect to /dashboard. Use Stripe's pre-built checkout page."
3. Webhook handler
"Create a Stripe webhook endpoint at /api/webhooks/stripe in my Next.js app. Listen for these events: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted, and invoice.payment_failed. When a checkout completes, update the user's subscription status in my database. Verify the webhook signature for security."
4. Customer portal
"Add a Stripe Customer Portal to my app. Create an API route at /api/create-portal-session that creates a portal session for the current logged-in user. Add a 'Manage Subscription' button on the dashboard that redirects to the portal. The portal should let customers update their payment method, change plans, and cancel their subscription."
5. Payment Links (no code)
"Create a simple buy button on my landing page that links to a Stripe Payment Link. Add a section with a product image, description, price ($29), and a styled 'Buy Now' button. The button should open the Stripe Payment Link in a new tab. Also add a 'What's included' list below the button. No server-side code needed for this."
6. Handle refunds
"Add a refund system to my admin dashboard. Create a page that lists recent Stripe payments with the customer email, amount, date, and status. Add a 'Refund' button next to each payment. When clicked, show a confirmation dialog, then call the Stripe API to process the refund. Show a success message when the refund is complete."
7. Pricing table component
"Build a pricing table component with a toggle to switch between monthly and yearly pricing (yearly should show a 20% discount). Each plan card should have: plan name, price, a highlighted 'Most Popular' badge on the middle plan, a list of features with checkmarks, and a 'Get Started' button that creates a Stripe Checkout session for that specific plan."
8. Product management page
"Create an admin page that shows all my Stripe products and their prices. Fetch the products from the Stripe API and display them in a table with columns for: product name, price, billing interval (one-time/monthly/yearly), and active status. Add a link to each product's Stripe dashboard page."
9. Free trial setup
"Set up a 14-day free trial for my subscription product. When a user clicks 'Start Free Trial', create a Stripe Checkout session with a 14-day trial period — they enter their card but won't be charged until the trial ends. Show the trial end date on the user's dashboard. Send a webhook notification when the trial ends and billing begins."
10. Check subscription status
"Create a helper function that checks the current user's Stripe subscription status. It should look up the user's Stripe customer ID from my database, fetch their active subscriptions from Stripe, and return whether they're on a free plan, trial, or paid plan (and which tier). Use this to show or hide premium features on the dashboard."
11. Embedded checkout form
"Instead of redirecting to Stripe's hosted checkout page, embed the payment form directly on my site using Stripe Elements. Create a checkout page at /checkout with a card input field, the order total, and a 'Pay Now' button. Use the PaymentIntent API to handle the payment. Show loading, success, and error states."
Stripe gives you test API keys that simulate payments with fake credit cards. Build and test everything in test mode first. Only switch to live keys when you're ready to accept real money.
Don't build custom payment forms until you need to. Stripe's hosted Checkout page handles card validation, 3D Secure, mobile optimization, and multiple payment methods automatically.
Don't rely on the redirect after payment to update your app. Sometimes users close the browser before being redirected. Webhooks are the reliable way to know a payment succeeded.
Stripe provides special test card numbers: 4242 4242 4242 4242 always succeeds, 4000 0000 0000 0002 always declines. Use these to test both success and failure scenarios.
It's easier to create your products and prices in Stripe's web dashboard than through code. Then just reference the price ID in your app when creating checkout sessions.
Never expose your Stripe Secret Key in frontend code or commit it to GitHub. It goes in .env.local only. The publishable key (starts with pk_) is safe for the frontend.
When receiving webhooks, always verify the signature to make sure the event actually came from Stripe and not someone trying to trick your app into giving away free stuff.
The most common cause is a missing or invalid price ID. Make sure you're using the price ID (starts with 'price_'), not the product ID (starts with 'prod_'). Also check that your Stripe Secret Key is correct in .env.local and that you've restarted your dev server.
Make sure you're using the raw request body (not parsed JSON) for verification. In Next.js App Router, don't use body parsing middleware on the webhook route. Also double-check your webhook signing secret — it's different from your API keys and starts with 'whsec_'.
This happens when you rely on the success page redirect instead of webhooks. Set up a webhook handler to listen for 'checkout.session.completed' events. This is the reliable way to confirm payment. The redirect can fail if the user closes their browser.
Make sure you're using Stripe's test card numbers, not a real card. In test mode, use 4242 4242 4242 4242 with any future expiration date and any 3-digit CVC. If you're accidentally using live mode keys in development, payments with test cards will always fail.
When a customer cancels, Stripe doesn't immediately end the subscription by default — it cancels at the end of the current billing period. If you want immediate cancellation, set 'cancel_at_period_end' to false and call the cancel endpoint. Make sure your webhook handles 'customer.subscription.deleted'.
Stripe holds your first payout for 7 days (this is normal for new accounts). After that, payouts happen on a 2-day rolling basis. You can check your payout schedule in the Stripe dashboard under Settings > Payouts. Make sure you've completed identity verification.
There are several ways to accept payments online. Here's how Stripe compares to the most popular alternatives.
PayPal is well-known and many customers already have accounts. But PayPal's developer tools are outdated and harder to work with. Stripe has cleaner APIs, better documentation, and more modern features. For a polished checkout experience that your AI tool can set up easily, Stripe is the better choice. PayPal is useful as an additional payment option alongside Stripe.
Lemon Squeezy is a newer, simpler alternative that acts as a 'merchant of record' — meaning they handle sales tax for you worldwide. Stripe leaves tax to you (or you can add Stripe Tax). Lemon Squeezy is easier for selling digital products and charges a flat 5% + 50 cents per transaction. Choose Lemon Squeezy if you sell digital products globally and want zero tax headaches. Choose Stripe for more control and lower fees.
Like Lemon Squeezy, Paddle is a merchant of record that handles sales tax and VAT globally. It's popular with SaaS companies. The trade-off: higher fees (5% + 50 cents) and less flexibility than Stripe. Choose Paddle if you're selling software internationally and don't want to deal with tax compliance. Choose Stripe if you want lower fees and more customization.