ayushyadav7970824760/goldensellingstore_botPublic · Bot Template
AIThis Telegram store bot lets customers browse digital products and plans, apply coupons, add funds via UPI, and receive purchased keys. It includes a full admin panel for managing products, reordering items, setting reseller prices, viewing and removing key stock, configuring UPI payment details and update links, and checking user balances. Co-admins and resellers are supported, and support tickets are forwarded to the admin.
Commercedigital_storeadmin_panelupi_paymentsresellercouponskey_stock
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
commands/_onQR.js
javascript · 155 lines
1/**#command2name: /onQR3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13 if (!content) { 14 Bot.sendMessage("❌ Error: No response received from server.");15 return; 16 }17 18 var res = (typeof content === "object") ? content : JSON.parse(content);19 20 if (!res || res.status != "success" || !res.data) {21 Api.sendMessage({22 chat_id: chat.chatid,23 text: "<tg-emoji emoji-id='6219547832169273793'>❌</tg-emoji> <b>QR Generation Failed /</b>",24 parse_mode: "HTML"25 });26 return;27 }28 29 var order_id = res.data.order_id;30 var qr = res.data.qr_url;31 var expire = res.data.expires_at_ist ? res.data.expires_at_ist : "5 Minutes";32 33 var userId = user.telegramid;34 35 var deposit_amount = res.data.amount ||36 Bot.getProperty("pending_pay_amount_" + userId) || 37 User.getProperty("pending_pay_amount_" + userId) || 38 Bot.getProperty("deposit_amount_" + userId) || 39 User.getProperty("deposit_amount") || 40 "0";41 42 // ✅ Order ID se amount reliably lookup ho sake iske liye yahin save kar do43 // — /check.js (Manual Approval mode) isi se amount uthata hai.44 try { Bot.setProperty("qr_order_amount_" + order_id, String(parseFloat(deposit_amount) || 0), "string"); } catch (e) {}45 46 if (!qr) {47 Bot.sendMessage("❌ Error: QR Code link missing from API response.");48 return;49 }50 51 var finalAmount = parseFloat(deposit_amount);52 if (isNaN(finalAmount) || finalAmount <= 0) {53 finalAmount = 0.00; 54 }55 56 var botDisplayName = Bot.getProperty("bot_name") || "GOLDEN SELLING STORE";57 var gatewayMsg =58 "<blockquote>🛍️ <b>" + botDisplayName + " — UPI QR ACTIVE</b> 💳</blockquote>\n" +59 "➤ ───────────────────\n" +60 "<tg-emoji emoji-id='5260399854500191689'>🏪</tg-emoji> <b>Merchant Name:</b> " + botDisplayName + "\n\n" +61 "💰 <b>Scan & pay exactly</b> ₹<code>" + finalAmount.toFixed(2) + "</code>\n\n" +62 "👉 <i>Tap <b>Verify Payment</b> below after completing payment.</i>\n" +63 "➤ ───────────────────\n" +64 "<blockquote>⏳ <b>Session expires in " + expire + ".</b></blockquote>";65 66 var inlineButtons = [67 [68 {69 text: "✅ VERIFY PAYMENT",70 callback_data: "/check " + order_id,71 style: "success",72 icon_custom_emoji_id: "6102856637343600044"73 }74 ],75 [76 {77 text: "❌ Cancel Order",78 callback_data: "/cancel_topup " + order_id,79 style: "danger",80 icon_custom_emoji_id: "6219547832169273793"81 }82 ]83 ];84 85 // ⚡ SPEED FIX: QR photo pehle bhejo taaki user ko turant dikhe, "Generating..."86 // wala purana message uske baad (background me) delete karo — pehle ye ulta87 // tha (pehle delete, fir photo), jisse QR dikhne me extra gap lagta tha.88 var genMsgId = null;89 try {90 genMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId);91 } catch (genErr) {}92 93 var sentQrMsg = Api.sendPhoto({94 chat_id: chat.chatid,95 photo: qr,96 caption: gatewayMsg,97 parse_mode: "HTML",98 reply_markup: JSON.stringify({ inline_keyboard: inlineButtons })99 });100 101 if (genMsgId) {102 try { Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId }); } catch (delGenErr) {}103 Bot.setProperty("gen_msg_id_" + userId, null, "string");104 User.setProperty("gen_msg_id_" + userId, null, "string");105 }106 107 var qrMsgId = null;108 try {109 if (sentQrMsg) {110 if (sentQrMsg.result && sentQrMsg.result.message_id) {111 qrMsgId = sentQrMsg.result.message_id;112 } else if (sentQrMsg.message_id) {113 qrMsgId = sentQrMsg.message_id;114 }115 }116 117 if (qrMsgId) {118 Bot.setProperty("qr_msg_id_" + userId, qrMsgId, "string");119 User.setProperty("qr_msg_id_" + userId, qrMsgId, "string");120 }121 122 if (order_id) {123 Bot.setProperty("qr_order_id_" + userId, order_id, "string");124 User.setProperty("qr_order_id_" + userId, order_id, "string");125 User.setProperty("pending_order_id", order_id, "string");126 127 // ✅ Ye "watch id" hai — expiry callback isse compare karega ki order abhi bhi wahi hai ya resolve ho chuka128 Bot.setProperty("qr_watch_order_" + userId, order_id, "string");129 User.setProperty("qr_watch_order_" + userId, order_id, "string");130 }131 132 Bot.setProperty("qr_caption_" + userId, gatewayMsg, "string");133 User.setProperty("qr_caption_" + userId, gatewayMsg, "string");134 Bot.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");135 User.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");136 137 var nowTs = String(new Date().getTime());138 Bot.setProperty("qr_created_ts_" + userId, nowTs, "string");139 User.setProperty("qr_created_ts_" + userId, nowTs, "string");140 141 Bot.setProperty("verifying_lock_" + userId, false, "boolean");142 User.setProperty("verifying_lock_" + userId, false, "boolean");143 } catch (saveErr) {}144 145 // ⏰ AUTO EXPIRY: gateway QR ko 5 minutes ke baad remove karke user ko146 // clear expiry message bheja jayega. Verify/Cancel pe watcher state clear ho147 // jaati hai, isliye resolved orders par ye kuch nahi karega.148 try {149 Bot.setProperty("qr_expiry_scheduled_" + order_id, true, "boolean");150 HTTP.get({ url: "https://httpbin.org/delay/300?order=" + encodeURIComponent(order_id), success: "/onQRExpire", error: "/onQRExpire" });151 } catch (expiryScheduleErr) {}152 153} catch (err) {154 Bot.sendMessage("⚠️ System Error: " + err.message);155}