#kucinglaut
1 messages · Page 1 of 1 (latest)
No unfortunately. Events in test mode are supposed to be sent to all Test mode endpoints
You can't stop them coming, but if you can distinguish them in your code, ie using metadata on each event, then probably it can work. But that's a lot of handling logic
yeah, I would like if I don't have to put that
but this is got me thinking, the status code in webhooks, is it supposed to mean that the message is successfully received, or successfully processed?
received. Stripe only care if you received
oh then I can just send 200 back after receiving then, the logic in processing does not matter right?
Yep. (Well it matter to your business logic though. It's just Stripe doesn't rely on it)
am I supposed to do it like this then?
try {
check signature(sig)
} catch (err) {
console.log(`❌ Error message: ${err}`)
res.status(400).send(`Webhook Error: ${errorMessage}`)
return
}
// Successfully constructed event.
console.log('Success:', event.id, " type: ", event.type)
res.status(200).json("{received: true}")
// Cast event data to Stripe object.
if (event.type === 'invoice.finalized') {
// ... business logic here etc ...
}
Hmm you can't run anything after res.status(200), can you? I think the code from if... will be ignored
I believe as long as there is no return yet, it still can run things 🤔 let me do a quick run
can confirm, it still goes
...well using res.json() only though
edit: res.status(200).json also works
okay I think it resolved the problem in staging environment, thank you for the help!