//
//
//
//
//
//
//
//
//
//
//
//
//
//1
//
//
//';
fcgi_header("Content-Type: text/html; charset=UTF-8");
try
{
$content = $_SERVER['original_querystring'];//request_helper::content();
wxLog::DEBUG("content = {$content}");
$result = WxPayResults::Init($content);
$ret_wx = array();
$ret_code = $result['result_code'];
Log::record("result_code= {$ret_code}",Log::DEBUG);
wxLog::DEBUG("result_code= {$ret_code}");
if($ret_code == 'SUCCESS')
{
$out_trade_no = $result['out_trade_no']; // 给微信用的随机商户订单SN
$attach = $result['attach']; // 真正的我们平台的订单SN号
$transaction_id=$result['transaction_id'];
wxLog::DEBUG("out_trade_no={$out_trade_no} and attach={$attach} and transaction_id = {$transaction_id}");
Log::record("out_trade_no={$out_trade_no} and attach={$attach} and transaction_id = {$transaction_id}",Log::DEBUG);
$cb_info = app_payControl::update_order($attach,$transaction_id,'wxpay');
if($cb_info['state'] == false) {
wxLog::ERROR('wxpay error 1.');
Log::record('wxpay error.',Log::DEBUG);
} else {
wxLog::DEBUG('wxpay success.');
Log::record('wxpay success.',Log::DEBUG);
$logic_delivery = Logic('delivery');
$ret = $logic_delivery->putOrder($attach, $transaction_id);
}
$ret_wx['return_code'] = 'SUCCESS';
$ret_wx['return_msg'] = 'OK';
} else {
Log::record('wxpay error 2.',Log::DEBUG);
wxLog::ERROR('wxpay error 2.');
$ret_wx['return_code'] = 'FAIL';
$ret_wx['return_msg'] = 'Error.';
}
$retoper = new WxPayResults();
$retoper->FromArray($ret_wx);
$xml = $retoper->ToXml();
wxLog::DEBUG($xml);
Log::record("return to wx= {$xml}",Log::DEBUG);
echo($xml);
} catch (WxPayException $e){
Log::record($e->getTraceAsString(),Log::ERR);
wxLog::DEBUG($e->getTraceAsString());
$msg = $e->errorMessage();
return false;
}