<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>正在为您跳转到支付页面，请稍候...</title>
    <style type="text/css">
        body {margin:0;padding:0;}
        p {position:absolute;
            left:50%;top:50%;
            width:330px;height:30px;
            margin:-35px 0 0 -160px;
            padding:20px;font:bold 14px/30px "宋体", Arial;
            background:#f9fafc url(../assets/load.gif) no-repeat 20px 26px;
            text-indent:22px;border:1px solid #c5d0dc;}
        #waiting {font-family:Arial;}
    </style>
<script>
function open_without_referrer(link){
document.body.appendChild(document.createElement('iframe')).src='javascript:"<script>top.location.replace(\''+link+'\')<\/script>"';
}
</script>
</head>
<body>
<?php


@header('Content-Type: text/html; charset=UTF-8');
define('SYSTEM_ROOT_E', dirname(__FILE__).'/');
define('SYSTEM_ROOT_INFO', md5($_SERVER['HTTP_HOST']."24K"));
include '../ayangw/common.php';
$paynumber = !empty($_GET['paynumber'])?daddslashes($_GET['paynumber']):exit();

//码支付
if($conf['payapi'] == 5){
	$url = "./msubmit.php?paynumber=".$paynumber;
	exit("<script language='javascript'>window.location.href='".$url."';</script>");

}

if(empty($conf['epay_id'])){
    exit("当前站点没有配置有效的支付接口！");
}
$row = getorder($paynumber);
if($row){
    $type=$row['type'];
}else{
    exit("订单不存在！");
}
if(isset($_SERVER['HTTP_REFERER'])){
    if(strpos($_SERVER['HTTP_REFERER'], "http://".$_SERVER['HTTP_HOST']."/")==0){
    }else{
        exit();
    }
}else{
    exit();
}

if($type=='alipay' || $type=='tenpay' || $type=='qqpay' || $type=='wxpay'){
	require_once(SYSTEM_ROOT_E."epay/epay.config.php");
	require_once(SYSTEM_ROOT_E."epay/epay_submit.class.php");
	$or = $row['out_trade_no'];
	$money = $row['money'];
        $gid = $row['gid'];
        $grow = getgoods($gid);
	$number = $row['number'];
        $allmoney = $grow['price']*$number;
        if(!$grow || round($allmoney,2) != $money){
            exit("商品验证失败");
        }
	$parameter = array(
		"pid" => $conf['epay_id'],//商户ID
		"type" => $type,//支付类型
		"notify_url"	=>"http://".$_SERVER['HTTP_HOST'].'/other/epay_notify.php',//异步通知
		"return_url"	=> "http://".$_SERVER['HTTP_HOST'].'/other/epay_return.php',//回调
		"out_trade_no"	=> $or,//订单编号
		"name"	=> $grow['gName'],//商品名称
		"money"	=> $money,//金额 
		"sitename"	=> $conf['title']//网站名称
	);
	//建立请求
	
	$alipaySubmit = new AlipaySubmit($alipay_config);
	$html_text = $alipaySubmit->buildRequestForm($parameter,"POST", "正在验证订单并跳转...");
	echo $html_text;


}else{
    echo "订单错误！";
}

?>
<p>正在为您跳转到支付页面，请稍候...</p>
</body>
</html>