Add new infra architecture 13
This commit is contained in:
@@ -4,6 +4,7 @@ Implements SetupIntent-first architecture for secure payment flows
|
||||
Implements PaymentProvider interface for easy SDK swapping
|
||||
"""
|
||||
|
||||
import os
|
||||
import stripe
|
||||
import uuid
|
||||
import logging
|
||||
@@ -30,12 +31,13 @@ class StripeClient(PaymentProvider):
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize Stripe client with configuration"""
|
||||
settings = BaseServiceSettings()
|
||||
stripe.api_key = settings.STRIPE_SECRET_KEY
|
||||
# Read Stripe settings directly from environment to avoid BaseServiceSettings validation
|
||||
stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")
|
||||
# Let the SDK use its default pinned API version (2025-12-15.clover for v14.1.0)
|
||||
# Only override if explicitly set in environment
|
||||
if settings.STRIPE_API_VERSION:
|
||||
stripe.api_version = settings.STRIPE_API_VERSION
|
||||
stripe_api_version = os.environ.get("STRIPE_API_VERSION")
|
||||
if stripe_api_version:
|
||||
stripe.api_version = stripe_api_version
|
||||
|
||||
async def create_setup_intent_for_verification(
|
||||
self,
|
||||
|
||||
@@ -100,9 +100,33 @@ class BaseServiceSettings(BaseSettings):
|
||||
# DATABASE CONFIGURATION
|
||||
# ================================================================
|
||||
|
||||
# Note: DATABASE_URL is defined as a property in each service-specific config
|
||||
# to construct the URL from secure environment variables
|
||||
|
||||
# DATABASE_URL as a property - can be overridden by service-specific configs
|
||||
# Base implementation reads from environment variable or builds from components
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from environment or components.
|
||||
|
||||
Service-specific configs should override this property to use their
|
||||
own service-specific environment variables (e.g., TENANT_DATABASE_URL).
|
||||
"""
|
||||
# Try complete URL first
|
||||
complete_url = os.getenv("DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Try to build from standard components
|
||||
user = os.getenv("DB_USER", "")
|
||||
password = os.getenv("DB_PASSWORD", "")
|
||||
host = os.getenv("DB_HOST", "localhost")
|
||||
port = os.getenv("DB_PORT", "5432")
|
||||
name = os.getenv("DB_NAME", "")
|
||||
|
||||
if user and password and name:
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Return empty string if not configured (will fail validation in production)
|
||||
return ""
|
||||
|
||||
# Database connection settings
|
||||
DB_POOL_SIZE: int = int(os.getenv("DB_POOL_SIZE", "10"))
|
||||
DB_MAX_OVERFLOW: int = int(os.getenv("DB_MAX_OVERFLOW", "20"))
|
||||
|
||||
Reference in New Issue
Block a user