examples/webhook-signing/README.md
Verify the events that Stripe sends to your webhook endpoints. Additional details in the Stripe docs.
Available examples:
You’ll need the following:
In the sample directory (cd examples/webhook-signing/express).
Install dependencies:
npm install
Update .env with your own Stripe API keys.
Next, follow these installation steps to install the Stripe CLI which we'll use for webhook forwarding.
After the installation has finished, authenticate the CLI with your Stripe account:
stripe login
To start the webhook forwarding run:
stripe listen --forward-to localhost:3000/webhook
The Stripe CLI will let you know that webhook forwarding is ready and output your webhook signing secret:
> Ready! Your webhook signing secret is whsec_xxx
Copy the webhook signing secret (whsec_xxx) to your .env file.
In a separate terminal window, start the local sample server:
`./main.ts`
In another separate terminal window, trigger an event, for example:
stripe trigger payment_intent.succeeded
You should now see some webhook event details being logged to your Node.js console.
To add a new example:
package.json from one of the existing samples. Remove extra dependencies.main.ts file with sample server code and run chmod +x main.ts so it's directly executable.main.ts has to follow some rules:import .. from .. import syntax.#!/usr/bin/env -S npm run-script run header to be directly runable.Webhook endpoint available at <url> when the server is started.{"received":true} and 200 status code for charge.succeeded event.cd examples/webhook-signing/test./main.ts ../<your test directory>/tests/Integration.spec.ts