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/_zap_onOrder.js
javascript · 159 lines
1/**#command2name: /zap_onOrder3answer: 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// 🟢 Zapupi create-order callback.19// Success reply: { status:"success", order_id, txn_id, payment_url }20// -> "Pay Now" link message bhejo, order state save karo, polling schedule karo.21// =========================================================22 23try {24 var userId = user.telegramid;25 var ownerId = String(Bot.getProperty("owner_id") || "7127818616");26 27 var res = null;28 try { res = (typeof content === "object") ? content : JSON.parse(content); } catch (pe) { res = null; }29 30 var genMsgId = null;31 try { genMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId); } catch (e) {}32 33 // ZapUPI's create-order response comes in TWO different shapes depending34 // on the merchant account's mode:35 // (a) pay_id + payment_image_url -> direct QR flow (image to scan)36 // (b) payment_url only -> hosted payment-page flow (Pay Now link)37 // This used to only check for payment_url, so whenever the account38 // returned shape (a) instead, a perfectly successful order was wrongly39 // treated as "order create nahi ho paya" and no QR ever appeared.40 if (!res || res.status !== "success" || (!res.payment_url && !res.pay_id)) {41 if (genMsgId) {42 try { Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId }); } catch (e) {}43 Bot.setProperty("gen_msg_id_" + userId, null, "string");44 User.setProperty("gen_msg_id_" + userId, null, "string");45 }46 Bot.setProperty("qr_gen_ts_" + userId, null, "string");47 Api.sendMessage({48 chat_id: chat.chatid,49 text: "<tg-emoji emoji-id='6219547832169273793'>❌</tg-emoji> <b>Order create nahi ho paya</b>\n<i>Thodi der baad dobara try karo ya dusra payment method chuno.</i>",50 parse_mode: "HTML",51 reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "🔄 Try Again", callback_data: "/addfund", style: "success" }], [{ text: "⬅️ Back to Menu", callback_data: "/back", style: "danger" }]] })52 });53 if (String(userId) !== ownerId) {54 var failRaw = (typeof content === "string") ? content : JSON.stringify(content || "");55 Api.sendMessage({ chat_id: ownerId, parse_mode: "HTML",56 text: "⚠️ <b>Zapupi create-order failed</b> (user <code>" + userId + "</code>)\n<code>" + String(failRaw).replace(/&/g, "&").replace(/</g, "<").slice(0, 500) + "</code>" });57 }58 return;59 }60 61 Bot.setProperty("qr_gen_ts_" + userId, null, "string");62 63 var orderId = String(res.order_id || Bot.getProperty("zap_oid_" + userId) || "");64 var lockedAmt = parseFloat(Bot.getProperty("zap_amt_" + userId) || User.getProperty("pending_pay_amount_" + userId) || 0);65 if (!orderId || isNaN(lockedAmt) || lockedAmt <= 0) {66 Bot.sendMessage("❌ Zapupi order state missing, dobara try karo.");67 return;68 }69 70 // Order -> gateway + locked amount (verification isi amount se match karti hai)71 Bot.setProperty("pay_gw_" + orderId, "zapupi", "string");72 Bot.setProperty("pay_order_amount_" + orderId, lockedAmt, "number");73 User.setProperty("pay_order_amount_" + orderId, lockedAmt, "number");74 // Order -> user mapping, used by /zap_webhook to confirm ownership before triggering a verify.75 Bot.setProperty("zap_order_owner_" + orderId, String(userId), "string");76 77 Bot.setProperty("qr_order_id_" + userId, orderId, "string");78 User.setProperty("qr_order_id_" + userId, orderId, "string");79 Bot.setProperty("qr_watch_order_" + userId, orderId, "string");80 User.setProperty("qr_watch_order_" + userId, orderId, "string");81 User.setProperty("pending_order_id", orderId, "string");82 Bot.setProperty("verifying_lock_" + userId, false, "boolean");83 User.setProperty("verifying_lock_" + userId, false, "boolean");84 85 var hasQrImage = !!res.pay_id && !!res.payment_image_url;86 87 var buttons = hasQrImage ? [88 [{ text: "Verify Payment", callback_data: "/check " + orderId, style: "primary", icon_custom_emoji_id: "6102856637343600044" }],89 [{ text: "Cancel", callback_data: "/cancel_topup " + orderId, style: "danger", icon_custom_emoji_id: "6219547832169273793" }]90 ] : [91 [{ text: "Pay ₹" + lockedAmt.toFixed(2) + " Now", url: String(res.payment_url), style: "success" }],92 [{ text: "Verify Payment", callback_data: "/check " + orderId, style: "primary", icon_custom_emoji_id: "6102856637343600044" }],93 [{ text: "Cancel", callback_data: "/cancel_topup " + orderId, style: "danger", icon_custom_emoji_id: "6219547832169273793" }]94 ];95 96 var sent;97 // QR image: ZapUPI direct image de to wahi, warna payment_url se QR banao98 var qrImageUrl = hasQrImage ? String(res.payment_image_url)99 : (res.payment_url ? "https://api.qrserver.com/v1/create-qr-code/?size=600x600&margin=10&data=" + encodeURIComponent(String(res.payment_url)) : "");100 if (qrImageUrl) {101 var qrCaption =102 "╔══════════════════════╗\n" +103 " 💰 UPI QR PAYMENT\n" +104 "╚══════════════════════╝\n\n" +105 "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n\n" +106 "💸 <b>Amount To Pay:</b> ₹<code>" + lockedAmt.toFixed(2) + "</code>\n\n" +107 "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n\n" +108 " 🪙<b>Order ID:</b> <code>" + orderId + "</code>\n\n" +109 "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n\n" +110 "💸 Scan the QR below & pay exact amount";111 sent = Api.sendPhoto({112 chat_id: chat.chatid,113 photo: qrImageUrl,114 caption: qrCaption,115 parse_mode: "HTML",116 reply_markup: JSON.stringify({ inline_keyboard: buttons })117 });118 } else {119 var linkText =120 "╔══════════════════════╗\n" +121 " 💰 UPI QR PAYMENT\n" +122 "╚══════════════════════╝\n\n" +123 "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n\n" +124 "💸 <b>Amount To Pay:</b> ₹<code>" + lockedAmt.toFixed(2) + "</code>\n\n" +125 "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n\n" +126 " 🪙<b>Order ID:</b> <code>" + orderId + "</code>\n\n" +127 "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n\n" +128 "💸 Tap Pay Now & pay exact amount";129 sent = Api.sendMessage({130 chat_id: chat.chatid,131 text: linkText,132 parse_mode: "HTML",133 reply_markup: JSON.stringify({ inline_keyboard: buttons })134 });135 }136 137 if (genMsgId) {138 try { Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId }); } catch (e) {}139 Bot.setProperty("gen_msg_id_" + userId, null, "string");140 User.setProperty("gen_msg_id_" + userId, null, "string");141 }142 143 try {144 var qrMsgId = (sent && sent.result && sent.result.message_id) ? sent.result.message_id : (sent && sent.message_id ? sent.message_id : null);145 if (qrMsgId) {146 Bot.setProperty("qr_msg_id_" + userId, qrMsgId, "string");147 User.setProperty("qr_msg_id_" + userId, qrMsgId, "string");148 }149 } catch (e) {}150 151 // 🔄 Start background auto-verify polling (same working pattern as FamPay's152 // /auto_verify_poll). run_after IS supported — Bot.run delay works fine;153 // the earlier belief that it didn't was mistaken and had silently disabled154 // ZapUPI auto-verification, leaving only the manual "Verify Payment" button.155 Bot.run({ command: "/zap_poll", options: { userId: userId, orderId: orderId, attempt: 1 }, run_after: 3 });156 157} catch (err) {158 Bot.sendMessage("⚠️ System Error: " + err.message);159}