Authored by 郝肖肖

微信支付日志

<?php
namespace WebPlugin\Pay\weixin\lib;
use WebPlugin\PhpLog;
use WebPlugin\UdpLog;
use Api\Yohobuy;
/**
*
... ... @@ -12,10 +12,6 @@ use Api\Yohobuy;
*/
class WxPayApi
{
// 向ERP提交订单状态有关接口调用日志和更新订单状态有关接口调用日志
const ORDER_STATUS_LOG = '/Data/logs/pc_pay/order_status';
// 日志等级,2表示记录信息等级的日志
const LOG_LEVEL = 2;
/**
*
... ... @@ -412,13 +408,9 @@ class WxPayApi
*/
public static function notify($callback, &$msg)
{
// 初始化日志
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
$log->LogInfo('begin WxPayApi->notify');
//获取通知的数据
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
$log->LogInfo(var_export($xml));
UdpLog::info("【微信支付结果通用通知XML】,function:notify,参数", $xml);
//如果返回成功则验证签名
try {
$result = WxPayResults::Init($xml);
... ... @@ -426,7 +418,7 @@ class WxPayApi
$msg = $e->errorMessage();
return false;
}
$log->LogInfo(var_export($result, true));
UdpLog::info("【微信支付结果通用通知】,function:notify,参数", $result);
return call_user_func($callback, $result);
}
... ...
<?php
namespace WebPlugin\Pay\weixin\lib;
use WebPlugin\PhpLog;
use WebPlugin\UdpLog;
/**
*
... ... @@ -11,10 +11,6 @@ use WebPlugin\PhpLog;
*/
class WxPayNotify extends WxPayNotifyReply
{
// 向ERP提交订单状态有关接口调用日志和更新订单状态有关接口调用日志
const ORDER_STATUS_LOG = '/Data/logs/pc_pay/order_status';
// 日志等级,2表示记录信息等级的日志
const LOG_LEVEL = 2;
/**
*
... ... @@ -23,22 +19,19 @@ class WxPayNotify extends WxPayNotifyReply
*/
final public function Handle($needSign = true)
{
// 初始化日志
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
$log->LogInfo('begin WxPayNotify->Handle');
$msg = "OK";
//当返回false的时候,表示notify中调用NotifyCallBack回调失败获取签名校验失败,此时直接回复失败
$result = WxPayApi::notify(array($this, 'NotifyCallBack'), $msg);
$log->LogInfo(var_export($result, true));
UdpLog::info("【微信扫码支付Handle】,function:Handle,结果", $result);
if ($result == false) {
$log->LogInfo('===微信扫码支付Handle失败===');
$this->SetReturn_code("FAIL");
$this->SetReturn_msg($msg);
$this->ReplyNotify(false);
return;
} else {
$log->LogInfo('===微信扫码支付Handle成功===');
//该分支在成功回调到NotifyCallBack方法,处理完成之后流程
$this->SetReturn_code("SUCCESS");
$this->SetReturn_msg("OK");
... ... @@ -70,23 +63,19 @@ class WxPayNotify extends WxPayNotifyReply
*/
final public function NotifyCallBack($data)
{
// 初始化日志
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
$log->LogInfo('begin WxPayNotify->NotifyCallBack');
$log->LogInfo(var_export($data, true));
$msg = "OK";
$result = $this->NotifyProcess($data, $msg);
UdpLog::info("【微信扫码支付NotifyCallBack】,function:NotifyCallBack,结果", $result);
if ($result == true) {
$log->LogInfo('===微信支付NotifyCallBack成功===');
$this->SetReturn_code("SUCCESS");
$this->SetReturn_msg("OK");
} else {
$log->LogInfo('===微信支付NotifyCallBack失败===');
$this->SetReturn_code("FAIL");
$this->SetReturn_msg($msg);
}
return $result;
}
... ...
... ... @@ -8,7 +8,7 @@
*/
namespace WebPlugin\Pay\weixin\lib;
use WebPlugin\PhpLog;
use WebPlugin\UdpLog;
/**
*
... ... @@ -18,10 +18,6 @@ use WebPlugin\PhpLog;
*/
class WxPayResults extends WxPayDataBase
{
// 向ERP提交订单状态有关接口调用日志和更新订单状态有关接口调用日志
const ORDER_STATUS_LOG = '/Data/logs/pc_pay/order_status';
// 日志等级,2表示记录信息等级的日志
const LOG_LEVEL = 2;
/**
*
... ... @@ -85,12 +81,12 @@ class WxPayResults extends WxPayDataBase
*/
public static function Init($xml)
{
// 初始化日志
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
$log->LogInfo('begin WxPayResults::notify');
$obj = new self();
$obj->FromXml($xml);
UdpLog::info("【微信支付-xml转为array】,function:Init,参数", $obj);
//fix bug 2015-06-29
if ($obj->values['return_code'] != 'SUCCESS') {
return $obj->GetValues();
... ...
... ... @@ -12,18 +12,18 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
define('EXHIBITION_TICKET', 512578896);//展览票skn
#test环境
//define('API_URL', 'http://testapi.yoho.cn:28078/');
//define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
//define('YOHOBUY_URL', 'http://www.yohobuy.com/');
//define('SERVICE_NOTIFY', 'http://testservice.yoho.cn:28077/');
//define('API_OLD', 'http://test2.open.yohobuy.com/');
define('API_URL', 'http://testapi.yoho.cn:28078/');
define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
define('SERVICE_NOTIFY', 'http://testservice.yoho.cn:28077/');
define('API_OLD', 'http://test2.open.yohobuy.com/');
#dev环境
define('API_URL', 'http://devapi.yoho.cn:58078/');
define('SERVICE_URL', 'http://devservice.yoho.cn:58077/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
define('SERVICE_NOTIFY', 'http://test2.open.yohobuy.com/');
define('API_OLD', 'http://devservice.yoho.cn:58077/');
// define('API_URL', 'http://devapi.yoho.cn:58078/');
// define('SERVICE_URL', 'http://devservice.yoho.cn:58077/');
// define('YOHOBUY_URL', 'http://www.yohobuy.com/');
// define('SERVICE_NOTIFY', 'http://test2.open.yohobuy.com/');
// define('API_OLD', 'http://devservice.yoho.cn:58077/');
$application = new Application(APPLICATION_PATH . '/configs/application.developer.ini');
$application->bootstrap()->run();
\ No newline at end of file
... ...