app.post('/api/checkout', async (req, res) => {
const { shieldRequestId, paymentData, userId } = req.body;
// Wait up to 3 seconds for Shield score
const shield = await waitForScore(shieldRequestId, 3000);
const score = shield?.score ?? 0;
if (score >= 100) {
// Block — bot/automation
await logFraudAttempt(userId, shield);
return res.status(403).json({
error: 'Payment declined. Please contact support.',
});
}
if (score >= 40) {
// Require extra verification
return res.status(200).json({
requiresVerification: true,
reason: 'Additional verification required for this session.',
});
}
// Clean session — proceed with payment
return processPayment(paymentData, userId, res);
});