telegram
RUEN
~/cases/approute-shop

AppRoute Shop

A Telegram store for digital codes. The buyer pays via Platega, the bot buys the code from AppRoute and sends it to the chat with instructions.

166automated tests, including concurrent orders
60 spayment and order checks
10 mincatalog and price refresh
14latest backups kept

The task

The store owner wanted to sell digital codes — Valorant Points, PlayStation, Apple Gift Card and more — with no manual work: the buyer pays, the bot buys the code from the supplier and delivers it.

What I built

  • a catalog by section and region; AppRoute products are added by ID
  • automatic pricing: markup, fees, minimum margin and rounding — prices follow purchase costs
  • payments through Platega: SBP or crypto
  • automatic purchase and delivery of the code to the chat with instructions, plus a "My orders" section
  • problem orders: retry, manual delivery, refund
  • notifications about sales, issues, low balance and chargebacks
  • an admin panel inside the bot and daily backups to a private channel

Under the hood

  • No double purchases. Every order is bought under its own key. After a failure the bot first looks the order up at the supplier and only then retries.
  • Payment callbacks aren't trusted. A callback is just a signal: status and amount are re-checked through the API, underpayments go to problem orders.
  • Balance safeguards. Free balance accounts for reserves on open orders, with a daily limit and a stop button for sales.
  • Codes are encrypted in the database, and the key never ends up in backups.
stack:Pythonaiogram 3aiohttpSQLiteFernetsystemdnginx

The code belongs to the clients, so the case pages only describe the work.