#louislegourmet
1 messages · Page 1 of 1 (latest)
Hi there
Okay so if you are using the Stripe CLI are you using the Webhook Secret that the CLI gave you?
No worries!
Yes
I even printed it and checked that they are the same
I can show you the logs if you want
That's okay, I believe you.
If that is the case then it is most likely an issue with not having the raw body of the request
Most of the time this means something in your framework is manipulating the raw body before this verification occurs
How are you constructing your payload?
Mmh...I am using tomcat to deploy the java app and test it perhaps there is something to do with it?
String payload = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
String sigHeader = request.getHeader("Stripe-Signature");
This is how I define payload
Hmm yeah I would assume that is the issue then
You are going to want to look at that framework and see how you can get the raw body of the request
You can see in our webhook builder sample (https://stripe.com/docs/webhooks/quickstart?lang=java) that we just do String payload = request.body();
To grab the raw body immediately
So I should just replace the request.getReader() by request.body() ?
I am not using spark but tomcat
So the request is a ```HttpServletRequest````object
There is no .body() method I am afraid :/
Yeah I'm not familiar with tomcat but you will likely want to look at their docs for how to get the raw body
https://stackoverflow.com/questions/8100634/get-the-post-request-body-from-httpservletrequest
Yeah, I looked at this and it seems pretty similar to what I had written
(first answer)
It seems like String payload = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
allows mee to directly access the raw body of the request
Think https://stackoverflow.com/questions/5023718/how-to-retrieve-raw-post-data-from-httpservletrequest-in-java is what you want actually
Pretty sure you want the byte stream