The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
fix: update webhook handler
Mythie603cc1cb0d17
diff --git a/packages/ee/server-only/stripe/webhook/handler.ts b/packages/ee/server-only/stripe/webhook/handler.tsindex 825c266cf..c063ee2d9 100644--- a/packages/ee/server-only/stripe/webhook/handler.ts+++ b/packages/ee/server-only/stripe/webhook/handler.ts@@ -52,7 +52,31 @@ export const stripeWebhookHandler = async (// eslint-disable-next-line @typescript-eslint/consistent-type-assertionsconst session = event.data.object as Stripe.Checkout.Session;- const userId = Number(session.client_reference_id);+ const customerId =+ typeof session.customer === 'string' ? session.customer : session.customer?.id;++ let userId = Number(session.client_reference_id);++ if (!userId && customerId) {+ const result = await prisma.subscription.findFirst({+ select: {+ userId: true,+ },+ where: {+ customerId,+ },+ });++ if (!result?.userId) {+ return res.status(500).json({+ success: false,+ message: 'User not found',+ });+ }++ userId = result.userId;+ }+const subscriptionId =typeof session.subscription === 'string'? session.subscription