#fujiwara_codes

1 messages ยท Page 1 of 1 (latest)

turbid ferryBOT
elfin marsh
#

hello! taking a look ๐Ÿ‘€

copper leaf
#

thanks!

elfin marsh
#

hmmm, generally there're 3 main reasons as to why you get a 400 :

  1. wrong webhook secret - you've already confirmed that this is correct. But i would just log it during runtime again to make sure.
  2. The encoding on the string with the event data is not set to UTF-8. (Stripe treats everything as UTF-8 in our API, and so the string we would have signed ends up being different than the one the user sees. If this is the case, you'll need to enforce the encoding in your code.)
  3. Something in your application/server is changing the raw body of the raw body HTTP request that Stripe sends.

I'm not that familiar with Ruby, but what you can try doing is to download our sample code here : https://stripe.com/docs/webhooks/quickstart as it is for Ruby, change it to the CLI's webhook secret key. Try it to see if it works with the sample code. If it does work with the same key, you'll know the reason is probably 2 or 3 with your server./code

copper leaf
#

Thanks, I'll try that now

copper leaf
#

@elfin marsh Fortunately, none of those were the issue. In Stripe::Webhook.construct_event, the input parameters should be payload, sig_header, endpoint_secret not sig_header, payload, endpoint_secret. I had them in the wrong order ๐Ÿ˜‚ It's always the small things. Anyway just thought I'd let you know it's solved just in case anyone experiencing the same issue reads this. Thanks for your help though. Stripe team is awesome!

tender nebula
#

Great that you found the error!