public function payNotifyUrl() { $xml = $this->getXmlArray(); $wxPayHelper = new WxPayHelper(); //获得openid $openid = $xml['openid']; //$order = $_GET; //获取订单信息 //获取shop_id $shop_id = $_GET['shop_id']; //第三方商户订单号 $out_trade_no = $_GET['out_trade_no']; //订单号 $trade_no = $_GET['transaction_id']; //订单状态 0为成功 $trade_status = $_GET['trade_state']; //订单总金额,单位为分 $total_fee = $_GET['total_fee']; $notify_id = $_GET['notify_id']; $appsignature = $_GET['appsignature']; //验证是否是从微信服务器返回的 $is_weixin = $this->verifyNotify($_GET, $_GET['sign']); if ($is_weixin) { //实例化model $main = D('main'); //商城订单状态处理 //第三方订单号格式: 来源+订单ID+客户ID+用户ID; $order = explode('_', $out_trade_no); $source = $order[0]; $order_id = $order[1]; $custom_id = $order[2]; $user_id = $order[3]; //判断通知是否已经处理过,处理过直接返回success //是否支付成功 if ($trade_status == '0') { //获取access_token $access_token = $wxPayHelper->access_token(); //订单修改为已支付的状态 $order_data = array('id' => $order_id, 'u_id' => $user_id, 'data' => array('status' => 6)); $main->edit_order_status($order_data); //****************添加交易记录 组合参数************* //查询用户名和电话 $user_info = M(C('DB_WECHAT_NAME') . '.wxh_member_baseinfo')->where('is_del = 0 and id = ' . $user_id)->field('name, phone')->find(); //查询订单提交时间 $add_time = M(C('DB_WECHAT_NAME') . '.wxh_order')->where('is_del = 0 and id = ' . $order_id . ' and user_id = ' . $user_id)->getField('add_time'); $param_zero = array('user_id' => $user_id, 'order_id' => $order_id, 'source' => $source, 'source_id' => $shop_id, 'custom_id' => $custom_id, 'name' => $user_info['name'], 'tel' => $user_info['phone'], 'order_price' => round($total_fee / 100, 2), 'order_time' => $add_time, 'pay_method' => 2, 'pay_time' => time(), 'pay_status' => $trade_status, 'pay_number' => $trade_no, 'notify_id' => $notify_id); //添加交易记录 先验证验证是否已经添加 $is_record = $main->verify_record($order_id); if ($is_record) { $main->add_record($param_zero); } $wxPayHelper = new WxPayHelper($custom_id); //发货,调用发货接口 $res = $wxPayHelper->delivernotify($openid, $trade_no, $out_trade_no); //if($res["errmsg"]=='ok'){ //返回发货通知消息,ok为发货成功 ///记录到日志中 //} //业务处理完后以字符串形式返回微信系统结果 echo 'success'; //不要更改或删除 } else { //失败,微信系统通过补单机制再次通知 echo 'fail'; //不要更改或删除 } } else { echo "不是微信回调"; } //记录日志 $fp = fopen('api.txt', 'w+'); fwrite($fp, "\n_______delivernotify_______"); fwrite($fp, var_export($res, true)); fwrite($fp, "\n _______GET________"); fwrite($fp, var_export($_GET, true)); fwrite($fp, "\n ________postObj________"); fwrite($fp, var_export($xml, true)); fwrite($fp, 'NowTime: ' . date("Y-m-d H:i:s") . "\n"); fclose($fp); }
public function pay() { import('@.ORG.Weixinpay.CommonUtil'); import('@.ORG.Weixinpay.WxPayHelper'); $commonUtil = new CommonUtil(); $orderid = $_GET['single_orderid']; $payHandel = new payHandle($this->token, $_GET['from'], 'weixin'); $orderInfo = $payHandel->beforePay($orderid); $price = $orderInfo['price']; if ($orderInfo['paid']) { exit('您已经支付过此次订单!'); } $wxPayHelper = new WxPayHelper($this->payConfig['appid'], $this->payConfig['paysignkey'], $this->payConfig['partnerkey']); $wxPayHelper->setParameter('bank_type', 'WX'); $wxPayHelper->setParameter('body', $orderid); $wxPayHelper->setParameter('partner', $this->payConfig['partnerid']); $wxPayHelper->setParameter('out_trade_no', $orderid); $wxPayHelper->setParameter('total_fee', $price * 100); $wxPayHelper->setParameter('fee_type', '1'); $wxPayHelper->setParameter('notify_url', $this->siteUrl . '/index.php?g=Wap&m=Weixin&nohandle=1&a=return_url&token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&from=' . $_GET['from']); $wxPayHelper->setParameter('spbill_create_ip', $_SERVER['REMOTE_ADDR']); $wxPayHelper->setParameter('input_charset', 'GBK'); $url = $wxPayHelper->create_biz_package(); $this->assign('url', $url); $from = $_GET['from']; $from = $from ? $from : 'Groupon'; $from = $from != 'groupon' ? $from : 'Groupon'; switch ($from) { default: case 'Groupon': break; } $returnUrl = $this->siteUrl . '/index.php?g=Wap&m=' . $from . '&a=payReturn&nohandle=1&token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&orderid=' . $orderid; $this->assign('returnUrl', $returnUrl); echo '<html><head><meta http-equiv="Content-Type"content="text/html; charset=UTF-8"><meta name="viewport"content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;"><meta name="apple-mobile-web-app-capable"content="yes"><meta name="apple-mobile-web-app-status-bar-style"content="black"><meta name="format-detection"content="telephone=no"><link href="/tpl/Wap/default/common/css/style/css/hotels.css"rel="stylesheet"type="text/css"><title>微信支付</title></head><script language="javascript">function callpay(){WeixinJSBridge.invoke(\'getBrandWCPayRequest\',' . $url . ',function(res){WeixinJSBridge.log(res.err_msg);if(res.err_msg==\'get_brand_wcpay_request:ok\'){document.getElementById(\'payDom\').style.display=\'none\';document.getElementById(\'successDom\').style.display=\'\';setTimeout("window.location.href = \'' . $returnUrl . '\'",2000);}else{document.getElementById(\'payDom\').style.display=\'none\';document.getElementById(\'failDom\').style.display=\'\';document.getElementById(\'failRt\').innerHTML=res.err_code+\'|\'+res.err_desc+\'|\'+res.err_msg;}});}</script><body style="padding-top:20px;"><style>.deploy_ctype_tip{z-index:1001;width:100%;text-align:center;position:fixed;top:50%;margin-top:-23px;left:0;}.deploy_ctype_tip p{display:inline-block;padding:13px 24px;border:solid#d6d482 1px;background:#f5f4c5;font-size:16px;color:#8f772f;line-height:18px;border-radius:3px;}</style><div id="payDom"class="cardexplain"><ul class="round"><li class="title mb"><span class="none">支付信息</span></li><li class="nob"><table width="100%"border="0"cellspacing="0"cellpadding="0"class="kuang"><tr><th>金额</th><td>' . $price . '元</td></tr></table></li></ul><div class="footReturn"style="text-align:center"><input type="button"style="margin:0 auto 20px auto;width:100%"onclick="callpay()"class="submit"value="点击进行微信支付"/></div></div><div id="failDom"style="display:none"class="cardexplain"><ul class="round"><li class="title mb"><span class="none">支付结果</span></li><li class="nob"><table width="100%"border="0"cellspacing="0"cellpadding="0"class="kuang"><tr><th>支付失败</th><td><div id="failRt"></div></td></tr></table></li></ul><div class="footReturn"style="text-align:center"><input type="button"style="margin:0 auto 20px auto;width:100%"onclick="callpay()"class="submit"value="重新进行支付"/></div></div><div id="successDom"style="display:none"class="cardexplain"><ul class="round"><li class="title mb"><span class="none">支付成功</span></li><li class="nob"><table width="100%"border="0"cellspacing="0"cellpadding="0"class="kuang"><tr><th>您已支付成功,页面正在跳转...</th></tr></table><div id="failRt"></div></td></tr></table></li></ul></div></body></html>'; }
<?php include_once "WxPayHelper.php"; $commonUtil = new CommonUtil(); $wxPayHelper = new WxPayHelper(); $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", "test"); $wxPayHelper->setParameter("partner", "1900000109"); $wxPayHelper->setParameter("out_trade_no", $commonUtil->create_noncestr()); $wxPayHelper->setParameter("total_fee", "1"); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", "htttp://www.baidu.com"); $wxPayHelper->setParameter("spbill_create_ip", "127.0.0.1"); $wxPayHelper->setParameter("input_charset", "GBK"); echo $wxPayHelper->create_app_package("test"); echo "<br>"; echo $wxPayHelper->create_biz_package(); echo "<br>"; echo $wxPayHelper->create_native_package();
<?php include_once "WxPayHelper.php"; $wxPayHelper = new WxPayHelper(); echo $wxPayHelper->create_native_url("1234");
function fahuo($memberId, $payType, $orderId) { $this->load->database(); $rw = $this->db->query("select * from `wx_order` where id=" . $orderId)->row(); //判断是否微信支付 if ($rw->order_pay_qd == 'wxPay') { $wxinfo = json_decode($rw->wxinfo, true); $wxPayHelper = new WxPayHelper($memberId, $payType); $result = $wxPayHelper->delivernotify($wxinfo['openid'], $wxinfo['trade_no'], $orderId); //记录日志 $path = dirname(STATICPATH) . "/application/logs/fahuo/" . date("Ym"); if (!is_dir($path)) { mkdir($path, 0777); } $msg = array("orderId" => $orderId, "jg" => $result); $filename = $path . "/" . date("d") . ".txt"; $fp = fopen($filename, 'a+'); fwrite($fp, json_encode($msg)); fclose($fp); } }
<?php include_once "WxPayHelper.php"; $commonUtil = new CommonUtil(); $wxPayHelper = new WxPayHelper(); $user_ip = $_SERVER["REMOTE_ADDR"]; $notify_failed_url = "http://www.inink.cn/mobile/index.php"; $notify_url = "http://www.inink.cn/mobile/user.php"; $out_trade_no = $commonUtil->create_noncestr(); $wx_goods_name = ''; $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", $wx_goods_name); $wxPayHelper->setParameter("partner", "1218290401"); $wxPayHelper->setParameter("out_trade_no", $out_trade_no); $wxPayHelper->setParameter("total_fee", "1"); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", $notify_url); $wxPayHelper->setParameter("spbill_create_ip", $user_ip); $wxPayHelper->setParameter("input_charset", "UTF-8"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <head> <meta name="Generator" content="ECSHOP v2.7.3" /> <META content="IE=7.0000" http-equiv="X-UA-Compatible"> <TITLE>微信支付测试</TITLE> <META content="text/html; charset=utf-8" http-equiv=Content-Type> <META name=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <META name=apple-themes-web-app-capable content=yes>
$oid = intval($post['productid']); $order = $db->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = {$oid}"); //if($order['pay_status'] == 2) exit('is payed'); if ($order['order_amount'] > 0) { $payment = payment_info($order['pay_id']); include_once '../includes/modules/payment/' . $payment['pay_code'] . '.php'; $pay_obj = new $payment['pay_code'](); $payment = unserialize_config($payment['pay_config']); if ($post['appid'] == $payment['appId']) { define(APPID, $payment['appId']); define(APPKEY, $payment['paySignKey']); define(SIGNTYPE, "sha1"); define(PARTNERKEY, $payment['partnerKey']); define(APPSERCERT, $payment['appSecret']); include_once "../includes/modules/payment/weixin/WxPayHelper.php"; $wxPayHelper = new WxPayHelper(); $url = return_url('weixin'); $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", $order['order_sn']); $wxPayHelper->setParameter("partner", $payment['partnerId']); $wxPayHelper->setParameter("out_trade_no", $order['order_id']); $wxPayHelper->setParameter("total_fee", $order['order_amount'] * 100); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", $url); $wxPayHelper->setParameter("spbill_create_ip", real_ip()); $wxPayHelper->setParameter("input_charset", "GBK"); echo $wxPayHelper->create_native_package(); } } else { echo 1; }
public function pay() { import("@.ORG.Weixinpay.CommonUtil"); import("@.ORG.Weixinpay.WxPayHelper"); $commonUtil = new CommonUtil(); //var_export($this->payConfig); //exit(); $wxPayHelper = new WxPayHelper($this->payConfig['appid'], $this->payConfig['paysignkey'], $this->payConfig['partnerkey']); $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", $_GET['single_orderid']); $wxPayHelper->setParameter("partner", $this->payConfig['partnerid']); $wxPayHelper->setParameter("out_trade_no", $_GET['single_orderid']); $wxPayHelper->setParameter("total_fee", floatval($_GET['price']) * 100); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", C('site_url') . '/index.php?g=Wap&m=Weixin&a=return_url'); //$wxPayHelper->setParameter("notify_url", 'http://www.baidu.com'); $wxPayHelper->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']); $wxPayHelper->setParameter("input_charset", "GBK"); $url = $wxPayHelper->create_biz_package(); $this->assign('url', $url); $this->assign('returnUrl', '?g=Wap&m=Product&a=my&token=' . $this->token . '&wecha_id=' . $this->wecha_id); //................ $this->display(); }
<?php include_once "WxPayHelper.php"; //必填,不需要修改 $memberid = $_GET['memberid']; $payType = $_GET['payType']; $wxPayHelper = new WxPayHelper($memberid, $payType); //判断memberId有效性以及调用支付配置 if ($payType == 'shop' || $payType == 'tuan' || $payType == 'hotel' || $payType == 'dc') { //服务器异步通知页面路径 $notify_url = 'http://' . $_SERVER['SERVER_NAME'] . "/3G/" . $payType . "/notifywx/" . $memberid . "/"; //页面跳转同步通知页面路径 $call_back_url = 'http://' . $_SERVER['SERVER_NAME'] . "/3G/" . $payType . "/order/" . $memberid . "/"; //操作中断返回地址 $merchant_url = "http://www.wei3g.cn/3G/" . $payType . "/order/" . $memberid . "/"; } //付款金额 $total_fee = $_GET['total'] * 100; //订单名称 $subject = $_GET['subject']; //获取订单编号 $out_trade_no = $_GET['OrderId']; //获取银行通道类型 $wxPayHelper->setParameter("bank_type", "WX"); //商品描述 $wxPayHelper->setParameter("body", $subject); //商户号 $wxPayHelper->setParameter("partner", $wxPayHelper->getPartnerId()); //商户订单号 $wxPayHelper->setParameter("out_trade_no", $out_trade_no); //订单总金额
/** * callback-ent.php UTF8 * @author djks * @date 2014-03-11 * @copyright http://www.weixincaihong.com */ function create_wxpay($order_sn, $goods_name) { require_once ROOT_PATH . 'wechat/pay/WxPayHelper.php'; $wxPayHelper = new WxPayHelper(); $user_ip = $_SERVER["REMOTE_ADDR"]; $notify_url = "http://www.inink.cn/mobile/user.php"; $out_trade_no = $order_sn; $wx_goods_name = $goods_name; $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", $wx_goods_name); $wxPayHelper->setParameter("partner", "1218290401"); $wxPayHelper->setParameter("out_trade_no", $out_trade_no); $wxPayHelper->setParameter("total_fee", "1"); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", $notify_url); $wxPayHelper->setParameter("spbill_create_ip", $user_ip); $wxPayHelper->setParameter("input_charset", "UTF-8"); $create_wxpay = $wxPayHelper->create_biz_package(); return $create_wxpay; }
<?php include_once "WxPayHelper/WxPayHelper.php"; $commonUtil = new CommonUtil(); $wxPayHelper = new WxPayHelper(); $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", "test"); $wxPayHelper->setParameter("partner", "1221189901"); $wxPayHelper->setParameter("out_trade_no", $commonUtil->create_noncestr()); $wxPayHelper->setParameter("total_fee", "1"); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", "http://www.shajiawang.com/site/weixinapi/notify_url.php"); $wxPayHelper->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']); $wxPayHelper->setParameter("input_charset", "UTF-8"); ?> <html> <script language="javascript"> function callpay() { WeixinJSBridge.invoke('getBrandWCPayRequest',<?php echo $wxPayHelper->create_biz_package(); ?> ,function(res){ WeixinJSBridge.log(res.err_msg); alert(res.err_code+res.err_desc+res.err_msg); }); } </script> <body> <button type="button" onclick="callpay()">wx pay test</button> </body> </html>
<?php include_once "WxPayHelper.php"; $commonUtil = new CommonUtil(); $wxPayHelper = new WxPayHelper(); $body = $_GET['body']; //订单详情 $out_trade_no = $_GET['out_trade_no']; //订单号 $total_fee = intval($_GET['total_fee'] * 100); //价格3880.00 $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", $body); $wxPayHelper->setParameter("partner", $_GET['partner']); $wxPayHelper->setParameter("out_trade_no", $out_trade_no); $wxPayHelper->setParameter("total_fee", $total_fee); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", $_GET['notify_url']); $wxPayHelper->setParameter("spbill_create_ip", $_GET['ip']); $wxPayHelper->setParameter("input_charset", "UTF-8"); //var_dump($wxPayHelper); ?> <html> <script language="javascript"> document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { WeixinJSBridge.invoke('getBrandWCPayRequest',<?php echo $wxPayHelper->create_biz_package(); ?> ,function(res){ WeixinJSBridge.log(res.err_msg);
public function pay() { //取商家token值,取不到则默认为空 $tokenTall = $this->getTokenTall(); $this->assign('tokenTall', $tokenTall); //header("content-Type: text/html; charset=Utf-8"); //dump($_POST);exit; if (IS_POST && count($_SESSION['cart']) > 0) { import('Think.ORG.Cart'); // 导入购物车类 $cart = new Cart(); $user_address = M('user_address'); $item_order = M('item_order'); $order_detail = M('order_detail'); $item_goods = M('item'); $this->visitor->info['id']; //用户ID $this->visitor->info['username']; //用户账号 //收货地址begin $addr = array(); $address_options = $this->_post('address_options', 'intval'); //0:刚填的地址;大于0:历史地址 if ($address_options == 0) { $consignee = $this->_post('consignee', 'trim'); //真实姓名 $sheng = $this->_post('sheng', 'trim'); //省 $shi = $this->_post('shi', 'trim'); //市 $qu = $this->_post('qu', 'trim'); //区 $address = $this->_post('address', 'trim'); //详细地址 $phone_mob = $this->_post('phone_mob', 'trim'); //电话号码 $save_address = $this->_post('save_address', 'trim'); //是否保存地址 $addr['address_name'] = $consignee; //收货人姓名 $addr['mobile'] = $phone_mob; //电话号码 $addr['address'] = $sheng . $shi . $qu . $address; //地址 if ($save_address) { $add_address['uid'] = $this->visitor->info['id']; $add_address['consignee'] = $consignee; $add_address['address'] = $address; $add_address['mobile'] = $phone_mob; $add_address['sheng'] = $sheng; $add_address['shi'] = $shi; $add_address['qu'] = $qu; $user_address->data($add_address)->add(); } } else { $address = $user_address->where("uid='" . $this->visitor->info['id'] . "'")->find($address_options); //取到地址 $addr['address_name'] = $address['consignee']; //收货人姓名 $addr['mobile'] = $address['mobile']; //电话号码 $addr['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address']; //地址 } //收货地址end //把购物车的商品按商家分组 $result = $this->cart_by_group(); //header("content-Type: text/html; charset=Utf-8"); //dump($result);exit; $all_order_arr = array(); //所有生成的订单单号集合 $all_order_price = 0; //所有生成的订单总额 //按店铺生成订单 foreach ($result as $key => $value) { $data = array(); //生成订单号 $dingdanhao = date("Y-m-dH-i-s"); $dingdanhao = str_replace("-", "", $dingdanhao); $dingdanhao .= rand(1000, 2000); $time = time(); //订单添加时间 $goods_sum = 0; foreach ($value['item'] as $items) { $goods_sum = $goods_sum + floatval($items['price']) * floatval($items['num']); } $free_sum = 0; $freetype = $this->_post('free_' . $key, 'intval'); //配送方式 if ($freetype == 0) { //卖家包邮 $free_sum = 0; } else { $free_sum = $this->_post('freefee_' . $key, 'intval'); //取到运费 } $postscript = ''; //卖家留言 $postscript = $this->_post('mymsg_' . $key, 'trim'); //卖家留言 $data['orderId'] = $dingdanhao; //订单号 $data['add_time'] = $time; //添加时间 $data['goods_sumPrice'] = $goods_sum; //商品总额 $data['order_sumPrice'] = $goods_sum + $free_sum; //订单总额 $data['note'] = $postscript; $data['userId'] = $this->visitor->info['id']; //用户ID $data['userName'] = $this->visitor->info['username']; //用户名 $data['address_name'] = $addr['address_name']; //收货人姓名 $data['mobile'] = $addr['mobile']; //电话号码 $data['address'] = $addr['address']; //地址 $data['freetype'] = $freetype; //配送方式 $data['freeprice'] = $free_sum; //配送金额 $data['tokenTall'] = $key; $all_order_arr[] = $dingdanhao; $all_order_price = $all_order_price + $goods_sum + $free_sum; if ($orderid = $item_order->data($data)->add()) { $orders = array(); $orders['orderId'] = $dingdanhao; foreach ($value['item'] as $item) { $item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']); $orders['itemId'] = $item['id']; //商品ID $orders['title'] = $item['name']; //商品名称 $orders['img'] = $item['img']; //商品图片 $orders['price'] = $item['price']; //商品价格 $orders['quantity'] = $item['num']; //购买数量 $orders['size'] = $item['size']; //购买大小 $orders['color'] = $item['color']; //购买颜色 $order_detail->data($orders)->add(); //添加订单明细 } } else { $this->error('生成订单失败!'); } } $cart->clear(); //清空购物车 //$this->assign('orderid',$orderid);//订单ID //$this->assign('dingdanhao',$dingdanhao);//订单号 //$this->assign('order_sumPrice',$data['order_sumPrice']); //header("content-Type: text/html; charset=Utf-8"); //dump(implode(',', $all_order_arr));exit; //重新生成一个合并订单号,用于支付,并将原订单号和合并订单号的关联关系写入表中。 $merge = date("Y-m-dH-i-s"); $merge = str_replace("-", "", $merge); $merge .= rand(1000, 2000); foreach ($all_order_arr as $order) { $data1['orderid'] = $order; $data1['mergeid'] = $merge; M('order_merge')->where("orderid='" . $order . "'")->delete(); M('order_merge')->data($data1)->add(); } //$this->assign('dingdanhao', implode(',', $all_order_arr));//所有订单 //所有订单号 $this->assign('allorderid', $all_order_arr); //支付号 $this->assign('dingdanhao', $merge); $alldingdanhao = $merge; $this->assign('order_sumPrice', $all_order_price); //总金额 $ordersumPrice = $all_order_price; $this->assign('order_zhifu', '0'); } else { if (isset($_GET['orderId'])) { $item_order = M('item_order'); $orderId = $_GET['orderId']; //订单号 $orders = $item_order->where("userId='" . $this->visitor->info['id'] . "' and orderId='" . $orderId . "'")->find(); if (!is_array($orders)) { $this->_404(); } $this->assign('orderid', $orders['id']); //订单ID /* * 不能这么干,应该发起查询,如果没有支付,则再进行支付。by zcb //重新生成一个合并订单号,用于支付,并将原订单号和合并订单号的关联关系写入表中。 $merge = date("Y-m-dH-i-s"); $merge = str_replace("-","",$merge); $merge .= rand(1000,2000); M('order_merge')->where("orderid='".$orderId."'")->delete(); M('order_merge')->data(array('orderid'=>$orderId, 'mergeid'=>$merge))->add(); */ $merge = M('order_merge')->where(array('orderid' => $orderId))->find(); //支付号 $this->assign('dingdanhao', $merge['mergeid']); $alldingdanhao = $merge['mergeid']; //订单号 $this->assign('allorderid', array($orderId)); //金额 $this->assign('order_sumPrice', $orders['order_sumPrice']); $ordersumPrice = $orders['order_sumPrice']; $this->assign('order_exist', '1'); if (empty($orders['supportmetho'])) { $this->assign('order_zhifu', '0'); } else { //$alipay=M('alipay')->find(); //echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=".$alipay['alipayname']."&WIDout_trade_no=".$orderId."&WIDsubject=".$orderId."&WIDtotal_fee=".$orders['order_sumPrice']."'</script>"; //exit; $this->assign('order_zhifu', $orders['supportmetho']); } } else { $this->redirect('user/index', array('tokenTall' => $tokenTall)); } } $alipay_person = ""; $alipay_biz = ""; $wxpay = ""; if (M('alipay_person')->where(array('tokenTall' => $tokenTall))->find()) { $alipay_person = "ok"; } if (M('alipay_biz')->where(array('tokenTall' => $tokenTall))->find()) { $alipay_biz = "ok"; } if (M('wxpay')->where(array('tokenTall' => $tokenTall))->find()) { $wxpay = "ok"; } $this->assign('alipay_person', $alipay_person); $this->assign('alipay_biz', $alipay_biz); $this->assign('wxpay', $wxpay); $this->assign('current_user', $_SESSION['user_info']['username']); //微信支付 $all_order_price_100 = $ordersumPrice * 100; //支付用,精确到分 //header('Content-Type:text/html;charset=utf-8'); include_once "WxPayphp/WxPayHelper.php"; $commonUtil = new CommonUtil(); $wxPayHelper = new WxPayHelper(); $wxPayHelper->setParameter("bank_type", "WX"); $wxPayHelper->setParameter("body", "BILL(NO:" . $alldingdanhao . ")"); $wxPayHelper->setParameter("partner", "1218886101"); $wxPayHelper->setParameter("out_trade_no", $alldingdanhao); $wxPayHelper->setParameter("total_fee", "{$all_order_price_100}"); $wxPayHelper->setParameter("fee_type", "1"); $wxPayHelper->setParameter("notify_url", "http://www.kuyimap.com/weTall/wxpay/notify_url.php"); $wxPayHelper->setParameter("spbill_create_ip", "127.0.0.1"); $wxPayHelper->setParameter("input_charset", "GBK"); $biz_package = $wxPayHelper->create_biz_package(); $this->assign('biz_package', $biz_package); $this->display(); }