public function pay()
 {
     $user = session('user');
     $tools = new JsApiPay();
     $openId = $tools->GetOpenid();
     session('openId', $openId);
     if ($user) {
         $this->assign('jifen', $user['jifen']);
     }
     $this->display();
 }
Esempio n. 2
0
 /**
  * 根据订单信息生成签名
  * @param $data 订单信息
  * @return Weixin\json数据|null
  * @throws Weixin\WxPayException
  */
 public function jspay($data)
 {
     $jsApiParameters = null;
     if ($data) {
         $tools = new JsApiPay();
         $openId = session('openId');
         $input = new WxPayUnifiedOrder();
         $input->SetBody($data['body']);
         $input->SetAttach($data['attach']);
         $input->SetTotal_fee(intval($data['total_fee']));
         $input->SetGoods_tag($data['goods_tag']);
         $input->SetNotify_url($data['notify_url']);
         $input->SetOut_trade_no($data['order_id']);
         $input->SetTime_start($data['time']);
         $input->SetTime_expire(date("YmdHis", time() + 600));
         $input->SetTrade_type("JSAPI");
         $input->SetOpenid($openId);
         $order = WxPayApi::unifiedOrder($input);
         $jsApiParameters = $tools->GetJsApiParameters($order);
     }
     return $jsApiParameters;
 }