示例#1
0
function printf_info($data)
{
    foreach ($data as $key => $value) {
        echo "<font color='#f00;'>{$key}</font> : {$value} <br/>";
    }
}
if (isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != "") {
    $transaction_id = $_REQUEST["transaction_id"];
    $input = new WxPayOrderQuery();
    $input->SetTransaction_id($transaction_id);
    printf_info(WxPayApi::orderQuery($input));
    exit;
}
if (isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != "") {
    $out_trade_no = $_REQUEST["out_trade_no"];
    $input = new WxPayOrderQuery();
    $input->SetOut_trade_no($out_trade_no);
    printf_info(WxPayApi::orderQuery($input));
    exit;
}
?>
<body>  
	<form action="#" method="post">
        <div style="margin-left:2%;color:#f00">微信订单号和商户订单号选少填一个,微信订单号优先:</div><br/>
        <div style="margin-left:2%;">微信订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="transaction_id" /><br /><br />
        <div style="margin-left:2%;">商户订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_trade_no" /><br /><br />
		<div align="center">
			<input type="submit" value="查询" style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" onclick="callpay()" />
		</div>
示例#2
0
 /**
  * 
  * 查询订单,WxPayOrderQuery中out_trade_no、transaction_id至少填一个
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param base\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::Init($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }