//
//
//
//
//
//
//
//
//
//
//
//
//
//1
//
//
//';
echo("Content-Type: text/html; charset=UTF-8\r\n\r\n");
try
{
$content = $_POST['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'];
$transaction_id=$result['transaction_id'];
wxLog::DEBUG("out_trade_no={$out_trade_no} and transaction_id = {$transaction_id}");
Log::record("out_trade_no={$out_trade_no} and transaction_id = {$transaction_id}",Log::DEBUG);
$cb_info = app_payControl::update_order($out_trade_no,$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($out_trade_no, $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;
}