亚洲今日精彩视频_精品一级黄色_免费一级A片在现观看视频_8050福利视频 - 一级免费黄色片

7*24小時應急電話:15927160396
首頁 新聞資訊 技術文章
c#.net支付寶Payto接口

            t1=ConfigurationSettings.AppSettings["interface"];//支付接口,就是給的一個連接地址
            t2=ConfigurationSettings.AppSettings["account"];//支付寶帳戶你的帳戶
            t3=ConfigurationSettings.AppSettings["password"];//安全校驗碼,設置的商家驗證碼
            t4="images/logo_zfbsmall.gif";//按鈕圖片地址
            t5="test";//懸停說明
            cmd="0001";//默認
            subject="item";//商品名稱
            body="decrip";//描述
            order_no=;//定單號,用戶自己生成,方便自己管理
            prices=100;//價格0.01~50000.00
            rurl="http://www.xxx.com/";//商品展示網址
            types="1";//1:商品購買2:服務購買3:網絡拍賣4:捐贈
            number="1";//購買數量
            transport="3";//1:平郵2:快遞3:虛擬物品
            ordinary_fee="";//平郵運費
            express_fee="";//快遞運費
            readonlys="true";//交易信息是否只讀
            buyer_msg="";//買家給賣家的留言
            buyer="";//買家Email
            buyer_name="";//買家姓名
            buyer_address="";//買家地址
            buyer_zipcode="";//買家郵編
            buyer_tel="";//買家電話號碼
            buyer_mobile="";//買家手機號碼
            partner=ConfigurationSettings.AppSettings["partenid"];//合作伙伴ID,這個是固定的
上面就是要提供得基本信息,然后就是生成支付寶得連接,也就是給支付寶提供一條帶驗證的購買信息。

public string creatAlipayItemURL(string t1,string t2,string t3,string t4,string t5,string cmd,string subject,string body,string order_no,string prices,string rurl,string types,string number,string transport,string ordinary_fee,string express_fee,string readonlys,string buyer_msg,string buyer,string buyer_name,string buyer_address,string buyer_zipcode,string buyer_tel,string buyer_mobile,string partner)
        {
            string itemURL,str2CreateAc,acCode;
            string INTERFACE_URL,sellerEmail,keyCode,imgsrc,imgtitle,AlipayItemURL;
            //初始化各必要變量
            INTERFACE_URL=t1+t2;//支付接口
            sellerEmail=t2;//商戶支付寶賬戶(改成你自己的)
            keyCode=t3;//安全校驗碼(改成你自己的)
            imgsrc=t4;//支付寶按鈕圖片
            imgtitle=t5;//按鈕懸停說明

            str2CreateAc="cmd" + cmd + "subject" + subject;
            str2CreateAc=str2CreateAc + "body" + body;
            str2CreateAc=str2CreateAc + "order_no" + order_no;
            str2CreateAc=str2CreateAc + "price" + prices;
            //str2CreateAc=str2CreateAc + "url" + rurl;
            str2CreateAc=str2CreateAc + "type" + types;
            str2CreateAc=str2CreateAc + "number" + number;
            str2CreateAc=str2CreateAc + "transport" + transport;
            /*str2CreateAc=str2CreateAc + "ordinary_fee" + ordinary_fee;
            str2CreateAc=str2CreateAc + "express_fee" + express_fee;
            str2CreateAc=str2CreateAc + "readonly" + readonlys;
            str2CreateAc=str2CreateAc + "buyer_msg" + buyer_msg;*/
            str2CreateAc=str2CreateAc + "seller" + sellerEmail;
            /*str2CreateAc=str2CreateAc + "buyer" + buyer;
            str2CreateAc=str2CreateAc + "buyer_name" + buyer_name;
            str2CreateAc=str2CreateAc + "buyer_address" + buyer_address;
            str2CreateAc=str2CreateAc + "buyer_zipcode" + buyer_zipcode;
            str2CreateAc=str2CreateAc + "buyer_tel" + buyer_tel;
            str2CreateAc=str2CreateAc + "buyer_mobile" + buyer_mobile;*/
            str2CreateAc=str2CreateAc + "partner" + partner;
            str2CreateAc=str2CreateAc + keyCode;

            //acCode=FormsAuthentication.HashPasswordForStoringInConfigFile(str2CreateAc,"MD5");
            acCode=this.GetMD5(str2CreateAc,"gb2312");
            itemURL=INTERFACE_URL + "?cmd=" + cmd;
            itemURL=itemURL + "&subject=" + HttpUtility.UrlEncode(subject);
            itemURL=itemURL + "&body=" + HttpUtility.UrlEncode(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=" + HttpUtility.UrlEncode(buyer_msg);
            itemURL=itemURL + "&buyer=" + HttpUtility.UrlEncode(buyer);
            itemURL=itemURL + "&buyer_name=" + HttpUtility.UrlEncode(buyer_name);
            itemURL=itemURL + "&buyer_address=" + HttpUtility.UrlEncode(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;
        }

這個函數就是返回生成的地址,里面注釋掉的看你自己需要可以添加進去,然后就是md5碼的問題,現在用默認的md5生成程序對中文的支持只限于GB2312,而支付寶使用的是GBK,雖然兩個編碼的內容GBK兼容GB2312但是畢竟兩個編碼方式不同,所以會產生錯誤,如果用英文或者數字不會有問題。上面下載里面帶的一個md5.asp的算法支持中文。
        現在已經可以跳轉到支付寶的頁面了,而我們這邊就要自己記錄用戶的信息已經生成的定單編號,這樣在支付寶返回信息的時候來查詢。在設定了返回地址后,我們就要看接收頁面了。

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);

本篇文章來源于《無憂WEB技術網》轉載網址:http://www.100xue.cn/web/web_11421463236.html

版權所有:武漢網福互聯科技有限公司    鄂ICP備09022096號
業務QQ:23444550 客服QQ:267052100 電郵:23444550@qq.com  

鄂公網安備 42010602000905號

手機站二維碼