From 819f88ac4e9d1a240d5f9b4e382604e6ce8c4a35 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 7 Mar 2024 14:00:13 -0600 Subject: [PATCH] fix: make sure internal request can go through --- .../src/core/services/process-stripe-webhook.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/skill-api/src/core/services/process-stripe-webhook.ts b/packages/skill-api/src/core/services/process-stripe-webhook.ts index b0ea601eb..1bad5e99b 100644 --- a/packages/skill-api/src/core/services/process-stripe-webhook.ts +++ b/packages/skill-api/src/core/services/process-stripe-webhook.ts @@ -38,14 +38,7 @@ export async function receiveInternalStripeWebhooks({ const { req, options: {nextAuthOptions}, - rawReq, } = params - if (!rawReq) { - return { - status: 500, - body: `no raw request found for stripe verification, check bodyParser config!`, - } - } const skillSecret = req.headers['x-skill-secret'] as string @@ -63,7 +56,7 @@ export async function receiveInternalStripeWebhooks({ } const stripe = paymentOptions?.stripeCtx.stripe || defaultStripe - const event: any = req.body + const event: any = req.body.event return await processStripeWebhook(event, { nextAuthOptions, @@ -150,14 +143,15 @@ export async function receiveStripeWebhooks({ .parse(process.env.TJS_SKILL_SECRET) const headers = new Headers({ + 'Content-Type': 'application/json', 'x-skill-secret': skillSecret, }) // not awaiting the fetch so that endpoint can return 200 right away - fetch(internalStripeWebhookEndpoint, { + await fetch(internalStripeWebhookEndpoint, { method: 'POST', headers, - body: JSON.stringify(event), + body: JSON.stringify({event}), }) return {status: 200, body: `handled by ${targetSiteName}`}