inmsuvo/Example8BotPublic · Bot Template

ProfileTelegram

AIExample How To Use My Upi Geteway appears to be a Telegram automation bot. Commands include /start, /pay, /check_payment. Observed in code: messaging, keyboards, http, payments, web.

Utilityutility
3 commands1 envUpdated 29d agoCreated Aug 5, 2026
Back to folder

commands/_check_payment.js

javascript · 89 lines

Raw
1/**#command2name: /check_payment3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12let url = `https://upi-gateway-sstu.onrender.com/api/session/${User.getProperty("session")}`;13let res = await HTTP.get(url);14 15const serverSignature = res.headers["x-signature"];16 17if (res.data.success &&18  serverSignature &&19  res.data.data &&20  !verifyWebhookSignature(21    res.data.data,22    serverSignature,23    process.env.POLLING_SECRET24  )25)26{27  Api.answerCallbackQuery({28      callback_query_id: update.callback_query.id,29      text: "Unable to verify transaction securely. Please try again.",30      show_alert: true31  });32  return;33}34 35if (res.data.success && res.data.data.status === "paid") {36  User.setProperty("isVip", true);37  let m = await Api.sendMessage({38      text: "✅ Payment Successful!\n\n🎉 You got VIP access.",39      message_effect_id: "5046509860389126442"40  });41 42  try {43    Api.answerCallbackQuery({44        callback_query_id: request.id,45        text: "✅ Payment Successful! VIP Activated.",46        show_alert: true47    });48 49    Api.deleteMessage({50        chat_id: chat.id,51        message_id: request.message.message_id52    });53  } catch (er) {}54 55} else {56  Api.answerCallbackQuery({57      callback_query_id: request.id,58      text: res?.data?.message || "❌ Payment not received yet.\nPlease complete the payment first.",59      show_alert: true60  });61}62 63function verifyWebhookSignature(payload, signature, secret) {64  const expectedSignature =65  "sha256=" +66  crypto67  .createHmac("sha256", secret)68  .update(typeof payload === "string" ? payload : JSON.stringify(payload))69  .digest("hex");70 71  const received = String(signature || "").trim();72 73  const receivedBuffer = Buffer.from(received, "utf8");74  const expectedBuffer = Buffer.from(expectedSignature, "utf8");75 76  if (receivedBuffer.length !== expectedBuffer.length) {77    /*78    console.log({79    received,80    expectedSignature,81    receivedLength: receivedBuffer.length,82    expectedLength: expectedBuffer.length,83    });84     */85    return false;86  }87 88  return crypto.timingSafeEqual(receivedBuffer, expectedBuffer);89}