ecshop增加pc扫描二维码微信支付功能代码

 时间:2024-10-14 23:32:38

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="images/image.png" />';生成一个指向微信支付的手机连接二维码,手机扫描进入

ecshop增加pc扫描二维码微信支付功能代码

2、打开申请到的微信支付代码,在上面加入weixin.phpdefine('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);获取订单信息

ecshop增加pc扫描二维码微信支付功能代码

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>

ecshop增加pc扫描二维码微信支付功能代码

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;} ?>根据申请的信息填写

ecshop增加pc扫描二维码微信支付功能代码

5、找到notify_url.php文件上面添加define('IN_ECS', true);require('../includes/init.php');require('../includes/lib_payment.php');调用订单信息

ecshop增加pc扫描二维码微信支付功能代码

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); } //商户自行增加处理流程, //例如:更新订单状态 //例如:数据库操作 //例如:推送支付完成信息 }

ecshop增加pc扫描二维码微信支付功能代码

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

  • 奥特AT3051DP智能差压变送器说明书
  • 如何召开高品质的会议
  • LONGTEC TR700-LF失重称控制模块使用说明书:[4]
  • 丹纳赫S200伺服驱动器说明书:[1]
  • 海鲜虾粥的做法
  • 热门搜索
    呵护心灵手抄报内容 感恩亲情手抄报 历史手抄报图片大全 关于小动物的手抄报 消防安全手抄报知识 禁燃烟花爆竹手抄报 保护动物手抄报资料 交通的手抄报 汉字手抄报五年级 手抄报的装饰花边简单