<?php
require("../class/connect.php");
require("../class/q_functions.php");
require("../member/class/user.php");
eCheckCloseMods('pay');//關閉模塊
$link=db_connect();
$empire=new mysqlquery();
//支付平台
$paytype=RepPostVar($_GET['paytype']);
if(!$paytype)
{
	printerror('請選擇支付平台','',1,0,1);
}
$payr=$empire->fetch1("select * from {$dbtbpre}enewspayapi where paytype='$paytype' and isclose=0".do_dblimit_one());
if(!$payr['payid'])
{
	printerror('請選擇支付平台','',1,0,1);
}
$ddno='';
$productname='';
$productsay='';

include('payfun.php');

//訂單信息
$ddid=(int)getcvar('paymoneyddid');
$ddr=PayApiShopDdMoney($ddid);
$money=(float)$ddr['tmoney'];
if($money<=0)
{
	printerror('訂單金額有誤','',1,0,1);
}
//支付參數
$prdr=array();
$prdr['userid']=0;
$prdr['username']='';
$prdr['orderid']='';
$prdr['money']=$money;
$prdr['posttime']='';
$prdr['paybz']='';
$prdr['paytype']=$payr['paytype'];
$prdr['payip']='';
$prdr['ispay']=0;
$prdr['paydo']='ShopPay';
$prdr['payfor']=$ddid;
$prdr['payckcode']='';
$prdr['endtime']='';
//支付參數
//會員
$ckuserid=(int)getcvar('mluserid');
$ckusername=RepPostVar(getcvar('mlusername'));
$user=array();
if($ckuserid)
{
	$user=islogin();//是否登錄
	$prdr['userid']=$user['userid'];
	$prdr['username']=$user['username'];
}
//支付參數
$ddno=RepPostVar($ddr['ddno']);
$prdr['pname']="購物,支付訂單號:".$ddno;
$prdr['psay']="購物,訂單號:".$ddno;
$prdr['payddno']=epayapi_ReturnDdno($prdr['userid']);
$ddno=$prdr['payddno'];

$productname=$prdr['pname'];
$productsay=$prdr['psay'];

esetcookie("payphome","ShopPay",0);
//返回地址前綴
$PayReturnUrlQz=$public_r['newsurl'];
if(!stristr($public_r['newsurl'],'://'))
{
	$PayReturnUrlQz=eReturnDomain().$public_r['newsurl'];
}
//char
$iconv='';
$char='';
$targetchar='';
/*
if($ecms_config['sets']['pagechar']!='gb2312')
{
	$char=$ecms_config['sets']['pagechar']=='big5'?'BIG5':'UTF8';
	$targetchar='GB2312';
	$productname=DoIconvVal($char,$targetchar,$productname);
	$productsay=DoIconvVal($char,$targetchar,$productsay);
	@header('Content-Type: text/html; charset=gb2312');
}
*/
//記錄
$re_prdr=epayapi_AddPayRecord($prdr);
$prdr['id']=$re_prdr['id'];
$prdr['payckcode']=$re_prdr['payckcode'];
$prdr['posttime']=$re_prdr['posttime'];
$prdr['payip']=$re_prdr['payip'];

eCheckStrType(4,$payr['paytype'],1);
$file=$payr['paytype'].'/to_pay.php';
@include($file);
db_close();
$empire=null;
?>