<!-- #include file="include/config.asp" -->
<!-- #include file="../include/pay_md5.asp" -->
<%
tit="在线支付反馈"

'该页面为支付完成后获取返回的参数及处理.....
 '获取参数
dim v_oid,v_pmode,v_pstatus,v_pstring,v_md5info,v_amount,v_moneytype,v_md5money,v_md5,key,text,md5text
v_oid=request("v_oid")
v_pmode=request("v_pmode")
v_pstatus=request("v_pstatus")
v_pstring=request("v_pstring")
v_md5info=request("v_md5info")
v_amount=request("v_amount")
v_moneytype=request("v_moneytype")
v_md5money=request("v_md5money")
v_md5=request("v_md5")
key="test"

if request("v_md5info")="5" then
	response.Write("v_md5info：空值")
	response.end
end if


'md5校验

text = v_oid&v_pstatus&v_amount&v_moneytype&key
md5text = trim(md5(text))


'按md5检验情况输出结果 Ucase转换为大写
if Ucase(md5text)<>Ucase(v_md5) then
  response.write("error")
else
  response.write("received")
	'或response.write "sent',依据商品物流特征决定。
    '操作数据库

'''''''''''''''''''''开始写入数据库''''''''''''''''''''








'cn.close
'set cn=nothing
'set rs=nothing
   
   '-----------------------------------------------
   '若有错误发生
   If Err.Number <> 0 Then
      Response.Write "error" & Err.Number & "<br>"
      Response.Write "error" & Err.Source & "<br>"
      Response.Write "error" & Err.Description & "<br>"
  Else
     
   End If
   '-----------------------------------------------
   '关闭资料库
   '-----------------------------------------------
end if

call web_head(0,0,0,0,0)
call shop_load()
'----------------------------左边 开始----------------------------
call shop_left()
call shop_left_nsort(0)
'----------------------------左边 结束----------------------------
call web_center(0)
'----------------------------中间 开始----------------------------

call pay_true()

response.write ukong
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub pay_true()
  dim obj_pay,o_id,o_nname,o_prices,o_ispay
  set obj_pay=new joekoe_pay
  call obj_pay.pay_return()
  select case cint(obj_pay.val_num)	'0为验证通过
  case 1
    set obj_pay=nothing
    call pay_true_err("错误的支付反馈表单（反馈信息不完整）！")
    exit sub
  case 2
    set obj_pay=nothing
    call pay_true_err("错误的验证签名（非法提交或参数错误）！")
    exit sub
  end select
  
  sql="select top 1 id,nname,prices,ispay from shop_orders where ordernum='"&obj_pay.pay_ordernum&"' and ispayment=1"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call pay_true_err("错误的支付反馈表单（"&obj_pay.pay_sort&":"&obj_pay.pay_ordernum&"）！请与网站管理员联系处理。")
    set obj_pay=nothing
    exit sub
  end if
  o_id=rs("id")
  o_nname=rs("nname")
  o_prices=rs("prices")
  o_ispay=rs("ispay")
  rs.close
  if o_ispay=true then
    call pay_true_err("在线支付订单（"&obj_pay.pay_sort&":"&obj_pay.pay_ordernum&"）已支付！请与网站管理员联系处理。")
    set obj_pay=nothing
    exit sub
  end if
  if cstr(fm_price(obj_pay.pay_amount,1))<>cstr(fm_price(o_prices,1)) then
    call pay_true_err("在线支付订单（"&obj_pay.pay_sort&":<font class=blue>"&obj_pay.pay_ordernum&"</font>）的应支付金额（<font class=blue>"&o_prices&val_unit&"</font>）与实支付金额（"&obj_pay.pay_amount&val_unit&"）不等！<br>如有问题请与网站管理员联系处理。")
    set obj_pay=nothing
    exit sub
  end if
  call joekoe_cms.exec("update shop_orders set ispay=1,pay_tim='"&joekoe_cms.now_time&"' where id="&o_id,0)
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr><td colspan=2 class=td align=center><b><%response.write tit%></b></td></tr>
<tr class=bg_td>
<td width='20%'>此次交易编号： </td>
<td width='80%'><%=v_oid%></td>
</tr>
<tr class=bg_td>
<td>支付金额：</td>
<td><%=v_amount%></td>
</tr>
<tr class=bg_td>
<td>在线支付结果：</td>
<td><font class=red><%=v_pstring%> </font></td>
</tr>
<tr class=bg_td>
<td>您所使用的卡为：</td>
<td><font class=red><%=v_pmode%></font></td>
</tr>
<tr class=bg_td>
<td>传输来的校验码：</td>
<td><font class=red><%=v_md5%></font></td>
</tr>
<tr class=bg_td>
<td>在线支付币种：</td>
<td><font class=red><%=v_moneytype%></font></td>
</tr>
<tr class=bg_td>
<td>支付时间：</td>
<td><%response.write joekoe_cms.now_time%></td>
</tr>
<tr class=bg_td><td colspan=2 align=center height=50><input type=button class=btn value='点击继续购物' onClick="javascript:window.location.href='shop.asp';"></td></tr>
</table>
<%
  set obj_pay=nothing
end sub

sub pay_true_err(emsg)
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr><td class=td align=center><b><%response.write tit%>错误信息</b></td></tr>
<tr class=bg_td><td align=center height=200 class=htd><font class=red><%response.write emsg%></font><br><br><input type=button class=btn value='点击继续购物' onClick="javascript:window.location.href='shop.asp';"></td></tr>
</table>
<%
end sub
%>