- 删除PayPalService.java和PayPalController.java - 从PaymentMethod枚举中移除PAYPAL选项 - 移除PaymentController和PaymentApiController中的PayPal相关代码 - 移除前端PayPal支付选项和相关API - 清理配置文件中的PayPal配置 - 修复OrderController中的PayPal引用错误
65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
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()
|
||
|
||
|
||
|
||
|
||
|
||
|