service/app/mix/controller/yeepay_callback.go

35 lines
979 B
Go

package controller
import (
"github.com/gin-gonic/gin"
vasproto "service/api/proto/vas/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"service/library/payclients/yeepaycli"
)
func YeepayCallback(ctx *gin.Context) {
notify, err := yeepaycli.GetDefaultYeepayClient().ParseNotify(ctx.Request)
if err != nil {
logger.Error("ParseNotify fail, req: %v, err: %v", util.ToJson(notify), err)
return
}
logger.Info("YeepayCallback, notify: %v", util.ToJson(notify))
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,
CallbackPayType: vasproto.CallBackPayTypeYeepay,
})
if err != nil {
logger.Error("YeepayCallback fail, notify: %v, err: %v", util.ToJson(notify), err)
return
}
ctx.String(200, "SUCCESS")
}