PR REVIEWMissing Idempotency in Payment Webhooks#1042StripeAirbnb
00:00Mid~15 min
PULL REQUEST
Open#1042 · 1 commit
Missing Idempotency in Payment Webhooks
mid-dev-44 wants to mergefeat/webhook-handlermain
MI
mid-dev-44
1 file changed · 2 hours ago
YOUR MISSION
The customer support team is flooded with tickets. Users are complaining they are being double-charged for "Pro" credits. The junior says "I checked the code, we only call the increment function once per request!"
Mid~15 min
HINTS (0/3 used)
REVIEWING AS
SR
Senior Engineer
@ Stripe · Backend Platform
src / api / webhooks / stripe.ts+2 0
10
10
export async function handleStripeWebhook(req: Request, res: Response) {
11
11
const event = req.body;
12
12
if (event.type === "charge.succeeded") {
13
13
const { userId, amount } = event.data.object.metadata;
14
+
// Grant credits to user
+
15
+
await db.user.incrementBalance(userId, amount);
+
16
16
}
17
17
return res.sendStatus(200);
18
18
}
Click any changed line (+/−) to flag an issue · or Approve if everything looks safe