Test a webhooks integration with the Stripe CLI
Test that your webhook endpoint is working properly before taking it live.
Simulate Stripe events to test a webhooks integration using the stripe trigger <event>
command. When you trigger an event, Stripe issues HTTP requests against Stripe APIs, creating all API objects that correspond to that event.
Before you begin
- Install the Stripe CLI and log in to authenticate your account.
- Use the Interactive webhook endpoint builder to build a webhook endpoint.
Forward events to a local webhook endpoint
- Use the
--forward-to
flag to send all Stripe events in test mode to your local webhook endpoint. To disable HTTPS certificate verification, use the--skip-verify
flag.
Command Line
stripe listen --forward-to localhost:4242/stripe_webhooks
Output
Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit)
- Optionally, use the
--events
flag to forward specific events in a comma separated list.
Command Line
stripe listen --events payment_intent.created,customer.created,payment_intent.succeeded,charge.succeeded,checkout.session.completed,charge.failed \ --forward-to localhost:4242/webhook
- Optionally, if you’ve already registered your endpoint in Stripe, use the
--load-from-webhooks-api
and--forward-to
flags.
Command Line
stripe listen --load-from-webhooks-api --forward-to localhost:5000
This command forwards events sent to your Stripe-registered public webhook endpoint to your local webhook endpoint. It loads your registered endpoint, parses the path and its registered events, then appends the path to your local webhook endpoint in the --forward-to
path.
Trigger events to test your webhooks integration
- Run the
stripe trigger checkout.session.completed
command to simulate the event that occurs when a customer payment is successful for the Create a session API in the Prebuilt Checkout page.
Command Line
stripe trigger checkout.session.completed
- Run the
stripe trigger payment_intent.succeeded
command to simulate the event that occurs when a customer payment is successful for the Create a PaymentIntent API in the Custom payment flow.
Command Line
stripe trigger payment_intent.succeeded