现在已经可以跳转到支付宝的页面了,而我们这边就要自己记录用户的信息已经生成的定单编号,这样在支付宝返回信息的时候来查询。在设定了返回地址后,我们就要看接收页面了。
string msg_id,order_no,gross,buyer_email,buyer_name,buyer_address,buyer_zipcode,buyer_tel,buyer_mobile,action,s_date,ac,notify_type;
string returnTxt;//返回给支付宝通知接口的结果
string alipayNotifyURL;//支付宝查询接口URL
string myalipayEmail;//商户的支付宝Email
string ResponseTxt="";
returnTxt = "N";
alipayNotifyURL = ConfigurationSettings.AppSettings["interfaceback"];//支付宝查询接口地址
myalipayEmail = ConfigurationSettings.AppSettings["account"];//填写您的支付宝帐号
//检查支付宝通知接口传递过来的参数是否合法
msg_id = newop.DelStr(Request["msg_id"]);
order_no = newop.DelStr(Request["order_no"]);
gross = newop.DelStr(Request["gross"]);
buyer_email = newop.DelStr(Request["buyer_email"]);
buyer_name = newop.DelStr(Request["buyer_name"]);
buyer_address = newop.DelStr(Request["buyer_address"]);
buyer_zipcode = newop.DelStr(Request["buyer_zipcode"]);
buyer_tel = newop.DelStr(Request["buyer_tel"]);
buyer_mobile = newop.DelStr(Request["buyer_mobile"]);
action = newop.DelStr(Request["action"]);
s_date = newop.DelStr(Request["date"]);
ac = newop.DelStr(Request["ac"]);
notify_type = newop.DelStr(Request["notify_type"]);
alipayNotifyURL = alipayNotifyURL + "msg_id=" + msg_id + "&email=" + myalipayEmail + "&order_no=" + order_no;
System.Net.WebClient isClient= new System.Net.WebClient();
Stream isStream = isClient.OpenRead(alipayNotifyURL);
StreamReader isReader = new StreamReader(isStream,System.Text.Encoding.GetEncoding("GB2312"));
ResponseTxt = isReader.ReadToEnd();
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";
}
Response.Write(returnTxt);
中间那段webclient是返回支付宝查询这个消息是不是支付宝发出的,这里也使用的是获取支付宝那里一个查询接口的结果,True或者False。
这样就完成了整个支付的流程,而你需要做的就是记录用户买的数据,然后接受支付宝给你的信息并确认是否正确,而且是否已经购买或者已经发货,从而完成你的销售过程。接收页面做的标准就是在直接访问的情况下显示的结果只有N或者Y或者其他你设定的returnTxt的值,如果有其他内容将会不能实现功能。
支付宝现在的即时到帐功能还没有正式发布,请不要私自做,要不然会出现麻烦。
string msg_id,order_no,gross,buyer_email,buyer_name,buyer_address,buyer_zipcode,buyer_tel,buyer_mobile,action,s_date,ac,notify_type;
string returnTxt;//返回给支付宝通知接口的结果
string alipayNotifyURL;//支付宝查询接口URL
string myalipayEmail;//商户的支付宝Email
string ResponseTxt="";
returnTxt = "N";
alipayNotifyURL = ConfigurationSettings.AppSettings["interfaceback"];//支付宝查询接口地址
myalipayEmail = ConfigurationSettings.AppSettings["account"];//填写您的支付宝帐号
//检查支付宝通知接口传递过来的参数是否合法
msg_id = newop.DelStr(Request["msg_id"]);
order_no = newop.DelStr(Request["order_no"]);
gross = newop.DelStr(Request["gross"]);
buyer_email = newop.DelStr(Request["buyer_email"]);
buyer_name = newop.DelStr(Request["buyer_name"]);
buyer_address = newop.DelStr(Request["buyer_address"]);
buyer_zipcode = newop.DelStr(Request["buyer_zipcode"]);
buyer_tel = newop.DelStr(Request["buyer_tel"]);
buyer_mobile = newop.DelStr(Request["buyer_mobile"]);
action = newop.DelStr(Request["action"]);
s_date = newop.DelStr(Request["date"]);
ac = newop.DelStr(Request["ac"]);
notify_type = newop.DelStr(Request["notify_type"]);
alipayNotifyURL = alipayNotifyURL + "msg_id=" + msg_id + "&email=" + myalipayEmail + "&order_no=" + order_no;
System.Net.WebClient isClient= new System.Net.WebClient();
Stream isStream = isClient.OpenRead(alipayNotifyURL);
StreamReader isReader = new StreamReader(isStream,System.Text.Encoding.GetEncoding("GB2312"));
ResponseTxt = isReader.ReadToEnd();
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";
}
Response.Write(returnTxt);
中间那段webclient是返回支付宝查询这个消息是不是支付宝发出的,这里也使用的是获取支付宝那里一个查询接口的结果,True或者False。
这样就完成了整个支付的流程,而你需要做的就是记录用户买的数据,然后接受支付宝给你的信息并确认是否正确,而且是否已经购买或者已经发货,从而完成你的销售过程。接收页面做的标准就是在直接访问的情况下显示的结果只有N或者Y或者其他你设定的returnTxt的值,如果有其他内容将会不能实现功能。
支付宝现在的即时到帐功能还没有正式发布,请不要私自做,要不然会出现麻烦。