question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

com.stripe.exception.SignatureVerificationException

See original GitHub issue

My webserver is a apache tomcat java servlet webserver. I keep getting the error com.stripe.exception.SignatureVerificationException: No signatures found matching the expected signature for payload.

I have tried to get the request body with req.getReader().lines().collect(Collectors.joining()) but I still get the error. This is what the payload looks like { "id": "evt_1GxflCKnr9az9gTnSx6pa7KT", "object": "event", "api_version": "2020-03-02", "created": 1593032637, "data": { "object": { "id": "cs_test_rwrNI9q1Zw2ESPjNtuJPtTMvbcIdTfv3JBoUk1Er7h0wiSAzmuxUMeVf", "object": "checkout.session", "billing_address_collection": null, "cancel_url": "https://example.com/cancel", "client_reference_id": null, "customer": "cus_HWjDEWSjC9No1F", "customer_email": null, "livemode": false, "locale": null, "metadata": { "message": "m", "buyerName": "m", "email": "gmyoungwps@gmail.com" }, "mode": "subscription", "payment_intent": null, "payment_method_types": [ "card" ], "setup_intent": null, "shipping": null, "shipping_address_collection": null, "submit_type": null, "subscription": "sub_HWjDjtufcasHFy", "success_url": "https://example.com/success?session_id={CHECKOUT_SESSION_ID}" } }, "livemode": false, "pending_webhooks": 1, "request": { "id": "req_BFygc4p4ANudUI", "idempotency_key": null }, "type": "checkout.session.completed"}. I am not sure how to get the rawbody the way that stripe wants me to with servlets.

I followed this documentation: https://stripe.com/docs/payments/checkout/set-up-a-subscription This error comes from the event = Webhook.constructEvent(payload, header, endpointSecret);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
georgemax99commented, Jun 25, 2020

If anyone comes here with my same problem here is how I got the raw body:

String payload = IOUtils.toString(req.getInputStream(), "UTF-8");

1reaction
fionnachancommented, Mar 29, 2021

@georgemax99 Thanks for sharing your solution. I was encountering the same issue and your solution works perfectly!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SignatureVerificationException (stripe-java 22.2.0 API)
Methods inherited from class com.stripe.exception.StripeException · getCode, getMessage, getRequestId, getStatusCode, getStripeError, getUserMessage, ...
Read more >
Check the webhook signatures | Stripe Documentation
Verifying signatures using our official libraries. Use one of our official libraries to verify signatures. You perform the verification by providing the event ......
Read more >
laravel - Stripe PHP Best way to debug an ... - Stack Overflow
To debug it i changes the http_response_code(400) and I realised it generate a SignatureVerificationException. My question is, how can i debug ...
Read more >
com.stripe.exception.SignatureVerificationException.<init ...
List<String> signatures = getSignatures(sigHeader, EXPECTED_SCHEME); if (timestamp <= 0) { throw new SignatureVerificationException( "Unable to extract ...
Read more >
Java Examples for com.stripe.exception ... - Javatips.net
Verifies the signature header sent by Stripe. Throws a * SignatureVerificationException if the verification fails for any reason.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found