package controller import ( "github.com/gin-gonic/gin" wxpay "github.com/go-pay/gopay/wechat/v3" vasproto "service/api/proto/vas/proto" "service/app/mix/service" "service/bizcommon/util" "service/library/logger" "service/library/payclients/wxpaycli" ) func WxpayCallback(ctx *gin.Context) { notify, err := wxpaycli.GetDefaultWxpayClient().ParseNotify(ctx.Request) if err != nil { logger.Error("ParseNotify fail, req: %v, err: %v", util.ToJson(notify), err) return } if notify == nil { logger.Error("ParseNotify nil, req: %v, err: %v", util.ToJson(notify), err) return } logger.Info("WxpayCallback, notify: %v", util.ToJson(notify)) if notify.TradeState == wxpay.TradeStateSuccess { service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{ OrderId: notify.OutTradeNo, OutOrderId: notify.TransactionId, CallbackPayType: vasproto.CallBackPayTypeWxpay, }) } ctx.String(200, "success") } func WxpayCallbackManual(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.WxpayCallbackManualParam) service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{ OrderId: req.OrderId, OutOrderId: req.OutOrderId, CallbackPayType: vasproto.CallBackPayTypeWxpay, }) ctx.String(200, "success") }