From 7a3c99886d4b3682cd56617328c62c5f9e1af5e8 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Wed, 30 Oct 2019 14:40:16 +0700 Subject: [PATCH] Added logging for failed webhook verification no-issue This gives us some more information about the secret used --- ghost/members-api/lib/stripe/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ghost/members-api/lib/stripe/index.js b/ghost/members-api/lib/stripe/index.js index 95c1355970..30630d0878 100644 --- a/ghost/members-api/lib/stripe/index.js +++ b/ghost/members-api/lib/stripe/index.js @@ -80,9 +80,14 @@ module.exports = class StripePaymentProcessor { } async parseWebhook(body, signature) { - const event = await this._stripe.webhooks.constructEvent(body, signature, this._webhookSecret); - debug(`Parsed webhook event: ${event.type}`); - return event; + try { + const event = await this._stripe.webhooks.constructEvent(body, signature, this._webhookSecret); + debug(`Parsed webhook event: ${event.type}`); + return event; + } catch (err) { + this.logging.error(`Error verifying webhook signature, using secret ${this._webhookSecret}`); + throw err; + } } async createCheckoutSession(member, planName, options) {