mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-07 10:22:38 +08:00
wx pay
This commit is contained in:
@ -23,6 +23,31 @@ use app\plugins\weixinwebauthorization\service\Service;
|
||||
*/
|
||||
class Auth extends Controller
|
||||
{
|
||||
/**
|
||||
* 支付提示
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-05-25T20:15:23+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function PayTips($params = [])
|
||||
{
|
||||
// 自定义链接
|
||||
$this->assign('to_url', MyUrl('index/order/index'));
|
||||
$this->assign('to_title', '我的订单');
|
||||
|
||||
// 状态
|
||||
if(isset($params['status']) && $params['status'] == 0)
|
||||
{
|
||||
$this->assign('msg', '支付成功');
|
||||
return $this->fetch('public/pay_success');
|
||||
} else {
|
||||
$this->assign('msg', $ret['msg']);
|
||||
return $this->fetch('public/pay_error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付授权
|
||||
* @author Devil
|
||||
|
||||
@ -84,6 +84,12 @@ class OrderService
|
||||
return DataReturn('支付方式有误', -1);
|
||||
}
|
||||
|
||||
// 更新订单支付方式
|
||||
if(!empty($params['payment_id']) && $params['payment_id'] != $order['payment_id'])
|
||||
{
|
||||
Db::name('Order')->where(['id'=>$order['id']])->update(['payment_id'=>$payment_id, 'upd_time'=>time()]);
|
||||
}
|
||||
|
||||
// 支付入口文件检查
|
||||
$pay_checked = PaymentService::EntranceFileChecked($payment[0]['payment'], 'order');
|
||||
if($pay_checked['code'] != 0)
|
||||
|
||||
@ -252,6 +252,9 @@ class Weixin
|
||||
*/
|
||||
private function PayHtml($pay_data, $redirect_url)
|
||||
{
|
||||
$success_url = urlencode(PluginsHomeUrl('weixinwebauthorization', 'auth', 'paytips', ['status'=>0]));
|
||||
$error_url = urlencode(PluginsHomeUrl('weixinwebauthorization', 'auth', 'paytips', ['status'=>-1]));
|
||||
|
||||
exit('<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
@ -260,28 +263,23 @@ class Weixin
|
||||
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("支付参数有误");
|
||||
}
|
||||
});
|
||||
\'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" )
|
||||
{
|
||||
window.location.href = "'.$success_url.'";
|
||||
} else {
|
||||
window.location.href = "'.$error_url.'";
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
if(typeof WeixinJSBridge == "undefined")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user