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: ...@@ -17,22 +17,15 @@ class PayPalPaymentHandler:
self.config = config self.config = config
self.http_client = httpx.AsyncClient(timeout=30.0) self.http_client = httpx.AsyncClient(timeout=30.0)
# Load PayPal configuration from database # Load PayPal configuration from admin_settings
with self.db._get_connection() as conn: gateways = self.db.get_payment_gateway_settings()
cursor = conn.cursor() paypal_config = gateways.get('paypal', {})
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 if paypal_config.get('enabled'):
import json self.client_id = paypal_config.get('client_id')
config_json = json.loads(paypal_config[2]) # config_json column self.client_secret = paypal_config.get('client_secret')
self.client_id = config_json.get('client_id') self.webhook_secret = paypal_config.get('webhook_secret')
self.client_secret = config_json.get('client_secret') self.sandbox = paypal_config.get('sandbox', False)
self.webhook_id = config_json.get('webhook_id')
self.sandbox = config_json.get('sandbox', False)
# Set API base URL # Set API base URL
if self.sandbox: if self.sandbox:
...@@ -42,6 +35,7 @@ class PayPalPaymentHandler: ...@@ -42,6 +35,7 @@ class PayPalPaymentHandler:
else: else:
self.client_id = None self.client_id = None
self.client_secret = None self.client_secret = None
self.base_url = None
async def get_access_token(self) -> str: async def get_access_token(self) -> str:
"""Get PayPal OAuth access token""" """Get PayPal OAuth access token"""
......
...@@ -16,22 +16,15 @@ class StripePaymentHandler: ...@@ -16,22 +16,15 @@ class StripePaymentHandler:
self.db = db_manager self.db = db_manager
self.config = config self.config = config
# Load Stripe configuration from database # Load Stripe configuration from admin_settings
with self.db._get_connection() as conn: gateways = self.db.get_payment_gateway_settings()
cursor = conn.cursor() stripe_config = gateways.get('stripe', {})
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 if stripe_config.get('enabled'):
import json stripe.api_key = stripe_config.get('secret_key')
config_json = json.loads(stripe_config[2]) # config_json column self.publishable_key = stripe_config.get('publishable_key')
stripe.api_key = config_json.get('secret_key') self.webhook_secret = stripe_config.get('webhook_secret')
self.publishable_key = config_json.get('publishable_key') self.test_mode = stripe_config.get('sandbox', False)
self.webhook_secret = config_json.get('webhook_secret')
self.test_mode = config_json.get('sandbox', False)
else: else:
self.publishable_key = None self.publishable_key = None
self.webhook_secret = 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