From ece1e629137b6a26ee4c423e6542208ee8000acf Mon Sep 17 00:00:00 2001 From: Koncept Kit <63216427+konceptkit@users.noreply.github.com> Date: Wed, 21 Jan 2026 00:10:02 +0700 Subject: [PATCH] =?UTF-8?q?Was=20reading=20from=20.env=20only=20=E2=86=92?= =?UTF-8?q?=20=E2=9C=85=20NOW=20FIXED=20to=20read=20from=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 8cf51a7..a10850c 100644 --- a/server.py +++ b/server.py @@ -6101,7 +6101,15 @@ async def create_checkout( # Create Stripe Checkout Session import stripe - stripe.api_key = os.getenv("STRIPE_SECRET_KEY") + # Try to get Stripe API key from database first, then fall back to environment + stripe_key = get_setting(db, 'stripe_secret_key', decrypt=True) + if not stripe_key: + stripe_key = os.getenv("STRIPE_SECRET_KEY") + + if not stripe_key: + raise HTTPException(status_code=500, detail="Stripe API key not configured") + + stripe.api_key = stripe_key mode = "subscription" if stripe_interval else "payment" @@ -6176,7 +6184,15 @@ async def create_donation_checkout( # Create Stripe Checkout Session for one-time payment import stripe - stripe.api_key = os.getenv("STRIPE_SECRET_KEY") + # Try to get Stripe API key from database first, then fall back to environment + stripe_key = get_setting(db, 'stripe_secret_key', decrypt=True) + if not stripe_key: + stripe_key = os.getenv("STRIPE_SECRET_KEY") + + if not stripe_key: + raise HTTPException(status_code=500, detail="Stripe API key not configured") + + stripe.api_key = stripe_key checkout_session = stripe.checkout.Session.create( payment_method_types=['card'],