mansuriamaan803/SANJEEVFFSTORE_botPublic · Bot Template

AIThis bot is a commerce platform for selling digital products, primarily focused on FreeFire accounts and related services. It provides admin tools for managing products, categories, stock, reseller roles, and a balance system for user payments. Users can browse products, apply coupons, and check their balance through an interactive interface with premium emojis and inline keyboards.

Commercecommercestoreproductsresellerbalancecoupon
ProfileTelegram
102 commands0 envUpdated 12d agoCreated Aug 26, 2026
Back to folder

commands/_send_stars_invoice.js

javascript · 97 lines

Raw
1/**#command2name: /send_stars_invoice3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// ⭐ Sends a real Telegram Stars (XTR) invoice.14// Usage via callback_data:15//   /send_stars_invoice deposit <amount>16//   /send_stars_invoice buy <prodIdx> <planIdx>17//18// ⚠️ IMPORTANT: This uses the RAW Telegram Bot API (sendInvoice) directly19// via bot.token, bypassing any platform-specific wrapper, since Stars20// payments (XTR currency, empty provider_token) need exact API compliance.21// For Stars: provider_token MUST be an empty string, currency MUST be "XTR".22// =========================================================23 24try {25  var userId = String(user.telegramid);26  var chatId = chat.chatid;27 28  var parts = params ? String(params).trim().split(" ") : [];29  var mode = parts[0];30 31  var title, description, payload, starsAmount;32 33  if (mode === "deposit") {34    starsAmount = parseInt(parts[1]);35    if (isNaN(starsAmount) || starsAmount <= 0) {36      Bot.sendMessage("❌ Invalid Stars amount.");37      return;38    }39    title = "Wallet Deposit — " + starsAmount + " Stars";40    description = "Add " + starsAmount + " Telegram Stars to your Aman Panel Store wallet balance.";41    payload = "deposit:" + userId + ":" + starsAmount;42 43  } else if (mode === "buy") {44    var prodIdx = Number(parts[1]);45    var planIdx = Number(parts[2]);46    var productList = Bot.getProperty("stored_products") || [];47    var product = productList[prodIdx];48    if (!product || !product.plans || !product.plans[planIdx]) {49      Bot.sendMessage("❌ Product/Plan not found.");50      return;51    }52    var plan = product.plans[planIdx];53    var cleanProdName = product.name.trim().toUpperCase();54    var planUnit = plan.unit || "day";55    var cleanPlanDays = String(plan.days).replace(/[^0-9.]/g, "").trim();56    var starsKeySuffix = (planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_" + planUnit);57    var starsPriceKey = "stars_price_" + cleanProdName + "_" + starsKeySuffix;58    starsAmount = Number(Bot.getProperty(starsPriceKey) || 0);59 60    if (!starsAmount) {61      Bot.sendMessage("❌ Is plan ke liye Stars price abhi set nahi hai. Admin se contact karein.");62      return;63    }64 65    var durationDisplay = plan.durationDisplay || (cleanPlanDays + " " + (planUnit === "hour" ? "Hour(s)" : planUnit === "minute" ? "Minute(s)" : "Day(s)"));66    title = product.name + " — " + durationDisplay;67    description = "Instant key delivery for " + product.name + " (" + durationDisplay + "), paid via Telegram Stars.";68    payload = "buy:" + userId + ":" + prodIdx + ":" + planIdx;69 70  } else {71    Bot.sendMessage("❌ Invalid invoice request.");72    return;73  }74 75  var invoiceBody = {76    chat_id: chatId,77    title: title,78    description: description,79    payload: payload,80    provider_token: "", // ✅ MUST be empty string for Telegram Stars (XTR)81    currency: "XTR",82    prices: JSON.stringify([{ label: title, amount: starsAmount }])83  };84 85  HTTP.post({86    url: "https://api.telegram.org/bot" + bot.token + "/sendInvoice",87    body: invoiceBody88  });89 90  var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;91  if (queryId) {92    try { Api.answerCallbackQuery({ callback_query_id: String(queryId), text: "⭐ Invoice sent!" }); } catch (e) {}93  }94 95} catch (err) {96  Bot.sendMessage("⚠️ Stars Invoice Error: " + err.message, { parse_mode: "HTML" });97}