#louislegourmet

1 messages · Page 1 of 1 (latest)

quartz lanternBOT
robust trout
#

Hi there

stray robin
#

Hi

#

Sorry I didn't see your message previously

robust trout
#

Okay so if you are using the Stripe CLI are you using the Webhook Secret that the CLI gave you?

#

No worries!

stray robin
#

Yes

#

I even printed it and checked that they are the same

#

I can show you the logs if you want

robust trout
#

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?

stray robin
#

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

robust trout
#

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

#

To grab the raw body immediately

stray robin
#

So I should just replace the request.getReader() by request.body() ?

robust trout
#

Depends on your framework

#

But yeah I'd try that

stray robin
#

I am not using spark but tomcat

#

So the request is a ```HttpServletRequest````object

#

There is no .body() method I am afraid :/

robust trout
#

Yeah I'm not familiar with tomcat but you will likely want to look at their docs for how to get the raw body

stray robin
#

(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

robust trout
#

Pretty sure you want the byte stream

stray robin
#

Oh okay I will try that then thank you

#

Thank you so much

#

This worked !!!