<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet"/>
<script type="text/javascript" charset="utf-8">
mui.init();
var channel = null;
var channels = null;
// 1. 获取支付通道
function plusReady() {
// 获取支付通道
plus.payment.getChannels(function(cs) {
channels = cs;
},
function(e) {
alert("获取支付通道失败:" + e.message);
});
}
document.addEventListener('plusready', plusReady, false);
// var ALIPAYSERVER = 'http://demo.dcloud.net.cn/helloh5/payment/alipay.php?total=';
//var WXPAYSERVER = 'http://www.m.rfvip.cn:20677/WX/index?payid=wxpay&appid=wx84f0ceea370f1748&total=1';
// var WXPAYSERVER = 'http://www.m.rfvip.cn:20677';
//var WXPAYSERVER='http://demo.dcloud.net.cn/helloh5/payment/wxpay.php?total=1';
// 2. 发起支付请求
function pay(id) {
for (var i in channels)
{
if (channels[i].id == id)
{
channel = channels[i];
}
}
// var varpay = {
// appid: "wx0411fa6a39d61297",//
// noncestr: "9AkU7zoEckVt9I8Z",//随意字符串
// package: "Sign=WXPay",//调用包
// partnerid: "1230636401",//商户ID
// prepayid: "wx05112714955769c027b7a14b1981808800",//订单ID
// timestamp: "1562297234",//时间戳
// sign: "75967CB53A2E23D420B9722BBE666080"//签名
// }
var varpay = {
appid: "*****",//
noncestr: "tSC7MZWeUcg3lDbn",//随意字符串
package: "Sign=WXPay",//调用包
partnerid: "*****",//商户ID
prepayid: "wx05135935000398f304f8cfcc1783723100",//订单ID
timestamp: "1562306375",//时间戳
sign: "BD23EB2BD9D768C01F4544B417BB0DA5"//签名
}
// console.log("appid==>"+varpay.appid);
// console.log("noncestr==>"+varpay.noncestr);
// console.log("package==>"+varpay.package);
// console.log("partnerid==>"+varpay.partnerid);
// console.log("prepayid==>"+varpay.prepayid);
// console.log("timestamp==>"+varpay.timestamp);
// console.log("sign==>"+varpay.sign);
plus.payment.request(channel, varpay, function(result) {
plus.nativeUI.alert("支付成功!", function() {
back();
});
}, function(e) {
plus.nativeUI.alert("支付失败:" + e.code + "支付失败:" + e.message);
console.log(e.code);
console.log(e.message);
});
/* xhr.open('GET',PAYSERVER);
xhr.send();*/
}
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">支付测试123456</h1>
</header>
<div class="mui-content">
<input type="button" class="btn btn-lg" id="pay" value="微信支付" onclick="pay('wxpay')" />
</div>
</body>
</html>
备注:注意APPID 必须为APP应用ID