Исправил ошибку с id и изменил call_api что бы он работал с billing
This commit is contained in:
@@ -24,11 +24,11 @@ router = Router()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def call_api(method, endpoint, data=None):
|
||||
async def call_api(method, endpoint, data=None,base_url = BASE_URL_FASTAPI):
|
||||
"""
|
||||
Выполняет HTTP-запрос к FastAPI.
|
||||
"""
|
||||
url = f"{BASE_URL_FASTAPI}{endpoint}"
|
||||
url = f"{base_url}{endpoint}"
|
||||
logger.info(f"Инициализация запроса: {method} {url} с данными {data}")
|
||||
|
||||
try:
|
||||
@@ -71,7 +71,7 @@ async def profile_callback_handler(callback: CallbackQuery):
|
||||
|
||||
# Последняя подписка пользователя
|
||||
sub_data = await call_api(
|
||||
"GET", f"/subscription/{user_data['id']}/last"
|
||||
"GET", f"/subscription/{user_data['telegram_id']}/last"
|
||||
)
|
||||
if sub_data == "ERROR" or not isinstance(sub_data, dict):
|
||||
sub_data = None
|
||||
@@ -171,7 +171,7 @@ async def tranhist_callback_handler(callback: CallbackQuery):
|
||||
|
||||
try:
|
||||
transactions = await call_api(
|
||||
"GET", f"/user/{user_data['id']}/transactions"
|
||||
"GET", f"/user/{user_data['telegram_id']}/transactions"
|
||||
)
|
||||
if not transactions:
|
||||
await callback.message.edit_text(
|
||||
@@ -251,7 +251,7 @@ async def method_ykassa_handler(callback: CallbackQuery):
|
||||
"""
|
||||
amount = callback.data.split("_")[-1]
|
||||
data = {"user_id": callback.from_user.id, "amount": amount, "provider": "yookassa"}
|
||||
result = await call_api("POST", "billing/payments/init", data)
|
||||
result = await call_api("POST", "billing/payments/init", data,"http://billing:8000")
|
||||
|
||||
payment_url = result.get("confirmation_url", "#")
|
||||
payment_id = result.get("payment_id", "")
|
||||
@@ -276,7 +276,7 @@ async def method_crypto_handler(callback: CallbackQuery):
|
||||
"""
|
||||
amount = callback.data.split("_")[-1]
|
||||
data = {"user_id": callback.from_user.id, "amount": amount, "provider": "cryptobot"}
|
||||
result = await call_api("POST", "billing/payments/init", data)
|
||||
result = await call_api("POST", "billing/payments/init", data,"http://billing:8000")
|
||||
|
||||
payment_url = result.get("confirmation_url", "#")
|
||||
payment_id = result.get("payment_id", "")
|
||||
|
||||
Reference in New Issue
Block a user