2023-12-29 14:16:37 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
vasproto "service/api/proto/vas/proto"
|
|
|
|
"service/app/mix/service"
|
2023-12-29 17:40:33 +08:00
|
|
|
"service/bizcommon/util"
|
2023-12-29 14:16:37 +08:00
|
|
|
"service/library/logger"
|
|
|
|
"service/library/payclients/alipaycli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func AlipayCallback(ctx *gin.Context) {
|
2023-12-29 17:40:33 +08:00
|
|
|
//req, _ := ctx.GetRawData()
|
|
|
|
//logger.Info("_AlipayCallback req: %v", string(req))
|
2023-12-29 14:16:37 +08:00
|
|
|
bm, err := alipaycli.GetDefaultAlipayClient().ParseNotify(ctx.Request)
|
|
|
|
if err != nil {
|
2023-12-29 17:40:33 +08:00
|
|
|
logger.Error("ParseNotify fail, req: %v, err: %v", util.ToJson(bm), err)
|
2023-12-29 14:16:37 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-08 21:24:45 +08:00
|
|
|
if bm.GetString("trade_status") == "TRADE_SUCCESS" {
|
|
|
|
service.DefaultService.AlipayCallback(ctx, &vasproto.AlipayCallbackParamIn{
|
|
|
|
OrderId: bm.GetString("out_trade_no"),
|
|
|
|
AlipayOrderId: bm.GetString("trade_no"),
|
|
|
|
})
|
|
|
|
}
|
2023-12-29 14:16:37 +08:00
|
|
|
ctx.String(200, "success")
|
|
|
|
}
|