ecshop开发网站,如果没有手机版,又想通过微信支付,可以加入pc二维码扫描微信支付功能

工具/原料

  • ecshop商城系统,phpqrcode,WxPayPubHelper
  • 公众号已申请微信支付

方法/步骤

  1.  

    使用PHP QR Code生成二维码,下载,在商品支付页面加入

    include 'phpqrcode/phpqrcode.php';

    $pay_url ='http://www.xxx.com/weixin/weixin.php?order_id='.$order['order_sn'];

    QRcode::png($pay_url, 'images/image.png', 'L', 8);

    echo '<img src="data:images/image.png" />';

    生成一个指向微信支付的手机连接二维码,手机扫描进入

  2.  

    打开申请到的微信支付代码,在上面加入weixin.php

    define('IN_ECS', true);

    require('../includes/init.php');

    require('../includes/lib_order.php');

    $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0;

    $order = order_info(0,$order_id);

    获取订单信息

  3.  

    手机打开页面调用代码

    <html>

    <head>

    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>

    <title>微信安全支付</title>

    <script type="text/javascript">

    //调用微信JS api 支付

    function jsApiCall()

    {

    WeixinJSBridge.invoke(

    'getBrandWCPayRequest',

    <?php echo $jsApiParameters; ?>,

    function(res){

    WeixinJSBridge.log(res.err_msg);

    //alert(res.err_code+res.err_desc+res.err_msg);

    }

    );

    }

    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();

    }

    }

    callpay();

    </script>

    </head>

    <body>

    </br></br></br></br>

    </body>

    </html>

  4.  

    代码引用WxPayPubHelper,

    WxPay.pub.config.php

    配置文件

    class WxPayConf_pub

    {

    //=======【基本信息设置】=====================================

    //微信公众号身份的唯一标识。审核通过后,在微信发送的邮件中查看

    const APPID = 'xxx';

    //受理商ID,身份标识

    const MCHID = 'xxx';

    //商户支付密钥Key。审核通过后,在微信发送的邮件中查看

    const KEY = 'xxx';

    //JSAPI接口中获取openid,审核后在公众平台开启开发模式后可查看

    const APPSECRET = 'xxx';

    //=======【JSAPI路径设置】===================================

    //获取access_token过程中的跳转uri,通过跳转将code传入jsapi支付页面

    const JS_API_CALL_URL = 'http://www.xxx.com/weixin/js_api_call.php';

    //=======【证书路径设置】=====================================

    //证书路径,注意应该填写绝对路径

    const SSLCERT_PATH = '/weixin/WxPayPubHelper/cacert/apiclient_cert.pem';

    const SSLKEY_PATH = '/weixin/WxPayPubHelper/cacert/apiclient_key.pem';

    //=======【异步通知url设置】===================================

    //异步通知url,商户根据实际开发过程设定

    const NOTIFY_URL = 'http://www.xxx.com/weixin/notify_url.php';

    //=======【curl超时设置】===================================

    //本例程通过curl使用HTTP POST方法,此处可修改其超时时间,默认为30秒

    const CURL_TIMEOUT = 30;

    }

    ?>

    根据申请的信息填写

  5.  

    找到notify_url.php文件

    上面添加

    define('IN_ECS', true);

    require('../includes/init.php');

    require('../includes/lib_payment.php');

    调用订单信息

  6.  

    notify_url.php添加支付后修改订单状态

    if($notify->checkSign() == TRUE)

    {

    if ($notify->data["return_code"] == "FAIL") {

    //此处应该更新一下订单状态,商户自行增删操作

    //$log_->log_result($log_name,"【通信出错】:\n".$xml."\n");

    }

    elseif($notify->data["result_code"] == "FAIL"){

    //此处应该更新一下订单状态,商户自行增删操作

    //$log_->log_result($log_name,"【业务出错】:\n".$xml."\n");

    }

    else{

    //此处应该更新一下订单状态,商户自行增删操作

    //$log_->log_result($log_name,"【支付成功】:\n".$xml."\n");

    $order = $notify->getData();

    $log_id=get_order_id_by_sn($order["out_trade_no"]);

    order_paid($log_id);

    }

    //商户自行增加处理流程,

    //例如:更新订单状态

    //例如:数据库操作

    //例如:推送支付完成信息

    }

  7. 7

    更多安全信息和详细信息就不列举了

最新文章

  1. JS操作Json
  2. block和代理小结
  3. Fiddler 手机端证书安装No root certificate was found
  4. 360路由器刷openwrt、不死uboot、双系统 、wifi中继
  5. foreach DataTable或Table时要略过第一行。
  6. paper 87:行人检测资源(下)代码数据【转载,以后使用】
  7. java 构造函数
  8. webbench
  9. What version of .NET Framework is integrated into what version of OS?
  10. @CacheEvict(value = { &quot;&quot; })
  11. 用PS绿化版出现“请卸载并重新安装该产品”的解决方法
  12. JS效果的步骤
  13. 使用CMake生成解决方案后构建INSTALL报错
  14. sqli-labs(十五)(堆叠注入)
  15. MySQL5.7.25解压版安装详细教程
  16. 非递归和递归分别实现求第n个斐波那契数。
  17. DELL MD3200i存储控制器解锁方法
  18. 【面试题】Java EE面试题
  19. MVC中Controller与View之间的数据传递
  20. PHP求并集,交集,差集

热门文章

  1. ios webView 默认有缓存
  2. CSS浮动与清浮动
  3. C# web api 返回类型设置为json的两种方法
  4. Python:使用psycopg2模块操作PostgreSQL
  5. 怎么查找执行比较慢的sql语句-DBA给的建议
  6. MJRefresh简单处理
  7. WAL
  8. Lintcode: Flip Bits
  9. Leetcode: Number of Islands II &amp;&amp; Summary of Union Find
  10. JS语法部分-数组