add netopia payment process
This commit is contained in:
33
UI_V2/dbActions/netopia.py
Normal file
33
UI_V2/dbActions/netopia.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import sqlite3
|
||||
from typing import Optional
|
||||
|
||||
class Netopia:
|
||||
def __init__(self, db_path="instance/app_database.db"):
|
||||
self.db_path = db_path
|
||||
self._create_netopia_table()
|
||||
|
||||
def _create_netopia_table(self):
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS netopia (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
order_id TEXT,
|
||||
netopia_id TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
""")
|
||||
conn.commit()
|
||||
|
||||
def add_netopia_card(self, order_id, netopia_id):
|
||||
try:
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("""
|
||||
INSERT INTO netopia (order_id, netopia_id)
|
||||
VALUES (?, ? )
|
||||
""", (order_id, netopia_id))
|
||||
conn.commit()
|
||||
return True
|
||||
except sqlite3.IntegrityError:
|
||||
return False
|
||||
Reference in New Issue
Block a user