devbro468/Dev_x_store_botPublic · Bot Template
AIThis bot operates a digital storefront (DEV X STORE) selling subscription-based products — likely game hacks, accounts, or access keys — categorized by platform (Android Root, Non-Root, iPhone). It features a reseller program with discounted pricing, a dual-currency wallet (INR balance + Telegram Stars/XTR), and a full admin/co-admin panel for managing products, plans, per-plan pricing, stock (keys/accounts), coupons, and API endpoints. Purchases flow through a plan selection screen offering wallet payment, Stars invoices (sendInvoice with XTR currency), and coupon application. Successful Stars payments are handled via successful_payment webhook, crediting wallet or delivering keys directly. Admin tools include user listing with chunked messaging, stock viewing/deletion with inline keyboards, co-admin management, and API registry updates. The bot registers users on first interaction and
commands/_onPreCheckoutQuery.js
javascript · 40 lines
1/**#command2name: /onPreCheckoutQuery3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// ⭐ Handles Telegram's pre_checkout_query event (Stars payments).14// MUST answer within 10 seconds or the payment is auto-cancelled by Telegram.15// ⚠️ PLATFORM NOTE: This file assumes Bots.Business routes incoming16// pre_checkout_query updates to a command named "/onPreCheckoutQuery" or17// exposes it via `request.pre_checkout_query`. If this event isn't reaching18// this file in testing, the same handling logic is duplicated as a fallback19// inside _start.js (which appears to be the platform's general message router).20// =========================================================21 22try {23 var pcq = (request && request.pre_checkout_query) ? request.pre_checkout_query : null;24 if (!pcq) { return; }25 26 // ✅ Always approve — our payloads are self-validated at successful_payment time.27 // (If you later want to reject e.g. out-of-stock items, check pcq.invoice_payload here first.)28 HTTP.post({29 url: "https://api.telegram.org/bot" + bot.token + "/answerPreCheckoutQuery",30 body: {31 pre_checkout_query_id: pcq.id,32 ok: true33 }34 });35 36} catch (err) {37 try {38 Bot.sendMessage("⚠️ PreCheckout Error: " + err.message);39 } catch (e2) {}40}