<?php

//---------------------------------------------------------
//QQ钱包支付即时到帐支付后台回调示例，商户按照此文档进行开发即可
//---------------------------------------------------------
require_once(__DIR__ . '/inc.php');
require_once(SYSTEM_ROOT.'qqpay/qpayNotify.class.php');
@header('Content-Type: text/html; charset=UTF-8');

$qpayNotify = new QpayNotify();
$result = $qpayNotify->getParams();
if($qpayNotify->verifySign()) {
	if($result['trade_state'] == "SUCCESS") {
		$out_trade_no = daddslashes($result['out_trade_no']);
		$transaction_id = daddslashes($result['transaction_id']);
		$total_fee = $result['total_fee'];
		$fee_type = $result['fee_type'];
		
		$srow=$DB->getRow("SELECT * FROM pre_pay WHERE trade_no='{$out_trade_no}' LIMIT 1");
		
		if($srow['status']==0){
			if($DB->exec("UPDATE `pre_pay` SET `status` ='1' WHERE `trade_no`='{$out_trade_no}'")){
				$DB->exec("UPDATE `pre_pay` SET `endtime` ='$date',`api_trade_no` ='$transaction_id' WHERE `trade_no`='{$out_trade_no}'");
				processOrder($srow);
			}
		}
		echo "<xml>
<return_code>SUCCESS</return_code>
</xml>";
	} else {
		echo "<xml>
<return_code>FAIL</return_code>
</xml>";
	}

} else {
	echo "<xml>
<return_code>FAIL</return_code>
<return_msg>签名失败</return_msg>
</xml>";
}

 

?>