调整AccessPlatformAPIWithRetry中的调试输出信息
+wxpayapi.CloseOrder
This commit is contained in:
@@ -37,6 +37,16 @@ type CallbackResponse struct {
|
||||
type BaseResultMsg struct {
|
||||
ReturnCode string `json:"return_code" xml:"return_code"`
|
||||
ReturnMsg string `json:"return_msg" xml:"return_msg"`
|
||||
|
||||
AppID string `json:"appid" xml:"appid"`
|
||||
DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"`
|
||||
MchID string `json:"mch_id" xml:"mch_id"`
|
||||
NonceStr string `json:"nonce_str" xml:"nonce_str"`
|
||||
Sign string `json:"sign" xml:"sign"`
|
||||
ResultCode string `json:"result_code" xml:"result_code"`
|
||||
ResultMsg string `json:"result_msg" xml:"result_msg"`
|
||||
ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"`
|
||||
ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"`
|
||||
}
|
||||
|
||||
type PayResultMsg struct {
|
||||
@@ -49,6 +59,7 @@ type PayResultMsg struct {
|
||||
NonceStr string `json:"nonce_str" xml:"nonce_str"`
|
||||
Sign string `json:"sign" xml:"sign"`
|
||||
ResultCode string `json:"result_code" xml:"result_code"`
|
||||
ResultMsg string `json:"result_msg" xml:"result_msg"`
|
||||
ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"`
|
||||
ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"`
|
||||
|
||||
@@ -90,6 +101,7 @@ type RefundResultMsg struct {
|
||||
NonceStr string `json:"nonce_str" xml:"nonce_str"`
|
||||
Sign string `json:"sign" xml:"sign"`
|
||||
ResultCode string `json:"result_code" xml:"result_code"`
|
||||
ResultMsg string `json:"result_msg" xml:"result_msg"`
|
||||
ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"`
|
||||
ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"`
|
||||
|
||||
@@ -147,49 +159,47 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
|
||||
}
|
||||
|
||||
func (a *API) getCallbackMsg(msgBody string) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
|
||||
mapData, _, err := a.checkResultAsMap(msgBody)
|
||||
mapData, _, err := a.parseXmlStrAsMap(msgBody)
|
||||
if err != nil {
|
||||
return nil, Err2CallbackResponse(err, "")
|
||||
}
|
||||
returnCode := utils.Interface2String(mapData["return_code"])
|
||||
if returnCode != ResponseCodeSuccess { // 如果return_code出错,直接返回
|
||||
return nil, SuccessResponse
|
||||
}
|
||||
|
||||
reqInfo := utils.Interface2String(mapData["req_info"])
|
||||
transactionID := utils.Interface2String(mapData["transaction_id"])
|
||||
if reqInfo == "" && transactionID != "" { // 对于支付结果通知进行签名验证(退款结果通知不支持验证)
|
||||
sign := utils.Interface2String(mapData[sigKey])
|
||||
desiredSign := a.signParam(mapData)
|
||||
if desiredSign != sign {
|
||||
return nil, Err2CallbackResponse(fmt.Errorf("desiredSign:%s <> sign:%s", desiredSign, sign), "")
|
||||
}
|
||||
}
|
||||
|
||||
msg = &CallbackMsg{
|
||||
MapData: mapData,
|
||||
}
|
||||
returnCode := utils.Interface2String(mapData["return_code"])
|
||||
if returnCode != ResponseCodeSuccess {
|
||||
msg.Data = &BaseResultMsg{
|
||||
ReturnCode: returnCode,
|
||||
ReturnMsg: utils.Interface2String(mapData["return_msg"]),
|
||||
}
|
||||
} else {
|
||||
reqInfo := utils.Interface2String(mapData["req_info"])
|
||||
if reqInfo == "" {
|
||||
sign := utils.Interface2String(mapData[sigKey])
|
||||
desiredSign := a.signParam(mapData)
|
||||
if desiredSign != sign {
|
||||
return nil, Err2CallbackResponse(fmt.Errorf("desiredSign:%s <> sign:%s", desiredSign, sign), "")
|
||||
}
|
||||
}
|
||||
if reqInfo != "" {
|
||||
msg.MsgType = MsgTypeRefund
|
||||
var refundResult *RefundResultMsg
|
||||
if err = utils.Map2StructByJson(mapData, &refundResult, false); err == nil {
|
||||
if reqInfo, err = a.decodeReqInfo(reqInfo); err == nil {
|
||||
mv, err2 := mxj.NewMapXml([]byte(reqInfo))
|
||||
if err = err2; err == nil {
|
||||
reqInfoMap := mv["root"].(map[string]interface{})
|
||||
if err = utils.Map2StructByJson(reqInfoMap, &refundResult.ReqInfoObj, false); err == nil {
|
||||
msg.Data = refundResult
|
||||
}
|
||||
if reqInfo != "" {
|
||||
msg.MsgType = MsgTypeRefund
|
||||
var refundResult *RefundResultMsg
|
||||
if err = utils.Map2StructByJson(mapData, &refundResult, false); err == nil {
|
||||
if reqInfo, err = a.decodeReqInfo(reqInfo); err == nil {
|
||||
mv, err2 := mxj.NewMapXml([]byte(reqInfo))
|
||||
if err = err2; err == nil {
|
||||
reqInfoMap := mv["root"].(map[string]interface{})
|
||||
if err = utils.Map2StructByJson(reqInfoMap, &refundResult.ReqInfoObj, false); err == nil {
|
||||
msg.Data = refundResult
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if transactionID := utils.Interface2String(mapData["transaction_id"]); transactionID != "" {
|
||||
msg.MsgType = MsgTypePay
|
||||
var payResult *PayResultMsg
|
||||
if err = utils.Map2StructByJson(mapData, &payResult, false); err == nil {
|
||||
msg.Data = payResult
|
||||
}
|
||||
}
|
||||
} else if transactionID != "" {
|
||||
msg.MsgType = MsgTypePay
|
||||
var payResult *PayResultMsg
|
||||
if err = utils.Map2StructByJson(mapData, &payResult, false); err == nil {
|
||||
msg.Data = payResult
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user