123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8"/>
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <title>微信支付</title>
- </head>
- <body>
- @if(!$success)
- <div style="color: red;text-align: center;margin-top: 20px;">
- {{$msg}}
- </div>
- @else
- <script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
- <script type="text/javascript" charset="utf-8">
- wx.config({!! $configStr !!});
- wx.ready(function () {
- wx.chooseWXPay({
- timestamp: {{$prepayConfig['timestamp']}},
- nonceStr: '{{$prepayConfig['nonceStr']}}',
- package: '{{$prepayConfig['package']}}',
- signType: '{{$prepayConfig['signType']}}',
- paySign: '{{$prepayConfig['paySign']}}', // 支付签名
- success: res => {
- // 支付成功
- if (res.errMsg === "chooseWXPay:ok") {
- // 使用以上方式判断前端返回,微信团队郑重提示:
- //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
- // that.payCheckSuccess(); // 支付成功回调
- WeixinJSBridge.call('closeWindow');
- } else if (res.errMsg === "chooseWXPay:cancel") {
- console.log('支付已取消!')
- WeixinJSBridge.call('closeWindow');
- } else {
- console.log('其他错误')
- }
- },
- fail: res => {
- console.log(JSON.stringify(res));
- alert(JSON.stringify(res))
- }
- });
- });
- wx.error(res => {
- console.log(JSON.stringify(res));
- alert(JSON.stringify(res))
- });
- </script>
- @endif
- </body>
- </html>
|