<!--#include virtual="/inc/conn.asp"-->
<!--#include virtual="/inc/sitecon.asp"-->
<!--#include virtual="/inc/md52.asp"--> 
<!--#include virtual="/inc/buysyspc.asp"-->
<!--#include virtual="/pay/weifutong/classes/class.asp"-->
<%
On error resume next 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="/Template/newbuy/css/paycss.css" type="text/css" rel="stylesheet">
<script src="/inc/qrcode.min.js" type="text/javascript"></script>
<title>商品付款<%if isgoodurl<>"yes" then%>-<%=trim(webname)%><%end if%></title>
<%if isgoodurl<>"yes" then%>
<meta name="keywords" content="商品付款,<%=webkeywords%>">
<meta name="description" content="<%=webdescription%>">
<%end if%>
</head>
<body>
<script language=javascript>
function check_add()
{
document.form1.tijiao.disabled="disabled";
zhifu.style.display='none';
tiqu.style.display='';
}
</script> 
<%
'初始化参数
isshowerweima="no"
isguolvallcan="no" '清空表单所有参数
isgoodurl=SafeRequestform("isgoodurl")
if trim(isgoodurl)="" then isgoodurl="no"

set rss=server.CreateObject("adodb.recordset")

'post方法
function getHTTPPagwx(url,cset) 
dim Http 
set Http=server.createobject("MSXML2.XMLHTTP") 
Http.open "GET",url,false 
Http.send() 
if Http.readystate<>4 then exit function 
getHTTPPagwx=bytesToBSTR(Http.responseBody,cset) 
set http=nothing 
if err.number<>0 then err.Clear  
end function

'威富通获取数据
Function BytesToBstrwft(body)
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 = "GB2312"
BytesToBstrwft = objstream.ReadText
objstream.Close()
Set objstream = Nothing
End Function

'邮箱检测
Function RegTest(str,r,i)
Dim Reg
Set Reg=New RegExp
Reg.IgnoreCase=i
Reg.Pattern=r
RegTest=Reg.Test(str)
Set Reg=Nothing
End Function

'日期格式补零
function FillZero(str)
	if len(str)=1 then
	FillZero = "0"&str
	else
	FillZero=str
	end if
end function


'创建订单号
sjstr=split(userinip,".")
if len(sjstr(0))=1 then 
sj1="0"&sjstr(0)
else
sj1=mid(sjstr(0),1,1)&mid(sjstr(0),len(sjstr(0)),len(sjstr(0)))
end if
if len(sjstr(1))=1 then 
sj2="0"&sjstr(1)
else
sj2=mid(sjstr(1),1,1)&mid(sjstr(1),len(sjstr(1)),len(sjstr(1)))
end if
sito=sj1&sj2&mid(sjstr(2),len(sjstr(2)),len(sjstr(2)))&mid(sjstr(3),len(sjstr(3)),len(sjstr(3)))

Const stringmodarr = "0123456789"
strlength = Len(stringmodarr)
Randomize timer
For i = 1 To 5 
randarr2 = randarr2&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 
For i = 1 To 4 
randarr3 = randarr3&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 

'订单完整组合 randarrlei&randarrhost&randarrddku&randarrlast
randarrlei="D" 	 	'标示 D订单 C财务
randarrhost="A" 	'服务器数据库
randarrlast=Right(("00"&Day(Now())),2)&Right(("00"&second(Now())),2)&sito&randarr2    '订单字符串
randarrlasta=Right(("00"&Day(Now())),2)&Right(("00"&second(Now())),2)&sito&randarr3   '订单字符串 支付宝驻守使用

'获取参数
if SafeRequestform("act")="" or SafeRequestform("act")<>"buy" then response.Redirect(weburl)
isfan=SafeRequestform("isfan")                      '是否泛解析来访
ismd5=SafeRequestform("ismd5")
shanghuqq=SafeRequestform("shanghuqq")
if trim(shanghuqq)="" then shanghuqq="-"
buyurlid=SafeRequestform("buyurlid")
tikapass=SafeRequestform("tikapass") 				'提卡密码
isagree=SafeRequestform("isagree")              	'选定值ture 同意协议
feilei=SafeRequestform("fid")                	    '分类ID
shangid=SafeRequestform("sid")				  	    '商品ID
gooduserid=SafeRequestform("gooduserid")          	'商品所属会员ID
quantity=SafeRequestform("quantity")              	'购买数量

danjia=SafeRequestform("danjia")				  	'商品单价
goodyj=SafeRequestform("goodyj")				  	'商品原价(单价)
goodzongjia=SafeRequestform("goodzongjia")        	'商品总价

wangyinzhi=SafeRequestform("wangyinzhi")         	'网银值  1支付宝网银 2财付通网银 3易宝网银 ALIPAY  TENPAY  99余额
'email=SafeRequestform("email")                	 	'邮箱
email=""
contact=trim(SafeRequestform("contact"))			'联系方式
bugpass=trim(SafeRequestform("bugpass"))            '购卡密码


istelka=trim(SafeRequestform("istelka"))            '是否使用手机接收短信 yes是

isxinyongka=SafeRequestform("isxinyongka")           '是否信用卡支付
pid=SafeRequestform("pid")                  		 '支付通道代码

isyouhui=SafeRequestform("isyouhui")          		 '是否使用优惠券 选定值=1
youhuiquan=SafeRequestform("youhuiquan")      	 	 '优惠券信息
youhuiquanzhi=SafeRequestform("youhuiquanzhi")		 '优惠券值

if request.Cookies("aynameid")<>"" then 'and request.Cookies("kfopenid")<>"" and request.Cookies("kfopenname")<>""
ayddbuyid=request.Cookies("aynameid") 
else
ayddbuyid=0
end if



yingfuzongjia=goodzongjia                       '应支付总价
showddzj=danjia*quantity						'订单总价
ddzj=showddzj

if isyouhui="" then 
youhuiquan=""
youhuiquanzhi=""
end if



'除去优惠券值计算真实订单总价
if trim(youhuiquanzhi)<>"" then   
	youhuiquanstr=split(youhuiquanzhi,"|")
	if Ubound(youhuiquanstr)>0 then youhuiquanzhi=mid(youhuiquanzhi,1,instr(1,youhuiquanzhi,"|")-1)&"%"        				
		str=split(youhuiquanzhi,"%")
		if Ubound(str)>0 then
		quanzhi=mid(youhuiquanzhi,1,instr(1,youhuiquanzhi,"%")-1)
		ddzj=showddzj-quanzhi/100*showddzj 
		else
		ddzj=showddzj-youhuiquanzhi
		end if
end if
'除去优惠券值计算真实订单总价END

picpid=pid

'参数判断验证
if shangid="" then call PopErr2("商品信息有误","/")
if cint(quantity)<1 then call PopErr("购买数量有误")
if isagree="" then call PopErr("您没有勾选并同意支付协议")
if feilei="0" or shangid="0" then call PopErr("请选择需要购买的商品")
if contact="" then call PopErr("请填写一个联系方式以便查询")
if len(contact)<6 then call PopErr("联系方式不少于6位请重新填写")
if contact="123456" or contact="000000" or contact="0000000" or contact="888888" or contact="112233" or contact="111111" then call PopErr("联系方式过于简单请重新填写")
if trim(yingfuzongjia)<>"" and CCur(yingfuzongjia)<0 then call PopErr("商品价格出现错误请重新选择")
if yingfuzongjia<>0 and pid="" then call PopErr("请选择支付方式")
if yingfuzongjia=0 then call PopErr("支付价格有误，请联系商家，NP-err13")
'参数判断验证END

'检查是否在买家黑名单
call chkbuyhei(contact,trim(email))

'判断买家是否绑定微信
maiweixin=""
if isNumeric(contact)=true and len(contact)=11 then
		rs.open "select maitel,maiopenid from aymaiweixin where maitel='"&contact&"'",conn,1,1
		if not(rs.bof and rs.eof) then
		maiweixin=trim(rs("maiopenid"))
		end if
		rs.close
end if

'是否有其他核心设置
shezhi1="no"
shezhi2="no"
shezhi3="no"
rs.open "select * from ayapiquanju2" ,conn,1,1
if cint(rs("shezhi1"))=1 then shezhi1="yes"	'非重要级别 是否开启 支付宝人工收款接口 1是
if cint(rs("shezhi2"))=1 then shezhi2="yes"	'非重要级别 是否开启 微信人工收款接口 1是
if cint(rs("shezhi3"))=1 then shezhi3="yes"	'非重要级别 是否开启 QQ人工收款接口 1是
rs.close

'全局参数
rs.open "select * from ayquanju",conn,1,1
bankfs=rs("aybankpay")
aychenbank=rs("aychenbank")      '网银接口成本
aychenalipay=rs("aychenalipay")  '支付宝接口成本
saomacheng=rs("saomacheng")      '微信扫码成本
qqsaomacheng=rs("qqsaomacheng")  'qq成本
jdsaomacheng=rs("jdsaomacheng")  '京东成本
alipayguanfei=rs("qzalipayf")    '支付宝官方接口手续费
buyisdl=rs("buyisdl")			 '全局强制登录购买

if wangyinzhi="1" or wangyinzhi="2" then
aybankf=rs("aybankf") 			 '网银交易费率
zaybankf=rs("aybankf") 			 '上级代理默认网银手续费
end if

if wangyinzhi="ALIPAY" then 
ayalif=rs("ayalif")  			  '支付宝交易费率
zayalif=rs("ayalif")  			  '上级代理默认支付宝手续费
ayisraili=rs("ayisraili")         '是否使用支付宝驻守 1是
aliqitajiekou=rs("aliqitajiekou")  '其他接口
alipayguancheng=rs("qzalipayc")   '支付宝官方接口成本
qzalipayf2=rs("qzalipayf2")       '支付宝驻守程序手续费
qzalipayc2=rs("qzalipayc2")       '支付宝驻守程序成本
end if

if wangyinzhi="WEIXIN" then
saomafei=rs("saomafei")           '微信扫码交易费率
zsaomafei=rs("saomafei")		  '上级代理默认微信扫码手续费
wxqitajiekou=rs("wxqitajiekou")   '其他接口
end if

if wangyinzhi="QQPAY" then
qqsaomafei=rs("qqsaomafei")      'QQ扫码费率
zqqsaomafei=rs("qqsaomafei")     '上级代理qq扫码默认费率
qqqitajiekou=rs("qqqitajiekou")  '其他接口
end if

if wangyinzhi="JDPAY" then
jdsaomafei=rs("jdsaomafei")      '京东费率
zjdsaomafei=rs("jdsaomafei")     '上级代理京东扫码默认费率
jdqitajiekou=rs("jdqitajiekou")  '京东其他接口
end if

isalipayfz=rs("isalipayfz")      '是否开启秒结 1是
alipayfzxx=rs("alipayfzxx")      '秒结下限
alipayfzsx=rs("alipayfzsx")      '秒结上限
alipayfzfei=rs("alipayfzfei")    '秒结手续费
alipayfz1=rs("alipayfz1")        '秒结开始时间
alipayfz2=rs("alipayfz2")        '秒结结束时间
rs.close


'商户数据处理
isvip="no"
rs.open "select * from ayname where aynameid="&gooduserid&"",conn,1,1
if rs.bof and rs.eof then call PopErr("无此商家")

if cint(rs("ddmaxj"))>0 then		'订单单价上限
	if ccur(ddzj)>ccur(rs("ddmaxj")) then 
	call PopErr("订单金额超限")
	response.end
	end if
end if

if cint(rs("isbuylog"))=1 then		'强制买家登录购买
	if request.Cookies("aynameid")="" or cint(ayddbuyid)=0 then 
	response.Write "{""err"":""必须登录后才可以购买""}"
	response.end
	end if
end if

if cint(rs("isbuylog"))<>2 then		'2=关闭强制登录
	if cint(buyisdl)=1 then			'全站强制买家登录购买
		if request.Cookies("aynameid")="" or cint(ayddbuyid)=0 then 
		response.Write "{""err"":""必须登录后才可以购买""}"
		response.end
		end if
	end if
end if

yongjin=rs("yongjin")
ayjibie=rs("ayjibie")
ayaisalipayfz=rs("ayaisalipayfz")	 '秒结

if cint(rs("isshangzishou"))=1 then  '商家自收 接口
	if DateDiff("d",now(),rs("zishoudate"))>=1 then '权限未到期
		if pid="ALIPAY" and cint(rs("iszsali"))=1 then 
		isshzishou="yes"
		shzishoupic=trim(rs("zsali"))
		end if
		if pid="WEIXIN" and cint(rs("iszswei"))=1 then 
		isshzishou="yes"
		shzishoupic=trim(rs("zswei"))
		end if
		if pid="QQPAY" and cint(rs("iszsqq"))=1 then 
		isshzishou="yes"
		shzishoupic=trim(rs("zsqq"))
		end if
	end if
end if

ddku=trim(rs("ddku"))
select case	trim(rs("ddku")) 		 '订单库
case "aydingdan"
randarrddku="A"
case "aydingdan01"
randarrddku="B"
case "aydingdan02"
randarrddku="C"
case "aydingdan03"
randarrddku="D"
case "aydingdan04"
randarrddku="E"
case "aydingdan05"
randarrddku="F"
end select
'创建订单号
randarr=randarrlei&randarrhost&randarrddku&randarrlast 
rs.close


'商户级别
if cint(ayjibie)<>5 and cint(ayjibie)<>9 then
isvip="yes"

	rs.open "select * from ayujb where ayujbgid="&ayjibie&"" ,conn,1,1
	bankfs=rs("aybankpay")
	if wangyinzhi="1" or wangyinzhi="2" then
	if cint(rs("ayisbankpay"))=0 then call PopErr("该商家级别未启用该支付方式")
	aybankf=rs("ayujbbankbl")   	   '非普通商户 网银费率   0为免费
	aychenbank=rs("ayujbjiekoubank")   '非普通商户 接口成本 网银
	end if
	
	if wangyinzhi="ALIPAY" then
	if cint(rs("ayisalipay"))=0 then call PopErr("该商家级别未启用该支付方式")
	ayalif=rs("ayujbalibl")  		   '非普通商户 支付宝费率 0为免费
	aychenalipay=rs("ayujbjiekouali")  '非普通商户 接口成本 支付宝  
	aliqitajiekou=rs("jbaliqitajiekou")  '其他接口
	end if
	
	if wangyinzhi="WEIXIN" then
	if cint(rs("ayissaopay"))=0 then call PopErr("该商家级别未启用该支付方式")
	saomafei=rs("ayujbsaobl")   	   '非普通商户 微信费率   0为免费
	saomacheng=rs("ayujbjiekouwei")    '非普通商户 接口成本 微信 
	wxqitajiekou=rs("jbwxqitajiekou")  '其他接口
	end if
	
	if wangyinzhi="QQPAY" then
	if cint(rs("ayisqqpay"))=0 then call PopErr("该商家级别未启用该支付方式")
	qqsaomafei=rs("ayujbqqbl")  	   '非普通商户 QQ扫码费率 0为免费
	qqsaomacheng=rs("ayujbjiekouqq")   '非普通商户 接口成本 QQ扫码 
	qqqitajiekou=rs("jbqqqitajiekou")'其他接口
	end if

	if wangyinzhi="JDPAY" then
	if cint(rs("ayisjdpay"))=0 then call PopErr("该商家级别未启用该支付方式")
	jdsaomafei=rs("jdsaomafei")  	    '非普通商户 京东扫码费率 0为免费
	jdsaomacheng=rs("jdsaomacheng")     '非普通商户 接口成本 京东扫码 
	jdqitajiekou=rs("jdqitajiekou")		'其他接口
	end if

	rs.close
end if


'是否为包年套餐商户
rs.open "select top 1 aytcuid,aytcbuyd,aytcsj,aytczt,aytcisyear,aytcyearf,aytczhiding from aytaocanlog where aytcuid="&gooduserid&" and aytcisyear=1 and aytczt=0",conn,1,1
if not(rs.bof and rs.eof) then
	if DateDiff("d",rs("aytcbuyd"),now())<=clng(rs("aytcsj")) then  '*******套餐未过期
		if chkujb(ayjibie,trim(rs("aytczhiding")))=true then  '检查级别是否可用
		aybankf=rs("aytcyearf")    '包年套餐网银手续费
		ayalif=rs("aytcyearf")     '包年套餐支付宝手续费
		saomafei=rs("aytcyearf")   '包年套餐微信手续费
		qqsaomafei=rs("aytcyearf") '包年套餐手Q手续费
		jdsaomafei=rs("aytcyearf") '包年套餐京东手续费
		end if
	end if
end if
rs.close

'其他核心设置 非重要级别 是否开启人工收款接口 
if shezhi1="yes" then	'支付宝人工
	if cint(ayjibie)=4 or cint(ayjibie)=10 or cint(ayjibie)=7 or cint(ayjibie)=6 or cint(ayjibie)=14 or cint(ayjibie)=1 or cint(ayjibie)=13 then
	aliqitajiekou=90
	aychenalipay=0
	end if
end if
if shezhi2="yes" then	'微信人工
	if cint(ayjibie)=4 or cint(ayjibie)=10 or cint(ayjibie)=7 or cint(ayjibie)=6 or cint(ayjibie)=14 or cint(ayjibie)=1 or cint(ayjibie)=13 then
	wxqitajiekou=90
	saomacheng=0
	end if
end if
if shezhi3="yes" then	'QQ人工
	if cint(ayjibie)=4 or cint(ayjibie)=10 or cint(ayjibie)=7 or cint(ayjibie)=6 or cint(ayjibie)=14 or cint(ayjibie)=1 or cint(ayjibie)=13 then
	qqqitajiekou=90
	qqsaomacheng=0
	end if
end if


'生成支付地址
zhifufangshi=99
if wangyinzhi="1" or wangyinzhi="2" then zhifufangshi=0
if wangyinzhi="ALIPAY" then zhifufangshi=2 
if wangyinzhi="WEIXIN" then zhifufangshi=4
if wangyinzhi="QQPAY" then zhifufangshi=5
if wangyinzhi="JDPAY" then zhifufangshi=6

if wangyinzhi="1" then  
qudao="支付宝"
urlact="action='/pay/alipaybank/' method=post"  '1支付宝网银
end if 
if wangyinzhi="2" then  
qudao="财付通"
urlact="action='/pay/tenpaybank/' method=get"	 '2财付通网银
end if 

isusershoukuan="no"	'个人收款二维码

'支付宝帐号
if wangyinzhi="ALIPAY" then  
isqtalipay="no" '是否使用其他跳转支付宝接口

	urlact="action='/pay/alipay/' method=post" '支付宝官方
	qudao="官方"
	
	if cint(aliqitajiekou)=1 then 	'IK接口
	qudao="28"
	isqtalipay="yes"
	urlact="action='/pay/ikpay/' method=post" 
	end if
	
	'商户 个人 二维码收款
	rss.open "select top 1 * from ayshoukuan where userid="&gooduserid&" and lei=1 and isok=1",conn,1,1
	if not(rss.bof and rss.eof) then
	zishoufs=trim(rss("con"))
	picurl=trim(rss("pic"))
	allname=trim(rss("allname"))
	ayshoukuanid=rss("ayshoukuanid")
	aliqitajiekou=91
	isusershoukuan="yes"
	zhifufs="1"
	qudao="平台代收"
	urlact="action='/pay/erweima/' method=post" 
	isqtalipay="yes"
	end if
	rss.close

	'商家自收
	if isshzishou="yes" then
	aliqitajiekou=92
	isusershoukuan="no"
	zhifufs="1"
	qudao="商家自收"
	urlact="action='/pay/erweima_zs/' method=post" 
	isqtalipay="yes"
	picurl=shzishoupic
	end if
	
	'二维码收款 支持轮询
	if cint(aliqitajiekou)=90  then  
	
		zhifufs="1"
		qudao="自收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
		grlunxunsum=0
		constr=""
		
		sql="select * from ayshoukuan where userid=0 and lei=1 and isok=1" 
		rss.open sql,conn,1,1
		if not(rss.bof and rss.eof) then
		do while not rss.eof
			grlunxunsum=grlunxunsum+1
			constr=constr&trim(rss("con"))&","
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
		rss.movenext
		loop
		end if
		rss.close
		
		if grlunxunsum=0 then 
		response.Write "{""err"":""没有可用收款方式""}"
		response.end
		end if
		
		'#####个人二维码代收 轮询开始
		if grlunxunsum>1 then
		constr=mid(constr,1,len(constr)-1)
		
			rss.open "select top 1 * from aybuylx where qudao='自收' and zhifufs=1 order by aylxid desc" ,conn,1,1
			if not(rss.bof and rss.eof) then
				if trim(rss("zishoufs"))<>"" and isnull(trim(rss("zishoufs")))=false then 	'最后一单 自收订单 自收接口 如：艺星24492628@qq.com
				lastzishoufs=trim(rss("zishoufs"))
				else
				lastzishoufs=""	
				end if
			end if
			rss.close
			
			fenjiestr=split(constr,",")	'获取已设置好的轮询接口个数	Ubound(fenjiestr)+1	单个具体位置 fenjiestr(0)
			lunxunzongshu=Ubound(fenjiestr)
			
			isyou="no"	'是否还存在已设置的轮询接口中
			nextzishounum=0
			For zishousum=0 To Ubound(fenjiestr)
				if lastzishoufs=fenjiestr(zishousum) then	'获取最后一单渠道 在已设置的轮询接口中的位置
				nextzishounum=zishousum+1								'下一个轮询接口 位置
				isyou="yes"
				if nextzishounum>lunxunzongshu then nextzishounum=0
				exit for
				end if
			next 
		
			if isyou="no" then
			nextzishoujiekou=fenjiestr(0)
			else
			nextzishoujiekou=fenjiestr(nextzishounum)
			end if
			
			sql="select * from ayshoukuan where con='"&nextzishoujiekou&"'" 
			rss.open sql,conn,1,1
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
			rss.close
			
		end if
		'#####个人二维码代收 轮询结束
	
	
	end if
	
end if


'微信三方接口
if trim(wangyinzhi)="WEIXIN" then  
	
	if cint(wxqitajiekou)=2 then   'IK接口
	qudao="28"
	isqtalipay="yes"
	urlact="action='/pay/ikpay/' method=post" 
	end if
	
	'商户 个人 二维码收款
	rss.open "select top 1 * from ayshoukuan where userid="&gooduserid&" and lei=2 and isok=1",conn,1,1
	if not(rss.bof and rss.eof) then
	zishoufs=trim(rss("con"))
	picurl=trim(rss("pic"))
	allname=trim(rss("allname"))
	ayshoukuanid=rss("ayshoukuanid")
	wxqitajiekou=91
	isusershoukuan="yes"
	zhifufs="2"
	qudao="平台代收"
	urlact="action='/pay/erweima/' method=post" 
	isqtalipay="yes"
	end if
	rss.close
	
	'商家自收
	if isshzishou="yes" then
	wxqitajiekou=92
	isusershoukuan="no"
	zhifufs="2"
	qudao="商家自收"
	urlact="action='/pay/erweima_zs/' method=post" 
	isqtalipay="yes"
	picurl=shzishoupic
	end if
	
	'二维码收款 支持轮询
	if cint(wxqitajiekou)=90  then  
	
		zhifufs="2"
		qudao="自收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
		grlunxunsum=0
		constr=""
		
		sql="select * from ayshoukuan where userid=0 and lei=2 and isok=1" 
		rss.open sql,conn,1,1
		if not(rss.bof and rss.eof) then
		do while not rss.eof
			grlunxunsum=grlunxunsum+1
			constr=constr&trim(rss("con"))&","
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
		rss.movenext
		loop
		end if
		rss.close
		
		if grlunxunsum=0 then 
		response.Write "{""err"":""没有可用收款方式""}"
		response.end
		end if
		
		'#####个人二维码代收 轮询开始
		if grlunxunsum>1 then
		constr=mid(constr,1,len(constr)-1)
		
			rss.open "select top 1 * from aybuylx where qudao='自收' and zhifufs=2 order by aylxid desc" ,conn,1,1
			if not(rss.bof and rss.eof) then
				if trim(rss("zishoufs"))<>"" and isnull(trim(rss("zishoufs")))=false then 	'最后一单 自收订单 自收接口 如：艺星24492628@qq.com
				lastzishoufs=trim(rss("zishoufs"))
				else
				lastzishoufs=""	
				end if
			end if
			rss.close
			
			fenjiestr=split(constr,",")	'获取已设置好的轮询接口个数	Ubound(fenjiestr)+1	单个具体位置 fenjiestr(0)
			lunxunzongshu=Ubound(fenjiestr)
			
			isyou="no"	'是否还存在已设置的轮询接口中
			nextzishounum=0
			For zishousum=0 To Ubound(fenjiestr)
				if lastzishoufs=fenjiestr(zishousum) then	'获取最后一单渠道 在已设置的轮询接口中的位置
				nextzishounum=zishousum+1								'下一个轮询接口 位置
				isyou="yes"
				if nextzishounum>lunxunzongshu then nextzishounum=0
				exit for
				end if
			next 
		
			if isyou="no" then
			nextzishoujiekou=fenjiestr(0)
			else
			nextzishoujiekou=fenjiestr(nextzishounum)
			end if
			
			sql="select * from ayshoukuan where con='"&nextzishoujiekou&"'" 
			rss.open sql,conn,1,1
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
			rss.close
			
		end if
		'#####个人二维码代收 轮询结束
	
	end if
		
end if

if trim(wangyinzhi)="QQPAY" then
	
	if cint(qqqitajiekou)=1 then  'IK接口
	qudao="28"
	isqtalipay="yes"
	urlact="action='/pay/ikpay/' method=post" 
	end if
	
	'商户 个人 二维码收款
	rss.open "select top 1 * from ayshoukuan where userid="&gooduserid&" and lei=3 and isok=1",conn,1,1
	if not(rss.bof and rss.eof) then
	zishoufs=trim(rss("con"))
	picurl=trim(rss("pic"))
	allname=trim(rss("allname"))
	ayshoukuanid=rss("ayshoukuanid")
	aliqitajiekou=91
	isusershoukuan="yes"
	zhifufs="1"
	qudao="平台代收"
	urlact="action='/pay/erweima/' method=post" 
	isqtalipay="yes"
	end if
	rss.close
	
	'商家自收
	if isshzishou="yes" then
	qqqitajiekou=92
	isusershoukuan="no"
	zhifufs="3"
	qudao="商家自收"
	urlact="action='/pay/erweima_zs/' method=post" 
	isqtalipay="yes"
	picurl=shzishoupic
	end if
	
	'二维码收款 支持轮询
	if cint(qqqitajiekou)=90  then  
	
		zhifufs="3"
		qudao="自收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
		grlunxunsum=0
		constr=""
		
		sql="select * from ayshoukuan where userid=0 and lei=3 and isok=1" 
		rss.open sql,conn,1,1
		if not(rss.bof and rss.eof) then
		do while not rss.eof
			grlunxunsum=grlunxunsum+1
			constr=constr&trim(rss("con"))&","
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
		rss.movenext
		loop
		end if
		rss.close
		
		if grlunxunsum=0 then 
		response.Write "{""err"":""没有可用收款方式""}"
		response.end
		end if
		
		'#####个人二维码代收 轮询开始
		if grlunxunsum>1 then
		constr=mid(constr,1,len(constr)-1)
		
			rss.open "select top 1 * from aybuylx where qudao='自收' and zhifufs=3 order by aylxid desc" ,conn,1,1
			if not(rss.bof and rss.eof) then
				if trim(rss("zishoufs"))<>"" and isnull(trim(rss("zishoufs")))=false then 	'最后一单 自收订单 自收接口 如：艺星24492628@qq.com
				lastzishoufs=trim(rss("zishoufs"))
				else
				lastzishoufs=""	
				end if
			end if
			rss.close
			
			fenjiestr=split(constr,",")	'获取已设置好的轮询接口个数	Ubound(fenjiestr)+1	单个具体位置 fenjiestr(0)
			lunxunzongshu=Ubound(fenjiestr)
			
			isyou="no"	'是否还存在已设置的轮询接口中
			nextzishounum=0
			For zishousum=0 To Ubound(fenjiestr)
				if lastzishoufs=fenjiestr(zishousum) then	'获取最后一单渠道 在已设置的轮询接口中的位置
				nextzishounum=zishousum+1								'下一个轮询接口 位置
				isyou="yes"
				if nextzishounum>lunxunzongshu then nextzishounum=0
				exit for
				end if
			next 
		
			if isyou="no" then
			nextzishoujiekou=fenjiestr(0)
			else
			nextzishoujiekou=fenjiestr(nextzishounum)
			end if
			
			sql="select * from ayshoukuan where con='"&nextzishoujiekou&"'" 
			rss.open sql,conn,1,1
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
			rss.close
			
		end if
		'#####个人二维码代收 轮询结束
	
	end if
end if

if trim(wangyinzhi)="JDPAY" then
end if
'生成支付方式 -结束



'获取商品成本价及常见错误检测
aygoodsuoyouid=gooduserid '初始本商户ID
rs.open "select * from aygood where aygoodid="&clng(shangid)&"",conn,1,1
aydingdancb=rs("aychenben")
aygoodname=rs("aygoodname")
aygooddlid=rs("aygooddlid")  			'上级代理ID 默认0无代理
aysjgid=rs("aysjgid")        			'上级商品ID
aysjjiage=rs("aysjjiage")               '代理价格
aychenben=rs("aychenben")               '成本价格

if clng(aygooddlid)<>0 then

if isusershoukuan="yes" or isshzishou="yes" then
response.Write "{""err"":""当前商家收款方式不支持代理关系""}":response.end
end if

	'是否批发  批发数量 价格 在本代理商调用
	if cint(rs("aypifayes"))=1 then 
	if ccur(quantity)>=ccur(rs("aypifa5")) then aysjjiage=rs("dailicb5")
	if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then aysjjiage=rs("dailicb4")
	if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then aysjjiage=rs("dailicb3")
	if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then aysjjiage=rs("dailicb2")
	if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then 
	aysjjiage=rs("dailicb1")
	else
	aysjjiage=rs("aysjjiage")
	end if
	end if
	
aygooddlfd=ccur(aysjjiage)*ccur(quantity)  '代理商 应如总价 代理价格或批发单价*购买数量
end if

if trim(rs("bugpass"))<>"" and isnull(trim(rs("bugpass")))=false then
	if bugpass="" then 
	call PopErr2("需要正确输入购卡密码，NP-err14","/")
	end if
	if bugpass<>trim(rs("bugpass")) then
	call PopErr2("需要正确输入购卡密码，NP-err14","/")
	end if
end if
if cint(rs("ayggodispass"))=1 then
	if trim(tikapass)="" then 
	call PopErr2("商家要求必须设置一个提卡密码，NP-err15","/")
	end if
end if
rs.close



'组织 代理关系 -结束
'saygooddlid=aygooddlid '初始 仅显示 上级代理 不显示总代理
dailistr=""
if clng(aygooddlid)<>0 then '是代理商品  
		For sum=1 To 10 '10层代理关系
		
			'aysjgid 上级商品ID 
			'aysjjiage 商品代理价格
			'aygoodsuoyouid 代理商 商户ID  
			'aygooddlid 上级代理 商户ID 
			'aygsumid 商品唯一标示
			
			if isnull(trim(aysjgid))=true or trim(aysjgid)="" then  '上级商品ID
			call PopErr("代理商品ID错误，NP-DL-"&aygooddlid&"-"&aysjgid&"-err1")'商品ID错误
			response.end 
			end if
			if clng(aysjgid)=0 then 
			call PopErr("代理商品ID错误，NP-DL-"&aygooddlid&"-"&aysjgid&"-err2")'商品ID错误
			response.end
			end if
			if ccur(aysjjiage)=0 then  '商品代理价格有误
			call PopErr("代理商品价格错误，NP-DL-"&aygooddlid&"-"&aysjgid&"-"&aysjjiage&"-err3")'代理商品价格错误
			response.end
			end if
		
			'验证代理关系                                                                                 '代理商 商户ID                        上级代理 商户ID 
			rs.open "select aydluserid,aydlsjuserid,aydlistongguo from aydailishang where aydluserid='"&clng(aygoodsuoyouid)&"' and aydlsjuserid='"&clng(aygooddlid)&"' and aydlistongguo=1",conn,1,1
			if rs.bof and rs.eof then 
			call PopErr("代理关系失效，NP-DL-"&gooduserid&"-"&aygooddlid&"-err4")'未找到代理关系
			response.end
			end if
			rs.close
			
			'获取代理商品ID                            '上级商品ID                          上级代理 商户ID 
			rs.open "select * from aygood where aygoodid="&clng(aysjgid)&" and aygoodsuoyouid="&clng(aygooddlid)&" and aygoodzhuangtai=0",conn,1,1
			if not(rs.bof and rs.eof) then 
				
				'上级代理 相关参数 卡密库 财务库 会员级别 费率
				set rsj=server.CreateObject("adodb.recordset")
				set rsjb=server.CreateObject("adodb.recordset")
				rsj.open "select aynameid,ayjibie,kamiku,ddku,cwku from ayname where aynameid="&aygooddlid&"",conn,1,1
				zkamiku=trim(rsj("kamiku"))
				zddku=trim(rsj("ddku"))
				zcwku=trim(rsj("cwku"))
				if rsj("ayjibie")<>5 and rsj("ayjibie")<>9 then
					rsjb.open "select * from ayujb where ayujbgid="&rsj("ayjibie")&"",conn,1,1
					if not(rsjb.bof and rsjb.eof) then
					zayalif=rsjb("ayujbalibl")   '非普通商户 支付宝交易价值比例 0为免费
					zaybankf=rsjb("ayujbbankbl") '非普通商户 网银交易价值比例 0为免费
					zsaomafei=rsjb("ayujbsaobl") '微信扫码
					zqqsaomafei=rsjb("ayujbqqbl")'QQ扫码
					zjdsaomafei=rsjb("jdsaomafei")
					end if
					rsjb.close 
				end if 
				rsj.close
				
				'查看上级代理是否为包年套餐商户
				rsj.open "select top 1 aytcuid,aytcbuyd,aytcsj,aytczt,aytcisyear,aytcyearf from aytaocanlog where aytcuid="&aygooddlid&" and aytcisyear=1 and aytczt=0" ,conn,1,1
				if not(rsj.bof and rsj.eof) then
					if DateDiff("d",rsj("aytcbuyd"),now())<=clng(rsj("aytcsj")) then  '*******套餐未过期
					zayalif=rsj("aytcyearf")  '包年套餐手续费价值
					zaytenf=rsj("aytcyearf")  
					zaybankf=rsj("aytcyearf")
					zsaomafei=rsj("aytcyearf")
					zqqsaomafei=rsj("aytcyearf")
					zjdsaomafei=rsj("aytcyearf")
					end if
				end if
				rsj.close
				
				
				pifachenben=rs("aychenben")
				'批发
				if cint(rs("aypifayes"))=1 then 
					if clng(rs("aygooddlid"))<>0 then '多层上级代理  成本=dailicb1
						if ccur(quantity)>=ccur(rs("aypifa5")) then pifachenben=rs("dailicb5")
						if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then pifachenben=rs("dailicb4")
						if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifachenben=rs("dailicb3")
						if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifachenben=rs("dailicb2")
						if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then
						pifachenben=rs("dailicb1")
						else
						pifachenben=rs("aychenben")
						end if
						
					else  '已是总代 成本=dailij1
						if ccur(quantity)>=ccur(rs("aypifa5")) then pifachenben=rs("dailij5")
						if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then pifachenben=rs("dailij4")
						if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifachenben=rs("dailij3")
						if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifachenben=rs("dailij2")
						if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then
						pifachenben=rs("dailij1")
						else
						pifachenben=rs("aychenben")
						end if
						
					end if
				end if

					   '代理商品成本    '上级商品成本价
				if ccur(aychenben)<ccur(pifachenben) then
				call PopErr("代理商品成本价格低于上级代理成本价格，NP-DL-err5")'代理成本价格低于上级代理成本价格
				response.end
				end if
				
				'上级代理入账 不含手续费
				if clng(rs("aygooddlid"))=0 then '已是总代
				caiwuyf=aysjjiage*ccur(quantity) '应付金额 用于利润统计
				ddzjzd=aysjjiage*ccur(quantity) '上级代理入款 = 商品代理价格
				else '多层上级代理
				caiwuyf=ccur(aysjjiage)-ccur(pifachenben) '应付金额 用于利润统计
				caiwuyf=ccur(caiwuyf)*ccur(quantity)
				ddzjzd=ccur(aysjjiage)-ccur(pifachenben) '上级代理入款 = 商品代理价 - 商品成本价或批发成本价
				ddzjzd=ddzjzd*ccur(quantity)
				end if
				

				
				'获取手续费后的价格  
				if wangyinzhi="1" or wangyinzhi="2" then
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zaybankf/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if
				if wangyinzhi="ALIPAY" then
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zayalif/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if
				if wangyinzhi="WEIXIN" then 
				if ccur(ddzjzd)>=1 then ddzjzd=ccur(ddzjzd)-ccur(zsaomafei/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if
				if wangyinzhi="QQPAY" then 
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zqqsaomafei/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if  
				if wangyinzhi="JDPAY" then 
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zjdsaomafei/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if 
				
				if ccur(ddzjzd)<=0 then 
				call logadd("0","NP-上级代理入款小于0",0,1)
				call PopErr2("上级代理入款应大于0，请联系商家，NP-err10","/")
				end if
				
				'                 序号|上级商品ID|上级商品代理价格|本商户ID|上级代理ID|上级卡密库|上级订单库|上级财务库|上级代理入款|统计利润金额
				dailistr=dailistr&sum&","&aysjgid&","&aysjjiage&","&aygoodsuoyouid&","&aygooddlid&","&zkamiku&","&zddku&","&zcwku&","&Formatnumber(ddzjzd,2,true,0,0)&","&caiwuyf&"|"
				
				if clng(rs("aygooddlid"))=0 then '已是顶级代理  
				rs.close
				exit for
				else
					aysjgid=rs("aysjgid") 			    '上级商品ID 
					aysjjiage=rs("aysjjiage") 		    '商品代理价格
					aygoodsuoyouid=rs("aygoodsuoyouid") '代理商 商户ID  
					aychenben=rs("aychenben")           '成本价格
					aygooddlid=rs("aygooddlid")		    '上级代理 商户ID 
					'批发
					if cint(rs("aypifayes"))=1 then 
						if ccur(quantity)>=ccur(rs("aypifa5")) then 
						aysjjiage=rs("dailicb5")
						aychenben=rs("dailicb5")
						end if
						if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then 
						aysjjiage=rs("dailicb4")
						aychenben=rs("dailicb4")
						end if
						if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then 
						aysjjiage=rs("dailicb3")
						aychenben=rs("dailicb3")
						end if
						if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then 
						aysjjiage=rs("dailicb2")
						aychenben=rs("dailicb2")
						end if
						if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then 
						aysjjiage=rs("dailicb1")
						aychenben=rs("dailicb1")
						else
						aysjjiage=rs("aysjjiage")
						aychenben=rs("aychenben")
						end if
					end if
				end if
				
			else
			call PopErr("未找到代理商品，NP-DL-err6")'未找到代理关系
			response.end
			end if
			rs.close
			
		next 
dailistr=mid(dailistr,1,len(dailistr)-1)
end if
'组织 代理关系 -结束




if clng(aygooddlid)<>0 then
ddzj=ccur(yingfuzongjia)-ccur(aygooddlfd) '代理商入账 不含手续费 应付总价-代理价格
'response.Write yingfuzongjia&"<br>"
'response.Write aygooddlfd&"<br>"
'response.end
end if



'获取手续费后的价格  
	if wangyinzhi="1" or wangyinzhi="2" then
	jiekoulirun=ccur(aybankf)-ccur(aychenbank) '接口利润
		if aybankf<>0 then 
		if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(aybankf/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
		end if
	end if
	
	if wangyinzhi="ALIPAY" then
		if isusershoukuan="yes" then
			jiekoulirun=0.6
			if ccur(ddzj)>=5 then yingkouyongjin=0.006*ddzj:else:yingkouyongjin=0.03:end if
			ddzj=0
			if ccur(yongjin)<ccur(yingkouyongjin) then
			response.Write "{""err"":""预存手续费不足""}"
			response.end
			end if
		else
			jiekoulirun=ccur(ayalif)-ccur(aychenalipay) 
			if ayalif<>0 then 
			if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(ayalif/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
			end if
		end if
	end if
	
	if wangyinzhi="WEIXIN" then
		if isusershoukuan="yes" then
			jiekoulirun=0.6
			if ccur(ddzj)>=5 then yingkouyongjin=0.006*ddzj:else:yingkouyongjin=0.03:end if
			ddzj=0
			if ccur(yongjin)<ccur(yingkouyongjin) then
			response.Write "{""err"":""预存手续费不足""}"
			response.end
			end if
		else
			jiekoulirun=ccur(saomafei)-ccur(saomacheng)
			if saomafei<>0 then 
			if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(saomafei/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
			end if
		end if	
	end if
	
	if wangyinzhi="QQPAY" then
		if isusershoukuan="yes" then
			jiekoulirun=0.6
			if ccur(ddzj)>=5 then yingkouyongjin=0.006*ddzj:else:yingkouyongjin=0.03:end if
			ddzj=0
			if ccur(yongjin)<ccur(yingkouyongjin) then
			response.Write "{""err"":""预存手续费不足""}"
			response.end
			end if
		else
			jiekoulirun=ccur(qqsaomafei)-ccur(qqsaomacheng) 
			if qqsaomafei<>0 then 
			if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(qqsaomafei/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
			end if
		end if	
	end if
	
	if wangyinzhi="JDPAY" then
	jiekoulirun=ccur(jdsaomafei)-ccur(jdsaomacheng) 
		if jdsaomafei<>0 then 
		if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(jdsaomafei/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
		end if
	end if

'代理商品 禁止0元入款
if ccur(ddzj)<=0 and isusershoukuan="no" then 
	call logadd("0","NP-入款小于0-"&ddzj&"-商品ID-"&shangid&"",0,1)
	call PopErr2("商品入款应大于0，请联系商家，NP-err11","/")
	response.End()
end if


'优惠券价值应小于订单价格一半
'if trim(youhuiquanzhi)<>"" then
'	if ccur(youhuiquanzhi)*2>=ccur(showddzj) then 
'	call logadd("0","NP-优惠券大于订单金额一般-"&youhuiquanzhi&"-"&showddzj&"-商品ID-"&shangid&"",0,1)
'	call PopErr2("优惠券禁止在该类商品价格范围使用，请联系商家，NP-err12","/")
'	end if
'end if



'检查订单是否被篡改  -开始
rs.open "select aygoodzhuangtai,aygoodid,aygoodfl,ayjiage,aypifayes,aypifa1,aypifa2,aypifa3,aypifa4,aypifa5,aypifaj1,aypifaj2,aypifaj3,aypifaj4,aypifaj5,ayyouhuiyes from aygood where aygoodid="&clng(shangid)&" and aygoodsuoyouid="&gooduserid&"",conn,1,1	
		if not(rs.bof and rs.eof) then 
					'商品状态检测
					if cint(rs("aygoodzhuangtai"))=1 then
					response.Write "{""err"":""该商品已下架""}"
					response.End()
					end if
					
					'商品隶属分类检测 
					if clng(feilei)<>clng(rs("aygoodfl")) then
					response.Write "{""err"":""商品分类信息获取失败，请重新尝试购买""}"
					response.End()
					end if
					
					'优惠券 
					if trim(youhuiquan)<>"" then
						'检测是否开启优惠券
						if cint(rs("ayyouhuiyes"))=0 then
						response.Write "{""err"":""商品优惠券信息错误，请重新尝试购买""}"
						response.End()
						end if
						'检测优惠券价值是否正确
						if ccur(chkbuyyouhuiquan(trim(youhuiquan),gooduserid))<>ccur(youhuiquanzhi) then
						response.Write "{""err"":""优惠券信息错误，请重新尝试购买""}"
						response.End()
						end if
					end if
					
					'不使用批发优惠
					if cint(rs("aypifayes"))=0 then 
								'与订单原价(单价)不符
								if ccur(goodyj)<>ccur(rs("ayjiage")) then 
								response.Write "{""err"":""订单单价有误，请重新尝试购买""}"
								response.End()
								end if
								'与订单总价不符
								ddyzj=ccur(rs("ayjiage"))*ccur(quantity)
								if ccur(showddzj)<>ccur(ddyzj) then 
								response.Write "{""err"":""订单总价有误，请重新尝试购买""}"
								response.End()
								end if
								'应付总价不符
								if zhifufangshi<>1 then
									if trim(youhuiquan)="" then  'if istelka="yes"
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										if ccur(yfzongjia)<>ccur(ddyzj) then 
										response.Write "{""err"":""应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									else
										kouyouhui=ccur(ddyzj)-ccur(youhuiquanzhi) '除去优惠券价值
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										if ccur(kouyouhui)<>ccur(yfzongjia) then
										response.Write "{""err"":""含优惠券应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									end if
								end if
					else '使用批发优惠
								'获取批发单价
								if clng(rs("aypifa5"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa5")) then pifadj=rs("aypifaj5")
									if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then pifadj=rs("aypifaj4")
									if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifadj=rs("aypifaj3")
									if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 		
								elseif clng(rs("aypifa4"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa4")) then pifadj=rs("aypifaj4")
									if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifadj=rs("aypifaj3")
									if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								elseif clng(rs("aypifa3"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa3")) then pifadj=rs("aypifaj3")
									if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								elseif clng(rs("aypifa2"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								elseif clng(rs("aypifa1"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								end if
									
								'与订单单价不符
								if ccur(danjia)<>ccur(pifadj) then 
								response.Write "{""err"":""订单单价有误，请重新尝试购买""}"
								response.End()
								end if
								'与订单总价不符
								ddyzj=ccur(pifadj)*ccur(quantity)
								if ccur(showddzj)<>ccur(ddyzj) then 
								response.Write "{""err"":""订单总价有误，请重新尝试购买""}"
								response.End()
								end if
								'应付总价不符
								if zhifufangshi<>1 then
									if trim(youhuiquan)="" then
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										if ccur(yfzongjia)<>ccur(ddyzj) then 
										response.Write "{""err"":""应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									else
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										kouyouhui=ccur(ddyzj)-ccur(youhuiquanzhi) '除去优惠券价值
										if ccur(kouyouhui)<>ccur(yfzongjia) then
										response.Write "{""err"":""含优惠券应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									end if
								end if
					end if
		else
		response.Write "{""err"":""未找到该订单商品""}"
		response.End()
		end if
		rs.close
'检查订单是否被篡改  -结束

'创建订单

'支付宝分账处理
isalipayfz_2=0
if cint(ayaisalipayfz)=1 and cint(isalipayfz)=1 and zhifufangshi<>1 and ccur(showddzj)>=10 and isusershoukuan="no" then
	if hour(now())>=cint(alipayfz1) and hour(now())<cint(alipayfz2) then 
	isalipayfz_2=1
	end if
end if

aybuyipxx=trim(userinip)&"@"&request.serverVariables("HTTP_USER_AGENT")

buyuseryu=0
'if buyuseryu=1 then zhifufangshi=99   	'支付方式 0网银 1充值卡 2支付宝 3财付通 4快捷 99余额

'微信接收卡密
openid="-"
if request.Cookies("openid")<>"" then openid=request.Cookies("openid")

'是否使用手机接收短信0.1元
msnurl="-"
if istelka="yes" then msnurl="yes" 

if isyiok="no" then
	if ccur(yingfuzongjia)<1 then 
		call PopErr2("订单金额不能低于1元，请联系商家或增加购买数量","/")
		response.End()
	end if
end if

strsign=""
strsign=trim(randarr)
strsign=strsign&trim(pid)
strsign=strsign&shangid
strsign=strsign&gooduserid
strsign=strsign&Formatnumber(yingfuzongjia,4,true,-1,0)
strsign=strsign&Formatnumber(ddzj,2,true,0,0)
strsign=strsign&Formatnumber(goodyj,4,true,-1,0)
strsign=strsign&Formatnumber(danjia,4,true,-1,0)
strsign=strsign&Formatnumber(showddzj,4,true,-1,0)
strsign=strsign&ptjiami
strsign=md5(strsign)
%>
<script language="javascript">
document.onkeydown=function mykeydown() { 
if(event.keyCode==116) { 
alert("请不要在此页面做刷新操作,以免影响正常支付!");
return false; 
}
}
</script>
<script language="JScript"> 
function copyToClipBoard(copycon)
{ 
	if(navigator.userAgent.indexOf("MSIE") == -1)
	{
	alert("您的浏览器非IE内核,请手动复制内容");
	return false;
	}
window.clipboardData.setData("Text",copycon); 
copyid.innerHTML ="<font color=#FF3300 size=2> [已复制]</font>";
} 
</script>
<table width="100%" height="900" border="0" cellpadding="0" cellspacing="0" class="www">
<tr>
<td valign="top">
<br><br>

<table width="860" height="624" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
	<td width="32" height="624" background="<%=ossurl%>images/payimg/pay_01.gif"></td>
	<td width="346" height="624">
	<table id="Table_01" width="346" height="624" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td width="346" height="22" background="<%=ossurl%>images/payimg/pay_02_01.gif"></td>
	</tr>
	<tr>
	<td>
<a href="<%=weburl%>" target="_blank"><img src="<%=ossurl%>images/payimg/pay_02_02.jpg" alt="" width="346" height="465" border="0"></a>
		</td>
	</tr>
	<tr>
		<td width="346" height="137" background="<%=ossurl%>images/payimg/pay_02_03.gif"></td>
	</tr>
</table></td>
		<td width="469" height="624" valign="top" bgcolor="#FFFFFF">
<br>
		
<table width="400" border="0" cellspacing="0" cellpadding="0" id="zhifu">
  <tr>
    <td>
<form <%=urlact%> name="form1" id="form1" onSubmit="return check_add()" target="_blank">
<table width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="353"><table width="336" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" align="center" ><span class="STYLE10">订 单 号：</span></td>
        <td width="77%" align="left" valign="top" ><span class="STYLE5"><%=trim(randarr)%></span>
		<span id="copyid"><a href="#" style="font-size:13px; text-decoration:none; color:#FF3300" onClick=copyToClipBoard('<%=randarr%>')> [复制]

</a></span>		</td>
      </tr>
      <%if cint(buyuseryu)=1 then%>
      <tr>
        <td height="25" align="center" ><span class="STYLE10"> 余额支付：</span> </td>
        <td align="left" valign="top" ><span class="STYLE5"><%=Formatnumber(buyuseryuekou,2,true,-1,0)%>元 </span></td>
      </tr>
      <%end if%>
      <tr>
        <td height="25" align="center"><span class="STYLE10">支付金额：</span></td>
        <td align="left" valign="top" ><span class="STYLE5"><%response.Write Formatnumber(yingfuzongjia,2,true,-1,0)%>元</span>
		</td>
      </tr>
      <tr>
        <td height="25" align="center" ><span class="STYLE10">商品名称： </span> </td>
        <td align="left" ><span class="STYLE2 STYLE11">
        <%response.Write trim(aygoodname)%></span></td>
      </tr>
      <tr>
        <td height="25" align="center" ><span class="STYLE10">联系方式：</span></td>
        <td align="left" ><span class="STYLE2 STYLE11"><%=contact%> </span></td>
      </tr>

      <%if youhuiquanzhi<>"" then%>
      <tr>
        <td height="25" align="center" ><span class="STYLE10">优惠券：</span> </td>
        <td align="left" ><span class="STYLE2 STYLE11">优惠
        <%
		youhuiquanstr=split(youhuiquanzhi,"%")
		if Ubound(youhuiquanstr)>0 then
		response.Write youhuiquanzhi
		else
		response.Write youhuiquanzhi&"元"
		end if
		%>
        </span></td>
      </tr>
      <%end if%>
      <%if email<>"" then %>
      <tr>
        <td height="25" align="center" ><span class="STYLE10">通知邮箱： </span> </td>
        <td align="left" ><span class="STYLE2 STYLE11"><%=email%></span></td>
      </tr>
      <%end if%>
      <tr>
        <td height="25" align="center" ><span class="STYLE10">支付方式：</span> </td>
        <td align="left" >
		<%if picpid="" then%>
		<span class="STYLE11">其他</span>
		<%else%>
        <img src="<%=ossurl%>images/pay/<%=pid%>.gif" /> 
		<%end if%>		
		</td>
      </tr>
      <tr >
        <td align="center" ></td>
        <td align="left"></td>
      </tr>
      <tr>
        <td colspan="2" align="left"></td>
      </tr>
      <tr>
        <td colspan="2" align="center">

		</td>
      </tr>
      <tr>
        <td colspan="2" align="center"></td>
      </tr>

    </table></td>
  </tr>
  <tr>
    <td height="160">
<% 
showrandarr=randarr '显示订单号
show_body="查询退款Q"&fuwuqq&"订单"&randarr  '中文 长商品说明
show_body1="查询退款Q"&fuwuqq				'中文 短商品说明
show_bodyy="QQ"&fuwuqq&"-"&randarr			'非中文 商品说明
z_body="buy"

'支付宝支付
if wangyinzhi="ALIPAY" then   
showstr="支付宝"

		if cint(aliqitajiekou)=1 then '使用IK接口 支付宝扫码
			qudao="28"
			isshowerweima="yes"  
			z_partner=toparkey("ayapipartner")
			signstr="z_partner="&z_partner&"&z_key="&toparkey("ayapikey")&"&z_trade_no="&randarr&"&z_total_fee="&Formatnumber(yingfuzongjia,4,true,-1,0) 
			z_sign=UCase(MD5(signstr))
			sfd=getHTTPPagwx(""&apijk&"api161208/alipay_sao.asp?z_partner="&z_partner&"&z_nurl="&toparkey("ayapinotify")&"&z_trade_no="&randarr&"&z_sign="&z_sign&"&z_total_fee="&yingfuzongjia&"&z_body="&z_body&"&z_fs=2&contact="&contact&"","gb2312")
			if trim(sfd)="notourl" then
			isshowerweima="no"
			end if
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if


		if cint(aliqitajiekou)=2 then '吉易支付宝
			qudao="吉易"
			isshowerweima="yes"
			partner=toparkey("jiyiid")
			key=toparkey("jiyikey")
			callbackurl=toparkey("jiyino")
			hrefbackurl=toparkey("jiyire")
			banktype="ALIPAY"   '扫码传ALIPAY   WAP传ALIPAYWAP
			channelcode="200001"	'扫码传200001    WAP传400001
			paymoney=yingfuzongjia
			ordernumber=randarr
			body=show_bodyy
			attach="buy"
			version="3.0"
			method="JiYi.online.interface"
			isshow="0"
			surl="http://gateway.jyipay.com/online/gateway"
			str="version="&version&"&"
			str=str&"method="&method&"&"
			str=str&"partner="&partner&"&"
			str=str&"banktype="&banktype&"&"
			str=str&"paymoney="&paymoney&"&"
			str=str&"ordernumber="&ordernumber&"&"
			str=str&"callbackurl="&callbackurl
			str=str&key
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "version",version
			d.Add "method",method
			d.Add "partner",partner
			d.Add "banktype", banktype
			d.Add "channelcode",channelcode
			d.Add "paymoney", paymoney
			d.Add "ordernumber", ordernumber
			d.Add "callbackurl", callbackurl
			d.Add "hrefbackurl", hrefbackurl
			d.Add "body", body
			d.Add "attach", attach
			d.Add "isshow", isshow
			d.Add "Sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			sfd=trim(json.qrurl)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if
				
		if cint(aliqitajiekou)=3 then '吉易2支付宝
			qudao="吉易2"
			isshowerweima="yes"
			partner=jiyiid2
			key=jiyikey2
			callbackurl=jiyino2
			hrefbackurl=jiyire2
			banktype="ALIPAY"   '扫码传ALIPAY   WAP传ALIPAYWAP
			channelcode="200001"	'扫码传200001    WAP传400001
			paymoney=yingfuzongjia
			ordernumber=randarr
			body=show_bodyy
			attach="buy"
			version="3.0"
			method="JiYi.online.interface"
			isshow="0"
			surl="http://gateway.jyipay.com/online/gateway"
			str="version="&version&"&"
			str=str&"method="&method&"&"
			str=str&"partner="&partner&"&"
			str=str&"banktype="&banktype&"&"
			str=str&"paymoney="&paymoney&"&"
			str=str&"ordernumber="&ordernumber&"&"
			str=str&"callbackurl="&callbackurl
			str=str&key
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "version",version
			d.Add "method",method
			d.Add "partner",partner
			d.Add "banktype", banktype
			d.Add "channelcode",channelcode
			d.Add "paymoney", paymoney
			d.Add "ordernumber", ordernumber
			d.Add "callbackurl", callbackurl
			d.Add "hrefbackurl", hrefbackurl
			d.Add "body", body
			d.Add "attach", attach
			d.Add "isshow", isshow
			d.Add "Sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			sfd=trim(json.qrurl)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if
		
		if cint(aliqitajiekou)=10 then '优畅支付宝
			qudao="优畅"
			isshowerweima="yes"
			mch_id=toparkey("youchangid")
			key=toparkey("youchangkey")
			notify_url=toparkey("youchangno")
			tourl = "http://mapi.bosc.uline.cc/alipay/orders/precreate" '支付宝	ALI_OFFLINE_NATIVE
			payment_code="ALI_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<qr_code>", "</qr_code>")
			else
            conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.End()
			end if
		end if
		
		if cint(aliqitajiekou)=11 then '优畅2支付宝
			qudao="优畅2"
			isshowerweima="yes"
			mch_id=youchangid2
			key=youchangkey2
			notify_url=youchangno2
			tourl = "http://mapi.bosc.uline.cc/alipay/orders/precreate" '支付宝	ALI_OFFLINE_NATIVE
			payment_code="ALI_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<qr_code>", "</qr_code>")
			else
            conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.End()
			end if
		end if
		
		
		if cint(aliqitajiekou)=30 then '上海汇付-威富通1 支付宝
			qudao="汇付"
			isshowerweima="yes"
			time_start=year(now)&FillZero(month(now))&FillZero(day(now))&FillZero(hour(now))&FillZero(minute(now))&FillZero(second(now))
			Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
			packageParams.Add "attach", z_body       '随机字符串，商户可自定义
			packageParams.Add "body", show_bodyy                     '商品描述
			packageParams.Add "charset", "UTF-8" 
			packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
			packageParams.Add "mch_id", huifu_id              '商户号
			packageParams.Add "nonce_str", z_body 
			packageParams.Add "notify_url", huifu_no         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
			packageParams.Add "out_trade_no", randarr          '商户订单号
			packageParams.Add "service", "pay.alipay.nativev2"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
			packageParams.Add "sign_type", "MD5" 
			packageParams.Add "time_start", time_start 
			packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
			packageParams.Add "version", "2.0" 
			strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			surl = "https://pay.swiftpass.cn/pay/gateway"
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", surl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstrwft(http.ResponseBody)
			Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
			If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
			If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
			sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"%3A%2F%2F","://")
			sfd=replace(sfd,"%2F","/")
			sfd=replace(sfd,"%3F","?")
			sfd=replace(sfd,"%3D","=")
			sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if
		
		if cint(aliqitajiekou)=31 then '上海汇付-威富通2 支付宝
			qudao="汇付2"
			isshowerweima="yes"
			time_start=year(now)&FillZero(month(now))&FillZero(day(now))&FillZero(hour(now))&FillZero(minute(now))&FillZero(second(now))
			Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
			packageParams.Add "attach", z_body       '随机字符串，商户可自定义
			packageParams.Add "body", show_bodyy                     '商品描述
			packageParams.Add "charset", "UTF-8" 
			packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
			packageParams.Add "mch_id", huifu_id2              '商户号
			packageParams.Add "nonce_str", z_body 
			packageParams.Add "notify_url", huifu_no2         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
			packageParams.Add "out_trade_no", randarr          '商户订单号
			packageParams.Add "service", "pay.alipay.nativev2"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
			packageParams.Add "sign_type", "MD5" 
			packageParams.Add "time_start", time_start 
			packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
			packageParams.Add "version", "2.0" 
			strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key2
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			surl = "https://pay.swiftpass.cn/pay/gateway"
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", surl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstrwft(http.ResponseBody)
			Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
			If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
			If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
			sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"%3A%2F%2F","://")
			sfd=replace(sfd,"%2F","/")
			sfd=replace(sfd,"%3F","?")
			sfd=replace(sfd,"%3D","=")
			sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if
		
end if




'QQ支付
if trim(wangyinzhi)="QQPAY" then
showstr="手Q"
feeq=yingfuzongjia*100
				
			if cint(qqqitajiekou)=30 then  '*****使用 IK接口 QQ扫码支付 ******
				qudao="28"
				isshowerweima="yes"
				z_partner=toparkey("ayapipartner")
				signstr="z_partner="&z_partner&"&z_key="&toparkey("ayapikey")&"&z_trade_no="&randarr&"&z_total_fee="&Formatnumber(yingfuzongjia,4,true,-1,0) 
				z_sign=UCase(MD5(signstr))
				sfd=getHTTPPagwx(""&apijk&"api161208/qq_sao.asp?z_partner="&z_partner&"&z_nurl="&toparkey("ayapinotify")&"&z_trade_no="&randarr&"&z_sign="&z_sign&"&z_total_fee="&yingfuzongjia&"&z_body="&z_body&"&z_fs=6&contact="&contact&"","gb2312")
				if trim(sfd)="notourl" then
				isshowerweima="no"
				end if
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			end if
				
			if cint(qqqitajiekou)=15 then '掌灵qq	
				qudao="掌灵"
				isshowerweima="yes"
				Set d =Server.CreateObject("Scripting.Dictionary")
				Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
				d.Add "amount",yingfuzongjia*100
				d.Add "body",z_body
				d.Add "mchntOrderNo",randarr
				d.Add "notifyUrl", toparkey("zlno")
				d.Add "payChannelId","2000000003" '支付宝0000000002 微信2100000001  QQ 2000000003 微信H5 2000000001 
				d.Add "returnUrl", toparkey("zlno") 
				d.Add "subject", show_body
				result=parseURL(d)
				xmlhttp.Open "POST", weburl&"pay/mingtian/index.php", false
				xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
				xmlhttp.Send result		
				codeurl=xmlhttp.responseTEXT
				Set json = toObject(codeurl)
				codeurl=split(json.extra,"&")
				sfd=replace(codeurl(0),"code_url="," ")
				sfd=trim(sfd)
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			end if
				
			if cint(qqqitajiekou)=16 then '掌灵qq2	
				qudao="掌灵2"
				isshowerweima="yes"
				Set d =Server.CreateObject("Scripting.Dictionary")
				Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
				d.Add "amount",yingfuzongjia*100
				d.Add "body",z_body
				d.Add "mchntOrderNo",randarr
				d.Add "notifyUrl", zlno2
				d.Add "payChannelId","2000000003" '支付宝0000000002 微信2100000001  QQ 2000000003 微信H5 2000000001 
				d.Add "returnUrl", zlno2 
				d.Add "subject", show_body
				result=parseURL(d)
				xmlhttp.Open "POST", weburl&"pay/mingtian2/index.php", false
				xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
				xmlhttp.Send result		
				codeurl=xmlhttp.responseTEXT
				Set json = toObject(codeurl)
				codeurl=split(json.extra,"&")
				sfd=replace(codeurl(0),"code_url="," ")
				sfd=trim(sfd)
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			end if
			
			if cint(qqqitajiekou)=19 then '优畅qq
				qudao="优畅"
				isshowerweima="yes"
				mch_id=toparkey("youchangid")
				key=toparkey("youchangkey")
				notify_url=toparkey("youchangno")
				tourl = "http://mapi.bosc.uline.cc/qqpay/orders" 
				payment_code="QQ_OFFLINE_NATIVE"	
				total_fee=yingfuzongjia*100
				out_trade_no=randarr
				nonce_str=randarr
				body=show_bodyy										
				attach="buy"										
				spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
				trade_type="NATIVE"		
				Set packageParams = CreateObject("Scripting.Dictionary")
				packageParams.Add "mch_id", mch_id
				packageParams.Add "nonce_str", nonce_str
				packageParams.Add "body", body
				packageParams.Add "attach", attach 
				packageParams.Add "out_trade_no", out_trade_no
				packageParams.Add "total_fee", total_fee
				packageParams.Add "spbill_create_ip", spbill_create_ip
				packageParams.Add "notify_url", notify_url
				packageParams.Add "trade_type", trade_type 
				packageParams.Add "payment_code", payment_code
				strsign2 = createSHA1Sign(packageParams) & "&key="&key
				sign = UCase(md5(strsign2))
				packageParams.Add "sign", sign
				para = parseXML(packageParams)
				Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
				http.Option(4) = 13056
				http.Option(6) = False
				http.SetTimeouts 5000, 10000, 10000, 10000
				http.Open "POST", tourl, False
				http.SetRequestHeader "Connection", "Keep-Alive"
				http.SetRequestHeader "User-Agent", "Mozilla/4.0"
				http.SetRequestHeader "Content-Length", Len(data)
				http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
				http.Send para
				body = BytesToBstr(http.ResponseBody, "utf-8")
				return_code = mysubstr(body, "<return_code>", "</return_code>")
				result_code = mysubstr(body, "<result_code>", "</result_code>")
				if return_code="SUCCESS" and result_code="SUCCESS" then 
				sfd = mysubstr(body, "<code_url>", "</code_url>")
				else
				conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
				response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
				response.End()
				end if
			end if
			
			
			if cint(qqqitajiekou)=0 then '官方
				qudao="官方"
				isshowerweima="yes"
				ver="2.0"
				charset="2"
				bank_type="0"
				pay_channel="1"
				fee_type="1"
				bargainor_id=toparkey("qqpar")
				key=toparkey("qqkey")
				notify_url=toparkey("qqnotify")
				sp_billno=randarr
				desc = show_bodyy  
				attach=z_body
				toUrl = "http://myun.tenpay.com/cgi-bin/wappayv2.0/wappay_init.cgi" 
				signstr="attach="&attach
				signstr=signstr&"&bank_type="&bank_type
				signstr=signstr&"&bargainor_id="&bargainor_id
				signstr=signstr&"&charset="&charset
				signstr=signstr&"&desc="&desc
				signstr=signstr&"&fee_type="&fee_type
				signstr=signstr&"&notify_url="&notify_url
				signstr=signstr&"&pay_channel="&pay_channel
				signstr=signstr&"&sp_billno="&sp_billno
				signstr=signstr&"&total_fee="&feeq
				signstr=signstr&"&ver="&ver
				signstr=signstr&"&key="&key
				sign=MD5(signstr)
				sign=UCase(sign)
				str=getHTTPPagwx(""&toUrl&"?attach="&attach&"&bank_type="&bank_type&"&bargainor_id="&bargainor_id&"&charset="&charset&"&desc="&desc&"&fee_type="&fee_type&"&notify_url="&notify_url&"&pay_channel="&pay_channel&"&purchaser_id="&purchaser_id&"&sign="&sign&"&sp_billno="&sp_billno&"&time_expire="&time_expire&"&time_start="&time_start&"&total_fee="&feeq&"&ver="&ver&"","gb2312")
				str=mid(str,instr(1,str,"<token_id>")+10)
				str=replace(str,"</token_id></root>"," ")
				sfd="http://myun.tenpay.com/mqq/pay/qrcode.html?t="&trim(str)
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			end if
            
end if




'微信支付
if trim(wangyinzhi)="WEIXIN" then
showstr="微信"
feeq=yingfuzongjia*100
	
	if cint(wxqitajiekou)=0 then '官方
		isshowerweima="yes"
		notifyUrl = toparkey("saomanotify")
		notifyUrl=replace(notifyUrl,"{siteweb}",Request.ServerVariables("SERVER_NAME"))
		Function getSign(signParams)
		Dim keys,k,v,i,j,md5str,sign
		keys	= signParams.Keys()
		for i=0 to UBound(keys)-1
			for j=i+1 to UBound(keys)
			if StrComp(keys(i), keys(j)) > 0 then 
			tmp=keys(i)
			keys(i)=keys(j)
			keys(j)=tmp
			end if
			next
		next
		For Each k in keys
		v = signParams(k)
		if v <> "" and k <> "sign" and k <> "key" then
		md5str	= md5str & k & "=" & v & "&"
		end if
		Next
		md5str	= md5str & "key=" & skey
		sign	= UCase(md5(md5str))
		getSign	= sign
		End Function
		function checkSign(signParams,sing)
		hqsign = getSign(signParams)
		if hqsign=sing then
		checkSign=true
		else
		checkSign=false
		end if
		end function
		Set d =Server.CreateObject("Scripting.Dictionary")
		Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
		d.Add "body_title",show_body
		d.Add "out_trade_no",randarr
		d.Add "total_fee",feeq
		d.Add "trade_type","NATIVE"
		d.Add "attach", z_body
		qudao="官方"
		d.Add "notify_url",notifyUrl
		d.Add "appid", toparkey("appid")
		d.Add "mch_id", toparkey("mchid")
		d.Add "paykey", toparkey("skey")
		result=parseURL(d)
		xmlhttp.Open "POST", toparkey("saomatourl"), false
		xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
		xmlhttp.Send result		
		sfd=xmlhttp.responseTEXT
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
	end if
	
	
	if cint(wxqitajiekou)=2 then  '*****使用 IK接口******
		qudao="28"
		isshowerweima="yes"
		z_partner=toparkey("ayapipartner")
		signstr="z_partner="&z_partner&"&z_key="&toparkey("ayapikey")&"&z_trade_no="&randarr&"&z_total_fee="&Formatnumber(yingfuzongjia,4,true,-1,0) 
		z_sign=UCase(MD5(signstr))
		sfd=getHTTPPagwx(""&apijk&"api161208/weixin_sao.asp?z_partner="&z_partner&"&z_nurl="&toparkey("ayapinotify")&"&z_trade_no="&randarr&"&z_sign="&z_sign&"&z_total_fee="&yingfuzongjia&"&z_body="&z_body&"&z_fs=5&contact="&contact&"","gb2312")
		if trim(sfd)="notourl" then
		isshowerweima="no"
		end if
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
	end if
	
	
		if cint(wxqitajiekou)=3 then '吉易微信
			qudao="吉易"
			isshowerweima="yes"
			mch_id=toparkey("jiyiid")
			jiyikey=toparkey("jiyikey")
			notify_url=toparkey("jiyino")
			return_url=toparkey("jiyire")
			attach="buy"
			body=show_bodyy
			charset="utf-8"
			out_trade_no=randarr
			payment_code="8001"		'支付渠道编码	8001微信扫码支付	8004支付宝扫码支付
			sign_type="MD5"
			timestamp=now()
			total_fee=yingfuzongjia
			version="1.0"
			surl="http://pay.jipays.com/gateway"
			str="attach="&attach&"&"
			str=str&"body="&body&"&"
			str=str&"charset="&charset&"&"
			str=str&"mch_id="&mch_id&"&"
			str=str&"notify_url="&notify_url&"&"
			str=str&"out_trade_no="&out_trade_no&"&"
			str=str&"payment_code="&payment_code&"&"
			str=str&"return_url="&return_url&"&"
			'str=str&"sign_type="&sign_type&"&"
			str=str&"timestamp="&timestamp&"&"
			str=str&"total_fee="&total_fee&"&"
			str=str&"version="&version&"&"
			str=str&"key="&jiyikey
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "attach",attach
			d.Add "body",body
			d.Add "charset",charset
			d.Add "mch_id", mch_id
			d.Add "notify_url",notify_url
			d.Add "out_trade_no", out_trade_no
			d.Add "payment_code", payment_code
			d.Add "return_url", return_url
			d.Add "sign_type", sign_type
			d.Add "timestamp", timestamp
			d.Add "total_fee", total_fee
			d.Add "version", version
			d.Add "sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded;charset=utf-8"
			xmlhttp.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			'response.Write json.data.qrcode_url
			sfd=trim(json.data.qrcode_url)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if
	
		if cint(wxqitajiekou)=4 then '吉易2微信
			qudao="吉易2"
			isshowerweima="yes"
			mch_id=jiyiid2
			jiyikey=jiyikey2
			notify_url=jiyino2
			return_url=jiyire2
			attach="buy"
			body=show_bodyy
			charset="utf-8"
			out_trade_no=randarr
			payment_code="8001"		'支付渠道编码	8001微信扫码支付	8004支付宝扫码支付
			sign_type="MD5"
			timestamp=now()
			total_fee=yingfuzongjia
			version="1.0"
			surl="http://pay.jipays.com/gateway"
			str="attach="&attach&"&"
			str=str&"body="&body&"&"
			str=str&"charset="&charset&"&"
			str=str&"mch_id="&mch_id&"&"
			str=str&"notify_url="&notify_url&"&"
			str=str&"out_trade_no="&out_trade_no&"&"
			str=str&"payment_code="&payment_code&"&"
			str=str&"return_url="&return_url&"&"
			'str=str&"sign_type="&sign_type&"&"
			str=str&"timestamp="&timestamp&"&"
			str=str&"total_fee="&total_fee&"&"
			str=str&"version="&version&"&"
			str=str&"key="&jiyikey
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "attach",attach
			d.Add "body",body
			d.Add "charset",charset
			d.Add "mch_id", mch_id
			d.Add "notify_url",notify_url
			d.Add "out_trade_no", out_trade_no
			d.Add "payment_code", payment_code
			d.Add "return_url", return_url
			d.Add "sign_type", sign_type
			d.Add "timestamp", timestamp
			d.Add "total_fee", total_fee
			d.Add "version", version
			d.Add "sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded;charset=utf-8"
			xmlhttp.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			'response.Write json.data.qrcode_url
			sfd=trim(json.data.qrcode_url)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		end if
	
	if cint(wxqitajiekou)=5 then '掌灵微信
		qudao="掌灵"
		isshowerweima="yes"
		Set d =Server.CreateObject("Scripting.Dictionary")
		Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
		d.Add "amount",yingfuzongjia*100
		d.Add "body",z_body
		d.Add "mchntOrderNo",randarr
		d.Add "notifyUrl", toparkey("zlno")
		d.Add "payChannelId","2100000001" '支付宝0000000002 微信2100000001  
		d.Add "returnUrl", toparkey("zlno") 
		d.Add "subject", show_body
		result=parseURL(d)
		xmlhttp.Open "POST", weburl&"pay/mingtian/index.php", false
		xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
		xmlhttp.Send result		
		codeurl=xmlhttp.responseTEXT
		'response.Write codeurl 
		'response.End()
		Set json = toObject(codeurl)
		codeurl=split(json.extra,"&")
		sfd=replace(codeurl(0),"code_url="," ")
		sfd=trim(sfd)
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
	end if
	
	if cint(wxqitajiekou)=6 then '掌灵微信2
		qudao="掌灵2"
		isshowerweima="yes"
		Set d =Server.CreateObject("Scripting.Dictionary")
		Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
		d.Add "amount",yingfuzongjia*100
		d.Add "body",z_body
		d.Add "mchntOrderNo",randarr
		d.Add "notifyUrl", zlno2
		d.Add "payChannelId","2100000001" '支付宝0000000002 微信2100000001  
		d.Add "returnUrl", zlno2 
		d.Add "subject", show_body
		result=parseURL(d)
		xmlhttp.Open "POST", weburl&"pay/mingtian2/index.php", false
		xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
		xmlhttp.Send result		
		codeurl=xmlhttp.responseTEXT
		'response.Write codeurl
		'response.End()
		Set json = toObject(codeurl)
		codeurl=split(json.extra,"&")
		sfd=replace(codeurl(0),"code_url="," ")
		sfd=trim(sfd)
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
	end if
 
	
	if cint(wxqitajiekou)=10 then '系统默认 优畅微信
		qudao="优畅"
		isshowerweima="yes"
			mch_id=toparkey("youchangid")
			key=toparkey("youchangkey")
			notify_url=toparkey("youchangno")
			tourl = "http://mapi.bosc.uline.cc/wechat/orders"
			payment_code="WX_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<code_url>", "</code_url>")
			else
			conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.End()
			end if
	end if
	
	
	if cint(wxqitajiekou)=12 then '优畅2微信
		qudao="优畅2"
		isshowerweima="yes"
			mch_id=youchangid2
			key=youchangkey2
			notify_url=youchangno2
			tourl = "http://mapi.bosc.uline.cc/wechat/orders"
			payment_code="WX_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<code_url>", "</code_url>")
			else
			conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.End()
			end if
	end if
	
	
	if cint(wxqitajiekou)=30 then '上海汇付-威富通微信
		qudao="汇付"
	    isshowerweima="yes"
		Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
		packageParams.Add "attach", z_body
		packageParams.Add "service", "pay.weixin.native"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
		packageParams.Add "mch_id", huifu_id              '商户号
		packageParams.Add "out_trade_no", randarr          '商户订单号
		packageParams.Add "body", show_bodyy                     '商品描述
		packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
		packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
		packageParams.Add "notify_url", huifu_no         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
		packageParams.Add "nonce_str", randarr       '随机字符串，商户可自定义
		strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		surl = "https://pay.swiftpass.cn/pay/gateway"
		http.SetTimeouts 5000, 10000, 10000, 10000
		http.Open "POST", surl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstrwft(http.ResponseBody)
		'response.Write server.HTMLEncode(body)
		Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
		If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
		sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"%3A%2F%2F","://")
		sfd=replace(sfd,"%2F","/")
		sfd=replace(sfd,"%3F","?")
		sfd=replace(sfd,"%3D","=")
		sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
	end if

	if cint(wxqitajiekou)=31 then '上海汇付-威富通微信2
		qudao="汇付2"
	    isshowerweima="yes"
		Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
		packageParams.Add "attach", z_body
		packageParams.Add "service", "pay.weixin.native"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
		packageParams.Add "mch_id", huifu_id2              '商户号
		packageParams.Add "out_trade_no", randarr          '商户订单号
		packageParams.Add "body", show_bodyy                     '商品描述
		packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
		packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
		packageParams.Add "notify_url", huifu_no2         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
		packageParams.Add "nonce_str", randarr       '随机字符串，商户可自定义
		strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key2
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		surl = "https://pay.swiftpass.cn/pay/gateway"
		http.SetTimeouts 5000, 10000, 10000, 10000
		http.Open "POST", surl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstrwft(http.ResponseBody)
		Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
		If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
		sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"%3A%2F%2F","://")
		sfd=replace(sfd,"%2F","/")
		sfd=replace(sfd,"%3F","?")
		sfd=replace(sfd,"%3D","=")
		sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
	end if
	
	
	
	if cint(wxqitajiekou)=50 then '优畅50 【公众号URL直接访问  扫码URL生成二维码】
		qudao="优畅50"
	    isshowerweima="yes"
		mch_id=ycnewid50
		appid=ycnewappid50
		key=ycnewkey50
		notify_url=youchangno50
		Set packageParams = CreateObject("Scripting.Dictionary")
		packageParams.Add "appid", appid
		packageParams.Add "attach", z_body
		packageParams.Add "body", show_bodyy
		packageParams.Add "mch_id", mch_id
		packageParams.Add "method", "mbupay.unifpay.native"
		packageParams.Add "nonce_str", randarr
		packageParams.Add "notify_url", notify_url
		packageParams.Add "out_trade_no", randarr
		packageParams.Add "total_fee", yingfuzongjia*100
		strsign2 = createSHA1Sign(packageParams) & "&key="&key
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		http.SetTimeouts 5000, 10000, 10000, 10000
		tourl = "https://api.tnbpay.com/pay/gateway"
		http.Open "POST", tourl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstr(http.ResponseBody, "utf-8")
		'response.Write server.HTMLEncode(body)
		'response.End()
		return_code = mysubstr(body, "<return_code><![CDATA[", "]]></return_code>")
		if return_code="FAIL" then
		return_msg = mysubstr(body, "<return_msg><![CDATA[", "]]></return_msg>")
		'response.Write return_msg
		conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&return_msg&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
		response.End()
		end if
		result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		if return_code="SUCCESS" and result_code="SUCCESS" then
		code_url = mysubstr(body, "<code_url><![CDATA[", "]]></code_url>")
		'response.Write code_url&"<br>"
		sfd=code_url
		end if
	end if
	
	if cint(wxqitajiekou)=51 then '优畅51 【公众号URL直接访问  扫码URL生成二维码】
		qudao="优畅51"
	    isshowerweima="yes"
		mch_id=ycnewid51
		appid=ycnewappid51
		key=ycnewkey51
		notify_url=youchangno51
		Set packageParams = CreateObject("Scripting.Dictionary")
		packageParams.Add "appid", appid
		packageParams.Add "attach", z_body
		packageParams.Add "body", show_bodyy
		packageParams.Add "mch_id", mch_id
		packageParams.Add "method", "mbupay.unifpay.native"
		packageParams.Add "nonce_str", randarr
		packageParams.Add "notify_url", notify_url
		packageParams.Add "out_trade_no", randarr
		packageParams.Add "total_fee", yingfuzongjia*100
		strsign2 = createSHA1Sign(packageParams) & "&key="&key
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		http.SetTimeouts 5000, 10000, 10000, 10000
		tourl = "https://api.tnbpay.com/pay/gateway"
		http.Open "POST", tourl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstr(http.ResponseBody, "utf-8")
		'response.Write server.HTMLEncode(body)
		'response.End()
		return_code = mysubstr(body, "<return_code><![CDATA[", "]]></return_code>")
		if return_code="FAIL" then
		return_msg = mysubstr(body, "<return_msg><![CDATA[", "]]></return_msg>")
		'response.Write return_msg
		conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&return_msg&"','shop/newp.asp','"&randarr&"','"&qudao&"','"&wangyinzhi&"','PC')")
		response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
		response.End()
		end if
		result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		if return_code="SUCCESS" and result_code="SUCCESS" then
		code_url = mysubstr(body, "<code_url><![CDATA[", "]]></code_url>")
		'response.Write code_url&"<br>"
		sfd=code_url
		end if
	end if
	
	
end if


'京东支付
if trim(wangyinzhi)="JDPAY" then
showstr="京东"
end if
 

if err.number<>0 then response.Write "{""err"":""Err-["&Err.Description&"]，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}":response.end 


'浏览器缓存订单号
hostbiaoshi="A"		'服务器标示
if request.Cookies("ikpayddh")<>"" then

	ikpayddhstr=request.Cookies("ikpayddh")
	sumikpayddh=split(ikpayddhstr,"|")					'数量  6     Ubound(sumikpayddh)     总数-1
	
	if Ubound(sumikpayddh)>=30 then						'上限个数
	laststr=sumikpayddh(Ubound(sumikpayddh)-1)&"|"		'A&DAB164215112269824|
	laststrCookies=replace(ikpayddhstr,laststr," ")
	laststrCookies=trim(laststrCookies)
	response.Cookies("ikpayddh")=laststrCookies
	end if

	'if instr(1,request.Cookies("ikpayddh"),randarr&"|")=0 then
	response.Cookies("ikpayddh")=hostbiaoshi&"&"&randarr&"|"&request.Cookies("ikpayddh")
	response.Cookies("ikpayddh").expires=DateAdd("n",60,now())
	'end if
	
else
response.Cookies("ikpayddh")=hostbiaoshi&"&"&randarr&"|"
response.Cookies("ikpayddh").expires=DateAdd("n",60,now())
end if


'rs.open "select top 1 aydingdansum from "&ddku&" where aydingdansum='"&randarr&"' order by aydingdanid desc",conn,1,1
'if not(rs.bof and rs.eof) then
'response.Write "{""err"":""订单号重复""}"
'response.End()
'end if
'rs.close


			if isshowerweima="yes" then 
			conn.Execute("Insert Into "&ddku&"(isalipayfz,apicheng,aydingdansum,aydingdanuser,aydigndanyf,aydingdanyj,aydingdanjin,aydingdanzj,shangqq,aydingdanin,aydingdancb,ayddquantity,ayddfeileiid,ayddshangid,aybuyipxx,ayddcontact,ayddpid,aydingdansj,aydingdanpass,ayddyouhuiquanzhi,ayddyouhuiquan,ayddemail,ayddzffangshi,ayddsign,dailikuo,openid,msnurl,qudao,ayddbuyid,lailuyu) values('"&isalipayfz_2&"','"&jiekoulirun&"','"&randarr&"','"&gooduserid&"','"&yingfuzongjia&"','"&goodyj&"','"&danjia&"','"&showddzj&"','"&shanghuqq&"','"&Formatnumber(ddzj,2,true,0,0)&"','"&aydingdancb&"','"&quantity&"','"&clng(feilei)&"','"&clng(shangid)&"','"&aybuyipxx&"','"&contact&"','"&trim(pid)&"','"&now()&"','"&trim(tikapass)&"','"&youhuiquanzhi&"','"&youhuiquan&"','"&email&"','"&zhifufangshi&"','"&strsign&"','"&dailistr&"','"&openid&"','"&msnurl&"','"&qudao&"','"&ayddbuyid&"','"&request.Cookies("lailuyu")&"')")
			conn.Execute("Insert Into aybuylx(aylxcon,aylxku,aydddsum,aylxbuyid,qudao,suid) values('"&contact&"','"&ddku&"','"&randarr&"','"&ayddbuyid&"','"&qudao&"','"&gooduserid&"')")
			if err.number<>0 then response.Write "{""err"":""Err-"&Err.Description&"入库错误，请重新尝试或联系管理员""}":response.end 	
			response.Cookies("timed")=now()
			%>
			<table border="0" align="center" cellpadding="0" cellspacing="0">
			  <tr>
				<td width="336"><br>
				<div style="float:left;border:1px solid #CCCCCC; width:150px; height:170px;"><div id="qrcode"></div>
                <div align="center">请使用<%=showstr%>扫一扫</div>
                </div>
				<div style="float:left; padding-left:15px;"><img src="<%=ossurl%>images/sao.jpg" width="160" height="170" /></div>
                <script type="text/javascript">var qrcode = new QRCode(document.getElementById("qrcode"), {width:150,height:150});qrcode.makeCode("<%=trim(ReplaceTrim(sfd))%>");</script>
				</td>
			  </tr>
			</table>
			<%
			else
			
			'自收接口
			iserweimashou="no"
			if pid="ALIPAY" and (cint(aliqitajiekou)=90 or cint(aliqitajiekou)=91) then iserweimashou="yes"
			if pid="WEIXIN" and (cint(wxqitajiekou)=90 or cint(wxqitajiekou)=91) then iserweimashou="yes"
			if pid="QQPAY" and (cint(qqqitajiekou)=90 or cint(qqqitajiekou)=91) then iserweimashou="yes"
			
			if iserweimashou="yes" then  
			nextjsum=zishoujj(yingfuzongjia,zishoufs,contact)	'应加分
			jjjin=ccur(yingfuzongjia)+ccur(nextjsum)/100	'加价后应付价格
			conn.Execute("Insert Into ddlasttime(ddhao) values('"&randarr&"')")
			conn.Execute("Insert Into aybuylx(aylxcon,aylxku,aydddsum,aylxbuyid,aylxjin,zishoufs,jjjzj,qudao,suid,zhifufs) values('"&contact&"','"&ddku&"','"&randarr&"','"&ayddbuyid&"','"&yingfuzongjia&"','"&zishoufs&"','"&nextjsum&"','"&qudao&"','"&gooduserid&"','"&zhifufs&"')")
			else
			conn.Execute("Insert Into aybuylx(aylxcon,aylxku,aydddsum,aylxbuyid) values('"&contact&"','"&ddku&"','"&randarr&"','"&ayddbuyid&"')")
			end if
			
			conn.Execute("Insert Into "&ddku&"(isalipayfz,apicheng,aydingdansum,aydingdanuser,aydigndanyf,aydingdanyj,aydingdanjin,aydingdanzj,shangqq,aydingdanin,aydingdancb,ayddquantity,ayddfeileiid,ayddshangid,aybuyipxx,ayddcontact,ayddpid,aydingdansj,aydingdanpass,ayddyouhuiquanzhi,ayddyouhuiquan,ayddemail,ayddzffangshi,ayddsign,dailikuo,openid,msnurl,qudao,ayddbuyid,lailuyu,zishoufs,jjjzj,yongjin) values('"&isalipayfz_2&"','"&jiekoulirun&"','"&randarr&"','"&gooduserid&"','"&yingfuzongjia&"','"&goodyj&"','"&danjia&"','"&showddzj&"','"&shanghuqq&"','"&Formatnumber(ddzj,2,true,0,0)&"','"&aydingdancb&"','"&quantity&"','"&clng(feilei)&"','"&clng(shangid)&"','"&aybuyipxx&"','"&contact&"','"&trim(pid)&"','"&now()&"','"&trim(tikapass)&"','"&youhuiquanzhi&"','"&youhuiquan&"','"&email&"','"&zhifufangshi&"','"&strsign&"','"&dailistr&"','"&openid&"','"&msnurl&"','"&qudao&"','"&ayddbuyid&"','"&request.Cookies("lailuyu")&"','"&zishoufs&"','"&nextjsum&"','"&yingkouyongjin&"')")
			
			
			if err.number<>0 then response.Write "{""err"":""Err-"&Err.Description&"入库错误，请重新尝试或联系管理员""}":response.end 
			response.Cookies("timed")=now()	
			end if%>

	
	
<br>
<div id="protect22">
<%
if isxinyongka="1" then pid=" "
response.Cookies("openid")=""

'初始化 爱普接口 清空其他无用参数 开始
'初始化 爱普接口 清空其他无用参数 结束



if isguolvallcan="no" then

		if zhifufangshi<>99 and ccur(yingfuzongjia)<>0 then%>
		<input name="z_total_fee" type="hidden" value="<%=yingfuzongjia%>" />
		<input name="z_trade_no" type="hidden" value="<%=randarr%>" />
		<input name="z_body" type="hidden" value="<%=z_body%>" />
		<input name="z_weburl" type="hidden" value="<%=apiurl%>" />
		<input name="contact" type="hidden" value="<%=contact%>" />
        		
				<%if zhifufangshi=0 and wangyinzhi="1" then    '支付宝 网银直连%>
				<input name="z_bankid" type="hidden" value="<%=trim(pid)%>" />
				<input name="WIDseller_email" type="hidden" value="<%=paymail%>" />	
				<input name="WIDout_trade_no" type="hidden" value="<%=randarr%>" />	
				<input name="WIDsubject" type="hidden" value="<%=show_body1%>" />	
				<input name="WIDtotal_fee" type="hidden" value="<%=yingfuzongjia%>" />
				<input name="WIDdefaultbank" type="hidden" value="<%=trim(pid)%>" />
				<input name="WIDbody" type="hidden" value="<%=z_body%>" />	
				<input name="WIDshow_url" type="hidden" value="<%=zweburl%>" />
				<%end if%>
				
				<%if zhifufangshi=0 and wangyinzhi="2" then    '财付通 网银直连%>
				<input name="z_bankid" type="hidden" value="<%=trim(pid)%>" />
				<input name="order_no" type="hidden" value="<%=randarr%>" />	
				<input name="product_name" type="hidden" value="<%=show_body1%>" />
				<input name="order_price" type="hidden" value="<%=yingfuzongjia%>" />
				<input name="trade_mode" type="hidden" value="1" />
				<input name="remarkexplain" type="hidden" value="<%=show_body1%>" />
				<input name="attach" type="hidden" value="<%=z_body%>" />
				<input name="bank_type_value" type="hidden" value="<%=trim(pid)%>" />
				<%end if%>
                								
				
				<%if zhifufangshi=2 and wangyinzhi="ALIPAY" then       '支付宝帐号 %>
				<input name="z_bankid" type="hidden" value="ALIPAY" />
				<%if isqtalipay="yes" then%>

							<%if cint(aliqitajiekou)=40 or cint(aliqitajiekou)=41 or cint(aliqitajiekou)=42 then '一扫付1   一扫付2  一扫付3%>
                                <input name="orderId" type="hidden" value="<%=randarr%>" />	
                                <input name="orderAmount" type="hidden" value="<%=yingfuzongjia%>" />	
                                <input name="payMethod" type="hidden" value="2" />	
                                <input name="payType" type="hidden" value="21" />	
                            <%end if%>
							<%if cint(aliqitajiekou)=90 or cint(aliqitajiekou)=91 then	'人工收款%>
                            <input name="total_fee" type="hidden" value="<%=yingfuzongjia%>" />
                            <input name="out_trade_no" type="hidden" value="<%=randarr%>" />
                            <input name="jjjin" type="hidden" value="<%=jjjin%>" />
                            <input name="act" type="hidden" value="ali" />	
                            <input name="shouid" type="hidden" value="<%=ayshoukuanid%>" />
                            <input name="allname" type="hidden" value="<%=allname%>" />
                            <%end if%>
							<%if cint(aliqitajiekou)=92 then	'商家自收%>
                            <input name="total_fee" type="hidden" value="<%=yingfuzongjia%>" />
                            <input name="out_trade_no" type="hidden" value="<%=randarr%>" />
                            <input name="act" type="hidden" value="ali" />	
                            <input name="shouid" type="hidden" value="<%=picurl%>" />
                            <%end if%>
                            

				<%else%>
				<input name="WIDseller_email" type="hidden" value="<%=toparkey("ayalipaymail")%>" />	
				<input name="WIDout_trade_no" type="hidden" value="<%=randarr%>" />	
				<input name="WIDsubject" type="hidden" value="<%=show_body%>" />
				<input name="WIDtotal_fee" type="hidden" value="<%=yingfuzongjia%>" />
				<input name="WIDbody" type="hidden" value="<%=z_body%>" />	
				<input name="WIDshow_url" type="hidden" value="<%=zweburl%>" />
				<%end if%>        
				<%end if%>
				
				
				<%if zhifufangshi=4 and wangyinzhi="WEIXIN" then%>
                <input name="z_bankid" type="hidden" value="WEIXIN" />
						<%if isqtalipay="yes" then%>
							<%if cint(wxqitajiekou)=40 or cint(wxqitajiekou)=41 or cint(wxqitajiekou)=42 then '一扫付1   一扫付2  一扫付3%>
                                <input name="orderId" type="hidden" value="<%=randarr%>" />	
                                <input name="orderAmount" type="hidden" value="<%=yingfuzongjia%>" />	
                                <input name="payMethod" type="hidden" value="1" />	
                                <input name="payType" type="hidden" value="11" />	
                            <%end if%>
                            
							<%if cint(wxqitajiekou)=90 or cint(wxqitajiekou)=91  then	'人工收款%>
                            <input name="total_fee" type="hidden" value="<%=yingfuzongjia%>" />
                            <input name="out_trade_no" type="hidden" value="<%=randarr%>" />
                            <input name="jjjin" type="hidden" value="<%=jjjin%>" />
                            <input name="act" type="hidden" value="wei" />	
                            <input name="shouid" type="hidden" value="<%=ayshoukuanid%>" />
                            <input name="allname" type="hidden" value="<%=allname%>" />
                            <%end if%>
							<%if cint(wxqitajiekou)=92 then	'商家自收%>
                            <input name="total_fee" type="hidden" value="<%=yingfuzongjia%>" />
                            <input name="out_trade_no" type="hidden" value="<%=randarr%>" />
                            <input name="act" type="hidden" value="wei" />	
                            <input name="shouid" type="hidden" value="<%=picurl%>" />
                            <%end if%>
                            
                        <%end if%>        
                <%end if%>
				
				<%if zhifufangshi=5 and wangyinzhi="QQPAY" then       '二维码收款%>
                <input name="z_bankid" type="hidden" value="QQPAY" />
                	<%if cint(qqqitajiekou)=90 or cint(qqqitajiekou)=91  then	'人工收款%> 
					<input name="total_fee" type="hidden" value="<%=yingfuzongjia%>" />
					<input name="out_trade_no" type="hidden" value="<%=randarr%>" />
					<input name="jjjin" type="hidden" value="<%=jjjin%>" />
					<input name="act" type="hidden" value="qq" />
                    <input name="shouid" type="hidden" value="<%=ayshoukuanid%>" />
                    <input name="allname" type="hidden" value="<%=allname%>" />
                    <%end if%>
					<%if cint(qqqitajiekou)=92 then	'商家自收%>
                    <input name="total_fee" type="hidden" value="<%=yingfuzongjia%>" />
                    <input name="out_trade_no" type="hidden" value="<%=randarr%>" />
                    <input name="act" type="hidden" value="qq" />	
                    <input name="shouid" type="hidden" value="<%=picurl%>" />
                    <%end if%>
				<%end if

			  
		end if
end if%>
      

<strong>免责声明</strong>（向陌生人付款，请注意交易风险，否则造成的经济损失自负！）
<br>本站仅是提供自动发卡服务，并非销售商，相关售后问题并不负责，由此产生的交易纠纷由双方自行处理，与本平台无关！
<br>
<strong style="text-decoration:underline">产品相关问题请提前与商家进行沟通!</strong> 商户QQ：<a href="http://wpa.qq.com/msgrd?V=1&amp;Uin=<%=shanghuqq%>&amp;Site=点击咨询&amp;Menu=yes" target="_blank" style="color:#FF0000"><%=shanghuqq%></a><br><br>


<strong>##提卡说明-重要提示##</strong><br>
<%
if isshowerweima="yes" then
response.Write" ·扫码支付成功后将自动跳转并提取卡密。<br>"
else
response.Write" ·支付成功后请不要关闭网页，等待页面跳转后将会自动提取卡密。<br>"
end if%>
·通过商品购买页面"订单查询"可以查询支付结果并提取卡密。<br>

·同时也可以通过"<a href="/chaxun" target="_blank" style="color:#0000FF">查询订单</a>"官方查询订单并提取卡密。

<br>
<strong>注意：订单投诉时效为24小时，付款后出现任何问题请在24小时内进行投诉！</strong>
</div>
</td>
    </tr>
  <tr <%if isshowerweima="yes" then response.Write "style=display:none"%> >
    <td height="50" align="center"><input style="cursor:pointer"  class="newlogin" type="submit" name="Submit" id="tijiao" value="" /></td>
  </tr>
  
  <%if isshowerweima="yes" and Ubound(split(request.serverVariables("HTTP_USER_AGENT"),"IE"))>0 then%>
  <tr>
  <td align="center"><a style="font-size:16px; font-weight:bold;" href="/chaxun?ka=<%=trim(randarr)%>">[如支付后长时间未跳转 请点击此处提取卡密]</a></td>
  </tr>
  <%end if%>
</table>

</form>
	
	</td>
  </tr>
</table>
		

<form action="/chaxun?ka=<%=trim(randarr)%>" method="post" name="tiquka" id="tiquka">

<table width="350" border="0" align="center" cellpadding="0" cellspacing="0" id="tiqu" style="display:none">
  <tr>
    <td width="116" height="25" align="center"><span class="STYLE10">订 单 号：</span></td>
    <td width="284" height="25"><span class="STYLE5"><%=trim(randarr)%></span><input name="ka" type="hidden" id="ka" value="<%=trim(randarr)%>" />
	</td>
  </tr>
  <tr>
    <td height="25" align="center"><span class="STYLE10">订单总价：</span></td>
    <td height="25"><span class="STYLE11"><%response.Write Formatnumber(showddzj,2,true,-1,0)%>元</span></td>
  </tr>
  <tr>
    <td height="25" align="center"><span class="STYLE10">商品名称：</span></td>
    <td height="25"><span class="STYLE2 STYLE11">
        <%response.Write trim(aygoodname)%>
        </span></td>
  </tr>
  <tr>
    <td height="25" align="center"><span class="STYLE10">购买数量：</span></td>
    <td height="25"><span class="STYLE5"><%=quantity%></span></td>
  </tr>
  <tr>
    <td height="25" colspan="2" align="center">
	<input style="cursor:pointer"  class="recharge-btn-2" type="submit" name="Submit" id="tijiao" value="我已付款 获取商品" />
	
	</td>
  </tr>
</table>
</form> 
		
		
		
		</td>
		<td width="13" height="624">
			<table id="Table_01" width="13" height="624" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td><img src="<%=ossurl%>images/payimg/pay_04_01.png" width="13" height="11" alt=""></td>
	</tr>
	<tr>
		<td width="13" height="597" background="<%=ossurl%>images/payimg/pay_04_02.gif"></td>
	</tr>
	<tr>
		<td><img src="<%=ossurl%>images/payimg/pay_04_03.png" width="13" height="16" alt=""></td>
	</tr>
</table></td>
	</tr>
</table>
<div style="text-align:center;font-size:12px; margin-top:200px;">

</div>
	</td>
  </tr>
</table>

			<script src="/Template/newbuy/css/jquery.min.js" type="text/javascript"></script>
			<script type="text/javascript">
                   var timer;
                    $(function(){
                        var handler = function(){
                            $.post("/pay/?id=<%=randarr%>",null,function(msg){
                                if(msg == 'ok'){
                                    document.location.href="/tika?ka=<%=randarr%>";
                                    clearInterval(timer);
                                }
                            });
                        } 
                        timer = setInterval(handler , 2000); 
                    });
            </script>

</body>
</html>
<%
	'if err.number<>0 then 
	'errstr=replace(Err.Description,"'"," ")  
	'conn.Execute("Insert Into ayerr(errcon,errlu,errbei) values('"&errstr&"','"&Request.ServerVariables("HTTP_URL")&"','newpay')")
	'end if
	
conn.close
set conn=nothing



%>