Ejemplo n.º 1
0
  public function zhifu_test(){
	require_once getcwd()."/Wxpay/lib/WxPay.Api.php";
	require_once getcwd()."/Wxpay/unit/WxPay.JsApiPay.php";
	//获取用户openid
	$tools = new JsApiPay();
	$openId = $tools->GetOpenid();
	//cookie('openId',$openId);
	//统一下单
	/*
	$input = new WxPayUnifiedOrder();
	$input->SetBody("test");
	$input->SetAttach("test");
	$input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
	$input->SetTotal_fee("1");
	$input->SetTime_start(date("YmdHis"));
	$input->SetTime_expire(date("YmdHis", time() + 600));
	$input->SetGoods_tag("test");
	$input->SetNotify_url(C('SITE_URL')."/index.php/Index/wx_notify");
	$input->SetTrade_type("JSAPI");
	$input->SetOpenid($openId);
	$order = WxPayApi::unifiedOrder($input);
	$jsApiParameters = $tools->GetJsApiParameters($order);
	//dump($order);echo $jsApiParameters; exit; 
	$this->assign('jsApiParameters',$jsApiParameters);
	*/
	$this->display();
  }
Ejemplo n.º 2
0
  /**
   *  支付前处理
   */
  public function beforepay(){
	//是否微信支付
	//dump($_GET);exit;
	if(!isWeixin()){
		if($_GET['order_sn']){
			header("Location: ".__ROOT__."/Order/pay?order_sn=".$_GET['order_sn']);
		}
		if($_GET['mo_sn']){
			header("Location: ".__ROOT__."/Order/pay?mo_sn=".$_GET['mo_sn']);
		}			
		exit;
	}
	include C('INTERFACE_PATH')."wxwappay/lib/WxPay.Api.php";
	include C('INTERFACE_PATH')."wxwappay/unit/WxPay.JsApiPay.php";
	//获取用户openid
	$tools = new JsApiPay();
	$openId = $tools->GetOpenid();
	cookie('wx_real_openid',authcode($openId,'ENCODE'));
	$this->assign('order_sn',$_GET['order_sn']);
	$this->assign('mo_sn',$_GET['mo_sn']);
  }