<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>微信支付</title>
</head>
<body>
<div style="text-align:center;size:30px;">
<input type="button" style="200px;height:80px;" value="微信支付" onclick="callpay()">
</div>
</body>
</html>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script type="text/javascript">
function callpay() {
WeixinJSBridge.invoke('getBrandWCPayRequest', {
"appId": "wxecf3ae97bc826a07", //公众号ID,由商户传入
"timeStamp": "1617265039648", //时间戳
"nonceStr": "wxecf3ae97bc826a07", //随机串
"package": "prepay_id=wx20210401160153404751",
"signType": "MD5", //微信签名方式:
"paySign": "7909D7FAC59AADE971B3D7757C7EB457" //微信签名
},
function(res) {
WeixinJSBridge.log(res.err_msg);
if (res.err_msg == "get_brand_wcpay_request:ok") {
alert("微信支付成功!");
} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
alert("用户取消支付!");
} else {
alert("支付失败!");
}
})
}
</script>
————————————————
版权声明:本文为CSDN博主「我有一个蓝朋友」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qdm13209211861/article/details/116084844