#basieboots_webhooks

1 messages ยท Page 1 of 1 (latest)

azure zincBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1231855218686164992

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

gentle violetBOT
vocal halo
#

Your webhook endpoint returned 404 , and the response body says Cannot POST /api/v1/stripe/webhook

#

Can you check you webhook endpoint and make sure it accepts POST requests to /api/v1/stripe/webhook ?

pearl flame
#

it can accept post requests to that route. If I switch to the unverified (for instance using just the req.body.type example instead of using the stripe signatures) I get a 200 response. That's why I'm pretty sure the issue is with the event = stripe.webhooks.constructEvent function especially since when I try to console log the event.type it doesn't happen

vocal halo
#

That's different from what I saw in event log. Or is there a different event ID that I should take a look at ?

pearl flame
#

here's the start of the webhook function:

#

exports.webhook = asyncHandler(async (req, res, next)=> {
console.log('Webhook started');
const sig = req.headers['stripe-signature'];
console.log(stripe signature: ${sig});
// console.log(req.body.type);

let event;

try {
console.log('constructing stripe webhook event');
console.log(req.body);
//Verify the stripe secret key and stripe webhook secret key as well as jwt
event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
console.log(event type ${event.type});
} catch (err) {
res.status(400).send(Webhook Error: ${err.message});
return;
}

// // const event = req.body.type;
// const event = req.body;

// Handle the event
switch (event.type) {

#

the console.log up to the one before event = stripe.webhooks.constructEvent work, so my server is getting the post request

#

it's just not constructing your event

vocal halo
#

OK, did you sepcify the correct webhook secret? i.e., the one from your Dashboard, not the one from Stripe CLI.

pearl flame
#

so I just watched your youtube node starter and I'm pretty sure he used the cli one... but switching to the one from my dashboard didn't change anything at least from what I can see

vocal halo
#

I believe the video is about setting up a local webhook listener and that's why the local webhook secret is used.

#

Can you share with me the latest webhook event ID after the change?

pearl flame
#

I'm working on my local host right now

#

evt_3P8GsGKyc5KZ78km1uOyiHTK

#

I'm using flutter_stripe so it might be that one of the url's throughout might be pointing to my end client instead of my local host...

#

but is there any way to check if you received that event = stripe.webhooks.constructEvent request that I sent out?

vocal halo
#
Signature verification is impossible without access to the original signed material. 
Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing
pearl flame
#

I have to go and I'll be back in 30 minutes

vocal halo
#

This is the response from your local webhook endpoint.

pearl flame
#

ok I can throw in the body parser thing and try that

#

is there somewhere I can see that response?

vocal halo
pearl flame
#

I don't see that error message anywhere.... I'm new to using the dashboard so

vocal halo
#

You need to expand it

pearl flame
#

oh I found it

#

I expanded everything else but that ๐Ÿ™‚

#

thanks the biggest thing is to find where I can find the error messages ๐Ÿ™‚

#

have a great day! I should be able to work this out from here I think

#

thanks!

vocal halo
#

So the problem isn't with the webhook secret, you need to pass in the raw request body, not the parsed Json object/

#

You might check if you project has a middleware somewhere that parse the raw request body into json object.

pearl flame
#

yeah I thought we did

#

which is why I didn't put in the body parser part