From 0781c4c621a211026fe181866cd8e8536ec2e04d Mon Sep 17 00:00:00 2001 From: Artur <33733651+Keeqler@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:22:41 -0300 Subject: [PATCH] fix(webhooks): respond with 200 when done processing --- pages/api/printful/webhook.ts | 4 +++- server/utils/webhooks.ts | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pages/api/printful/webhook.ts b/pages/api/printful/webhook.ts index cadbe994..5f0d45b4 100644 --- a/pages/api/printful/webhook.ts +++ b/pages/api/printful/webhook.ts @@ -47,7 +47,7 @@ async function handlePrintfulWebhook(req: NextApiRequest, res: NextApiResponse) const body: Body = req.body if (body.type !== 'package_shipped') { - return res.end() + return res.status(200).end() } const { @@ -82,6 +82,8 @@ async function handlePrintfulWebhook(req: NextApiRequest, res: NextApiResponse) trackingUrl: body.data.shipment.tracking_url, trackingNumber: body.data.shipment.tracking_number, }) + + res.status(200).end() } export default handlePrintfulWebhook diff --git a/server/utils/webhooks.ts b/server/utils/webhooks.ts index 1f306cb1..eb56ba07 100644 --- a/server/utils/webhooks.ts +++ b/server/utils/webhooks.ts @@ -37,7 +37,7 @@ export function getStripeWebhookHandler(fundSlug: FundSlug, secret: string) { const metadata = paymentIntent.metadata as DonationMetadata // Skip this event if intent is still not fully paid - if (paymentIntent.amount_received !== paymentIntent.amount) return + if (paymentIntent.amount_received !== paymentIntent.amount) return res.status(200).end() const shouldGivePointsBack = metadata.givePointsBack === 'true' const grossFiatAmount = paymentIntent.amount_received / 100 @@ -149,9 +149,9 @@ export function getStripeWebhookHandler(fundSlug: FundSlug, secret: string) { } } } - - // Return a 200 response to acknowledge receipt of the event - res.status(200).end() } + + // Return a 200 response to acknowledge receipt of the event + res.status(200).end() } }