2024-02-05 21:16:49 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2024-02-05 22:57:17 +08:00
|
|
|
wxpay "github.com/go-pay/gopay/wechat/v3"
|
|
|
|
vasproto "service/api/proto/vas/proto"
|
|
|
|
"service/app/mix/service"
|
2024-02-05 21:16:49 +08:00
|
|
|
"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
|
|
|
|
}
|
2024-02-05 22:57:17 +08:00
|
|
|
if notify == nil {
|
|
|
|
logger.Error("ParseNotify nil, req: %v, err: %v", util.ToJson(notify), err)
|
|
|
|
return
|
|
|
|
}
|
2024-02-05 21:16:49 +08:00
|
|
|
logger.Info("WxpayCallback, notify: %v", util.ToJson(notify))
|
|
|
|
|
2024-02-05 22:57:17 +08:00
|
|
|
if notify.TradeState == wxpay.TradeStateSuccess {
|
|
|
|
service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{
|
|
|
|
OrderId: notify.OutTradeNo,
|
|
|
|
OutOrderId: notify.TransactionId,
|
|
|
|
CallbackPayType: vasproto.CallBackPayTypeWxpay,
|
|
|
|
})
|
|
|
|
}
|
2024-02-05 21:16:49 +08:00
|
|
|
ctx.String(200, "success")
|
|
|
|
}
|
2024-04-26 01:29:36 +08:00
|
|
|
|
|
|
|
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")
|
|
|
|
}
|