<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/Commoncode.asp"-->
<!--#include file="../../inc/pay_md5.asp"-->
<!--#include file="../../inc/base64.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
query="select * from Job_pay_online where chk=1 and payflag=1"
rs.open query,conn,1,1
if not rs.eof then
ipayid=rs("shid")
ipaykey=rs("pay_key")
else
retcode  = "4"
retMsg	 = "支付接口配置错误！"
end if
rs.close  

if ipayno="" then
retcode  = "4"
retMsg	 = "支付接口配置错误！"
end if

partner=replace(strAnsi2Unicode(Base64decode(strUnicode2Ansi(ipayid))),chr(13)&chr(10),"<br>")
key=replace(strAnsi2Unicode(Base64decode(strUnicode2Ansi(ipaykey))),chr(13)&chr(10),"<br>")

out_trade_no	= DelStr(Request("out_trade_no"))  '获取定单号
total_fee		= DelStr(Request("total_fee"))     '获取支付的总价格
'如需获取其它参数，可填写 参数 =DelStr(Request.Form("获取参数名"))

'**********************判断消息是不是支付宝发出********************
alipayNotifyURL = "http://notify.alipay.com/trade/notify_query.do?"
alipayNotifyURL = alipayNotifyURL &"partner=" & partner & "&notify_id=" & request("notify_id")
Set Retrieval = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
Retrieval.setOption 2, 13056 
Retrieval.open "GET", alipayNotifyURL, False, "", "" 
Retrieval.send()
ResponseTxt = Retrieval.ResponseText
Set Retrieval = Nothing
'*******************************************************************

'*******获取支付宝GET过来通知消息,判断消息是不是被修改过************
For Each varItem in Request.QueryString
	mystr=varItem&"="&Request(varItem)&"^"&mystr
Next 
If mystr<>"" Then 
	mystr=Left(mystr,Len(mystr)-1)
End If 
mystr = SPLIT(mystr, "^")
Count=ubound(mystr)
'对参数排序
For i = Count TO 0 Step -1
	minmax = mystr( 0 )
	minmaxSlot = 0
	For j = 1 To i
		mark = (mystr( j ) > minmax)
		If mark Then 
			minmax = mystr( j )
			minmaxSlot = j
		End If 
	Next    
	If minmaxSlot <> i Then 
		temp = mystr( minmaxSlot )
		mystr( minmaxSlot ) = mystr( i )
		mystr( i ) = temp
	End If
Next
'构造md5摘要字符串
For j = 0 To Count Step 1
	value = SPLIT(mystr( j ), "=")
	If  value(1)<>"" And value(0)<>"sign" And value(0)<>"sign_type"  Then
		If j=Count Then
			md5str= md5str&mystr( j )
		Else 
			md5str= md5str&mystr( j )&"&"
		End If 
	End If 
Next
md5str=md5str&key
mysign=md5(md5str)
'********************************************************

If mysign=Request("sign") and ResponseTxt="true"   Then 	
	payok=true
Else
	payok=false
End If 


Function DelStr(Str)
	If IsNull(Str) Or IsEmpty(Str) Then
		Str	= ""
	End If
	DelStr	= Replace(Str,";","")
	DelStr	= Replace(DelStr,"'","")
	DelStr	= Replace(DelStr,"&","")
	DelStr	= Replace(DelStr," ","")
	DelStr	= Replace(DelStr,"　","")
	DelStr	= Replace(DelStr,"%20","")
	DelStr	= Replace(DelStr,"--","")
	DelStr	= Replace(DelStr,"==","")
	DelStr	= Replace(DelStr,"<","")
	DelStr	= Replace(DelStr,">","")
	DelStr	= Replace(DelStr,"%","")
End Function
%>
<HTML><HEAD><TITLE><%=SiteName%>-银行在线支付</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE>TD {
	FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
</STYLE>

<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<br>
<br>
<br>
<TABLE height=400 cellSpacing=0 cellPadding=0 width=500 
background=../pay_img/cmbchinabg.jpg border=0 align="center" style="border:#000000 1px double">
  <TBODY> 
  <TR>
    <TD vAlign=top>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD><IMG height=86 src="../pay_img/blank.gif" width=10></TD>
          <TD>&nbsp;</TD></TR>
        <TR>
          <TD width=236><img height=1 src="../pay_img/blank.gif" 
            width=236></TD>
          <TD vAlign=top> 
            <P><% if payok=true then %><font color="#FF0000"><b>恭喜您！</b></font><br>
              <br>
              您所支付的款项：<br>
              <br>
              人民币：<b><font color="#FF0000"><%=total_fee%></font>元</b><br>
              <br>
              已经成功转到您的会员号下！<br>
			  <% else %>
              <font color="#FF0000"><b><font color="#0000FF">对不起！</font></b></font><br>
              <br>
              您所支付的款项：<br>
              <br>
              人民币：<b><font color="#FF0000"><%=total_fee%></font>元</b><br>
              <br>
              因操作失败未能转到您的会员号下！ 
			  <% end if %></P>
	 <P>&nbsp;</P>
	 </TD>
	 </TR>
	 </TBODY>
	 </TABLE>
	 </TD>
	 </TR>
	 </TBODY>
	 </TABLE>
	 </BODY>
</HTML>