mansuriamaan803/SANJEEVFFSTORE_botPublic · Bot Template

AIThis bot is a commerce platform for selling digital products, primarily focused on FreeFire accounts and related services. It provides admin tools for managing products, categories, stock, reseller roles, and a balance system for user payments. Users can browse products, apply coupons, and check their balance through an interactive interface with premium emojis and inline keyboards.

Commercecommercestoreproductsresellerbalancecoupon
ProfileTelegram
102 commands0 envUpdated 12d agoCreated Aug 26, 2026
Back to folder

commands/_confirm_reseller_upgrade.js

javascript · 102 lines

Raw
1/**#command2name: /confirm_reseller_upgrade3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 👑 Reseller Upgrade — Confirm button handler14// Balance sufficient -> instant upgrade. Insufficient -> shortfall QR15// (payment completion handled automatically in _onCheck.js).16// =========================================================17 18try {19  var userId = String(user.telegramid);20  var chatId = chat.chatid;21 22  if (Bot.getProperty("is_reseller_" + userId)) {23    Bot.sendMessage("💎 Aap already ek Reseller hain!");24    return;25  }26 27  var price = Number(Bot.getProperty("reseller_upgrade_price") || 0);28  if (!price) {29    Bot.sendMessage("❌ Reseller Upgrade price admin ne abhi set nahi kiya.");30    return;31  }32 33  var unifiedBal = (function () {34    var resBal = 0;35    try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}36    var bonusBal = Number(Bot.getProperty("balance" + userId) || 0);37    return resBal + bonusBal;38  })();39 40  function grantReseller(chatIdTarget) {41    Bot.setProperty("is_reseller_" + userId, true, "boolean");42    var congratsText =43      "<blockquote><tg-emoji emoji-id='6102856637343600044'>🎉</tg-emoji> <b>CONGRATULATIONS!</b></blockquote>\n\n" +44      "<tg-emoji emoji-id='6215386799133433653'>👑</tg-emoji> <b>You are now a Reseller!</b>\n\n" +45      "<i>Aapko ab har product/plan par reseller pricing milegi, priority processing, aur reseller-only stock ka access. Enjoy your upgraded status!</i>";46    Api.sendMessage({47      chat_id: chatIdTarget,48      text: congratsText,49      parse_mode: "HTML",50      reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Explore Shop", callback_data: "/buy_hack", style: "success", icon_custom_emoji_id: "5866053971960929280" }]] })51    });52 53    var ownerId = Bot.getProperty("owner_id") || "8963001413";54    try {55      Api.sendMessage({56        chat_id: ownerId,57        text: "👑 <b>NEW RESELLER!</b>\n👤 <b>User:</b> <code>" + userId + "</code>\n💰 <b>Paid:</b> ₹" + price.toFixed(2),58        parse_mode: "HTML"59      });60    } catch (e) {}61  }62 63  if (unifiedBal >= price) {64    try { Libs.ResourcesLib.userRes("balance").add(-price); } catch (e) {}65    grantReseller(chatId);66  } else {67    var needToPay = price - unifiedBal;68    User.setProperty("buy_reseller_upgrade", true, "boolean");69    User.setProperty("buy_reseller_price", price, "number");70 71    var genText = "<tg-emoji emoji-id='6100657257605763582'>⏳</tg-emoji> <b>Creating order for ₹" + needToPay.toFixed(2) + ", please wait...</b>";72    if (request && request.message) {73      Api.editMessageText({ chat_id: String(chatId), message_id: Number(request.message.message_id), text: genText, parse_mode: "HTML" });74      try {75        Bot.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");76        User.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");77      } catch (e) {}78    } else {79      var genMsg = Api.sendMessage({ chat_id: chatId, text: genText, parse_mode: "HTML" });80      try {81        var gmid = (genMsg && genMsg.result && genMsg.result.message_id) ? genMsg.result.message_id : (genMsg && genMsg.message_id ? genMsg.message_id : null);82        if (gmid) {83          Bot.setProperty("gen_msg_id_" + userId, gmid, "string");84          User.setProperty("gen_msg_id_" + userId, gmid, "string");85        }86      } catch (e) {}87    }88 89    var upi_id = "mansuri-sarfaraz@fam";90    HTTP.get({91      url: "https://fampay.anujbots.xyz/qr.php?upi=" + encodeURIComponent(upi_id) + "&amount=" + encodeURIComponent(needToPay.toFixed(2)),92      success: "/onQR",93      error: "/onApiError"94    });95  }96 97  var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;98  if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: String(queryId) }); } catch (e) {} }99 100} catch (err) {101  Bot.sendMessage("⚠️ Error: " + err.message);102}