indrajitghosh20006/Igstore_01botPublic Β· Bot Template

ProfileTelegram

AIThe bot provides an admin interface for a digital store, allowing the owner or co‑admins to add balances, products, plans, and categories. It supports payment workflows via UPI and Binance Pay, automatically generating QR codes and handling manual approval of deposits. The code patches inline keyboards to use premium emoji icons and includes helper functions for user and bot properties. Overall, it serves as a commerce management tool for a Telegram-based storefront.

Commercestoreadminbalanceproductplancategory
170 commands0 envUpdated 8h agoCreated Oct 30, 2026
Back to folder

commands/_onVerifyResult.js

javascript Β· 206 lines

Raw
1/**#command2name: /onVerifyResult3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// PREMIUM BUTTON ICONS13(function(){14  try {15    if (!JSON.__premiumPatched) {16      var __origStringify = JSON.stringify;17      JSON.stringify = function(value, replacer, space) {18        try {19          if (value && value.inline_keyboard && Array.isArray(value.inline_keyboard)) {20            var premiumIds = [21              "6143444134125379822",22              "6091379307907652768",23              "6147534454819661264",24              "6147817325660741985",25              "6235683689292897318",26              "6102856637343600044"27            ];28            var rows = value.inline_keyboard.map(function(row, ri) {29              if (!Array.isArray(row)) return row;30              return row.map(function(btn, bi) {31                if (!btn || typeof btn !== "object") return btn;32                var copy = {};33                for (var k in btn) copy[k] = btn[k];34                if (!copy.icon_custom_emoji_id) copy.icon_custom_emoji_id = premiumIds[(ri + bi) % premiumIds.length];35                return copy;36              });37            });38            var cloned = {};39            for (var key in value) cloned[key] = value[key];40            cloned.inline_keyboard = rows;41            return __origStringify.call(JSON, cloned, replacer, space);42          }43        } catch (e) {}44        return __origStringify.call(JSON, value, replacer, space);45      };46      JSON.__premiumPatched = true;47    }48  } catch (e) {}49})();50 51 52 53// =========================================================54// πŸš€ COMMAND = /onVerifyResult55// STATUS: ERROR-FREE DATA VALIDATION PIPELINE56// =========================================================57 58try {59  if (!content) {60    Bot.sendMessage("⚠️ Server response was blank. Please contact admin if payment was deducted.");61    return;62  }63 64  var res = (typeof content === "object") ? content : null;65  if (!res) {66    try { res = JSON.parse(content); } catch (e) { res = null; }67  }68 69  // Aapke response scheme ke mutabik status handle matrix70  var paymentVerified = (res && (res.status === "success" || res.status === "PAID" || res.success === true));71  var live_amount = res && res.data && res.data.amount ? res.data.amount : (User.getProperty("deposit_amount") || "0");72  var order_id = params ? params.trim() : "UNKNOWN";73 74  // βœ… BUG FIX: pehle yaha QR message delete/clear karne ka koi code hi nahi tha,75  // isi wajah se balance add hone ke baad bhi purana QR code chat me pada reh76  // jaata tha. Ab /onCheck.js jaisa hi vanish + state-clear logic add kiya gaya77  // hai taaki verify hote hi QR turant hat jaaye.78  var verifyUserId = (typeof user !== "undefined" && user) ? user.telegramid : null;79  var verifyChatId = (typeof chat !== "undefined" && chat) ? chat.chatid : null;80 81  function vanishQrOnVerify(uid, fallbackChatId) {82    try {83      var qrMsgId = Bot.getProperty("qr_msg_id_" + uid) ||84                    User.getProperty("qr_msg_id_" + uid) ||85                    User.getProperty("last_qr_message_id_" + uid);86      if (qrMsgId && fallbackChatId) {87        try { Api.deleteMessage({ chat_id: fallbackChatId, message_id: qrMsgId }); } catch (e) {}88      }89    } catch (e) {}90  }91 92  function clearQrStateOnVerify(uid) {93    if (!uid) return;94    Bot.setProperty("qr_msg_id_" + uid, null, "string");95    User.setProperty("qr_msg_id_" + uid, null, "string");96    User.setProperty("last_qr_message_id_" + uid, null, "string");97    Bot.setProperty("qr_order_id_" + uid, null, "string");98    User.setProperty("qr_order_id_" + uid, null, "string");99    Bot.setProperty("qr_watch_order_" + uid, null, "string");100    User.setProperty("qr_watch_order_" + uid, null, "string");101    Bot.setProperty("verifying_lock_" + uid, false, "boolean");102    User.setProperty("verifying_lock_" + uid, false, "boolean");103    User.setProperty("pending_order_id", null);104  }105 106  if (paymentVerified == true) {107 108    // Payment verify hote hi sabse pehle QR ko vanish karo (product delivery ho109    // ya sirf wallet balance add β€” dono cases me QR hatna chahiye)110    vanishQrOnVerify(verifyUserId, verifyChatId);111    clearQrStateOnVerify(verifyUserId);112 113    var prodIdx = User.getProperty("last_selected_prod_idx");114    var planIdx = User.getProperty("last_selected_plan_idx");115    var productList = Bot.getProperty("stored_products") || [];116    117    var product = (prodIdx !== undefined && prodIdx !== null) ? productList[Number(prodIdx)] : null;118    var plan = (product && planIdx !== undefined && planIdx !== null) ? product.plans[Number(planIdx)] : null;119 120    if (product && plan) {121      // 🟒 CASE A: DIRECT KEY EXTRACTION122      var stockList = Bot.getProperty("stock_" + product.name.trim() + "_" + plan.days.trim() + "_Day") || Bot.getProperty("stock_" + prodIdx + "_" + planIdx) || [];123      124      if (stockList.length > 0) {125        var deliveredKey = stockList.shift();126        127        Bot.setProperty("stock_" + product.name.trim() + "_" + plan.days.trim() + "_Day", stockList, "json");128        Bot.setProperty("stock_" + prodIdx + "_" + planIdx, stockList, "json");129        130        var userKeysHistory = User.getProperty("my_purchased_keys") || [];131        userKeysHistory.push({ product: product.name, days: plan.days, price: live_amount, key: deliveredKey, date: new Date().toLocaleDateString() });132        User.setProperty("my_purchased_keys", userKeysHistory, "json");133 134        var gatewaySuccessText = "┏━━━━━━━━━━━━━━━━━━━━━━━━ Club β”“\n" +135          "┃ <tg-emoji emoji-id='5350447674971660988'>βœ…</tg-emoji> <b>PAYMENT SUCCESSFUL</b> <tg-emoji emoji-id='5352825278672412291'>πŸ‘†</tg-emoji> ┃\n" +136          "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n" +137          "<blockquote>" +138          "<tg-emoji emoji-id='6147767796097884213'>πŸ“¦</tg-emoji> <b>Product Name:</b> <code>" + product.name + "</code>\n" +139          "<tg-emoji emoji-id='6145391828779672333'>πŸ’°</tg-emoji> <b>Validity:</b> <code>" + plan.days + " Days</code>\n" +140          "<tg-emoji emoji-id='6284816251143331422'>πŸ—</tg-emoji> <b>Your Key:</b> <code>" + deliveredKey + "</code>\n\n" +141          "━━━━━━━━━━━━━━━━━━━━━\n" +142          "✨ <i>Payment auto-verified! Enjoy your premium product.</i>" +143          "</blockquote>";144 145        Bot.sendMessage(gatewaySuccessText, { parse_mode: "HTML" });146 147        // Admin Log148        var adminMsg = "<blockquote>" +149          "πŸ”” <b>QR PAYMENT DIRECT DELIVERY</b> βœ”οΈ\n\n" +150          "πŸ‘€ <b>Buyer:</b> " + user.first_name + " (<code>" + user.telegramid + "</code>)\n" +151          "πŸ“¦ <b>Product:</b> " + product.name + "\n" +152          "πŸ”‘ <b>Key:</b> <code>" + deliveredKey + "</code>" +153          "</blockquote>";154          155        // βœ… FIXED: pehle yaha ek hardcoded chat_id ("7839151435" β€” kisi aur bot ka156        // reference ID) tha, jiski wajah se admin log tumhare admin ko kabhi milta157        // hi nahi tha. Ab yeh owner_id property se aata hai (same jo /start me set hai).158        var logAdminId = Bot.getProperty("owner_id") || "7839151435";159        Api.sendMessage({ chat_id: logAdminId, text: adminMsg, parse_mode: "HTML" });160        161        User.setProperty("last_selected_prod_idx", null);162        User.setProperty("last_selected_plan_idx", null);163        return;164      } else {165        Bot.sendMessage("⚠️ Payment received, but item went Out of Stock! Contact Admin with Order ID: <code>" + order_id + "</code>");166        return;167      }168    } else {169      // 🟑 CASE B: RE-ALIGNED BALANCE FALLBACK170      Libs.ResourcesLib.userRes("balance").add(Number(live_amount));171 172      // πŸ”” Admin notification for wallet balance top-up173      var walletLogAdminId = Bot.getProperty("owner_id") || "7839151435";174      var walletAdminMsg = "<blockquote>" +175        "πŸ”” <b>WALLET BALANCE ADDED</b> βœ”οΈ\n\n" +176        "πŸ‘€ <b>User:</b> " + user.first_name + " (<code>" + user.telegramid + "</code>)\n" +177        "πŸ’° <b>Amount Added:</b> β‚Ή" + Number(live_amount).toFixed(2) + "\n" +178        "πŸ†” <b>Order ID:</b> <code>" + order_id + "</code>" +179        "</blockquote>";180      try {181        Api.sendMessage({ chat_id: walletLogAdminId, text: walletAdminMsg, parse_mode: "HTML" });182      } catch (e) {}183 184      var walletSuccessText = "┏━━━━━━━━━━━━━━━━━━━━━━━━ Club β”“\n" +185        "┃ <tg-emoji emoji-id='6194922667242429131'>πŸŽ‰</tg-emoji> <b>PAYMENT SUCCESSFUL</b> <tg-emoji emoji-id='6192822213486321961'>✨</tg-emoji> ┃\n" +186        "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n" +187        "<blockquote>" +188        "<tg-emoji emoji-id='6194911182499881916'>πŸ—£</tg-emoji> <b>Amount Added:</b> β‚Ή<code>" + Number(live_amount).toFixed(2) + "</code>\n\n" +189        "ℹ️ <i>Click the button below to browse products.</i>" +190        "</blockquote>";191 192      var shopButtons = [[{ text: "πŸ›’ Shop Now", callback_data: "/back", style: "success", icon_custom_emoji_id: "6194922667242429131" }]];193 194      Api.sendMessage({195        chat_id: chat.chatid,196        text: walletSuccessText,197        parse_mode: "HTML",198        reply_markup: JSON.stringify({ inline_keyboard: shopButtons })199      });200    }201  } else {202    Bot.sendMessage("❌ <b>Payment not found yet.</b> Please complete the transaction first and make sure you have paid the exact amount.", { parse_mode: "HTML" });203  }204} catch (err) {205  Bot.sendMessage("⚠️ Process Error: " + err.message);206}