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_upi.js
javascript · 744 lines
1/**#command2name: /pay_upi3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: /pay_upi14answer:15keyboard:16parse_mode: markdown17aliases:18allow_only_group: false19need_reply: false20case_insensitive: false21is_web: 022#command**/23 24/*#SIZE_V1*/25try {26 (function () {27 var z = Bot.getProperty("ui_btn_size");28 var mx = z === "large" ? 1 : (z === "medium" ? 2 : 0);29 if (!mx || Api.__sz) return;30 31 var NAV = /^[◀▶⬅➡«»‹›⏪⏩]|\d+\s*\/\s*\d+|prev|next|page/i;32 33 var T = function (m) {34 try {35 var o = typeof m === "string" ? JSON.parse(m) : m;36 if (!o || !o.inline_keyboard) return m;37 38 var out = [], cnt = 0;39 40 o.inline_keyboard.forEach(function (row) {41 var nav = row.some(function (b) {42 return NAV.test(String(b.text || "").trim());43 });44 45 if (row.length <= mx || nav) {46 out.push(row);47 cnt += row.length;48 return;49 }50 51 for (var i = 0; i < row.length; i += mx) {52 var c = row.slice(i, i + mx);53 out.push(c);54 cnt += c.length;55 }56 });57 58 if (cnt > 100 || out.length > 100) return m;59 o.inline_keyboard = out;60 return typeof m === "string" ? JSON.stringify(o) : o;61 } catch (e) {62 return m;63 }64 };65 66 [67 "sendMessage", "editMessageText", "editMessageCaption",68 "editMessageReplyMarkup", "sendPhoto", "sendVideo",69 "sendAnimation", "sendDocument"70 ].forEach(function (n) {71 var f = Api[n];72 if (typeof f !== "function") return;73 74 Api[n] = function (p) {75 try {76 if (p && p.reply_markup) p.reply_markup = T(p.reply_markup);77 } catch (e) {}78 return f.apply(Api, arguments);79 };80 });81 82 Api.__sz = true;83 })();84} catch (__szE) {}85 86/*#ANIM_V1*/87try {88 (function () {89 var M = {90 party: "5046509860389126442",91 fire: "5104841245755180586",92 heart: "5159385139981059251",93 like: "5107584321108051014"94 };95 96 var a = Bot.getProperty("ui_anim");97 if (!a || !M[a] || Api.__an) return;98 99 var E = M[a];100 var OK = /PURCHASE SUCCESSFUL|PAYMENT SUCCESSFUL|Payment verified|CONGRATULATIONS/i;101 102 var priv = function (p) {103 return p && p.chat_id && String(p.chat_id).charAt(0) !== "-";104 };105 106 ["sendMessage", "sendPhoto", "sendVideo", "sendAnimation"].forEach(function (n) {107 var f = Api[n];108 if (typeof f !== "function") return;109 110 Api[n] = function (p) {111 try {112 if (priv(p) && !p.message_effect_id &&113 OK.test(String(p.text || p.caption || ""))) {114 p.message_effect_id = E;115 }116 } catch (e) {}117 return f.apply(Api, arguments);118 };119 });120 121 var fe = Api.editMessageText;122 if (typeof fe === "function") {123 Api.editMessageText = function (p) {124 var r = fe.apply(Api, arguments);125 try {126 if (priv(p) && OK.test(String(p.text || ""))) {127 Api.sendMessage({128 chat_id: p.chat_id,129 text: "🎉",130 message_effect_id: E131 });132 }133 } catch (e) {}134 return r;135 };136 }137 138 Api.__an = true;139 })();140} catch (__anE) {}141 142/*#PREMIUM_UI_V1*/143try {144 (function () {145 if (Bot.getProperty("ui_premium") !== true || Api.__pm) return;146 147 var R = function (t, c) {148 var s = (String(t || "") + " " + String(c || "")).toLowerCase();149 150 if (/back|cancel|close|delete|remove|clear|reject|stop|ban|exit/.test(s))151 return "danger";152 153 if (/pay|buy|confirm|verify|paid|add|deposit|shop|claim|yes|receive|wallet|download|update/.test(s))154 return "success";155 156 return "primary";157 };158 159 var T = function (m) {160 try {161 var o = typeof m === "string" ? JSON.parse(m) : m;162 if (!o || !o.inline_keyboard) return m;163 164 o.inline_keyboard.forEach(function (row) {165 row.forEach(function (b) {166 if (b.copy_text || b.url || b.callback_data || b.web_app) {167 b.style = R(b.text, b.callback_data || b.url);168 169 if (!b.icon_custom_emoji_id && b.text &&170 !/^[\u2600-\u27BF\uD83C-\uD83E]/.test(String(b.text).trim()) &&171 !/^[✦✨💎]/.test(b.text)) {172 b.text = "✦ " + b.text;173 }174 }175 });176 });177 178 return typeof m === "string" ? JSON.stringify(o) : o;179 } catch (e) {180 return m;181 }182 };183 184 [185 "sendMessage", "editMessageText", "editMessageCaption",186 "editMessageReplyMarkup", "sendPhoto", "sendVideo",187 "sendAnimation", "sendDocument"188 ].forEach(function (n) {189 var f = Api[n];190 if (typeof f !== "function") return;191 192 Api[n] = function (p) {193 try {194 if (p && p.reply_markup) p.reply_markup = T(p.reply_markup);195 } catch (e) {}196 return f.apply(Api, arguments);197 };198 });199 200 Api.__pm = true;201 })();202} catch (__pmE) {}203 204// =========================================================205// 💳 Pay via UPI — selected-plan shortfall QR206// =========================================================207 208try {209 try {210 User.setProperty("buy_reseller_upgrade", null, "boolean");211 try {212 Bot.setProperty("reseller_upg_" + user.telegramid, null, "number");213 } catch (__ru) {}214 User.setProperty("buy_reseller_price", null, "number");215 } catch (__rf) {}216 217 // Maintenance guard218 function isPanelUnderMaintenance(product) {219 if (!product) return false;220 221 var mKey = "panel_maintenance_" +222 String(product.id || product.name || "")223 .toUpperCase().replace(/[^A-Z0-9_-]/g, "_");224 225 return Bot.getProperty(mKey) === true;226 }227 228 var productList = Bot.getProperty("stored_products") || [];229 230 var callbackId = (request && request.id)231 ? request.id232 : ((request && request.callback_query && request.callback_query.id) || null);233 234 var chatId = chat.chatid;235 var userId = user.telegramid;236 237 var __rawP =238 (typeof options !== "undefined" && options && options.params !== undefined && options.params !== null)239 ? String(options.params)240 : String(typeof params !== "undefined" && params ? params : "");241 242 var parts = __rawP ? __rawP.trim().split(/\s+/) : [];243 var prodIdx = Number(parts[0]);244 var planIdx = Number(parts[1]);245 246 if (!isFinite(prodIdx) || !isFinite(planIdx) ||247 prodIdx < 0 || planIdx < 0 ||248 Math.floor(prodIdx) !== prodIdx ||249 Math.floor(planIdx) !== planIdx) {250 Bot.sendMessage("❌ Product or Plan configuration missing!");251 return;252 }253 254 var product = productList[prodIdx];255 256 var panelMaintenanceKey = "panel_maintenance_" +257 String(product && (product.id || product.name) || prodIdx)258 .toUpperCase().replace(/[^A-Z0-9_-]/g, "_");259 260 if (product && Bot.getProperty(panelMaintenanceKey) === true) {261 var maintenanceLink = String(product.maintenance_link || "").trim();262 263 var maintenanceText =264 "<tg-emoji emoji-id='6194949330399407789'>🛠️</tg-emoji> <b>Ye product abhi maintenance mein hai.</b>\n\n" +265 "<tg-emoji emoji-id='6215414866744712399'>📥</tg-emoji> <b>Update Files neeche open karo.</b>";266 267 var maintenanceMarkup = {268 inline_keyboard: [269 maintenanceLink270 ? [{271 text: "Update Files",272 url: maintenanceLink,273 style: "success",274 icon_custom_emoji_id: "6143177515440544964"275 }]276 : [{277 text: "⚠️ Update Link Not Set",278 callback_data: "/viewprod " + String(prodIdx),279 style: "danger"280 }],281 [{282 text: "⬅️ Back to Shop",283 callback_data: "/buy_hack",284 style: "danger",285 icon_custom_emoji_id: "5893163582194978381"286 }]287 ]288 };289 290 if (request && request.message && request.message.message_id) {291 try {292 Api.editMessageText({293 chat_id: String(chatId),294 message_id: Number(request.message.message_id),295 text: maintenanceText,296 parse_mode: "HTML",297 reply_markup: JSON.stringify(maintenanceMarkup)298 });299 } catch (e) {300 Api.sendMessage({301 chat_id: String(chatId),302 text: maintenanceText,303 parse_mode: "HTML",304 reply_markup: JSON.stringify(maintenanceMarkup)305 });306 }307 } else {308 Api.sendMessage({309 chat_id: String(chatId),310 text: maintenanceText,311 parse_mode: "HTML",312 reply_markup: JSON.stringify(maintenanceMarkup)313 });314 }315 316 return;317 }318 319 if (!product || !Array.isArray(product.plans) || !product.plans[planIdx]) {320 Bot.sendMessage("❌ Product or Plan configuration missing!");321 322 try {323 var __pl = Array.isArray(productList) ? productList : [];324 var __p = __pl[prodIdx];325 var __own = String(Bot.getProperty("owner_id") || "7127818616");326 327 Api.sendMessage({328 chat_id: __own,329 text: "Config missing debug (_pay_upi.js)\n" +330 "user: " + String(user.telegramid) +331 "\nprodIdx=" + prodIdx +332 " planIdx=" + planIdx +333 "\nproduct=" + (__p ? String(__p.name) : "NOT FOUND") +334 " | plans=" + (__p && __p.plans ? __p.plans.length : "none") +335 " | totalProducts=" + __pl.length336 });337 } catch (__dg) {}338 339 return;340 }341 342 var plan = product.plans[planIdx];343 344 if (!plan || typeof plan !== "object") {345 Bot.sendMessage("❌ Product plan data is invalid.");346 return;347 }348 349 // ---------------------------------------------------------350 // FIX: Read duration + unit from the selected plan.351 // Supports fields such as days, duration, unit, duration_unit.352 // Example: days="1 HOUR" -> 1 hour, not 1 day.353 // ---------------------------------------------------------354 355 var rawDuration = plan.days;356 357 if (rawDuration === undefined || rawDuration === null || rawDuration === "") {358 rawDuration = plan.duration;359 }360 361 if (rawDuration === undefined || rawDuration === null || rawDuration === "") {362 rawDuration = plan.value;363 }364 365 var rawUnit = plan.unit || plan.duration_unit || plan.period || "";366 367 var durationText = String(368 rawDuration === undefined || rawDuration === null ? "" : rawDuration369 ).trim();370 371 var unitText = String(rawUnit || "").trim().toLowerCase();372 373 // Prefer the explicit unit when valid, but detect units embedded374 // in the selected plan duration label.375 var combinedText = (durationText + " " + unitText).toLowerCase();376 377 var unitMap = {378 h: "hour",379 hr: "hour",380 hrs: "hour",381 hour: "hour",382 hours: "hour",383 d: "day",384 day: "day",385 days: "day",386 w: "week",387 wk: "week",388 wks: "week",389 week: "week",390 weeks: "week",391 mo: "month",392 month: "month",393 months: "month",394 y: "year",395 yr: "year",396 yrs: "year",397 year: "year",398 years: "year"399 };400 401 var detectedUnit = "";402 403 if (/\bhours?\b|\bhrs?\b|\bhr\b/.test(combinedText)) {404 detectedUnit = "hour";405 } else if (/\bdays?\b/.test(combinedText)) {406 detectedUnit = "day";407 } else if (/\bweeks?\b|\bwks?\b|\bwk\b/.test(combinedText)) {408 detectedUnit = "week";409 } else if (/\bmonths?\b|\bmo\b/.test(combinedText)) {410 detectedUnit = "month";411 } else if (/\byears?\b|\byrs?\b|\byr\b/.test(combinedText)) {412 detectedUnit = "year";413 }414 415 var normalizedExplicitUnit = unitMap[unitText] || "";416 417 // If duration includes a unit, it takes priority over a default418 // unit that may have been attached to the plan object.419 if (detectedUnit) {420 unitText = detectedUnit;421 } else if (normalizedExplicitUnit) {422 unitText = normalizedExplicitUnit;423 } else {424 unitText = "day";425 }426 427 var durationMatch = durationText.match(/\d+(?:\.\d+)?/);428 429 if (!durationMatch) {430 durationMatch = combinedText.match(/\d+(?:\.\d+)?/);431 }432 433 if (!durationMatch) {434 Bot.sendMessage("❌ Selected plan duration is missing or invalid.");435 return;436 }437 438 var cleanPlanDays = durationMatch[0];439 var planUnit = unitText;440 441 // Keep the original plan object as the price source.442 var unifiedBal = (function () {443 var resBal = 0;444 445 try {446 resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0;447 } catch (e) {}448 449 var bonusBal = Number(Bot.getProperty("balance" + userId) || 0);450 451 return resBal + bonusBal;452 })();453 454 var isReseller = Bot.getProperty("is_reseller_" + userId) === true;455 456 var cleanProdName = String(product.name || "").trim().toUpperCase();457 458 var priceKeySuffix = (planUnit === "day")459 ? cleanPlanDays460 : (cleanPlanDays + "_" + planUnit);461 462 var normalKey = "price_normal_" + cleanProdName + "_" + priceKeySuffix;463 var resellerKey = "price_reseller_" + cleanProdName + "_" + priceKeySuffix;464 465 var adminNormalPrice = Bot.getProperty(normalKey);466 var adminResellerPrice = Bot.getProperty(resellerKey);467 468 var currentNormal =469 (adminNormalPrice !== undefined && adminNormalPrice !== null)470 ? adminNormalPrice471 : plan.normal_price;472 473 var currentReseller =474 (adminResellerPrice !== undefined && adminResellerPrice !== null)475 ? adminResellerPrice476 : plan.reseller_price;477 478 var basePrice = isReseller479 ? Number(currentReseller)480 : Number(currentNormal);481 482 var memberPriceKey =483 "member_custom_price_" + userId + "_" +484 cleanProdName.replace(/[^A-Z0-9_-]/g, "_") + "_" +485 ((planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_hour"));486 487 var memberCustomPrice = Bot.getProperty(memberPriceKey);488 489 var hasMemberCustomPrice =490 memberCustomPrice !== undefined &&491 memberCustomPrice !== null &&492 isFinite(Number(memberCustomPrice));493 494 var originalPrice = hasMemberCustomPrice495 ? Number(memberCustomPrice)496 : basePrice;497 498 var price = originalPrice;499 500 var planSpecificDiscKey =501 "auto_discount_" + cleanProdName + "_" +502 cleanPlanDays + "_" + planUnit.toUpperCase();503 504 var productWideDiscKey = "auto_discount_" + cleanProdName + "_ALL";505 506 var autoDiscountPercent =507 Bot.getProperty(planSpecificDiscKey) ||508 Bot.getProperty(productWideDiscKey) ||509 Bot.getProperty("auto_discount_global") ||510 0;511 512 var appliedCouponCode =513 User.getProperty("applied_coupon_" + prodIdx + "_" + planIdx);514 515 // Profile coupon support516 var __profileCouponUsed = false;517 518 if (!appliedCouponCode) {519 try {520 var __pc = User.getProperty("profile_coupon");521 var __pcRec = __pc ? Bot.getProperty("coupon_" + __pc) : null;522 523 if (__pcRec && !__pcRec.isPaused && __pcRec.discountPercent) {524 var __pcClaimed = Array.isArray(__pcRec.claimedBy)525 ? __pcRec.claimedBy526 : [];527 528 var __pcOk =529 __pcClaimed.indexOf(String(userId)) === -1 &&530 __pcClaimed.length < Number(__pcRec.maxClaims || 0);531 532 if (__pcOk && __pcRec.scope === "specific") {533 __pcOk =534 String(__pcRec.productName || "").trim().toLowerCase() ===535 String(product.name).trim().toLowerCase();536 }537 538 if (__pcOk) {539 appliedCouponCode = __pc;540 __profileCouponUsed = true;541 }542 }543 } catch (__pcErr) {}544 }545 546 if (appliedCouponCode) {547 var couponRec = Bot.getProperty("coupon_" + appliedCouponCode);548 549 if (couponRec && couponRec.discountPercent) {550 price = Number(551 (originalPrice * (1 - couponRec.discountPercent / 100)).toFixed(2)552 );553 }554 } else if (Number(autoDiscountPercent) > 0) {555 price = Number(556 (originalPrice * (1 - Number(autoDiscountPercent) / 100)).toFixed(2)557 );558 }559 560 if (!isFinite(price) || price < 0) {561 Bot.sendMessage("❌ Invalid plan price. Please contact admin.");562 return;563 }564 565 var needToPay = Math.max(price - unifiedBal, 0);566 567 // Existing fallback behavior preserved.568 if (needToPay <= 0) {569 needToPay = price;570 }571 572 // Save selected product + plan context for verification/purchase.573 User.setProperty("last_selected_prod_idx", prodIdx);574 User.setProperty("last_selected_plan_idx", planIdx);575 576 User.setProperty("buy_prod_idx", prodIdx, "number");577 User.setProperty("buy_plan_idx", planIdx, "number");578 User.setProperty("buy_price", Number(price), "number");579 User.setProperty("buy_needpay", Number(needToPay), "number");580 User.setProperty("buy_prod_name", String(product.name).trim(), "string");581 582 // These properties are used by /onBuyQR to show the selected plan.583 User.setProperty("buy_plan_days", cleanPlanDays, "string");584 User.setProperty("buy_plan_unit", planUnit, "string");585 User.setProperty(586 "buy_plan_name",587 String(cleanPlanDays + " " + planUnit).toUpperCase(),588 "string"589 );590 User.setProperty(591 "buy_selected_plan",592 String(cleanPlanDays + " " + planUnit).toUpperCase(),593 "string"594 );595 596 var genText =597 "<tg-emoji emoji-id='6147936236125298267'>⏳</tg-emoji> <b>Creating order for ₹" +598 needToPay.toFixed(2) +599 ", please wait...</b>";600 601 // Preserve media-screen handling.602 var srcIsMedia = !!(603 request && request.message &&604 (request.message.photo || request.message.video ||605 request.message.animation || request.message.document)606 );607 608 if (srcIsMedia) {609 try {610 Api.deleteMessage({611 chat_id: String(chatId),612 message_id: Number(request.message.message_id)613 });614 } catch (delMediaErr) {}615 }616 617 if (request && request.message && !srcIsMedia) {618 Api.editMessageText({619 chat_id: String(chatId),620 message_id: Number(request.message.message_id),621 text: genText,622 parse_mode: "HTML"623 });624 625 try {626 Bot.setProperty(627 "gen_msg_id_" + userId,628 request.message.message_id,629 "string"630 );631 632 User.setProperty(633 "gen_msg_id_" + userId,634 request.message.message_id,635 "string"636 );637 } catch (e) {}638 } else {639 var genMsg = Api.sendMessage({640 chat_id: chatId,641 text: genText,642 parse_mode: "HTML"643 });644 645 try {646 var gmid =647 (genMsg && genMsg.result && genMsg.result.message_id)648 ? genMsg.result.message_id649 : (genMsg && genMsg.message_id ? genMsg.message_id : null);650 651 if (gmid) {652 Bot.setProperty("gen_msg_id_" + userId, gmid, "string");653 User.setProperty("gen_msg_id_" + userId, gmid, "string");654 }655 } catch (e) {}656 }657 658 if (Bot.getProperty("gateway_upi_enabled") === false) {659 Bot.sendMessage("❌ Paytm Business gateway is currently disabled by admin.");660 return;661 }662 663 // This command uses Paytm only.664 User.setProperty("buy_selected_gateway", "paytm", "string");665 Bot.setProperty("pending_gateway_" + userId, "paytm", "string");666 User.setProperty("pending_gateway_" + userId, "paytm", "string");667 668 var upi_id =669 Bot.getProperty("paytm_upi") ||670 Bot.getProperty("payment_upi_id") ||671 "paytm.s1tk6od@pty";672 673 var merchantId =674 Bot.getProperty("paytm_merchant_id") ||675 "SDfRhW21109811758334";676 677 var merchantKey =678 Bot.getProperty("paytm_merchant_key") ||679 "SDfRhW21109811758334";680 681 if (!upi_id || !merchantId || !merchantKey) {682 Bot.sendMessage(683 "⚠️ Paytm Business gateway abhi configure nahi hai. Admin se Paytm UPI / Merchant ID / Merchant Key set karwao."684 );685 return;686 }687 688 var exactPayAmount = Number(needToPay.toFixed(2));689 690 User.setProperty("buy_expected_amount", exactPayAmount, "number");691 692 User.setProperty(693 "pending_pay_amount_" + userId,694 exactPayAmount.toFixed(2),695 "string"696 );697 698 var paytmUrl =699 "https://paytm.anujbots.xyz/qr.php?upi=" +700 encodeURIComponent(upi_id) +701 "&amount=" +702 encodeURIComponent(exactPayAmount.toFixed(2)) +703 "&merchantid=" +704 encodeURIComponent(merchantId) +705 "&merchantkey=" +706 encodeURIComponent(merchantKey);707 708 HTTP.get({709 url: paytmUrl,710 success: "/onBuyQR",711 error: "/onBuyQR"712 });713 714 try {715 var qrTs = String(new Date().getTime());716 Bot.setProperty("qr_gen_ts_" + userId, qrTs, "string");717 } catch (wdErr) {}718 719 if (callbackId) {720 Api.answerCallbackQuery({721 callback_query_id: String(callbackId),722 text: "⏳ Generating QR...",723 show_alert: false724 });725 }726 727} catch (e) {728 var errChatId =729 (typeof chat !== "undefined" && chat && chat.chatid)730 ? chat.chatid731 : null;732 733 if (errChatId) {734 try {735 Api.sendMessage({736 chat_id: errChatId,737 text: "❌ <b>Error:</b> <code>" +738 String(e && e.message ? e.message : e) +739 "</code>",740 parse_mode: "HTML"741 });742 } catch (fatal) {}743 }744}