#gorbypark-webhook-secret
1 messages · Page 1 of 1 (latest)
Hello! Starting up a thread for you
Yes, that's where you'd look for the signing secret.
great, thanks. So I have something like this, ```js
const endpointSecret = 'whsec_redacted_redacted_redacted';
let event;
...
try {
event = stripe.webhooks.constructEvent(body, sig, endpointSecret);
} catch (err) {
console.log('wrong secret!!');
return new Response(JSON.stringify(err), {
status: 400,
headers: {'Content-Type': 'application/json'},
});
}
but still getting the catch returned
This is in node, right? With node it's really easy to accidentally not use the raw request, which is really important for signature verification
What do you get when you log body?
it's deno
i've logged the sig (header) but not the body, one sec
it appears the body is normal, ```
{
id: "evt_3Ldh1LIcQ9TvRlVs2fwndTrk",
object: "event",
api_version: "2020-08-27",
created: 1662152618,
data: {
object: {
id: "ch_3Ldh1LIcQ9TvRlVs2eUal5rj",
object: "charge",
amount: 1099,
...
I think this is probably relevant -https://github.com/stripe-samples/stripe-node-deno-samples/blob/main/webhook-signing/main.js.
It looks like with deno you need to use a different CryptoProvider
aha, i'll give that a go
hrm doesn't seem to do anything. i found another issue (i was using req.json() and the code you posted said req.text() is needed), but that didn't work either...
i might just wholesale copy that code and see if it works 😛
ok well that seemed to work...not sure what i was doing wrong, i'll scour my code to see what's up