Skip to content

Commit e8641d6

Browse files
waleedlatif1claude
andcommitted
fix(stripe): use static Stripe.webhooks for verification
Avoids instantiating a Stripe client just to access constructEvent. The webhook signing secret is per-trigger (user-provided whsec_…) and unrelated to our billing STRIPE_SECRET_KEY, so coupling them was wrong. Stripe.webhooks is exposed as a static — no client, no API key needed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 71c1176 commit e8641d6

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

apps/sim/lib/webhooks/providers/stripe.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { NextResponse } from 'next/server'
33
import Stripe from 'stripe'
4-
import { env } from '@/lib/core/config/env'
54
import type {
65
AuthContext,
76
EventFilterContext,
@@ -13,16 +12,6 @@ import { skipByEventTypes } from '@/lib/webhooks/providers/utils'
1312

1413
const logger = createLogger('WebhookProvider:Stripe')
1514

16-
/**
17-
* Stripe SDK instance used solely for `webhooks.constructEvent`. The API key is
18-
* not used by signature verification (purely local HMAC), but the SDK constructor
19-
* requires a value — pass the configured secret key when present to avoid leaving
20-
* a recognisable placeholder in heap dumps or error serialisations.
21-
*/
22-
const stripeClient = new Stripe(env.STRIPE_SECRET_KEY || '', {
23-
apiVersion: '2025-08-27.basil',
24-
})
25-
2615
export const stripeHandler: WebhookProviderHandler = {
2716
verifyAuth({ request, rawBody, requestId, providerConfig }: AuthContext) {
2817
const secret = providerConfig.webhookSecret as string | undefined
@@ -40,7 +29,7 @@ export const stripeHandler: WebhookProviderHandler = {
4029
}
4130

4231
try {
43-
stripeClient.webhooks.constructEvent(rawBody, signature, secret)
32+
Stripe.webhooks.constructEvent(rawBody, signature, secret)
4433
} catch (error) {
4534
logger.warn(`[${requestId}] Stripe signature verification failed`, {
4635
error: error instanceof Error ? error.message : String(error),

0 commit comments

Comments
 (0)