提交 8bcf1841 编写于 作者: G gongfuxiang

wx pay

上级 ce264145
......@@ -210,55 +210,7 @@ class Weixin
// 微信中
if(!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false)
{
$html = '<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>微信安全支付</title>
<script type="text/javascript">
function onBridgeReady()
{
WeixinJSBridge.invoke(
\'getBrandWCPayRequest\', {
"appId":"'.$pay_data['appId'].'",
"timeStamp":"'.$pay_data['timeStamp'].'",
"nonceStr":"'.$pay_data['nonceStr'].'",
"package":"'.$pay_data['package'].'",
"signType":"'.$pay_data['signType'].'",
"paySign":"'.$pay_data['paySign'].'"
},
function(res) {
if(res.err_msg == "get_brand_wcpay_request:ok" )
{
Prompt(result.msg, "success");
} else if(res.err_msg == "get_brand_wcpay_request:cancel")
{
Prompt("用户取消");
} else if(res.err_msg == "get_brand_wcpay_request:fail")
{
Prompt("支付失败");
} else {
Prompt("支付参数有误");
}
});
}
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>
</head>
<body>
</html>';
exit($html);
$this->PayHtml($pay_data, $redirect_url);
} else {
$result = DataReturn('success', 0, $pay_data);
}
......@@ -272,6 +224,67 @@ class Weixin
return $result;
}
/**
* 支付代码
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-25T00:07:52+0800
* @param [array] $pay_data [支付信息]
* @param [string] $redirect_url [成功后的url]
*/
private function PayHtml($pay_data, $redirect_url)
{
exit('<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>微信安全支付</title>
<script type="text/javascript">
function onBridgeReady()
{
WeixinJSBridge.invoke(
\'getBrandWCPayRequest\', {
"appId":"'.$pay_data['appId'].'",
"timeStamp":"'.$pay_data['timeStamp'].'",
"nonceStr":"'.$pay_data['nonceStr'].'",
"package":"'.$pay_data['package'].'",
"signType":"'.$pay_data['signType'].'",
"paySign":"'.$pay_data['paySign'].'"
},
function(res) {
if(res.err_msg == "get_brand_wcpay_request:ok" )
{
Prompt("支付成功", "success");
} else if(res.err_msg == "get_brand_wcpay_request:cancel")
{
Prompt("用户取消");
} else if(res.err_msg == "get_brand_wcpay_request:fail")
{
Prompt("支付失败");
} else {
Prompt("支付参数有误");
}
});
}
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>
</head>
<body>
</html>');
}
/**
* 获取支付参数
* @author Devil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册