Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: don't retrigger old events

Marc Seitzb841c2854ded
diff --git a/ee/stripe/webhooks/checkout-session-completed.ts b/ee/stripe/webhooks/checkout-session-completed.ts
index 259d330d..27ed69e9 100644
--- a/ee/stripe/webhooks/checkout-session-completed.ts
+++ b/ee/stripe/webhooks/checkout-session-completed.ts
@@ -99,6 +99,15 @@ export async function checkoutSessionCompleted(
},
});
+ // if event creation time more than 1 hour ago, return
+ if (event.created > Date.now() - 1 * 60 * 60 * 1000) {
+ await log({
+ message: `Checkout session completed event created more than 1 hour ago: ${event.id}`,
+ type: "error",
+ });
+ return;
+ }
+
// Send thank you email to project owner if they are a new customer
await sendUpgradePlanEmail({
user: {