From d4e3405d0aa57c7701d7cc278fab61dc2c0d6b34 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Thu, 30 May 2024 17:40:26 -0400 Subject: [PATCH] if user is trialing, set payment method to trial --- backend/routes/generate_code.py | 11 +++++++++-- backend/routes/logging_utils.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py index 0c2e19d..d74adbb 100644 --- a/backend/routes/generate_code.py +++ b/backend/routes/generate_code.py @@ -118,8 +118,15 @@ async def stream_code(websocket: WebSocket): # TODO: Rename does_user_have_subscription_credits res = await does_user_have_subscription_credits(auth_token) if res.status != "not_subscriber": - if res.status == "subscriber_has_credits": - payment_method = PaymentMethod.SUBSCRIPTION + if ( + res.status == "subscriber_has_credits" + or res.status == "subscriber_is_trialing" + ): + payment_method = ( + PaymentMethod.SUBSCRIPTION + if res.status == "subscriber_has_credits" + else PaymentMethod.TRIAL + ) openai_api_key = os.environ.get("PLATFORM_OPENAI_API_KEY") print("Subscription - using platform API key") elif res.status == "subscriber_has_no_credits": diff --git a/backend/routes/logging_utils.py b/backend/routes/logging_utils.py index 052d417..bbc39c0 100644 --- a/backend/routes/logging_utils.py +++ b/backend/routes/logging_utils.py @@ -13,6 +13,7 @@ class PaymentMethod(Enum): UNKNOWN = "unknown" OPENAI_API_KEY = "openai_api_key" SUBSCRIPTION = "subscription" + TRIAL = "trial" async def send_to_saas_backend(