diff --git a/platformapi/wxpay/wxpay.go b/platformapi/wxpay/wxpay.go index afee6dd1..8529de4b 100644 --- a/platformapi/wxpay/wxpay.go +++ b/platformapi/wxpay/wxpay.go @@ -283,10 +283,12 @@ func (a *API) AccessAPI(action string, requestParam IRequestBase) (retVal map[st requestParam.SetMchID(a.mchID) requestParam.SetNonceStr(utils.GetUUID()) requestParam.SetSignType(sigType) - requestParam.SetSign(a.signParam(utils.Struct2FlatMap(requestParam))) + signStr := a.signParam(utils.Struct2FlatMap(requestParam)) + requestParam.SetSign(signStr) fullURL := utils.GenerateGetURL(prodURL, action, nil) + var responseStr string err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { request, _ := http.NewRequest(http.MethodPost, fullURL, bytes.NewReader(mustMarshalXML(requestParam))) @@ -294,6 +296,7 @@ func (a *API) AccessAPI(action string, requestParam IRequestBase) (retVal map[st }, a.config, func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) { + responseStr = bodyStr if jsonResult1 == nil { return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil") } @@ -303,6 +306,9 @@ func (a *API) AccessAPI(action string, requestParam IRequestBase) (retVal map[st if err == nil { if utils.Interface2String(retVal["result_code"]) != ResponseCodeSuccess { err = utils.NewErrorCode(utils.Interface2String(retVal["err_code_des"]), utils.Interface2String(retVal["err_code"])) + if err != nil { + baseapi.SugarLogger.Debugf("wxpay AccessAPI %s failed:%s, err:%v", signStr, strings.ReplaceAll(responseStr, "\\n", " "), err) + } retVal = nil } }