kkapil9112/Hguuuuuv45botPublic · Bot Template

AITelegram commerce bot for an admin-managed digital store: admins create categories, products, time-based plans, stock entries and license keys, and can grant reseller roles or adjust user balances. End users can view their balance, start a deposit flow with an inline amount keypad, apply coupon codes, and navigate back to the store menu. It uses Bot properties for product/stock/coupon data and Libs.ResourcesLib for per-user balances.

Commercecommerceshopreselleradmin-panelbalanceproduct-management
ProfileTelegram
102 commands0 envUpdated 29d agoCreated Aug 7, 2026
Back to folder

commands/_onVerifyResult.js

javascript · 116 lines

Raw
1/**#command2name: /onVerifyResult3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 🚀 COMMAND = /onVerifyResult14// STATUS: ERROR-FREE DATA VALIDATION PIPELINE15// =========================================================16 17try {18  if (!content) {19    Bot.sendMessage("⚠️ Server response was blank. Please contact admin if payment was deducted.");20    return;21  }22 23  var res = (typeof content === "object") ? content : null;24  if (!res) {25    try { res = JSON.parse(content); } catch (e) { res = null; }26  }27 28  // Aapke response scheme ke mutabik status handle matrix29  var paymentVerified = (res && (res.status === "success" || res.status === "PAID" || res.success === true));30  var live_amount = res && res.data && res.data.amount ? res.data.amount : (User.getProperty("deposit_amount") || "0");31  var order_id = params ? params.trim() : "UNKNOWN";32 33  if (paymentVerified == true) {34 35    var prodIdx = User.getProperty("last_selected_prod_idx");36    var planIdx = User.getProperty("last_selected_plan_idx");37    var productList = Bot.getProperty("stored_products") || [];38    39    var product = (prodIdx !== undefined && prodIdx !== null) ? productList[Number(prodIdx)] : null;40    var plan = (product && planIdx !== undefined && planIdx !== null) ? product.plans[Number(planIdx)] : null;41 42    if (product && plan) {43      // 🟢 CASE A: DIRECT KEY EXTRACTION44      var stockList = Bot.getProperty("stock_" + product.name.trim() + "_" + plan.days.trim() + "_Day") || Bot.getProperty("stock_" + prodIdx + "_" + planIdx) || [];45      46      if (stockList.length > 0) {47        var deliveredKey = stockList.shift();48        49        Bot.setProperty("stock_" + product.name.trim() + "_" + plan.days.trim() + "_Day", stockList, "json");50        Bot.setProperty("stock_" + prodIdx + "_" + planIdx, stockList, "json");51        52        var userKeysHistory = User.getProperty("my_purchased_keys") || [];53        userKeysHistory.push({ product: product.name, days: plan.days, price: live_amount, key: deliveredKey, date: new Date().toLocaleDateString() });54        User.setProperty("my_purchased_keys", userKeysHistory, "json");55 56        var gatewaySuccessText = "┏━━━━━━━━━━━━━━━━━━━━━━━━ Club ┓\n" +57          "┃ <tg-emoji emoji-id='5350447674971660988'>✅</tg-emoji> <b>PAYMENT SUCCESSFUL</b> <tg-emoji emoji-id='5352825278672412291'>👆</tg-emoji> ┃\n" +58          "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n" +59          "<blockquote>" +60          "<tg-emoji emoji-id='6147767796097884213'>📦</tg-emoji> <b>Product Name:</b> <code>" + product.name + "</code>\n" +61          "<tg-emoji emoji-id='6145391828779672333'>💰</tg-emoji> <b>Validity:</b> <code>" + plan.days + " Days</code>\n" +62          "<tg-emoji emoji-id='6284816251143331422'>🗝</tg-emoji> <b>Your Key:</b> <code>" + deliveredKey + "</code>\n\n" +63          "━━━━━━━━━━━━━━━━━━━━━\n" +64          "✨ <i>Payment auto-verified! Enjoy your premium product.</i>" +65          "</blockquote>";66 67        Bot.sendMessage(gatewaySuccessText, { parse_mode: "HTML" });68 69        // Admin Log70        var adminMsg = "<blockquote>" +71          "🔔 <b>QR PAYMENT DIRECT DELIVERY</b> ✔️\n\n" +72          "👤 <b>Buyer:</b> " + user.first_name + " (<code>" + user.telegramid + "</code>)\n" +73          "📦 <b>Product:</b> " + product.name + "\n" +74          "🔑 <b>Key:</b> <code>" + deliveredKey + "</code>" +75          "</blockquote>";76          77        // ✅ FIXED: pehle yaha ek hardcoded chat_id ("6191635812" — kisi aur bot ka78        // reference ID) tha, jiski wajah se admin log tumhare admin ko kabhi milta79        // hi nahi tha. Ab yeh owner_id property se aata hai (same jo /start me set hai).80        var logAdminId = Bot.getProperty("owner_id") || "6191635812";81        Api.sendMessage({ chat_id: logAdminId, text: adminMsg, parse_mode: "HTML" });82        83        User.setProperty("last_selected_prod_idx", null);84        User.setProperty("last_selected_plan_idx", null);85        return;86      } else {87        Bot.sendMessage("⚠️ Payment received, but item went Out of Stock! Contact Admin with Order ID: <code>" + order_id + "</code>");88        return;89      }90    } else {91      // 🟡 CASE B: RE-ALIGNED BALANCE FALLBACK92      Libs.ResourcesLib.userRes("balance").add(Number(live_amount));93 94      var walletSuccessText = "┏━━━━━━━━━━━━━━━━━━━━━━━━ Club ┓\n" +95        "┃ <tg-emoji emoji-id='6194922667242429131'>🎉</tg-emoji> <b>PAYMENT SUCCESSFUL</b> <tg-emoji emoji-id='6192822213486321961'>✨</tg-emoji> ┃\n" +96        "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n" +97        "<blockquote>" +98        "<tg-emoji emoji-id='6194911182499881916'>🗣</tg-emoji> <b>Amount Added:</b> ₹<code>" + Number(live_amount).toFixed(2) + "</code>\n\n" +99        "ℹ️ <i>Click the button below to browse products.</i>" +100        "</blockquote>";101 102      var shopButtons = [[{ text: "🛒 Shop Now", callback_data: "/back", style: "success", icon_custom_emoji_id: "6194922667242429131" }]];103 104      Api.sendMessage({105        chat_id: chat.chatid,106        text: walletSuccessText,107        parse_mode: "HTML",108        reply_markup: JSON.stringify({ inline_keyboard: shopButtons })109      });110    }111  } else {112    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" });113  }114} catch (err) {115  Bot.sendMessage("⚠️ Process Error: " + err.message);116}