𝗦𝘁𝗿𝗶𝗽𝗲 𝗪𝗲𝗯𝗵𝗼𝗼𝗸 𝗧𝗲𝘀𝘁𝗶𝗻𝗴: 𝗟𝗼𝗰𝗮𝗹 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁 𝗚𝘂𝗶𝗱𝗲

Stripe webhooks notify your app about payments and subscriptions. A missed webhook causes failed orders. Testing used to be hard. Now it is easy with the Stripe CLI.

Install the CLI first.

  • macOS: brew install stripe/stripe-cli/stripe
  • Windows: scoop install stripe
  • Linux: Use the releases page.

Link your account with this command: stripe login

Start the listener to forward events to your server: stripe listen --forward-to localhost:3000/webhooks/stripe

Save the signing secret from the output. Set it in your environment: export STRIPE_WEBHOOK_SECRET=whsec_abc123

Test events without spending money. Use triggers.

  • Payment success: stripe trigger payment_intent.succeeded
  • Payment fail: stripe trigger payment_intent.payment_failed
  • New subscription: stripe trigger customer.subscription.created

Verify signatures to stop fake requests. Use the raw request body. JSON parsers break the verification. Use express.raw() in Express.

Solve common errors.

  • A 400 response means the signature failed.
  • Check your CLI secret. Dashboard secrets do not work here.
  • Review your logs.

Production checklist.

  • Use HTTPS.
  • Use the production secret.
  • Respond in under 30 seconds.
  • Handle duplicate events.

Source: https://dev.to/digital_trubador/stripe-webhook-testing-local-development-guide-391