working auto
This commit is contained in:
@@ -8,7 +8,7 @@ import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
|
||||
from app import crud, database, schemas
|
||||
from app import crud, database, schemas, models
|
||||
from app.services import payment_service
|
||||
|
||||
# Create a router for transaction endpoints
|
||||
@@ -42,6 +42,37 @@ def get_delivery_transaction(delivery_id: int, db: Session = Depends(database.ge
|
||||
"preauthorize_amount": transaction.preauthorize_amount
|
||||
}
|
||||
|
||||
|
||||
@transaction_router.put("/transaction/delivery/{delivery_id}/update/{new_delivery_id}", summary="Update delivery_id for transaction")
|
||||
def update_transaction_delivery(delivery_id: int, new_delivery_id: int, db: Session = Depends(database.get_db)):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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")
|
||||
|
||||
transaction.delivery_id = new_delivery_id
|
||||
db.commit()
|
||||
return {"message": "Transaction delivery_id updated"}
|
||||
|
||||
|
||||
@transaction_router.put("/transaction/{transaction_id}/update_auto_id/{new_auto_id}", summary="Update auto_id for transaction")
|
||||
def update_transaction_auto_id(transaction_id: int, new_auto_id: int, db: Session = Depends(database.get_db)):
|
||||
"""
|
||||
Update the auto_id of a transaction by its ID.
|
||||
Used to set auto_id to auto_ticket.id after ticket creation.
|
||||
"""
|
||||
transaction = db.query(models.Transaction).filter(models.Transaction.id == transaction_id).first()
|
||||
if not transaction:
|
||||
raise HTTPException(status_code=404, detail="Transaction not found")
|
||||
|
||||
transaction.auto_id = new_auto_id
|
||||
db.commit()
|
||||
return {"message": "Transaction auto_id updated"}
|
||||
|
||||
|
||||
@transaction_router.post("/capture/", response_model=schemas.Transaction, summary="Capture a previously authorized amount")
|
||||
def capture_authorized_amount(transaction: schemas.TransactionCapture, db: Session = Depends(database.get_db)):
|
||||
# This endpoint captures a previously authorized transaction
|
||||
|
||||
Reference in New Issue
Block a user