indrajitghosh20006/Igstore_01botPublic Β· Bot Template
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 7h agoCreated Oct 30, 2026
commands/_onCheck.js
javascript Β· 359 lines
1/**#command2name: /onCheck3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13 var opts = (typeof options !== "undefined" && options) ? options : {};14 let isBackground = opts.is_background || false;15 let orderId = opts.order_id;16 let amount = opts.amount;17 let chatId = chat ? chat.chatid : null;18 let attempt = opts.attempt || 1;19 20 if (typeof params !== "undefined" && params && params.trim() !== "") {21 let splitParams = params.trim().split(" ");22 if (splitParams.length >= 1 && splitParams[0].length > 5) {23 orderId = splitParams[0];24 }25 if (splitParams.length >= 2) amount = splitParams[1];26 }27 28 let targetUserId = (typeof user !== "undefined" && user) ? user.telegramid : null;29 30 // π οΈ ULTIMATE FALLBACK: Agar button ya params se orderId na mile, toh active pending order ID utha lo!31 if ((!orderId || orderId.trim() === "") && targetUserId) {32 orderId = User.getProperty("pending_order_id") || 33 Bot.getProperty("qr_order_id_" + targetUserId) || 34 User.getProperty("qr_order_id_" + targetUserId) ||35 User.getProperty("buy_pending_order_id");36 }37 38 let queryId = null;39 if (typeof request !== "undefined" && request) {40 if (request.callback_query && request.callback_query.id) {41 queryId = request.callback_query.id;42 } else if (request.id) {43 queryId = request.id;44 }45 }46 47 // π¨ Premium emojis48 let e_chart = "π";49 let e_plus = "β";50 let e_arrow = "β‘οΈ";51 let e_coin = "πͺ";52 let e_money = "π°";53 let e_time = "π";54 let e_check = "β
";55 56 function vanishQrMessage(uid, fallbackChatId) {57 try {58 let qrMsgId = Bot.getProperty("qr_msg_id_" + uid) ||59 User.getProperty("qr_msg_id_" + uid) ||60 User.getProperty("last_qr_message_id_" + uid);61 if (qrMsgId) {62 try { Api.deleteMessage({ chat_id: fallbackChatId, message_id: qrMsgId }); } catch (e) {}63 }64 } catch (e) {}65 }66 67 function clearQrState(uid) {68 Bot.setProperty("qr_msg_id_" + uid, null, "string");69 User.setProperty("qr_msg_id_" + uid, null, "string");70 User.setProperty("last_qr_message_id_" + uid, null, "string");71 Bot.setProperty("qr_order_id_" + uid, null, "string");72 User.setProperty("qr_order_id_" + uid, null, "string");73 Bot.setProperty("qr_watch_order_" + uid, null, "string");74 User.setProperty("qr_watch_order_" + uid, null, "string");75 Bot.setProperty("verifying_lock_" + uid, false, "boolean");76 User.setProperty("verifying_lock_" + uid, false, "boolean");77 User.setProperty("topup_verifying_lock_" + uid, false, "boolean");78 User.setProperty("pending_order_id", null);79 }80 81 function getUnifiedBalance(uid) {82 let resBal = 0;83 try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}84 let bonusBal = Number(Bot.getProperty("balance" + uid) || 0);85 return resBal + bonusBal;86 }87 88 // β
STEP 1: Strict Order ID validation check89 if (!orderId || orderId.trim() === "") {90 if (queryId) {91 try {92 Api.answerCallbackQuery({93 callback_query_id: queryId,94 text: "β οΈ Active order nahi mila. Kripya pehle naya QR generate karein.",95 show_alert: true96 });97 } catch (e) {}98 }99 return;100 }101 102 // β
STEP 2: Duplicate Claim Check103 if (Bot.getProperty("claimed_topup_" + orderId)) {104 try { Bot.clearRunAfter({ label: "gram_verify_" + orderId }); } catch (e) {}105 vanishQrMessage(targetUserId, chatId);106 if (targetUserId) clearQrState(targetUserId);107 108 if (queryId) {109 try {110 Api.answerCallbackQuery({111 callback_query_id: queryId,112 text: "β
ALREADY CLAIMED β
\nYe payment pehle hi verify hokar balance me add ho chuki hai.",113 show_alert: true114 });115 } catch (e) {}116 }117 return;118 }119 120 if (targetUserId && !isBackground) {121 let isChecking = User.getProperty("topup_verifying_lock_" + targetUserId);122 if (isChecking) {123 if (queryId) {124 try {125 Api.answerCallbackQuery({126 callback_query_id: queryId,127 text: "β³ VERIFYING... PLEASE WAIT...",128 show_alert: true129 });130 } catch (e) {}131 }132 return;133 }134 User.setProperty("topup_verifying_lock_" + targetUserId, true, "boolean");135 }136 137 let responseData = (typeof content !== "undefined" && content) ? (typeof content === "object" ? content : JSON.parse(content)) : null;138 139 // Gram UPI Gateway returns status:true and data.status:"PAID" only after payment is verified.140 if (responseData && responseData.status === true && responseData.data && String(responseData.data.status || "").toUpperCase() === "PAID") {141 142 // Keep duplicate protection, but DO NOT mark an order claimed until its143 // gateway-reported amount has passed the strict order-amount check.144 if (Bot.getProperty("claimed_topup_" + orderId)) {145 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");146 return;147 }148 149 let txData = responseData.data;150 let gatewayOrderId = String(txData.order_id || "").trim();151 if (!gatewayOrderId || gatewayOrderId !== String(orderId).trim()) {152 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");153 let orderMismatchText = "β Payment Order ID mismatch. Is order ka payment credit nahi kiya ja sakta.";154 if (queryId) {155 try { Api.answerCallbackQuery({ callback_query_id: queryId, text: orderMismatchText, show_alert: true }); } catch (e) {}156 } else {157 Bot.sendMessage(orderMismatchText);158 }159 return;160 }161 let txAmount = txData.amount || amount;162 let utr = txData.utr || txData.transaction_id || "";163 if (!utr) {164 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");165 let missingUtrText = "β Verified response-ΰ¦ UTR ΰ¦ͺΰ¦Ύΰ¦ΰ§ΰ¦Ύ ΰ¦―ΰ¦Ύΰ§ΰ¦¨ΰ¦Ώ; নিরাΰ¦ͺঀΰ§ΰ¦€ΰ¦Ύΰ¦° ΰ¦ΰ¦¨ΰ§ΰ¦― credit ΰ¦ΰ¦°ΰ¦Ύ ΰ¦Ήΰ§ΰ¦¨ΰ¦Ώΰ₯€ Admin-ΰ¦ΰ¦° ΰ¦Έΰ¦ΰ§ΰ¦ΰ§ ΰ¦―ΰ§ΰ¦ΰ¦Ύΰ¦―ΰ§ΰ¦ ΰ¦ΰ¦°ΰ§ΰ¦¨ΰ₯€";166 if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: queryId, text: missingUtrText, show_alert: true }); } catch (e) {} }167 else { Bot.sendMessage(missingUtrText); }168 return;169 }170 let senderName = txData.payer || txData.sender_name || (typeof user !== "undefined" && user ? user.first_name : "Valued User");171 let payTime = txData.payment_time || txData.payment_time_ist || "N/A";172 let addedAmount = parseFloat(txAmount) || 0;173 174 // The gateway order is the source of truth for the amount lock. Fall back175 // to the user's pending amount only for older orders created before this176 // per-order property was introduced.177 let expectedAmount = Number(178 Bot.getProperty("pay_order_amount_" + orderId) ||179 User.getProperty("pay_order_amount_" + orderId) ||180 User.getProperty("buy_needpay") ||181 User.getProperty("buy_expected_amount") ||182 User.getProperty("deposit_amount") ||183 User.getProperty("pending_pay_amount_" + targetUserId) || 0184 );185 186 if (!(expectedAmount > 0) || !(addedAmount > 0) || Math.abs(addedAmount - expectedAmount) > 0.01) {187 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");188 let mismatchText = expectedAmount > 0189 ? "β Amount mismatch! Expected βΉ" + expectedAmount.toFixed(2) + ", received βΉ" + addedAmount.toFixed(2) + "."190 : "β This order has no valid locked amount, so it cannot be credited.";191 if (queryId) {192 try { Api.answerCallbackQuery({ callback_query_id: queryId, text: mismatchText, show_alert: true }); } catch (e) {}193 } else {194 Bot.sendMessage(mismatchText);195 }196 return;197 }198 199 // Claim only after success + exact amount. Also reject reused UTRs.200 if (utr && utr !== "N/A" && Bot.getProperty("claimed_utr_" + utr)) {201 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");202 if (queryId) { try { Api.answerCallbackQuery({callback_query_id: queryId, text: "β
Ye payment pehle hi credit ho chuki hai.", show_alert: true}); } catch (e) {} }203 return;204 }205 try { Bot.clearRunAfter({ label: "gram_verify_" + orderId }); } catch (e) {}206 Bot.setProperty("claimed_topup_" + orderId, true, "boolean");207 if (utr && utr !== "N/A") Bot.setProperty("claimed_utr_" + utr, true, "boolean");208 209 try {210 Libs.ResourcesLib.userRes("balance").add(addedAmount);211 } catch (e) {}212 let newBalance = getUnifiedBalance(targetUserId);213 214 215 // π Admin notification for wallet balance top-up216 try {217 let walletLogAdminId = Bot.getProperty("owner_id") || "7839151435";218 let walletAdminMsg = "<blockquote>" +219 "π <b>WALLET BALANCE ADDED</b> βοΈ\n\n" +220 "π€ <b>User:</b> " + senderName + " (<code>" + targetUserId + "</code>)\n" +221 "π° <b>Amount Added:</b> βΉ" + addedAmount.toFixed(2) + "\n" +222 "π§Ύ <b>UTR:</b> <code>" + utr + "</code>\n" +223 "π <b>Order ID:</b> <code>" + orderId + "</code>" +224 "</blockquote>";225 Api.sendMessage({ chat_id: walletLogAdminId, text: walletAdminMsg, parse_mode: "HTML" });226 } catch (e) {}227 228 if (queryId) {229 try {230 Api.answerCallbackQuery({231 callback_query_id: queryId,232 text: "β
PAYMENT VERIFIED SUCCESSFULLY!",233 show_alert: false234 });235 } catch (e) {}236 }237 238 if (targetUserId) {239 vanishQrMessage(targetUserId, chatId);240 clearQrState(targetUserId);241 }242 243 if (User.getProperty("buy_reseller_upgrade")) {244 let resellerPrice = Number(User.getProperty("buy_reseller_price") || 0);245 User.setProperty("buy_reseller_upgrade", null, "boolean");246 User.setProperty("buy_reseller_price", null, "number");247 248 // The UPI payment has already been credited to the wallet above.249 // Consume the reseller fee from that wallet now; any amount above the250 // fee remains available for future key purchases.251 let resellerResourceBal = 0;252 try { resellerResourceBal = Number(Libs.ResourcesLib.anotherUserRes("balance", targetUserId).value()) || 0; } catch (eRes) {}253 let resellerBonusBal = Number(Bot.getProperty("balance" + targetUserId) || 0);254 let resellerFromResource = Math.min(resellerResourceBal, resellerPrice);255 let resellerRemainingFee = resellerPrice - resellerFromResource;256 if (resellerFromResource > 0) { try { Libs.ResourcesLib.anotherUserRes("balance", targetUserId).add(-resellerFromResource); } catch (eDed) {} }257 if (resellerRemainingFee > 0) {258 Bot.setProperty("balance" + targetUserId, Math.max(0, resellerBonusBal - resellerRemainingFee), "number");259 }260 261 Bot.setProperty("reseller_fee_paid_" + targetUserId, resellerPrice, "number");262 Bot.setProperty("is_reseller_" + targetUserId, true, "boolean");263 try {264 let walletResellers = Bot.getProperty("resellers_list") || [];265 if (!Array.isArray(walletResellers)) walletResellers = [];266 if (walletResellers.map(function(x){ return String(x); }).indexOf(String(targetUserId)) === -1) walletResellers.push(targetUserId);267 Bot.setProperty("resellers_list", walletResellers, "json");268 } catch (eList) {}269 270 let resellerRemainingBalance = 0;271 try { resellerRemainingBalance += Number(Libs.ResourcesLib.anotherUserRes("balance", targetUserId).value()) || 0; } catch (eRes2) {}272 resellerRemainingBalance += Number(Bot.getProperty("balance" + targetUserId) || 0);273 274 Api.sendMessage({275 chat_id: chatId,276 text: "<blockquote>π <b>CONGRATULATIONS!</b></blockquote>\n\n" +277 "π <b>You are now a Reseller!</b>\n\n" +278 "<i>Payment verified aur permanent reseller status activate ho gaya!</i>\n\n" +279 "π³ <b>Remaining Wallet:</b> βΉ" + resellerRemainingBalance.toFixed(2) + "\n" +280 "π Ab isi balance se aap keys/products purchase kar sakte hain.",281 parse_mode: "HTML",282 reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Explore Shop", callback_data: "/buy_hack" }]] })283 });284 285 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");286 return;287 }288 289 let pendingProdIdx = User.getProperty("buy_prod_idx");290 let pendingPlanIdx = User.getProperty("buy_plan_idx");291 292 if (pendingProdIdx !== null && pendingProdIdx !== undefined && pendingProdIdx !== "" &&293 pendingPlanIdx !== null && pendingPlanIdx !== undefined && pendingPlanIdx !== "") {294 295 Api.sendMessage({ 296 chat_id: chatId, 297 text: e_check + " <b>Payment verified! Generating your key now...</b>", 298 parse_mode: "HTML" 299 });300 301 Bot.run({302 command: "/confirm_buyitem",303 options: { params: pendingProdIdx + " " + pendingPlanIdx }304 });305 306 User.setProperty("buy_prod_idx", null);307 User.setProperty("buy_plan_idx", null);308 User.setProperty("buy_price", null);309 User.setProperty("buy_needpay", null);310 311 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");312 return;313 }314 315 let successText = "ββββββββββββββββββββ\n" +316 e_plus + " <b>PAYMENT SUCCESSFUL</b> " + e_plus + "\n" +317 "ββββββββββββββββββββ\n\n" +318 e_money + " <b>Added Amount:</b> βΉ<b>" + addedAmount.toFixed(2) + "</b>\n" +319 e_chart + " <b>New Balance:</b> βΉ<b>" + newBalance.toFixed(2) + "</b>\n" +320 e_arrow + " <b>UTR / Ref ID:</b> <code>" + utr + "</code>\n" +321 e_time + " <b>Time:</b> " + payTime + "\n\n" +322 "ββββββββββββββββββββ\n" +323 e_coin + " <i>Your funds have been successfully credited! π</i>";324 325 Api.sendMessage({326 chat_id: chatId,327 text: successText,328 parse_mode: "HTML",329 reply_markup: JSON.stringify({330 inline_keyboard: [[331 { text: "π Shop Now", callback_data: "/buy_hack" },332 { text: "π° Profile", callback_data: "/profile" }333 ]]334 })335 });336 337 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");338 return;339 }340 341 if (queryId && !isBackground) {342 try {343 Api.answerCallbackQuery({344 callback_query_id: queryId,345 text: "β οΈ PAYMENT NOT VERIFIED YET\nPayment abhi gateway par confirm nahi hui. Payment complete hone ke baad automatic check dobara hoga.",346 show_alert: true347 });348 } catch (e) {}349 }350 351 if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");352 353} catch (err) {354 try {355 let uid = (typeof user !== "undefined" && user) ? user.telegramid : null;356 if (uid) User.setProperty("topup_verifying_lock_" + uid, false, "boolean");357 } catch (e) {}358 Bot.sendMessage("β οΈ Error in verification check: " + err.message);359}