#mr-stinky-pants_webhooks

1 messages ยท Page 1 of 1 (latest)

gleaming archBOT
#

๐Ÿ‘‹ 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/1304543557075468360

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

sly heart
#

Hello, thanks for the info. Can you tell me more about where you are getting stuck? Are you getting an error about a signature verification mismatch when trying to construct the event? Or something else?

errant fox
#

yes sorry it the dashboard its giving error 405

#

i cant see how to get some sort of response back from the endpoint to i know what the error is?

sly heart
#

Gotcha, if you are seeing a 405 in the CLI, that is because your local server is returning an error when it tries to process that event. So the way to see the error would be to resend the event and place a breakpoint endpoint's code to step through what is happening

#

A common cause for this is that our constructEvent method expects the raw request body that we sent you but a lot of frameworks do some processing on that body before it gets to your code. I see there is this stack overflow on getting the raw body in next.js if that helps https://stackoverflow.com/questions/69968460/nextjs-stripe-webhook-raw-body

errant fox
#

cheers ill check it

#

but shouldnt the try catch then allow the end point to send a message back to stripe?

sly heart
#

Yes it does and you can typically see it in your event logs https://dashboard.stripe.com/test/events
One thing that unfortunately gets in the way of this is our CLI endpoints and it looks like you are using one at the moment. The CLI itself responds with a 200 so it usually just looks like a success in our logs even if your local server errored out in some way

errant fox
#

i dont see why in the logs the response is like a stripe payment intent?

#

shouldnt it be the response i send from the endpoint

sly heart
#

It should show the request body, which is what we sent to your endpoint, and then the "HTTP status code" and "Response body" which are what we got back from your server

errant fox
sly heart
#

Oh and it looks like we should actually show what your local server sent back.

#

That is the API request that you made to us, so in that case the request body is your request to stripe and the response is what we sent you back, which would be a payment intent object in this case

errant fox
#

yes i see it now

#

Webhook Error: Webhook payload must be provided as a string or a Buffer

sly heart
#

Ah there we go, so I think the SO that I linked to should help. It shows how to get the raw event body as a buffer

errant fox
#

you dont need any packages i dont think

#

just this

#

const buf = await request.text();
event = stripe.webhooks.constructEvent(buf, sig, endpointSecret);

sly heart
#

Nice! that is way easier

errant fox
#

yes got there i think getting past that stage anyway

#

so its events not logs i need to be looing at

sly heart
#

Yep yep, events are what Stripe sends you, logs are when you make requests to stripe

errant fox
#

got it cheers

#

thanks for your help

#

๐Ÿ‘

sly heart
#

Of course, have a good weekend!