Пример #1
0
 /**
  *
  * 测速上报,该方法内部封装在report中,使用时请注意异常流程
  * WxPayReport中interface_url、return_code、result_code、user_ip、execute_time_必填
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayReport $inputObj
  * @param int $timeOut
  * @throws WxPayException
  * @return 成功时返回,其他抛异常
  */
 public function report($inputObj, $timeOut = 1)
 {
     $url = "https://api.mch.weixin.qq.com/payitil/report";
     //检测必填参数
     if (!$inputObj->isInterfaceUrlSet()) {
         throw new WxPayException("接口URL,缺少必填参数interface_url!");
     }
     if (!$inputObj->isReturnCodeSet()) {
         throw new WxPayException("返回状态码,缺少必填参数return_code!");
     }
     if (!$inputObj->isResultCodeSet()) {
         throw new WxPayException("业务结果,缺少必填参数result_code!");
     }
     if (!$inputObj->isUserIpSet()) {
         throw new WxPayException("访问接口IP,缺少必填参数user_ip!");
     }
     if (!$inputObj->isExecuteTimeSet()) {
         throw new WxPayException("接口耗时,缺少必填参数execute_time_!");
     }
     $inputObj->setAppid($this->apiConfig->appid);
     //公众账号ID
     $inputObj->setMchId($this->apiConfig->mchid);
     //商户号
     $inputObj->setMchKey($this->apiConfig->mchkey);
     //商户密钥
     $inputObj->setUserIp($_SERVER['REMOTE_ADDR']);
     //终端ip
     $inputObj->setTime(date("YmdHis"));
     //商户上报时间
     $inputObj->setNonceStr($this->getNonceStr());
     //随机字符串
     $inputObj->setSign();
     //签名
     $xml = $inputObj->toXml();
     $startTimeStamp = $this->getMillisecond();
     //请求开始时间
     $response = $this->postXmlCurl($xml, $url, false, $timeOut);
     return $response;
 }