The following changes were made by the replace_file_content tool to: /root/aadharbot/modules/pay/controllers/paymentController.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission.
[diff_block_start]
@@ -81,6 +81,8 @@
'lifetime': 10 * 365 * 24 * 60 * 60 * 1000
};
const duration = planDurations[planType] || (30 * 24 * 60 * 60 * 1000);
+ const days = Math.round(duration / (24 * 60 * 60 * 1000));
+ const durationLabel = `${days} Days (${planLabel})`;
const planExpiresAt = new Date(Date.now() + duration);
const planExpiryStr = planExpiresAt.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' });
@@ -87,6 +87,20 @@
- `UPDATE users SET credits = credits - $1, plan_type = 'unlimited', plan_expires_at = $2, plan_started_at = NOW(), updated_at = NOW() WHERE telegram_id = $3`,
- [amount, planExpiresAt, userId]
+ `UPDATE users SET
+ credits = credits - $1,
+ plan_type = 'unlimited',
+ plan_expires_at = $2,
+ plan_started_at = NOW(),
+ subscription_duration = $3,
+ subscription_payment_method = 'Wallet Balance',
+ subscription_amount = $4,
+ updated_at = NOW()
+ WHERE telegram_id = $5`,
+ [amount, planExpiresAt, durationLabel, `₹${amount}`, userId]
);
+ await pool.query(
+ `INSERT INTO user_subscriptions (telegram_id, plan_name, duration, days, amount, payment_method, started_at, expires_at, status)
+ VALUES ($1, $2, $3, $4, $5, 'Wallet Balance', NOW(), $6, 'ACTIVE')`,
+ [userId, `${planLabel} Plan`, durationLabel, days, `₹${amount}`, planExpiresAt]
+ ).catch(() => {});
return ctx.reply(`✅ Payment Successful! (Paid from Wallet)\n\n` +
`💎 You have successfully purchased the ${planLabel} Plan for ₹${amount}.\n` +
[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.