⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpay_get.asp

📁 电子商城代码
💻 ASP
字号:
<%@codepage="936"%>
<!--#include file="md32.asp"-->

<%
dim Db,conn,connstr,dbname
dbname="56770_v40.mdb"
Db = "database/"&dbname&""
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & db)
Set conn = Server.CreateObject("ADODB.Connection")
	conn.open ConnStr

'--------------------下面定义接收反馈信息时用到的变量----------------------------
   
dim cash  '消费用户实际支付的金额
dim orderid '商户网站提交到QPAY平台时,该笔交易的交易ID号
dim xinxi '商户网站提交到QPAY平台时,对该笔交易的备注信息
dim shopname '消费用户购买的商品名称
dim email '为消费用户支付时使用的email地址
dim handphone '消费用户支付时使用的手机号码
dim paysok  '交易成功标识,值等于大写字母"Y"时,代表交易成功,否则为失败
dim dayss '消费用户完成此笔交易支付的时间
dim codes 'QPAY平台反馈给商户的交易结果加密信息
dim username '交易中,商家在QPAY的商户ID


'codes加密顺序依次为md32(keys&cash&dayss&payid&xinxi&shopname&email&handphone)

'--------------------------------------------------------------------------------

'----------------------以下部分定义本页面将会用到变量-----------------------------


dim codes2   '接收信息加密结果,用来与接收到的codes值进行对比,确认交易的合法性
dim cash2    '此处为该笔交易在商户网站所记录的金额值,用来与接收到的金额对比,用以确认该消费用户支付的金额是否正确
dim FoundErr '交易出错标识 正常时为False,出错时为True;
dim ErrMsg   '出错时页面显示内容
dim keys     '商户交易识别码
dim sqlStr
dim userid
'---------------------------------------------------------------------------


paysok=request("paysok")
cash=request("cash")
orderid=request("payid")
xinxi=request("xinxi")
shopname=request("shopname")
email=request("email")
handphone=request("phonehands")
dayss=request("days")
codes=request("codes")
username=request("username") 
'****************************************
FoundErr=False '交易默认为正常成交状态
ErrMsg="" 
'****************************************

if paysok="Y" then '当返回交易是成功状态时,进行交易信息的判断

'-------------------------------以下部分读取商户自动化流程时使用到的交易识别码--------------------------------------------
'交易识别码
'(登陆QPAY网站后可进行更改,更改后请注意同时重新运行Qpay_setup.asp页面进行设置,两处必须保持一致)
'Qpay网站中设置交易识别码地址: 登陆后台-安装接口-自动流程接口 中进行设置
  dim RsKey
  dim Keys_ok
  Keys_ok=True
   sqlStr="select qpaykeys from 56770_pay"
   set RsKey=Server.CreateObject("Adodb.Recordset")
      RsKey.open sqlStr,conn,1,1
	  if RsKey.Bof and RsKey.Eof then
	     Keys_ok=False
      else
         keys=RsKey("qpaykeys")
      end if
      RsKey.close
      set RsKey=nothing
'---------------------------------------------------------------------------
         if Keys_ok then
'对接收结果进行加密
keys=trim(keys & cash & dayss & orderid & xinxi & shopname & email & handphone)
codes2=md32(keys)

            if codes=codes2 then  '加密结果相同时,证明此笔交易在QPAY平台为合法正当交易      						
'-------------------------------判断此笔交易是否已经成功完成---------------------
'如果交易已经成功,转到错误页面,提示交易已经完成
                 if xinxi="chongzhi" then
				     sqlStr="select m_zt as orderzt , m_price as summoney , m_user_id as user_id from [56770_money_log] where m_order_num='"& orderid &"'" 
				 else
				     sqlStr="select * from [56770_orders] where order_number='"& orderid &"'"    
				 end if 
				 response.write sqlstr
                    set Rs=Server.CreateObject("Adodb.Recordset")
                       Rs.open sqlStr,conn,1,3
                         if Rs.Bof and Rs.Eof then
		                  FoundErr=True
		                  ErrMsg="非法交易,此次交易结束!"
	                     else
	                     FoundErr=False 
						 order_up=instr(Rs("orderzt"),"2")
	                     cash2=Rs("summoney")
						 userid=Rs("user_id")
						 
						 if xinxi<>"chongzhi" then
						    if instr(order_up,"2")>0 then
							   FoundErr=True
		                       ErrMsg="非法交易,交易已成交,请不要重复刷新本页面!"
							 else
							   FoundErr=false
							 end if
						 else
						   if order_up=1 then
						       FoundErr=True
		                       ErrMsg="非法交易,交易已成交,请不要重复刷新本页面!"
							 else
							   FoundErr=false
							 end if 
						 end if
						 
						  if FoundErr=false and Csng(cash)<>Csng(cash2)  then '用户实际支付金额与应支付金额相符,交易成功
							       FoundErr=True
		                           ErrMsg="支付金额与应付金额不符,交易失败! "   
						  end if	
						end if 
                         Rs.close
						 set Rs=nothing
'---------------------------------------------------------------------------
     
            else '交易信息被人修改,非法交易
                FoundErr=True
                ErrMsg="交易非法,请不要试图破解交易系统!你的行为已被记录,如有疑问请与本公司联系!" 
            end if
	   else
	      	     FoundErr=True
	             ErrMsg="网站自动化接口设置有误,此次交易情况未能及时反应,请与本站联系!"
	   end if

else
  FoundErr=True
  ErrMsg="支付未成功,请重新进行支付,如果您确认已经支付成功,请与本公司联系!"
end if

if FoundErr=False then  
  
'********************************************************************************
'  检验完毕,交易信息正常,更新交易状态为已成交,并传出该笔交易的交易编号信息
'      传出参数有Founderr,orderid 分别代表错误标识以及该笔交易的交易订单号
'******************************************************************************** 
   
        call ShowWeb() '操作完成后,页面显示内容
else
'**********************************************************************************
'  交易信息检验时,发现交易错误,传出该笔交易的错误信息
'      传出参数有Founderr,ErrMsg 分别代表错误标识以及错误详细信息
      call on_Err()
end if

%>
<% 
sub on_Err()
 Response.Redirect("Qpay_get_show.asp?FoundErr=1&Errmsg="&Errmsg)
end sub
%>
<%
sub ShowWeb()

   if xinxi="chongzhi" then
   dim shenqingtype
     sqlStr="select * from [56770_user] where user_id='"& userid &"'"  
	 set rs=conn.execute(sqlstr)
	 shenqingtype=rs("shenqingtype")
	 set rs=nothing
      rem 开始写入数据库
        If shenqingtype=2 And CInt(cash2)>=CInt(sys_56770com23) Then 
                conn.execute("UPDATE [56770_user] SET ifpay=1,shenqing=0 where user_id='"&userid&"'")
        End If 
        conn.execute("UPDATE [56770_user] SET usermoney=usermoney+"&cash2&" where user_id='"&userid&"'")
        conn.execute("UPDATE [56770_money_log] SET m_zt=1 where m_order_num='"&orderid&"'")
   end if
    Response.Redirect("Qpay_get_show.asp?FoundErr=0&orderid="& orderid)
end sub 
%>
<%
Function BytesToBstr(body,CodeSet) 
dim objstream 
set objstream = Server.CreateObject("adodb.stream") 
objstream.Type = 1 
objstream.Mode =3 
objstream.Open 
objstream.Write body 
objstream.Position = 0 
objstream.Type = 2 
objstream.Charset = CodeSet '转换原来默认的UTF-8编码转换成所选编码,否则直接用XMLHTTP组件调用有中文字符的网页得到的将是乱码 
BytesToBstr = objstream.ReadText 
objstream.Close 
set objstream = nothing 
End Function 
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -