Commit e98d5a85 authored by Your Name's avatar Your Name

Fix payment handlers to read from admin_settings table

- PayPalPaymentHandler now reads from admin_settings via get_payment_gateway_settings()
- StripePaymentHandler now reads from admin_settings via get_payment_gateway_settings()
- Remove references to non-existent payment_gateway_config table
- Fixes 'base_url' attribute error in PayPal handler
- All payment gateway configs now stored in database only
parent 75bb24d6
......@@ -17,22 +17,15 @@ class PayPalPaymentHandler:
self.config = config
self.http_client = httpx.AsyncClient(timeout=30.0)
# Load PayPal configuration from database
with self.db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute("""
SELECT * FROM payment_gateway_config
WHERE gateway_name = 'paypal'
""")
paypal_config = cursor.fetchone()
if paypal_config and paypal_config[3]: # is_enabled column
import json
config_json = json.loads(paypal_config[2]) # config_json column
self.client_id = config_json.get('client_id')
self.client_secret = config_json.get('client_secret')
self.webhook_id = config_json.get('webhook_id')
self.sandbox = config_json.get('sandbox', False)
# Load PayPal configuration from admin_settings
gateways = self.db.get_payment_gateway_settings()
paypal_config = gateways.get('paypal', {})
if paypal_config.get('enabled'):
self.client_id = paypal_config.get('client_id')
self.client_secret = paypal_config.get('client_secret')
self.webhook_secret = paypal_config.get('webhook_secret')
self.sandbox = paypal_config.get('sandbox', False)
# Set API base URL
if self.sandbox:
......@@ -42,6 +35,7 @@ class PayPalPaymentHandler:
else:
self.client_id = None
self.client_secret = None
self.base_url = None
async def get_access_token(self) -> str:
"""Get PayPal OAuth access token"""
......
......@@ -16,22 +16,15 @@ class StripePaymentHandler:
self.db = db_manager
self.config = config
# Load Stripe configuration from database
with self.db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute("""
SELECT * FROM payment_gateway_config
WHERE gateway_name = 'stripe'
""")
stripe_config = cursor.fetchone()
if stripe_config and stripe_config[3]: # is_enabled column
import json
config_json = json.loads(stripe_config[2]) # config_json column
stripe.api_key = config_json.get('secret_key')
self.publishable_key = config_json.get('publishable_key')
self.webhook_secret = config_json.get('webhook_secret')
self.test_mode = config_json.get('sandbox', False)
# Load Stripe configuration from admin_settings
gateways = self.db.get_payment_gateway_settings()
stripe_config = gateways.get('stripe', {})
if stripe_config.get('enabled'):
stripe.api_key = stripe_config.get('secret_key')
self.publishable_key = stripe_config.get('publishable_key')
self.webhook_secret = stripe_config.get('webhook_secret')
self.test_mode = stripe_config.get('sandbox', False)
else:
self.publishable_key = None
self.webhook_secret = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment