public DigitalTrade() { TradeConfigInfo tradeConfigInfo = TradeConfigs.GetConfig(); _input_charset = tradeConfigInfo.Alipayconfiginfo.Inputcharset; _partner = tradeConfigInfo.Alipayconfiginfo.Partner; _sign = tradeConfigInfo.Alipayconfiginfo.Sign; //tradeConfigInfo.Alipayconfiginfo.Inputcharset = "utf-8"; //tradeConfigInfo.Alipayconfiginfo.Partner = "2088002052150939"; //tradeConfigInfo.Alipayconfiginfo.Sign = "gh0bis45h89m5mwcoe85us4qrwispes0"; TradeConfigs.SaveConfig(tradeConfigInfo); }
/// <summary> /// 检查支付结果 /// </summary> /// <returns></returns> private bool CheckPayment() { AliPayConfigInfo aliPayConfigInfo = TradeConfigs.GetConfig().Alipayconfiginfo; string aliPayNotifyUrl = "http://notify.alipay.com/trade/notify_query.do?"; aliPayNotifyUrl = aliPayNotifyUrl + "partner=" + aliPayConfigInfo.Partner + "¬ify_id=" + DNTRequest.GetString("notify_id"); //获取支付宝ATN返回结果,true是正确的订单信息,false 是无效的 if (Get_Http(aliPayNotifyUrl, 120000, null) != "true") { return(false); } aliPayNotifyUrl = "http://pay.discuz.net/gateway/alipay.php?_type=alipay&_action=verify&_product=Discuz!NT&_version=" + Discuz.Common.Utils.GetAssemblyVersion(); //排序 string[] sortedStr = System.Web.HttpContext.Current.Request.Form.AllKeys; //构造Post的数据串 StringBuilder prestr = new StringBuilder(); for (int i = 0; i < sortedStr.Length; i++) { if (DNTRequest.GetString(sortedStr[i]) != "") { if (i == sortedStr.Length - 1) { prestr.Append(sortedStr[i] + "=" + Utils.UrlEncode(DNTRequest.GetString(sortedStr[i]))); } else { prestr.Append(sortedStr[i] + "=" + Utils.UrlEncode(DNTRequest.GetString(sortedStr[i])) + "&"); } } } //提交到支付网关 return(Get_Http(aliPayNotifyUrl, 120000, prestr.ToString()) == "true"); }