From 79684af1cdcefb0fc558a4ffff6a8ac20e2fd969 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 5 Dec 2019 12:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=E8=BE=93=E5=87=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/wxpay/wxpay.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 } }