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&token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&from=' . $_GET['from']);
        //$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);
        //
        $from = $_GET['from'];
        $from = $from ? $from : 'Groupon';
        $from = $from != 'groupon' ? $from : 'Groupon';
        switch ($from) {
            default:
            case 'Groupon':
                break;
        }
        $returnUrl = '/index.php?g=Wap&m=' . $from . '&a=payReturn&token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&orderid=' . $_GET['single_orderid'];
        $this->assign('returnUrl', $returnUrl);
        //$this->display('Weixin_pay.html');
        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>' . floatval($_GET['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>您已支付成功,页面正在跳转...</td></tr></table><div id="failRt"></div></td></tr></table></li></ul></div></body></html>';
    }
Exemple #2
0
 public function index($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'] . "/pay/wxpay/notifywx/" . $memberId . "/" . $payType;
         //页面跳转同步通知页面路径
         $call_back_url = 'http://' . $_SERVER['SERVER_NAME'] . "/3G/" . $payType . "/order/" . $memberId . "/";
         //操作中断返回地址
         $merchant_url = 'http://' . $_SERVER['SERVER_NAME'] . "/3G/" . $payType . "/order/" . $memberId . "/";
     }
     //付款金额
     $total_fee = $_GET['total'] * 100;
     //订单名称
     $subject = str_replace("X", "", $_GET['subject']);
     $subject = str_replace(" ", "", $subject);
     $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);
     //订单总金额
     $wxPayHelper->setParameter("total_fee", $total_fee);
     //支付币种
     $wxPayHelper->setParameter("fee_type", "1");
     //通知url
     $wxPayHelper->setParameter("notify_url", $notify_url);
     //订单生成的机器IP
     $wxPayHelper->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
     //字符编码
     $wxPayHelper->setParameter("input_charset", "UTF-8");
     //生成jsapi支付请求json
     $data['msg'] = $wxPayHelper->create_biz_package();
     $data['total'] = $_GET['total'];
     $data['subject'] = $_GET['subject'];
     $data['call_back_url'] = $call_back_url;
     $data['merchant_url'] = $merchant_url;
     $this->load->view("/member/weipay/weixinpay", $data);
 }
Exemple #3
0
/**
 * 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;
}
 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();
 }
 public function weixinpay()
 {
     $commonUtil = new CommonUtil();
     $wxPayHelper = new WxPayHelper();
     $source = Input::safeHtml($_POST['source']);
     //接收来源属性
     $custom_id = intval($_POST['custom_id']);
     //接收客户id
     $order_id = intval($_POST['trade_no']);
     //接收订单id
     $merchant_url = Input::safeHtml($_POST['merchant_url']);
     //操作中断返回地址
     //获取商城id
     $shop_id = $_GET['shop_id'];
     //获取商品名称
     $shop_name = M(C('DB_WECHAT_NAME') . '.wxh_order_detail')->where("is_del = 0 and order_id = '" . $order_id . "' and source = '" . $source . "'")->getField('commodity_name');
     //echo M()->getLastSql();
     //dump($shop_name);
     // echo '<br >access_token为:'.$wxPayHelper->access_token(false);
     //获取订单信息
     $order_info = M(C('DB_WECHAT_NAME') . '.wxh_order')->where('is_del = 0 and status = 5 and id = ' . $order_id . ' and user_id = ' . $_SESSION['U_IF']['member_id'])->field('from_id, price, add_time')->find();
     //$price = $order_info['price'];
     //验证post参数,非法返回
     if ($source == '' || $custom_id <= 0 || $order_id <= 0 || $merchant_url == '') {
         die(jump(array('jumpmsg' => '参数非法')));
     }
     //获取订单编号 :来源+订单ID+客户ID+用户ID
     $order_no = $source . '_' . $order_id . '_' . $custom_id . '_' . $_SESSION['U_IF']['member_id'];
     //echo $order_no;
     //$wxpay_config = C('WX_PAY_CONFIG');
     //dump($wxpay_config);
     //echo $total_fee = round($price,2);   //付款金额
     //获取银行通道类型
     $wxPayHelper->setParameter("bank_type", "WX");
     //商品描述
     $wxPayHelper->setParameter("body", $shop_name);
     //商户号
     $wxPayHelper->setParameter("partner", $wxPayHelper->getPartnerId());
     //商户订单号
     $wxPayHelper->setParameter("out_trade_no", $order_no);
     //订单总金额
     $wxPayHelper->setParameter("total_fee", '1');
     //支付币种
     $wxPayHelper->setParameter("fee_type", "1");
     //通知url
     $wxPayHelper->setParameter("notify_url", "http://test.weixinhai.net/shop.php/Wxpay/payNotifyUrl/shop_id/" . $shop_id);
     //订单生成的机器IP
     $wxPayHelper->setParameter("spbill_create_ip", get_client_ip());
     //字符编码
     $wxPayHelper->setParameter("input_charset", "UTF-8");
     //生成jsapi支付请求json
     //dump($wxPayHelper->parameters);
     $data = array('merchant_url' => $merchant_url, 'custom_id' => $custom_id, 'shop_name' => $shop_name, 'order_info' => $order_info);
     $msg = $wxPayHelper->create_biz_package();
     $this->assign('merchant_url', $merchant_url);
     $this->assign('custom_id', $custom_id);
     $this->assign('data', $data);
     $this->assign('msg', $msg);
     $this->display('./shop/Tpl/Index/weixinpay.html');
     //dump($msg);
 }
Exemple #6
0
	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);
		$message = '';
		$message .= '<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>';

		if (empty($this->_issystem)) {
			$message .= '<script language="javascript">function callpay(){WeixinJSBridge.invoke("getBrandWCPayRequest",' . $jsApiParameters . ',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{if(res.err_msg == "get_brand_wcpay_request:cancel"){var err_msg = "您取消了支付";}else if(res.err_msg == "get_brand_wcpay_request:fail"){var err_msg = "支付失败<br/>错误信息:"+res.err_desc;}else{var err_msg = res.err_msg +"<br/>"+res.err_desc;}document.getElementById("payDom").style.display = "none";document.getElementById("failDom").style.display = "";document.getElementById("failRt").innerHTML = err_msg;}});}</script>';
		}

		$message .= '</head><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>';

		if ($this->_issystem) {
			$message .= '<ul class="round" id="cross_pay"><li class="title mb" style="text-align:center"><span class="none">微信扫描支付</span></li><li class="nob" style="margin-bottom: 18px;"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="kuang"><tr><td style="text-align:center" ><img src="' . U('Weixin/qrcode', array('url' => $url)) . '" height="200" id="show_success"></td></tr><tr><td style="text-align:center">长按图片[识别二维码]付款</td></tr></table></li><li class="mb" style="text-align:center;margin-top: 20px;border-top: 1px solid #C6C6C6;" id="success"><span class="none"><a href="' . $returnUrl . '" style="color:#459ae9">我已经支付成功</a></span></li></ul>';
		}
		else {
			$message .= '<div class="footReturn" style="text-align:center" id="pay_div"><input type="button" style="margin:0 auto 20px auto;width:100%"  onclick="callpay()"  class="submit" value="点击进行微信支付" /></div>';
		}

		$message .= '</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><td>您已支付成功,页面正在跳转...</td></tr></table><div id="failRt"></div></li></ul></div></body></html>';
		echo $message;
	}
Exemple #7
0
<?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();
Exemple #8
0
<?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>
Exemple #9
0
//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;
}
function addLog($other = array(), $type = 1)
{
Exemple #10
0
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);
//订单总金额
$wxPayHelper->setParameter("total_fee", $total_fee);
//支付币种
$wxPayHelper->setParameter("fee_type", "1");
//通知url
$wxPayHelper->setParameter("notify_url", 'http://demo.weixinhai.com.cn/mobile/wxpay/weixinpay.php');
//订单生成的机器IP
$wxPayHelper->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//字符编码
Exemple #11
0
<?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>
Exemple #12
0
<?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();
 }