update
This commit is contained in:
@@ -66,9 +66,21 @@ class Wechat
|
|||||||
* @Date : 2022/9/9 11:32
|
* @Date : 2022/9/9 11:32
|
||||||
* @Author : <Jason.C>
|
* @Author : <Jason.C>
|
||||||
*/
|
*/
|
||||||
public function payment()
|
public function payment(): string
|
||||||
{
|
{
|
||||||
return View::fetch();
|
$config = Config::get('wechat.payment');
|
||||||
|
$payment = Factory::payment($config);
|
||||||
|
$unify = $payment->order->unify([
|
||||||
|
'body' => '商品订单',
|
||||||
|
'out_trade_no' => time(),
|
||||||
|
'total_fee' => 100,
|
||||||
|
'notify_url' => '',
|
||||||
|
'trade_type' => 'JSAPI',
|
||||||
|
'openid' => '$openid',
|
||||||
|
]);
|
||||||
|
$prepayId = $unify->prepay_id;
|
||||||
|
$jssdk = $payment->jssdk->bridgeConfig($prepayId);
|
||||||
|
return View::fetch('', ['jssdk' => $jssdk]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,10 +1,82 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="utf-8">
|
||||||
<title>Title</title>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>微信支付</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.background {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
filter: blur(1px);
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>支付页面</h1>
|
<div class="background" style="background-image: url('/static/field-gf7775feec_640.jpg')">
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" src="/layer/layer.js"></script>
|
||||||
|
<script>
|
||||||
|
function onBridgeReady() {
|
||||||
|
if (typeof WeixinJSBridge === 'undefined') {
|
||||||
|
alert('请在微信在打开页面!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WeixinJSBridge.invoke(
|
||||||
|
'getBrandWCPayRequest',
|
||||||
|
{$jssdk},
|
||||||
|
function (res) {
|
||||||
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||||||
|
setTimeout(function () {
|
||||||
|
layer.open({
|
||||||
|
content: '支付成功'
|
||||||
|
, shadeClose: false
|
||||||
|
, btn: ['3秒后自动返回']
|
||||||
|
, time: 3
|
||||||
|
, end: function () {
|
||||||
|
window.history.back()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
content: '支付过程出现问题'
|
||||||
|
, shadeClose: false
|
||||||
|
, btn: ['3秒后自动返回']
|
||||||
|
, time: 3
|
||||||
|
, end: function () {
|
||||||
|
window.history.back()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -7,7 +7,8 @@ return [
|
|||||||
'app_id' => 'wx3793a03c18984e4f', // AppID
|
'app_id' => 'wx3793a03c18984e4f', // AppID
|
||||||
'secret' => 'f1c242f4f28f735d4687abb469072xxx', // AppSecret
|
'secret' => 'f1c242f4f28f735d4687abb469072xxx', // AppSecret
|
||||||
'token' => 'iQoSaqys8cQawIusDZn6H5LPYTMIOWVg', // Token
|
'token' => 'iQoSaqys8cQawIusDZn6H5LPYTMIOWVg', // Token
|
||||||
'aes_key' => 'fmkgnwli1JaabwxlcZdkI6bZ2lwxiVGnxg5o0mSHsuB', // EncodingAESKey,兼容与安全模式下请一定要填写!!!
|
'aes_key' => 'fmkgnwli1JaabwxlcZdkI6bZ2lwxiVGnxg5o0mSHsuB',
|
||||||
|
// EncodingAESKey,兼容与安全模式下请一定要填写!!!
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
|
* 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
|
||||||
@@ -65,4 +66,15 @@ return [
|
|||||||
'scopes' => ['snsapi_userinfo'],
|
'scopes' => ['snsapi_userinfo'],
|
||||||
'callback' => '/wechat/callback',
|
'callback' => '/wechat/callback',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'payment' => [
|
||||||
|
// 必要配置
|
||||||
|
'app_id' => 'wx3793a03c18984e4f',
|
||||||
|
'mch_id' => '1620663318',
|
||||||
|
'key' => 'iQoSaqys8cQawIusDZn6H5LPYTMIOWVg', // API v2 密钥 (注意: 是v2密钥 是v2密钥 是v2密钥)
|
||||||
|
// 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
|
||||||
|
'cert_path' => 'path/to/your/cert.pem', // XXX: 绝对路径!!!!
|
||||||
|
'key_path' => 'path/to/your/key', // XXX: 绝对路径!!!!
|
||||||
|
'notify_url' => '默认的订单回调地址', // 你也可以在下单时单独设置来想覆盖它
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user