freeleaps-service-hub/apps/payment/backend/models/payment/models.py

67 lines
1.6 KiB
Python

from typing import List, Dict, Optional
from decimal import Decimal
from beanie import Document
from pydantic import BaseModel
from datetime import datetime
from backend.services.payment.constants import PaymentGateway
from backend.infra.payment.constants import MoneyCollectionType, PaymentLocation
class PaymentMethod(BaseModel):
setup: bool = False
verified: bool = False
channel: Optional[PaymentGateway]
location: Optional[PaymentLocation]
priority: int = 0 # less number has high priority to be used.
class MoneyCollectingMethod(BaseModel):
setup: bool = False
verified: bool = False
channel: Optional[PaymentGateway]
type: Optional[MoneyCollectionType]
location: Optional[PaymentLocation]
priority: int = 0 # less number has high priority to be used.
stripe_account_id: Optional[str]
last_update_time: Optional[int] = None
class CurrencyAmount(BaseModel):
amount: Decimal
currency: str
class Wallet(BaseModel):
payment_methods: List[PaymentMethod]
deposit: CurrencyAmount
class BankAccount(BaseModel):
money_collecting_methods: List[MoneyCollectingMethod]
class IncomeProfileDoc(Document):
user_id: str
bank_account: BankAccount
total: CurrencyAmount
payment_location: PaymentLocation
preferred_channel: Optional[PaymentGateway] = None
class Settings:
name = "income_profile"
class PaymentProfileDoc(Document):
user_id: str
wallet: Wallet
total: CurrencyAmount
payment_location: PaymentLocation
preferred_currency: str
class Settings:
name = "payment_profile"