Prochain événement : cours découverte - le 9 juin de 19h à 20hProchain événement : cours découverte - le 9 juin de 19h à 20h
Bloc Spot
SalleÉcoleFalaiseEntreprisesAgendaTarifsMerchÀ proposContact
Y aller
Agenda
SalleÉcoleFalaiseEntreprises
TarifsMerchÀ proposContact
Y aller
SalleÉcoleFalaiseEntreprisesAgendaTarifsMerchÀ proposContact
Back to Blog
Building a SaaS with Stripe Payments
January 10, 20251 min read

Building a SaaS with Stripe Payments

A complete guide to integrating Stripe payments into your SaaS application for subscriptions and one-time payments.

SaaSPayments

Building a successful SaaS requires a robust payment system. Stripe makes it easy to accept payments, manage subscriptions, and handle billing.

Setting Up Stripe

First, install the Stripe SDK:

npm install stripe @stripe/stripe-js

Create a Stripe instance on the server:

import Stripe from "stripe";

export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
  apiVersion: "2024-12-18.acacia",
});

Creating a Subscription

To create a subscription, you need to:

  1. Create a customer
  2. Attach a payment method
  3. Create the subscription
const subscription = await stripe.subscriptions.create({
  customer: customerId,
  items: [{ price: priceId }],
  payment_behavior: "default_incomplete",
  expand: ["latest_invoice.payment_intent"],
});

Handling Webhooks

Webhooks are essential for keeping your database in sync:

export async function POST(req: Request) {
  const body = await req.text();
  const sig = req.headers.get("stripe-signature")!;

  const event = stripe.webhooks.constructEvent(body, sig, webhookSecret);

  switch (event.type) {
    case "customer.subscription.created":
      // Handle new subscription
      break;
    case "invoice.paid":
      // Handle successful payment
      break;
  }
}

Best Practices

  • Always use webhooks for critical business logic
  • Store Stripe IDs in your database
  • Implement proper error handling
  • Test with Stripe CLI locally
Bloc SpotBloc Spot

Salle d'escalade de bloc à Angoulême. 800 m², 190 voies, ouverte 7j/7 dès 4 ans.

★Laisser un avis Google
Activités
La salle d'escaladeÉcole d'escaladeFalaise avec BrunoAgenda & événementsTeam buildingAnniversaires
Infos
Tarifs & abonnementsMerch & producteurs locauxÀ proposInfos pratiques
Nous trouver
144 Route de Vars
16160 Gond-Pontouvre
Horaires
Lun – Ven9h – 23h
Sam – Dim9h – 21h
07 49 39 93 43blocspot.16@gmail.com
© 2026 Bloc Spot — OSPOT AngoulêmeMentions légalesConfidentialitéCGV
Codé avec cœur parSocial Sphère