Skip to content

Commit

Permalink
More explicitly call out that constructEvent needs the raw body
Browse files Browse the repository at this point in the history
  • Loading branch information
jlomas-stripe committed Oct 4, 2017
1 parent 20f4a1e commit ab7968d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ stripe.off('request', onRequest);

Stripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it [here](https://stripe.com/docs/webhooks#signatures).

Please note that you must pass the _raw_ request body, exactly as received from Stripe, to the `constructEvent()` function; this will not work with a parsed (i.e., JSON) request body.

You can find an example of how to use this with [Express](https://expressjs.com/) in the [`examples/webhook-signing`](examples/webhook-signing) folder, but here's what it looks like:

```js
Expand Down
4 changes: 3 additions & 1 deletion lib/Webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ var signature = {

if (!signatureFound) {
throw new Error.StripeSignatureVerificationError({
message: 'No signatures found matching the expected signature for payload',
message: 'No signatures found matching the expected signature for payload.' +
' Are you passing the raw request body you received from Stripe?' +
' https://github.com/stripe/stripe-node#webhook-signing',
detail: {
header: header,
payload: payload,
Expand Down

0 comments on commit ab7968d

Please sign in to comment.