service/app/mix/controller/alipay_callback.go

28 lines
727 B
Go
Raw Permalink 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) {
2024-07-04 11:39:10 +08:00
bm, err := alipaycli.ParseNotify(ctx.Request)
2023-12-29 14:16:37 +08:00
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-05-27 19:23:05 +08:00
_ = service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{
2024-02-05 21:16:49 +08:00
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")
}