From 1e30e07ed52177a3ee470297aa5bbbc9e4fdf350 Mon Sep 17 00:00:00 2001 From: southseact-3d Date: Thu, 12 Feb 2026 11:51:51 +0000 Subject: [PATCH] fix: remove hardcoded subscription ID and rely on API queries - Removed hardcoded subscription ID from code - Rely on API queries to find subscriptions by customer or through fallback search - Added proper logging to diagnose customer/subscription mismatches --- chat/server.js | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/chat/server.js b/chat/server.js index dc06fbb..46b9894 100644 --- a/chat/server.js +++ b/chat/server.js @@ -12240,55 +12240,6 @@ async function handleAccountSettingsUpdate(req, res) { return foundSub.subscription_id || foundSub.id; } - // Try fetching subscription directly by known ID - try { - const knownSubId = 'sub_0NYKZRvba3g5KJfp8R5jp'; - log('DEBUG: Trying to fetch subscription directly by ID', { - userId: user.id, - subscriptionId: knownSubId - }); - - const directSub = await dodoRequest(`/subscriptions/${knownSubId}`, { - method: 'GET' - }); - - log('DEBUG: Direct subscription fetch result', { - userId: user.id, - subscriptionId: knownSubId, - found: !!directSub, - subStatus: directSub?.status, - subCustomerId: directSub?.customer?.customer_id, - currentCustomerId: customerId, - customerMatch: directSub?.customer?.customer_id === customerId - }); - - if (directSub && directSub.subscription_id) { - // Check if customer IDs match - if (directSub.customer?.customer_id && directSub.customer.customer_id !== customerId) { - log('CRITICAL: Subscription belongs to different customer!', { - userId: user.id, - storedCustomerId: customerId, - subscriptionCustomerId: directSub.customer.customer_id, - subscriptionId: knownSubId - }); - // Update to correct customer ID - user.dodoCustomerId = directSub.customer.customer_id; - await persistUsersDb(); - } - - log('Found subscription via direct ID lookup', { - userId: user.id, - subscriptionId: directSub.subscription_id, - status: directSub.status - }); - return directSub.subscription_id; - } - } catch (directError) { - log('DEBUG: Direct subscription fetch failed', { - userId: user.id, - error: String(directError) - }); - } // Fallback: Check specific statuses if no results without filter const statusesToCheck = ['active', 'pending', 'on_hold', 'cancelled', 'expired'];