<?php
/////////////////////////////////////////////////////////////////////////////
// 此文件是 ShopNC多用户商城 的一部分
//
// Copyright (c) 2007 - 2008 www.shopnc.net 
//
// 要查看完整的版权信息和许可信息，请查看源代码中附带的 COPYRIGHT 文件，
// 或者访问 http://www.shopnc.net/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : index.php   FILE_PATH : E:\www\multishop\trunk\payment\tenpay\index.php
 * ....财付通支付方式链接跳转
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author ShopNC Develop Team
 * @package 
 * @subpackage 
 * @version Thu May 08 10:17:14 CST 2008
 */

include("../../global.inc.php");//加载信息

class tenpayIndex extends CommonFrameWork{
	/**
	 * 会员对象
	 *
	 * @var obj
	 */
	var $obj_member;
	/**
	 * 预存款对象
	 *
	 */
	var $obj_predeposit;

	function main(){
		if($_SESSION['s_login']['id'] == ''){
			$this->redirectPath("error","",$this->_lang['langCMemberIsEmpty']);
		}
		if ($this->_input['predeposit_r_id'] == ''){
			$this->redirectPath("error","",$this->_lang['langCIdIsIllegal']);
		}
		/**
		 * 加载语言包
		 */
		$this->getlang('own_predeposit');
		
		/**
		 * 创建会员对象
		 */
		if (!is_object($this->obj_member)){
			require_once ("member.class.php");
			$this->obj_member = new MemberClass();
		}
		/**
		 * 初始化预存款类
		 */
		if (!is_object($this->obj_predeposit)){
			require_once("predeposit.class.php");
			$this->obj_predeposit = new PredepositClass();
		}
		//验证信息是否与会员相符
		$record_array = $this->obj_predeposit->getOnePredepositRecordById($this->_input['predeposit_r_id']);
		if ($record_array['member_id'] != $_SESSION['s_login']['id']){
			$this->redirectPath("error","",$this->_lang['langCIdIsIllegal']);
		}
		if (strtoupper($this->_configinfo['websit']['ncharset']) == 'UTF-8'){
			$this->_lang['langPredepositPay'] = Common::nc_change_charset($this->_lang['langPredepositPay'],'utf8_to_gbk');
		}
		//参数
		$array = array();
		$array['desc'] = $this->_lang['langPredepositPay'];//商品名称
		$array['sp_billno'] = $record_array['predeposit_r_id'];//订单号
		$array['total_fee'] = $record_array['online_amount']*100;//商品价格,单位为分
		$array['transport_desc'] = $this->_lang['langPredepositPay'];//物流说明

		return $array;
	}
}

$tenpay_index = new tenpayIndex();
$tenpay_param = $tenpay_index->main();
//路径输出
	require_once("md5_request.php");
	$tenpay = new tenpay_online_payment;
	$url = $tenpay->tenpay_interface_pay ("0","$tenpay_param[desc]","",$tenpay_param['sp_billno'],$tenpay_param['total_fee'],"",$_SERVER["REMOTE_ADDR"]);
//if($tenpay_param['sp_billno'] !== ''){
//	$url = 'https://www.tenpay.com/med/tradeDetail.shtml?b=1&trans_id='.$tenpay_param['sp_billno'];
//}else{
//	
//}

header("location: $url");exit;
?>
