ZLW-PC\Administrator
7 years ago
11 changed files with 268 additions and 108 deletions
-
42app/Http/Controllers/Weixin/UserController.php
-
21app/Http/Controllers/Weixin/WxPayController.php
-
2app/Http/Model/User.php
-
87resources/org/wxpay/WxPayConfig.php
-
33resources/org/wxpay/WxPayPubHelper.class.php
-
0resources/org/wxpay/微信支付demo.html
-
22resources/views/weixin/index/index.blade.php
-
2resources/views/weixin/user/userRecharge.blade.php
-
71resources/views/weixin/user/userRechargeOrderDetail.blade.php
-
91resources/views/weixin/user/userRechargeTwo.blade.php
-
5routes/web.php
@ -0,0 +1,21 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Weixin; |
|||
|
|||
use App\Http\Controllers\Weixin\CommonController; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class WxPayController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
//微信支付回调
|
|||
public function wxpayNotify(Request $request) |
|||
{ |
|||
require_once(resource_path('org/wxpay/WxPayPubHelper.class.php')); |
|||
|
|||
return view('weixin.cart.index', $data); |
|||
} |
|||
} |
@ -0,0 +1,87 @@ |
|||
<?php |
|||
/** |
|||
* 微信支付配置账号信息 |
|||
*/ |
|||
|
|||
class WxPayConfig |
|||
{ |
|||
//=======【基本信息设置】=====================================
|
|||
//
|
|||
/** |
|||
* TODO: 修改这里配置为您自己申请的商户信息 |
|||
* 微信公众号信息配置 |
|||
* |
|||
* APPID:绑定支付的APPID(必须配置,开户邮件中可查看) |
|||
* |
|||
* MCHID:商户号(必须配置,开户邮件中可查看) |
|||
* |
|||
* KEY:商户支付密钥,参考开户邮件设置(必须配置,登录商户平台自行设置) |
|||
* 设置地址:https://pay.weixin.qq.com/index.php/account/api_cert |
|||
* |
|||
* APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置, 登录公众平台,进入开发者中心可设置), |
|||
* 获取地址:https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN |
|||
* @var string |
|||
*/ |
|||
const APPID = 'wx1c7946b5734199d0'; |
|||
const MCHID = '1331184301'; |
|||
const KEY = '93aa64d6552bf09401af7e7e6f9b3be7'; |
|||
const APPSECRET = '93aa64d6552bf09401af7e7e6f9b3be7'; |
|||
|
|||
//=======【证书路径设置】=====================================
|
|||
/** |
|||
* TODO:设置商户证书路径 |
|||
* 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要,可登录商户平台下载, |
|||
* API证书下载地址:https://pay.weixin.qq.com/index.php/account/api_cert,下载之前需要安装商户操作证书) |
|||
* @var path |
|||
*/ |
|||
const SSLCERT_PATH = '../cert/apiclient_cert.pem'; |
|||
const SSLKEY_PATH = '../cert/apiclient_key.pem'; |
|||
|
|||
//=======【curl代理设置】===================================
|
|||
/** |
|||
* TODO:这里设置代理机器,只有需要代理的时候才设置,不需要代理,请设置为0.0.0.0和0 |
|||
* 本例程通过curl使用HTTP POST方法,此处可修改代理服务器, |
|||
* 默认CURL_PROXY_HOST=0.0.0.0和CURL_PROXY_PORT=0,此时不开启代理(如有需要才设置) |
|||
* @var unknown_type |
|||
*/ |
|||
const CURL_PROXY_HOST = "0.0.0.0";//"10.152.18.220";
|
|||
const CURL_PROXY_PORT = 0;//8080;
|
|||
|
|||
//=======【上报信息配置】===================================
|
|||
/** |
|||
* TODO:接口调用上报等级,默认紧错误上报(注意:上报超时间为【1s】,上报无论成败【永不抛出异常】, |
|||
* 不会影响接口调用流程),开启上报之后,方便微信监控请求调用的质量,建议至少 |
|||
* 开启错误上报。 |
|||
* 上报等级,0.关闭上报; 1.仅错误出错上报; 2.全量上报 |
|||
* @var int |
|||
*/ |
|||
const REPORT_LEVENL = 1; |
|||
|
|||
public static function wxconfig() |
|||
{ |
|||
//=======【基本信息设置】=====================================
|
|||
//微信公众号身份的唯一标识。审核通过后,在微信发送的邮件中查看
|
|||
$wxconfig['APPID'] = self::APPID; |
|||
//受理商ID,身份标识
|
|||
$wxconfig['MCHID'] = self::MCHID; |
|||
//商户支付密钥Key。审核通过后,在微信发送的邮件中查看
|
|||
$wxconfig['KEY'] = self::KEY; |
|||
//JSAPI接口中获取openid,审核后在公众平台开启开发模式后可查看
|
|||
$wxconfig['APPSECRET'] = self::APPSECRET; |
|||
|
|||
//=======【证书路径设置】=====================================
|
|||
//证书路径,注意应该填写绝对路径
|
|||
$wxconfig['SSLCERT_PATH'] = self::SSLCERT_PATH; |
|||
$wxconfig['SSLKEY_PATH'] = self::SSLKEY_PATH; |
|||
|
|||
//=======【异步通知url设置】===================================
|
|||
//异步通知url,商户根据实际开发过程设定
|
|||
//$wxconfig['NOTIFY_URL'] = 'http://'.$_SERVER['HTTP_HOST'].U('Wxpay/notify_url'); //放在下单时,添加
|
|||
|
|||
//=======【curl超时设置】===================================
|
|||
//本例程通过curl使用HTTP POST方法,此处可修改其超时时间,默认为30秒
|
|||
$wxconfig['CURL_TIMEOUT'] = 30; |
|||
|
|||
return $wxconfig; |
|||
} |
|||
} |
@ -0,0 +1,71 @@ |
|||
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/> |
|||
<title>充值-支付</title><meta name="keywords" content="关键词"><meta name="description" content="描述"><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> |
|||
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet"> |
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script> |
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script> |
|||
<link href="<?php echo env('APP_URL'); ?>/css/font-awesome.min.css" type="text/css" rel="stylesheet"> |
|||
<script> |
|||
//调用微信JS api 支付
|
|||
function jsApiCall() |
|||
{ |
|||
WeixinJSBridge.invoke( |
|||
'getBrandWCPayRequest', |
|||
{$jsApiParameters}, |
|||
function(res){ |
|||
WeixinJSBridge.log(res.err_msg); |
|||
//alert(res.err_code+res.err_desc+res.err_msg);
|
|||
|
|||
if(res.err_msg=='get_brand_wcpay_request:ok') |
|||
{ |
|||
alert('支付成功!'); |
|||
} |
|||
else |
|||
{ |
|||
alert('支付失败!'); |
|||
} |
|||
|
|||
setTimeout("location.href = '{$returnUrl}'",2000); |
|||
} |
|||
); |
|||
} |
|||
|
|||
function callpay() |
|||
{ |
|||
if (typeof WeixinJSBridge == "undefined"){ |
|||
if( document.addEventListener ){ |
|||
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); |
|||
}else if (document.attachEvent){ |
|||
document.attachEvent('WeixinJSBridgeReady', jsApiCall); |
|||
document.attachEvent('onWeixinJSBridgeReady', jsApiCall); |
|||
} |
|||
}else{ |
|||
jsApiCall(); |
|||
} |
|||
} |
|||
</script> |
|||
</head><body onload="callpay();"> |
|||
|
|||
<div class="classreturn loginsignup"> |
|||
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div> |
|||
<div class="ds-in-bl tit center"><span>充值</span></div> |
|||
</div> |
|||
|
|||
<style> |
|||
.account{text-align:center;margin-top:30px;} |
|||
.account .icon{color:#FFCC00;font-size:100px;}
|
|||
.account .tit{color:#000;font-size:18px;}
|
|||
.bottoma{display:block;font-size:18px;padding:10px;border-radius:2px;} |
|||
</style> |
|||
<div class="floor account"> |
|||
<div class="icon"><i class="fa fa-google-wallet"></i></div> |
|||
<div style="margin:10px;text-align:left;"> |
|||
<p style="color:#7abd65;">订单已于 <b style="color:#fea700;"><?php echo $post['created_at']; ?></b> 提交成功,请您尽快付款!</p>
|
|||
订单号:<?php echo $post['id']; ?><br>
|
|||
应付金额:<strong style="color:#D03737;">¥<?php echo $post['money']; ?></strong> 元<br><br>
|
|||
|
|||
<p style="color:#999;font-size:.875em">请您在提交订单后30分钟内完成支付,否则订单会自动取消。</p> |
|||
</div> |
|||
<a style="margin:0 10px 10px 10px;background-color:#1aad19;text-align:center;color:#fff;border:1px solid #179e16;" class="bottoma" href="javascript:chongzhi();">去支付</a> |
|||
</div> |
|||
|
|||
</body></html> |
@ -1,91 +0,0 @@ |
|||
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/> |
|||
<title>充值-支付</title><meta name="keywords" content="关键词"><meta name="description" content="描述"><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> |
|||
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet"> |
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script> |
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script> |
|||
<link href="<?php echo env('APP_URL'); ?>/css/font-awesome.min.css" type="text/css" rel="stylesheet"></head><body> |
|||
<div class="classreturn loginsignup"> |
|||
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div> |
|||
<div class="ds-in-bl tit center"><span>充值</span></div> |
|||
</div> |
|||
|
|||
<style> |
|||
.account{text-align:center;margin-top:30px;} |
|||
.account .icon{color:#FFCC00;font-size:100px;}
|
|||
.account .tit{color:#000;font-size:18px;}
|
|||
.bottoma{display:block;font-size:18px;padding:10px;border-radius:2px;} |
|||
</style> |
|||
<div class="floor account"> |
|||
<div class="icon"><i class="fa fa-google-wallet"></i></div> |
|||
<div style="margin:10px;padding:10px;text-align:left;"> |
|||
订单已于 <span style="color:#390;"><?php echo $post['created_at']; ?></span> 提交成功,请您尽快付款!<br>
|
|||
订单号:<?php echo $post['id']; ?><br>
|
|||
应付金额:<span style="color:#ff5500;font-size:18px;">¥<?php echo $post['money']; ?></span> 元<br><br>
|
|||
|
|||
请您在提交订单后30分钟内完成支付,否则订单会自动取消。<br><br> |
|||
</div> |
|||
<a style="margin:0 10px 10px 10px;background-color:#1aad19;text-align:center;color:#fff;border:1px solid #179e16;" class="bottoma" href="javascript:chongzhi();">去支付</a> |
|||
</div> |
|||
|
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script> |
|||
<script> |
|||
function chongzhi() |
|||
{ |
|||
var money = $('#money').val(); |
|||
var re = /^[0-9]+$/; //判断字符串是否为数字
|
|||
|
|||
if(money == '') |
|||
{ |
|||
//提示
|
|||
layer.open({ |
|||
content: '请输入充值金额' |
|||
,skin: 'msg' |
|||
,time: 2 //2秒后自动关闭
|
|||
}); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
if(!re.test(money)) |
|||
{ |
|||
//提示
|
|||
layer.open({ |
|||
content: '金额格式不正确' |
|||
,skin: 'msg' |
|||
,time: 2 //2秒后自动关闭
|
|||
}); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//询问框
|
|||
layer.open({ |
|||
content: '确定要充值吗?' |
|||
,btn: ['确定', '取消'] |
|||
,yes: function(){ |
|||
var url = '<?php echo env('APP_API_URL')."/user_recharge_add"; ?>'; |
|||
var pay_type = $('#pay_type').val(); |
|||
|
|||
$.post(url,{access_token:'<?php echo $_SESSION['weixin_user_info']['access_token']; ?>',money:money,pay_type:pay_type},function(res) |
|||
{ |
|||
//提示
|
|||
layer.open({ |
|||
content: res.msg |
|||
,skin: 'msg' |
|||
,time: 2 //2秒后自动关闭
|
|||
}); |
|||
|
|||
if(res.code==0) |
|||
{ |
|||
location.href = '<?php echo substr(route('weixin_user_recharge_two',array('id'=>1)), 0, -1); ?>' + res.data; |
|||
} |
|||
else |
|||
{ |
|||
|
|||
} |
|||
},'json'); |
|||
} |
|||
}); |
|||
} |
|||
</script> |
|||
</body></html> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue