Add independent payment-service (port 8012, payment_db) with foundation licensing, BYO-PSP, merchant accounts, idempotent requests, callbacks, and immutable ledger. Co-authored-by: Cursor <cursoragent@cursor.com>
13 lines
618 B
Python
13 lines
618 B
Python
import os
|
|
from urllib.parse import urlparse
|
|
def main():
|
|
url=os.getenv("PAYMENT_DATABASE_URL_SYNC","")
|
|
if not url: return
|
|
import psycopg
|
|
p=urlparse(url.replace("+psycopg","")); db=(p.path or "/payment_db").lstrip("/")
|
|
with psycopg.connect(host=p.hostname or "localhost",port=p.port or 5432,user=p.username,password=p.password,dbname="postgres",autocommit=True) as conn:
|
|
with conn.cursor() as cur:
|
|
cur.execute("SELECT 1 FROM pg_database WHERE datname=%s",(db,))
|
|
if not cur.fetchone(): cur.execute(f'CREATE DATABASE "{db}"')
|
|
if __name__=="__main__": main()
|