feat: 新增后端支付模块,支持微信和支付宝
- 新增api/payment/支付服务(微信、支付宝) - 新增api/routers/payment.py支付路由 - 更新database/models.py支付相关模型 - 新增数据库迁移文件(订单表、用户订阅字段) - 更新main.py、requirements.txt、.env.production Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
40
api/payment/exceptions.py
Normal file
40
api/payment/exceptions.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
支付模块异常定义
|
||||
"""
|
||||
|
||||
|
||||
class PaymentError(Exception):
|
||||
"""支付基础异常"""
|
||||
|
||||
def __init__(self, message: str = "支付异常", code: str = "PAYMENT_ERROR"):
|
||||
self.message = message
|
||||
self.code = code
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class PaymentConfigError(PaymentError):
|
||||
"""支付配置异常"""
|
||||
|
||||
def __init__(self, message: str = "支付配置错误"):
|
||||
super().__init__(message=message, code="PAYMENT_CONFIG_ERROR")
|
||||
|
||||
|
||||
class PaymentCreateError(PaymentError):
|
||||
"""创建支付订单异常"""
|
||||
|
||||
def __init__(self, message: str = "创建支付订单失败"):
|
||||
super().__init__(message=message, code="PAYMENT_CREATE_ERROR")
|
||||
|
||||
|
||||
class PaymentNotifyError(PaymentError):
|
||||
"""支付回调通知处理异常"""
|
||||
|
||||
def __init__(self, message: str = "支付回调处理失败"):
|
||||
super().__init__(message=message, code="PAYMENT_NOTIFY_ERROR")
|
||||
|
||||
|
||||
class PaymentQueryError(PaymentError):
|
||||
"""查询支付状态异常"""
|
||||
|
||||
def __init__(self, message: str = "查询支付状态失败"):
|
||||
super().__init__(message=message, code="PAYMENT_QUERY_ERROR")
|
||||
Reference in New Issue
Block a user