Refactor payment service, fix DB session, and consolidate endpoints
- Fix critical NameError in database.py by restoring Session factory - Refactor payment_service.py and crud.py to use shared constants.py and utils.py - Deduplicate state mapping and input sanitization logic - Move transaction amount calculation logic from CRUD to Router layer - Enforce type safety in schemas using IntEnum for TransactionType/Status - Move capture endpoint from transaction.py to payment.py (now /payments/capture) - Update create_customer_profile signature for clarity
This commit is contained in:
@@ -4,7 +4,9 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from decimal import Decimal
|
||||
import re
|
||||
from .constants import TransactionType, TransactionStatus
|
||||
|
||||
# --- NEW SCHEMAS FOR CIM WORKFLOW (Now with correct Pydantic V2 config) ---
|
||||
|
||||
@@ -68,7 +70,7 @@ class TransactionAuthorizeByCardID(BaseModel):
|
||||
class TransactionBase(BaseModel):
|
||||
preauthorize_amount: Optional[Decimal] = None
|
||||
charge_amount: Optional[Decimal] = None
|
||||
transaction_type: int
|
||||
transaction_type: TransactionType
|
||||
service_id: Optional[int] = None
|
||||
delivery_id: Optional[int] = None
|
||||
auto_id: Optional[int] = None
|
||||
@@ -94,8 +96,8 @@ class TransactionCapture(BaseModel):
|
||||
|
||||
class Transaction(TransactionBase):
|
||||
id: int
|
||||
transaction_type: int
|
||||
status: int
|
||||
transaction_type: TransactionType
|
||||
status: TransactionStatus
|
||||
auth_net_transaction_id: Optional[str] = None
|
||||
customer_id: int
|
||||
created_at: datetime
|
||||
|
||||
Reference in New Issue
Block a user