Files
AIGC/demo/test_payment.py
AIGC Developer 1e71ae6a26 feat: 系统优化和功能完善
主要更新:
- 调整并发配置为50人(数据库连接池30,Tomcat线程150,异步线程池5/20)
- 实现无界阻塞队列(LinkedBlockingQueue)任务处理
- 实现分镜视频保存功能(保存到uploads目录)
- 统一管理页面导航栏和右上角样式
- 添加日活用户统计功能
- 优化视频拼接和保存逻辑
- 添加部署文档和快速部署指南
- 更新.gitignore排除敏感配置文件
2025-11-07 19:09:50 +08:00

72 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
import json
# 测试支付API
def test_payment_api():
# 首先创建支付记录
create_payment_url = "http://localhost:8080/api/payments/create"
create_payment_data = {
"amount": 59.00,
"description": "标准版会员 - 支付宝支付",
"paymentMethod": "ALIPAY"
}
headers = {
"Authorization": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUk9MRV9VU0VSIiwidXNlcklkIjoxLCJ1c2VybmFtZSI6ImFkbWluIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE3NjE2MzYyNDQsImV4cCI6MTc2MTcyMjY0NH0.qZxHDkgSoSRvmMHBFfRdzZYtC55eCKba3VN07lTsFzKXn1hYbupv7boBJDKNOUrRYaH5ougHLFTI5xm059434g",
"Content-Type": "application/json"
}
try:
print("1. 创建支付记录...")
response = requests.post(create_payment_url, json=create_payment_data, headers=headers)
print(f"创建支付记录状态码: {response.status_code}")
print(f"创建支付记录响应: {response.text}")
if response.status_code == 200:
payment_data = response.json()
if payment_data.get('success'):
payment_id = payment_data['data']['id']
print(f"支付记录创建成功ID: {payment_id}")
# 然后创建支付宝支付
alipay_url = "http://localhost:8080/api/payments/alipay/create"
alipay_data = {"paymentId": payment_id}
print("2. 创建支付宝支付...")
alipay_response = requests.post(alipay_url, json=alipay_data, headers=headers)
print(f"支付宝支付状态码: {alipay_response.status_code}")
print(f"支付宝支付响应: {alipay_response.text}")
if alipay_response.status_code == 200:
alipay_data = alipay_response.json()
if alipay_data.get('success'):
qr_code = alipay_data['data'].get('qrCode')
print(f"支付宝二维码生成成功: {qr_code}")
else:
print(f"支付宝支付失败: {alipay_data.get('message')}")
else:
print(f"支付宝支付请求失败: {alipay_response.text}")
else:
print(f"支付记录创建失败: {payment_data.get('message')}")
else:
print(f"创建支付记录请求失败: {response.text}")
except Exception as e:
print(f"测试失败: {e}")
if __name__ == "__main__":
test_payment_api()