<%
'财付通接口代码
function CFTGetServerDate 
	sDate = Now()
	sDate = Year(sDate) & Right(("00" & Month(sDate)),2) & Right(("00" & Day(sDate)),2) & Right(("00" & Hour(sDate)),2) & Right(("00" &  Minute(sDate)),2) & Right(("00" & Second(sDate)),2)
	CFTGetServerDate = sDate
end function
'---------------------------------------------ipay----------------------------------------------
sub pay_ipay()
    v_oid      =OrderNo   '订单号
    v_amount   =money  '总价
    v_email    =pay_email     '付款人电子邮件
    v_mobile   =pay_tel       '付款人联系电话
    v_md5      =md5(v_mid & v_oid & v_amount & v_email & v_mobile & key)  '组合md5加密
    v_comment_1="账户充值" 
    v_comment  =server.urlencode(v_comment_1)
    v_url      ="PayBackIPay.asp"  '支付结果后返回页
    response.write ("<form method=post name=post action=""http://www.ipay.cn/4.0/bank.shtml"">")
    response.write ("<input type=hidden name=v_mid value="&v_mid&">")
    response.write ("<input type=hidden name=v_oid value="&v_oid&">")
    response.write ("<input type=hidden name=v_amount value="&v_amount&">")
    response.write ("<input type=hidden name=v_md5 value="&v_md5&">")
    response.write ("<input type=hidden name=v_email value="&v_email&">")
    response.write ("<input type=hidden name=v_mobile value="&v_mobile&">")
    response.write ("<input type=hidden name=v_comment value="&v_comment&">")
    response.write ("<input type=hidden name=v_url  value="&v_url&">") 
    response.write ("</form>")
    response.write "<SCRIPT LANGUAGE=""JavaScript"">"
    response.write "document.post.submit();"
    response.write "</script>"
end sub

'---------------------------------------------网银---------------------------------------------
sub pay_ChinaBank()
    v_oid =OrderNo   '订单号
	v_amount=money
    v_url=SiteUrl&InstallDir&"onlinepay/chinabank/result.asp"
    v_moneytype = "0" '人民币支付方式
    style="0"'指网关模式0(普通)，1(银行列表中带外卡)
    remark1=""
    remark2=""	
	text = v_amount&v_moneytype&v_oid&v_mid&v_url&key
	v_md5info=Ucase(trim(md5(text)))					'网银支付平台对MD5值只认大写字符串，所以小写的MD5值得转换为大写   
    response.write ("<form method=post name=post action=""https://pay.chinabank.com.cn/select_bank"">")
    response.write ("<input type=hidden name=v_md5info size=100  value="&v_md5info&">")
    response.write ("<input type=hidden name=v_mid value="&v_mid&">")
    response.write ("<input type=hidden name=v_oid value="&v_oid&">")
    response.write ("<input type=hidden name=v_amount value="&v_amount&">")
    response.write ("<input type=hidden name=v_moneytype  value="&v_moneytype&">")
    response.write ("<input type=hidden name=v_url value="&v_url&">")
    response.write ("<input type=hidden name=style value="&style&">")
    response.write ("<input type=hidden name=remark1 value="&remark1&">")
    response.write ("<input type=hidden name=remark2 value="&remark2&">")
	response.write ("<input type=hidden name=v_rcvname value="&pay_member&">")
	response.write ("<input type=hidden name=v_rcvaddr value="&pay_address&">")
	response.write ("<input type=hidden name=v_rcvtel value="&pay_tel&">")
	response.write ("<input type=hidden name=v_orderemail  value="&pay_email&">")
    response.write ("</form>")
    response.write "<SCRIPT LANGUAGE=""JavaScript"">"
    response.write "document.post.submit();"
    response.write "</script>"
end sub

'---------------------------------------支付宝--------------------------------
sub pay_AliPay()
	pay_url="https://www.alipay.com/cooperate/gateway.do?"
    notify_url		= SiteUrl&InstallDir&"Onlinepay/chinabank/Alipay_Notify.asp"	       '交易过程中服务器通知的页面，例如http://www.alipay.com/alipay/Alipay_Notify.asp  注意文件位置请填写正确。
	return_url		= SiteUrl&InstallDir&"Onlinepay/chinabank/return_Alipay_Notify.asp"  '付完款后跳转的页面，例如http://www.alipay.com/alipay/return_Alipay_Notify.asp  注意文件位置请填写正确。
	show_url        = SiteUrl  '商户网站的网址,例如:www.alipay.com
	subject			= "账户充值"	'商品名称，如果客户走购物车流程可以设为  "订单号："&request("客户网站订单")
	body			= "账户充值"		'商品描述
	out_trade_no    = OrderNo        '按时间获取的订单号
	price		    = money			'price商品单价	0.01～50000.00 , 注：不要出现3,000.00，价格不支持","号
    quantity        = "1"             '商品数量,如果走购物车默认为1
	discount        = "0"             '商品折扣
    seller_email    = v_mid   '卖家的支付宝帐号,c2c客户，可以更改此参数。
	partner			= v_sid	 '填写对应支付宝账户的合作者身份ID
	key			    = key
	mystr = Array("service=create_direct_pay_by_user","partner="&partner,"subject="&subject,"body="&body,"out_trade_no="&out_trade_no,"price="&price,"discount="&discount,"show_url="&show_url,"quantity="&quantity,"payment_type=1","seller_email="&seller_email,"notify_url="&notify_url,"return_url="&return_url)
	Count=ubound(mystr)
	For i = Count TO 0 Step -1
		minmax = mystr( 0 )
		minmaxSlot = 0
		For j = 1 To i
				mark = (mystr( j ) > minmax)
			If mark Then 
				minmax = mystr( j )
				minmaxSlot = j
			End If
		Next
		If minmaxSlot <> i Then 
			temp = mystr( minmaxSlot )
			mystr( minmaxSlot ) = mystr( i )
			mystr( i ) = temp
		End If
	 Next
	
	For j = 0 To Count Step 1
		value = SPLIT(mystr( j ), "=")
		If value(1)<>"" then
			If j=Count Then
				md5str= md5str&mystr( j )
			Else 
				md5str= md5str&mystr( j )&"&"
			End If 
		End If 
	Next
	
	md5str=md5str&key
	sign=md5(md5str)
	itemURL	= itemURL&pay_url 
	
	For j = 0 To Count Step 1     
		value = SPLIT(mystr( j ), "=")
		If  value(1)<>"" then
			itemURL= itemURL&mystr( j )&"&"
		End If 	     
	Next
	itemURL	= itemURL&"sign="&sign&"&sign_type="&"MD5"
	response.Redirect(itemUrl)
end sub

'---------------------------------------财付通--------------------------------
sub pay_tenpay()
	spid			= v_mid		    '商户号
	sp_key			= key			'商户密钥
	v_spid			= ""			'买家帐号
	attach			= "tencent_magichu"			'支付附加数据，非中文标准字符
	pay_url			= "https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi" 	'财付通支付网关地址
	notify_url      = SiteUrl&InstallDir&"onlinepay/chinabank/tenpay_notify.asp"
	body			= server.urlencode("账户充值")		'商品描述
	sp_billno       = OrderNo        '按时间获取的订单号
	total_fee		= money*100			'price商品单价	0.01～50000.00 , 注：不要出现3,000.00，价格不支持","号
	ip				= request.servervariables("REMOTE_ADDR")
	dim sign_text
	sign_text = "cmdno=1&date="&left(CFTGetServerDate,8)&"&bargainor_id="&spid&_
        		"&transaction_id="&spid&left(CFTGetServerDate,8)&right(CFTGetServerDate,10)&"&sp_billno="&sp_billno&_
				"&total_fee="&total_fee&"&fee_type=1"&"&return_url="&notify_url&_
				"&attach="&attach 
	if ip <> "" then
	sign_text = sign_text&"&spbill_create_ip="&ip
	end if
	sign = Ucase(md5(sign_text&"&key="&sp_key))
	itemUrl= pay_url&"?"&sign_text&"&sign="&sign&"&bank_type=0&purchaser_id="&v_spid&"&desc="&body&""
	response.write "<SCRIPT LANGUAGE=""JavaScript"">"
	response.write "window.location.href='"&itemUrl&"';"
	response.write "</script>"
end sub

'-----------------------------------------------------------nps--------------------------------------------

sub pay_NPS()

	m_id		=	v_mid
	modate		=	date()
	m_orderid	=	OrderNo
	m_oamount	=	money
	m_ocurrency	=	"1"
	m_url		=	""
	m_language	=	"1"
	s_name		=	""
	s_addr		=	""
	s_postcode	=	""
	s_tel		=	""			
	s_eml		=	""
	r_name		=	""
	r_addr		=	""
	r_postcode	=	""
	r_tel		=	""
	r_eml		=	""
	m_ocomment	=	"账户充值"	
	m_status	=	"0"
	key		    =	key
	
	OrderMessage =m_id&m_orderid&m_oamount&m_ocurrency&m_url&m_language&s_postcode&s_tel&s_eml&r_postcode&r_tel&r_eml&modate&key
	
	digest = Ucase(trim(md5(OrderMessage)))
	
response.write ("<form method=get name=post action=https://payment.nps.cn/VirReceiveMerchantAction.do>")
response.write ("<input Type=hidden Name=M_ID value="&m_id&">")
response.write ("<input Type=hidden Name=MOrderID value="&m_orderid&">")
response.write ("<input Type=hidden Name=MOAmount value="&m_oamount&">")
response.write ("<input Type=hidden Name=MOCurrency value="&m_ocurrency&">")
response.write ("<input Type=hidden Name=M_URL value="&m_url&">")
response.write ("<input Type=hidden Name=M_Language value="&m_language&">")
response.write ("<input Type=hidden Name=S_Name value="&s_name&">")
response.write ("<input Type=hidden Name=S_Address value="&s_addr&">")
response.write ("<input Type=hidden Name=S_PostCode value="&s_postcode&">")
response.write ("<input Type=hidden Name=S_Telephone value="&s_tel&">")
response.write ("<input Type=hidden Name=S_Email value="&s_eml&">")
response.write ("<input Type=hidden Name=R_Name value="&r_name&">")
response.write ("<input Type=hidden Name=R_Address value="&r_addr&">")
response.write ("<input Type=hidden Name=R_PostCode value="&r_postcode&">")
response.write ("<input Type=hidden Name=R_Telephone value="&r_tel&">")
response.write ("<input Type=hidden Name=R_Email value="&r_eml&">")
response.write ("<input Type=hidden Name=MOComment value="&m_ocomment&">")
response.write ("<input Type=hidden Name=MODate value="&modate&">")
response.write ("<input Type=hidden Name=State value="&m_status&">")
response.write ("<input Type=hidden Name=digestinfo value="&digest&">")
response.write ("</form>")
response.write "<SCRIPT LANGUAGE=""JavaScript"">"
response.write "document.post.submit();"
response.write "</script>"
end sub

sub pay_paypal()
response.write ("<form action=https://www.paypal.com/cgi-bin/webscr method=post name=post>")
response.write ("<input type=hidden name=cmd value=_xclick>")
response.write ("<input type=hidden name=business value="&v_mid&">")
response.write ("<input type=hidden name=return value=../PayBackPayPal.asp>")
response.write ("<input type=hidden name=item_name value=Order NO. is "&OrderNo&">")
response.write ("<input type=hidden name=item_number value="&OrderNo&">")
response.write ("<input type=hidden name=amount value="&money&">")
response.write ("</form>")
response.write "<SCRIPT LANGUAGE=""JavaScript"">"
response.write "document.post.submit();"
response.write "</script>"
end sub

sub pay_yeepay()
	p0_Cmd          = "Buy"
	p1_MerId		= v_mid			
	merchantKey	    = key
	p2_Order		= OrderNo
	p3_Amt			= money'	支付金额,必填.
	p4_Cur			= "CNY"
	p5_Pid			= "member_amount"	'	商品名称
	p6_Pcat			= ""'	商品种类
	p7_Pdesc		= "member_amount"	'	商品描述			
	p8_Url			= SiteUrl&InstallDir&"onlinepay/chinabank/yeepay_notify.asp"
	p9_SAF			= "0"'需要填写送货信息 0：不需要  1:需要
	pa_MP			= ""	'	商户扩展信息	
	pd_FrpId		= "" '	银行编码
	pr_NeedResponse	= "1"	'	应答机制
	sbOld  = ""
	'	进行签名处理，一定按照文档中标明的签名顺序进行
	sbOld = sbOld + p0_Cmd
	sbOld = sbOld + p1_MerId
	sbOld = sbOld + p2_Order
	sbOld = sbOld + CStr(p3_Amt)		
	sbOld = sbOld + p4_Cur					
	sbOld = sbOld + p5_Pid
	sbOld = sbOld + p6_Pcat
	sbOld = sbOld + p7_Pdesc
	sbOld = sbOld + p8_Url
	sbOld = sbOld + p9_SAF
	sbOld = sbOld + pa_MP
	sbOld = sbOld + pd_FrpId
	sbOld = sbOld + pr_NeedResponse
	hmac = HmacMd5(sbOld,merchantKey)
response.write ("<form name=yeepay action=https://www.yeepay.com/app-merchant-proxy/node method=post>")
response.write ("<input type=hidden name=p0_Cmd	value="&p0_Cmd&">")
response.write ("<input type=hidden name=p1_MerId value="&p1_MerId&">")
response.write ("<input type=hidden name=p2_Order value="&p2_Order&">")
response.write ("<input type=hidden name=p3_Amt value="&p3_Amt&">")
response.write ("<input type=hidden name=p4_Cur value="&p4_Cur&">")
response.write ("<input type=hidden name=p5_Pid value="&p5_Pid&">")
response.write ("<input type=hidden name=p6_Pcat value="&p6_Pcat&">")
response.write ("<input type=hidden name=p7_Pdesc value="&p7_Pdesc&">")
response.write ("<input type=hidden name=p8_Url value="&p8_Url&">")
response.write ("<input type=hidden name=p9_SAF value="&p9_SAF&">")
response.write ("<input type=hidden name=pa_MP value="&pa_MP&">")
response.write ("<input type=hidden name=pd_FrpId value="&pd_FrpId&">")		
response.write ("<input type=hidden name=pr_NeedResponse value="&pr_NeedResponse&">")
response.write ("<input type=hidden name=hmac value="&hmac&">")
response.write ("</form>")
response.write "<SCRIPT LANGUAGE=""JavaScript"">"
response.write "document.yeepay.submit();"
response.write "</script>"
end sub
%>