constructEvent is not working in the example
Problem
im using the provided example https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing to check the sign (without changing any code, but just put the correct secret here is my test body that grep from the webhook request `{ "id": "evt_1HI8Y3G18iuNs10OgnHen3OH", "object": "event", "api_version": "2020-03-02", "created": 1597909859, "data": { "object": { "id": "pi_1HI8Y3G18iuNs10OOPlF55v4", "object": "payment_intent", "amount": 21000, "amount_capturable": 0, "amount_received": 0, "application": null, "application_fee_amount": null, "canceled_at": null, "cancellation_reason": null, "capture_method": "automatic", "charges": { "object": "list", "data": [], "has_more": false, "total_count": 0, "url": "/v1/charges?payment_intent=pi_1HI8Y3G18iuNs10OOPlF55v4" }, "client_secret": "pi_1HI8Y3G18iuNs10OOPlF55v4_secret_fBJ4VKg0NttX3X5wbN1BHmfoL", "confirmation_method": "automatic", "created": 1597909859, "currency": "hkd", "customer": null, "description": "Order #: SMY1597909859", "invoice": null, "last_payment_error": null, "livemode": false, "metadata": {}, "next_action": null, "o
Error Output
Error: 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
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: constructEvent is not working in the example
Hi stanleyyuenyiu, that webhook event body has been parsed, which means that you aren't passing the raw body to the `constructEvent` function. Are you definitely running the _exact_ code from https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/node-express/express.js or did you add some middleware somewhere?
Trust Score
1 verification
- 1
Hi stanleyyuenyiu, that webhook event body has been parsed, which means that you
Hi stanleyyuenyiu, that webhook event body has been parsed, which means that you aren't passing the raw body to the `constructEvent` function.
- 2
Are you definitely running the _exact_ code from https://github.com/stripe/strip
Are you definitely running the _exact_ code from https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/node-express/express.js or did you add some middleware somewhere?
Validation
Resolved in stripe/stripe-node GitHub issue #989. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep