public override Task <UnifiedOrderReturnModel> Unifiedorder(string OrderId, string Paytype, decimal Totalfee, string Ip, string Body, string Attach) { UnifiedOrderReturnModel unifiedorderReturn = new UnifiedOrderReturnModel(); IDictionary <string, string> dic = new SortedDictionary <string, string>(); string channel = "alipay"; switch (Paytype) { case "1": //网银 channel = "unipay"; break; case "21": //支付宝转卡 channel = "aliToCard"; // "alipay"; break; case "14": //支付宝扫码 channel = "bmAlipay"; break; case "2": //支付宝H5 channel = "alipay"; break; default: channel = "unipay"; break; } dic.Add("rid", this.MchID); dic.Add("channel", channel); dic.Add("price", Totalfee.ToString("F2")); dic.Add("user_id", new Random().Next(1000, 9999).ToString()); dic.Add("notify_url", this.NotifyUrl); dic.Add("out_order_sn", OrderId); string signstr = PayHelper.GetParamSrc(dic); signstr = string.Format("krid={0}&{1}&kts={2}", this.MchID, signstr, PayHelper.GenerateTimeStamp()); string sign = PayHelper.Md5Hash4(signstr); sign = PayHelper.Md5Hash4(sign + this.MchKey); dic.Add("sign", sign); dic.Add("kts", PayHelper.GenerateTimeStamp()); dic.Add("krid", this.MchID); string response = HttpHelper.Post(this.Plat.Pay_gateway, JsonConvert.SerializeObject(dic)); dynamic jo = JsonConvert.DeserializeObject(response); string resCode = jo["errno"]; if (resCode == "0") { string url = jo["data"]["pay_link"]; unifiedorderReturn.Type = PayReturnTypeEnum.Url; unifiedorderReturn.Content = url; unifiedorderReturn.OrderNumber = OrderId; unifiedorderReturn.SerialNumber = OrderId; unifiedorderReturn.RealPrice = Totalfee.ToString("F2"); } else { unifiedorderReturn.Type = PayReturnTypeEnum.Err; unifiedorderReturn.Content = "第三方下单失败"; unifiedorderReturn.OrderNumber = OrderId; unifiedorderReturn.SerialNumber = OrderId; unifiedorderReturn.RealPrice = Totalfee.ToString("F2"); } return(Task.FromResult <UnifiedOrderReturnModel>(unifiedorderReturn)); //return new Task<UnifiedorderReturn>(() => unifiedorderReturn); }
public override Task <UnifiedorderReturn> Unifiedorder(string OrderId, string Paytype, decimal Totalfee, string Ip, string Body, string Attach) { UnifiedorderReturn unifiedorderReturn = new UnifiedorderReturn(); IDictionary <string, string> dic = new Dictionary <string, string>(); string channel = "1000"; switch (Paytype) { case "1": //B2C網銀 channel = "5000"; break; case "2": //支付宝H5 channel = "1000"; break; case "3": //微信H5 channel = "2000"; break; default: channel = "1000"; break; } dic.Add("P_UserId", this.MchID); dic.Add("P_OrderId", OrderId); dic.Add("P_CardId", ""); dic.Add("P_CardPass", ""); dic.Add("P_FaceValue", Totalfee.ToString("F2")); dic.Add("P_ChannelId", channel); string signstr = PayHelper.GetParamSrc2(dic, "|"); string sign = PayHelper.MD5Hash1(signstr + this.MchKey).ToLower(); dic.Add("P_PostKey", sign); dic.Add("P_Subject", ""); dic.Add("P_Price", "0"); dic.Add("P_Quantity", "0"); dic.Add("P_Description", ""); dic.Add("P_Notic", ""); dic.Add("P_Result_URL", this.CallbackUrl); dic.Add("P_Notify_URL", this.NotifyUrl); dic.Add("ResultType", "1"); string response = HttpHelper.Post(this.Plat.Pay_gateway, PayHelper.GetParamSrc(dic)); dynamic jo = JsonConvert.DeserializeObject(response); string resCode = jo["Result_code"]; if (resCode == "0") { string url = jo["PayUrl"]; unifiedorderReturn.Type = PayReturnType.Url; unifiedorderReturn.Content = url; unifiedorderReturn.OrderNumber = OrderId; unifiedorderReturn.SerialNumber = OrderId; unifiedorderReturn.RealPrice = Totalfee.ToString("F2"); } else { unifiedorderReturn.Type = PayReturnType.Err; unifiedorderReturn.Content = "第三方下单失败"; unifiedorderReturn.OrderNumber = OrderId; unifiedorderReturn.SerialNumber = OrderId; unifiedorderReturn.RealPrice = Totalfee.ToString("F2"); } //return new Task<UnifiedorderReturn>(() => unifiedorderReturn); return(Task.FromResult <UnifiedorderReturn>(unifiedorderReturn)); }