當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WxPayUnifiedOrder::SetOpenid方法代碼示例

本文整理匯總了PHP中WxPayUnifiedOrder::SetOpenid方法的典型用法代碼示例。如果您正苦於以下問題:PHP WxPayUnifiedOrder::SetOpenid方法的具體用法?PHP WxPayUnifiedOrder::SetOpenid怎麽用?PHP WxPayUnifiedOrder::SetOpenid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WxPayUnifiedOrder的用法示例。


在下文中一共展示了WxPayUnifiedOrder::SetOpenid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: JsApiPay

 /**
  * jsapi支付
  * @param string  $user_id    用戶id
  * @param int     $order_id
  * @param string  $order_sn   訂單號
  * @param int     $total_fee  費用
  * @param string  $body       商品或支付單簡要描述
  * @param string  $goods_tag  商品標記
  * @param string  $attach     自定義數據
  * @return array
  */
 public function JsApiPay($user_id, $order_id, $order_sn, $total_fee, $body = '', $goods_tag = '', $attach = '')
 {
     if (empty($user_id) || empty($total_fee)) {
         return ['status' => -1, 'message' => '數據錯誤'];
     }
     $tools = new JsApiPay();
     $openId = UserModel::instance()->getOpenId($user_id);
     if (empty($openId)) {
         $openId = $tools->GetOpenid();
         //             return ['status'=> -2 , 'message'=>'user_id錯誤'];
     }
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($body);
     $input->SetAttach($attach);
     $input->SetOut_trade_no($order_sn);
     //\WxPayConfig::MCHID.date("YmdHis")
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag($goods_tag);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     if ($order['return_code'] != 'SUCCESS') {
         return ['status' => -10, 'message' => $order['return_msg']];
     }
     $jsApiParameters = $tools->GetJsApiParameters($order);
     $this->addPayLog($openId, $order_id, $input);
     return ['status' => 1, 'message' => $jsApiParameters];
 }
開發者ID:xswolf,項目名稱:dc,代碼行數:41,代碼來源:PayEvent.class.php

示例2: jsapipay

/**
 * 生成支付接口內容
 * @param $data
 * @param bool $debug
 * @return json
 */
function jsapipay($data, $debug = false)
{
    // C('weixin.weixin_')
    //①、獲取用戶openid
    $tools = new JsApiPay();
    //    $openId = $tools->GetOpenid();
    if (!empty($data['openid'])) {
        $openId = $data['openid'];
    } else {
        echo "empty openid";
        die;
    }
    //②、統一下單
    $input = new WxPayUnifiedOrder();
    $input->SetBody($data['body']);
    $input->SetAttach($data['attach']);
    $input->SetOut_trade_no($data['order_sn']);
    $input->SetTotal_fee($data['total_fee']);
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetGoods_tag($data['goods_tag']);
    $input->SetNotify_url("http://{$_SERVER[HTTP_HOST]}/weixin/notify.html");
    $input->SetTrade_type("JSAPI");
    $input->SetOpenid($openId);
    $order = WxPayApi::unifiedOrder($input);
    if ($debug) {
        echo '<font color="#f00"><b>統一下單支付單信息</b></font><br/>';
        printf_info($order);
    }
    $jsApiParameters = $tools->GetJsApiParameters($order);
    return $jsApiParameters;
}
開發者ID:ysc8620,項目名稱:zhima,代碼行數:38,代碼來源:weizhao.php

示例3: wxJsPay

 public function wxJsPay()
 {
     $list = isset($_SESSION['orderinfo']) ? $_SESSION['orderinfo'] : array();
     if (!isset($_SESSION['orderinfo'])) {
         header("Location:" . appurl('getMeOrder'));
         die;
     }
     //驗證是否能預定
     if (isset($_SESSION['orderList'])) {
         foreach ($_SESSION['orderList'] as $key => $value) {
             $this->checkCanSum($value['bookid'], $value);
             if (!$this->checkBook($value['bookid'])) {
                 $this->alert($value['title'] . '已經售賣結束');
                 exit;
             }
         }
     }
     //初始化日誌
     $logHandler = new CLogFileHandler("../logs/" . date('Y-m-d') . '.log');
     $log = Log::Init($logHandler, 15);
     //①、獲取用戶openid
     $tools = new JsApiPay();
     $openId = $tools->GetOpenid();
     //②、統一下單
     //價錢轉成分
     $totalFee = $list['allPrice'] * 100;
     $input = new WxPayUnifiedOrder();
     $input->SetBody("訂單");
     $input->SetAttach("訂單");
     $input->SetOut_trade_no($list['orderid']);
     $input->SetTotal_fee($totalFee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("訂單");
     $input->SetNotify_url(appurl('callBack'));
     // "http://paysdk.weixin.qq.com/example/notify.php"
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = WxPayApi::unifiedOrder($input);
     echo '<font color="#f00"><b>支付中,客官請稍後....</b></font><br/>';
     // $this->printf_info($order);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //獲取共享收貨地址js函數參數
     $editAddress = $tools->GetEditAddressParameters();
     //③、在支持成功回調通知中處理成功之後的事宜,見 notify.php
     /**
      * 注意:
      * 1、當你的回調地址不可訪問的時候,回調通知會失敗,可以通過查詢訂單來確認支付是否成功
      * 2、jsapi支付時需要填入用戶openid,WxPay.JsApiPay.php中有獲取openid流程 (文檔可以參考微信公眾平台“網頁授權接口”,
      * 參考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
      */
     $data = array('jsApiParameters' => $jsApiParameters, 'editAddress' => $editAddress, 'orderid' => $list['orderid'], 'pageTitle' => '支付');
     unset($_SESSION['orderinfo']);
     $this->layoutRender('/wxpay', $data);
 }
開發者ID:aising,項目名稱:ding,代碼行數:55,代碼來源:PayController.php

示例4: getJsApiParameters

 public function getJsApiParameters($out_trade_no = '', $fee = '', $openId = '')
 {
     $input = new WxPayUnifiedOrder();
     $input->SetBody("購買相冊打印服務");
     $input->SetOut_trade_no($out_trade_no);
     $input->SetTotal_fee($fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetNotify_url('http://api.dayinxiangsh.com/1.0/pay/callback');
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = WxPayApi::unifiedOrder($input);
     $jsApiParameters = $this->getParameters($order);
     return $jsApiParameters;
 }
開發者ID:mingshi,項目名稱:printer-api,代碼行數:15,代碼來源:Wxpay.php

示例5: createUnifiedOrder

 public function createUnifiedOrder($out_trade_no, $subject, $total_fee, $open_id = null)
 {
     //②、統一下單
     $input = new \WxPayUnifiedOrder();
     $input->setWxPayApi($this->wxPayApi);
     $input->SetBody($subject);
     $input->SetOut_trade_no($out_trade_no);
     //        $input->SetTotal_fee($total_fee);
     $input->SetTotal_fee(intval($total_fee * 100));
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetTrade_type($this->trade_type);
     if ($open_id) {
         $input->SetOpenid($open_id);
     }
     $order = $this->wxPayApi->unifiedOrder($input);
     return $order;
 }
開發者ID:fishlab,項目名稱:wechat-sdk-php,代碼行數:18,代碼來源:WechatPaymentSupport.php

示例6: unifiedorder

 public function unifiedorder($openId, $product_id)
 {
     //統一下單
     $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("http://paysdk.weixin.qq.com/example/notify.php");
     $input->SetTrade_type("NATIVE");
     $input->SetOpenid($openId);
     $input->SetProduct_id($product_id);
     $result = WxPayApi::unifiedOrder($input);
     Log::DEBUG("unifiedorder:" . json_encode($result));
     return $result;
 }
開發者ID:aising,項目名稱:ding,代碼行數:19,代碼來源:native_notify.php

示例7: unifiedorder

 public function unifiedorder($openId, $product_id)
 {
     //統一下單
     $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(Config::API_NOTIFY_URL);
     $input->SetTrade_type("NATIVE");
     $input->SetOpenid($openId);
     $input->SetProduct_id($product_id);
     $result = WxPayApi::unifiedOrder($input, Config::API_TIMEOUT);
     Log::DEBUG("unifiedorder:" . json_encode($result));
     return $result;
 }
開發者ID:xiaoziwuzui,項目名稱:gdby_github_repo,代碼行數:19,代碼來源:native_notify.php

示例8: getUnifiedOrder

 /**
  * 統一下單
  *
  * @param $amount
  *
  * @return string
  */
 private function getUnifiedOrder($amount)
 {
     $tools = new \JsApiPay();
     $openId = $tools->GetOpenid();
     //獲取用戶openID
     $outTradeNo = \tools\Tools::uuid();
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($this->data['memo']);
     $input->SetAttach($this->data['id']);
     $input->SetOut_trade_no($outTradeNo);
     $input->SetTotal_fee($this->amount);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag($this->data['memo']);
     $input->SetNotify_url($this->notify_url);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //獲取共享收貨地址js函數參數
     $editAddress = $tools->GetEditAddressParameters();
     return ['jsApiParameters' => $jsApiParameters, 'editAddress' => $editAddress, 'amount' => $amount, 'orderId' => $this->data['id']];
 }
開發者ID:hejxing,項目名稱:jt,代碼行數:30,代碼來源:Api.php

示例9: jsApiParametersGet_action

 /**
  *
  */
 public function jsApiParametersGet_action($mpid, $order)
 {
     $user = $this->getUser($mpid);
     $order = $this->model('app\\merchant\\order')->byId($order);
     if (false === $order) {
         return new \ResponseError('訂單不存在');
     }
     $products = array();
     $order->products = json_decode($order->products);
     foreach ($order->products as $prod) {
         $products[] = $prod->name;
     }
     $products = implode(',', $products);
     $notifyUrl = "http://" . $_SERVER['HTTP_HOST'];
     $notifyUrl .= "/rest/op/merchant/payok/notify";
     $tools = $this->model('mpproxy/WxPayJsApi');
     $wxPayConfig = new \WxPayConfig($mpid);
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($products);
     $input->SetAttach("測試附加信息");
     $input->SetOut_trade_no($order->trade_no);
     $input->SetTotal_fee($order->order_total_price);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("測試標簽");
     $input->SetNotify_url($notifyUrl);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($user->openid);
     $order = \WxPayApi::unifiedOrder($mpid, $input);
     if ($order['result_code'] === 'FAIL') {
         return new \ResponseError($order['err_code_des']);
     }
     $jsApiParameters = $tools->GetJsApiParameters($mpid, $order);
     //獲取共享收貨地址js函數參數
     $editAddress = $tools->GetEditAddressParameters($mpid);
     $rsp = array('jsApiParameters' => $jsApiParameters, 'editAddress' => $editAddress);
     return new \ResponseData($rsp);
 }
開發者ID:ahmatjan,項目名稱:xinxintong,代碼行數:41,代碼來源:pay.php

示例10: create_order

 protected function create_order($user_id, $trade_type, $attach, $fee, $open_id = null)
 {
     // 商戶號 + 用戶id + uniqid生成的隨機字符串
     $out_trade_no = WxPayConfig::MCHID . uniqid($user_id);
     // 需重置下當前時區,PHP配置文件不知為何不起作用
     //date_default_timezone_set('PRC');
     // 統一下單
     $input = new WxPayUnifiedOrder();
     $input->SetBody("掛號費");
     $input->SetAttach($attach);
     $input->SetOut_trade_no($out_trade_no);
     // 測試用1分錢
     $input->SetTotal_fee(1);
     $current_time = time();
     $start = date('YmdHis', $current_time);
     $expire = date('YmdHis', $current_time + 3600);
     // 下單時間:當前時間
     $input->SetTime_start($start);
     // 失效時間:測試用一個小時
     $input->SetTime_expire($expire);
     $input->SetGoods_tag("掛號費");
     $input->SetNotify_url("http://test.zerioi.com/pay/wxpay_notify");
     $input->SetTrade_type($trade_type);
     // JSAPI調用支付需設置open_id
     if ($open_id) {
         $input->SetOpenid($open_id);
     }
     $record = new WeixinPay();
     $record->trade_no = $out_trade_no;
     $record->trade_type = $trade_type;
     $record->time_start = $start;
     $record->time_expire = $expire;
     $record->user_id = $user_id;
     $record->open_id = $open_id;
     $record->attach = $attach;
     $record->total_fee = $fee;
     $record->status = 'UNFINISHED';
     if (!$record->save()) {
         throw new Exception("Could not save pay parameters");
     }
     return WxPayApi::unifiedOrder($input);
 }
開發者ID:Jv-Juven,項目名稱:hospital-register-system,代碼行數:42,代碼來源:PayController.php

示例11: jsApiPay

 /**
  *
  * jsApi微信支付示例
  * 注意:
  * 1、微信支付授權目錄配置如下  http://www.youweihui.net/addon/Wxpay/Index/jsApiPay/mp_id/
  * 2、支付頁麵地址需帶mp_id參數
  * 3、管理後台-基礎設置-公眾號管理,微信支付必須配置的參數都需填寫正確
  * @param array $mp_id 公眾號在係統中的ID
  * @return 將微信支付需要的參數寫入支付頁麵,顯示支付頁麵
  */
 public function jsApiPay()
 {
     $uid = get_ucuser_uid();
     //獲取粉絲用戶uid,一個神奇的函數,沒初始化過就初始化一個粉絲
     if ($uid === false) {
         $this->error('隻可在微信中訪問');
     }
     $user = get_uid_ucuser($uid);
     //獲取本地存儲公眾號粉絲用戶信息
     $this->assign('user', $user);
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     //odata通用訂單數據,訂單數據可以從訂單頁麵提交過來
     $odata['uid'] = $uid;
     $odata['mp_id'] = $params['mp_id'];
     // 當前公眾號在係統中ID
     $odata['order_id'] = "time" . date("YmdHis");
     //
     $odata['order_status'] = 1;
     //不帶該字段-全部狀態, 2-待發貨, 3-已發貨, 5-已完成, 8-維權中
     $odata['order_total_price'] = 1;
     //訂單總價,單位:分
     $odata['buyer_openid'] = $user['openid'];
     $odata['buyer_nick'] = $user['nickname'];
     $odata['receiver_mobile'] = $user['mobile'];
     $odata['product_id'] = 1;
     $odata['product_name'] = "UCToo";
     $odata['product_price'] = 100;
     //商品價格,單位:分
     $odata['product_sku'] = "UCToo_Wxpay";
     $odata['product_count'] = 1;
     $odata['module'] = MODULE_NAME;
     $odata['model'] = "order";
     $odata['aim_id'] = 1;
     $order = D("Order");
     // 實例化order對象
     $order->create($odata);
     // 生成數據對象
     $result = $order->add();
     // 寫入數據
     if ($result) {
         // 如果主鍵是自動增長型 成功後返回值就是最新插入的值
     }
     //獲取公眾號信息,jsApiPay初始化參數
     $info = get_mpid_appinfo($odata['mp_id']);
     $this->options['appid'] = $info['appid'];
     $this->options['mchid'] = $info['mchid'];
     $this->options['mchkey'] = $info['mchkey'];
     $this->options['secret'] = $info['secret'];
     $this->options['notify_url'] = $info['notify_url'];
     $this->wxpaycfg = new WxPayConfig($this->options);
     //①、初始化JsApiPay
     $tools = new JsApiPay($this->wxpaycfg);
     $wxpayapi = new WxPayApi($this->wxpaycfg);
     //②、統一下單
     $input = new WxPayUnifiedOrder($this->wxpaycfg);
     //這裏帶參數初始化了WxPayDataBase
     //  $input->SetAppid($info['appid']);//公眾賬號ID
     //  $input->SetMch_id($info['mchid']);//商戶號
     $input->SetBody($odata['product_name']);
     $input->SetAttach($odata['product_sku']);
     $input->SetOut_trade_no($odata['order_id']);
     $input->SetTotal_fee($odata['order_total_price']);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     // $input->SetGoods_tag("WXG");                      //商品標記,代金券或立減優惠功能的參數
     //  $input->SetNotify_url($info['notify_url']);       //http://test.uctoo.com/index.php/UShop/Index/notify
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($user['openid']);
     $order = $wxpayapi->unifiedOrder($input);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //獲取共享收貨地址js函數參數
     $editAddress = $tools->GetEditAddressParameters();
     //③、在支持成功回調通知中處理成功之後的事宜,見 notify.php
     /**
      * 注意:
      * 1、當你的回調地址不可訪問的時候,回調通知會失敗,可以通過查詢訂單來確認支付是否成功
      * 2、jsapi支付時需要填入用戶openid,WxPay.JsApiPay.php中有獲取openid流程 (文檔可以參考微信公眾平台“網頁授權接口”,
      * 參考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
      */
     $this->assign('order', $odata);
     $this->assign('jsApiParameters', $jsApiParameters);
     $this->assign('editAddress', $editAddress);
     $this->display();
 }
開發者ID:bjjfsd,項目名稱:youweihui,代碼行數:98,代碼來源:IndexController.class.php

示例12: getUnifiedOrder

 /**
  *
  * 生成預支付訂單
  * @param data
  *  + body
  *  + out_trade_no
  *  + total_fee
  *  + product_id
  *  + time_expire
  *  + attach
  *  + openid
  */
 public static function getUnifiedOrder($data)
 {
     $input = new WxPayUnifiedOrder();
     // 商品描述
     $body = '商品付款';
     if ($data['body']) {
         $body = $data['body'];
     }
     $input->SetBody($body);
     // 商戶訂單號
     $input->SetOut_trade_no($data['out_trade_no']);
     // 訂單交易總額
     $input->SetTotal_fee($data['total_fee']);
     // 商品ID
     if ($data['product_id']) {
         $input->SetProduct_id($data['product_id']);
     }
     $input->SetTime_start(date("YmdHis", $data['time_start']));
     // 訂單過期時間,微信最長過期時間可設置為 2 小時,最短為5分鍾
     $input->SetTime_expire(date("YmdHis", strtotime($data['time_start']) + 7200));
     // 訂單通知回調的 url
     $input->SetNotify_url(WxPayConfig::$notify_url);
     // 支付類型:掃碼支付
     $input->SetTrade_type($data['trade_type']);
     // 選填參數設置
     if ($data['attach']) {
         $input->SetAttach($data['attach']);
     }
     // 掃碼支付模式一,第一次微信回調會帶有用戶的 openid,請求生成預支付 id 時需要加入到請求參數內
     if ($data['openid']) {
         $input->SetOpenid($data['openid']);
     }
     return $input;
 }
開發者ID:jiaoyix,項目名稱:jiaoyix-php,代碼行數:46,代碼來源:WxPay.php

示例13: wxJsPay

  private function wxJsPay($request)
  {
    $state = $request->input('state');

    $decodeObject = json_decode($state);

    $user = Auth::user();

    $order_code = $decodeObject->order_code;

    $order = Order::where('code', '=', $order_code)->first();

    if (empty($order->id)) {
    
      //todo
    
    } else if ($order->status > 0) {
    
      return view('mobile/payed');
    
    }

    $good = Good::where('id', '=', $order->gid)->first();

    $orderPrice = OrderPrice::where('oid', '=', $order->id)->first();

    $receiver = ReceiverInfo::find($order->rid);

    require_once "lib/WxPay.Api.php";  

    require_once "lib/WxPay.JsApiPay.php";

    $notify_url = $this->debug ? "http://www.51linpai.com:8000/order/wxpay/" : "http://www.51linpai.com/order/wxpay/";

    $tools = new \JsApiPay();

    $openId = $tools->GetOpenid("", null);

    $input = new \WxPayUnifiedOrder();
    $input->SetBody($good->name);
    $input->SetAttach($good->code);
    $input->SetOut_trade_no($order->code);
    $input->SetTotal_fee($orderPrice->final_price * 100);
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetGoods_tag($good->code);
    $input->SetNotify_url($notify_url);
    $input->SetTrade_type("JSAPI");
    $input->SetOpenid($openId);
    $jsWxOrder = \WxPayApi::unifiedOrder($input);
    $jsApiParameters = $tools->GetJsApiParameters($jsWxOrder);

    //獲取共享收貨地址js函數參數
    $editAddress = $tools->GetEditAddressParameters();

    $data = [

        'editAddress' => $editAddress,

        'jsApiParameters' => $jsApiParameters,

        'order_code' => $order->code,

        'price' => $orderPrice->final_price,

        'address' =>  $receiver->city . ' ' . $receiver->district . ' ' . $receiver->address,

        'step' => 4,

        'header' => '支付訂單'
      
      ];
    
    return view('mobile/wechat_js_pay', $data);
  
  }
開發者ID:kukujiabo,項目名稱:linpai,代碼行數:76,代碼來源:OrdersController.php

示例14: weiXinPay

 /**
  * 微信支付
  * @param $orderId
  * @return array
  * @throws \WxPayException
  */
 public function weiXinPay($orderId)
 {
     //①、獲取用戶openid
     $tools = new \JsApiPay();
     $openId = $tools->GetOpenid();
     if ($openId == -1) {
         return false;
     }
     //②、統一下單
     $orderInfo = ChargeOrder::getInstance()->getOne($orderId);
     $goods = ChargeGoods::getInstance()->getOne($orderInfo['charge_goods_id']);
     $input = new \WxPayUnifiedOrder();
     $input->SetBody("嘉瑞百合緣-【" . $goods['name'] . "】");
     $input->SetAttach("手機網站");
     $input->SetOut_trade_no($orderInfo['order_id']);
     $input->SetTotal_fee((string) $orderInfo['money']);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetNotify_url("http://wechat.baihey.com/wap/charge/notify-url");
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     return ['orderInfo' => $orderInfo, 'jsApiParameters' => $jsApiParameters];
 }
開發者ID:xswolf,項目名稱:baihey,代碼行數:31,代碼來源:ChargeOrder.php

示例15: pay

 public function pay()
 {
     require_once 'Weixinpay/WxPayData.class.php';
     require_once 'Weixinpay/WxPayApi.class.php';
     require_once 'Weixinpay/WxPayJsApiPay.php';
     // require_once ('Weixinpay/log.php');
     $paymentId = $_GET['paymentId'];
     $token = $_GET['token'];
     $body = $_GET['orderName'];
     $orderNo = $_GET['orderNumber'];
     if ($orderNo == "") {
         $orderNo = $_GET['single_orderid'];
     }
     $totalFee = $_GET['price'] * 100;
     // 單位為分
     // $paytype=$_GET['paytype'];
     $tools = new \JsApiPay();
     // $openId = $tools->GetOpenid();
     // $openId=$_GET['wecha_id'];
     // $openId=get_openid();
     // dump($openId);
     // die();
     // // dump($openId);
     //         $openId='orgF0t-HyMrDJHFOl9GAkENyu6i0';
     // dump('45456');
     $openId = $this->getPaymentOpenid();
     //         dump(session('paymentinfo'));
     //         dump($openId);
     //         dump('1232');die;
     // 統一下單
     import('Weixinpay.WxPayData');
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($body);
     // $input->SetAttach("test");
     $input->SetOut_trade_no($orderNo);
     $input->SetTotal_fee($totalFee);
     // $input->SetTime_start(date("YmdHis"));
     // $input->SetTime_expire(date("YmdHis", time() + 600));
     // $input->SetGoods_tag("test");
     $input->SetNotify_url("Weixinpay/notify.php");
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     //         echo '<font color="#f00"><b>統一下單支付單信息</b></font><br/>';
     //dump($order);
     //         die;
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //  dump($jsApiParameters);
     $returnUrl = addons_url('Payment://Weixin/payOK');
     header('Location:' . SITE_URL . '/WxpayAPI/unifiedorder.php?jsApiParameters=' . $jsApiParameters . '&returnurl=' . $returnUrl . '&totalfee=' . $_GET['price'] . '&paymentId=' . $paymentId);
     // echo $jsApiParameters;
     // die;
     // session('jsaparams',$jsApiParameters);
     // $_COOKIE['jsaparams']=$jsApiParameters;
     // $from=$_GET['from'];
     // if($from!='shop'){
     // $from=$this->doFromStr($_GET['from']);
     // }
     // //$returnUrl = '/index.php?g=Wap&m=' . $from . '&a=payReturn&token=' . $_GET ['token'] . '&wecha_id=' . $_GET ['wecha_id'] . '&orderid=' . $orderNo;
     // $returnUrl=addons_url('Payment://Weixin/payOK');
     // //$this->assign ( 'returnUrl', $returnUrl );
     // $this->assign ( 'jsApiParameters', $jsApiParameters );
     // $this->assign ( 'price', $_GET['price'] );
     // die;
     // header('Location:http://'.$_SERVER['HTTP_HOST'].'/weishi/WxpayAPI/unifiedorder.php?body='.$body.'&out_trade_no='.$orderNo.'&totalfee='.$totalFee.'&openid='.$openId.'&returnurl='.$returnUrl);
 }
開發者ID:chenpusn,項目名稱:guoxian,代碼行數:66,代碼來源:WeixinController.class.php


注:本文中的WxPayUnifiedOrder::SetOpenid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。