//测试与使用示例
//1. 启动应用程序
///////////////////////////////////////////////////////////////
# 克隆项目
git clone https://github.com/yourusername/payment-demo.git
cd payment-demo

# 安装依赖
go mod tidy

# 配置环境变量
cp .env.example .env
# 编辑.env文件，填入实际的支付配置

# 启动服务
go run main.go
/////////////////////////////////////////////////////////////////////

//2. 测试支付接口
//使用curl或Postman测试支付接口：
////////////////////////////////////////////////////////////////////////////
# 创建订单
curl -X POST http://localhost:8080/api/v1/orders \
  -H "Content-Type: application/json" \
  -d '{
    "name": "VIP会员",
    "amount": 100.00,
    "pay_type": "alipay",
    "param": "user_id=123",
    "device": "pc"
  }'

# 页面跳转支付
curl "http://localhost:8080/api/v1/payment/page?out_trade_no=ORDER202503300001&name=VIP会员&money=100.00&pay_type=alipay&param=user_id=123"

# API接口支付
curl -X POST http://localhost:8080/api/v1/payment/api \
  -H "Content-Type: application/json" \
  -d '{
    "out_trade_no": "ORDER202503300002",
    "name": "VIP会员",
    "amount": "100.00",
    "pay_type": "alipay",
    "device": "pc",
    "param": "user_id=123"
  }'

# 模拟支付回调测试
curl -X POST "http://localhost:8080/api/v1/payment/notify" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "pid=1222&trade_no=202503300001&out_trade_no=ORDER202503300001&type=alipay&name=VIP会员&money=100.00&trade_status=TRADE_SUCCESS&param=user_id=123&sign=生成的签名&sign_type=MD5"

////////////////////////////////////////////////////////
//3. 模拟支付流程测试
////////////////////////////////////////////////
# 1. 创建订单
curl -X POST http://localhost:8080/api/v1/orders \
  -H "Content-Type: application/json" \
  -d '{"name":"测试商品","amount":0.01,"pay_type":"alipay"}'

# 2. 获取订单ID（假设返回的订单ID为"ord_123456789"）
# 3. 模拟支付
curl "http://localhost:8080/api/v1/orders/ord_123456789/pay"

# 4. 查询订单状态
curl "http://localhost:8080/api/v1/orders/ord_123456789"

///////////////////////////////////////////////////////////

本Go语言支付Demo基于UESA支付平台的文档规范，结合最佳实践，实现了一个完整的支付集成解决方案。系统采用Gin框架，包含签名验证、HTTP请求、支付接口集成和回调处理等核心功能.