86 lines
2.5 KiB
Go
86 lines
2.5 KiB
Go
package handler
|
||
|
||
import (
|
||
"fmt"
|
||
"net/http"
|
||
|
||
"github.com/gin-gonic/gin"
|
||
)
|
||
|
||
// PaymentAlipayNotify POST /api/payment/alipay/notify
|
||
func PaymentAlipayNotify(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentCallback POST /api/payment/callback
|
||
func PaymentCallback(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentCreateOrder POST /api/payment/create-order
|
||
func PaymentCreateOrder(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentMethods GET /api/payment/methods
|
||
func PaymentMethods(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true, "data": []interface{}{}})
|
||
}
|
||
|
||
// PaymentQuery GET /api/payment/query
|
||
func PaymentQuery(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentStatusOrderSn GET /api/payment/status/:orderSn
|
||
func PaymentStatusOrderSn(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentVerify POST /api/payment/verify
|
||
func PaymentVerify(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentWechatNotify POST /api/payment/wechat/notify
|
||
func PaymentWechatNotify(c *gin.Context) {
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// PaymentWechatTransferNotify POST /api/payment/wechat/transfer/notify
|
||
func PaymentWechatTransferNotify(c *gin.Context) {
|
||
// 微信转账回调处理
|
||
// 注意:实际生产环境需要验证签名,这里简化处理
|
||
|
||
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"})
|
||
}
|