游戏创建修复,微信支付回调修复
This commit is contained in:
parent
06bf6c4cc9
commit
669ee02cff
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -3,4 +3,5 @@
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="table_game_project" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="table_game" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
2
.idea/table_game_project.iml
generated
2
.idea/table_game_project.iml
generated
@ -2,7 +2,7 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="table_game_project" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="table_game" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyNamespacePackagesService">
|
||||
|
||||
@ -47,7 +47,7 @@ initialize_database()
|
||||
# 注册路由
|
||||
app.include_router(admin_login.router, prefix="/admin", tags=["Admin"])
|
||||
# 管理员对用户的操作接口
|
||||
app.include_router(admin_user.router, prefix="/admin", tags=["Admin-User"])
|
||||
app.include_router(admin_user .router, prefix="/admin", tags=["Admin-User"])
|
||||
# 管理员订单管理路由
|
||||
app.include_router(admin_order.router, prefix="/admin", tags=["Admin-Order"])
|
||||
app.include_router(admin_game.router, prefix="/admin", tags=["Admin-Game"])
|
||||
|
||||
@ -40,7 +40,7 @@ with open('backend/cert/apiclient_key.pem') as f:
|
||||
CERT_SERIAL_NO = config.get('wechat','cert_serial_no')
|
||||
APIV3_KEY = config.get('wechat','apiv3_key')
|
||||
APPID = config.get('wechat','appid')
|
||||
NOTIFY_URL = 'https://table-game-backend.miniprogram.ahaostudio.tech/user/order/paystatus/'
|
||||
NOTIFY_URL = 'https://table-game-backend.miniprogram.ahaostudio.tech/user/orders/paystatus/'
|
||||
CERT_DIR = './cert'
|
||||
PARTNER_MODE = False
|
||||
PROXY = None
|
||||
@ -284,7 +284,9 @@ async def wxpay_notify(request: Request):
|
||||
# 获取回调数据
|
||||
headers = dict(request.headers)
|
||||
body_bytes = await request.body()
|
||||
|
||||
print(body_bytes)
|
||||
body_unicode = body_bytes.decode('utf-8')
|
||||
print(body_unicode)
|
||||
# 验证微信支付签名
|
||||
if not wxpay.verify(headers, body_bytes):
|
||||
logging.warning("签名验证失败")
|
||||
@ -292,8 +294,11 @@ async def wxpay_notify(request: Request):
|
||||
|
||||
# 解密回调数据
|
||||
result = wxpay.decrypt_callback(headers, body_bytes)
|
||||
print(result)
|
||||
out_trade_no = result.get('out_trade_no')
|
||||
print(out_trade_no)
|
||||
transaction_id = result.get('transaction_id')
|
||||
print(transaction_id)
|
||||
|
||||
if not out_trade_no or not transaction_id:
|
||||
return JSONResponse(content={"code": "FAIL", "message": "缺少必要参数"}, status_code=400)
|
||||
|
||||
@ -39,7 +39,7 @@ def create_game(token: str, game) -> dict:
|
||||
"""
|
||||
INSERT INTO games
|
||||
(game_name, game_type, description, min_players, max_players, duration, price, difficulty_level, is_available, quantity, long_description)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
""",
|
||||
(
|
||||
game.game_name,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
[mysql]
|
||||
host = localhost
|
||||
port = 3306
|
||||
user = tguser
|
||||
password = jagxor-xokwis-dekqE6
|
||||
database = table_game
|
||||
port = 3307
|
||||
user = root
|
||||
password = mysql_YDnNkC
|
||||
database = tg01
|
||||
|
||||
[jwt]
|
||||
key = jagxor-xokwis-dekqE6
|
||||
|
||||
13
backend/redis_test.py
Normal file
13
backend/redis_test.py
Normal file
@ -0,0 +1,13 @@
|
||||
import redis
|
||||
|
||||
# 创建 Redis 连接对象,连接到本地 Redis 实例
|
||||
redis_client = redis.Redis(host='localhost', port=6379, db=0)
|
||||
|
||||
# 测试 Redis 连接是否正常
|
||||
try:
|
||||
# 使用 ping 命令测试连接
|
||||
redis_client.ping()
|
||||
print("Successfully connected to Redis!")
|
||||
except redis.ConnectionError:
|
||||
print("Failed to connect to Redis!")
|
||||
|
||||
45
demo.log
45
demo.log
@ -485,3 +485,48 @@ AttributeError: 'WeChatPay' object has no attribute 'verify'
|
||||
2025-03-10 06:56:57,517 - 41712 - DEBUG: Response status code: 200
|
||||
2025-03-10 06:56:57,518 - 41712 - DEBUG: Response headers: {'Server': 'nginx', 'Date': 'Sun, 09 Mar 2025 22:56:57 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '52', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=8', 'Cache-Control': 'no-cache, must-revalidate', 'X-Content-Type-Options': 'nosniff', 'Request-ID': '08B9B9B8BE0610AE0118A1AA8C5820ABB204289E8502-0', 'Content-Language': 'zh-CN', 'Wechatpay-Nonce': '3a1c171e4f7220784474913327ccd6dc', 'Wechatpay-Signature': 'M3TQvOadhQQwh99p6nA5KzKh6KE3PzEPhdnO45AqXLQEsVGB0k6lGODZ8E1pHE56oBR13AbMmCy9KLGpWnviD3Rl05MaMLAO0KvHVRUBh7HcyGKjPYT5Ul9MSL0AaNK59ziet6CKClQmiupiwXtFuTkt2DcLcgelzd86MIqRQxxkVLl5xWyuRh0gTMo7YJs/yAOxaFKjRjUxbKvY/Go5eB9JcFCLjwkJD7eQJz9dVITPXa96Meu0teekmpcSNBJyF/NfA95Dj33mxvmAMt1ohY58XVT8uG3mJmMJIqZakPW10sX4eABSl2XTM1NgwgMltkJ4tboxDvYNtKD+yLvX7Q==', 'Wechatpay-Timestamp': '1741561017', 'Wechatpay-Serial': '71557EDA8012268B4428C3D6C988C301F1906C59', 'Wechatpay-Signature-Type': 'WECHATPAY2-SHA256-RSA2048'}
|
||||
2025-03-10 06:56:57,518 - 41712 - DEBUG: Response content: {"prepay_id":"wx100656574693846bf3706e382f888f0001"}
|
||||
2025-03-12 18:27:17,318 - 14644 - DEBUG: /etc/localtime found
|
||||
2025-03-12 18:27:17,319 - 14644 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-12 18:27:59,741 - 14685 - DEBUG: /etc/localtime found
|
||||
2025-03-12 18:27:59,742 - 14685 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-12 18:29:02,802 - 14713 - DEBUG: /etc/localtime found
|
||||
2025-03-12 18:29:02,803 - 14713 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-13 01:39:13,358 - 18448 - DEBUG: /etc/localtime found
|
||||
2025-03-13 01:39:13,360 - 18448 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-13 01:40:23,445 - 18466 - DEBUG: /etc/localtime found
|
||||
2025-03-13 01:40:23,446 - 18466 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-13 01:44:20,476 - 18509 - DEBUG: /etc/localtime found
|
||||
2025-03-13 01:44:20,477 - 18509 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-13 01:50:06,243 - 18543 - DEBUG: /etc/localtime found
|
||||
2025-03-13 01:50:06,244 - 18543 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-13 01:50:56,212 - 18608 - DEBUG: /etc/localtime found
|
||||
2025-03-13 01:50:56,214 - 18608 - DEBUG: 1 found:
|
||||
{'/etc/localtime is a symlink to': 'Asia/Shanghai'}
|
||||
2025-03-13 01:57:51,822 - 18608 - DEBUG: Request url: https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi
|
||||
2025-03-13 01:57:51,823 - 18608 - DEBUG: Request type: POST
|
||||
2025-03-13 01:57:51,823 - 18608 - DEBUG: Request headers: {'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'wechatpay v3 api python sdk(https://github.com/minibear2021/wechatpayv3)', 'Authorization': 'WECHATPAY2-SHA256-RSA2048 mchid="1709464037",nonce_str="79093256D750476CAFEC94A5AB21EA52",signature="X0Udhp3es4SytZUq5JdP4E5IZZ10PTtVHJMUaC9y616Ff1AdLe7oJOzu26qQbNIPUgsgLj9I0QP+HBMKvg8tD4BdKC+qnahMei7M8mnTSoAJOv8LaKewAv30+FHzLXuAjwOXdy8l15ke8UgfR0uYH2GpgLVrFOASnGdcNMz9qpnxrisHARMJBM2ax/l2bYDe95eZITCD4PdcnO3l397vQTdbZ2nNDfV8s8xUXY4QkZ7e0olTJP6AVGNReo1mnPVaIkYXSFgH0uf2KgRY0GNM01eFQW0s2AYaPpq18zFSIgj05iOLFJATJsyPeHws/OYsg24wnhjXBXEybMR+voTv3Q==",timestamp="1741802271",serial_no="214EA0DFFD516E0E88BCBAD28D525D967C0FEF10"'}
|
||||
2025-03-13 01:57:51,823 - 18608 - DEBUG: Request params: {'notify_url': 'https://table-game-backend.miniprogram.ahaostudio.tech/user/orders/paystatus/', 'description': '即墨区小鲨桌游店-第B001桌-订单结算', 'out_trade_no': 'XA1C3Bfe', 'amount': {'total': 18}, 'payer': {'openid': 'op5Zb7IaP_awBMJiULYMo28TzVbU'}, 'appid': 'wx2c0e64b724b6dec4', 'mchid': '1709464037'}
|
||||
2025-03-13 01:57:51,834 - 18608 - DEBUG: Starting new HTTPS connection (1): api.mch.weixin.qq.com:443
|
||||
2025-03-13 01:57:52,327 - 18608 - DEBUG: https://api.mch.weixin.qq.com:443 "POST /v3/pay/transactions/jsapi HTTP/1.1" 200 52
|
||||
2025-03-13 01:57:52,328 - 18608 - DEBUG: Response status code: 200
|
||||
2025-03-13 01:57:52,328 - 18608 - DEBUG: Response headers: {'Server': 'nginx', 'Date': 'Wed, 12 Mar 2025 17:57:52 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '52', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=8', 'Cache-Control': 'no-cache, must-revalidate', 'X-Content-Type-Options': 'nosniff', 'Request-ID': '08A096C7BE06104C188F978EAA012084A10328B8E203-0', 'Content-Language': 'zh-CN', 'Wechatpay-Nonce': 'e83a3cb46c84a92d9ccca6db86b4b4b8', 'Wechatpay-Signature': 'maDroAc+d5NtzpYzBUfar8By8i08I3gJAbpPuv4V7/0EY7K7LCw5vGR+ycJGwHjsU6SgUUZfZSbL6EtD6BbtDnwG51iykSRNGAgQWzkMIM6lTcBWa445ch9s2rm4KHzKQ8wwCaXpKSg2kPTtJJdWAqAG9Hv2+uihn99NnwMXgrz5FSHRiDAMcNH608ayjsdSjsWd45TT51paVKPGyMA9TlOx+eMoSlX6mGc9IJ2SxqmKFvscC5YTqwOvOjvLgtR4Q6U50VS4u+Q/3iBtZfZzIH8fkVfX3DUN/HFu3M35oWcUvCqGTcLDtdw302JsBqsq7Xy+MLsPQB3BzCVG1CdcEg==', 'Wechatpay-Timestamp': '1741802272', 'Wechatpay-Serial': '71557EDA8012268B4428C3D6C988C301F1906C59', 'Wechatpay-Signature-Type': 'WECHATPAY2-SHA256-RSA2048'}
|
||||
2025-03-13 01:57:52,328 - 18608 - DEBUG: Response content: {"prepay_id":"wx13015752320196915781ccdcb56c4e0001"}
|
||||
2025-03-13 02:04:01,320 - 18608 - ERROR: 回调处理异常: 'WeChatPay' object has no attribute 'verify'
|
||||
Traceback (most recent call last):
|
||||
File "/Users/haochen/PycharmProjects/table_game/backend/app/routers/user_order.py", line 289, in wxpay_notify
|
||||
if not wxpay.verify(headers, body_bytes):
|
||||
^^^^^^^^^^^^
|
||||
AttributeError: 'WeChatPay' object has no attribute 'verify'
|
||||
2025-03-13 02:04:05,643 - 18608 - ERROR: 回调处理异常: 'WeChatPay' object has no attribute 'verify'
|
||||
Traceback (most recent call last):
|
||||
File "/Users/haochen/PycharmProjects/table_game/backend/app/routers/user_order.py", line 289, in wxpay_notify
|
||||
if not wxpay.verify(headers, body_bytes):
|
||||
^^^^^^^^^^^^
|
||||
AttributeError: 'WeChatPay' object has no attribute 'verify'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user