# This is how Stripe calls your webhook
curl -X POST https://api.vaniykempire.com/api/payments/webhook \
-H "stripe-signature: t=1678886400,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd" \
-H "Content-Type: application/json" \
-d '{
"id": "evt_1MtwBwLkdIwHu7ix28a3tqPa",
"type": "payment_intent.succeeded",
"data": {
"object": {
"id": "pi_3MtwBwLkdIwHu7ix28a3tqPa",
"amount": 2999,
"currency": "usd",
"status": "succeeded",
"metadata": {
"contentId": "507f191e810c19729de860ea",
"userId": "507f1f77bcf86cd799439011",
"contentTitle": "Advanced React Patterns"
}
}
}
}'
{
"received": true
}
Stripe webhook endpoint for processing payment events
# This is how Stripe calls your webhook
curl -X POST https://api.vaniykempire.com/api/payments/webhook \
-H "stripe-signature: t=1678886400,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd" \
-H "Content-Type: application/json" \
-d '{
"id": "evt_1MtwBwLkdIwHu7ix28a3tqPa",
"type": "payment_intent.succeeded",
"data": {
"object": {
"id": "pi_3MtwBwLkdIwHu7ix28a3tqPa",
"amount": 2999,
"currency": "usd",
"status": "succeeded",
"metadata": {
"contentId": "507f191e810c19729de860ea",
"userId": "507f1f77bcf86cd799439011",
"contentTitle": "Advanced React Patterns"
}
}
}
}'
{
"received": true
}
Secure webhook endpoint that receives events from Stripe when payment status changes. This endpoint handles payment intent success and failure events, updating the Purchase record status accordingly.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PhemiT/vaniykeempire-api/llms.txt
Use this file to discover all available pages before exploring further.
express.json() middleware in your Express application. The Stripe signature verification requires access to the raw request body.https://api.vaniykempire.com/api/payments/webhookpayment_intent.succeededpayment_intent.payment_failedSTRIPE_WEBHOOK_SECRET environment variableconst sig = req.headers['stripe-signature'];
const event = stripe.webhooks.constructEvent(
req.body,
sig,
process.env.STRIPE_WEBHOOK_SECRET
);
stripePaymentIntentIdcompletedstripePaymentIntentIdfailedapplication/jsonevt_1MtwBwLkdIwHu7ix28a3tqPa)payment_intent.succeeded, payment_intent.payment_failed)Show data.object properties
pi_3MtwBwLkdIwHu7ix28a3tqPa)usd)true to acknowledge receipt of the webhookWebhook Error: <error message># This is how Stripe calls your webhook
curl -X POST https://api.vaniykempire.com/api/payments/webhook \
-H "stripe-signature: t=1678886400,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd" \
-H "Content-Type: application/json" \
-d '{
"id": "evt_1MtwBwLkdIwHu7ix28a3tqPa",
"type": "payment_intent.succeeded",
"data": {
"object": {
"id": "pi_3MtwBwLkdIwHu7ix28a3tqPa",
"amount": 2999,
"currency": "usd",
"status": "succeeded",
"metadata": {
"contentId": "507f191e810c19729de860ea",
"userId": "507f1f77bcf86cd799439011",
"contentTitle": "Advanced React Patterns"
}
}
}
}'
{
"received": true
}
# Install Stripe CLI
stripe login
# Forward webhooks to local server
stripe listen --forward-to localhost:3000/api/payments/webhook
# Trigger test events
stripe trigger payment_intent.succeeded
stripe trigger payment_intent.payment_failed
| Issue | Solution |
|---|---|
| Signature verification fails | Ensure raw body parsing is enabled and webhook secret is correct |
| Purchase not found | Check that payment intent was created through your API |
| Webhooks not received | Verify webhook URL is correct in Stripe Dashboard |
| Duplicate events | Implement idempotency using event ID |
whsec_...express.raw({ type: 'application/json' })express.json() middlewaresrc/controllers/paymentController.js:64-130src/routes/paymentRoutes.js:7-11