From be092ca6b595aeac84e5e0a6b274ce82e86456fa Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 12 Aug 2026 20:54:28 +0200 Subject: [PATCH] feat: add webhook signing key as config variable --- README.md | 3 ++- example.env | 1 + nuxt.config.ts | 1 + server/utils/handleStripeWebhook.ts | 2 +- src/plugins/types.d.ts | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70b1b00..fa9b059 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ There are no fully required configuration variables, the app can runs minimally | | `PN_WEBSITE_DISCORD_SUPPORTER_ROLE_ID` | Role to give for supporter access | (No role) | | | | | | | Payments | `PN_WEBSITE_STRIPE_SECRET_KEY` | Stripe secret key | - | -| (Requires `discord` feature) | `PN_WEBSITE_STRIPE_NOTIFICATION_EMAIL` | Email address to send stripe notifications to | (No notifications) | +| (Requires `discord` feature) | `PN_WEBSITE_STRIPE_WEBHOOK_SECRET` | Stripe webhook signing key | - | +| | `PN_WEBSITE_STRIPE_NOTIFICATION_EMAIL` | Email address to send stripe notifications to | (No notifications) | | | `PN_WEBSITE_MONGO_CONNECTION_STRING` | MongoDB connection string for account server | - | | | `PN_WEBSITE_SMTP_HOST` | Host for the SMTP server | - | | | `PN_WEBSITE_SMTP_PORT` | Port for the SMTP server | `587` | diff --git a/example.env b/example.env index c0e01ff..0a4a0e3 100644 --- a/example.env +++ b/example.env @@ -28,6 +28,7 @@ PN_WEBSITE_DISCORD_SUPPORTER_ROLE_ID= # Optional - Donation features + rewards (Requires discord): PN_WEBSITE_STRIPE_SECRET_KEY= +PN_WEBSITE_STRIPE_WEBHOOK_SECRET= PN_WEBSITE_STRIPE_NOTIFICATION_EMAIL=notifs@example.com PN_WEBSITE_MONGO_CONNECTION_STRING=mongodb://localhost:27017/account?directConnection=true PN_WEBSITE_SMTP_HOST=localhost diff --git a/nuxt.config.ts b/nuxt.config.ts index 05cff82..b613ced 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -33,6 +33,7 @@ export default defineNuxtConfig({ githubApiToken: '', stripeSecretKey: '', + stripeWebhookSecret: '', stripeNotificationEmail: '', hcaptchaSecretKey: '', grpcHost: '', diff --git a/server/utils/handleStripeWebhook.ts b/server/utils/handleStripeWebhook.ts index f0ce354..567468c 100644 --- a/server/utils/handleStripeWebhook.ts +++ b/server/utils/handleStripeWebhook.ts @@ -49,7 +49,7 @@ export async function handleStripeEvent(event: H3Event, stripe: Stripe, webhook: return; } - if (webhook.type === 'customer.subscription.updated' || webhook.type === 'customer.subscription.deleted') { + if (webhook.type === 'customer.subscription.updated' || webhook.type === 'customer.subscription.created' || webhook.type === 'customer.subscription.deleted') { const subscription = webhook.data.object; const subscriptionItem = subscription.items.data[0]; if (!subscriptionItem) { diff --git a/src/plugins/types.d.ts b/src/plugins/types.d.ts index 800f68e..63164d3 100644 --- a/src/plugins/types.d.ts +++ b/src/plugins/types.d.ts @@ -9,6 +9,7 @@ declare module 'nuxt/schema' { githubApiToken: string; stripeSecretKey: string; + stripeWebhookSecret: string; stripeNotificationEmail: string; hcaptchaSecretKey: string;