atitit.微信支付的教程文档 attilax总结
?
atitit.微信支付的教程文檔?attilax總結
?
1.?支付流程概覽 1
2.?設置支付起始目錄???host/app/paydir/ 1
3.?設置oauth驗證域名 1
4.?測試目錄?可以使用ip,但必須80端口好像。 1
5.?發起測試支付,菜單??host/fromother.jsp 2
6.?Start.jsp 2
7.?獲取openid的page接口,并制定回調接口 2
8.?開始支付頁面 3
9.?生成js調用支付接口 4
10.?注意事項 5
10.1.?預支付的簽名and提示mch不存在 5
?
?
1.?支付流程概覽
首先,生成一個prepayID
在,拿這個prepayid??使用js?調用支付的js?fun...
2.?設置支付起始目錄???host/app/paydir/
要有一個通過備案的域名+80端口,不能使用ip形式,也不能其他端口號(好像域名+端口號可以)
?
如果測試,可以使用測試目錄
?
作者::?老哇的爪子?Attilax?艾龍,??EMAIL:1466519819@qq.com
轉載請注明來源:?http://blog.csdn.net/attilax
?
?
3.?設置oauth驗證域名
實際上可以設置ip+端口
?
4.?測試目錄?可以使用ip,但必須80端口好像。
要手動添加測試白名單。。然后就可以測試了。。
?
?
?
5.?發起測試支付,菜單??host/fromother.jsp
6.?Start.jsp
String?call="http://www.baidu.com/xx.htm";
String?return_url="http://www.baidu.com/orderProcess?orderno=12346?2=val2";
String?url="http://host:port/wechat/pay.jsp?orderno="+filex.getUUidName()+"&fee=1&callback_url="+URLEncoder.encode(call,?"utf-8")+"&name="+URLEncoder.encode("測試商品",?"utf-8")+"&return_url="+URLEncoder.encode(return_url,?"utf-8");
?
??
?
?
%>?<meta?http-equiv="refresh"?content="0;URL=<%=url%>"?/>
<%=url%>
?
7.?獲取openid的page接口,并制定回調接口
??<%
??session.setAttribute("queryStr",request.getQueryString());
?
??String?url="http://host+port/wechat/getopenid.jsp?callbackurl=pay_stp2.jsp"?;//URLEncoder.encode(s,?enc);
??session.setAttribute("orderno",request.getParameter("orderno"));
????session.setAttribute("fee",request.getParameter("fee"));
??session.setAttribute("name",request.getParameter("name"));
????session.setAttribute("callback_url",request.getParameter("callback_url"));
?
??String?url2=?URLEncoder.encode(url,?"utf-8");
??%>
?pay:?
??<meta?http-equiv="refresh"?content="0;URL=https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx947702f1812d3249&redirect_uri=<%=url2%>&response_type=code&scope=snsapi_base&state=1#wechat_redirect"?/>
<%=url%>
?
注意,這個url的host+port必須在othau驗證配置那里設置到。
?
8.?開始支付頁面
?
????<%@page?import="com.attilax.net.urlUtil"%>
<%
WechatX?wechatC=?IocX.getBean(WechatX.class);
String?openid?=request.getParameter("openid");
//urlUtil.urlEncode
String?url="http://domain/wechat/pay_stp3.jsp?openid="+openid+"&"+(session.getAttribute("queryStr").toString());
//String?payurl=?URLEncoder.encode(url,?"utf-8")?;
%>
p2:
?<meta?http-equiv="refresh"?content="0;URL=<%=url%>"?/>
?<label?for="textarea"></label>
?<textarea?name="textarea"?id="textarea"?cols="45"?rows="5"><%=url%><aa></textarea>
?
?
注意這個支付的發起目錄必須在正式域名下配置的那個目錄才可
?
9.?生成js調用支付接口
??<%
WechatX4Pay?px?=?IocX.getBean(WechatX4Pay.class);
try{
????px.orderno=request.getParameter("orderno").toString();
?px.openid=request.getParameter("openid");
px.fee=request.getParameter("fee").toString();
px.title=request.getParameter("name").toString();
px.notify_url=request.getParameter("callback_url").toString();
px.Pay_geneJsapiParam(request);
}catch(Exception?e)
{
out.write(com.attilax.html.HtmlX.Htmlencode?(?com.attilax.util.god.getTrace(e)));
return;
}
?
%>
?
?
?
?<script>
??var?title=<%=px.title%>
??</script>
??<script>
?
function?onBridgeReady(){
???WeixinJSBridge.invoke(
???????'getBrandWCPayRequest',?{
???????????"appId"?:?"<%=px.appId%>",?????//公眾號名稱,由商戶傳入?????
???????????"timeStamp":"<%=px.timeStamp%>",?????????//時間戳,自1970年以來的秒數?????
???????????"nonceStr"?:?"<%=px.nonceStr%>",?//隨機串?????
???????????"package"?:?"<%=px.packageStr%>",?????
???????????"signType"?:?"MD5",?????????//微信簽名方式:?????
???????????"paySign"?:?"<%=px.paySign%>"?//微信簽名?
???????},
???????function(res){?????
???????????if(res.err_msg?==?"get_brand_wcpay_request:ok"?)?{
??var?ret="<%=?request.getParameter("return_url")%>";
??if(ret!="null")
???window.location=ret;
else
alert("支付成功");
???
???}?????//?使用以上方式判斷前端返回,微信團隊鄭重提示:res.err_msg將在用戶支付成功后返回????ok,但并不保證它絕對可靠。?
???????}
???);?
???//invoke?end
}
//?obr?end
//alert(?typeof?WeixinJSBridge?);
if?(typeof?WeixinJSBridge?==?"undefined"){
???if(?document.addEventListener?){
???????document.addEventListener('WeixinJSBridgeReady',?onBridgeReady,?false);
???}else?if?(document.attachEvent){
???????document.attachEvent('WeixinJSBridgeReady',?onBridgeReady);?
???????document.attachEvent('onWeixinJSBridgeReady',?onBridgeReady);
???}
}else{
???onBridgeReady();
}
??
?
?
</script>
?
?
10.?注意事項
10.1.?預支付的簽名and提示mch不存在
提示mch不存在,可能sign有誤,不個sign袖管改給掛,要是還是中個,走十sign?err
Mch?id?也許不是wechat?admin?console支持的內個...也許別的的...
要有個mch?id?跟個pay?key...這個paykey?要到個mch?console?設置...登錄mch?console要證書and手機驗證碼,麻煩的..
這個pay?key不是app?d?pwdkey..另一個的...
?
10.2.?'getBrandWCPayRequest'的簽名,
要包括?????"signType"?:?"MD5",???這個參數
?
Return_url?::::
?if(res.err_msg?==?"get_brand_wcpay_request:ok"?)?{
??var?ret="<%=?request.getParameter("return_url")%>";
??if(ret!="null")
???window.location=ret;
?
10.3.?用戶取消的處理::
?
返回網站主頁面
返回挑選服務框(like??cart),冉設置服務的數量等..
返回內個服務頁面
專門的一個cancel頁面(?不好使用)
?
10.4.?可用性設計:手動支付,再次支付按鈕要有
10.5.?測試方面的支持
Debug模式,可以使用在調用開頭的時候兒...
Stopstep::?可以指定stopstep
Show?html?code的支持...特別是支付林吧的時候兒.
?
?
?
?
?
?
?
?
?
轉載于:https://www.cnblogs.com/attilax/p/5963668.html
總結
以上是生活随笔為你收集整理的atitit.微信支付的教程文档 attilax总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DM8168 新三板系统启动
- 下一篇: TCP/UDP网络性能测试工具 - Ne