#xingkong_63323
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- xingkong_63323, 2 hours ago, 3 messages
Hi there!
Getting a SignatureVerificationError is quite common. It usually comes from two potential errors:
- You are using the wrong webhook secret. So please double check you are using the correct one. It should look like whsec_xxx and match the one displayed in your dashboard
- The payload you pass in the constructEvent function is not the raw payload. So you need to ensure that you get the raw body of the HTTP request that Stripe sent you, without any interference by your code or framework in the middle.
To debug this you'll need to add logging to every value you pass to constructEvent (the payload, the secret, and the signature header) and then we can try to have a look at what part is wrong
Have you tried what I suggested above?
You check the code you wrote in your webhook endpoint, add print the variables (as explained above), and then check your server logs to see what is the output.
The logs seen on the stripe platform are the same as the logs I printed after receiving them
can you help look log on stripe
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
Can you help me check it
ok
com.stripe.exception.SignatureVerificationException: No signatures found matching the expected signature for payload
eventid : evt_3ODOhFAKQ4ll3SWp1PMvfIlE
This is the secret key of my hook: whsec_ MFNPFZ5w9eNzQ9osAZo6chldPXHZ2kJ0
Are you still there
Are you still there
Yes, I will take a look as soon as I can. It's busy today.
Are you sure you are using the correct webhook secret?
And there's no middleware that might modify the incoming webhook request in any way?
yes
private String getRequestBody(HttpServletRequest request) {
StringBuffer sb = new StringBuffer();
try (ServletInputStream inputStream = request.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
//log.error("读取数据流异常:{}", e);
}
return sb.toString();
}
我是通过这个方法获取的body
I obtained the body through this method
I see you're using local listener, and the requests are handled successfully. Is it using the same application code?
The obtained payload is different, and the other code is the same
The local listener uses Spark's framework to obtain 'payload', while the server uses: private String getRequestBody (HttpServletRequest request){
StringBuffer sb=new StringBuffer();
Try (ServletInputStream inputStream=request. getInputStream();
BufferedReader reader=new BufferedReader (new InputStreamReader (inputStream));
){
String line;
While (line=reader. readLine())= Null){
Sb. append (line);
}
}Catch (IOException e){
//Log. error ("Reading data stream exception: {}", e);
}
Return sb. toString();
It means it's not your code that might be modifying the incoming request. It's likely the webhook secret that's incorrect, or your hosting provider/proxy modifies the incoming requests.
I don't quite understand
What am I going to do
Can you help me see the difference between the log parameters of the stripe platform and the logs printed by my service
I'll give you the parameter log I printed and the hook key. Can you help me try it out
My network has gone through proxy
Do you think this proxy might modify the requests in any way? Add/remove request headers?
I'm not very clear. We usually cannot access foreign websites and must have an agent to access them
I will provide you with all the parameters, and your side will help me verify them
I think this will require a deeper investigation. Could you please write to Stripe Support and my engineering team will take over the case: https://support.stripe.com/?contact=true
Is the plan I mentioned feasible? Just give the parameters and secret key to verify
What plan exactly?
You can take a look at the corresponding request log for the stripe, and I will give you the secret key to verify if it is correct
I can't do it manually.
Aren't you a technician
Stripe code verifies signatures, not employees.