微信支付demo订单查询文件 payment/example/orderquery.php
header("Access-Control-Allow-Origin:*"); // 因为撸主的支付实在另外一台服务器上,所以给了一个域头 ini_set(\'date.timezone\',\'Asia/Shanghai\');// 设置一下时区 error_reporting(E_ERROR); // 关闭报错 require_once "../lib/WxPay.Api.php"; require_once \'log.php\'; //初始化日志 $logHandler= new CLogFileHandler("./logs/".date(\'Y-m-d\').\'.log\'); $log = Log::Init($logHandler, 15); function printf_info($data) { foreach($data as $key=>$value){ echo "<font color=http://www.likecs.com/\'#f00;\'>$key</font> : $value <br/>"; } } // 一下两个if的判断均为判断订单的状态,这里撸主建议去微信官网进行查阅,下面有传送门送你过去 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)); $result=WxPayApi::orderQuery($input); echo $result[\'trade_state\']; 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)); $result=WxPayApi::orderQuery($input); $status[\'code\'] = $result[\'trade_state\']; $status[\'openid\'] = $result[\'openid\']; $status[\'total_fee\'] = $result[\'total_fee\']; $status[\'transaction_id\'] = $result[\'transaction_id\']; $status[\'time\'] = $result[\'time_end\']; //print_r($result); print_r(json_encode($status)); exit(); }传送门 微信返回错误代码解释