# HoneyBox API 支付系统接口测试文件
# 用于验证所有支付系统相关的控制器接口
# Checkpoint 18: 控制器测试验证

@baseUrl = http://localhost:5238/api
@contentType = application/json

# 测试用Token（需要通过登录接口获取真实Token后替换）
# 下面是一个有效的测试Token（用户ID: 21583），有效期至2026年
@authToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoi5b6u5L-h55So5oi3MTMxMCIsImV4cCI6MTc2NzQzMTM1OCwidWlkIjoiMzMyMjY2IiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbmFtZWlkZW50aWZpZXIiOiIyMTU4MyIsImF1ZCI6IkhvbmV5Qm94VXNlcnMiLCJpc3MiOiJIb25leUJveCJ9.700XWIUmzEumNk5tNYRshh7M42A8MG1X4yTHuz9PZbc

# 测试用参数
@testOrderNo = TEST_PAY_ORDER_001
@testAmount = 10.00
@testOpenId = test_open_id_123

### ============================================
### 1. 健康检查接口
### ============================================

### 1.1 健康检查 - 验证服务是否正常运行
# GET /api/health
GET {{baseUrl}}/health
Accept: {{contentType}}

### ============================================
### 2. 微信支付统一下单接口 (PayController)
### Requirements: 1.1-1.5
### ============================================

### 2.1 微信支付统一下单 - 一番赏订单
# POST /api/pay
# Requirements: 1.1, 1.2, 1.4
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "一番赏商品购买",
    "attach": "order_yfs",
    "open_id": "{{testOpenId}}"
}

### 2.2 微信支付统一下单 - 无限赏订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "WXS_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "无限赏商品购买",
    "attach": "order_wxs",
    "open_id": "{{testOpenId}}"
}

### 2.3 微信支付统一下单 - 余额充值
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "RECHARGE_{{testOrderNo}}",
    "amount": 100.00,
    "body": "余额充值",
    "attach": "user_recharge",
    "open_id": "{{testOpenId}}"
}

### 2.4 微信支付统一下单 - 发货运费
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "SHIP_{{testOrderNo}}",
    "amount": 12.00,
    "body": "发货运费",
    "attach": "order_list_send",
    "open_id": "{{testOpenId}}"
}

### 2.5 微信支付统一下单 - 擂台赏订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "LTS_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "擂台赏商品购买",
    "attach": "order_lts",
    "open_id": "{{testOpenId}}"
}

### 2.6 微信支付统一下单 - 转转赏订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "ZZS_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "转转赏商品购买",
    "attach": "order_zzs",
    "open_id": "{{testOpenId}}"
}

### 2.7 微信支付统一下单 - 福利屋订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "FLW_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "福利屋商品购买",
    "attach": "order_flw",
    "open_id": "{{testOpenId}}"
}

### 2.8 微信支付统一下单 - 商城赏订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "SCS_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "商城赏商品购买",
    "attach": "order_scs",
    "open_id": "{{testOpenId}}"
}

### 2.9 微信支付统一下单 - 翻倍赏订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "FBS_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "翻倍赏商品购买",
    "attach": "order_fbs",
    "open_id": "{{testOpenId}}"
}

### 2.10 微信支付统一下单 - 抽卡机订单
# POST /api/pay
# Requirements: 1.1, 1.2
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "CKJ_{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "抽卡机商品购买",
    "attach": "order_ckj",
    "open_id": "{{testOpenId}}"
}

### ============================================
### 3. 微信支付回调接口 (NotifyController)
### Requirements: 2.1-2.9
### ============================================

### 3.1 微信支付回调 - 成功通知（一番赏订单）
# POST /api/notify/order_notify
# Requirements: 2.1, 2.2, 2.3
# 注意：这是模拟微信支付回调，实际签名需要使用正确的商户密钥生成
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <appid><![CDATA[wx1234567890abcdef]]></appid>
    <attach><![CDATA[order_yfs]]></attach>
    <bank_type><![CDATA[CFT]]></bank_type>
    <cash_fee>1000</cash_fee>
    <fee_type><![CDATA[CNY]]></fee_type>
    <is_subscribe><![CDATA[Y]]></is_subscribe>
    <mch_id><![CDATA[1234567890]]></mch_id>
    <nonce_str><![CDATA[test_nonce_str_123]]></nonce_str>
    <openid><![CDATA[test_open_id_123]]></openid>
    <out_trade_no><![CDATA[TEST_PAY_ORDER_001]]></out_trade_no>
    <result_code><![CDATA[SUCCESS]]></result_code>
    <return_code><![CDATA[SUCCESS]]></return_code>
    <sign><![CDATA[TEST_SIGN_PLACEHOLDER]]></sign>
    <time_end><![CDATA[20260102120000]]></time_end>
    <total_fee>1000</total_fee>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <transaction_id><![CDATA[4200001234567890123456789012]]></transaction_id>
</xml>

### 3.2 微信支付回调 - 成功通知（无限赏订单）
# POST /api/notify/order_notify
# Requirements: 2.1, 2.2, 2.3
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <appid><![CDATA[wx1234567890abcdef]]></appid>
    <attach><![CDATA[order_wxs]]></attach>
    <bank_type><![CDATA[CFT]]></bank_type>
    <cash_fee>1000</cash_fee>
    <fee_type><![CDATA[CNY]]></fee_type>
    <is_subscribe><![CDATA[Y]]></is_subscribe>
    <mch_id><![CDATA[1234567890]]></mch_id>
    <nonce_str><![CDATA[test_nonce_str_456]]></nonce_str>
    <openid><![CDATA[test_open_id_123]]></openid>
    <out_trade_no><![CDATA[WXS_TEST_PAY_ORDER_001]]></out_trade_no>
    <result_code><![CDATA[SUCCESS]]></result_code>
    <return_code><![CDATA[SUCCESS]]></return_code>
    <sign><![CDATA[TEST_SIGN_PLACEHOLDER]]></sign>
    <time_end><![CDATA[20260102120000]]></time_end>
    <total_fee>1000</total_fee>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <transaction_id><![CDATA[4200001234567890123456789013]]></transaction_id>
</xml>

### 3.3 微信支付回调 - 成功通知（余额充值）
# POST /api/notify/order_notify
# Requirements: 2.1, 2.2, 2.4
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <appid><![CDATA[wx1234567890abcdef]]></appid>
    <attach><![CDATA[user_recharge]]></attach>
    <bank_type><![CDATA[CFT]]></bank_type>
    <cash_fee>10000</cash_fee>
    <fee_type><![CDATA[CNY]]></fee_type>
    <is_subscribe><![CDATA[Y]]></is_subscribe>
    <mch_id><![CDATA[1234567890]]></mch_id>
    <nonce_str><![CDATA[test_nonce_str_789]]></nonce_str>
    <openid><![CDATA[test_open_id_123]]></openid>
    <out_trade_no><![CDATA[RECHARGE_TEST_PAY_ORDER_001]]></out_trade_no>
    <result_code><![CDATA[SUCCESS]]></result_code>
    <return_code><![CDATA[SUCCESS]]></return_code>
    <sign><![CDATA[TEST_SIGN_PLACEHOLDER]]></sign>
    <time_end><![CDATA[20260102120000]]></time_end>
    <total_fee>10000</total_fee>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <transaction_id><![CDATA[4200001234567890123456789014]]></transaction_id>
</xml>

### 3.4 微信支付回调 - 成功通知（发货运费）
# POST /api/notify/order_notify
# Requirements: 2.1, 2.2, 2.5
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <appid><![CDATA[wx1234567890abcdef]]></appid>
    <attach><![CDATA[order_list_send]]></attach>
    <bank_type><![CDATA[CFT]]></bank_type>
    <cash_fee>1200</cash_fee>
    <fee_type><![CDATA[CNY]]></fee_type>
    <is_subscribe><![CDATA[Y]]></is_subscribe>
    <mch_id><![CDATA[1234567890]]></mch_id>
    <nonce_str><![CDATA[test_nonce_str_abc]]></nonce_str>
    <openid><![CDATA[test_open_id_123]]></openid>
    <out_trade_no><![CDATA[SHIP_TEST_PAY_ORDER_001]]></out_trade_no>
    <result_code><![CDATA[SUCCESS]]></result_code>
    <return_code><![CDATA[SUCCESS]]></return_code>
    <sign><![CDATA[TEST_SIGN_PLACEHOLDER]]></sign>
    <time_end><![CDATA[20260102120000]]></time_end>
    <total_fee>1200</total_fee>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <transaction_id><![CDATA[4200001234567890123456789015]]></transaction_id>
</xml>

### 3.5 微信支付回调 - 失败通知
# POST /api/notify/order_notify
# Requirements: 2.1
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <return_code><![CDATA[FAIL]]></return_code>
    <return_msg><![CDATA[签名失败]]></return_msg>
</xml>

### ============================================
### 4. 错误场景测试 - 未授权访问
### ============================================

### 4.1 未授权访问 - 支付接口（无Token）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}

{
    "order_no": "{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "测试商品",
    "attach": "order_yfs"
}

### 4.2 未授权访问 - 支付接口（无效Token）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer invalid_token_123

{
    "order_no": "{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "测试商品",
    "attach": "order_yfs"
}

### ============================================
### 5. 错误场景测试 - 参数缺失
### ============================================

### 5.1 参数缺失 - 支付接口（无订单号）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "amount": {{testAmount}},
    "body": "测试商品",
    "attach": "order_yfs"
}

### 5.2 参数缺失 - 支付接口（订单号为空）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "",
    "amount": {{testAmount}},
    "body": "测试商品",
    "attach": "order_yfs"
}

### 5.3 参数缺失 - 支付接口（金额为0）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "{{testOrderNo}}",
    "amount": 0,
    "body": "测试商品",
    "attach": "order_yfs"
}

### 5.4 参数缺失 - 支付接口（金额为负数）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "{{testOrderNo}}",
    "amount": -10.00,
    "body": "测试商品",
    "attach": "order_yfs"
}

### 5.5 参数缺失 - 支付接口（无订单类型）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "测试商品"
}

### 5.6 参数缺失 - 支付接口（订单类型为空）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "{{testOrderNo}}",
    "amount": {{testAmount}},
    "body": "测试商品",
    "attach": ""
}

### 5.7 参数缺失 - 支付接口（请求体为空）
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

### 5.8 参数缺失 - 回调接口（空XML）
# POST /api/notify/order_notify
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

### 5.9 参数缺失 - 回调接口（无效XML）
# POST /api/notify/order_notify
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<invalid>not valid xml structure

### ============================================
### 6. 边界条件测试
### ============================================

### 6.1 边界条件 - 最小金额支付
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "MIN_AMOUNT_ORDER",
    "amount": 0.01,
    "body": "最小金额测试",
    "attach": "order_yfs"
}

### 6.2 边界条件 - 大金额支付
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "MAX_AMOUNT_ORDER",
    "amount": 99999.99,
    "body": "大金额测试",
    "attach": "order_yfs"
}

### 6.3 边界条件 - 长订单号
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "VERY_LONG_ORDER_NUMBER_1234567890_ABCDEFGHIJ_1234567890",
    "amount": {{testAmount}},
    "body": "长订单号测试",
    "attach": "order_yfs"
}

### 6.4 边界条件 - 特殊字符订单号
# POST /api/pay
POST {{baseUrl}}/pay
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_no": "ORDER_2026_01_02_TEST",
    "amount": {{testAmount}},
    "body": "特殊字符订单号测试",
    "attach": "order_yfs"
}

### ============================================
### 7. 幂等性测试 - 重复回调
### Requirements: 2.8
### ============================================

### 7.1 幂等性测试 - 第一次回调
# POST /api/notify/order_notify
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <appid><![CDATA[wx1234567890abcdef]]></appid>
    <attach><![CDATA[order_yfs]]></attach>
    <bank_type><![CDATA[CFT]]></bank_type>
    <cash_fee>1000</cash_fee>
    <fee_type><![CDATA[CNY]]></fee_type>
    <is_subscribe><![CDATA[Y]]></is_subscribe>
    <mch_id><![CDATA[1234567890]]></mch_id>
    <nonce_str><![CDATA[idempotent_test_nonce]]></nonce_str>
    <openid><![CDATA[test_open_id_123]]></openid>
    <out_trade_no><![CDATA[IDEMPOTENT_TEST_ORDER]]></out_trade_no>
    <result_code><![CDATA[SUCCESS]]></result_code>
    <return_code><![CDATA[SUCCESS]]></return_code>
    <sign><![CDATA[TEST_SIGN_PLACEHOLDER]]></sign>
    <time_end><![CDATA[20260102120000]]></time_end>
    <total_fee>1000</total_fee>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <transaction_id><![CDATA[4200001234567890123456789099]]></transaction_id>
</xml>

### 7.2 幂等性测试 - 第二次回调（相同订单）
# POST /api/notify/order_notify
# 期望：返回成功但不重复处理
POST {{baseUrl}}/notify/order_notify
Content-Type: application/xml

<xml>
    <appid><![CDATA[wx1234567890abcdef]]></appid>
    <attach><![CDATA[order_yfs]]></attach>
    <bank_type><![CDATA[CFT]]></bank_type>
    <cash_fee>1000</cash_fee>
    <fee_type><![CDATA[CNY]]></fee_type>
    <is_subscribe><![CDATA[Y]]></is_subscribe>
    <mch_id><![CDATA[1234567890]]></mch_id>
    <nonce_str><![CDATA[idempotent_test_nonce]]></nonce_str>
    <openid><![CDATA[test_open_id_123]]></openid>
    <out_trade_no><![CDATA[IDEMPOTENT_TEST_ORDER]]></out_trade_no>
    <result_code><![CDATA[SUCCESS]]></result_code>
    <return_code><![CDATA[SUCCESS]]></return_code>
    <sign><![CDATA[TEST_SIGN_PLACEHOLDER]]></sign>
    <time_end><![CDATA[20260102120000]]></time_end>
    <total_fee>1000</total_fee>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <transaction_id><![CDATA[4200001234567890123456789099]]></transaction_id>
</xml>

### ============================================
### 测试说明
### ============================================
# 
# 1. 运行测试前，请确保：
#    - API服务已启动（dotnet run）
#    - 数据库连接正常
#    - 微信支付配置正确（appsettings.json）
#
# 2. 测试Token说明：
#    - 当前使用的测试Token有效期至2026年
#    - 如Token过期，请通过登录接口获取新Token
#
# 3. 微信支付回调测试说明：
#    - 回调测试中的签名是占位符，实际测试需要使用正确的签名
#    - 签名生成需要使用商户密钥
#    - 可以通过单元测试验证签名逻辑
#
# 4. 预期响应格式：
#    - 支付接口：{ "status": 1, "msg": "success", "data": { ... } }
#    - 回调接口：<xml><return_code>SUCCESS</return_code><return_msg>OK</return_msg></xml>
#
# 5. 错误响应格式：
#    - 支付接口：{ "status": 0, "msg": "错误信息" }
#    - 回调接口：<xml><return_code>SUCCESS</return_code><return_msg>OK</return_msg></xml>
#      （即使处理失败也返回成功，避免微信重复通知）
