收藏
回答

微信支付return_code为success,result为fail,求大神

请求的参数:<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xml>
<nonce_str>2710faff4b21493888b07d6f16941c94</nonce_str>
<out_trade_no>1016</out_trade_no>
<openid>oY5O15Ca4PaBNDcuLpZD0BCir_aA</openid>
<appid>wxf4c34ff8a5ed2ce2</appid>
<total_fee>1</total_fee>
<sign>F378D404A8ED52A5E6D9B6835A0C8A6C</sign>
<trade_type>JSAPI</trade_type>
<mch_id>1537295961</mch_id>
<body>舞蹈用品支付</body>
https://www.baidu.com
<spbill_create_ip>39.107.77.243</spbill_create_ip>
</xml>

----------微信返回结果-------:<xml><return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[OK]]></return_msg>
<appid><![CDATA[wxf4c34ff8a5ed2ce2]]></appid>
<mch_id><![CDATA[1537295961]]></mch_id>
<nonce_str><![CDATA[rztyuKs6TlWPVGa2]]></nonce_str>
<sign><![CDATA[296C5AF41F62151A424335E2FBBF4492]]></sign>
<result_code><![CDATA[FAIL]]></result_code>
<err_code><![CDATA[PARAM_ERROR]]></err_code>
<err_code_des><![CDATA[appidåopenidä¸å¹é]]></err_code_des>
</xml>

我特别奇怪的是既然return_code都success了,后面还给我来了个result_code  fail  ,err_code_des还乱码,搞了两天了,一直不知道问题所在,求大神解答,下面是我的后台代码:

//统一下单接口参数
HashMap<String, String> param = new HashMap<String, String>();
param.put("appid", appid);
param.put("mch_id", partner);
param.put("nonce_str", nonce_str);
param.put("body", body);
//商户订单号
String out_trade_no= order.getOrderNo();
param.put("out_trade_no",out_trade_no);
param.put("total_fee", String.valueOf(total_fee));
param.put("spbill_create_ip", spbill_create_ip);
String notify_url = "https://www.baidu.com";//支付回調地址,把订单状态修改为已支付
param.put("notify_url", notify_url);
param.put("trade_type","JSAPI");
param.put("openid", openid);

String url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
HttpClient client = new HttpClient();
client.getParams().setSoTimeout(300*1000);
PostMethod myPost = new PostMethod(url);
try{
String xmlParam = WXPayUtil.generateSignedXml(param, partnerkey);
   System.out.println("请求的参数:"+xmlParam);
   myPost.setRequestEntity(new StringRequestEntity(xmlParam,"text/xml","utf-8"));
   int status = client.executeMethod(myPost);
   if (status ==200){
String xmlResult = myPost.getResponseBodyAsString();
       System.out.println("----------微信返回结果-------:"+xmlResult);


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容