Stripe Webhook Integration
Stripe webhooks allow you to receive real-time notifications about events in your Stripe account, such as successful payments, failed charges, subscription updates, and more.Quick Start
- Get your Unhook URL:
https://unhook.sh/wh_YOUR_ID - Configure in Stripe Dashboard: dashboard.stripe.com/webhooks
- Start receiving events locally:
unhook listen
Configuration Steps
1. Access Stripe Webhook Settings
Navigate to the Stripe Dashboard:- Direct Link: dashboard.stripe.com/webhooks
- Or go to Dashboard → Developers → Webhooks
2. Create a New Endpoint
- Click “Add endpoint”
- Enter your Unhook URL:
- Select API version (optional - defaults to your account version)
3. Select Events to Listen For
Choose the events relevant to your application:Payment Events
payment_intent.succeeded- Payment completed successfullypayment_intent.payment_failed- Payment attempt failedcharge.succeeded- Charge was successfulcharge.failed- Charge failedcharge.refunded- Charge was refundedcharge.dispute.created- Customer disputed a charge
Customer Events
customer.created- New customer createdcustomer.updated- Customer details updatedcustomer.deleted- Customer deletedcustomer.source.created- Payment method addedcustomer.source.deleted- Payment method removed
Subscription Events
customer.subscription.created- New subscription startedcustomer.subscription.updated- Subscription modifiedcustomer.subscription.deleted- Subscription cancelledcustomer.subscription.trial_will_end- Trial ending sooninvoice.payment_succeeded- Subscription payment successfulinvoice.payment_failed- Subscription payment failed
Checkout Events
checkout.session.completed- Checkout session successfulcheckout.session.expired- Checkout session expiredcheckout.session.async_payment_succeeded- Async payment completedcheckout.session.async_payment_failed- Async payment failed
Connect Events (for platforms)
account.updated- Connected account updatedaccount.application.authorized- OAuth connection authorizedaccount.application.deauthorized- OAuth connection removedpayout.created- Payout initiatedpayout.paid- Payout completedpayout.failed- Payout failed
4. Configure Webhook Settings
After selecting events, configure additional settings:- Description: Add a meaningful description (e.g., “Production webhooks for MyApp”)
- Listen to: Choose between live mode and test mode events
- Click “Add endpoint” to save
Webhook Signing Secret
Stripe signs all webhook events for security. To verify signatures:- After creating the endpoint, click on it to view details
- Click “Reveal” under Signing secret
- Copy the
whsec_...value - Add it to your environment variables:
Testing Webhooks
Using Stripe CLI
Using Stripe Dashboard
- Go to your webhook endpoint in the Dashboard
- Click “Send test webhook”
- Select an event type
- Click “Send test webhook”
Event Payload Examples
Payment Intent Succeeded
Customer Subscription Created
Best Practices
1. Verify Webhook Signatures
Always verify that webhooks are coming from Stripe:2. Handle Idempotency
Stripe may send the same event multiple times. Use the event ID to ensure idempotent processing:3. Respond Quickly
Return a 2xx response quickly to acknowledge receipt:4. Handle Failures Gracefully
Implement proper error handling and retries:Common Issues
Missing Events
- Ensure you’ve selected all required events in the webhook configuration
- Check if you’re listening to the correct mode (live vs test)
- Verify your endpoint URL is correct
Signature Verification Failures
- Make sure you’re using the correct endpoint secret
- Ensure the raw request body is used for verification (not parsed JSON)
- Check that your framework isn’t modifying the request body
Timeout Errors
- Respond to webhooks within 20 seconds
- Process heavy operations asynchronously
- Return 200 immediately, then process
Useful Links
- Stripe Webhook Documentation: stripe.com/docs/webhooks
- Stripe API Reference: stripe.com/docs/api/events
- Webhook Event Types: stripe.com/docs/api/events/types
- Stripe CLI: stripe.com/docs/stripe-cli
- Testing Webhooks: stripe.com/docs/webhooks/test
Support
Need help with Stripe webhooks?- Join our Discord community
- Check Stripe’s support
- Email us at support@unhook.sh