From daccbaea6c2a77e19c7078387f6763299eac2617 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sun, 15 Feb 2026 15:40:42 -0800 Subject: [PATCH] fix(stripe): remove dead syncUserPlan call to deleted backend /api/users/:userId/plan route MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Python backend users.py route was deleted in the backend cleanup. Plan updates are already handled by authRepo.updatePlan() inline in each webhook handler — the syncUserPlan fetch was redundant dead code. --- .../src/modules/stripe/routes.ts | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/services/platform-service/src/modules/stripe/routes.ts b/services/platform-service/src/modules/stripe/routes.ts index 6fe61739..8d6d9272 100644 --- a/services/platform-service/src/modules/stripe/routes.ts +++ b/services/platform-service/src/modules/stripe/routes.ts @@ -20,26 +20,6 @@ import * as authRepo from '../auth/repository.js'; import * as subRepo from '../subscriptions/repository.js'; import type { SubscriptionDoc } from '../subscriptions/types.js'; -const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:8000'; - -/** Sync plan change back to the backend users container (best-effort). */ -async function syncUserPlan( - userId: string, - plan: string, - log?: { warn: (...args: unknown[]) => void } -): Promise { - try { - await fetch(`${BACKEND_URL}/api/users/${userId}/plan`, { - method: 'PUT', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ plan }), - }); - } catch (err) { - // Best-effort — don't fail the webhook if backend is unreachable - (log ?? console).warn(`Failed to sync plan to backend for ${userId}:`, err); - } -} - export async function stripeRoutes(app: FastifyInstance) { // ── Checkout ────────────────────────────────────────────── app.post('/stripe/checkout', async (req, reply) => { @@ -153,9 +133,6 @@ export async function stripeRoutes(app: FastifyInstance) { await authRepo.updatePlan(userId, eventProductId, plan as SubscriptionDoc['plan']); } - // Sync plan to backend users container - await syncUserPlan(userId, plan, app.log); - // Record payment if (session.amount_total && session.amount_total > 0) { await subRepo.createPayment({ @@ -195,8 +172,6 @@ export async function stripeRoutes(app: FastifyInstance) { currentPeriodEnd: new Date(sub.current_period_end * 1000).toISOString(), }); await authRepo.updatePlan(existing.userId, effectiveProductId, updatedPlan); - // Sync plan to backend users container - await syncUserPlan(existing.userId, updatedPlan, app.log); } break; } @@ -215,8 +190,6 @@ export async function stripeRoutes(app: FastifyInstance) { cancelAtPeriodEnd: false, }); await authRepo.updatePlan(existing.userId, effectiveProductId, 'free'); - // Sync plan downgrade to backend users container - await syncUserPlan(existing.userId, 'free', app.log); } break; }