title: Stripe Error: No signatures found matching the expected signature for payload
body: <p>I have a stripe webhook that call a Firebase function. In this function I need to verify that this request comes from Stripe servers. Here is the code :</p>
  <pre class="lang-js prettyprint-override"><code>const functions = require('firebase-functions');
  const bodyParser = require('body-parser');
  const stripe = require(&quot;stripe&quot;)(&quot;sk_test_****&quot;);
  const endpointSecret = 'whsec_****';
  const app = require('express')();
  
  app.use(bodyParser.json({
      verify: function (req, res, buf) {
          var url = req.originalUrl;
          if (url.startsWith('/webhook')) {
              req.rawBody = buf.toString()
          }
      }
  }));
  
  app.post('/webhook/example', (req, res) =&gt; {
      let sig = req.headers[&quot;stripe-signature&quot;];
  
      try {
          console.log(req.bodyRaw)
          let event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
          console.log(event);
          res.status(200).end()
  
          // Do something with event
      }
      catch (err) {
          console.log(err);
          res.status(400).end()
      }
  });
  
  exports.app = functions.https.onRequest(app);
  </code></pre>
  <p>As mentioned in <a href="https://stripe.com/docs/webhooks/signatures" rel="noreferrer">Stripe Documentation</a>, I have to use raw body to perform this security check.</p>
  <p>I have tried with my current code and with :</p>
  <pre class="lang-js prettyprint-override"><code>app.use(require('body-parser').raw({type: '*/*'}));
  </code></pre>
  <p>But I always get this error :</p>
  <pre><code>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#webhook-signing
  </code></pre>