Ejemplo n.º 1
0
 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     // debug
     Yii::error("\n====================start payorder===================");
     Yii::error($result);
     Yii::error("\n====================end payorder===================");
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         $this->order = $result;
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  *
  * 查询订单,WxPayOrderQuery中out_trade_no、transaction_id至少填一个
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayOrderQuery $inputObj
  * @param int $timeOut
  * @throws WxPayException
  * @return 成功时返回,其他抛异常
  */
 public static function orderQuery($inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/pay/orderquery";
     //检测必填参数
     if (!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) {
         throw new WxPayException("订单查询接口中,out_trade_no、transaction_id至少填一个!");
     }
     $inputObj->SetAppid(WxPayConfig::APPID);
     //公众账号ID
     $inputObj->SetMch_id(WxPayConfig::MCHID);
     //商户号
     $inputObj->SetNonce_str(self::getNonceStr());
     //随机字符串
     $inputObj->SetSign();
     //签名
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //请求开始时间
     $response = self::postXmlCurl($xml, $url, false, $timeOut);
     $result = WxPayResults::Inits($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }