更新小程序API路径,统一为/api/miniprogram前缀,确保与后端一致性。同时,调整微信支付相关配置,增强系统的灵活性和可维护性。
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -48,5 +49,37 @@ func PaymentWechatNotify(c *gin.Context) {
|
||||
|
||||
// PaymentWechatTransferNotify POST /api/payment/wechat/transfer/notify
|
||||
func PaymentWechatTransferNotify(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||
// 微信转账回调处理
|
||||
// 注意:实际生产环境需要验证签名,这里简化处理
|
||||
|
||||
var req struct {
|
||||
ID string `json:"id"`
|
||||
CreateTime string `json:"create_time"`
|
||||
EventType string `json:"event_type"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
Summary string `json:"summary"`
|
||||
Resource struct {
|
||||
Algorithm string `json:"algorithm"`
|
||||
Ciphertext string `json:"ciphertext"`
|
||||
AssociatedData string `json:"associated_data"`
|
||||
Nonce string `json:"nonce"`
|
||||
} `json:"resource"`
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
fmt.Printf("[TransferNotify] 解析请求失败: %v\n", err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": "FAIL", "message": "请求格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("[TransferNotify] 收到转账回调: event_type=%s\n", req.EventType)
|
||||
|
||||
// TODO: 使用 APIv3 密钥解密 resource.ciphertext
|
||||
// 解密后可以获取转账详情(outBatchNo、outDetailNo、detailStatus等)
|
||||
|
||||
// 暂时记录日志,实际处理需要解密后进行
|
||||
fmt.Printf("[TransferNotify] 转账回调数据: %+v\n", req)
|
||||
|
||||
// 返回成功响应
|
||||
c.JSON(http.StatusOK, gin.H{"code": "SUCCESS", "message": "OK"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user