DEV Community

seller-mind
seller-mind

Posted on

Stripe Integration Guide - From Zero to Production in 2026

Stripe Integration Guide - Zero to Production

Adding payments to your SaaS? Here is everything you need to know about Stripe in 2026.

Why Stripe?

  • Available in 46+ countries
  • Supports 135+ currencies
  • Industry-standard security
  • Excellent documentation
  • Huge ecosystem of tools

The Basics

1. Create Account

Go to stripe.com and create an account. You will get:

  • Publishable key (public)
  • Secret key (private - never share this)

2. Install Stripe SDK

npm install stripe @stripe/stripe-js
Enter fullscreen mode Exit fullscreen mode

3. Basic Payment Intent

const stripe = require('stripe')('sk_test_...');

const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000, // $20.00
  currency: 'usd',
  automatic_payment_methods: { enabled: true },
});
Enter fullscreen mode Exit fullscreen mode

Subscription Billing

Create a Product and Price

const product = await stripe.products.create({
  name: 'Pro Plan',
});

const price = await stripe.prices.create({
  product: product.id,
  unit_amount: 2900, // $29.00
  currency: 'usd',
  recurring: { interval: 'month' },
});
Enter fullscreen mode Exit fullscreen mode

Create Checkout Session

const session = await stripe.checkout.sessions.create({
  payment_method_types: ['card'],
  line_items: [{ price: price.id, quantity: 1 }],
  mode: 'subscription',
  success_url: 'https://yoursite.com/success',
  cancel_url: 'https://yoursite.com/cancel',
});
Enter fullscreen mode Exit fullscreen mode

Webhooks - Critical for Subscriptions

Webhooks tell your app when payment events happen.

app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
  const event = stripe.webhooks.constructEvent(
    req.body, req.headers['stripe-signature'], endpointSecret
  );

  switch (event.type) {
    case 'checkout.session.completed':
      // Handle successful payment
      break;
    case 'customer.subscription.deleted':
      // Handle cancellation
      break;
    case 'invoice.payment_failed':
      // Handle failed payment
      break;
  }

  res.json({received: true});
});
Enter fullscreen mode Exit fullscreen mode

Common Pitfalls

  1. Not using webhooks - Relying on redirect URLs is unreliable
  2. Not handling failures - Cards get declined
  3. Ignoring SCA - European customers need 3D Secure
  4. Storing card data - Never do this, use Stripe
  5. Not testing webhooks locally - Use Stripe CLI

Testing

Stripe CLI for Local Webhooks

stripe listen --forward-to localhost:3000/webhook
Enter fullscreen mode Exit fullscreen mode

Test Card Numbers

Number Result
4242 4242 4242 4242 Success
4000 0000 0000 0002 Declined
4000 0025 0000 3155 3D Secure required

Stripe Alternatives

Provider Best For
Stripe Global SaaS
Dodo Payments Simple, one-time + subscription
Lemon Squeezy Digital products
Paddle Merchant of record (handles taxes)

Need a Head Start?

Setting up Stripe correctly takes time. If you want to skip the setup:

SaaSLaunch includes:

  • Stripe integration (subscriptions + one-time)
  • Dodo Payments support
  • Lemon Squeezy support
  • Webhook handling
  • Customer portal

Launch your SaaS with payments already working.


Skip months of payment setup with SaaSLaunch - SaaS boilerplate with Stripe, Dodo Payments, and Lemon Squeezy built in.

Top comments (0)