<!--#include file="conn.asp" -->

<% 

'1----------------接收IPAY平台返回信息---------------------------------------------------------------------------
v_oid    =Request.Form("v_oid")         '支付定单号
v_pamount=Request.Form("v_pamount")         '支付金额
v_pstatus=Request.Form("v_pstatus")         '支付状态，如果为”20“，则表示支付成功
v_pstring=Request.Form("v_pstring")         '支付结果说明
v_pmd5   =Request.Form("v_pmd5")         '数字签名

'Response.Write v_oid &"<br>"
'Response.Write v_pamount &"<br>"
'Response.Write v_pstatus &"<br>"
'Response.Write v_pstring &"<br>"
'Response.Write v_pmd5 &"<br>"
'2----------------重新计算md5值----------------------------------------------------------------------------------
v_mid="0444"                                '商户编号，改成IPAY负责分配给商户的编号
key  ="luo888750105123abc"                                '默认的私钥值，更改私钥后要修改这里
dim md5string 
set md=server.CreateObject ("md5_VB.md5class")
poststring=v_mid&v_oid&v_pamount
md5string=md.hmac(cstr(poststring),cstr(key))    
 'Response.Write md5string &"<br>"
 'Response.Write v_pmd5              
'3----------------判断返回信息，如果支付成功，并且支付结果可信，则进行进一步的操作-------------------------------     
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>支付结果</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#FF9900" leftmargin="0" topmargin="0">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr> 
    <td><div align="right"><font color="#FF0000"><%= session("us") %>　</font>你好:</div></td>
    <td>你的定单号为 <font color="#FFFFFF"><%= v_oid %> </font>支付金额为:<font color="#FFFFFF"> <%= v_pamount %></font></td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td width="20%">&nbsp;</td>
    <td width="56%"> <% 
	if v_pstatus="20" then
  'do something here 以下为支付成功后金额打入用户账号上面
    sql="select * from pay where v_oid="&v_oid&" and v_pstatus=false"
	 msg=""
	 payok=true
     rs.open sql,conn,2,3
      if rs.eof then
	   msg="<li>你的定单号出错,或者此定单已经入账,请不要重复刷新此页面.</li>"
	   payok=false
	   else
          
	 'if v_pamount<>rs("v_amount") then
	  ' msg="<li>你的入账金额和此定单不相符.</li>"
	  ' payok=false
	' end if	 
	userid=rs("userid")
	'if userid<>session("us") then
	  ' msg="<li>操作超时,请和管理员联系.</li>"
	 '  payok=false
	'end if 
	end if 
	rs.close
	
	'给用户账号上打入实际金额
	if payok then
	  sql="select * from user where userid='"&userid&"'"
	  rs.open sql,conn,2,3
	  if not rs.eof then
	   rs("je")=rs("je")+v_pamount
	   rs.update
	  else
	   msg="<li>用户不存在.</li>"
	   payok=false
	  end if
	  rs.close
	end if
	'写入日志文件
	if payok then
	 rs.open "memo",conn,2,3
	  rs.addnew
	  rs("userid")=userid
	  rs("body")="入账/定单号:"&v_oid
	  rs("log")="在线入账"
	  rs("je")=v_pamount
	  rs("bak")=v_pstring
	  rs.update
	  rs.close
	end if
	'入账成功确认入账定单
	    sql="select * from pay where v_oid="&v_oid
		rs.open sql,conn,2,3
		 rs("v_pstatus")=true
		rs.update
		rs.close
    '显示入账结果
   if payok then
     Response.Write("入账成功,￥ "&v_pamount&"已经成功打入你的账号内")
	 else
	 Response.Write msg&"入账失败请记住你的订单号和管理员联系"
   end if
   
   else
    Response.Write("入账失败或者私钥出错,请和管理员联系..")
    end if
	 %> </td>
    <td width="24%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<p align="center">[<a href="#" onClick="clwin()">关闭此窗口</a>]</p>
<script language="VBScript" type="text/VBScript">
sub clwin
window.close()
end sub
</script>

</body>
</html>




















