#goldenboy
1 messages ยท Page 1 of 1 (latest)
@winged pivot let's chat here!
I'm not familiar with honojs so I'll try to help as much as I can!
I think it has something to do with the rawbody
I tried top pass it in using different strategies
none of them worked
Devs usually receive the signature error for one of two reasons:
- the signature they've configured in their server code does not match the signature returned in your Stripe Dashboard
- or, your webhook handler code is editing the raw body of the event in some way
yea I saw such cases on stackoverflow
chatgpt also suggested that
I would assume that const rawBody = c.req.raw.body should not change the signature, but it returns a readable stream while stripe expect a buffer or string
Hello ๐
Can you try printing rawBody?
You should ideally be seeing buffered data and NOT json
if you're seeing JSON then that means something in your server is parsing the body as it comes in. Once parsed, webhook won't be able to construct an event body from it. It has to be untouched
before I used c.req.arraybuffer assuming it would pass it the rawbody untouched, but c.req.raw.body returns a readable stream, while stripe signature verification accepts only a string, buffer, Arraybuffer or array-likes
Hmm, as roadrunner mentioned our team doesn't know a ton about honojs
I see you are also creating a buffer from the ArrayBuffer of rawBody
What happens if you make the following change
const rawBody = c.req.body or const rawBody = c.req.rawBody
Also can you share your complete code for the webhook handler?
c.req.rawBody does not exist, only c.req.raw.Body which is a readable stream and its log is screenshotted above
the rest of the webhook handler is just a switch statement and does not do much, because the signature verification fails before doing anything
Hmm and converting the stream to a buffer doesn't do anything correct?
is the rawBody log from before you create a buffer or after?
before
Oh okay, could you try just passing rawBody.value as a payload then?
without creating a buffer
rawbody has no value method, only values() which is an asynciterableiterator, but the stripe function wants a string or a buffer
I just tried this:
didn't work either
๐ฆ
I spend a whole day on this, so frustrating
definitely understand the frustration. Might be a silly question but do you think this is specific to honojs?
Cloudflare's example here directly parses body using text() from the request
https://blog.cloudflare.com/announcing-stripe-support-in-workers/
I suspect that it might be a hono specific issue, worst case I just switch to something else, but dont know if express works on cloudflare workers
This thread seems to suggest it isn't supported but looks like there are alternatives
https://community.cloudflare.com/t/express-support-for-workers/390844
thank you for the help, I'll try some stuff and see where this goes