mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-02 03:48:47 +08:00
支付优化
This commit is contained in:
parent
bcae35db5b
commit
8b744beae0
@ -272,5 +272,19 @@ class Order extends Common
|
||||
return ApiService::ApiDataReturn(OrderService::OrderDelete($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付状态校验
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-01-08
|
||||
* @desc description
|
||||
*/
|
||||
public function PayCheck()
|
||||
{
|
||||
$params = $this->data_post;
|
||||
$params['user'] = $this->user;
|
||||
return ApiService::ApiDataReturn(OrderService::OrderPayCheck($params));
|
||||
}
|
||||
}
|
||||
?>
|
@ -271,7 +271,7 @@ class OrderService
|
||||
'call_back_url' => $call_back_url,
|
||||
'redirect_url' => $redirect_url,
|
||||
'site_name' => MyC('home_site_name', 'ShopXO', true),
|
||||
'ajax_url' => MyUrl('index/order/paycheck'),
|
||||
'check_url' => MyUrl('index/order/paycheck'),
|
||||
];
|
||||
|
||||
// 发起支付处理钩子
|
||||
|
@ -145,7 +145,6 @@ class Alipay
|
||||
// app,头条小程序
|
||||
case 'ios' :
|
||||
case 'android' :
|
||||
case 'toutiao' :
|
||||
$ret = $this->PayApp($params);
|
||||
break;
|
||||
|
||||
@ -246,17 +245,19 @@ class Alipay
|
||||
$parameter['sign'] = $this->MyRsaSign($this->GetSignContent($parameter));
|
||||
|
||||
// 接口则直接返回
|
||||
$html = $this->BuildRequestForm($parameter);
|
||||
if(APPLICATION == 'app')
|
||||
{
|
||||
$result = [
|
||||
'data' => $parameter,
|
||||
'html' => $html,
|
||||
'url' => 'https://openapi.alipay.com/gateway.do?charset=utf-8',
|
||||
];
|
||||
return DataReturn('success', 0, $result);
|
||||
}
|
||||
|
||||
|
||||
// web端输出执行form表单post提交
|
||||
exit($this->BuildRequestForm($parameter));
|
||||
exit($html);
|
||||
}
|
||||
|
||||
|
||||
@ -293,9 +294,21 @@ class Alipay
|
||||
|
||||
// 生成签名参数+签名
|
||||
$parameter['sign'] = $this->MyRsaSign($this->GetSignContent($parameter));
|
||||
|
||||
// 输出执行form表单post提交
|
||||
exit($this->BuildRequestForm($parameter));
|
||||
|
||||
// 接口则直接返回
|
||||
$html = $this->BuildRequestForm($parameter);
|
||||
if(APPLICATION == 'app')
|
||||
{
|
||||
$result = [
|
||||
'data' => $parameter,
|
||||
'html' => $html,
|
||||
'url' => 'https://openapi.alipay.com/gateway.do?charset=utf-8',
|
||||
];
|
||||
return DataReturn('success', 0, $result);
|
||||
}
|
||||
|
||||
// web端输出执行form表单post提交
|
||||
exit($html);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -504,9 +517,7 @@ class Alipay
|
||||
|
||||
//submit按钮控件请不要含有name属性
|
||||
$html .= "<input type='submit' value='ok' style='display:none;'></form>";
|
||||
|
||||
$html .= "<script>document.forms['alipaysubmit'].submit();</script>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class AlipayFace
|
||||
'name' => '支付宝', // 插件名称
|
||||
'version' => '1.0.0', // 插件版本
|
||||
'apply_version' => '不限', // 适用系统版本描述
|
||||
'apply_terminal'=> ['pc', 'h5'], // 适用终端 默认全部 ['pc', 'h5', 'app', 'alipay', 'weixin', 'baidu']
|
||||
'apply_terminal'=> ['pc', 'h5', 'weixin'], // 适用终端 默认全部 ['pc', 'h5', 'app', 'alipay', 'weixin', 'baidu']
|
||||
'desc' => '支付宝当面付、适用web端,用户主动扫码支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述(支持html)
|
||||
'author' => 'Devil', // 开发者
|
||||
'author_url' => 'http://shopxo.net/', // 开发者主页
|
||||
@ -171,19 +171,31 @@ class AlipayFace
|
||||
// 状态
|
||||
if(isset($result[$key]['code']) && $result[$key]['code'] == 10000 && !empty($result[$key]['qr_code']))
|
||||
{
|
||||
if(empty($params['ajax_url']))
|
||||
if(empty($params['check_url']))
|
||||
{
|
||||
return DataReturn('支付状态校验地址不能为空', -50);
|
||||
}
|
||||
$pay_params = [
|
||||
'url' => urlencode(base64_encode($result[$key]['qr_code'])),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => urlencode('支付宝支付'),
|
||||
'msg' => urlencode('打开支付宝APP扫一扫进行支付'),
|
||||
'ajax_url' => urlencode(base64_encode($params['ajax_url'])),
|
||||
];
|
||||
$url = MyUrl('index/pay/qrcode', $pay_params);
|
||||
return DataReturn('success', 0, $url);
|
||||
if(APPLICATION == 'app')
|
||||
{
|
||||
$data = [
|
||||
'pay_url' => $result[$key]['qr_code'],
|
||||
'qrcode_url' => MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode($result[$key]['qr_code']))]),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => '支付宝支付',
|
||||
'msg' => '打开支付宝APP扫一扫进行支付',
|
||||
'check_url' => $params['check_url'],
|
||||
];
|
||||
} else {
|
||||
$pay_params = [
|
||||
'url' => urlencode(base64_encode($result[$key]['qr_code'])),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => urlencode('支付宝支付'),
|
||||
'msg' => urlencode('打开支付宝APP扫一扫进行支付'),
|
||||
'check_url' => urlencode(base64_encode($params['check_url'])),
|
||||
];
|
||||
$data = MyUrl('index/pay/qrcode', $pay_params);
|
||||
}
|
||||
return DataReturn('success', 0, $data);
|
||||
}
|
||||
|
||||
// 直接返回支付信息
|
||||
|
@ -227,23 +227,35 @@ class QQ
|
||||
// 手机模式下直接返回微信的支付url地址,打开支付(缺点是支付后会直接关闭站点)
|
||||
// QQ支付本身没有提供H5支付方案,这种方式也可以直接支付(缺点是支付后不能回调到原来浏览器)
|
||||
// 公众号后续再采用公众号的方式支付,体验会更好一些,只是可以不关闭站点
|
||||
if(ApplicationClientType() == 'h5')
|
||||
if(APPLICATION == 'web' && IsMobile())
|
||||
{
|
||||
$result = DataReturn('success', 0, $data['code_url']);
|
||||
} else {
|
||||
if(empty($params['ajax_url']))
|
||||
if(empty($params['check_url']))
|
||||
{
|
||||
return DataReturn('支付状态校验地址不能为空', -50);
|
||||
}
|
||||
$pay_params = [
|
||||
'url' => urlencode(base64_encode($data['code_url'])),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => urlencode('QQ支付'),
|
||||
'msg' => urlencode('打开QQAPP扫一扫进行支付'),
|
||||
'ajax_url' => urlencode(base64_encode($params['ajax_url'])),
|
||||
];
|
||||
$url = MyUrl('index/pay/qrcode', $pay_params);
|
||||
$result = DataReturn('success', 0, $url);
|
||||
if(APPLICATION == 'app')
|
||||
{
|
||||
$data = [
|
||||
'pay_url' => $data['code_url'],
|
||||
'qrcode_url' => MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode($data['code_url']))]),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => 'QQ支付',
|
||||
'msg' => '打开QQAPP扫一扫进行支付',
|
||||
'check_url' => $params['check_url'],
|
||||
];
|
||||
} else {
|
||||
$pay_params = [
|
||||
'url' => urlencode(base64_encode($data['code_url'])),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => urlencode('QQ支付'),
|
||||
'msg' => urlencode('打开QQAPP扫一扫进行支付'),
|
||||
'check_url' => urlencode(base64_encode($params['check_url'])),
|
||||
];
|
||||
$data = MyUrl('index/pay/qrcode', $pay_params);
|
||||
}
|
||||
$result = DataReturn('success', 0, $data);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -249,19 +249,30 @@ class Weixin
|
||||
{
|
||||
// web支付
|
||||
case 'NATIVE' :
|
||||
if(empty($params['ajax_url']))
|
||||
if(empty($params['check_url']))
|
||||
{
|
||||
return DataReturn('支付状态校验地址不能为空', -50);
|
||||
}
|
||||
$pay_params = [
|
||||
'url' => urlencode(base64_encode($data['code_url'])),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => urlencode('微信支付'),
|
||||
'msg' => urlencode('打开微信APP扫一扫进行支付'),
|
||||
'ajax_url' => urlencode(base64_encode($params['ajax_url'])),
|
||||
];
|
||||
$url = MyUrl('index/pay/qrcode', $pay_params);
|
||||
$result = DataReturn('success', 0, $url);
|
||||
if(APPLICATION == 'app')
|
||||
{
|
||||
$data = [
|
||||
'qrcode_url' => MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode($data['code_url']))]),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => '微信支付',
|
||||
'msg' => '打开微信APP扫一扫进行支付',
|
||||
'check_url' => $params['check_url'],
|
||||
];
|
||||
} else {
|
||||
$pay_params = [
|
||||
'url' => urlencode(base64_encode($data['code_url'])),
|
||||
'order_no' => $params['order_no'],
|
||||
'name' => urlencode('微信支付'),
|
||||
'msg' => urlencode('打开微信APP扫一扫进行支付'),
|
||||
'check_url' => urlencode(base64_encode($params['check_url'])),
|
||||
];
|
||||
$data = MyUrl('index/pay/qrcode', $pay_params);
|
||||
}
|
||||
$result = DataReturn('success', 0, $data);
|
||||
break;
|
||||
|
||||
// h5支付
|
||||
@ -277,19 +288,20 @@ class Weixin
|
||||
|
||||
// 微信中/小程序支付
|
||||
case 'JSAPI' :
|
||||
$pay_data = array(
|
||||
$pay_data = [
|
||||
'appId' => $pay_params['appid'],
|
||||
'package' => 'prepay_id='.$data['prepay_id'],
|
||||
'nonceStr' => md5(time().rand()),
|
||||
'signType' => $pay_params['sign_type'],
|
||||
'timeStamp' => (string) time(),
|
||||
);
|
||||
];
|
||||
$pay_data['paySign'] = $this->GetSign($pay_data);
|
||||
|
||||
// 微信中
|
||||
if(APPLICATION == 'web' && IsWeixinEnv())
|
||||
{
|
||||
$this->PayHtml($pay_data, $redirect_url);
|
||||
$html = $this->PayHtml($pay_data, $redirect_url);
|
||||
die($pay_data['html']);
|
||||
} else {
|
||||
$result = DataReturn('success', 0, $pay_data);
|
||||
}
|
||||
@ -324,10 +336,16 @@ class Weixin
|
||||
private function PayHtml($pay_data, $redirect_url)
|
||||
{
|
||||
// 支付代码
|
||||
exit('<html>
|
||||
return '<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
<title>微信安全支付</title>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1">
|
||||
<body style="text-align:center;padding-top:10%;">
|
||||
<p style="color:#999;">正在支付中...</p>
|
||||
<p style="color:#f00;margin-top:20px;">请不要关闭页面!</p>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function onBridgeReady()
|
||||
{
|
||||
@ -359,9 +377,8 @@ class Weixin
|
||||
onBridgeReady();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</html>');
|
||||
</head>
|
||||
</html>';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -490,10 +507,12 @@ class Weixin
|
||||
'android' => 'APP',
|
||||
];
|
||||
|
||||
// 微信中打开
|
||||
if($client_type == 'h5' && IsWeixinEnv())
|
||||
// h5
|
||||
if($client_type == 'h5')
|
||||
{
|
||||
$type_all['h5'] = $type_all['weixin'];
|
||||
// 微信中打开
|
||||
// h5则使用NATIVE二维码的方式
|
||||
$type_all['h5'] = IsWeixinEnv() ? $type_all['weixin'] : $type_all['pc'];
|
||||
}
|
||||
|
||||
return isset($type_all[$client_type]) ? $type_all[$client_type] : '';
|
||||
|
Loading…
Reference in New Issue
Block a user