service/app/mix/controller/alipay_callback.go

30 lines
833 B
Go
Raw Normal View History

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" {
2024-02-05 21:16:49 +08:00
service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{
OrderId: bm.GetString("out_trade_no"),
OutOrderId: bm.GetString("trade_no"),
CallbackPayType: vasproto.CallBackPayTypeAlipay,
2024-01-08 21:24:45 +08:00
})
}
2023-12-29 14:16:37 +08:00
ctx.String(200, "success")
}