微信支付

掃碼支付(Native支付)適合場景:能夠事先生成二維碼(weixin://wxpay/bizpayurl?),不能有中間頁面跳轉。須要指定支付回調URL。javascript

公衆號支付適合場景:有商品展現頁面,或者須要先通過本身的頁面作下跳轉,須要先指定下支付受權目錄、測試受權目錄。例子:友寶自動售賣機。php

 

-----判斷是否是微信的瀏覽器-----css

https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_9html

以iPhone 版本爲例,能夠經過useragent可獲取以下微信版本示例信息:"Mozilla/5.0(iphone;CPU iphone OS 5_1_1 like Mac OS X)AppleWebKit/534.46(KHTML,like Geocko) Mobile/9B206MicroMessenger/5.0"其中5.0 爲用戶安裝的微信版本號java

view-source:https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxceb7190304ff89b0&redirect_uri=http%3a%2f%2forderapi.newcomevr.com%2fexample%2fproductPage.aspx&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirectandroid

<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;
var isAndroid = ua.indexOf('android') != -1;
var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
if (!isWeixin) {
document.head.innerHTML = '<title>抱歉,出錯了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/connect/zh_CN/htmledition/style/wap_err1a9853.css">';
document.body.innerHTML = '<div class="page_msg"><div class="inner"><span class="msg_icon_wrp"><i class="icon80_smile"></i></span><div class="msg_content"><h4>請在微信客戶端打開連接</h4></div></div></div>';
}
</script>api

相關文章
相關標籤/搜索