weixin_pay.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
  4. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  5. <title>微信支付</title>
  6. <script type="text/javascript">
  7. //调用微信JS api 支付
  8. function jsApiCall()
  9. {
  10. WeixinJSBridge.invoke(
  11. 'getBrandWCPayRequest',
  12. <?php echo $jsApiParameters; ?>,
  13. function(res){
  14. /* WeixinJSBridge.log(res.err_msg);
  15. alert(res.err_code+res.err_desc+res.err_msg);*/
  16. if(res.err_msg == "get_brand_wcpay_request:ok" ) {
  17. window.location.href = "<?=str_replace(array('&#61;','&amp;'),array('=','&'),urldecode($return_url));?>";
  18. }
  19. }
  20. );
  21. }
  22. function callpay()
  23. {
  24. if (typeof WeixinJSBridge == "undefined"){
  25. if( document.addEventListener ){
  26. document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
  27. }else if (document.attachEvent){
  28. document.attachEvent('WeixinJSBridgeReady', jsApiCall);
  29. document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
  30. }
  31. }else{
  32. jsApiCall();
  33. }
  34. }
  35. </script>
  36. </head>
  37. <body>
  38. <center hidden>
  39. <h1 class="title">微信支付</h1>
  40. <div class="info">
  41. <p class="price">¥<?php echo $order->total_price;?></p>
  42. <p class="order">
  43. <span>交易单号:<strong style="color:#ff5400;"><?php echo $order->order_sn;?></strong></span>
  44. <br>
  45. <span>创建时间:<strong><?php echo date("Y-m-d H:i:s",$order->create_time);?></strong></span>
  46. </p>
  47. </div>
  48. <button style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer; color:white; font-size:16px;" type="button" onclick="callpay()" >立即支付</button>
  49. </center>
  50. <script>
  51. callpay();
  52. </script>
  53. </body>
  54. </html>