fix: suppress redundant STRIPE_WEBHOOK_SECRET warning when Stripe is unconfigured - #341
Open
driver727-pixel wants to merge 2 commits into
Open
fix: suppress redundant STRIPE_WEBHOOK_SECRET warning when Stripe is unconfigured#341driver727-pixel wants to merge 2 commits into
driver727-pixel wants to merge 2 commits into
Conversation
…figured The STRIPE_WEBHOOK_SECRET warning was emitted unconditionally at startup, even when STRIPE_SECRET_KEY itself was not set. This produced a redundant second warning alongside the existing STRIPE_SECRET_KEY warning for users who haven't configured Stripe at all. Change the independent 'if' to 'else if' so the webhook-secret warning only fires when Stripe is actually enabled (STRIPE_SECRET_KEY is present) but the webhook secret is missing. Co-authored-by: SP Digital <driver727@gmail.com>
Webhooks are an optional safety net — the client-side /api/verify-checkout-session endpoint already handles purchase reconciliation for the normal flow. A missing webhook secret is a deliberate configuration choice, not an error, so demote the log from console.warn to console.info and clarify that purchases still work without it. Co-authored-by: SP Digital <driver727@gmail.com>
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
STRIPE_WEBHOOK_SECRETwarning was emitted unconditionally at server startup as aconsole.warn, even when:STRIPE_SECRET_KEYitself was not set (redundant alongside the existing secret-key warning), or/api/verify-checkout-sessionendpoint already handles purchase reconciliation.Fix
if (!stripeWebhookSecret)toelse if, so the message only appears when Stripe is actually enabled but the webhook secret is missing.console.warntoconsole.infoand rewrote the message to clarify that purchases still work without webhooks — the verify-checkout-session endpoint handles the normal flow.Before
After (no Stripe key set)
After (Stripe key set, no webhook secret)
Context
The Stripe webhook (
/api/stripe/webhook) and the client-side verify endpoint (/api/verify-checkout-session) both callsyncPurchasedTier. The webhook is a redundant safety net for edge cases (e.g. user closes browser before redirect). The verify endpoint already handles the normal checkout flow, so a missing webhook secret is a valid configuration choice, not an error.