Webhook signature verification and bodyParser.json issue
Problem
If you use in your express app `bodyParser.json()` for all routes, and then have a dedicated route for stripe's webhook, then the second call to `bodyParser.json({verify: ...})` as done in the example has no effect. I have the following code: [code block] The StripeRoute is defined exactly as the example. Unfortunately it doesn't work. Only if I comment out the first call to `bodyParser.json` does it work. Which mean that I cannot have a call to `bodyParser` just for my route, I need to add the `verify` function my top call to `bodyParser.json` and to avoid having to pay for the conversion all the time check for the Url to match my stripe route. Maybe the doc should reflect that, and if it is supposed to work then some guidance as it doesn't for me. Thanks!
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Webhook signature verification and bodyParser.json issue
@ronzeidman Thanks for sharing your solution, mine is: [code block] At the end it does what we need but I think it should be provided in the doc as currently you might think that the example would be easily plug-able as is but it is not.
Trust Score
9 verifications
- 1
@ronzeidman Thanks for sharing your solution, mine is:
@ronzeidman Thanks for sharing your solution, mine is:
- 2
At the end it does what we need but I think it should be provided in the doc as
At the end it does what we need but I think it should be provided in the doc as currently you might think that the example would be easily plug-able as is but it is not.
Validation
Resolved in stripe/stripe-node GitHub issue #341. Community reactions: 115 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep