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.

[Stripe] No signatures found matching the expected signature for payload.

See original GitHub issue

I am trying to configure Stripe webhooks and it doesn’t seem to work for me:

I configured the app:

StripeModule.forRoot(StripeModule, {
      apiKey: stripeSecretKey,
      webhookConfig: {
        stripeWebhookSecret: stripeWebhookSecret,
        // controllerPrefix: 'webhooks/stripe', // seems to have no effect
      },
    }),

And created a handler service:

@Injectable()
export class WebhookService {
  @StripeWebhookHandler('*')
  handlePaymentIntentCreated(evt: Stripe.Event) {
    // execute your custom business logic
    console.log(evt);
  }
}

I used stripe-cli (./stripe listen --forward-to localhost:3000/stripe/webhook) to forward webhooks to my dev instance and triggered a webhook customer.updated event from the dashboard, which throws:

[Nest] 126333  - 04/23/2022, 12:55:43 PM     LOG [NestApplication] Nest application successfully started +2ms
[Nest] 126333  - 04/23/2022, 12:55:53 PM   ERROR [ExceptionsHandler] 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
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
    at validateComputedSignature (/home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/stripe/lib/Webhooks.js:208:11)
    at Object.verifyHeader (/home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/stripe/lib/Webhooks.js:103:5)
    at Object.constructEvent (/home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/stripe/lib/Webhooks.js:10:20)
    at StripePayloadService.tryHydratePayload (/home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/@golevelup/nestjs-stripe/src/stripe.payload.service.ts:23:39)
    at StripeWebhookController.handleWebhook (/home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/@golevelup/nestjs-stripe/src/stripe.webhook.controller.ts:31:45)
    at /home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/@nestjs/core/router/router-execution-context.js:38:29
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at /home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at /home/alko/Development/IvanOnTech/Moralis/moralis-billing-coordinator-stripe/node_modules/@nestjs/core/router/router-proxy.js:9:17

I’ve created a min repo from typescript starter: https://github.com/alko89/nest-stripe-webhook

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
lapwatcommented, Aug 18, 2022

In my case, I set the bodyParser to false but forgot to comment the following lines referencing the body parse.

  const app = await NestFactory.create(AppModule, { bodyParser: false });
  // app.use(bodyParser.json({ limit: '5mb' }));                           <-- should also be commented
  // app.use(bodyParser.urlencoded({ limit: '5mb', extended: true }));     <-- should also be commented
1reaction
gogo199432commented, May 18, 2022

I have the same issue but also have the bodyParser off like @displaynone is suggesting. Interestingly it seems to work when I use StripeCLI and a local deploy but if I deploy it on my test environment then it fails for some reason

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stripe Error: No signatures found matching the expected ...
Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Read more >
Webhook validate signing error: No signature found matching ...
I want to verify all my received WebHooks from Stripe. ... Error message: No signatures found matching the expected signature for payload.
Read more >
Check the webhook signatures | Stripe Documentation
Use one of our official libraries to verify signatures. You perform the verification by providing the event payload, the Stripe-Signature header, ...
Read more >
Stripe Webhook Error on Vercel server: No signatures ... - Reddit
I've been running into an issue with Stripe Webhooks and Vercel, ... No signatures found matching the expected signature for payload.
Read more >
Stripe & Laravel Cashier - Signature not found - Laracasts
'No signatures found matching the expected signature for payload'. I've checked the docs and I have already added the Stripe webhook secret key...
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