tarunpoonia905/OfcDevShopBotPublic · Bot Template
AIDEV SHOP appears to be a Telegram automation bot. Commands include /confirm_delete_stock, /addstock_id, /extkey_menu, /partner_api, /apidelete, /buy_hack_cat, /admin_manage_products, /check_buy. Observed in code: messaging, keyboards, payments, libs, web, http, games.
Utilityutility
228 commands0 envUpdated 12d agoCreated Oct 18, 2026
commands/_pay_zapupi.js
javascript · 266 lines
1/**#command2name: /pay_zapupi3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/*#SIZE_V1*/try{(function(){var z=Bot.getProperty("ui_btn_size");var mx=z==="large"?1:(z==="medium"?2:0);if(!mx||Api.__sz)return;var NAV=/^[◀▶⬅➡«»‹›⏪⏩]|\d+\s*\/\s*\d+|prev|next|page/i;var T=function(m){try{var o=typeof m==="string"?JSON.parse(m):m;if(!o||!o.inline_keyboard)return m;var out=[],cnt=0;o.inline_keyboard.forEach(function(row){var nav=row.some(function(b){return NAV.test(String(b.text||"").trim());});if(row.length<=mx||nav){out.push(row);cnt+=row.length;return;}for(var i=0;i<row.length;i+=mx){var c=row.slice(i,i+mx);out.push(c);cnt+=c.length;}});if(cnt>100||out.length>100)return m;o.inline_keyboard=out;return typeof m==="string"?JSON.stringify(o):o;}catch(e){return m;}};["sendMessage","editMessageText","editMessageCaption","editMessageReplyMarkup","sendPhoto","sendVideo","sendAnimation","sendDocument"].forEach(function(n){var f=Api[n];if(typeof f!=="function")return;Api[n]=function(p){try{if(p&&p.reply_markup)p.reply_markup=T(p.reply_markup);}catch(e){}return f.apply(Api,arguments);};});Api.__sz=true;})();}catch(__szE){}13/*#ANIM_V1*/try{(function(){var M={party:"5046509860389126442",fire:"5104841245755180586",heart:"5159385139981059251",like:"5107584321108051014"};var a=Bot.getProperty("ui_anim");if(!a||!M[a]||Api.__an)return;var E=M[a];var OK=/PURCHASE SUCCESSFUL|PAYMENT SUCCESSFUL|Payment verified|CONGRATULATIONS/i;var priv=function(p){return p&&p.chat_id&&String(p.chat_id).charAt(0)!=="-";};["sendMessage","sendPhoto","sendVideo","sendAnimation"].forEach(function(n){var f=Api[n];if(typeof f!=="function")return;Api[n]=function(p){try{if(priv(p)&&!p.message_effect_id&&OK.test(String(p.text||p.caption||"")))p.message_effect_id=E;}catch(e){}return f.apply(Api,arguments);};});var fe=Api.editMessageText;if(typeof fe==="function"){Api.editMessageText=function(p){var r=fe.apply(Api,arguments);try{if(priv(p)&&OK.test(String(p.text||"")))Api.sendMessage({chat_id:p.chat_id,text:"🎉",message_effect_id:E});}catch(e){}return r;};}Api.__an=true;})();}catch(__anE){}14/*#PREMIUM_UI_V1*/try{(function(){if(Bot.getProperty("ui_premium")!==true||Api.__pm)return;var R=function(t,c){var s=(String(t||"")+" "+String(c||"")).toLowerCase();if(/back|cancel|close|delete|remove|clear|reject|stop|ban|exit/.test(s))return"danger";if(/pay|buy|confirm|verify|paid|add|deposit|shop|claim|yes|receive|wallet|download|update/.test(s))return"success";return"primary";};var T=function(m){try{var o=typeof m==="string"?JSON.parse(m):m;if(!o||!o.inline_keyboard)return m;o.inline_keyboard.forEach(function(row){row.forEach(function(b){if(b.copy_text||b.url||b.callback_data||b.web_app){b.style=R(b.text,b.callback_data||b.url);if(!b.icon_custom_emoji_id&&b.text&&!/^[\u2600-\u27BF\uD83C-\uD83E]/.test(String(b.text).trim())&&!/^[✦✨💎]/.test(b.text))b.text="✦ "+b.text;}});});return typeof m==="string"?JSON.stringify(o):o;}catch(e){return m;}};["sendMessage","editMessageText","editMessageCaption","editMessageReplyMarkup","sendPhoto","sendVideo","sendAnimation","sendDocument"].forEach(function(n){var f=Api[n];if(typeof f!=="function")return;Api[n]=function(p){try{if(p&&p.reply_markup)p.reply_markup=T(p.reply_markup);}catch(e){}return f.apply(Api,arguments);};});Api.__pm=true;})();}catch(__pmE){}15 16 17// =========================================================18// 💳 "Pay via UPI" button — generates the shortfall QR19// (this used to be inline inside buyitem.js; moved here since buyitem.js20// now always shows the Payment Method screen first)21// =========================================================22 23try {24try { User.setProperty("buy_reseller_upgrade", null, "boolean"); try { Bot.setProperty("reseller_upg_" + user.telegramid, null, "number"); } catch (__ru) {} User.setProperty("buy_reseller_price", null, "number"); } catch (__rf) {}25 26 27 // 🛠 PANEL MAINTENANCE GUARD28 // Re-check at every purchase/payment stage so an admin can switch a panel29 // OFF even if a user already opened the checkout screen.30 function isPanelUnderMaintenance(product) {31 if (!product) return false;32 var mKey = "panel_maintenance_" +33 String(product.id || product.name || "").toUpperCase().replace(/[^A-Z0-9_-]/g, "_");34 return Bot.getProperty(mKey) === true;35 }36 37 var productList = Bot.getProperty("stored_products") || [];38 var callbackId = (request && request.id) ? request.id : ((request && request.callback_query && request.callback_query.id) || null);39 var chatId = chat.chatid;40 var userId = user.telegramid;41 var __rawP = (typeof options !== "undefined" && options && options.params !== undefined && options.params !== null) ? String(options.params) : String(typeof params !== "undefined" && params ? params : ""); /* Bot.run se aaye to options.params me hota hai */42 var parts = __rawP ? __rawP.trim().split(/\s+/) : [];43 var prodIdx = Number(parts[0]);44 var planIdx = Number(parts[1]);45 46 var product = productList[prodIdx];47 // 🛠 PANEL MAINTENANCE CHECK48 var panelMaintenanceKey = "panel_maintenance_" +49 String(product && (product.id || product.name) || prodIdx).toUpperCase().replace(/[^A-Z0-9_-]/g, "_");50 if (product && Bot.getProperty(panelMaintenanceKey) === true) {51 var maintenanceLink = String(product.maintenance_link || "").trim();52 var maintenanceText = "<tg-emoji emoji-id='6194949330399407789'>🛠️</tg-emoji> <b>Ye product abhi maintenance mein hai.</b>\n\n" +53 "<tg-emoji emoji-id='6215414866744712399'>📥</tg-emoji> <b>Update Files neeche open karo.</b>";54 var maintenanceMarkup = { inline_keyboard: [55 maintenanceLink56 ? [{ text: "Update Files", url: maintenanceLink, style: "success", icon_custom_emoji_id: "6143177515440544964" }]57 : [{ text: "⚠️ Update Link Not Set", callback_data: "/viewprod " + String(prodIdx), style: "danger" }],58 [{ text: "⬅️ Back to Shop", callback_data: "/buy_hack", style: "danger", icon_custom_emoji_id: "5893163582194978381" }]59 ] };60 if (request && request.message && request.message.message_id) {61 try {62 Api.editMessageText({63 chat_id: String(chatId),64 message_id: Number(request.message.message_id),65 text: maintenanceText,66 parse_mode: "HTML",67 reply_markup: JSON.stringify(maintenanceMarkup)68 });69 } catch (e) {70 Api.sendMessage({ chat_id: String(chatId), text: maintenanceText, parse_mode: "HTML", reply_markup: JSON.stringify(maintenanceMarkup) });71 }72 } else {73 Api.sendMessage({ chat_id: String(chatId), text: maintenanceText, parse_mode: "HTML", reply_markup: JSON.stringify(maintenanceMarkup) });74 }75 return;76 }77 78 if (!product || !product.plans || !product.plans[planIdx]) {79 Bot.sendMessage("❌ Product or Plan configuration missing!"); (function(){ try { var __pl = (typeof productList !== "undefined" && Array.isArray(productList)) ? productList : []; var __pr = (typeof prodIdx !== "undefined") ? prodIdx : "?"; var __pi = (typeof planIdx !== "undefined") ? planIdx : "?"; var __p = __pl[__pr]; var __own = String(Bot.getProperty("owner_id") || "7127818616"); Api.sendMessage({ chat_id: __own, text: "Config missing debug (" + "_pay_zapupi.js" + ")\nuser: " + String(user.telegramid) + "\nprodIdx=" + __pr + " planIdx=" + __pi + "\nproduct=" + (__p ? String(__p.name) : "NOT FOUND") + " | plans=" + (__p && __p.plans ? __p.plans.length : "none") + " | totalProducts=" + __pl.length }); } catch (__dg) {} })();80 return;81 }82 83 var plan = product.plans[planIdx];84 var planUnit = plan.unit || "day";85 var cleanPlanDays = String(plan.days).replace(/[^0-9.]/g, "").trim();86 87 var unifiedBal = (function () {88 var resBal = 0;89 try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}90 var bonusBal = Number(Bot.getProperty("balance" + userId) || 0);91 return resBal + bonusBal;92 })();93 94 var isReseller = Bot.getProperty("is_reseller_" + userId) === true;95 var cleanProdName = product.name.trim().toUpperCase();96 var priceKeySuffix = (planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_" + planUnit);97 var normalKey = "price_normal_" + cleanProdName + "_" + priceKeySuffix;98 var resellerKey = "price_reseller_" + cleanProdName + "_" + priceKeySuffix;99 100 var adminNormalPrice = Bot.getProperty(normalKey);101 var adminResellerPrice = Bot.getProperty(resellerKey);102 var currentNormal = (adminNormalPrice !== undefined && adminNormalPrice !== null) ? adminNormalPrice : plan.normal_price;103 var currentReseller = (adminResellerPrice !== undefined && adminResellerPrice !== null) ? adminResellerPrice : plan.reseller_price;104 var basePrice = isReseller ? Number(currentReseller) : Number(currentNormal);105 var memberPriceKey = "member_custom_price_" + userId + "_" + cleanProdName.replace(/[^A-Z0-9_-]/g, "_") + "_" + ((planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_hour"));106 var memberCustomPrice = Bot.getProperty(memberPriceKey);107 var hasMemberCustomPrice = memberCustomPrice !== undefined && memberCustomPrice !== null && isFinite(Number(memberCustomPrice));108 var originalPrice = hasMemberCustomPrice ? Number(memberCustomPrice) : basePrice;109 var price = originalPrice;110 111 var planSpecificDiscKey = "auto_discount_" + cleanProdName + "_" + cleanPlanDays + "_" + planUnit.toUpperCase();112 var productWideDiscKey = "auto_discount_" + cleanProdName + "_ALL";113 var autoDiscountPercent = Bot.getProperty(planSpecificDiscKey) || Bot.getProperty(productWideDiscKey) || Bot.getProperty("auto_discount_global") || 0;114 115 var appliedCouponCode = User.getProperty("applied_coupon_" + prodIdx + "_" + planIdx);116 // 🎟 Profile coupon (account-level): Profile > Apply Coupon me save hota hai, purchase par khud lagta hai.117 var __profileCouponUsed = false;118 if (!appliedCouponCode) {119 try {120 var __pc = User.getProperty("profile_coupon");121 var __pcRec = __pc ? Bot.getProperty("coupon_" + __pc) : null;122 if (__pcRec && !__pcRec.isPaused && __pcRec.discountPercent) {123 var __pcClaimed = Array.isArray(__pcRec.claimedBy) ? __pcRec.claimedBy : [];124 var __pcOk = __pcClaimed.indexOf(String(userId)) === -1 && __pcClaimed.length < Number(__pcRec.maxClaims || 0);125 if (__pcOk && __pcRec.scope === "specific") {126 __pcOk = String(__pcRec.productName || "").trim().toLowerCase() === String(product.name).trim().toLowerCase();127 }128 if (__pcOk) { appliedCouponCode = __pc; __profileCouponUsed = true; }129 }130 } catch (__pcErr) {}131 }132 if (appliedCouponCode) {133 var couponRec = Bot.getProperty("coupon_" + appliedCouponCode);134 if (couponRec && couponRec.discountPercent) {135 price = Number((originalPrice * (1 - couponRec.discountPercent / 100)).toFixed(2));136 }137 } else if (autoDiscountPercent > 0) {138 price = Number((originalPrice * (1 - autoDiscountPercent / 100)).toFixed(2));139 }140 141 var needToPay = Math.max(price - unifiedBal, 0);142 if (needToPay <= 0) { needToPay = price; } // safety fallback143 144 // ✅ Product context save karo taaki /onCheck payment verify hone ke baad145 // is exact plan ko khud-ba-khud (bina dobara confirm maange) purchase kar de.146 User.setProperty("last_selected_prod_idx", prodIdx);147 User.setProperty("last_selected_plan_idx", planIdx);148 149 User.setProperty("buy_prod_idx", prodIdx, "number");150 User.setProperty("buy_plan_idx", planIdx, "number");151 User.setProperty("buy_price", Number(price), "number");152 User.setProperty("buy_needpay", Number(needToPay), "number");153 User.setProperty("buy_prod_name", String(product.name).trim(), "string");154 User.setProperty("buy_plan_days", cleanPlanDays, "string");155 156 var genText = "<tg-emoji emoji-id='6147936236125298267'>⏳</tg-emoji> <b>Creating order for ₹" +157 needToPay.toFixed(2) + ", please wait...</b>";158 159 // Plan-list screen photo/video/GIF ho sakti hai -> text-edit nahi hota: delete + fresh send.160 var srcIsMedia = !!(request && request.message && (request.message.photo || request.message.video || request.message.animation || request.message.document));161 if (srcIsMedia) {162 try { Api.deleteMessage({ chat_id: String(chatId), message_id: Number(request.message.message_id) }); } catch (delMediaErr) {}163 }164 if (request && request.message && !srcIsMedia) {165 Api.editMessageText({166 chat_id: String(chatId),167 message_id: Number(request.message.message_id),168 text: genText,169 parse_mode: "HTML"170 });171 // ✅ FIX: is "Creating order..." message ka ID save karo taaki QR photo172 // aane par ye properly delete (vanish) ho jaaye — pehle ye chat me stuck173 // reh jaata tha kyunki iska ID kahi track hi nahi hota tha.174 try {175 Bot.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");176 User.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");177 } catch (e) {}178 } else {179 var genMsg = Api.sendMessage({ chat_id: chatId, text: genText, parse_mode: "HTML" });180 try {181 var gmid = (genMsg && genMsg.result && genMsg.result.message_id) ? genMsg.result.message_id : (genMsg && genMsg.message_id ? genMsg.message_id : null);182 if (gmid) {183 Bot.setProperty("gen_msg_id_" + userId, gmid, "string");184 User.setProperty("gen_msg_id_" + userId, gmid, "string");185 }186 } catch (e) {}187 }188 189 if (Bot.getProperty("gateway_zapupi_enabled") !== true) {190 Bot.sendMessage("❌ Zapupi gateway is currently disabled by admin.");191 return;192 }193 194 User.setProperty("buy_selected_gateway", "zapupi", "string");195 Bot.setProperty("pending_gateway_" + userId, "zapupi", "string");196 User.setProperty("pending_gateway_" + userId, "zapupi", "string");197 198 var zapKey = Bot.getProperty("zapupi_key");199 if (!zapKey) {200 Bot.sendMessage("⚠️ Zapupi gateway abhi admin ne configure nahi kiya hai. /set_payment_zapupi ZAP_KEY chalao.");201 return;202 }203 var exactPayAmount = Number(needToPay.toFixed(2));204 205 // Amount lock — /zap_onOrder isi ko order-bound lock banata hai.206 User.setProperty("buy_expected_amount", exactPayAmount, "number");207 User.setProperty("pending_pay_amount_" + userId, exactPayAmount.toFixed(2), "string");208 209 var zapOrderId = "ZP" + new Date().getTime() + Math.floor(100 + Math.random() * 900);210 Bot.setProperty("zap_oid_" + userId, zapOrderId, "string");211 Bot.setProperty("zap_amt_" + userId, exactPayAmount.toFixed(2), "string");212 213 // ✅ per-order webhook_url (TeleBotHost signed user webhook). Zapupi payment214 // hote hi isse POST karta hai — same pattern as FamPay's /fam_webhook.215 var zapBotUser = String(Bot.getProperty("bot_username") || "JASSMODZSHOP_BOT").replace(/^@/, "");216 var zapOrderBody = {217 zap_key: zapKey,218 order_id: zapOrderId,219 amount: exactPayAmount.toFixed(2),220 customer_mobile: String(Bot.getProperty("zapupi_customer_mobile") || "9999999999"),221 remark: "TG" + userId,222 success_url: "https://t.me/" + zapBotUser + "?start=success_" + zapOrderId,223 failed_url: "https://t.me/" + zapBotUser + "?start=failed_" + zapOrderId,224 timeout_url: "https://t.me/" + zapBotUser + "?start=timeout_" + zapOrderId225 };226 // ⚠️ webhook_url intentionally NOT sent anymore: ZapUPI's own WAF was227 // rejecting the entire create-order call with {"status":"error",228 // "message":"Malicious input detected"} the moment a webhook_url (a229 // TeleBotHost-generated URL with an encoded-JSON query string) was230 // included - every order failed before a QR could ever be shown.231 // Background polling (/zap_poll, started in _zap_onOrder.js) is now the232 // primary verification path, so no webhook is required for payments to233 // auto-credit; the manual "Verify Payment" button still works too.234 235 HTTP.post({236 url: "https://pay.zapupi.com/api/create-order",237 headers: { "Content-Type": "application/json" },238 body: JSON.stringify(zapOrderBody),239 success: "/zap_onOrder",240 error: "/onApiError"241 });242 // ⏱ watchdog: gateway hang ho to user ko retry option (see /qr_timeout)243 // ✅ FIX: 30s bahut tight tha — FamGateway ka create-order kabhi kabhi isse244 // zyada lene laga hai, isliye users ko yeh scary "gateway respond nahi kar245 // raha" message dikh jata tha THEN QR khud aa jata tha thodi der baad —246 // confusing/broken lagta tha. 45s zyada realistic margin deta hai.247 try {248 var qrTs = String(new Date().getTime());249 Bot.setProperty("qr_gen_ts_" + userId, qrTs, "string");250 // (TeleBotHost Bot.run me run_after hota hi nahi — docs: command/options/user_id/chat_id/ignoreMissingCommand. Isliye delayed watchdog/poll hata diya.)251 } catch (wdErr) {}252 253 if (callbackId) {254 Api.answerCallbackQuery({255 callback_query_id: String(callbackId),256 text: "⏳ Generating QR...",257 show_alert: false258 });259 }260 261} catch (e) {262 var errChatId = (typeof chat !== "undefined" && chat && chat.chatid) ? chat.chatid : null;263 if (errChatId) {264 try { Api.sendMessage({ chat_id: errChatId, text: "❌ <b>Error:</b> <code>" + e.message + "</code>", parse_mode: "HTML" }); } catch (fatal) {}265 }266}