Was reading from .env only → ✅ NOW FIXED to read from database
This commit is contained in:
20
server.py
20
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'],
|
||||
|
||||
Reference in New Issue
Block a user