Skip to content

Commit

Permalink
Merge pull request #120 from MAGICGrants/webhook-fixes
Browse files Browse the repository at this point in the history
fix(webhooks): respond with 200 when done processing
  • Loading branch information
Keeqler authored Dec 23, 2024
2 parents 37dafed + 0781c4c commit 8588a35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pages/api/printful/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions server/utils/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}

0 comments on commit 8588a35

Please sign in to comment.