public void goalipay(string out_trade_no, string total_fee, string paytype) { //支付类型 string payment_type = "1"; string notify_url = System.Configuration.ConfigurationManager.AppSettings["notify_url"]; string return_url = System.Configuration.ConfigurationManager.AppSettings["return_url"]; string seller_email = "*****@*****.**"; //订单名称 string subject = (string)GetGlobalResourceObject("GResource", "mpselection"); //订单描述 string body = ""; //商品展示地址 string show_url = ""; //防钓鱼时间戳 string anti_phishing_key = Submit.Query_timestamp(); //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 string exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", payment_type); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("body", body); if (paytype != "alipay") { sParaTemp.Add("paymethod", "bankPay"); sParaTemp.Add("defaultbank", paytype.Substring(7, paytype.Length - 7)); } sParaTemp.Add("show_url", show_url); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认"); Response.Write(sHtmlText); }
public AliPayModel() { //默认是1 Payment_type = "1"; Notify_url = Config.Notify_Url; Return_url = Config.Return_Url; Seller_email = Config.Seller_Email; Input_charset = Config.Input_charset; Key = Config.Key; Partner = Config.Partner; Anti_phishing_key = Submit.Query_timestamp(); Exter_invoke_ip = ""; }
//跳转至支付宝支付页面 public ActionResult alipay(int id) { OrderResponse response = _orderService.OrderDetail(id); var userContext = UserContext.WebUserContext; if (response == null || response.MemberId != userContext.Id) { return(RedirectToAction("index", "player", new { area = "player" })); } else if (response.OrderStatus == OrderStatusEm.支付成功) { return(RedirectToAction("paysuccess", "playerpay", new { area = "player", orderId = id })); } else if (response.OrderStatus != OrderStatusEm.等待支付 && response.OrderStatus != OrderStatusEm.支付失败) { return(RedirectToAction("index", "player", new { area = "player" })); } else { _orderService.PayLog(id, response.Money, PayTypeEm.支付宝, userContext.Id); //插入支付流水信息 string str = "1"; string str2 = "/callback/alinotifyurl"; //异步回调地址 string str3 = "/callback/alireturnurl"; //同步回调地址 string str4 = Constant.PayAccount; //支付宝账号 string str5 = DesEncoderAndDecoder.Encrypt($"{id}#nsda"); string pkgName = response.Remark; string str7 = response.Money.ToString(); string info = response.Remark; string str9 = "";//网站地址 string str10 = Submit.Query_timestamp(); string str11 = ""; SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", str); sParaTemp.Add("notify_url", str2); sParaTemp.Add("return_url", str3); sParaTemp.Add("seller_email", str4); sParaTemp.Add("out_trade_no", str5); sParaTemp.Add("subject", pkgName); sParaTemp.Add("total_fee", str7); sParaTemp.Add("body", info); sParaTemp.Add("show_url", str9); sParaTemp.Add("anti_phishing_key", str10); sParaTemp.Add("exter_invoke_ip", str11); string content = Submit.BuildRequest(sParaTemp, "get", "确认"); return(Content(content)); } }
/// <summary> /// 即时支付模型初始化函数 /// </summary> /// <param name="out_trade_no">商户订单号</param> /// <param name="subject">订单名称</param> /// <param name="body">订单描述</param> /// <param name="show_url"></param> /// <param name="anti_phishing_key"></param> /// <param name="exter_invoke_ip"></param> public AliPayDirectModel(string out_trade_no, string total_fee, string subject, string body = "", string show_url = "", string anti_phishing_key = "", string exter_invoke_ip = "") { try { double fee = double.Parse(out_trade_no); total_fee = fee.ToString("F"); } catch (Exception e) { this.total_fee = "0"; } finally { this.out_trade_no = out_trade_no; this.total_fee = total_fee; this.subject = subject; this.body = body; this.show_url = show_url; this.anti_phishing_key = anti_phishing_key == "" ? Submit.Query_timestamp() : anti_phishing_key; this.exter_invoke_ip = exter_invoke_ip; } }
public ActionResult ProcessTrx(FormCollection data) { //return JavaScript("window.location = 'http://www.google.co.uk'"); //return new RedirectResult("http://www.baidu.com",false); MoneyRecord money = new MoneyRecord { ID = Guid.NewGuid(), Money = decimal.Parse(Request["moneyhidden"]), Statues = 1, Username = Request["username"], Type = "充值类型:" + Request["type"] + ",充值金额:" + Request["moneyhidden"] }; string domain = System.Configuration.ConfigurationManager.AppSettings["domain"]; Guid id = imoney.Create(money); if (id == money.ID) { string payment_type = "1"; string notify_url = domain + "/home/notify"; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 string return_url = domain + "/home/processtrxreturn"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 string seller_email = "*****@*****.**"; //必填 //商户订单号 string out_trade_no = id.ToString(); //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = "美丽说分享宝"; //必填 //付款金额 string total_fee = money.Money.ToString(); //必填 //订单描述 string body = ""; //商品展示地址 string show_url = ""; //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 string anti_phishing_key = Submit.Query_timestamp(); //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 string exter_invoke_ip = GetClientIP(); //非局域网的外网IP地址,如:221.0.0.1 //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", payment_type); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("body", body); sParaTemp.Add("show_url", show_url); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认"); return(Content(sHtmlText)); } else { AddCrossActionMsg("fail", "下定单失败"); return(Content("下定单失败")); } }
/// <summary> /// 支付宝支付 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnApliay() { //企业钱包充值记录 Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(KeyID); decimal price = prepayM.price; #region 支付记录 int payid = 0; int regid = 0; string guid = Guid.NewGuid().ToString().Replace("-", ""); Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); payModel.OrderID = KeyID; payModel.DisID = this.DisID; payModel.PayUser = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; payModel.PayPrice = price; payModel.guid = Common.Number_repeat(guid); payModel.IsAudit = 2; payModel.vdef3 = "2"; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; payModel.Channel = "6"; //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付 payModel.State = 0; //手续费收取方 payModel.vdef5 = "0.00"; //支付手续费 payModel.PrintNum = 1; //结算标示 payid = new Hi.BLL.PAY_Payment().Add(payModel); Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = KeyID; regModel.Ordercode = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(KeyID); regModel.number = payModel.guid; regModel.Price = price; regModel.Payuse = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; regModel.PayName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; regModel.DisID = this.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = prepayM.vdef1; regModel.DisName = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; regModel.BankID = "支付宝"; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1375; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { //JScript.AlertMsg(this, "数据异常!"); ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('数据异常!');</script>"); return; } #endregion #region 支付宝支付 //支付类型 string payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 string notify_url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/Distributor/Pay/ReceiveNoticeAlipay.aspx"; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 string return_url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/Distributor/pay/PrePayList.aspx"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 //string seller_email = "*****@*****.**"; string seller_email = Common.GetPayWxandAli(this.CompID).ali_seller_email;// ConfigurationManager.AppSettings["seller_email"] == null ? "*****@*****.**" : ConfigurationManager.AppSettings["seller_email"].ToString().Trim(); //必填 //商户订单号 string out_trade_no = payModel.guid;// OrderModel.GUID; //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = "钱包充值";//OrderModel.GUID; //必填 //付款金额 string total_fee = price.ToString("0.00"); string paymethod = string.Empty; //默认支付方式 string defaultbank = string.Empty; //默认网银 //if (OrderInfoModel.BankId != "0" && OrderInfoModel.BankId != "") //{ // //默认支付方式 // paymethod = "bankPay"; // //必填 // //默认网银 // defaultbank = OrderInfoModel.BankId; //} //必填 //订单描述 string body = prepayM.vdef1; //商品展示地址 string show_url = "http://www.my1818.com"; //需以http://开头的完整路径, //防钓鱼时间戳 string anti_phishing_key = Submit.Query_timestamp();//""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 string exter_invoke_ip = Page.Request.UserHostAddress; //非局域网的外网IP地址,如:221.0.0.1 //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", payment_type); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("body", body); //if (OrderInfoModel.BankId != "0" && OrderInfoModel.BankId != "") //{ // sParaTemp.Add("paymethod", paymethod); // sParaTemp.Add("defaultbank", defaultbank); //} sParaTemp.Add("show_url", show_url); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认"); Response.Write(sHtmlText); #endregion }
public ActionResult AliPay(string id) { var order = psv.GetOrderByOrderNo(id); if (order != null && order.TradeStatus == TradeStatus.NotPay && order.CustomerId.Equals(CurrentMember.MemberId.ToString())) { #region 支付宝 ////////////////////////////////////////////请求参数//////////////////////////////////////////// //订单号 string out_trade_no = order.No; //订单名称 string subject = "蛋糕"; //付款金额 string total_fee = ((order.TotalPrice - (order.CouponPay + order.GiftCardPay + order.IntegralPay)) > 0 ? (order.TotalPrice - (order.CouponPay + order.GiftCardPay + order.IntegralPay)).ToString() : "0.1") + ""; //订单描述 // string body = string.Join("\r\n", order.OrderDetails.Select(a => a.Name + ":" + a.Num + "张" + a.AllPrice + "元")); //商品展示地址 string show_url = ""; //防钓鱼时间戳 string anti_phishing_key = Submit.Query_timestamp(); string domain_url = Request.Url.ToString(); Regex reg = new Regex(@"http://.*?/"); var res = reg.Match(domain_url); if (res.Success) { domain_url = res.Value; } string notify_url = ConfigurationManager.AppSettings["alipay_notify"]; string return_url = ConfigurationManager.AppSettings["alipay_return"]; notify_url = domain_url + notify_url; return_url = domain_url + return_url; //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", Config.Seller_Email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", String.Format("{0:F}", Convert.ToDecimal(total_fee))); //sParaTemp.Add("body", body); sParaTemp.Add("show_url", show_url); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", ConfigurationManager.AppSettings["alipay_ip"]); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "post", "确认"); ViewBag.html = sHtmlText; return(View()); #endregion } return(Redirect("/Member/Index")); }
public ActionResult AliPay(string id) { var order = psv.GetOrderByOrderNo(id); if (order != null && order.TradeStatus == TradeStatus.NotPay && order.CustomerId.Equals(CurrentMember.MemberId.ToString())) { #region 支付宝 ////////////////////////////////////////////请求参数//////////////////////////////////////////// //返回格式 string format = "xml"; //必填,不需要修改 //返回格式 string v = "2.0"; //必填,不需要修改 //请求号 string req_id = DateTime.Now.ToString("yyyyMMddHHmmss"); //必填,须保证每次请求都是唯一 //支付宝网关地址 string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?"; //订单号 string out_trade_no = order.No; //订单名称 string subject = "蛋糕"; //付款金额 string total_fee = (order.TotalPrice - (order.CouponPay + order.GiftCardPay + order.IntegralPay)) + ""; //订单描述 // string body = string.Join("\r\n", order.OrderDetails.Select(a => a.Name + ":" + a.Num + "张" + a.AllPrice + "元")); //商品展示地址 string show_url = ""; //防钓鱼时间戳 string anti_phishing_key = Submit.Query_timestamp(); //操作中断返回地址 string merchant_url = Url.Action("Index", "Home"); //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //请求业务参数详细 string req_dataToken = "<direct_trade_create_req><notify_url>" + ConfigurationManager.AppSettings["alipay_notify"] + "</notify_url><call_back_url>" + ConfigurationManager.AppSettings["alipay_return"] + "</call_back_url><seller_account_name>" + Config.Seller_Email + "</seller_account_name><out_trade_no>" + out_trade_no + "</out_trade_no><subject>" + subject + "</subject><total_fee>" + total_fee + "</total_fee><merchant_url>" + merchant_url + "</merchant_url></direct_trade_create_req>"; //必填 //把请求参数打包成数组 Dictionary <string, string> sParaTempToken = new Dictionary <string, string>(); sParaTempToken.Add("partner", Config.Partner); sParaTempToken.Add("_input_charset", Config.Input_charset.ToLower()); sParaTempToken.Add("sec_id", Config.Sign_type.ToUpper()); sParaTempToken.Add("service", "alipay.wap.trade.create.direct"); sParaTempToken.Add("format", format); sParaTempToken.Add("v", v); sParaTempToken.Add("req_id", req_id); sParaTempToken.Add("req_data", req_dataToken); //建立请求 string sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken); //URLDECODE返回的信息 Encoding code = Encoding.GetEncoding(Config.Input_charset); sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code); //解析远程模拟提交后返回的信息 Dictionary <string, string> dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken); //获取token string request_token = dicHtmlTextToken["request_token"]; ////////////////////////////////////////////根据授权码token调用交易接口alipay.wap.auth.authAndExecute//////////////////////////////////////////// //业务详细 string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>"; //必填 //把请求参数打包成数组 Dictionary <string, string> sParaTemp = new Dictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("sec_id", Config.Sign_type.ToUpper()); sParaTemp.Add("service", "alipay.wap.auth.authAndExecute"); sParaTemp.Add("format", format); sParaTemp.Add("v", v); sParaTemp.Add("req_data", req_data); //建立请求 string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认"); ViewBag.html = sHtmlText; return(View()); #endregion } return(Redirect("/")); }