NET支付宝接口
a
table
tbody
tr
td contentcode csharp keywo
a
003 |
using System.Configuration; |
004 |
using System.Collections; |
006 |
using System.Web.Security; |
008 |
using System.Web.UI.WebControls; |
009 |
using System.Web.UI.WebControls.WebParts; |
010 |
using System.Web.UI.HtmlControls; |
012 |
public partial class pay : System.Web.UI.Page |
014 |
protected void Page_Load( object sender, EventArgs e) |
016 |
Encoding gb2312 = Encoding.GetEncoding( "gb2312" ); |
017 |
Response.ContentEncoding = gb2312; |
018 |
Request.ContentEncoding = gb2312; |
020 |
protected void ImageButton1_Click( object sender, ImageClickEventArgs e) |
022 |
if (Request.Cookies[FormsAuthentication.FormsCookieName] != null ) |
024 |
Vlike_DB_read a = new Vlike_DB_read(); |
025 |
string zfb_ddh = a.get_zfb_id(Membership.GetUser().UserName, Convert.ToInt32(DropDownList1.SelectedValue)); |
026 |
Response.Redirect(img( "0001" , "包月" , "影视包月 10元/月" , zfb_ddh, "10.00" , Membership.GetUser().UserName.ToUpper(), DropDownList1.SelectedValue)); |
030 |
Response.Write( "<script type=" text/javascript ">alert(" 请先登陆! ");</script>" ); |
033 |
private string img( string strcmd, string strSub, string strSubinfo, string strid, string strMoney, string strUser, string strNum) |
035 |
string strsellerEmail = "341081@qq.com" ; |
038 |
string strCmd = strcmd; |
039 |
string strSubject = strSub; |
040 |
string strBody = strSubinfo; |
041 |
string strOrder_no = strid; |
042 |
string strPrice = strMoney; |
043 |
string rurl = "http://" ; //商品展示网址 |
044 |
string strType = "2" ; |
045 |
string strNumber = strNum; |
046 |
string strTransport = "3" ; |
047 |
string strOrdinary_fee = "" ; |
048 |
string strExpress_fee = "" ; |
049 |
string strReadOnly = "true" ; |
050 |
string strBuyer_msg = "" ; |
051 |
string strBuyer = "" ; |
052 |
string strBuyer_name = strUser; |
053 |
string strBuyer_address = "" ; |
054 |
string strBuyer_zipcode = "" ; |
055 |
string strBuyer_tel = "" ; |
056 |
string strBuyer_mobile = "" ; |
057 |
string strPartner = "" ; |
058 |
return CreatUrl(strsellerEmail, strAc, INTERFACE_URL, strCmd, strSubject, strBody, |
059 |
strOrder_no, strPrice, rurl, strType, strNumber, strTransport, |
060 |
strOrdinary_fee, strExpress_fee, strReadOnly, strBuyer_msg, strBuyer, |
061 |
strBuyer_name, strBuyer_address, strBuyer_zipcode, strBuyer_tel, |
062 |
strBuyer_mobile, strPartner); |
064 |
private string CreatUrl( |
065 |
string strsellerEmail, |
067 |
string INTERFACE_URL, |
077 |
string strOrdinary_fee, |
078 |
string strExpress_fee, |
082 |
string strBuyer_name, |
083 |
string strBuyer_address, |
084 |
string strBuyer_zipcode, |
086 |
string strBuyer_mobile, |
089 |
string str2CreateAc = "" ; |
090 |
str2CreateAc += "cmd" + strCmd + "subject" + strSubject; |
091 |
str2CreateAc += "body" + strBody; |
092 |
str2CreateAc += "order_no" + strOrder_no; |
093 |
str2CreateAc += "price" + strPrice; |
094 |
str2CreateAc += "url" + rurl; |
095 |
str2CreateAc += "type" + strType; |
096 |
str2CreateAc += "number" + strNumber; |
097 |
str2CreateAc += "transport" + strTransport; |
098 |
str2CreateAc += "ordinary_fee" + strOrdinary_fee; |
099 |
str2CreateAc += "express_fee" + strExpress_fee; |
100 |
str2CreateAc += "readonly" + strReadOnly; |
101 |
str2CreateAc += "buyer_msg" + strBuyer_msg; |
102 |
str2CreateAc += "seller" + strsellerEmail; |
103 |
str2CreateAc += "buyer" + strBuyer; |
104 |
str2CreateAc += "buyer_name" + strBuyer_name; |
105 |
str2CreateAc += "buyer_address" + strBuyer_address; |
106 |
str2CreateAc += "buyer_zipcode" + strBuyer_zipcode; |
107 |
str2CreateAc += "buyer_tel" + strBuyer_tel; |
108 |
str2CreateAc += "buyer_mobile" + strBuyer_mobile; |
109 |
str2CreateAc += "partner" + strPartner; |
110 |
str2CreateAc += strAc; |
111 |
string acCode = GetMD5(str2CreateAc); |
112 |
string parameter = "" ; |
113 |
parameter += INTERFACE_URL + strsellerEmail + "?cmd=" + strCmd; |
114 |
parameter += "&subject=" + Server.UrlEncode(strSubject); |
115 |
parameter += "&body=" + Server.UrlEncode(strBody); |
116 |
parameter += "&order_no=" + strOrder_no; |
117 |
parameter += "&url=" + rurl; |
118 |
parameter += "&price=" + strPrice; |
119 |
parameter += "&type=" + strType; |
120 |
parameter += "&number=" + strNumber; |
121 |
parameter += "&transport=" + strTransport; |
122 |
parameter += "&ordinary_fee=" + strOrdinary_fee; |
123 |
parameter += "&express_fee=" + strExpress_fee; |
124 |
parameter += "&readonly=" + strReadOnly; |
125 |
parameter += "&buyer_msg=" + strBuyer_msg; |
126 |
parameter += "&buyer=" + strBuyer; |
127 |
parameter += "&buyer_name=" + Server.UrlEncode(strBuyer_name); |
128 |
parameter += "&buyer_address=" + strBuyer_address; |
129 |
parameter += "&buyer_zipcode=" + strBuyer_zipcode; |
130 |
parameter += "&buyer_tel=" + strBuyer_tel; |
131 |
parameter += "&buyer_mobile=" + strBuyer_mobile; |
132 |
parameter += "&partner=" + strPartner; |
133 |
parameter += "&ac=" + acCode; |
136 |
private static string GetMD5( string s) |
138 |
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); |
139 |
byte [] t = md5.ComputeHash(System.Text.Encoding.GetEncoding( "gb2312" ).GetBytes(s)); |
140 |
System.Text.StringBuilder sb = new System.Text.StringBuilder(32); |
141 |
for ( int i = 0; i < t.Length; i++) |
143 |
sb.Append(t[i].ToString( "x" ).PadLeft(2, "0" )); |
145 |
return sb.ToString(); |
接收支付宝信息并进行相应操作
001 |
<%@ Page Language= "C#" %> |
002 |
<%@ Import Namespace= "System.Data.SqlClient" %> |
003 |
<%@ Import Namespace= "System.Data" %> |
004 |
<%@ Import Namespace= "System.Web" %> |
005 |
<%@ Import Namespace= "System.IO" %> |
006 |
<%@ Import Namespace= "System.Net" %> |
007 |
<%@ Import Namespace= "System.Text" %> |
008 |
<%@ Import Namespace= "System.Security.Cryptography" %> |
009 |
<script type= "text/C#" runat= "server" > |
010 |
private string returnTxt = "N" ; |
012 |
private string myalipayEmail = "341081@qq.com" ; |
013 |
private string constPaySecurityCode = "" ; |
014 |
private SqlConnection conn = new SqlConnection(); |
015 |
private string GetMD5( string s) |
017 |
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); |
018 |
byte [] t = md5.ComputeHash(System.Text.Encoding.GetEncoding( "gb2312" ).GetBytes(s)); |
019 |
StringBuilder sb = new StringBuilder(32); |
020 |
for ( int i = 0; i < t.Length; i++) |
022 |
sb.Append(t[i].ToString( "x" ).PadLeft(2, "0" )); |
024 |
return sb.ToString(); |
026 |
private String Get_Http(String a_strUrl, int timeout) |
031 |
System.Net.HttpWebRequest myReq = (System.Net.HttpWebRequest) System.Net.HttpWebRequest.Create(a_strUrl); |
032 |
myReq.Timeout = timeout; |
033 |
System.Net.HttpWebResponse HttpWResp = (System.Net.HttpWebResponse) myReq.GetResponse(); |
034 |
Stream myStream = HttpWResp.GetResponseStream(); |
035 |
StreamReader sr = new StreamReader(myStream, System.Text.Encoding.Default); |
036 |
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder(); |
037 |
while (-1 != sr.Peek()) |
039 |
strBuilder.Append(sr.ReadLine() + "\r\n" ); |
041 |
strResult = strBuilder.ToString(); |
043 |
catch (Exception exp) |
045 |
strResult = "错误:" + exp.Message; |
049 |
public void send( string sql) |
051 |
string dbconn = "data source=127.0.0.1;UID=Cm;PWD=fallenangel;database=text" ; |
052 |
conn = new SqlConnection(dbconn); |
054 |
SqlCommand cmd = new SqlCommand(sql, conn); |
055 |
int aa = cmd.ExecuteNonQuery(); |
058 |
private void Page_Load( object sender, System.EventArgs e) |
061 |
string msg_id = System.Web.HttpContext.Current.Request[ "msg_id" ]; |
062 |
string order_no = System.Web.HttpContext.Current.Request[ "order_no" ]; |
063 |
string gross = System.Web.HttpContext.Current.Request[ "gross" ]; |
064 |
string buyer_email = System.Web.HttpContext.Current.Request[ "buyer_email" ]; |
065 |
string buyer_name = System.Web.HttpContext.Current.Request[ "buyer_name" ]; |
066 |
string buyer_address = System.Web.HttpContext.Current.Request[ "buyer_address" ]; |
067 |
string buyer_zipcode = System.Web.HttpContext.Current.Request[ "buyer_zipcode" ]; |
068 |
string buyer_tel = System.Web.HttpContext.Current.Request[ "buyer_tel" ]; |
069 |
string buyer_mobile = System.Web.HttpContext.Current.Request[ "buyer_mobile" ]; |
070 |
string action = System.Web.HttpContext.Current.Request[ "action" ]; |
071 |
string s_date = System.Web.HttpContext.Current.Request[ "date" ]; |
072 |
string ac = System.Web.HttpContext.Current.Request[ "ac" ]; |
073 |
string notify_type = System.Web.HttpContext.Current.Request[ "notify_type" ]; |
074 |
alipayNotifyURL = alipayNotifyURL + "msg_id=" + msg_id + "&email=" + myalipayEmail + "&order_no=" + order_no; |
076 |
string responseTxt = Get_Http(alipayNotifyURL, 120000); |
077 |
string Str = "msg_id" + msg_id + "order_no" + order_no + "gross" + gross + "buyer_email" + buyer_email + "buyer_name" + buyer_name + "buyer_address" + buyer_address + "buyer_zipcode" + buyer_zipcode + "buyer_tel" + buyer_tel + "buyer_mobile" + buyer_mobile + "action" + action + "date" + s_date + constPaySecurityCode; |
078 |
string ac_code = GetMD5(Str); |
079 |
if (action == "test" ) |
083 |
if (action == "sendOff" ) |
085 |
if (responseTxt.Substring(0, 4) == "true" |
086 |
|| responseTxt.Substring(0, 4) == "fals" ) |
094 |
if (action == "checkOut" ) |
097 |
if (responseTxt.Substring(0, 4) == "true" |
098 |
|| responseTxt.Substring(0, 4) == "fals" ) |
106 |
System.Web.HttpContext.Current.Response.Write(returnTxt); |
本文作者:曾祥展 来源: http://www.cnblogs.com/zengxiangzhan/
CIO之家 www.ciozj.com 微信公众号:imciow
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读