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_upi.js

javascript · 147 lines

Raw
1/**#command2name: /addbal_upi3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 💳 "UPI Pay" chosen on Add Balance screen — same purana FamPay QR14// flow jo pehle /press.js ke confirm button me seedha chalta tha.15// Amount hamesha ₹ (India price) me dikhta hai.16// =========================================================17 18try {19  let userId = user.telegramid;20  let callbackId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;21 22  let finalAmount = String(parseInt(params ? String(params).trim() : "0"));23  if (!finalAmount || finalAmount === "0" || isNaN(parseInt(finalAmount)) || parseInt(finalAmount) <= 0) {24    Bot.sendMessage("❌ Invalid amount!");25    return;26  }27 28  let e_gear = "<tg-emoji emoji-id='5348292765325212780'>⚙</tg-emoji>";29  let upiId = Bot.getProperty("payment_upi_id") || "ayushrds@nyes";30 31  User.setProperty("deposit_amount", finalAmount, "string");32 33  // =====================================================34  // ✋ MANUAL MODE — Fampay ka QR bilkul use nahi hota (uspar Fampay ka logo35  // aata hai). Iski jagah apni UPI ID se seedha ek plain QR generate hota36  // hai (qrserver.com — sirf QR image banata hai, koi gateway nahi), aur37  // apna khud ka order_id banate hain taaki /check.js ka Manual Approval38  // isi se amount lookup kar sake.39  // =====================================================40  if ((Bot.getProperty("upi_payment_mode") || "auto") === "manual") {41    var manualOrderId = "MANUAL" + String(Date.now());42    try { Bot.setProperty("qr_order_amount_" + manualOrderId, finalAmount, "string"); } catch (e) {}43 44    var manualUpiUri = "upi://pay?pa=" + encodeURIComponent(upiId) +45                        "&pn=" + encodeURIComponent(Bot.getProperty("bot_name") || "GOLDEN MODS STORE") +46                        "&am=" + encodeURIComponent(finalAmount) +47                        "&cu=INR";48    var pLogoUrl2 = Bot.getProperty("bot_logo_url");49    var manualQrImage = "https://quickchart.io/qr?text=" + encodeURIComponent(manualUpiUri) + "&size=400&margin=2" +50      (pLogoUrl2 ? "&centerImageUrl=" + encodeURIComponent(pLogoUrl2) + "&centerImageSizeRatio=0.22" : "");51 52    var manualGatewayMsg =53      "<blockquote>📋 <b>Instructions</b></blockquote>\n" +54      "• Scan the QR using any UPI app.\n" +55      "• Pay the exact amount shown below.\n" +56      "• Wait a few seconds after payment.\n" +57      "• Tap <b>Verify Payment</b> below.\n\n" +58      "🧾 <b>Order ID:</b> <code>" + manualOrderId + "</code>\n" +59      "💰 <b>Amount:</b> ₹<code>" + finalAmount + "</code>\n" +60      "<b>UPI ID:</b> <code>" + upiId + "</code>\n\n" +61      "✅ <i>Aapke payment ko admin manually verify karega.</i>";62 63    var manualInlineButtons = [64      [{ text: "✅ Verify Payment", callback_data: "/check " + manualOrderId, style: "success", icon_custom_emoji_id: "5330237710655306682" }],65      [{ text: "❌ Cancel", callback_data: "/cancel_topup " + manualOrderId, style: "danger", icon_custom_emoji_id: "6219547832169273793" }]66    ];67 68    var manualGenMsgId = null;69    try { manualGenMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId); } catch (e) {}70 71    var manualSentQrMsg = Api.sendPhoto({72      chat_id: chat.chatid,73      photo: manualQrImage,74      caption: manualGatewayMsg,75      parse_mode: "HTML",76      reply_markup: JSON.stringify({ inline_keyboard: manualInlineButtons })77    });78 79    if (manualGenMsgId) {80      try { Api.deleteMessage({ chat_id: chat.chatid, message_id: manualGenMsgId }); } catch (e) {}81      Bot.setProperty("gen_msg_id_" + userId, null, "string");82      User.setProperty("gen_msg_id_" + userId, null, "string");83    }84    if (request && request.message) {85      try { Api.deleteMessage({ chat_id: chat.chatid, message_id: request.message.message_id }); } catch (e) {}86    }87 88    try {89      var manualQrMsgId = (manualSentQrMsg && manualSentQrMsg.result && manualSentQrMsg.result.message_id) ? manualSentQrMsg.result.message_id : (manualSentQrMsg && manualSentQrMsg.message_id ? manualSentQrMsg.message_id : null);90      if (manualQrMsgId) {91        Bot.setProperty("qr_msg_id_" + userId, manualQrMsgId, "string");92        User.setProperty("qr_msg_id_" + userId, manualQrMsgId, "string");93      }94      Bot.setProperty("qr_order_id_" + userId, manualOrderId, "string");95      User.setProperty("qr_order_id_" + userId, manualOrderId, "string");96      User.setProperty("pending_order_id", manualOrderId, "string");97      Bot.setProperty("qr_watch_order_" + userId, manualOrderId, "string");98      User.setProperty("qr_watch_order_" + userId, manualOrderId, "string");99    } catch (e) {}100    try { HTTP.get({url:"https://httpbin.org/delay/300?manual="+encodeURIComponent(manualOrderId),success:"/onQRExpire",error:"/onQRExpire"}); } catch(e) {}101 102    if (callbackId) {103      try { Api.answerCallbackQuery({ callback_query_id: String(callbackId) }); } catch (e) {}104    }105    return; // 🚫 STOP — Fampay API bilkul call nahi hui106  }107 108  HTTP.get({109    url: "https://fampay.anujbots.xyz/qr.php?upi=" + encodeURIComponent(upiId) + "&amount=" + encodeURIComponent(finalAmount),110    success: "/onQR",111    error: "/onApiError"112  });113 114  let generatingText =115    "<blockquote>" + e_gear + " <b>Generating QR Code for ₹" + finalAmount + "...</b>\n" +116    "<i>Please wait a moment</i></blockquote>";117 118  if (request && request.message) {119    Api.editMessageText({120      chat_id: chat.chatid,121      message_id: request.message.message_id,122      text: generatingText,123      parse_mode: "HTML"124    });125 126    try {127      Bot.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");128      User.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");129    } catch (e) {}130  } else {131    let genMsg = Api.sendMessage({ chat_id: chat.chatid, text: generatingText, parse_mode: "HTML" });132    try {133      let gmid = (genMsg && genMsg.result && genMsg.result.message_id) ? genMsg.result.message_id : (genMsg && genMsg.message_id ? genMsg.message_id : null);134      if (gmid) {135        Bot.setProperty("gen_msg_id_" + userId, gmid, "string");136        User.setProperty("gen_msg_id_" + userId, gmid, "string");137      }138    } catch (e) {}139  }140 141  if (callbackId) {142    Api.answerCallbackQuery({ callback_query_id: String(callbackId) });143  }144 145} catch (err) {146  Bot.sendMessage("⚠️ System Error: " + err.message);147}