The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update charge-failed.ts
Kiran K44c9fdd6b803
diff --git a/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts b/apps/web/app/(ee)/api/stripe/webhook/charge-failed.tsindex 320d0f70bd..763dd4c49b 100644--- a/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts+++ b/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts@@ -218,18 +218,8 @@ async function processRenewalInvoice({ invoice }: { invoice: Invoice }) {},});- // if invoice failed attempts is less than 3, retry in 3 days- // otherwise, turn off auto-renew for the domains- if (invoice.failedAttempts < 3) {- await qstash.publishJSON({- url: `${APP_DOMAIN_WITH_NGROK}/api/cron/invoices/retry-failed`,- delay: 3 * 24 * 60 * 60, // 3 days in seconds- deduplicationId: `${invoice.id}-attempt-${invoice.failedAttempts + 1}`,- body: {- invoiceId: invoice.id,- },- });- } else {+ // Domain renewal failed 3 times, turn off auto-renew for the domains+ if (invoice.failedAttempts >= 3) {await Promise.allSettled(domains.map((domain) =>setRenewOption({@@ -238,10 +228,18 @@ async function processRenewalInvoice({ invoice }: { invoice: Invoice }) {}),),);+ }- // TODO:- // Archive the domains- // Remove from Vercel+ // We'll retry the invoice 3 times, if it fails 3 times, we'll turn off auto-renew for the domains+ if (invoice.failedAttempts < 3) {+ await qstash.publishJSON({+ url: `${APP_DOMAIN_WITH_NGROK}/api/cron/invoices/retry-failed`,+ delay: 3 * 24 * 60 * 60, // 3 days in seconds+ deduplicationId: `${invoice.id}-attempt-${invoice.failedAttempts + 1}`,+ body: {+ invoiceId: invoice.id,+ },+ });}const workspace = await prisma.project.findUniqueOrThrow({@@ -263,7 +261,7 @@ async function processRenewalInvoice({ invoice }: { invoice: Invoice }) {const workspaceOwners = workspace.users.filter(({ user }) => user.email);if (workspaceOwners.length === 0) {- console.log("No users found to send domain renewal failed email.");+ console.log("No workspace owners found, skipping...");return;}