Fix license cache not updating after checkout

The checkout.session.completed webhook only sent a welcome email but
did not update the subscription cache, so users kept getting cached
free status after paying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lawrence Hook
2026-02-21 17:30:29 -05:00
parent c5734518c4
commit 49e1a5d9ba
+3 -2
View File
@@ -35,13 +35,14 @@ router.post('/stripe', async (req, res) => {
try {
const email = session.customer_email || await getCustomerEmail(session.customer);
if (email) {
storage.setSubscriptionStatus(email, true, session.customer);
await sendWelcomeEmail(email);
console.log(`[webhook] Checkout completed: ${email} (welcome email sent)`);
console.log(`[webhook] Checkout completed: ${email} (cache updated, welcome email sent)`);
} else {
console.log(`[webhook] Checkout completed: ${session.customer} (no email found)`);
}
} catch (err) {
console.error(`[webhook] Checkout completed but welcome email failed:`, err.message);
console.error(`[webhook] Checkout completed but failed:`, err.message);
}
break;
}