
<!--#include file="../../conn.asp"-->
<!--#include file="../../config.asp"-->
<!--#include file="MD5.asp"-->
<body bgcolor=#FCFCFC leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<% dim  goods,sum,opayid
goods=saferequest("paygood",1)
sum=saferequest("paysum",1)
opayid=4
Function GetLocationURL() 
Dim Url 
Dim ServerPort,ServerName,ScriptName,QueryString 
ServerName = Request.ServerVariables("SERVER_NAME") 
ServerPort = Request.ServerVariables("SERVER_PORT") 
ScriptName = Request.ServerVariables("SCRIPT_NAME") 
QueryString = Request.ServerVariables("QUERY_STRING") 
Url="http://"&ServerName 
If ServerPort <> "80" Then Url = Url & ":" & ServerPort 
Url=Url&ScriptName 
Url=replace(Url,"index.asp","")
GetLocationURL=Url 
End Function 


action=FormatSQL(SafeRequest("action",0))

set rs=server.CreateObject("adodb.recordset")
rs.open "select opayid,opayname,opaypassword,opayrturl,opayparter from sdx_opay where opayid="&opayid,conn,1,1
payid=rs("opayname")
paypwd=rs("opaypassword")
payurl=GetLocationURL()&rs("opayrturl")
payparter=rs("opayparter")
rs.close
set rs=nothing

select case action
Case "1"
%> 

<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#ECECEC>
          <TD  height="20" colspan="2"></TD>
        </TR>
   <TR >
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp</TD>
        </TR>
    

   </TBODY>
  </TABLE>
  <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD  height="50"><IMG src="images/rmbtop.gif" border=0></TD>
        </TR>

   
   </TBODY>
  </TABLE>

   <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD bgcolor=#FF5900 height="28" colspan="2" align="center">快钱支付网关</TD>
        </TR>

   
   </TBODY>
  </TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
     <TR bgcolor=#FFD350>
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp您现在[<%=webname%>]在线支付给<%=payid %>网址:(<%=weburl%>)</TD>
        </TR>

   
   </TBODY>
  </TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" bgcolor=#f1f1f1>
       
     <TBODY>
      <form name="alipayment" method="post" action="index.asp?action=2">
         
       
          <TR bgcolor=#ffffff>
          
          <TD height="30">&nbsp 商品订单：</TD>
          <TD height="30"><%=goods%>
          <input type="hidden" name="shopname"  size="30" value="<%=goods%>">

    </TD>
      </TR>
      
          
          <TR bgcolor=#ffffff>
          
         
          <TD  height="30">&nbsp 付款金额：</TD>
         <TD height="30"> <%=FormatNumber(sum)%>元
          <input type="hidden" name="shopsum"  size="30" value="<%=sum%>">

          </TD>
         </TR>           
         <TR bgcolor=#ffffff>
          <TD  height="30">&nbsp 支付人姓名：</TD>
         <TD height="30"> 
          <input type="text" name="payname"  size="30" value="">(中文或英文字符)*必填

          </TD>
         </TR> 
       <TR bgcolor=#ffffff>
          <TD  height="30">&nbsp 支付人邮箱：</TD>
         <TD height="30"> 
          <input type="text" name="payemail"  size="30" value="">(中文或英文字符)*必填

          </TD>
         </TR>         
        <TR bgcolor=#ffffff>
          
          <TD  height="30"> &nbsp 客户留言：</TD>
          <TD height="30"><textarea name="shopbody" cols="60" rows="4">暂无</textarea><br>（如联系方法，商品要求、数量等。50汉字内）*选填</TD></TR>

         <TR bgcolor=#F5F5B8>
         
          <TD height="30" colspan="2">&nbsp &nbsp <input type="Submit" name="aliorder"  size="30" value="确   认"  onClick="return CheckForm();"></TD></TR>
   </FORM>
   </TBODY>

</TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>

   <TR >
          <TD  height="60" colspan="2">&nbsp&nbsp&nbsp</TD>
        </TR>
     <TR bgcolor=#ECECEC>
          <TD  height="5" colspan="2"></TD>
        </TR>

      <TR >
          <TD  height="40" colspan="2" align="center"><IMG src="images/logo.gif" border=0>	</TD>
        </TR>
   </TBODY>
  </TABLE>


<%
Case "2"
dim shopsum,shopname,shopbody
shopname      =     sqlCheckstr(request.form("shopname")) 
shopsum       =     sqlCheckstr(request.form("shopsum"))
shopbody      =     sqlCheckstr(request.form("shopbody"))
str_payname      =  sqlCheckstr(request.form("payname"))
str_payemail      =  sqlCheckstr(request.form("payemail"))

str_name               =  shopname
str_payid              =  payid
str_paypwd             =  paypwd
str_payurl             =  payurl
str_sum	               =  shopsum*100
str_goods	       =  shopname
str_comment            =  shopbody
pro_body               =  "以下金额（"& str_sum & "元）已包含配送费用"
str_shopname           =  str_goods & "号订单在线支付" 



'*
'* @Description: 快钱人民币支付网关接口范例
'* @Copyright (c) 上海快钱信息服务有限公司
'* @version 2.0
'*

'人民币网关账户号
''请登录快钱系统获取用户编号，用户编号后加01即为人民币网关账户号。
merchantAcctId=str_payid&"01" 

'人民币网关密钥
''区分大小写.请与快钱联系索取
key=str_paypwd

'字符集.固定选择值。可为空。
''只能选择1、2、3.
''1代表UTF-8; 2代表GBK; 3代表gb2312
''默认值为1
inputCharset="3"

'服务器接受支付结果的后台地址.与[pageUrl]不能同时为空。必须是绝对地址。
''快钱通过服务器连接的方式将交易结果发送到[bgUrl]对应的页面地址，在商户处理完成后输出的<result>如果为1，页面会转向到<redirecturl>对应的地址。
''如果快钱未接收到<redirecturl>对应的地址，快钱将把支付结果GEt到[pageUrl]对应的页面。
bgUrl=str_payurl
	
'网关版本.固定值
''快钱会根据版本号来调用对应的接口处理程序。
''本代码版本号固定为v2.0
version="v2.0"

'语言种类.固定选择值。
''只能选择1、2、3
''1代表中文；2代表英文
''默认值为1
language="1"

'签名类型.固定值
''1代表MD5签名
''当前版本固定为1
signType="1"
   
'支付人姓名
''可为中文或英文字符
payerName=str_payname

'支付人联系方式类型.固定选择值
''只能选择1
''1代表Email
payerContactType="1"

'支付人联系方式
''只能选择Email或手机号
payerContact=str_payemail

'商户订单号
''由字母、数字、或[-][_]组成
orderId=str_goods

'订单金额
''以分为单位，必须是整型数字
''比方2，代表0.02元
orderAmount=str_sum
	
'订单提交时间
''14位数字。年[4位]月[2位]日[2位]时[2位]分[2位]秒[2位]
''如；20080101010101
orderTime=getDateStr()

'商品名称
''可为中文或英文字符
productName=str_shopname

'商品数量
''可为空，非空时必须为数字
productNum="1"

'商品代码
''可为字符或者数字
productId=str_goods

'商品描述
productDesc=str_comment
	
'扩展字段1
''在支付结束后原样返回给商户
ext1=""

'扩展字段2
''在支付结束后原样返回给商户
ext2=""
	
'支付方式.固定选择值
''只能选择00、10、11、12、13、14
''00：组合支付（网关支付页面显示快钱支持的各种支付方式，推荐使用）10：银行卡支付（网关支付页面只显示银行卡支付）.11：电话银行支付（网关支付页面只显示电话支付）.12：快钱账户支付（网关支付页面只显示快钱账户支付）.13：线下支付（网关支付页面只显示线下支付方式）
payType="00"

'同一订单禁止重复提交标志
''固定选择值： 1、0
''1代表同一订单号只允许提交1次；0表示同一订单号在没有支付成功的前提下可重复提交多次。默认为0建议实物购物车结算类商户采用0；虚拟产品类商户采用1
redoFlag="0"

'快钱的合作伙伴的账户号
''如未和快钱签订代理合作协议，不需要填写本参数
pid=""


   
'生成加密签名串
''请务必按照如下顺序和规则组成加密串！
	signMsgVal=appendParam(signMsgVal,"inputCharset",inputCharset)
	signMsgVal=appendParam(signMsgVal,"bgUrl",bgUrl)
	signMsgVal=appendParam(signMsgVal,"version",version)
	signMsgVal=appendParam(signMsgVal,"language",language)
	signMsgVal=appendParam(signMsgVal,"signType",signType)
	signMsgVal=appendParam(signMsgVal,"merchantAcctId",merchantAcctId)
	signMsgVal=appendParam(signMsgVal,"payerName",payerName)
	signMsgVal=appendParam(signMsgVal,"payerContactType",payerContactType)
	signMsgVal=appendParam(signMsgVal,"payerContact",payerContact)
	signMsgVal=appendParam(signMsgVal,"orderId",orderId)
	signMsgVal=appendParam(signMsgVal,"orderAmount",orderAmount)
	signMsgVal=appendParam(signMsgVal,"orderTime",orderTime)
	signMsgVal=appendParam(signMsgVal,"productName",productName)
	signMsgVal=appendParam(signMsgVal,"productNum",productNum)
	signMsgVal=appendParam(signMsgVal,"productId",productId)
	signMsgVal=appendParam(signMsgVal,"productDesc",productDesc)
	signMsgVal=appendParam(signMsgVal,"ext1",ext1)
	signMsgVal=appendParam(signMsgVal,"ext2",ext2)
	signMsgVal=appendParam(signMsgVal,"payType",payType)
	signMsgVal=appendParam(signMsgVal,"redoFlag",redoFlag)
	signMsgVal=appendParam(signMsgVal,"pid",pid)
	signMsgVal=appendParam(signMsgVal,"key",key)
signMsg= Ucase(md5(signMsgVal))
	
	'功能函数。将变量值不为空的参数组成字符串
	Function appendParam(returnStr,paramId,paramValue)

		If returnStr <> "" Then
			If paramValue <> "" then
				returnStr=returnStr&"&"&paramId&"="&paramValue
			End if
		Else 
			If paramValue <> "" then
				returnStr=paramId&"="&paramValue
			End if
		End if
		
		appendParam=ReturnStr

	End Function
	'功能函数。将变量值不为空的参数组成字符串。结束

	'功能函数。获取14位的日期
	Function getDateStr() 
	dim dateStr1,dateStr2,strTemp 
	dateStr1=split(cstr(formatdatetime(now(),2)),"-") 
	dateStr2=split(cstr(formatdatetime(now(),3)),":") 

	for each StrTemp in dateStr1 
	if len(StrTemp)<2 then 
	getDateStr=getDateStr & "0" & strTemp 
	else 
	getDateStr=getDateStr & strTemp 
	end if 
	next 

	for each StrTemp in dateStr2 
	if len(StrTemp)<2 then 
	getDateStr=getDateStr & "0" & strTemp 
	else 
	getDateStr=getDateStr & strTemp 
	end if
	next
	End function 
	'功能函数。获取14位的日期。结束
	
%>

<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#ECECEC>
          <TD  height="20" colspan="2"></TD>
        </TR>
   <TR >
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp</TD>
        </TR>
    

   </TBODY>
  </TABLE>
  <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD  height="50"><IMG src="images/rmbtop.gif" border=0></TD>
        </TR>

   
   </TBODY>
  </TABLE>

   <TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
    <TR bgcolor=#FFffff>
          <TD bgcolor=#FF5900 height="28" colspan="2" align="center">快钱支付网关</TD>
        </TR>

   
   </TBODY>
  </TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="600" border=0 align="center" >
       
     <TBODY>
     <TR bgcolor=#FFD350>
          <TD  height="30" colspan="2">&nbsp&nbsp&nbsp您现在[<%=webname%>]在线支付给<%=payid %>网址:(<%=weburl%>)</TD>
        </TR>

   
   </TBODY>
  </TABLE>
	
	<div align="center">
		<table width="600" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC" >
			<tr bgcolor="#FFFFFF">
				<td width="80">支付方式:</td>
				<td >快钱[99bill]_<%=shopbody%></td>
			</tr>
			<tr bgcolor="#FFFFFF">
				<td >订单编号:</td>
				<td ><%=orderId %></td>
			</tr>
			<tr bgcolor="#FFFFFF">
				<td>订单金额:</td>
				<td><%=FormatNumber(orderAmount*0.01) %> 元</td>
			</tr>
			<tr bgcolor="#FFFFFF">
				<td>支付人:</td>
				<td><%=payerName %></td>
			</tr>
			<tr bgcolor="#FFFFFF">
				<td>商品名称:</td>
				<td><%=productName %></td>
			</tr>
			<tr>
				<td></td>
				<td></td>
			</tr>
	  </table>
	</div>

	<div align="center" style="font-size=12px;font-weight: bold;color=red;">
		<form name="kqPay" method="post" action="https://www.99bill.com/gateway/recvMerchantInfoAction.htm">
			<input type="hidden" name="inputCharset" value="<%=inputCharset %>">
			<input type="hidden" name="bgUrl" value="<%=bgUrl %>">
			<input type="hidden" name="version" value="<%=version %>">
			<input type="hidden" name="language" value="<%=language %>">
			<input type="hidden" name="signType" value="<%=signType %>">
			<input type="hidden" name="signMsg" value="<%=signMsg %>">
			<input type="hidden" name="merchantAcctId" value="<%=merchantAcctId %>">
			<input type="hidden" name="payerName" value="<%=payerName %>">
			<input type="hidden" name="payerContactType" value="<%=payerContactType %>">
			<input type="hidden" name="payerContact" value="<%=payerContact %>">
			<input type="hidden" name="orderId" value="<%=orderId %>">
			<input type="hidden" name="orderAmount" value="<%=orderAmount %>">
			<input type="hidden" name="orderTime" value="<%=orderTime %>">
			<input type="hidden" name="productName" value="<%=productName %>">
			<input type="hidden" name="productNum" value="<%=productNum %>">
			<input type="hidden" name="productId" value="<%=productId %>">
			<input type="hidden" name="productDesc" value="<%=productDesc %>">
			<input type="hidden" name="ext1" value="<%=ext1 %>">
			<input type="hidden" name="ext2" value="<%=ext2 %>">
			<input type="hidden" name="payType" value="<%=payType %>">
			<input type="hidden" name="redoFlag" value="<%=redoFlag %>">
			<input type="hidden" name="pid" value="<%=pid %>">
			<input type="submit" name="submit" value="提交到快钱">
			
		</form>		
	</div>
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 align="center" >
       
     <TBODY>

   <TR >
          <TD  height="60" colspan="2">&nbsp&nbsp&nbsp</TD>
        </TR>
     <TR bgcolor=#ECECEC>
          <TD  height="5" colspan="2"></TD>
        </TR>

      <TR >
          <TD  height="40" colspan="2" align="center"><IMG src="images/logo.gif" border=0>	</TD>
        </TR>
   </TBODY>
  </TABLE>
</body>
</html>
<% 
end select  %>	

<SCRIPT LANGUAGE="JavaScript">
<!--
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function CheckForm()
{
   if(checkspace(document.alipayment.payname.value)) {
	document.alipayment.payname.focus();
    alert("对不起，请填写支付人姓名！");
	return false;
  }
 
  if(document.alipayment.payemail.value.length!=0)
  {
    if (document.alipayment.payemail.value.charAt(0)=="." ||        
         document.alipayment.payemail.value.charAt(0)=="@"||       
         document.alipayment.payemail.value.indexOf('@', 0) == -1 || 
         document.alipayment.payemail.value.indexOf('.', 0) == -1 || 
         document.alipayment.payemail.value.lastIndexOf("@")==document.alipayment.payemail.value.length-1 || 
         document.alipayment.payemail.value.lastIndexOf(".")==document.alipayment.payemail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.alipayment.payemail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.alipayment.payemail.focus();
   return false;
   }
   
}
//-->
</script> 