//
//
//
//
//
//
//
//
//
//
//
//
//
//1
//
//
//';
fcgi_header("Content-Type: text/html; charset=UTF-8");
try {
$content = $_SERVER['post_content'];
Log::record("content = {$content}", Log::DEBUG);
$result = OpenWxPayResults::Init($content);
$ret_wx = [];
$ret_code = $result['result_code'];
Log::record("result_code= {$ret_code}", Log::DEBUG);
if ($ret_code == 'SUCCESS') {
$out_trade_no = $result['out_trade_no'];
$pay_sn = $result['attach'];
$trade_no = $result['transaction_id'];
Log::record("out_trade_no={$out_trade_no} and pay_sn={$pay_sn} and trade_no = {$trade_no}", Log::DEBUG);
$payer = new pay_helper($pay_sn);
$cb_info = $payer->update_order($trade_no, 'wxpay');
if ($cb_info['state'] == false) {
Log::record('wxpay error.', Log::DEBUG);
} else {
Log::record('wxpay success.', Log::DEBUG);
if (is_pushoms()) {
$logic_delivery = Logic('delivery');
$ret = $logic_delivery->putOrder($pay_sn, $trade_no);
}
$payer->OnSuccess();
}
$ret_wx['return_code'] = 'SUCCESS';
$ret_wx['return_msg'] = 'OK';
} else {
Log::record('wxpay error 2.', Log::DEBUG);
$ret_wx['return_code'] = 'FAIL';
$ret_wx['return_msg'] = 'Error.';
}
$retoper = new OpenWxPayResults();
$retoper->FromArray($ret_wx);
$xml = $retoper->ToXml();
Log::record("return to wx= {$xml}", Log::DEBUG);
echo($xml);
} catch (OpenWxPayException $e) {
Log::record($e->getTraceAsString(), Log::ERR);
$msg = $e->errorMessage();
return false;
}