curl --request POST \
--url https://api.example.com/api/webhooks/stripe \
--header 'stripe-signature: <stripe-signature>'{
"status": true,
"message": "Webhook recibido correctamente",
"data": {
"received": true,
"type": "payment_intent.succeeded"
}
}
Receives and processes Stripe webhook events with signature verification
curl --request POST \
--url https://api.example.com/api/webhooks/stripe \
--header 'stripe-signature: <stripe-signature>'{
"status": true,
"message": "Webhook recibido correctamente",
"data": {
"received": true,
"type": "payment_intent.succeeded"
}
}
This endpoint receives webhook events from Stripe, enabling your application to respond to payment events in real-time. The endpoint implements secure signature verification to ensure events are legitimately sent by Stripe.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/peLuis123/Stripe_Back/llms.txt
Use this file to discover all available pages before exploring further.
stripe-signature header and STRIPE_WEBHOOK_SECRET. Never process webhooks without signature verification, as this could allow attackers to send fraudulent events to your application.constructEvent method to verify that incoming webhooks are authentic. This process:
stripe-signature header containing the signature and timestampSTRIPE_WEBHOOK_SECRET to verify the signature matches the payloadSTRIPE_WEBHOOK_SECRETYou must configure this secret in your environment. The webhook secret is provided in your Stripe Dashboard when you create a webhook endpoint. It typically starts with whsec_.https://yourdomain.com/api/webhooks/stripeSTRIPE_WEBHOOK_SECRETapplication/json{
"id": "evt_1234567890",
"object": "event",
"api_version": "2023-10-16",
"created": 1234567890,
"type": "payment_intent.succeeded",
"data": {
"object": {
// Event-specific data (e.g., PaymentIntent, Refund, Charge)
}
},
"livemode": false,
"pending_webhooks": 1,
"request": {
"id": "req_1234567890",
"idempotency_key": null
}
}
payment_intent.succeeded
event.data.object contains the complete PaymentIntent object.Use cases:payment_intent.payment_failed
event.data.object contains the PaymentIntent with error details.Use cases:refund.created
event.data.object contains the Refund object.Use cases:charge.refunded
event.data.object contains the Charge object with refund details.Use cases:true for valid webhooks.{
"id": "evt_1QR7tPABC123def456",
"object": "event",
"type": "payment_intent.succeeded",
"data": {
"object": {
"id": "pi_3QR7tPABC123def456",
"object": "payment_intent",
"amount": 2000,
"currency": "usd",
"status": "succeeded",
"customer": "cus_ABC123def456",
"payment_method": "pm_1QR7tPABC123def456",
"charges": {
"data": [
{
"id": "ch_3QR7tPABC123def456",
"amount": 2000,
"currency": "usd",
"status": "succeeded"
}
]
}
}
},
"livemode": false,
"created": 1234567890
}
{
"status": true,
"message": "Webhook recibido correctamente",
"data": {
"received": true,
"type": "payment_intent.succeeded"
}
}
event.id to ensure you only process each event once.
| Error Condition | HTTP Status | Response Message |
|---|---|---|
Missing STRIPE_WEBHOOK_SECRET | 500 | ”Missing STRIPE_WEBHOOK_SECRET in environment variables” |
Missing stripe-signature header | 400 | ”Missing stripe-signature header” |
| Invalid signature | 400 | ”Webhook signature verification failed: [error details]“ |
| Valid webhook received | 200 | ”Webhook recibido correctamente” |