amanjha18v/AMAN_SHOPS_BOTPublic · Bot Template
AIAMAN SHOP STORE appears to be a Telegram automation bot. Commands include /*, /addbal, /addbal_all, /addbal_binance, /addbal_binance_approve, /addbal_binance_paid, /addbal_upi, /addcat_id. Observed in code: messaging, http, libs, keyboards, payments.
Utilityutility
132 commands0 envUpdated 6h agoCreated Sep 4, 2026
commands/_pay_upi.js
javascript · 137 lines
1/**#command2name: /pay_upi3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 💳 "Pay via UPI" button — generates the shortfall QR14// (this used to be inline inside buyitem.js; moved here since buyitem.js15// now always shows the Payment Method screen first)16// =========================================================17 18try {19 var productList = Bot.getProperty("stored_products") || [];20 var callbackId = (request && request.id) ? request.id : ((request && request.callback_query && request.callback_query.id) || null);21 var chatId = chat.chatid;22 var userId = user.telegramid;23 24 var parts = params ? String(params).trim().split(" ") : [];25 var prodIdx = Number(parts[0]);26 var planIdx = Number(parts[1]);27 28 var product = productList[prodIdx];29 if (!product || !product.plans || !product.plans[planIdx]) {30 Bot.sendMessage("❌ Product or Plan configuration missing!");31 return;32 }33 34 var plan = product.plans[planIdx];35 var planUnit = plan.unit || "day";36 var cleanPlanDays = String(plan.days).replace(/[^0-9.]/g, "").trim();37 38 var unifiedBal = (function () {39 var resBal = 0;40 try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}41 var bonusBal = Number(Bot.getProperty("balance" + userId) || 0);42 return resBal + bonusBal;43 })();44 45 var isReseller = Bot.getProperty("is_reseller_" + userId) === true;46 var cleanProdName = product.name.trim().toUpperCase();47 var priceKeySuffix = (planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_" + planUnit);48 var normalKey = "price_normal_" + cleanProdName + "_" + priceKeySuffix;49 var resellerKey = "price_reseller_" + cleanProdName + "_" + priceKeySuffix;50 51 var adminNormalPrice = Bot.getProperty(normalKey);52 var adminResellerPrice = Bot.getProperty(resellerKey);53 var currentNormal = (adminNormalPrice !== undefined && adminNormalPrice !== null) ? adminNormalPrice : plan.normal_price;54 var currentReseller = (adminResellerPrice !== undefined && adminResellerPrice !== null) ? adminResellerPrice : plan.reseller_price;55 var originalPrice = isReseller ? Number(currentReseller) : Number(currentNormal);56 var price = originalPrice;57 58 var planSpecificDiscKey = "auto_discount_" + cleanProdName + "_" + cleanPlanDays + "_" + planUnit.toUpperCase();59 var productWideDiscKey = "auto_discount_" + cleanProdName + "_ALL";60 var autoDiscountPercent = Bot.getProperty(planSpecificDiscKey) || Bot.getProperty(productWideDiscKey) || Bot.getProperty("auto_discount_global") || 0;61 62 var appliedCouponCode = User.getProperty("applied_coupon_" + prodIdx + "_" + planIdx);63 if (appliedCouponCode) {64 var couponRec = Bot.getProperty("coupon_" + appliedCouponCode);65 if (couponRec && couponRec.discountPercent) {66 price = Number((originalPrice * (1 - couponRec.discountPercent / 100)).toFixed(2));67 }68 } else if (autoDiscountPercent > 0) {69 price = Number((originalPrice * (1 - autoDiscountPercent / 100)).toFixed(2));70 }71 72 var needToPay = Math.max(price - unifiedBal, 0);73 if (needToPay <= 0) { needToPay = price; } // safety fallback74 75 // ✅ Product context save karo taaki /onCheck payment verify hone ke baad76 // is exact plan ko khud-ba-khud (bina dobara confirm maange) purchase kar de.77 User.setProperty("last_selected_prod_idx", prodIdx);78 User.setProperty("last_selected_plan_idx", planIdx);79 80 User.setProperty("buy_prod_idx", prodIdx, "number");81 User.setProperty("buy_plan_idx", planIdx, "number");82 User.setProperty("buy_price", Number(price), "number");83 User.setProperty("buy_needpay", Number(needToPay), "number");84 User.setProperty("buy_prod_name", String(product.name).trim(), "string");85 User.setProperty("buy_plan_days", cleanPlanDays, "string");86 87 var genText = "<tg-emoji emoji-id='6147936236125298267'>⏳</tg-emoji> <b>Creating order for ₹" +88 needToPay.toFixed(2) + ", please wait...</b>";89 90 if (request && request.message) {91 Api.editMessageText({92 chat_id: String(chatId),93 message_id: Number(request.message.message_id),94 text: genText,95 parse_mode: "HTML"96 });97 // ✅ FIX: is "Creating order..." message ka ID save karo taaki QR photo98 // aane par ye properly delete (vanish) ho jaaye — pehle ye chat me stuck99 // reh jaata tha kyunki iska ID kahi track hi nahi hota tha.100 try {101 Bot.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");102 User.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");103 } catch (e) {}104 } else {105 var genMsg = Api.sendMessage({ chat_id: chatId, text: genText, parse_mode: "HTML" });106 try {107 var gmid = (genMsg && genMsg.result && genMsg.result.message_id) ? genMsg.result.message_id : (genMsg && genMsg.message_id ? genMsg.message_id : null);108 if (gmid) {109 Bot.setProperty("gen_msg_id_" + userId, gmid, "string");110 User.setProperty("gen_msg_id_" + userId, gmid, "string");111 }112 } catch (e) {}113 }114 115 var upi_id = Bot.getProperty("payment_upi_id") || "galureang@fam";116 117 HTTP.get({118 url: "https://fampay.anujbots.xyz/qr.php?upi=" + encodeURIComponent(upi_id) +119 "&amount=" + encodeURIComponent(needToPay.toFixed(2)),120 success: "/onQR",121 error: "/onApiError"122 });123 124 if (callbackId) {125 Api.answerCallbackQuery({126 callback_query_id: String(callbackId),127 text: "⏳ Generating QR...",128 show_alert: false129 });130 }131 132} catch (e) {133 var errChatId = (typeof chat !== "undefined" && chat && chat.chatid) ? chat.chatid : null;134 if (errChatId) {135 try { Api.sendMessage({ chat_id: errChatId, text: "❌ <b>Error:</b> <code>" + e.message + "</code>", parse_mode: "HTML" }); } catch (fatal) {}136 }137}