Fix Stripe handler: replace hardcoded SQLite '?' placeholders with db-type-aware '%s' for MySQL

Co-Authored-By: 's avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent 48b4f355
......@@ -73,10 +73,11 @@ class StripePaymentHandler:
# Store payment method in database
with self.db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute("""
ph = '?' if self.db.db_type == 'sqlite' else '%s'
cursor.execute(f"""
INSERT INTO payment_methods
(user_id, type, identifier, is_default, is_active)
VALUES (?, 'stripe', ?, 1, 1)
VALUES ({ph}, 'stripe', {ph}, 1, 1)
""", (user_id, payment_method.id))
conn.commit()
......@@ -98,11 +99,11 @@ class StripePaymentHandler:
async def _get_or_create_customer(self, user_id: int) -> str:
"""Get existing Stripe customer or create new one"""
# Check if customer exists in database
ph = '?' if self.db.db_type == 'sqlite' else '%s'
with self.db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute(
"SELECT email, stripe_customer_id FROM users WHERE id = ?",
f"SELECT email, stripe_customer_id FROM users WHERE id = {ph}",
(user_id,)
)
user = cursor.fetchone()
......@@ -127,7 +128,7 @@ class StripePaymentHandler:
with self.db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute(
"UPDATE users SET stripe_customer_id = ? WHERE id = ?",
f"UPDATE users SET stripe_customer_id = {ph} WHERE id = {ph}",
(customer.id, user_id)
)
conn.commit()
......
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