<!-- #include file="hmac-md5.asp" -->
<!-- #include file="yeepayCommon.asp" -->
<!--#include file="../../inc/config.asp"-->
<!--#include file="../../inc/conn.asp"-->
<%
	response.charset="UTF-8"
	'以下代码和变量不需要修改
	Dim sCmd
	Dim sErrorCode
	Dim sTrxId
	Dim amount
	Dim cur
	Dim productId
	Dim orderId
	Dim userId
	Dim MP
	Dim bType		
	Dim svrHmac
	Dim sbOld
	Dim sNewString
	Dim bRet

	payid=GetOneValue("web_orders","uo_recpayway","uo_orderid='"&trim(request("r6_order"))&"'")
	//response.write payid
	if isnumeric(payid)=true then
		merchantId = GetOneValue("pay","userno","payid="&payid)
		keyValue = GetOneValue("pay","userkey","payid="&payid)
	else
		response.write "获取密钥异常，如果您确定付款成功，请和网站联系，并手动修改定单状态"
		response.end
	end if 

	'解析返回参数
	Call getCallBackValue(sCmd,sErrorCode,sTrxId,amount,cur,productId,orderId,userId,MP,bType,svrHmac)
	'判断返回签名是否正确（True/False）
	bRet = CheckHmac(sCmd,sErrorCode,sTrxId,orderId,amount,productId,userId,MP,bType,svrHmac)
	'以上代码和变量不需要修改
	
	
	'校验码正确
	If bRet = True Then
	  if(sErrorCode="1") Then
	  	'如果需要应答机制则必须回写流,以success开头,大小写不敏感.
		'Response.write("success")
		'需要比较返回的金额与商家数据库中订单的金额是否相等，只有相等的情况下才认为是交易成功
		'并且需要对返回的处理进行事务控制，进行记录的排它性处理，防止对同一条交易重复发货的情况发生      	  	      	  
		'Response.write("交易成功")
		conndb
			conn.execute("update web_orders set uo_state=2 where uo_orderid='"&trim(request("r6_order"))&"'")
		closedb
		If(bType="1") Then
			Response.write("在线支付页面返回")
		elseif(bType="2") Then
			Response.write("在线支付服务器返回")
		elseif(bType="3") Then
			Response.write("电话支付通知页面返回")
		End IF  
	  End IF
	Else
		Response.write("交易信息被篡改")
	End If

Function GetOneValue(tabname,fldname,strwhere)
        conndb	
	'on error resume next
	set ojbrss=server.createobject("adodb.recordset")
	if strwhere="" then
		sql="select ["&fldname&"] from " & tabname
	else
		sql="select ["&fldname&"] from "&tabname& " where " &  strwhere
	end if 
	'response.write sql
	ojbrss.open sql,conn,1,3
	if err.number<>0 then
		GetOneValue="-1EISERR"
		err.clear
		ojbrss.close : set ojbrss=nothing
		exit function 
		response.end
	end if 
	if ojbrss.eof then 
		Rem When the result is null return this value
		GetOneValue="-1NISNUL"
	else
		rem return value
		GetOneValue=ojbrss(fldname)
	end if 
	ojbrss.close : set ojbrss=nothing
	closedb
End Function
%>
<html>
<head>
<title>Return from YeePay Page
</title>
</head>
<body>
<table width="93%" border="0">
  <tr> 
    <td> 
	<p><b><font color="#FF0000">提示：</font> 您通过Yeepay易宝支付情况反馈如下：</b><br><br>此次交易编号： <%=trim(request("r6_order"))%></p>
        <p> 
        <%
	 if bRet = True then
		zhuangtai = "在线支付已经支付成功"
	%>
	        在线支付已经支付成功 
        <%
	 else
		zhuangtai = "在线支付失败!"
	%>
        在线支付失败! 
        <%end if%>
      </p>
      <p>金额：<%=trim(request("r3_amt"))%></p>
      <p>币种：人民币</p>
      </p>
	<p><a href="../../index.html">返回商城首页</a></p>
   </td>
  </tr>
</table>
</body>
</html>