<?php
ini_set('date.timezone','Asia/Shanghai');
error_reporting(E_ERROR);
require_once "../lib/WxPay.Api.php";
require_once '../lib/WxPay.Notify.php';
require_once 'log.php';
//session_start();
//初始化日志
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
$log = Log::Init($logHandler, 15);
Log::DEBUG("第1步");
class PayNotifyCallBack extends WxPayNotify
{
//查询订单
public function Queryorder($transaction_id)
{
$input = new WxPayOrderQuery();
$input->SetTransaction_id($transaction_id);
$result = WxPayApi::orderQuery($input);
Log::DEBUG("query:" . json_encode($result));
Log::DEBUG("第2步");
if(array_key_exists("return_code", $result)
&& array_key_exists("result_code", $result)
&& $result["return_code"] == "SUCCESS"
&& $result["result_code"] == "SUCCESS")
{
/*******************************下面是自己写的************************************************************************************/
include '../../../../conn/conn.php' ;
include 'notify_function.php';
$OrderNo = '202501061647228429';
//$OrderNo = $_REQUEST['order_no'];
//echo $OrderNo;
//$OrderNo = $result['out_trade_no'];
order_notify($OrderNo);
user_notify($OrderNo);
/*
include '../../../../conn/conn.php' ;
include 'notify_function.php';
// $channel = 'weixin_pay';
//$trade_no = $result['transaction_id'];
//$total_fee = $result['total_fee']/100;
//$seller_id = $result['mch_id'];
//echo $result["result_code"];
$OrderNo = $result['out_trade_no'];
//echo $OrderNo;
// 处理数据库 OrderNo系统订单号,trade_no支付宝交易号,total_fee交易金额,seller_id 支付宝返回的商户号,channel付款渠道
//notify_url($trade_no,$OrderNo,$total_fee,$seller_id,$pid,$channel);
*/
/*******************************上面是自己写的****************************************************************************/
return true;
}
return false;
}
//重写回调处理函数
public function NotifyProcess($data, &$msg)
{
Log::DEBUG("call back:" . json_encode($data));
$notfiyOutput = array();
if(!array_key_exists("transaction_id", $data)){
$msg = "输入参数不正确";
return false;
}
//查询订单,判断订单真实性
if(!$this->Queryorder($data["transaction_id"])){
$msg = "订单查询失败";
return false;
}
return true;
}
}
Log::DEBUG("begin notify");
$notify = new PayNotifyCallBack();
$notify->Handle(false);
?>
没看懂你前面引用的是什么,用下面这个方法就可以接收的
$input = file_get_contents('php://input');
<?php // 接收微信支付通知 $input = file_get_contents('php://input'); $data = json_decode($input, true); // 记录日志 $logFile = 'wechat_pay_logs.txt'; file_put_contents($logFile, print_r($data, true), FILE_APPEND); // 响应微信支付平台 $response = [ 'code' => 'SUCCESS', 'message' => 'OK', ]; echo json_encode($response);