protected void Page_Load(object sender, EventArgs e) { //SetPay("0.01", "PRE10022211226701", "*****@*****.**"); //Response.Write(Server.UrlEncode("预存费用")); string base_fee = "4000"; order o = new order(); o.OrderAddCredit(base_fee, "9", "FCL10022216305647", "0", "1");//预存保证金 o.OrderAddCredit((0 - Convert.ToDouble(base_fee)).ToString(), "4", "FCL10022216305647", "8299", "0");//预存保证金 }
public void SetPay(string baozhengjin,string orderid) { order o = new order(); string ali_account = o.OrderGetAliAccount(); System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now; string out_order_no = ""; out_order_no = orderid + "_AA"; //out_trade_no 外部商家订单号 string out_trade_no = ""; out_trade_no = orderid + "_BB"; //业务参数赋值; string gateway = "https://www.alipay.com/cooperate/gateway.do?"; //'支付接口 string service = "unfreeze2fastpay"; string partner = "2088201885472720"; //partner 合作伙伴ID 保留字段 string sign_type = "MD5"; string key = "o272s6dqq0s60tm44sy314jvnsfeihd0"; //partner账户的支付宝安全校验码 string out_order_dt = "2008-01-17 21:46:00"; //外部系统订单生成时间 string buyer_nick = ali_account; //买家昵称 string seller_nick = "*****@*****.**"; //卖家昵称 string order_from = "100002"; //(6) 订单的来源地(电子客票使用,淘宝=100001) Y string old_out_order_no = orderid; //(64) 外部系统的冻结资金时的订单号 string goods_detail = "PREPAY"; //(400) 购买商品详情(不同于商品名称) Y string totle_fee = baozhengjin; // 交易总金额 (0.01-100000000.00元) N string price = baozhengjin; // 商品价格(0.01-100000000.00元) N string other_fee = "0"; // 其他费用(0.00-100000000.00元) N string op_type = "0006"; //(50) 见业务类型表 N string _input_charset = "utf-8"; string aliay_url = CreatUrl2( gateway, service, partner, sign_type, out_order_no, out_trade_no, seller_nick, buyer_nick, _input_charset, out_order_dt, op_type, totle_fee, price, other_fee, old_out_order_no, order_from, goods_detail, key ); // sign_type = "MD5" ' 见签名方式N //aliay_url = aliay_url.Replace("订舱保证金", "%e8%ae%a2%e8%88%b1%e4%bf%9d%e8%af%81%e9%87%91").Replace("返还订舱保证金", "%e8%bf%94%e8%bf%98%e8%ae%a2%e8%88%b1%e4%bf%9d%e8%af%81%e9%87%91"); aliay_url = aliay_url.Replace("预存费用", "%e9%a2%84%e5%ad%98%e8%b4%b9%e7%94%a8"); XmlTextReader textReader = null; try { textReader = new XmlTextReader(aliay_url); textReader.Read(); textReader.WhitespaceHandling = WhitespaceHandling.None; baozhengjin = baozhengjin.ToString(); //实际订舱费比支付宝放大10w倍,正式版去掉 o.OrderAddCredit(baozhengjin, "1", orderid, "0", "1");//预存保证金 data_conn cn = new data_conn(); string sql = "UPDATE TB_ORDER_ALIPREPAY SET alipay_pay_return = 1 WHERE order_code = '" + orderid + "'"; //更新存根状态 cn.mdb_exe(sql); ScriptManager.RegisterStartupScript(this, this.GetType(), "提示", "alert(\"支付宝到账成功!\");", true); //Response.Write("成功"); //while (textReader.Read()) //{ // Response.Write("<br>Type=" + textReader.NodeType + "<br>Name=" + textReader.Name + "<br>Value=" + textReader.Value + "<br>LocalName=" + textReader.LocalName + "<br>XmlLang=" + textReader.XmlLang); // 自己定义输出格式 //} } catch { ScriptManager.RegisterStartupScript(this, this.GetType(), "提示", "alert(\"支付宝到账失败!\");", true); } finally { if (textReader != null) { textReader.Close(); } } //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "提示", "window.open('" + aliay_url + "' ,'_blank','');", true); }
protected void Page_Load(object sender, EventArgs e) { writeLog("程序开始", DateTime.Now.ToString()); ///当不知道https的时候,请使用http //string alipayNotifyURL = "https://www.alipay.com/cooperate/gateway.do?"; string alipayNotifyURL = "http://notify.alipay.com/trade/notify_query.do?"; string partner = "2088201885472720"; //partner string key = "o272s6dqq0s60tm44sy314jvnsfeihd0"; //partner //alipayNotifyURL = alipayNotifyURL + "service=notify_verify" + "&partner=" + partner + "¬ify_id=" + Request.QueryString["notify_id"]; alipayNotifyURL = alipayNotifyURL + "&partner=" + partner + "¬ify_id=" + Request.QueryString["notify_id"]; string responseTxt = Get_Http(alipayNotifyURL, 120000); //********************************************************************************************* int i; NameValueCollection coll; //Load Form variables into NameValueCollection variable. coll = Request.QueryString; // Get names of all forms into a string array. String[] requestarr = coll.AllKeys; //进行排序; string[] Sortedstr = BubbleSort(requestarr); //构造待md5摘要字符串 ; StringBuilder prestr = new StringBuilder(); for (i = 0; i < Sortedstr.Length; i++) { if (Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type") { if (i == Sortedstr.Length - 1) { prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]]); } else { prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]] + "&"); } } } prestr.Append(key); //生成Md5摘要; string mysign = GetMD5(prestr.ToString()); string sign = Request.QueryString["sign"]; //Response.Write(Request.QueryString["amount"]); //Response.Write(mysign); //Response.Write("=="); //Response.Write(sign); writeLog("prestr=" + prestr + ",request_sign=" + Request.QueryString["sign"] + ",mysign=" + mysign + ",sign=" + sign + ",dingdan=" + Request.QueryString["out_order_no"] + ",responseTxt=" + responseTxt, DateTime.Now.ToString()); if (mysign == sign && responseTxt == "true") //验证支付发过来的消息,签名是否正确 { //更新自己数据库的订单语句,请自己填写一下 check ck = new check(); string orderid = ck.CheckInput(GetRequestQueryString("out_order_no", "")); //获得订单号 string[] odetail; odetail = AllinOrder1.GetOrderDetail(orderid); string alipay_pay_return = odetail[120]; if (alipay_pay_return == "0") { string userid = odetail[4]; //获得货代编号 string otherid = odetail[3]; //获得货主编号 string order_type_string = odetail[58]; double base_fee = Convert.ToDouble(odetail[62]); Literal1.Text = base_fee.ToString(); order o = new order(); o.OrderAddCredit(base_fee.ToString(), "9", orderid, "0", "1");//预存保证金 AllinOrder1.SetOrderDetail("2", "2", "3", orderid, ""); //设置状态,传递短消息 AllinOrder1.SetAliPayReturn(orderid, "1"); } Literal2.Text = "支付宝信息:成功"; //Response.Write(Request.QueryString["amount"]); //返回给支付宝消息,成功 //Response.Write("success"); //Response.Write("<br>------------------" + Request.QueryString["subject"] + "--------------冻结成功,订单号为:"); //Response.Write(Request.QueryString["out_order_no"]); //返回给支付宝消息,成功 } else { Literal2.Text = "支付宝信息:失败"; //Response.Write("fail"); //Response.Write("<br>------------------" + Request.QueryString["subject"]); } writeLog("程序结束", DateTime.Now.ToString()); }