feat: billing guest access
This commit is contained in:
51
routers/billing.py
Normal file
51
routers/billing.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from backend.dependecies import SessionDependency, CurrentUserDependency
|
||||
from external.billing import BillStatusUpdateRequest
|
||||
from schemas.billing import *
|
||||
from services.billing import BillingService
|
||||
|
||||
billing_router = APIRouter(
|
||||
prefix='/billing',
|
||||
tags=['billing']
|
||||
)
|
||||
|
||||
|
||||
@billing_router.post(
|
||||
'/webhook'
|
||||
)
|
||||
async def webhook(
|
||||
request: BillStatusUpdateRequest,
|
||||
session: SessionDependency
|
||||
):
|
||||
try:
|
||||
await BillingService(session).process_update(request)
|
||||
return {'ok': True}
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return {'ok': False}
|
||||
|
||||
|
||||
@billing_router.post(
|
||||
'/create-deal-bill',
|
||||
operation_id='create_deal_bill',
|
||||
response_model=CreateDealBillResponse
|
||||
)
|
||||
async def create_deal_bill(
|
||||
session: SessionDependency,
|
||||
request: CreateDealBillRequest,
|
||||
user: CurrentUserDependency
|
||||
):
|
||||
return await BillingService(session).create_deal_billing(user, request)
|
||||
|
||||
|
||||
@billing_router.get(
|
||||
'/deal-bill-request/{deal_id}',
|
||||
response_model=GetDealBillById,
|
||||
operation_id='get_deal_bill_by_id'
|
||||
)
|
||||
async def get_deal_bill_by_id(
|
||||
deal_id: int,
|
||||
session: SessionDependency
|
||||
):
|
||||
return await BillingService(session).get_deal_bill_by_id(deal_id)
|
||||
Reference in New Issue
Block a user