Files
pay/internal/router/router.go
T
wangjia fd5f56f7de feat: 微信V3 + 支付宝手机站/UA自适应 + 业务对接(签名下单/webhook) + 通用多业务
- 微信支付 V3 Native 渠道 (wechat.go):Native下单/回调AES-GCM解密验签/查单
- 支付宝:手机网站支付 wap.pay + 按 UA 自适应(PC page.pay扫码 / 手机拉App);qr_pay_mode=2 完整扫码收银台
- 业务对接:下单接口扩展(biz_system/biz_ref/return_url)+ HMAC 签名鉴权;支付成功 webhook 主动推送业务方 + 60s 重试 + BizNotifyLog
- 通用多业务:config.biz 改 map,加业务只改配置(BIZ_<SYS>_SECRET/_CALLBACK_URL)
- seedPlans:四档真实套餐 + promo_first_month(¥1) + test_liandiao(0.01),均挂 biz_code;/products 暴露 biz_code
- 删除沙箱 pay.html;对接设计文档入 docs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019UQmqWmV67sXGLrb3U1XXn
2026-07-03 22:44:34 +08:00

37 lines
1.0 KiB
Go

package router
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"github.com/wangjia/pay/config"
"github.com/wangjia/pay/internal/channel"
"github.com/wangjia/pay/internal/handler"
"github.com/wangjia/pay/internal/service"
)
// Setup 装配路由。返回 OrderService 供 main 启动查单兜底任务。
func Setup(r *gin.Engine, db *gorm.DB, reg *channel.Registry) *service.OrderService {
orderSvc := service.NewOrderService(db, reg, config.C.Server.BaseURL)
orderH := handler.NewOrderHandler(orderSvc)
pageH := handler.NewPageHandler(db, "web")
r.GET("/health", func(c *gin.Context) { c.JSON(200, gin.H{"status": "ok"}) })
// 页面
r.GET("/result", pageH.ResultPage)
r.GET("/qrcode", pageH.QRCode)
v1 := r.Group("/api/v1")
{
v1.GET("/products", pageH.ListProducts)
v1.POST("/orders", orderH.Create)
v1.POST("/orders/qr", orderH.CreateQR)
v1.GET("/orders/:out_trade_no", orderH.GetStatus)
v1.POST("/notify/alipay", orderH.AlipayNotify)
v1.POST("/notify/wechat", orderH.WechatNotify)
}
return orderSvc
}