#xingkong_63323

1 messages · Page 1 of 1 (latest)

cinder gulchBOT
#

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.

tame plaza
#

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

blissful heath
#

event id : evt_3ODOhFAKQ4ll3SWp1nfedZO0

tame plaza
#

Have you tried what I suggested above?

blissful heath
#

日志记录在哪里看

#

Where to look at the log records

tame plaza
#

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.

blissful heath
#

can you help look log on stripe

sullen night
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

blissful heath
#

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

sullen night
#

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?

blissful heath
#

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

sullen night
#

I see you're using local listener, and the requests are handled successfully. Is it using the same application code?

blissful heath
#

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();

sullen night
#

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.

blissful heath
#

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

sullen night
#

Do you think this proxy might modify the requests in any way? Add/remove request headers?

blissful heath
#

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

sullen night
blissful heath
#

Is the plan I mentioned feasible? Just give the parameters and secret key to verify

sullen night
#

What plan exactly?

blissful heath
#

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

sullen night
#

I can't do it manually.

blissful heath
#

Aren't you a technician

sullen night
#

Stripe code verifies signatures, not employees.