[TOC]
官方文档: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_2
## 函数
```
/**
* 微信订单查询
* 注:微信订单号和商户订单号选少填一个,微信订单号优先
* @param $transaction_id 微信订单号
* @param $out_trade_no 商户订单号
*/
function wxpayQuery($transaction_id,$out_trade_no)
{
//导入 WxPay.Api.php 类
import('WxpayAPI.lib.WxPay',EXTEND_PATH,'.Api.php');
//导入 WxPay.Data.php 类
import('WxpayAPI.lib.WxPay',EXTEND_PATH,'.Data.php');
$input = new WxPayOrderQuery();
$input->SetOut_trade_no($transaction_id);
$input->SetOut_trade_no($out_trade_no);
return WxPayApi::orderQuery($input);
}
```
## 使用方法:
```
//微信支付 - 订单查询
public function payOrder()
{
$result = wxpayQuery('4200000011201709193042132589','2017091910048541');
dump($result);
}
```
## 返回的数据:
```
array(19) {
["appid"] => string(18) "wx92dedc49b3405e25"
["attach"] => array(0) {
}
["bank_type"] => string(11) "ICBC_CREDIT"
["cash_fee"] => string(3) "100"
["fee_type"] => string(3) "CNY"
["is_subscribe"] => string(1) "Y"
["mch_id"] => string(10) "1404807102"
["nonce_str"] => string(16) "TJCtoX0EuXsp2u8n"
["openid"] => string(28) "o_eLbwM_tFJG2JRd2MhcSU1JwOCw"
["out_trade_no"] => string(16) "2017091910048541"
["result_code"] => string(7) "SUCCESS"
["return_code"] => string(7) "SUCCESS"
["return_msg"] => string(2) "OK"
["sign"] => string(32) "F19F72447F3C6FC070C0F4F339506342"
["time_end"] => string(14) "20170919183908"
["total_fee"] => string(3) "100"
["trade_state"] => string(7) "SUCCESS"
["trade_type"] => string(6) "NATIVE"
["transaction_id"] => string(28) "4200000011201709193042132589"
}
```
## 官网参考
![mark](http://qiniu.newthink.cc/blog/20170920-103322542.png)