<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"

%>
<!--#include file="classes/MediPayRequestHandler.asp"-->
<!--#include file="../../conn.asp"-->
<!--#include file="../../config.asp"-->

<body bgcolor=#FCFCFC leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<% dim  goods,sum,opayid
goods=saferequest("paygood",1)
sum=saferequest("paysum",1)
opayid=5


Function GetLocationURL() 
Dim Url 
Dim ServerPort,ServerName,ScriptName,QueryString 
ServerName = Request.ServerVariables("SERVER_NAME") 
ServerPort = Request.ServerVariables("SERVER_PORT") 
ScriptName = Request.ServerVariables("SCRIPT_NAME") 
QueryString = Request.ServerVariables("QUERY_STRING") 
Url="http://"&ServerName 
If ServerPort <> "80" Then Url = Url & ":" & ServerPort 
Url=Url&ScriptName 
Url=replace(Url,"index.asp","")
GetLocationURL=Url 
End Function 


action=FormatSQL(SafeRequest("action",0))

set rs=server.CreateObject("adodb.recordset")
rs.open "select opayid,opayname,opaypassword,opayrturl,opayparter from sdx_opay where opayid="&opayid,conn,1,1
payid=rs("opayname")
paypwd=rs("opaypassword")
payurl=GetLocationURL()&rs("opayrturl")
payparter=rs("opayparter")
rs.close
set rs=nothing


select case action
Case "1"
%> 

<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#ECECEC>
          <TD  height="20" colspan="2"></TD>
        </TR>
   <TR >
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp</TD>
        </TR>
    

   </TBODY>
  </TABLE>
  <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD  height="50"><IMG src="images/payment.gif" border=0></TD>
        </TR>

   
   </TBODY>
  </TABLE>

   <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD bgcolor=#FF5900 height="28" colspan="2" align="center">财付通支付网关</TD>
        </TR>

   
   </TBODY>
  </TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
     <TR bgcolor=#FFD350>
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp您现在[<%=webname%>]在线支付给<%=payid %>网址:(<%=weburl%>)</TD>
        </TR>

   
   </TBODY>
  </TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" bgcolor=#f1f1f1>
       
     <TBODY>
      <form name="alipayment" method="post" action="index.asp?action=2">
         
       
          <TR bgcolor=#ffffff>
          
          <TD height="30">&nbsp 商品订单：</TD>
          <TD height="30"><%=goods%>
          <input type="hidden" name="shopname"  size="30" value="<%=goods%>">

    </TD>
      </TR>
      
          
        <TR bgcolor=#ffffff>
          
         
          <TD  height="30">&nbsp 付款金额：</TD>
         <TD height="30"> <%=FormatNumber(sum)%>元
          <input type="hidden" name="shopsum"  size="30" value="<%=sum%>">

        </TD>
         </TR>           
         
        <TR bgcolor=#ffffff>
          
          <TD  height="30"> &nbsp 客户留言：</TD>
          <TD height="30"><textarea name="shopbody" cols="60" rows="4">暂无</textarea><br>（如联系方法，商品要求、数量等。50汉字内）</TD></TR>

         <TR bgcolor=#F5F5B8>
         
          <TD height="30" colspan="2">&nbsp &nbsp <input type="Submit" name="aliorder"  size="30" value="确   认"  onClick="return CheckForm();"></TD></TR>
   </FORM>
   </TBODY>

</TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>

   <TR >
          <TD  height="60" colspan="2">&nbsp&nbsp&nbsp</TD>
        </TR>
     <TR bgcolor=#ECECEC>
          <TD  height="5" colspan="2"></TD>
        </TR>

      <TR >
          <TD  height="40" colspan="2" align="center"><IMG src="images/logo.gif" border=0>	</TD>
        </TR>
   </TBODY>
  </TABLE>
<%
Case "2"
 Response.Charset="GB2312" 
dim shopsum,shopname,shopbody
shopname      =     sqlCheckstr(request.form("shopname")) 
shopsum       =     sqlCheckstr(request.form("shopsum"))
shopbody      =     sqlCheckstr(request.form("shopbody"))

str_name               =  shopname
str_payid              =  payid
str_paypwd             =  paypwd
str_payurl             =  payurl
str_opayrturl          =  opayrturl
str_opayrturl_n        =  GetLocationURL()&"/tenpayok_n.asp"
str_sum	               =  shopsum*100
str_goods	       =  shopname
str_comment            =  shopbody
pro_body               =  "以下金额（"& str_sum & "元）已包含配送费用"
str_shopname           =  str_goods & "号订单在线支付" 



 
	 
%>

 <TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor="#336699">
          <TD  height="28" width="300"  align="center"><img src='images/plogo.gif' border=0></TD>
         <TD  height="28"  align="center"></TD>
        </TR>

   
   </TBODY>
  </TABLE>
 <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD  height="50" colspan="2" align="center"></TD>
        </TR>

   
   </TBODY>
  </TABLE>


<TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
     <TR bgcolor=#FFD350>
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp您现在[<%=webname%>]在线支付给<%=payid %>网址:(<%=weburl%>)</TD>
        </TR>

   
   </TBODY>
  </TABLE>
<table width="600" border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="#f1f1f1" >

<tr bgcolor=#FFFFFF><td  height=300 align=center>
<%
'---------------------------------------------------------
'财付通中介担保支付请求示例，商户按照此文档进行开发即可
'---------------------------------------------------------

Dim strNow
Dim randNumber

'14位时间（YYYYmmddHHMMss)
strNow = getStrNow()

'4位随机数
randNumber = getStrRandNumber(1000,9999)

Dim key
Dim chnid
Dim seller

'平台商密钥
key = paypwd

'平台商帐号
chnid = payid

'卖家
seller = payid

Dim mch_desc
Dim mch_name
Dim mch_price
Dim mch_returl
Dim mch_vno
Dim show_url
Dim transport_desc
Dim transport_fee

'交易说明
mch_desc = "交易说明"

'商品名称
mch_name = str_name

'商品总价，单位为分
mch_price = str_sum

'回调通知URL
mch_returl = str_opayrturl

'商家的定单号
mch_vno = str_goods

'支付后的商户支付结果展示页面
show_url = str_opayrturl

'物流公司或物流方式说明
transport_desc = ""

'需买方另支付的物流费用,以分为单位
transport_fee = ""


'创建支付请求对象
Dim reqHandler
Set reqHandler = new MediPayRequestHandler

'初始化
reqHandler.init()

'设置密钥
reqHandler.setKey(key)

'-----------------------------
'设置支付参数
'-----------------------------
reqHandler.setParameter "chnid", chnid						'平台商帐号
reqHandler.setParameter "encode_type", "1"					'编码类型 1:gbk 2:utf-8
reqHandler.setParameter "mch_desc", mch_desc				'交易说明
reqHandler.setParameter "mch_name", mch_name				'商品名称
reqHandler.setParameter "mch_price", mch_price				'商品总价，单位为分
reqHandler.setParameter "mch_returl", mch_returl			'回调通知URL
reqHandler.setParameter "mch_type", "1"						'交易类型：1、实物交易，2、虚拟交易
reqHandler.setParameter "mch_vno", mch_vno					'商家的定单号
reqHandler.setParameter "need_buyerinfo", "2"				'是否需要在财付通填定物流信息，1：需要，2：不需要。
reqHandler.setParameter "seller", seller					'卖家财付通帐号
reqHandler.setParameter "show_url",	show_url				'支付后的商户支付结果展示页面
reqHandler.setParameter "transport_desc", transport_desc	'物流公司或物流方式说明
reqHandler.setParameter "transport_fee", transport_fee		'需买方另支付的物流费用


'请求的URL
Dim reqUrl
reqUrl = reqHandler.getRequestURL()

'debug信息
'Dim debugInfo
'debugInfo = reqHandler.getDebugInfo()

'Response.Write("<br/>debugInfo:" & debugInfo & "<br/>")

'Response.Write("<br/>reqUrl" & reqUrl & "<br/>")

'reqHandler.doSend()


%>
<br/><a href="<%=reqUrl%>" target="_blank">财付通支付</a>
</td>
</tr>
    

</table>
  <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD bgcolor=#FF5900 height="28" colspan="2" align="center"><FONT color=#ffffff>本站使用财付通支付平台，在线实时支付</font></TD>
        </TR>

   
   </TBODY>
  </TABLE>
 <TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>
    <tr bgcolor="#f1f1f1" height=100 ><td colspan=2 align=center>
<a href='http://www.tenpay.com.cn'  target="_blank"><img src='images/logo.gif' border=0></a>
</td></tr>

   
   </TBODY>
  </TABLE>
</body>
<% 
end select 
 %>	
<% 
payid=""
paypwd=""
payurl=""
payparter=""
opayrturl=""
conn.close
 set conn = nothing %>