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
ProfileTelegram
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
Back to folder

commands/_addbal_binance.js

javascript · 121 lines

Raw
1/**#command2name: /addbal_binance3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 🟡 "Binance Pay" chosen on Add Balance screen — shows the admin-set14// Binance QR (photo file_id OR image URL, whichever admin configured) with15// the amount converted to USD, plus Binance Pay ID + USDT Address.16// Koi live-verify API nahi hai, isliye "I Paid" ek manual Support flow17// shuru karta hai (UTR + screenshot -> admin ko forward).18// =========================================================19 20try {21  let userId = user.telegramid;22  let callbackId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;23 24  let inrAmount = String(parseInt(params ? String(params).trim() : "0"));25  if (!inrAmount || inrAmount === "0" || isNaN(parseInt(inrAmount)) || parseInt(inrAmount) <= 0) {26    Bot.sendMessage("❌ Invalid amount!");27    return;28  }29 30  let qrFileId = Bot.getProperty("binance_qr_file_id");31  let qrUrl = Bot.getProperty("binance_qr_url");32  let qrSource = qrFileId || qrUrl;33 34  let binanceId = Bot.getProperty("binance_pay_id");35  let usdtAddress = Bot.getProperty("binance_usdt_address");36  let usdRate = Number(Bot.getProperty("usd_rate") || 91);37  let usdAmount = (parseInt(inrAmount) / usdRate).toFixed(2);38 39  // ✅ FIXED: pehle Binance Pay tabhi kaam karta tha jab admin ek static QR40  // IMAGE upload karta (binance_qr_file_id/binance_qr_url) — agar wo set41  // nahi tha to poora payment method hi fail ho jaata tha. Ab agar koi42  // static QR image set nahi hai, to bot khud USDT address (ya Binance Pay43  // ID) se ek QR CODE dynamically generate kar deta hai (qrserver.com —44  // sirf QR ki image banata hai, koi payment gateway nahi) — isliye QR45  // hamesha aayega, chahe admin ne image upload ki ho ya nahi.46  if (!qrSource && (usdtAddress || binanceId)) {47    qrSource = "https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=" + encodeURIComponent(usdtAddress || binanceId);48  }49 50  if (!qrSource || (!binanceId && !usdtAddress)) {51    if (callbackId) {52      Api.answerCallbackQuery({53        callback_query_id: String(callbackId),54        text: "⚠️ Binance Pay abhi configure nahi hua hai. Kripya Support se contact karein.",55        show_alert: true56      });57    }58    return;59  }60 61  User.setProperty("binance_pending_amount_inr", inrAmount, "string");62  User.setProperty("binance_pending_amount_usd", usdAmount, "string");63 64  let e_binance = "<tg-emoji emoji-id='6312263493051489212'>🟡</tg-emoji>";65  let e_check = "<tg-emoji emoji-id='6100657257605763582'>✔️</tg-emoji>";66 67  let caption =68    "<blockquote>" + e_binance + " <b>BINANCE PAY</b></blockquote>\n" +69    "━━━━━━━━━━━━━━━━━━━━━\n\n" +70    "<tg-emoji emoji-id='6312263493051489212'>💰</tg-emoji> <b>Amount:</b> $<code>" + usdAmount + "</code> <i>(₹" + inrAmount + ")</i>\n\n" +71    (binanceId ? "<b>Binance Pay ID</b>\n<code>" + binanceId + "</code>\n\n" : "") +72    (usdtAddress ? "<b>USDT Address</b>\n<code>" + usdtAddress + "</code>\n\n" : "") +73    "━━━━━━━━━━━━━━━━━━━━━\n" +74    "<tg-emoji emoji-id='6100170496077204999'>📋</tg-emoji> <b>Instructions</b>\n" +75    "• Scan the QR above in your Binance/crypto app, or pay to the ID/Address shown.\n" +76    "• Pay the exact amount shown.\n" +77    "• Tap <b>I Paid</b> below and follow the steps to submit proof.\n\n" +78    e_check + " <i>Support team will verify and credit your balance.</i>";79 80  let inlineButtons = [81    [{ text: "I Paid", callback_data: "/addbal_binance_paid", style: "success", icon_custom_emoji_id: "6100657257605763582" }],82    [{ text: "Cancel", callback_data: "/cancel_topup", style: "danger", icon_custom_emoji_id: "6219547832169273793" }]83  ];84 85  // Agar purani QR/generating message chat me hai, use hata do86  try {87    let genMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId);88    if (genMsgId) {89      try { Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId }); } catch (e) {}90      Bot.setProperty("gen_msg_id_" + userId, null, "string");91      User.setProperty("gen_msg_id_" + userId, null, "string");92    }93  } catch (e) {}94 95  if (request && request.message && !request.message.photo) {96    try { Api.deleteMessage({ chat_id: chat.chatid, message_id: request.message.message_id }); } catch (e) {}97  }98 99  let sentMsg = Api.sendPhoto({100    chat_id: chat.chatid,101    photo: qrSource,102    caption: caption,103    parse_mode: "HTML",104    reply_markup: JSON.stringify({ inline_keyboard: inlineButtons })105  });106 107  try {108    let qrMsgId = (sentMsg && sentMsg.result && sentMsg.result.message_id) ? sentMsg.result.message_id : (sentMsg && sentMsg.message_id ? sentMsg.message_id : null);109    if (qrMsgId) {110      Bot.setProperty("qr_msg_id_" + userId, qrMsgId, "string");111      User.setProperty("qr_msg_id_" + userId, qrMsgId, "string");112    }113  } catch (e) {}114 115  if (callbackId) {116    Api.answerCallbackQuery({ callback_query_id: String(callbackId) });117  }118 119} catch (err) {120  Bot.sendMessage("⚠️ System Error: " + err.message);121}