refactor: replace direct WeChat/Alipay with unified pay-api gateway

Switch from direct WeChat Pay / Alipay integrations to the unified
宇之然 pay-api gateway (HMAC-SHA256 auth). Removes wechat_pay.py,
keeps PaymentGateway abstraction, adds UnifiedPayService. Simplifies
payment.py create_order to {plan, pay_type} params. Single webhook
endpoint replaces separate WeChat/Alipay notify handlers.
This commit is contained in:
TradeMate Dev
2026-05-29 18:36:50 +08:00
parent 5d2bced39f
commit 3e39cf0170
34 changed files with 973 additions and 424 deletions
+29
View File
@@ -0,0 +1,29 @@
from sqlalchemy import Column, String, Integer, DateTime, Float, Text, Boolean
from sqlalchemy.dialects.postgresql import UUID
from datetime import datetime
from app.database import Base
import uuid
class PaymentTransaction(Base):
__tablename__ = "payment_transactions"
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
user_id = Column(UUID(as_uuid=True), nullable=False, index=True)
order_no = Column(String(64), unique=True, nullable=False, index=True)
gateway_order_id = Column(String(128), nullable=True)
gateway_order_no = Column(String(128), nullable=True)
plan = Column(String(50), nullable=False)
amount = Column(Float, nullable=False)
currency = Column(String(10), default="CNY")
gateway = Column(String(20), nullable=False)
pay_type = Column(String(20), nullable=False)
status = Column(String(20), default="pending")
description = Column(Text, nullable=True)
refund_amount = Column(Float, default=0)
refund_reason = Column(Text, nullable=True)
paid_at = Column(DateTime, nullable=True)
refunded_at = Column(DateTime, nullable=True)
notify_raw = Column(Text, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)