The following changes were made by the replace_file_content tool to: /root/aadharbot/modules/pay/services/paymentService.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -806,6 +806,8 @@ if (planType !== 'credits' && planDurations[planType]) { // Apply Unlimited Plan const duration = planDurations[planType]; + const days = Math.round(duration / (24 * 60 * 60 * 1000)); + const durationLabel = `${days} Days (${planType.toUpperCase()})`; const planExpiresAt = new Date(Date.now() + duration); planExpiryStr = planExpiresAt.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' }); isPlanApplied = true; @@ -821,15 +821,30 @@ db[payment.userId].plan_type = 'unlimited'; db[payment.userId].plan_expires_at = planExpiresAt.toISOString(); db[payment.userId].plan_started_at = new Date().toISOString(); - fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); - } else { - await pool.query( - `INSERT INTO users (telegram_id, name, credits, plan_type, plan_expires_at, plan_started_at, created_at, updated_at) - VALUES ($1, 'User', 0, 'unlimited', $2, NOW(), NOW(), NOW()) - ON CONFLICT (telegram_id) - DO UPDATE SET plan_type = 'unlimited', plan_expires_at = EXCLUDED.plan_expires_at, plan_started_at = NOW(), updated_at = NOW()`, - [payment.userId, planExpiresAt] - ); + db[payment.userId].subscription_duration = durationLabel; + db[payment.userId].subscription_payment_method = 'UPI (QR Code)'; + db[payment.userId].subscription_amount = `₹${payment.expectedAmount}`; + fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); + } else { + await pool.query( + `INSERT INTO users (telegram_id, name, credits, plan_type, plan_expires_at, plan_started_at, subscription_duration, subscription_payment_method, subscription_amount, created_at, updated_at) + VALUES ($1, 'User', 0, 'unlimited', $2, NOW(), $3, 'UPI (QR Code)', $4, NOW(), NOW()) + ON CONFLICT (telegram_id) + DO UPDATE SET + plan_type = 'unlimited', + plan_expires_at = EXCLUDED.plan_expires_at, + plan_started_at = NOW(), + subscription_duration = EXCLUDED.subscription_duration, + subscription_payment_method = 'UPI (QR Code)', + subscription_amount = EXCLUDED.subscription_amount, + updated_at = NOW()`, + [payment.userId, planExpiresAt, durationLabel, `₹${payment.expectedAmount}`] + ); + await pool.query( + `INSERT INTO user_subscriptions (telegram_id, plan_name, duration, days, amount, payment_method, order_id, started_at, expires_at, status) + VALUES ($1, $2, $3, $4, $5, 'UPI (QR Code)', $6, NOW(), $7, 'ACTIVE')`, + [payment.userId, `${planType.toUpperCase()} Plan`, durationLabel, days, `₹${payment.expectedAmount}`, payment.orderId, planExpiresAt] + ).catch(() => {}); } [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.