feat: Update endpoint checkout
This commit is contained in:
parent
3b5dba9976
commit
a5788a3d70
@ -1 +1,32 @@
|
||||
new route
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import Optional
|
||||
|
||||
from app.db import get_db
|
||||
from app.models import Payment
|
||||
from app.schemas import PaymentCreate, PaymentResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/payment", response_model=PaymentResponse)
|
||||
async def create_payment(
|
||||
payment: PaymentCreate,
|
||||
db: Session = Depends(get_db),
|
||||
user_id: Optional[int] = None,
|
||||
):
|
||||
"""
|
||||
Create a new payment record.
|
||||
|
||||
Args:
|
||||
payment (PaymentCreate): The payment data to create.
|
||||
db (Session, optional): The database session. Defaults to Depends(get_db).
|
||||
user_id (Optional[int], optional): The user ID associated with the payment. Defaults to None.
|
||||
|
||||
Returns:
|
||||
PaymentResponse: The created payment record.
|
||||
"""
|
||||
db_payment = Payment(**payment.dict(), user_id=user_id)
|
||||
db.add(db_payment)
|
||||
db.commit()
|
||||
db.refresh(db_payment)
|
||||
return db_payment
|
Loading…
x
Reference in New Issue
Block a user