feat(rw): remnawave integration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from datetime import UTC, datetime
|
||||
import math
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
@@ -61,12 +61,11 @@ async def checkout(
|
||||
amount=amount_to_pay,
|
||||
status=InvoiceStatus.ACTIVE,
|
||||
)
|
||||
with open("log.txt", "w") as f:
|
||||
f.write(
|
||||
" ".join((str(price), str(amount_to_pay), cfg.pally_shop_id, str(order_entry.id)))
|
||||
)
|
||||
|
||||
bill = await pally.bills.create(
|
||||
float(amount_to_pay), cfg.pally_shop_id, order_id=str(order_entry.id)
|
||||
amount=float(amount_to_pay),
|
||||
shop_id=cfg.pally_shop_id,
|
||||
order_id=str(order_entry.id),
|
||||
)
|
||||
payment_link = bill.link_page_url
|
||||
if not payment_link:
|
||||
|
||||
@@ -14,6 +14,7 @@ from core.deps import get_db
|
||||
from db.models.orders import OrderStatus
|
||||
from db.models.transactions import BalanceTransaction, BalanceTxType
|
||||
from external.pally import BillStatus
|
||||
from external.rw import sync_subscription_by_telegram_id
|
||||
from repositories import AddonsRepository
|
||||
from repositories.invoices import InvoiceRepository
|
||||
from repositories.orders import OrderRepository
|
||||
@@ -248,7 +249,15 @@ async def pally_callback( # noqa: PLR0911, PLR0912, PLR0915
|
||||
pricing=pricing,
|
||||
now=now,
|
||||
):
|
||||
await apply_order_now(session, user=user, order=order, pricing=pricing, now=now)
|
||||
applied_subscription = await apply_order_now(
|
||||
session, user=user, order=order, pricing=pricing, now=now
|
||||
)
|
||||
await sync_subscription_by_telegram_id(
|
||||
expires_at=applied_subscription.expires_at,
|
||||
devices=applied_subscription.devices,
|
||||
telegram_id=user.telegram_id,
|
||||
username=user.username,
|
||||
)
|
||||
else:
|
||||
if subscription is None:
|
||||
logger.critical(
|
||||
|
||||
Reference in New Issue
Block a user