All posts
April 16, 2026 3 min read

Setting Up Stripe Payments with Netlify Serverless Functions

payments stripe serverless

We wanted a dead-simple payment flow: click "Subscribe to Pro", pay $7.99, and immediately unlock AI features. Here's how we wired it up.

Stripe Payment Links

Instead of building a custom checkout form, we used Stripe Payment Links. They're hosted by Stripe, PCI-compliant out of the box, and take about 30 seconds to set up. We pass the user's email and Firebase UID as URL parameters so we can link the payment back to their account.

The webhook

When a payment completes, Stripe sends a webhook to our Netlify serverless function at /.netlify/functions/stripe-webhook. The function:

  • Verifies the Stripe signature (prevents spoofing)
  • Extracts the client_reference_id (the user's Firebase UID)
  • Updates the user's Firestore document with subscription.plan = "pro" and an expiration date
  • Handles subscription updates and cancellations
  • Environment variables

    All secrets (Stripe key, webhook secret, Firebase service account) live in Netlify environment variables — never in source code. The serverless function reads them at runtime.

    The user experience

    From the user's perspective:

  • Click "Subscribe to Pro" in the paywall modal
  • Stripe checkout opens (pre-filled with their email)
  • Pay → redirected to a success page
  • AI features unlock immediately
  • Total implementation time: about 2 hours. Stripe's developer experience is genuinely excellent.