feat: implement billing system with Pally integration
- Added billing models and repository for handling bills. - Introduced BillingService to manage payment initiation and bill creation. - Updated user service to remove ticket-related functionality. - Refactored settings to include new billing-related fields. - Removed ticket-related handlers and schemas. - Added new billing handlers for processing payments. - Updated database schema with new bills table and status enum. - Enhanced utility functions to calculate prices considering discounts. - Introduced prehandling for non-private messages. - Updated main application to initialize new billing services and repositories.
This commit is contained in:
13
schemas/billing.py
Normal file
13
schemas/billing.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class BillingProviders(Enum):
|
||||
PALLY = "pally"
|
||||
|
||||
|
||||
@dataclass
|
||||
class BillingContext:
|
||||
amount: int
|
||||
bill_id: int | None = None
|
||||
provider: BillingProviders | None = BillingProviders.PALLY
|
||||
@@ -2,14 +2,18 @@ from dataclasses import dataclass
|
||||
|
||||
from remnawave import RemnawaveSDK
|
||||
|
||||
from repositories.tickets import TicketRepository
|
||||
from misc.pally import PallyClient
|
||||
from repositories.bills import BillsRepository
|
||||
from repositories.users import UserRepository
|
||||
from services.billing_service import BillingService
|
||||
from services.user_service import UserService
|
||||
|
||||
|
||||
@dataclass
|
||||
class DependenciesDTO:
|
||||
ticket_repository: TicketRepository
|
||||
user_repository: UserRepository
|
||||
user_service: UserService
|
||||
rw_sdk: RemnawaveSDK
|
||||
bills_repository: BillsRepository
|
||||
billing_service: BillingService
|
||||
pally_client: PallyClient
|
||||
|
||||
@@ -16,3 +16,4 @@ class SubscriptionPlan(BaseModel):
|
||||
devices: int = settings.min_devices
|
||||
duration: SubscriptionDuration = SubscriptionDuration.MONTH
|
||||
whitelists: bool = False
|
||||
discount: float = 1
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class NewTicketDTO:
|
||||
creator_id: int
|
||||
Reference in New Issue
Block a user