service/app/mix/controller/yeepay_callback.go

35 lines
979 B
Go
Raw Normal View History

2024-05-27 16:48:16 +08:00
package controller
import (
"github.com/gin-gonic/gin"
2024-05-27 19:23:05 +08:00
vasproto "service/api/proto/vas/proto"
"service/app/mix/service"
2024-05-27 16:48:16 +08:00
"service/bizcommon/util"
"service/library/logger"
"service/library/payclients/yeepaycli"
)
func YeepayCallback(ctx *gin.Context) {
2024-05-27 19:23:05 +08:00
notify, err := yeepaycli.GetDefaultYeepayClient().ParseNotify(ctx.Request)
2024-05-27 16:48:16 +08:00
if err != nil {
2024-05-27 19:23:05 +08:00
logger.Error("ParseNotify fail, req: %v, err: %v", util.ToJson(notify), err)
2024-05-27 16:48:16 +08:00
return
}
2024-05-27 19:23:05 +08:00
logger.Info("YeepayCallback, notify: %v", util.ToJson(notify))
2024-05-27 16:48:16 +08:00
2024-05-27 19:23:05 +08:00
if notify.Status != "SUCCESS" {
logger.Error("YeepayCallback invalid, notify: %v", util.ToJson(notify))
return
}
err = service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{
OrderId: notify.OrderId,
OutOrderId: notify.UniqueOrderNo,
2024-05-27 19:37:52 +08:00
CallbackPayType: vasproto.CallBackPayTypeYeepay,
2024-05-27 19:23:05 +08:00
})
if err != nil {
logger.Error("YeepayCallback fail, notify: %v, err: %v", util.ToJson(notify), err)
return
}
ctx.String(200, "SUCCESS")
2024-05-27 16:48:16 +08:00
}