首先需要檢視文件 知道h5支付的步驟
1.前台頁面
h5充值
2.後台介面直接呼叫統一下單
if(stringutils.isnotblank(ver_str))
string passback = order.containskey("passback") ? order.get("passback") : "";
string moneystr = order.get("money");
float money = float.parsefloat(moneystr);
if(stringutils.isblank(sn)) throw new serviceexception("建立臨時訂單失敗!");
mapresdata = null;
resdata = wxapiservice.unifiedorder_h5(openid, sn, money, order.get("goods"), passback, ip, callback);
r= new jsonresult("0", "", resdata);
} catch(serviceexception se) catch (exception e)
return responseentity.ok(r);
}logger.info("接收到的報文:" + notityxml);
sortedmapres = wxcommonutil.doxmlparse(notityxml);
//校驗是否接收成功
if(res != null && !res.isempty() && "success".equals(res.get("result_code")))elseelse
} catch (serviceexception se) catch (exception e)
return responseentity.ok(resxml);}}
3.涉及到的工具類
public class wxcommonutil
/** * 解析接收到的xml報文
* @param strxml
* @return sortedmap
* @throws jdomexception
* @throws ioexception
*/public static sortedmapdoxmlparse(string strxml) throws jdomexception, ioexception
sortedmap m = new treemap();
inputstream in = new bytearrayinputstream(strxml.getbytes("utf-8"));
saxbuilder builder = new saxbuilder();
document doc = builder.build(in);
element root = doc.getrootelement();
list list = root.getchildren();
iterator it = list.iterator();
while(it.hasnext()) else
m.put(k, v);
} //關閉流
in.close();
return m;
} string key= "";
if(parameters.containskey("key") && stringutils.isnotblank(parameters.get("key")))else
public static string verifydata(mapdata,string args) throws unsupportedencodingexception
if("sign".equals(arg))
if("ts".equals(arg))
}}else
}//引數都已明確並需要簽名驗證
if(stringutils.hastext(sign) && !stringutils.hastext(msg))
}"utf-8"));
string v_sign = md5util***.ge***5str(urlencoder.encode(arg_cnt+key,"utf-8").tolowercase());
if(!sign.tolowercase().equals(v_sign.tolowercase()))
}return msg;
}private static map transtomap(map parametermap) throws unsupportedencodingexceptionelse if(valueobj instanceof string)
value = value.substring(0, value.length()-1);
}else
system.out.println(value);
returnmap.put(name, value);
}return returnmap;
}}
微信H5支付概述
接下下是平台設定,設定授權網域名稱,在介面設定中就能找到,包括js介面安全網域名稱和網頁授權網域名稱 這個點進去之後會看到最下面兩個 js介面安全網域名稱,這個可以設定三個,就是填寫你訪問頁面的網域名稱即可 設定的網域名稱要備案 然後設定支付網域名稱,設定路徑 商戶平台 產品中心 開發配置中設定網域...
PHP微信H5支付
headers array headers connection keep alive headers accept language ru ru,ru q 0.8,en us q 0.5,en q 0.3 headers accept encoding gzip,deflate headers u...
微信H5支付demo
5.3 掃一掃支付,public wxf8affffgggggg public 7dddddddddddd8 商戶號 public static string partner 134356241 商戶api秘鑰 public static string partnerkey mmghfjhgdjgf...