更新功能和文档: 增强支付系统、任务队列管理、用户作品管理等功能
This commit is contained in:
59
demo/test_payment.py
Normal file
59
demo/test_payment.py
Normal file
@@ -0,0 +1,59 @@
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user