/// <summary> /// 定位到支付宝支付界面 /// </summary> public void RedirectToAlipay() { DigitalTrade alipayTrade = new DigitalTrade(); alipayTrade.Subject = string.Format("{0} 论坛积分充值({1}:{2}{3}),用户:{4}", config.Forumtitle, creditstransname, creditsamount, creditstransunit, username); if (Utils.IsValidEmail(config.Alipayaccout))//如果用户保存在配置文件里面的支付宝帐号格式是email的话 { alipayTrade.Seller_Email = config.Alipayaccout; } else { alipayTrade.Seller_Id = config.Alipayaccout; } alipayTrade.Return_Url = Utils.GetRootUrl(forumpath) + "tools/notifypage.aspx"; alipayTrade.Notify_Url = Utils.GetRootUrl(forumpath) + "tools/notifypage.aspx"; alipayTrade.Quantity = 1; decimal price = decimal.Round(((decimal)creditsamount / (decimal)config.Cashtocreditrate), 2); alipayTrade.Price = price > 0.1M ? price : 0.1M; //限定每个订单的最低价格是0.1元 alipayTrade.Payment_Type = 1; alipayTrade.PayMethod = "bankPay"; //跳转到支付宝时默认支付类型是网上银行 string payUrl = ""; alipayTrade.Partner = config.Alipaypartnerid; alipayTrade.Sign = config.Alipaypartnercheckkey; payUrl = StandardAliPayment.GetService().CreateDigitalGoodsTradeUrl(alipayTrade); CreditOrders.CreateCreditOrder(userid, username, creditstrans, creditsamount, 1, alipayTrade.Out_Trade_No); //创建积分充值订单 HttpContext.Current.Response.Redirect(payUrl); //跳转到支付宝即时到帐支付页面 }
public string CreateNormalGoodsTradeUrl(ITrade _goods) { DigitalTrade digitalTrade = (NormalTrade)_goods; string[] urlParam = GetUrlParam(digitalTrade); QuickSort(urlParam, 0, urlParam.Length - 1); CreateTradeUrl(urlParam); string str = CreateEncodeUrl(urlParam); return(this.PayUrl + str + string.Format("&sign_type={0}", digitalTrade.Sign_Type)); }
/// <summary> /// 构造实物商品url /// </summary> /// <param name="normalGoods">实特商品信息</param> /// <param name="key">账户的交易安全校验码(key)</param> /// <returns></returns> public string CreateNormalGoodsTradeUrl(ITrade _goods) { DigitalTrade normalGoods = (NormalTrade)_goods; string tradeUrl = ""; //未进行UrlEncode编码的链接参数串 string encodeUrl = ""; //进行UrlEncode编码的链接参数串 string[] urlParamArray = GetUrlParam(normalGoods); //排序参数 QuickSort(urlParamArray, 0, urlParamArray.Length - 1); tradeUrl = CreateTradeUrl(urlParamArray); encodeUrl = CreateEncodeUrl(urlParamArray); return(PayUrl + encodeUrl + string.Format("&sign_type={0}", normalGoods.Sign_Type)); }
/// <summary> /// 构造虚拟商品url /// </summary> /// <param name="digitalGoods">虚拟商品信息</param> /// <param name="key">账户的交易安全校验码(key)</param> /// <returns></returns> public string CreateDigitalGoodsTradeUrl(ITrade _goods) { DigitalTrade digitalGoods = (DigitalTrade)_goods; string tradeUrl = ""; //未进行UrlEncode编码的链接参数串 string encodeUrl = ""; //进行UrlEncode编码的链接参数串 string[] urlParamArray = GetUrlParam(digitalGoods); //排序参数 QuickSort(urlParamArray, 0, urlParamArray.Length - 1); tradeUrl = CreateTradeUrl(urlParamArray); encodeUrl = CreateEncodeUrl(urlParamArray); return(string.Format("{0}{1}&sign={2}&sign_type={3}", PayUrl, encodeUrl, GetMD5(tradeUrl + Config.GeneralConfigs.GetConfig().Alipaypartnercheckkey, "utf-8"), digitalGoods.Sign_Type)); }
public string CreateDigitalGoodsTradeUrl(ITrade _goods) { DigitalTrade digitalTrade = (DigitalTrade)_goods; string[] urlParam = GetUrlParam(digitalTrade); QuickSort(urlParam, 0, urlParam.Length - 1); string str = CreateTradeUrl(urlParam); string text = CreateEncodeUrl(urlParam); return(string.Format("{0}{1}&sign={2}&sign_type={3}", new object[] { this.PayUrl, text, GetMD5(str + GeneralConfigInfo.Current.Alipaypartnercheckkey, "utf-8"), digitalTrade.Sign_Type })); }
public void TestAccout(string accout) { int openPartner = DNTRequest.GetInt("openpartner", 0); string partnerId = DNTRequest.GetString("partnerid"); string partnerKey = DNTRequest.GetString("partnerKey"); DigitalTrade virtualTrade = new DigitalTrade(); virtualTrade.Subject = "测试支付宝充值功能"; if (Utils.IsValidEmail(accout))//如果传递的帐号类型是email { virtualTrade.Seller_Email = accout; } else { virtualTrade.Seller_Id = accout; } virtualTrade.Return_Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/notifypage.aspx"; virtualTrade.Notify_Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/notifypage.aspx"; virtualTrade.Quantity = 1; virtualTrade.Price = 0.1M; virtualTrade.Payment_Type = 1; virtualTrade.PayMethod = "bankPay"; string payUrl = ""; if (openPartner == 1) { virtualTrade.Partner = partnerId; virtualTrade.Sign = partnerKey; payUrl = StandardAliPayment.GetService().CreateDigitalGoodsTradeUrl(virtualTrade); } else { payUrl = AliPayment.GetService().CreateDigitalGoodsTradeUrl(virtualTrade); } HttpContext.Current.Response.Redirect(payUrl); }
public void RedirectToAlipay() { DigitalTrade digitalTrade = new DigitalTrade(); digitalTrade.Subject = string.Format("{0} 论坛积分充值({1}:{2}{3}),用户:{4}", new object[] { this.config.Forumtitle, this.creditstransname, this.creditsamount, this.creditstransunit, this.username }); if (Utils.IsValidEmail(this.config.Alipayaccout)) { digitalTrade.Seller_Email = this.config.Alipayaccout; } else { digitalTrade.Seller_Id = this.config.Alipayaccout; } digitalTrade.Return_Url = Utils.GetRootUrl(this.forumpath) + "tools/notifypage.aspx"; digitalTrade.Notify_Url = Utils.GetRootUrl(this.forumpath) + "tools/notifypage.aspx"; digitalTrade.Quantity = 1; decimal num = decimal.Round(this.creditsamount / this.config.Cashtocreditrate, 2); digitalTrade.Price = ((num > 0.1m) ? num : 0.1m); digitalTrade.Payment_Type = 1; digitalTrade.PayMethod = "bankPay"; digitalTrade.Partner = this.config.Alipaypartnerid; digitalTrade.Sign = this.config.Alipaypartnercheckkey; string url = StandardAliPayment.GetService().CreateDigitalGoodsTradeUrl(digitalTrade); //CreditOrders.CreateCreditOrder(this.userid, this.username, this.creditstrans, this.creditsamount, 1, digitalTrade.Out_Trade_No); Order.Create(userid, username, creditstrans, creditsamount, 1, digitalTrade.Out_Trade_No); HttpContext.Current.Response.Redirect(url); }
public void TestAccout(string accout) { int @int = DNTRequest.GetInt("openpartner", 0); string @string = Request["partnerid"]; string string2 = Request["partnerKey"]; DigitalTrade digitalTrade = new DigitalTrade(); digitalTrade.Subject = "测试支付宝充值功能"; if (Utils.IsValidEmail(accout)) { digitalTrade.Seller_Email = accout; } else { digitalTrade.Seller_Id = accout; } digitalTrade.Return_Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/notifypage.aspx"; digitalTrade.Notify_Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/notifypage.aspx"; digitalTrade.Quantity = 1; digitalTrade.Price = 0.1m; digitalTrade.Payment_Type = 1; digitalTrade.PayMethod = "bankPay"; string url; if (@int == 1) { digitalTrade.Partner = @string; digitalTrade.Sign = string2; url = StandardAliPayment.GetService().CreateDigitalGoodsTradeUrl(digitalTrade); } else { url = AliPayment.GetService().CreateDigitalGoodsTradeUrl(digitalTrade); } HttpContext.Current.Response.Redirect(url); }
/// <summary> /// 获取在线支付的URL字符串 /// </summary> /// <returns></returns> private string GetAliPayUrl() { string current_url = DNTRequest.GetUrl(); //forumurl = "http://124.207.144.194:8081/"; if (forumurl.ToLower().StartsWith("http://")) { current_url = forumurl + "tradenotify.aspx"; } else { if (current_url.IndexOf("/aspx/") > 0) { current_url = current_url.Substring(0, current_url.IndexOf("/aspx/") + 1) + "tradenotify.aspx"; } else { current_url = current_url.Substring(0, current_url.LastIndexOf("/") + 1) + "tradenotify.aspx"; } } IPayment _payment = AliPayment.GetService(); if (goodstradelog.Transport > 0) { //普通(实物)交易 NormalTrade normalTrade = new NormalTrade(); normalTrade.Body = goodstradelog.Subject; //goodsinfo.Message; normalTrade.Out_Trade_No = goodstradelog.Tradeno; string transportpay = ""; switch (goodstradelog.Transportpay) { case 1: transportpay = "SELLER_PAY"; break; //卖家承担运费 case 2: transportpay = "BUYER_PAY"; break; //买家承担运费 case 3: transportpay = "BUYER_PAY_AFTER_RECEIVE"; break; //买家收到货后直接支付给物流公司,费用不用计到总价中 } string transport = ""; switch (goodstradelog.Transport) { case 0: transport = "VIRTUAL"; break; //虚拟物品 case 1: transport = "POST"; break; //平邮 case 2: transport = "EMS"; break; //EMS case 3: transport = "EXPRESS"; break; //其他快递公司 } normalTrade.Logistics_Info = new LogisticsInfo[1] { new LogisticsInfo(transport, goodstradelog.Transportfee, transportpay) }; normalTrade.Notify_Url = current_url; normalTrade.Payment_Type = goodsinfo.Itemtype; normalTrade.Price = goodstradelog.Price; normalTrade.Quantity = goodstradelog.Number; normalTrade.Seller_Email = goodstradelog.Selleraccount; normalTrade.Show_Url = current_url.Replace("tradenotify.aspx", base.ShowGoodsAspxRewrite(goodstradelog.Goodsid)); normalTrade.Subject = goodstradelog.Subject; normalTrade.Buyer_Email = Users.GetShortUserInfo(goodstradelog.Buyerid).Email; return(_payment.CreateNormalGoodsTradeUrl((ITrade)normalTrade)); } else { //虚拟商品交易 DigitalTrade digitalTrade = new DigitalTrade(); digitalTrade.Body = goodstradelog.Subject; digitalTrade.Out_Trade_No = goodstradelog.Tradeno; digitalTrade.Notify_Url = current_url; digitalTrade.Payment_Type = goodsinfo.Itemtype; digitalTrade.Price = goodstradelog.Price; digitalTrade.Quantity = goodstradelog.Number; digitalTrade.Seller_Email = goodstradelog.Selleraccount; digitalTrade.Show_Url = current_url.Replace("tradenotify.aspx", base.ShowGoodsAspxRewrite(goodstradelog.Goodsid)); digitalTrade.Subject = goodstradelog.Subject; digitalTrade.Buyer_Email = Users.GetShortUserInfo(goodstradelog.Buyerid).Email; return(_payment.CreateDigitalGoodsTradeUrl((ITrade)digitalTrade)); } }