Managing customer license keys often forces you to build bloated web portals just so buyers can verify their plan tier or unbind a key. By combining FlexGram's Firebase-backed
USER state with global HTTP requests, you can handle license verification, local state binding, and self-serve key management entirely inside Telegram. Customers activate digital products instantly while your infrastructure stays minimal.๐ Filename:
command/activate.js๐จโ๐ป Code:
if (!params) return sendMessage("Please provide a key: `/activate YOUR-KEY`");
let res = HTTP.post({ url: "https://api.mysoftware.com/verify", body: JSON.stringify({ key: params, tg_id: user.telegramid }) });
let data = JSON.parse(res.body || "{}");
if (!data.valid) return sendMessage("Invalid or expired license key.");
USER.setProperty("license_key", params);
USER.setProperty("license_tier", data.tier);
sendMessage("*License Activated!*\nPlan: *" + data.tier + "*");๐ Filename:
command/status.js๐จโ๐ป Code:
let key = USER.getProp("license_key").value();
let tier = USER.getProp("license_tier").value();
if (!key) return sendMessage("No active license found. Use `/activate KEY` first.");
sendMessage("*Active License Details*\nKey: `" + key + "`\nPlan: *" + tier + "*");๐ Filename:
command/deactivate.js๐จโ๐ป Code:
let key = USER.getProp("license_key").value();
if (!key) return sendMessage("You do not have an active license to revoke.");
USER.deleteProp("license_key");
USER.deleteProp("license_tier");
sendMessage("License `" + key + "` has been unbound from this account.");๐ก Because
USER properties persist automatically in Firebase Realtime DB, your backend desktop or web app can query user key states directly without hammering your central auth endpoint.โ ๏ธ Note: Store external API tokens and secret keys in your production environment variables to keep backend calls secure.
#FlexGram

