public function pay()
 {
     ini_set('date.timezone', 'Asia/Shanghai');
     require_once "lib/WxPay.Api.php";
     require_once "WxPay.JsApiPay.php";
     $sn = $_GET['sn'];
     $code = $_GET['code'];
     $data = json_decode(cookie('login'), true);
     $arr = D('Shop')->orderdetail($sn, $data['user']);
     if ($arr['show_status'] == '未付款') {
         $tools = new JsApiPay();
         $openId = $tools->getOpenidFromMp($code);
         $input = new WxPayUnifiedOrder();
         $input->SetBody("民间厨王");
         $input->SetAttach("test");
         $input->SetOut_trade_no($sn);
         $total_fee = $arr['goods_price'] * 100;
         $input->SetTotal_fee(intval($total_fee));
         $input->SetTime_start(date("YmdHis"));
         $input->SetTime_expire(date("YmdHis", time() + 600));
         $input->SetGoods_tag("test");
         $input->SetNotify_url("http://www.minjianchuwang.com/Home/Order/notify_url.html");
         $input->SetTrade_type("JSAPI");
         $input->SetOpenid($openId);
         $order = WxPayApi::unifiedOrder($input);
         $jsApiParameters = $tools->GetJsApiParameters($order);
         $this->assign('jsApiParameters', $jsApiParameters);
         $daojishi = $arr['add_time'] + 600 - time();
         $this->assign('daojishi', $daojishi);
         $this->assign('orderdetail', $arr);
         $this->assign('address', explode(';', $arr['address']));
         $totalcount = M('cart')->where(array('user' => $data['user']))->sum('goods_number');
         $this->assign('totalcount', $totalcount);
         $this->display('order_details');
     } else {
         $this->redirect('Order/index');
     }
 }
Beispiel #2
0
  public function zhifu_test2(){
	require_once getcwd()."/Wxpay/lib/WxPay.Api.php";
	require_once getcwd()."/Wxpay/unit/WxPay.JsApiPay.php";
	$openId = cookie('openId');
	//统一下单
	$tools = new JsApiPay();
	$input = new WxPayUnifiedOrder();
	$payAmount = (string)100;
	$input->SetBody("test");
	$input->SetAttach("test");
	$input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
	$input->SetTotal_fee($payAmount);
	$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->SetNotify_url(C('SITE_URL')."/index.php/Wx_Payment/ali_notify_merge");
	$input->SetTrade_type("JSAPI");
	$input->SetOpenid($openId);
	$order = WxPayApi::unifiedOrder($input);
	//dump($order);echo $jsApiParameters; exit; 
	$jsApiParameters = $tools->GetJsApiParameters($order);
	//dump($order);echo $jsApiParameters; exit; 
	$this->assign('jsApiParameters',$jsApiParameters);
	$this->display();
  }
Beispiel #3
0
  /**
   *  收银台
   */
  public function pay(){
	//订单信息
	$model = M('Order');
	if($_REQUEST['order_sn']){
		$data['order_sn'] = $_REQUEST['order_sn'];
		$out_trade_no = $_REQUEST['order_sn'];
		//单一订单支付
		$notify_url = C('SITE_URL') . '/index.php/Wx_Payment/notify';
	}
	if($_REQUEST['mo_sn']){
		$data['mo_sn'] = $_REQUEST['mo_sn'];
		$out_trade_no = $_REQUEST['mo_sn'];
		//多订单合并支付
		$notify_url = C('SITE_URL') . '/index.php/Wx_Payment/notify_merge';
	}
	$data['member_id'] = $this->user['id'];
	$orders = $model->field('id,title,order_sn,total_fee,actual_paid,status')->where($data)->select();
	//echo $model->getlastsql();dump($orders);exit;
	if(!$orders){
		$this->error('订单不存在');
	}
	$total_fee = 0;
	$title = '';
	foreach($orders as $key=>$order){
		$total_fee += $order['total_fee'];
		$titles[] = $order['title'];
		if($order['status']!=1 || $order['pay_status']!=0){
			$this->error('订单:'.$order['order_id'].'状态错误');
		}
	}
	$body = implode(',',$titles);
	//支付接口请求
	/*
	require_once(C('INTERFACE_PATH')."Api/config.php");
	require_once(C('INTERFACE_PATH')."Api/Api.class.php");
	$api = new Api($config);
	$para['m'] = 'Payment';
	$para['a'] = 'wxWapPay';
	if($_REQUEST['order_sn'])$data['order_sn'] = $_REQUEST['order_sn'];
	if($_REQUEST['mo_sn'])$data['mo_sn'] = $_REQUEST['mo_sn'];
	$data['openid'] = 'oO8Umt19WO-Ci88IrRm2ywXgr9OM';
	$result = json_decode($api->get($para,$data),true);
	dump($result);exit;
	*/
	//如果是微信浏览器直接可支付
	$isWeixin = isWeixin();
	if($isWeixin){
		$openId = cookie('wx_real_openid');
		$openId = authcode($openId);
		$body = $body;
		$total_fee = $total_fee*100;
		$total_fee = (string)$total_fee;
		require_once C('INTERFACE_PATH')."wxwappay/lib/WxPay.Api.php";	
		require_once C('INTERFACE_PATH')."wxwappay/unit/WxPay.JsApiPay.php";
		$tools = new JsApiPay();
		$input = new WxPayUnifiedOrder();
		$input->SetBody($body);
		$input->SetOut_trade_no($out_trade_no);
		$input->SetTotal_fee($total_fee);
		$input->SetTime_start(date("YmdHis"));
		$input->SetTime_expire(date("YmdHis", time() + 600));
		//$input->SetGoods_tag("test");
		$input->SetNotify_url($notify_url);
		$input->SetTrade_type("JSAPI");
		$input->SetOpenid($openId);
		$payOrder = WxPayApi::unifiedOrder($input);
		$jsApiParameters = $tools->GetJsApiParameters($payOrder);
		$this->assign('jsApiParameters',$jsApiParameters);		
	}
	$this->assign('isWeixin',$isWeixin);
	$this->assign('order',$order);
	$this->assign('headerTitle','订单支付页');
	$this->assign('headerKeywords','订单支付页');
	$this->assign('headerDescription','订单支付页');
	$this->assign('wx_title','订单支付页');
	$this->assign('wx_desc',C('wx_desc'));
	$this->display();
  }