它现在这种支付方式比较多象网银在线等使用的方法都是url验证就是通过url参数和一个这些url参数的md编码来确认这个连接的正确性支付宝在你购买成功后跳转自定义连接的时候会传次过来第一次是数据底层请求第二次是web请求而只有第一次有验证码这个只能通过记录下来才看的到因为两次请求间隔很小如果光显示的话最后的结果是被第二次覆盖了的所以在接收的时候就要设定接收条件一种是没有notify_type参数的一种是有的
我们先来看一下创建一个连接地址
t=ConfigurationSettingsAppSettings[interface]//支付接口就是给的一个连接地址
t=ConfigurationSettingsAppSettings[account]//支付宝帐户你的帐户
t=ConfigurationSettingsAppSettings[password]//安全校验码设置的商家验证码
t=images/logo_zfbsmallgif//按钮图片地址
t=test//悬停说明
cmd=//默认
subject=item//商品名称
body=decrip//描述
order_no=//定单号用户自己生成方便自己管理 prices=//价格~
rurl=//商品展示网址
types=//商品购买服务购买网络拍卖捐赠
number=//购买数量
transport=//平邮快递虚拟物品
ordinary_fee=//平邮运费
express_fee=//快递运费
readonlys=true//交易信息是否只读
buyer_msg=//买家给卖家的留言
buyer=//买家Email
buyer_name=//买家姓名
buyer_address=//买家地址
buyer_zipcode=//买家邮编
buyer_tel=//买家电话号码
buyer_mobile=//买家手机号码
partner=ConfigurationSettingsAppSettings[partenid]//合作伙伴ID这个是固定的
上面就是要提供得基本信息然后就是生成支付宝得连接也就是给支付宝提供一条带验证的购买信息
public string creatAlipayItemURL(string tstring tstring tstring tstring tstring cmdstring subjectstring bodystring order_nostring pricesstring rurlstring typesstring numberstring transportstring ordinary_feestring express_feestring readonlysstring buyer_msgstring buyerstring buyer_namestring buyer_addressstring buyer_zipcodestring buyer_telstring buyer_mobilestring partner)
{
string itemURLstrCreateAcacCode
string INTERFACE_URLsellerEmailkeyCodeimgsrcimgtitleAlipayItemURL
//初始化各必要变量
INTERFACE_URL=t+t//支付接口
sellerEmail=t//商户支付宝账户(改成你自己的)
keyCode=t//安全校验码(改成你自己的)
imgsrc=t//支付宝按钮图片
imgtitle=t//按钮悬停说明
strCreateAc=cmd + cmd + subject + subject
strCreateAc=strCreateAc + body + body
strCreateAc=strCreateAc + order_no + order_no
strCreateAc=strCreateAc + price + prices
//strCreateAc=strCreateAc + url + rurl
strCreateAc=strCreateAc + type + types
strCreateAc=strCreateAc + number + number
strCreateAc=strCreateAc + transport + transport
/*strCreateAc=strCreateAc + ordinary_fee + ordinary_fee
strCreateAc=strCreateAc + express_fee + express_fee
strCreateAc=strCreateAc + readonly + readonlys
strCreateAc=strCreateAc + buyer_msg + buyer_msg*/
strCreateAc=strCreateAc + seller + sellerEmail
/*strCreateAc=strCreateAc + buyer + buyer
strCreateAc=strCreateAc + buyer_name + buyer_name
strCreateAc=strCreateAc + buyer_address + buyer_address
strCreateAc=strCreateAc + buyer_zipcode + buyer_zipcode
strCreateAc=strCreateAc + buyer_tel + buyer_tel
strCreateAc=strCreateAc + buyer_mobile + buyer_mobile*/
strCreateAc=strCreateAc + partner + partner
strCreateAc=strCreateAc + keyCode
//acCode=FormsAuthenticationHashPasswordForStoringInConfigFile(strCreateAcMD)
acCode=thisGetMD(strCreateAcgb)
itemURL=INTERFACE_URL + ?cmd= + cmd
itemURL=itemURL + &subject= + HttpUtilityUrlEncode(subject)
itemURL=itemURL + &body= + HttpUtilityUrlEncode(body)
itemURL=itemURL + &order_no= + order_no
itemURL=itemURL + &price= + prices
//itemURL=itemURL + &url= + rurl
itemURL=itemURL + &type= + types
itemURL=itemURL + &number= + number
itemURL=itemURL + &transport= + transport
/*itemURL=itemURL + &ordinary_fee= + ordinary_fee
itemURL=itemURL + &express_fee= + express_fee
itemURL=itemURL + &readonly= + readonlys
itemURL=itemURL + &buyer_msg= + HttpUtilityUrlEncode(buyer_msg)
itemURL=itemURL + &buyer= + HttpUtilityUrlEncode(buyer)
itemURL=itemURL + &buyer_name= + HttpUtilityUrlEncode(buyer_name)
itemURL=itemURL + &buyer_address= + HttpUtilityUrlEncode(buyer_address)
itemURL=itemURL + &buyer_zipcode= + buyer_zipcode
itemURL=itemURL + &buyer_tel= + buyer_tel
itemURL=itemURL + &buyer_mobile= + buyer_mobile*/
itemURL=itemURL + &partner= + partner
itemURL=itemURL + &ac= + acCode
AlipayItemURL=itemURL
return AlipayItemURL
}
这个函数就是返回生成的地址里面注释掉的看你自己需要可以添加进去然后就是md码的问题现在用默认的md生成程序对中文的支持只限于GB而支付宝使用的是GBK虽然两个编码的内容GBK兼容GB但是毕竟两个编码方式不同所以会产生错误如果用英文或者数字不会有问题上面下载里面带的一个mdasp的算法支持中文
现在已经可以跳转到支付宝的页面了而我们这边就要自己记录用户的信息已经生成的定单编号这样在支付宝返回信息的时候来查询在设定了返回地址后我们就要看接收页面了
string msg_idorder_nogrossbuyer_emailbuyer_namebuyer_addressbuyer_zipcodebuyer_telbuyer_mobileactions_dateacnotify_type
string returnTxt//返回给支付宝通知接口的结果
string alipayNotifyURL//支付宝查询接口URL
string myalipayEmail//商户的支付宝Email
string ResponseTxt=
returnTxt = N
alipayNotifyURL = ConfigurationSettingsAppSettings[interfaceback]//支付宝查询接口地址
myalipayEmail = ConfigurationSettingsAppSettings[account]//填写您的支付宝帐号
//检查支付宝通知接口传递过来的参数是否合法
msg_id = newopDelStr(Request[msg_id])
order_no = newopDelStr(Request[order_no])
gross = newopDelStr(Request[gross])
buyer_email = newopDelStr(Request[buyer_email])
buyer_name = newopDelStr(Request[buyer_name])
buyer_address = newopDelStr(Request[buyer_address])
buyer_zipcode = newopDelStr(Request[buyer_zipcode])
buyer_tel = newopDelStr(Request[buyer_tel])
buyer_mobile = newopDelStr(Request[buyer_mobile])
action = newopDelStr(Request[action])
s_date = newopDelStr(Request[date])
ac = newopDelStr(Request[ac])
notify_type = newopDelStr(Request[notify_type])
alipayNotifyURL = alipayNotifyURL + msg_id= + msg_id + &email= + myalipayEmail + &order_no= + order_no
SystemNetWebClient isClient= new SystemNetWebClient()
Stream isStream = isClientOpenRead(alipayNotifyURL)
StreamReader isReader = new StreamReader(isStreamSystemTextEncodingGetEncoding(GB))
ResponseTxt = isReaderReadToEnd()
if(action == test)//测试商户网站URL是否正确安装
{
returnTxt = Y
}
else if((action==sendOff)&&(msg_id!=))//发货通知
{
returnTxt = N
if((ResponseTxt == true)||(ResponseTxt == false))
{
//更新数据在商户系统里的订单数据如果已经发货则将returnTxt置为Y否则为N
}
else
{
//非法数据不做更新
returnTxt=Error
}
}
else if((action==sendOff)&&(notify_type==web))
{
//检查是否已经付帐并记录 }
else if((action==checkOut)&&(msg_id!=))//交易结束通知
{
returnTxt = Y
if((ResponseTxt==true)||(ResponseTxt == false))
{
//更新数据在商户系统里的订单数据如果数据更新成功则将returnTxt置为Y否则为N
//更新数据
//你的代码更新你这边数据
returnTxt= Y
}
else
{
//非法数据不做更新
returnTxt = Error
}
}
else
{
returnTxt=Error
}
ResponseWrite(returnTxt)