#briskdev1-webhook
1 messages · Page 1 of 1 (latest)
I'm trying to use the example endpoint for listening to events when a user makes a payment. https://dashboard.stripe.com/test/webhooks/create?endpoint_location=local
the example doesn't include anything about resolving/rejecting promises but my example webhook endpoint gives me errors saying im not handling the unresolved promises properly
Do you have code example you can share?
const testWebhook = async (request, response) => {
const endpointSecret = "whsec_oopsBl3Fw2tip1zBVQXzeVQOvKX"
const sig = request.headers['stripe-signature'];
console.log(sig = ${sig})
const event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret).then((event) => {
// Handle the event
switch (event.type) {
case 'payment_intent.succeeded':
const paymentIntent = event.data.object;
// Then define and call a function to handle the event payment_intent.succeeded
break;
// ... handle other event types
default:
console.log(`Unhandled event type ${event.type}`);
}
// Return a 200 response to acknowledge receipt of the event
response.status(200).send("success");
}).catch((error) => {
response.status(400).send(Webhook Error: ${error});
return;
})
}
I still get the events printed out to the terminal using the CLI but a few seconds later i get errors saying "[ERROR] Failed to POST: Post "http://localhost:3000/api/testWebhook": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"
I'm not entirely sure I follow. Do you get to the response.status(200)?
im not sure
should that be logged in my console too?
2021-11-01 08:59:15 --> payment_intent.created [evt_3Jr2ukJZYU3zUqpI08Jun5Ik]
2021-11-01 08:59:15 --> invoice.created [evt_1Jr2ulJZYU3zUqpI4M2Yzo4K]
2021-11-01 08:59:15 --> invoice.finalized [evt_1Jr2ulJZYU3zUqpIRaTWOcZI]
2021-11-01 08:59:15 --> customer.subscription.created [evt_1Jr2ulJZYU3zUqpIVNubxNIB]
2021-11-01 08:59:18 --> payment_intent.succeeded [evt_3Jr2ukJZYU3zUqpI0UkstWsl]
2021-11-01 08:59:18 --> charge.succeeded [evt_3Jr2ukJZYU3zUqpI0FQrUD2K]
2021-11-01 08:59:18 --> invoice.updated [evt_1Jr2uoJZYU3zUqpITs8xeZtd]
2021-11-01 08:59:18 --> customer.subscription.updated [evt_1Jr2uoJZYU3zUqpIXv5zVotE]
2021-11-01 08:59:18 --> invoice.paid [evt_1Jr2uoJZYU3zUqpI93eJ4hSz]
2021-11-01 08:59:19 --> invoice.payment_succeeded [evt_1Jr2uoJZYU3zUqpIIs78UuSP]
I'm sorry I don't really know what you're doing and what's errorring