#goldenboy

1 messages ยท Page 1 of 1 (latest)

topaz mapleBOT
mighty jacinth
#

@winged pivot let's chat here!

winged pivot
mighty jacinth
#

I'm not familiar with honojs so I'll try to help as much as I can!

winged pivot
#

I think it has something to do with the rawbody

#

I tried top pass it in using different strategies

#

none of them worked

mighty jacinth
#

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
winged pivot
#

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

wild verge
#

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

winged pivot
#

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

wild verge
#

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?

winged pivot
#

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

wild verge
#

Hmm and converting the stream to a buffer doesn't do anything correct?

winged pivot
#

I tried both ways, passing it raw and passing it via Buffer.from(...)

wild verge
#

is the rawBody log from before you create a buffer or after?

winged pivot
#

before

wild verge
#

Oh okay, could you try just passing rawBody.value as a payload then?

#

without creating a buffer

winged pivot
#

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

wild verge
#

๐Ÿ˜ฆ

winged pivot
#

I spend a whole day on this, so frustrating

wild verge
winged pivot
#

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

wild verge
winged pivot
#

thank you for the help, I'll try some stuff and see where this goes