Was reading from .env only → NOW FIXED to read from database

This commit is contained in:
Koncept Kit
2026-01-21 00:10:02 +07:00
parent d3a0cabede
commit ece1e62913

View File

@@ -6101,7 +6101,15 @@ async def create_checkout(
# Create Stripe Checkout Session # Create Stripe Checkout Session
import stripe 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" mode = "subscription" if stripe_interval else "payment"
@@ -6176,7 +6184,15 @@ async def create_donation_checkout(
# Create Stripe Checkout Session for one-time payment # Create Stripe Checkout Session for one-time payment
import stripe 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( checkout_session = stripe.checkout.Session.create(
payment_method_types=['card'], payment_method_types=['card'],