POST /webhooks/stripe-listener • HTTP 200 OK

Webhook Event Payload & HMAC Signature Verification — Request & Response Example

Demonstrates how webhooks deliver real-time notifications (e.g. payment successful, invoice paid) and how receivers verify cryptographic signatures.

1. HTTP Client Request (POST)

POST /webhooks/stripe-listener HTTP/1.1
{
  "Content-Type": "application/json",
  "X-Webhook-Signature": "t=1728212000,v1=9c4a8d2e7f1b3c5a6d8e0f2b4c6a8e1d7f3b5c9a"
}

{
  "id": "evt_3Msw2kLkdIwHu7ix",
  "type": "payment_intent.succeeded",
  "created": 1728212000,
  "data": {
    "amount": 4900,
    "currency": "usd",
    "customer_email": "buyer@example.com",
    "status": "succeeded"
  }
}

2. Server JSON Response (HTTP 200 OK)

{
  "received": true
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -X POST "https://cometflow.space/webhooks/stripe-listener" \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Signature: t=1728212000,v1=9c4a8d2e7f1b3c5a6d8e0f2b4c6a8e1d7f3b5c9a" \
  -d '{"type": "payment_intent.succeeded", "data": {"amount": 4900}}'
fetch('https://cometflow.space/webhooks/stripe-listener', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Webhook-Signature': 't=1728212000,v1=9c4a8d2e7f1b3c5a6d8e0f2b4c6a8e1d7f3b5c9a'
  },
  body: JSON.stringify({ type: 'payment_intent.succeeded' })
}).then(res => res.json()).then(console.log);
import hmac, hashlib, requests

payload = '{"type": "payment_intent.succeeded"}'
res = requests.post("https://cometflow.space/webhooks/stripe-listener", data=payload)
print(res.status_code)

How This API Call Works Step-by-Step

  1. 1. Third-party event triggers (e.g. customer enters card on Stripe).
  2. 2. Stripe signs body using shared webhook secret with HMAC-SHA256.
  3. 3. Your server receives POST /webhooks/stripe-listener with signature header.
  4. 4. Your server re-computes HMAC over the raw request body to verify authenticity.
  5. 5. Returns 200 OK within 2 seconds to acknowledge receipt.

Backend API Functions: The webhook handler function crypto.createHmac("sha256", secret).update(rawBody).digest("hex") validates the payload before fulfilling the customer purchase.

Frequently Asked Questions

Why must webhooks verify signatures?

Anyone who discovers your public webhook URL could send fake "payment succeeded" requests to trigger free shipping of orders. Verifying the cryptographic signature guarantees only the real provider sent the event.