major claude changes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
## File: transaction.py (New transaction router)
|
||||
import logging
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
import enum
|
||||
@@ -11,6 +12,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
from app import crud, database, schemas, models
|
||||
from app.services import payment_service
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create a router for transaction endpoints
|
||||
transaction_router = APIRouter()
|
||||
|
||||
@@ -22,6 +25,7 @@ class TransactionStatus(enum.IntEnum):
|
||||
@transaction_router.get("/test/", summary="Test transaction router")
|
||||
def test_transaction_router():
|
||||
"""Test endpoint to verify transaction router is loaded"""
|
||||
logger.info("GET /test - Testing transaction router")
|
||||
return {"test": "transaction router is working"}
|
||||
|
||||
|
||||
@@ -34,6 +38,7 @@ def get_delivery_transaction(delivery_id: int, db: Session = Depends(database.ge
|
||||
Get the pre-authorization transaction for a specific delivery.
|
||||
This endpoint is used to retrieve transaction details for delivery finalization.
|
||||
"""
|
||||
logger.info(f"GET /transaction/delivery/{delivery_id} - Fetching delivery transaction")
|
||||
transaction = crud.get_transaction_by_delivery_id(db, delivery_id=delivery_id)
|
||||
if not transaction:
|
||||
raise HTTPException(status_code=404, detail="No pre-authorization transaction found for this delivery")
|
||||
@@ -53,6 +58,7 @@ def update_transaction_delivery(delivery_id: int, new_delivery_id: int, db: Sess
|
||||
Update the delivery_id of a transaction based on the current delivery_id.
|
||||
Used to change transaction from auto_delivery.id to auto_ticket.id
|
||||
"""
|
||||
logger.info(f"PUT /transaction/delivery/{delivery_id}/update/{new_delivery_id} - Updating transaction delivery ID")
|
||||
transaction = crud.get_transaction_by_delivery_id(db, delivery_id=delivery_id)
|
||||
if not transaction:
|
||||
raise HTTPException(status_code=404, detail="No transaction found for this delivery")
|
||||
@@ -68,6 +74,7 @@ def update_transaction_auto_id(transaction_id: int, new_auto_id: int, db: Sessio
|
||||
Update the auto_id of a transaction by its ID.
|
||||
Used to set auto_id to auto_ticket.id after ticket creation.
|
||||
"""
|
||||
logger.info(f"PUT /transaction/{transaction_id}/update_auto_id/{new_auto_id} - Updating transaction auto ID")
|
||||
transaction = db.query(models.Transaction).filter(models.Transaction.id == transaction_id).first()
|
||||
if not transaction:
|
||||
raise HTTPException(status_code=404, detail="Transaction not found")
|
||||
@@ -81,6 +88,7 @@ def update_transaction_auto_id(transaction_id: int, new_auto_id: int, db: Sessio
|
||||
def capture_authorized_amount(transaction: schemas.TransactionCapture, db: Session = Depends(database.get_db)):
|
||||
# This endpoint captures a previously authorized transaction
|
||||
# It finds the original transaction by its ID and captures the funds
|
||||
logger.info(f"POST /capture - Capturing authorized transaction {transaction.auth_net_transaction_id}")
|
||||
auth_transaction = crud.get_transaction_by_auth_id(db, auth_net_transaction_id=transaction.auth_net_transaction_id)
|
||||
if not auth_transaction:
|
||||
raise HTTPException(status_code=404, detail="Authorization transaction not found")
|
||||
|
||||
Reference in New Issue
Block a user