<?
session_start();

$NotTransChar = 1; //不进行繁简转换,否则 Md5 校验可能会出错
require_once("../common/init.php");
require_once("security.inc.php");

$Amount = $_POST['Amount'];
$paycode = $_POST['paycode'];

$EnableNetPay = ($_CFG[PayOnline]==1)?"1":"0";
if(!$EnableNetPay){
   $db->close();
   die("<script>alert('没有开通网上支付功能');history.back()</script>");
}
$Amount = floatval($Amount);

$sql = "select * from payment_type where pay_code='$paycode' and status>0";
$payment_info = $db->getRow($sql);

if(!$payment_info) die("<script>alert('找不到您所选的支付方式1');history.back()</script>");
/* 调用相应的支付方式文件 */
if(!file_exists(COMMON_DIR . 'payment/' . $payment_info['pay_code'] . '.php'))
	die("<script>alert('找不到您所选的支付方式2');history.back()</script>");
include_once(COMMON_DIR . 'payment/' . $payment_info['pay_code'] . '.php');

//取得支付信息，生成支付代码
$payment_config = unserialize_config($payment_info['pay_config']);

$u_amount = number_format($Amount,2, '.', '');
$order_info['order_amount'] = $Amount;
$sql="insert into onlinepay set UserName='$_SESSION[User_S]',amount='$u_amount',`datetime`=now(), paymode='$paycode'";
$db->query($sql);
$order_info['log_id'] = $db->insert_id();

/* 取得在线支付方式的支付按钮 */
$pay_obj = new $payment_info['pay_code'];
$payment_info['pay_button'] = $pay_obj->get_code($order_info, $payment_config);

if($OrderID)$_SESSION['PayOrderID']  = $OrderID;
echo $payment_info['pay_button'];
$db->close();
exit();
?>