#niceffect

1 messages ยท Page 1 of 1 (latest)

naive bloomBOT
lilac ivy
#

hi! I don't think there's anything missing but it's hard to say without context. There's many things that can cause problems with signature verification.

austere shard
#

Just a moment, I'll provide the context

#

this is my code:
String sigHeader = headers.get("stripe-signature");//stripe sign
HttpServletRequest request = RequestUtil.get();
InputStream inputStream = request.getInputStream();
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024*4];
int n = 0;
while (-1 != (n = inputStream.read(buffer))) {
output.write(buffer, 0, n);
}
byte[] bytes = output.toByteArray();
String payload = new String(bytes, "UTF-8");

log.info("call back stripe secret 1. sigHeader:{}, webhookSecret:{}",sigHeader,webhookSecret);
log.info("payload:{}",payload);
Event event = Webhook.constructEvent(payload, sigHeader, webhookSecret);

lilac ivy
#

and when you log those values do they look sensible? the webhookSecret is something like whsec_xxx ? the sigHeader is like v1=xxxx&t=xxxx? The payload looks like a JSON string, with whitespace and tabs in it?

austere shard
#

let me check

#

this is my sigHeader and webhook secret:
sigHeader:t=1699442491,v1=0ba7f6da0e6c21500e6c41b0349297d035f280fc87a801b4541d26c9d176619e,v0=2c4f8e2275621a4a34de929709ad3e323c16f45e6fdda24b19ec2060b3ffb303, webhookSecret:whsec_xxxxxxxxxxx

#

request header info

lilac ivy
#

ok. Have you triple checked that it's the right signing secret for this specific webhook endpoint(as shown in the Dashboard or the output of stripe-cli if that's what you're using) and you copied it correctly and without typos?

austere shard
#

yes

lilac ivy
#

ok. So what does the payload look like?

austere shard
lilac ivy
#

hmm seems good

#

feels like this should just work overall. From the logs I see, you are responding with a 200 status when we send you this event

#

I guess what specifically is happening, what specific error message are you seeing, and is that happening on your local machine using stripe-cli, or on your server

austere shard
#

dev server

lilac ivy
#

ok. So you agree with me that you are currently returning a 200 from that server right?

#

also you didn't answer about what specific error message you're seeing ๐Ÿ™‚ is there a stack trace or something or much more context?

austere shard
#

Okay, let me check again on my code

#

tks