indrajitghosh20006/Igstore_01botPublic Β· Bot Template

ProfileTelegram

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
Back to folder

commands/_send_stars_invoice.js

javascript Β· 138 lines

Raw
1/**#command2name: /send_stars_invoice3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// PREMIUM BUTTON ICONS13(function(){14  try {15    if (!JSON.__premiumPatched) {16      var __origStringify = JSON.stringify;17      JSON.stringify = function(value, replacer, space) {18        try {19          if (value && value.inline_keyboard && Array.isArray(value.inline_keyboard)) {20            var premiumIds = [21              "6143444134125379822",22              "6091379307907652768",23              "6147534454819661264",24              "6147817325660741985",25              "6235683689292897318",26              "6102856637343600044"27            ];28            var rows = value.inline_keyboard.map(function(row, ri) {29              if (!Array.isArray(row)) return row;30              return row.map(function(btn, bi) {31                if (!btn || typeof btn !== "object") return btn;32                var copy = {};33                for (var k in btn) copy[k] = btn[k];34                if (!copy.icon_custom_emoji_id) copy.icon_custom_emoji_id = premiumIds[(ri + bi) % premiumIds.length];35                return copy;36              });37            });38            var cloned = {};39            for (var key in value) cloned[key] = value[key];40            cloned.inline_keyboard = rows;41            return __origStringify.call(JSON, cloned, replacer, space);42          }43        } catch (e) {}44        return __origStringify.call(JSON, value, replacer, space);45      };46      JSON.__premiumPatched = true;47    }48  } catch (e) {}49})();50 51 52 53// =========================================================54// ⭐ Sends a real Telegram Stars (XTR) invoice.55// Usage via callback_data:56//   /send_stars_invoice deposit <amount>57//   /send_stars_invoice buy <prodIdx> <planIdx>58//59// ⚠️ IMPORTANT: This uses the RAW Telegram Bot API (sendInvoice) directly60// via bot.token, bypassing any platform-specific wrapper, since Stars61// payments (XTR currency, empty provider_token) need exact API compliance.62// For Stars: provider_token MUST be an empty string, currency MUST be "XTR".63// =========================================================64 65try {66  var userId = String(user.telegramid);67  var chatId = chat.chatid;68 69  var parts = params ? String(params).trim().split(" ") : [];70  var mode = parts[0];71 72  var title, description, payload, starsAmount;73 74  if (mode === "deposit") {75    starsAmount = parseInt(parts[1]);76    if (isNaN(starsAmount) || starsAmount <= 0) {77      Bot.sendMessage("❌ Invalid Stars amount.");78      return;79    }80    title = "Wallet Deposit β€” " + starsAmount + " Stars";81    description = "Add " + starsAmount + " Telegram Stars to your 𝙄𝙂 π™Žπ™π™Šπ™π™€ wallet balance.";82    payload = "deposit:" + userId + ":" + starsAmount;83 84  } else if (mode === "buy") {85    var prodIdx = Number(parts[1]);86    var planIdx = Number(parts[2]);87    var productList = Bot.getProperty("stored_products") || [];88    var product = productList[prodIdx];89    if (!product || !product.plans || !product.plans[planIdx]) {90      Bot.sendMessage("❌ Product/Plan not found.");91      return;92    }93    var plan = product.plans[planIdx];94    var cleanProdName = product.name.trim().toUpperCase();95    var planUnit = plan.unit || "day";96    var cleanPlanDays = String(plan.days).replace(/[^0-9.]/g, "").trim();97    var starsKeySuffix = (planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_" + planUnit);98    var starsPriceKey = "stars_price_" + cleanProdName + "_" + starsKeySuffix;99    starsAmount = Number(Bot.getProperty(starsPriceKey) || 0);100 101    if (!starsAmount) {102      Bot.sendMessage("❌ Is plan ke liye Stars price abhi set nahi hai. Admin se contact karein.");103      return;104    }105 106    var durationDisplay = plan.durationDisplay || (cleanPlanDays + " " + (planUnit === "hour" ? "Hour(s)" : planUnit === "minute" ? "Minute(s)" : "Day(s)"));107    title = product.name + " β€” " + durationDisplay;108    description = "Instant key delivery for " + product.name + " (" + durationDisplay + "), paid via Telegram Stars.";109    payload = "buy:" + userId + ":" + prodIdx + ":" + planIdx;110 111  } else {112    Bot.sendMessage("❌ Invalid invoice request.");113    return;114  }115 116  var invoiceBody = {117    chat_id: chatId,118    title: title,119    description: description,120    payload: payload,121    provider_token: "", // βœ… MUST be empty string for Telegram Stars (XTR)122    currency: "XTR",123    prices: JSON.stringify([{ label: title, amount: starsAmount }])124  };125 126  HTTP.post({127    url: "https://api.telegram.org/bot" + bot.token + "/sendInvoice",128    body: invoiceBody129  });130 131  var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;132  if (queryId) {133    try { Api.answerCallbackQuery({ callback_query_id: String(queryId), text: "⭐ Invoice sent!" }); } catch (e) {}134  }135 136} catch (err) {137  Bot.sendMessage("⚠️ Stars Invoice Error: " + err.message, { parse_mode: "HTML" });138}