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/_addbal_upi_manual_approve.js
javascript · 116 lines
1/**#command2name: /addbal_upi_manual_approve3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// ✅ ADMIN — "Approve & Credit" button on a Manual UPI submission.14// =========================================================15 16try {17 var adminId = Bot.getProperty("owner_id") || "8477746023";18 var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));19 if (String(chat.chatid) !== adminId && !isCoAdmin0) {20 Bot.sendMessage("❌ You are not authorized to use this.");21 return;22 }23 24 var callbackId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;25 26 // ✅ FIXED: ab short token se asli data (userId/amount/orderId) lookup hota27 // hai, taaki callback_data kabhi 64-byte limit se bada na ho.28 var approvalToken = params ? String(params).trim() : "";29 var approvalData = null;30 try { approvalData = JSON.parse(Bot.getProperty("upi_appr_" + approvalToken) || "null"); } catch (e) {}31 32 if (!approvalData) {33 if (callbackId) {34 Api.answerCallbackQuery({ callback_query_id: String(callbackId), text: "❌ Order expired or already handled.", show_alert: true });35 }36 return;37 }38 39 var targetId = approvalData.userId;40 var amount = parseFloat(approvalData.amount);41 var orderIdRef = approvalData.orderId || null;42 43 if (!targetId || isNaN(amount) || amount <= 0) {44 if (callbackId) {45 Api.answerCallbackQuery({ callback_query_id: String(callbackId), text: "❌ Invalid data.", show_alert: true });46 }47 return;48 }49 50 try { Libs.ResourcesLib.anotherUserRes("balance", targetId).add(amount); } catch (resErr) {}51 52 // Canonical wallet is Libs.ResourcesLib balance. Do not write the legacy53 // balance<userId> property here, otherwise the UI can double-count funds.54 55 if (request && request.message && request.message.message_id) {56 try {57 Api.editMessageText({58 chat_id: chat.chatid,59 message_id: request.message.message_id,60 text: (request.message.text || "") + "\n\n<blockquote>✅ <b>APPROVED & CREDITED</b></blockquote>",61 parse_mode: "HTML"62 });63 } catch (e) {}64 }65 66 // ✅ User ke paas jo QR wali message thi, use DELETE karo — fir ek nayi67 // "Payment Successful" message bhejo (edit ki jagah, jaisa manga gaya).68 if (orderIdRef) {69 try {70 var qrRef = JSON.parse(Bot.getProperty("qr_msg_ref_" + orderIdRef) || "null");71 if (qrRef && qrRef.chatId && qrRef.msgId) {72 try { Api.deleteMessage({ chat_id: qrRef.chatId, message_id: qrRef.msgId }); } catch (e) {}73 }74 Bot.setProperty("qr_msg_ref_" + orderIdRef, null, "string");75 } catch (e) {}76 }77 78 var newBal = 0;79 try { newBal = Number(Libs.ResourcesLib.anotherUserRes("balance", targetId).value() || 0); } catch (eBal) {}80 var successText = "<blockquote><tg-emoji emoji-id='6194922667242429131'>🎉</tg-emoji> <b>PAYMENT SUCCESSFUL</b></blockquote>\n\n" +81 "<tg-emoji emoji-id='6267068789146260253'>💰</tg-emoji> <b>Credited:</b> ₹<code>" + amount.toFixed(2) + "</code>\n" +82 "<tg-emoji emoji-id='6064138396228392033'>💳</tg-emoji> <b>New Balance:</b> ₹<code>" + newBal.toFixed(2) + "</code>\n\n" +83 "<tg-emoji emoji-id='6194911182499881916'>🗣</tg-emoji> <i>Aapka balance successfully update ho gaya hai.</i>";84 try {85 Api.sendMessage({86 chat_id: targetId, text: successText, parse_mode: "HTML",87 reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Back to Menu", callback_data: "/back", style: "primary" }]] })88 });89 } catch (notifyErr) {}90 91 // 🔔 Fund-added group/channel notification. Uses the same destination configured92 // for sale announcements, or an optional dedicated fund_group_id.93 try {94 var fundGroupId = Bot.getProperty("fund_group_id") || Bot.getProperty("sale_channel_id");95 if (fundGroupId) {96 Api.sendMessage({97 chat_id: fundGroupId,98 text: "<blockquote><tg-emoji emoji-id='6194922667242429131'>🎉</tg-emoji> <b>NEW FUND ADDED</b> <tg-emoji emoji-id='6266967801580231067'>💎</tg-emoji></blockquote>\n\n" +99 "<tg-emoji emoji-id='6145572393499762737'>👤</tg-emoji> <b>User:</b> " + (approvalData.username || "User") + " (<code>" + targetId + "</code>)\n" +100 "<tg-emoji emoji-id='6267068789146260253'>💰</tg-emoji> <b>Amount:</b> ₹<code>" + amount.toFixed(2) + "</code>\n" +101 "<tg-emoji emoji-id='6064138396228392033'>💳</tg-emoji> <b>New Balance:</b> ₹<code>" + newBal.toFixed(2) + "</code>\n" +102 "<tg-emoji emoji-id='6215386799133433653'>✅</tg-emoji> <b>Status:</b> Approved & Credited",103 parse_mode: "HTML"104 });105 }106 } catch (groupErr) {}107 108 if (callbackId) {109 Api.answerCallbackQuery({ callback_query_id: String(callbackId), text: "✅ Approved & Credited!" });110 }111 112 try { Bot.setProperty("upi_appr_" + approvalToken, null, "string"); } catch (e) {}113 114} catch (err) {115 Bot.sendMessage("⚠️ Error: " + err.message);116}