Prompt

receive Stripe webhooks in Node

Technology / API Platforms2 observationsLast seen Nov 18, 2026

Latest observation

Nov 18, 2026OpenAI APIWeb search: off

To receive Stripe webhooks in Node.js, you need to:

  1. Create a webhook endpoint in your server
  2. Read the raw request body exactly as Stripe sends it
  3. Verify the webhook signature using your Stripe signing secret
  4. Handle the event types you care about

Example with Express

const express = require('express');
const Stripe = require('stripe');

const app = express();
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

// IMPORTANT: use raw body for this route only
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const sig = req.headers['stripe-signature'];
  const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET;

  let event;

  try {
    event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
  } catch (err) {
    console.error('Webhook signature verification failed:', err.message);
    return res.sendStatus(400);
  }

  switch (event.type) {
    case 'payment_intent.succeeded':
      console.log('Payment succeeded:', event.data.object);
      break;

    case 'invoice.paid':
      console.log('Invoice paid:', event.data.object);
      break;

    default:
      console.log(`Unhandled event type: ${event.type}`);
  }

  res.sendStatus(200);
});

app.listen(3000, () => console.log('Server running on port 3000'));

Install

npm install express stripe

Important notes

  • Do not use express.json() on the webhook route before express.raw(), or signature verification will fail.
  • Use your Stripe webhook signing secret from the Stripe Dashboard.
  • Your endpoint must be accessible from Stripe, so for local development use something like Stripe CLI or ngrok.

Local testing with Stripe CLI

stripe listen --forward-to localhost:3000/webhook

Then trigger a test event:

stripe trigger payment_intent.succeeded

If you use Express globally

If you already use JSON middleware elsewhere, do this:

app.use('/webhook', express.raw({ type: 'application/json' }));
app.use(express.json());

If you want, I can also give you:

  • a TypeScript version
  • an Express + Next.js example
  • an example for Fastify / NestJS / Koa

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.