Ejemplo n.º 1
0
 private function create_biz_package($appId, $paySignKey, $partnerId, $partnerKey)
 {
     try {
         if ($this->check_cft_parameters() == false) {
             throw new Exception("生成package参数缺失!" . "<br>");
         }
         $nativeObj["appId"] = $appId;
         $nativeObj["package"] = $this->get_cft_package($partnerKey);
         $nativeObj["timeStamp"] = strval(time());
         $nativeObj["nonceStr"] = weixin_util::create_noncestr();
         $nativeObj["paySign"] = $this->get_biz_sign($nativeObj, $paySignKey);
         $nativeObj["signType"] = $this->signtype;
         return json_encode($nativeObj);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 private function create_biz_package($appId, $paySignKey, $partnerId, $partnerKey)
 {
     try {
         if ($this->check_cft_parameters() == false) {
             throw new Exception("生成package参数缺失!" . "<br>");
         }
         $nativeObj["appId"] = $appId;
         $nativeObj["package"] = $this->get_cft_package($partnerKey);
         $nativeObj["timeStamp"] = strval(time());
         $nativeObj["nonceStr"] = weixin_util::create_noncestr();
         if (isset($_REQUEST['method']) && $_REQUEST['method'] == 'mobileapi.paycenter.dopayment') {
             $nativeObj["traceid"] = 'wxpay_id_' . $this->fields['out_trade_no'];
         }
         $nativeObj["paySign"] = $this->get_biz_sign($nativeObj, $paySignKey);
         $nativeObj["signType"] = $this->signtype;
         if (isset($_REQUEST['method']) && $_REQUEST['method'] == 'mobileapi.paycenter.dopayment') {
             $nativeObj["paySignKey"] = $paySignKey;
             return $nativeObj;
         }
         return json_encode($nativeObj);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Ejemplo n.º 3
0
 function vod_uploadkey()
 {
     $rnd = strtolower(weixin_util::create_noncestr(16));
     $key = md5($rnd . '视频上传') . $rnd;
     return $key;
 }
Ejemplo n.º 4
0
 /**
  * 提交支付信息的接口
  * @param array 提交信息的数组
  * @return mixed false or null
  */
 public function dopay($payment)
 {
     $appid = trim($this->getConf('appId', __CLASS__));
     $mch_id = trim($this->getConf('Mchid', __CLASS__));
     $key = trim($this->getConf('Key', __CLASS__));
     bcscale(2);
     $parameters = array('appid' => strval($appid), 'openid' => strval($_GET['openid']), 'body' => strval(str_replace(' ', '', isset($payment['body']) && $payment['body'] ? $payment['body'] : app::get('weixin')->_('网店订单'))), 'out_trade_no' => strval($payment['payment_id']), 'total_fee' => bcadd($payment['cur_money'], 0) * 100, 'notify_url' => strval($this->notify_url), 'trade_type' => 'JSAPI', 'mch_id' => strval($mch_id), 'nonce_str' => weixin_util::create_noncestr(), 'spbill_create_ip' => strval($_SERVER['REMOTE_ADDR']));
     $parameters['sign'] = $this->getSign($parameters, $key);
     $xml = $this->arrayToXml($parameters);
     $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
     $response = $this->postXmlCurl($xml, $url, 30);
     $result = $this->xmlToArray($response);
     $prepay_id = $result['prepay_id'];
     // 用于微信支付后跳转页面传order_id,不作为传微信的字段
     $this->add_field("appId", $appid);
     $this->add_field("timeStamp", strval(time()));
     $this->add_field("nonceStr", weixin_util::create_noncestr());
     $this->add_field("package", 'prepay_id=' . $prepay_id);
     $this->add_field("signType", "MD5");
     $this->add_field("paySign", $this->getSign($this->fields, $key));
     $this->add_field("jsApiParameters", json_encode($this->fields));
     $this->add_field("order_id", $payment['order_id']);
     echo $this->get_html();
     exit;
 }