fix payment
This commit is contained in:
+27
-1
@@ -29,7 +29,7 @@ from services.browser_pool import BrowserPool
|
||||
from services.visit_service import VisitScheduler
|
||||
from utils.helpers import parse_range, format_range, extract_domain
|
||||
from utils.telegram import send_message_safe, send_visit_result
|
||||
from managers.storage import TaskStorage, ChatStorage, BalanceStorage, RubleBalanceStorage, PaymentStorage
|
||||
from managers.storage import TaskStorage, ChatStorage, BalanceStorage, RubleBalanceStorage, PaymentStorage, PaymentHistoryStorage
|
||||
from services.payment_service import HelketPayment
|
||||
from services.twitch_api import get_viewer_count
|
||||
from auth.manager import AuthManager
|
||||
@@ -64,6 +64,7 @@ class BotInterface:
|
||||
self.balance_storage = BalanceStorage() # переходы
|
||||
self.rub_storage = RubleBalanceStorage() # рубли
|
||||
self.payment_storage = PaymentStorage()
|
||||
self.payment_history = PaymentHistoryStorage()
|
||||
self.heleket = HelketPayment()
|
||||
self._user_input_state: Dict[int, dict] = {}
|
||||
self._payment_state: Dict[int, str] = {} # user_id -> "topup" | "buy_clicks"
|
||||
@@ -542,6 +543,28 @@ class BotInterface:
|
||||
)
|
||||
await callback.answer()
|
||||
|
||||
@dp.callback_query(F.data == "payment_history")
|
||||
async def cb_payment_history(callback: CallbackQuery):
|
||||
uid = callback.from_user.id
|
||||
history = await interface.payment_history.get_user_history(uid)
|
||||
builder = InlineKeyboardBuilder()
|
||||
builder.row(InlineKeyboardButton(text="🔙 В кабинет", callback_data="my_balance"))
|
||||
|
||||
if not history:
|
||||
text = "🧾 История платежей\n\nПлатежей пока нет."
|
||||
else:
|
||||
lines = ["🧾 История платежей\n"]
|
||||
for r in history[:10]:
|
||||
dt = r.get("at", "")[:16].replace("T", " ")
|
||||
if r.get("type") == "clicks":
|
||||
lines.append(f"🖱 {r['clicks']} переходов — {r['rub']} ₽ ({dt})")
|
||||
else:
|
||||
lines.append(f"💳 Пополнение {r['rub']} ₽ ({dt})")
|
||||
text = "\n".join(lines)
|
||||
|
||||
await callback.message.edit_text(text, reply_markup=builder.as_markup())
|
||||
await callback.answer()
|
||||
|
||||
# ── Пополнение рублей (крипта → рубли) ──────────────────────────────
|
||||
|
||||
_TOPUP_PRESETS = [100, 300, 500, 1000, 3000]
|
||||
@@ -613,6 +636,7 @@ class BotInterface:
|
||||
payment_data = {
|
||||
"user_id": uid,
|
||||
"chat_id": callback.message.chat.id,
|
||||
"msg_id": callback.message.message_id,
|
||||
"payment_id": invoice["payment_id"],
|
||||
"rub": amount,
|
||||
"address": invoice.get("address"),
|
||||
@@ -925,6 +949,7 @@ class BotInterface:
|
||||
payment_data = {
|
||||
"user_id": uid,
|
||||
"chat_id": callback.message.chat.id,
|
||||
"msg_id": callback.message.message_id,
|
||||
"payment_id": invoice["payment_id"],
|
||||
"clicks": clicks,
|
||||
"rub": rub,
|
||||
@@ -2483,6 +2508,7 @@ class BotInterface:
|
||||
InlineKeyboardButton(text="💳 Пополнить криптой", callback_data="topup_main"),
|
||||
InlineKeyboardButton(text="🛒 Купить переходы", callback_data="visit_shop"),
|
||||
)
|
||||
builder.row(InlineKeyboardButton(text="🧾 История платежей", callback_data="payment_history"))
|
||||
builder.row(InlineKeyboardButton(text="🔑 Режим администратора", callback_data="enter_admin_mode"))
|
||||
await self._edit_or_send(message, text, builder.as_markup(), edit, user_id=user_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user