asp 支付宝 企业版 接口 支持网银接口 ,网银直接支付 仅仅是多了一个defalutbank的參数。
详细看
open.alipay.com
<%' 类名:AlipaySubmit' 功能:支付宝各接口请求提交类' 具体:构造支付宝各接口表单HTML文本。获取远程HTTP数据' 版本号:3.3' 改动日期:2012-07-13' 说明:' 以下代码仅仅是为了方便商户測试而提供的例子代码,商户能够依据自己站点的须要,依照技术文档编写,并不是一定要使用该代码。' 该代码仅供学习和研究支付宝接口使用,仅仅是提供一个參考%> <%'支付宝网关地址(新)GATEWAY_NEW = "https://mapi.alipay.com/gateway.do?"Class AlipaySubmit '' ' 生成签名结果 ' param sParaSort 待签名的数组 ' return 签名结果字符串 Private Function BuildRequestMysign(sParaSort) '把数组全部元素,依照“參数=參数值”的模式用“&”字符拼接成字符串 prestr = CreateLinkstring(sParaSort) '获得签名结果 Select Case sign_type Case "MD5" BuildRequestMysign = Md5Sign(prestr,key,input_charset) Case Else BuildRequestMysign = "" End Select End Function '' ' 生成要请求给支付宝的參数数组 ' param sParaTemp 请求前的參数数组 ' return 要请求的參数数组 Private Function BuildRequestPara(sParaTemp) Dim mysign '过滤签名參数数组 sPara = FilterPara(sParaTemp) '对请求參数数组排序 sParaSort = SortPara(sPara) '获得签名结果 mysign = BuildRequestMysign(sParaSort) '签名结果与签名方式增加请求提交參数组中 nCount = ubound(sParaSort) Redim Preserve sParaSort(nCount+1) sParaSort(nCount+1) = "sign="&mysign Redim Preserve sParaSort(nCount+2) sParaSort(nCount+2) = "sign_type="&sign_type BuildRequestPara = sParaSort End Function '' ' 生成要请求给支付宝的參数数组字符串 ' param sParaTemp 请求前的參数数组 ' return 要请求的參数数组字符串 Private Function BuildRequestParaToString(sParaTemp) Dim sRequestData '待签名请求參数数组 sPara = BuildRequestPara(sParaTemp) '把參数组中全部元素,依照“參数=參数值”的模式用“&”字符拼接成字符串。而且对其做urlencode编码处理 sRequestData = CreateLinkStringUrlEncode(sPara) BuildRequestParaToString = sRequestData End Function '' ' 建立请求。以表单HTML形式构造(默认) ' param sParaTemp 请求前的參数数组 ' param sMethod 提交方式。
两个值可选:post、get ' param sButtonValue 确认button显示文字 ' return 提交表单HTML文本 Public Function BuildRequestForm(sParaTemp, sMethod, sButtonValue) Dim sHtml, nCount '待请求參数数组 sPara = BuildRequestPara(sParaTemp) sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='"& GATEWAY_NEW &"_input_charset="&input_charset&"' method='"&sMethod&"'>" nCount = ubound(sPara) For i = 0 To nCount '把sPara的数组里的元素格式:变量名=值,切割开来 iPos = Instr(sPara(i),"=") '获得=字符的位置 nLen = Len(sPara(i)) '获得字符串长度 sItemName = left(sPara(i),iPos-1) '获得变量名 sItemValue = right(sPara(i),nLen-iPos)'获得变量的值 sHtml = sHtml & "<input type='hidden' name='"& sItemName &"' value='"& sItemValue &"'/>" next 'submitbutton控件请不要含有name属性 'submitbutton默认设置为不显示 sHtml = sHtml & "<input type='submit' value='"&sButtonValue&"' style='display:none;'></form>" sHtml = sHtml & "<script>document.forms['alipaysubmit'].submit();</script>" BuildRequestForm = sHtml End Function Public Function BuildRequestFormbank( trade_no , subject , total_fee ,body ,show_url ) Dim sHtml sHtml = "<form name=alipayment action=alipayapi.asp method=post>" sHtml = sHtml & " <input size=""30"" name=""WIDout_trade_no"" type='hidden' value="""& trade_no &"""/>" sHtml = sHtml & " <input size=""30"" name=""WIDsubject"" type='hidden' value="""& subject &"""/>" sHtml = sHtml & " <input size=""30"" name=""WIDtotal_fee"" type='hidden' value="""& total_fee &"""/>" sHtml = sHtml & " <input size=""30"" name=""WIDbody"" type='hidden' value="""& body &"""/>" sHtml = sHtml & " <input size=""30"" name=""WIDshow_url"" type='hidden' value="""& show_url &"""/>" sHtml = sHtml & " <style>" sHtml = sHtml & " ul.bank { padding:0px;margin-left:30px;}" sHtml = sHtml & " ul.bank li { list-style:none; float:left; padding:5px;}" sHtml = sHtml & " </style>" sHtml = sHtml & "" sHtml = sHtml & " <UL class=""bank fix"">" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""ICBCB2C"" type=""radio""> " sHtml = sHtml & " <IMG alt=""中国工商银行"" align=""middle"" src=""images/bank_gsyh2.gif"">" sHtml = sHtml & " </LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""CMB"" type=""radio""> <IMG alt=""招商银行""" sHtml = sHtml & " align=""middle""" sHtml = sHtml & " src=""images/bank_zsyh2.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""CCB"" type=""radio""> " sHtml = sHtml & " <IMG alt=""中国建设银行"" align=""middle""" sHtml = sHtml & " src=""images/bank_jsyh2.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""ABC"" type=""radio""> " sHtml = sHtml & " <IMG alt=""中国农业银行"" align=""middle""" sHtml = sHtml & " src=""images/bank_nyyh2.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""BOCB2C"" type=""radio""> " sHtml = sHtml & " <IMG alt=""中国银行"" align=""middle""" sHtml = sHtml & " src=""images/bank_zgyh2.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""COMM-DEBIT"" type=""radio""> " sHtml = sHtml & " <IMG alt=""交通银行"" align=""middle"" src=""images/bank_jtyh.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""CIB"" type=""radio""> " sHtml = sHtml & " <IMG alt=""兴业银行"" align=""middle"" src=""images/bank_xyyh.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""CMBC"" type=""radio""> " sHtml = sHtml & " <IMG alt=""中国民生银行"" align=""middle"" src=""images/bank_msyh2.gif"">" sHtml = sHtml & " </LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""GDB"" type=""radio""> <IMG alt=""广东发展银行""" sHtml = sHtml & " align=""middle""" sHtml = sHtml & " src=""images/bank_gdfz.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""SPABANK"" type=""radio""> " sHtml = sHtml & " 平安银行" sHtml = sHtml & " </LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""SPDB"" type=""radio""> " sHtml = sHtml & " <IMG alt=""上海浦东发展银行"" align=""middle""" sHtml = sHtml & " src=""images/bank_pfyh.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""CITIC"" type=""radio""> " sHtml = sHtml & " <IMG alt=""中信银行"" align=""middle"" src=""images/bank_zxyh.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""DEBIT"" type=""radio""> " sHtml = sHtml & " <IMG alt=""光大银行"" align=""middle"" src=""images/bank_gdyh.gif""></LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""FDB"" type=""radio""> 富滇银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""HZCBB2C"" type=""radio""> 杭州银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""SHBANK"" type=""radio""> 上海银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""NBBANK"" type=""radio""> 宁波银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""POSTGC"" type=""radio""> 中国邮政储蓄银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""BJBANK"" type=""radio""> 北京银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""SHRCB"" type=""radio""> 上海农商银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""WZCBB2C-DEBIT "" type=""radio""> 温州银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""BJRCB"" type=""radio""> 北京农村商业银行</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""abc1003"" type=""radio""> visa</LI>" sHtml = sHtml & " <LI><INPUT name=""WIDdefaultbank"" value=""abc1004"" type=""radio""> master</LI>" sHtml = sHtml & " </UL>" sHtml = sHtml & " <br><UL class=""bank fix"" style=""clear:both""><button class=""new-btn-login"" type=""submit"" style=""text-align:center;background-color: #ff8c00; color: #FFFFFF; font-weight: bold; " sHtml = sHtml &"border: medium none; width:82px;height:28px;"">确 认</button></UL>" 'submitbutton控件请不要含有name属性 'submitbutton默认设置为不显示 'sHtml = sHtml & "<input type='submit' value='"&sButtonValue&"' style='display:none;'></form>" sHtml = sHtml & "</form>" BuildRequestFormbank = sHtml End Function '' ' 建立请求,以HTML形式构造(默认) ' param sParaTemp 请求前的參数数组 ' param sMethod 提交方式。两个值可选:post、get ' param sButtonValue 确认button显示文字 ' return 提交表单HTML文本 Public Function BuildRequestUrl(sParaTemp, sMethod, sButtonValue) Dim sHtml, nCount '待请求參数数组 sPara = BuildRequestPara(sParaTemp) sHtml = GATEWAY_NEW nCount = ubound(sPara) For i = 0 To nCount '把sPara的数组里的元素格式:变量名=值,切割开来 iPos = Instr(sPara(i),"=") '获得=字符的位置 nLen = Len(sPara(i)) '获得字符串长度 sItemName = left(sPara(i),iPos-1) '获得变量名 sItemValue = right(sPara(i),nLen-iPos)'获得变量的值 sHtml = sHtml & "&"& sItemName &"="& sItemValue next BuildRequestUrl= sHtml End Function '' ' 建立请求。以模拟远程HTTP的GET请求方式构造并获取支付宝XML类型处理结果 ' param sParaTemp 请求前的參数数组 ' param sParaNode 要输出的XML节点名 ' return 支付宝返回XML指定节点内容 Public Function BuildRequestHttpXml(sParaTemp, sParaNode) Dim sUrl, objHttp, objXml, nCount, sParaXml() nCount = ubound(sParaNode) '待请求參数数组字符串 sRequestData = BuildRequestParaToString(sParaTemp) '构造请求地址 sUrl = GATEWAY_NEW & sRequestData '获取远程数据 Set objHttp=Server.CreateObject("Microsoft.XMLHTTP") '假设Microsoft.XMLHTTP不行,那么请替换以下的两行行代码尝试 'Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0") 'objHttp.setOption 2, 13056 objHttp.open "GET", sUrl, False, "", "" objHttp.send() Set objXml=Server.CreateObject("Microsoft.XMLDOM") objXml.Async=true objXml.ValidateOnParse=False objXml.Load(objHttp.ResponseXML) Set objHttp = Nothing set objXmlData = objXml.getElementsByTagName("alipay").item(0) If Isnull(objXmlData.selectSingleNode("alipay")) Then Redim Preserve sParaXml(1) sParaXml(0) = "错误:非法XML格式数据" Else If objXmlData.selectSingleNode("is_success").text = "T" Then For i = 0 To nCount Redim Preserve sParaXml(i+1) sParaXml(i) = objXmlData.selectSingleNode(sParaNode(i)).text Next Else Redim Preserve sParaXml(1) sParaXml(0) = "错误:"&objXmlData.selectSingleNode("error").text End If End If BuildRequestHttpXml = sParaXml End Function '' ' 建立请求,以模拟远程HTTP的GET请求方式构造并获取支付宝纯文字类型处理结果 ' param sParaTemp 请求前的參数数组 ' return 支付宝处理结果 Public Function BuildRequestHttpWord(sParaTemp) Dim sUrl, objHttp, sResponseTxt '待请求參数数组字符串 sRequestData = BuildRequestParaToString(sParaTemp) '构造请求地址 sUrl = GATEWAY_NEW & sRequestData '获取远程数据 Set objHttp=Server.CreateObject("Microsoft.XMLHTTP") '假设Microsoft.XMLHTTP不行。那么请替换以下的两行行代码尝试 'Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0") 'objHttp.setOption 2, 13056 objHttp.open "GET", sUrl, False, "", "" objHttp.send() sResponseTxt = objHttp.ResponseText Set objHttp = Nothing BuildRequestHttpWord = sResponseTxt End Function '' ' 用于防钓鱼,调用支付宝防钓鱼接口(query_timestamp)来获取时间戳的处理函数 ' 注意:远程解析XML出错,与IISserver配置有关 ' return 时间戳字符串 Public Function Query_timestamp() Dim sUrl, encrypt_key sUrl = GATEWAY_NEW &"service=query_timestamp&partner="&partner&"&_input_charset="&input_charset encrypt_key = "" Dim objHttp, objXml Set objHttp=Server.CreateObject("Microsoft.XMLHTTP") '假设Microsoft.XMLHTTP不行,那么请替换以下的两行行代码尝试 'Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0") 'objHttp.setOption 2, 13056 objHttp.open "GET", sUrl, False, "", "" objHttp.send() Set objXml=Server.CreateObject("Microsoft.XMLDOM") objXml.Async=true objXml.ValidateOnParse=False objXml.Load(objHttp.ResponseXML) Set objHttp = Nothing Set objXmlData = objXml.getElementsByTagName("encrypt_key") '节点的名称 If Isnull(objXml.getElementsByTagName("encrypt_key")) Then encrypt_key = "" Else encrypt_key = objXmlData.item(0).childnodes(0).text End If Query_timestamp = encrypt_key End Function End Class %>
如有疑问请加QQ群 348615323 网店系统开发群