Add subcription feature 2
This commit is contained in:
@@ -48,6 +48,12 @@ async def proxy_subscription_status(request: Request, tenant_id: str = Path(...)
|
||||
target_path = f"/api/v1/subscriptions/{tenant_id}/status"
|
||||
return await _proxy_to_tenant_service(request, target_path)
|
||||
|
||||
@router.api_route("/subscriptions/{tenant_id}/payment-method", methods=["GET", "OPTIONS"])
|
||||
async def proxy_payment_method(request: Request, tenant_id: str = Path(...)):
|
||||
"""Proxy payment method request to tenant service"""
|
||||
target_path = f"/api/v1/subscriptions/{tenant_id}/payment-method"
|
||||
return await _proxy_to_tenant_service(request, target_path)
|
||||
|
||||
@router.api_route("/subscriptions/cancel", methods=["POST", "OPTIONS"])
|
||||
async def proxy_subscription_cancel(request: Request):
|
||||
"""Proxy subscription cancellation request to tenant service"""
|
||||
@@ -66,6 +72,12 @@ async def proxy_payment_customer_create(request: Request):
|
||||
target_path = "/api/v1/payment-customers/create"
|
||||
return await _proxy_to_tenant_service(request, target_path)
|
||||
|
||||
@router.api_route("/setup-intents/{setup_intent_id}/verify", methods=["GET", "OPTIONS"])
|
||||
async def proxy_setup_intent_verify(request: Request, setup_intent_id: str):
|
||||
"""Proxy SetupIntent verification request to tenant service"""
|
||||
target_path = f"/api/v1/setup-intents/{setup_intent_id}/verify"
|
||||
return await _proxy_to_tenant_service(request, target_path)
|
||||
|
||||
@router.api_route("/subscriptions/reactivate", methods=["POST", "OPTIONS"])
|
||||
async def proxy_subscription_reactivate(request: Request):
|
||||
"""Proxy subscription reactivation request to tenant service"""
|
||||
@@ -116,10 +128,13 @@ async def _proxy_request(request: Request, target_path: str, service_url: str):
|
||||
|
||||
# Debug logging
|
||||
user_context = getattr(request.state, 'user', None)
|
||||
service_context = getattr(request.state, 'service', None)
|
||||
if user_context:
|
||||
logger.info(f"Forwarding subscription request to {url} with user context: user_id={user_context.get('user_id')}, email={user_context.get('email')}, subscription_tier={user_context.get('subscription_tier', 'not_set')}")
|
||||
elif service_context:
|
||||
logger.debug(f"Forwarding subscription request to {url} with service context: service_name={service_context.get('service_name')}, user_type=service")
|
||||
else:
|
||||
logger.warning(f"No user context available when forwarding subscription request to {url}")
|
||||
logger.warning(f"No user or service context available when forwarding subscription request to {url}")
|
||||
|
||||
# Get request body if present
|
||||
body = None
|
||||
|
||||
Reference in New Issue
Block a user