/** * 基本参数字典 */ private SortedDictionary <string, string> getBaseParamDict() { /**订单信息**/ // 商户唯一订单号 string no_order = YinTongUtil.getCurrentDateTimeStr(); // 商户订单时间 string dt_order = YinTongUtil.getCurrentDateTimeStr(); // 交易金额 单位为RMB-元 string money_order = WIDmoney_order.Text.Trim(); // 商品名称 string name_goods = WIDname_goods.Text.Trim(); // 订单描述 string info_order = "用户购买" + name_goods; /** 商户提交参数**/ string version = PartnerConfig.VERSION; //接口版本号 string oid_partner = LLYTPay.PartnerConfig.OID_PARTNER; //商户编号 string user_id = Request ["user_id"].Trim(); //用户ID string sign_type = PartnerConfig.SIGN_TYPE; //签名类型:RSA/MD5 string busi_partner = PartnerConfig.BUSI_PARTNER; //业务类型 虚拟商品销售 string notify_url = PartnerConfig.NOTIFY_URL; //接收异步通知地 string url_return = PartnerConfig.URL_RETURN; //支付结束后返回地址 string userreq_ip = Request.UserHostAddress; //IP * string url_order = ""; string valid_order = "10080"; // 订单有效期 单位分钟,可以为空,默认7天 string timestamp = YinTongUtil.getCurrentDateTimeStr(); //时间戳 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("version", version); sParaTemp.Add("oid_partner", oid_partner); sParaTemp.Add("user_id", user_id); sParaTemp.Add("sign_type", sign_type); sParaTemp.Add("busi_partner", busi_partner); sParaTemp.Add("no_order", no_order); sParaTemp.Add("dt_order", dt_order); sParaTemp.Add("name_goods", name_goods); sParaTemp.Add("info_order", info_order); sParaTemp.Add("money_order", money_order); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("url_return", url_return); sParaTemp.Add("userreq_ip", userreq_ip); sParaTemp.Add("url_order", url_order); sParaTemp.Add("valid_order", valid_order); sParaTemp.Add("timestamp", timestamp); sParaTemp.Add("risk_item", createRiskItem()); sParaTemp.Add("id_type", "0"); //证件类型 sParaTemp.Add("id_no", "410782198912151334"); //身份证 sParaTemp.Add("acct_name", "张三"); sParaTemp.Add("flag_modify", "1"); return(sParaTemp); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { lblOrderID.Text = YinTongUtil.getCurrentDateTimeStr(); lblGoodsName.Text = "出租屋测试支付"; lblCount.Text = "1"; lblCost.Text = "0.01"; lblMemo.Text = "无"; } }
protected void btnNext_Click(object sender, EventArgs e) { SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); OrderInfo info = new OrderInfo(lblOrderID.Text); if (rbUnion.Checked) { /**订单信息**/ // 商户订单时间 string dt_order = YinTongUtil.getCurrentDateTimeStr(); // 交易金额 单位为RMB-元 string money_order = lblCost.Text; // 商品名称 string name_goods = lblGoodsName.Text; // 订单描述 string info_order = lblGoodsName.Text; /** 商户提交参数**/ string version = PartnerConfig.VERSION; //接口版本号 string oid_partner = LigerRM.Common.Payment.PartnerConfig.OID_PARTNER; //商户编号 string user_id = SysContext.CurrentUserID.ToString(); string sign_type = PartnerConfig.SIGN_TYPE; //签名类型:RSA/MD5 string busi_partner = PartnerConfig.BUSI_PARTNER; //业务类型 虚拟商品销售 string notify_url = PartnerConfig.NOTIFY_URL; //接收异步通知地 string url_return = PartnerConfig.URL_RETURN; //支付结束后返回地址 string userreq_ip = Request.UserHostAddress; //IP * string url_order = ""; string valid_order = "10080"; // 订单有效期 单位分钟,可以为空,默认7天 string timestamp = YinTongUtil.getCurrentDateTimeStr(); //时间戳 if (!string.IsNullOrEmpty(info.DTOrder)) { sParaTemp.Add("version", info.Version); sParaTemp.Add("oid_partner", info.OidPartner); sParaTemp.Add("user_id", info.UserId); sParaTemp.Add("sign_type", info.SignType); sParaTemp.Add("busi_partner", info.BusiPartner); sParaTemp.Add("no_order", info.OrderID); sParaTemp.Add("dt_order", info.DTOrder); sParaTemp.Add("name_goods", info.OrderDesc); sParaTemp.Add("info_order", info.OrderDesc); sParaTemp.Add("money_order", info.Cost); sParaTemp.Add("notify_url", info.NotifyUrl); sParaTemp.Add("url_return", info.ReturnUrl); sParaTemp.Add("userreq_ip", info.RequestIP); sParaTemp.Add("url_order", info.OrderUrl); sParaTemp.Add("valid_order", info.OrderValid); sParaTemp.Add("timestamp", info.Timestamp); sParaTemp.Add("risk_item", "pass"); sParaTemp.Add("sign", info.Sign); } else { sParaTemp.Add("version", version); sParaTemp.Add("oid_partner", oid_partner); sParaTemp.Add("user_id", user_id); sParaTemp.Add("sign_type", sign_type); sParaTemp.Add("busi_partner", busi_partner); sParaTemp.Add("no_order", lblOrderID.Text); sParaTemp.Add("dt_order", dt_order); sParaTemp.Add("name_goods", name_goods); sParaTemp.Add("info_order", info_order); sParaTemp.Add("money_order", money_order); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("url_return", string.Format(url_return, lblOrderID.Text)); sParaTemp.Add("userreq_ip", userreq_ip); sParaTemp.Add("url_order", url_order); sParaTemp.Add("valid_order", valid_order); sParaTemp.Add("timestamp", timestamp); sParaTemp.Add("risk_item", "pass"); //加签 string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); info.OrderID = lblOrderID.Text; info.DTOrder = dt_order; info.OidPartner = oid_partner; info.UserId = user_id; info.KeyID = string.Empty; info.Sign = sign; info.SignType = sign_type; info.PayType = ((int)OrderInfo.PaymentType.Card).ToString(); info.BusiPartner = busi_partner; info.Version = version; info.OrderDesc = info_order; info.NotifyUrl = notify_url; info.ReturnUrl = string.Format(url_return, lblOrderID.Text); info.RequestIP = userreq_ip; info.OrderUrl = url_order; info.OrderValid = valid_order; info.Timestamp = timestamp; info.Risk = "pass"; info.DimensionUrl = string.Empty; info.CreatedBy = user_id; info.CreateDate = DateTime.Now; info.Status = ((int)OrderInfo.OrderStatus.NotPay).ToString(); OrderDetailInfo dInfo = new OrderDetailInfo(); dInfo.OrderDetailID = YinTongUtil.getCurrentDateTimeStr(); dInfo.OrderID = info.OrderID; dInfo.GoodsName = lblGoodsName.Text; dInfo.Cost = lblCost.Text; info.DetailInfos.Add(dInfo); OrderHelper helper = new OrderHelper(); helper.AddOrder(info); } StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<form id='payBillForm' action='" + ServerURLConfig.PAY_URL + "' method='post'>"); foreach (KeyValuePair <string, string> temp in sParaTemp) { sbHtml.Append("<input type='hidden' name='" + temp.Key + "' value='" + temp.Value + "'/>"); } //submit按钮控件请不要含有name属性 sbHtml.Append("<input type='submit' value='tijiao' style='display:none;'></form>"); sbHtml.Append("<script>document.forms['payBillForm'].submit();</script>"); string sHtmlText = sbHtml.ToString(); Response.Write(sHtmlText); } if (rbWeChart.Checked) { string url = ServerURLConfig.WECHARTPAY_URL; Encoding encoding = Encoding.GetEncoding("utf-8"); /**订单信息**/ // 商户唯一订单号 //string no_order = YinTongUtil.getCurrentDateTimeStr(); // 商户订单时间 string dt_order = YinTongUtil.getCurrentDateTimeStr(); // 交易金额 单位为RMB-元 string money_order = lblCost.Text; // 商品名称 string name_goods = lblGoodsName.Text; // 订单描述 string info_order = lblGoodsName.Text; /** 商户提交参数**/ string version = WeChartParentConfig.VERSION; //接口版本号 string oid_partner = LigerRM.Common.Payment.WeChartParentConfig.OID_PARTNER; //商户编号 //string user_id = Request["user_id"].Trim(); //用户ID string sign_type = WeChartParentConfig.SIGN_TYPE; //签名类型:RSA/MD5 string busi_partner = WeChartParentConfig.BUSI_PARTNER; //业务类型 虚拟商品销售 string notify_url = WeChartParentConfig.NOTIFY_URL; //接收异步通知地 string url_return = WeChartParentConfig.URL_RETURN; //支付结束后返回地址 string userreq_ip = Request.UserHostAddress; //IP * string url_order = ""; string valid_order = "10080"; // 订单有效期 单位分钟,可以为空,默认7天 string timestamp = YinTongUtil.getCurrentDateTimeStr(); //时间戳 //sParaTemp.Add("version", version); sParaTemp.Add("no_order", lblOrderID.Text); sParaTemp.Add("oid_partner", oid_partner); sParaTemp.Add("money_order", money_order); sParaTemp.Add("dt_order", dt_order); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("info_order", info_order); sParaTemp.Add("name_goods", name_goods); sParaTemp.Add("pay_type", ((int)OrderInfo.PaymentType.WeChart).ToString()); sParaTemp.Add("risk_item", "pass"); sParaTemp.Add("sign_type", sign_type); string sign = YinTongUtil.addSign(sParaTemp, WeChartParentConfig.TRADER_PRI_KEY, WeChartParentConfig.MD5_KEY); sParaTemp.Add("sign", sign); HttpWebResponse response = CreatePostHttpResponse(url, sParaTemp, encoding); Stream stream = response.GetResponseStream(); //获取响应的字符串流 StreamReader sr = new StreamReader(stream); //创建一个stream读取流 string html = sr.ReadToEnd(); //从头读到尾,放到字符串html Dictionary <string, string> returnStr = JSONHelper.FromJson <Dictionary <string, string> >(html); if (returnStr["ret_code"] == "000000" && returnStr.Keys.Contains("pay_status") && returnStr["pay_status"] == "1") { info.OrderID = lblOrderID.Text; info.DTOrder = dt_order; info.OidPartner = oid_partner; info.UserId = SysContext.CurrentUserID.ToString(); info.KeyID = string.Empty; info.Sign = sign; info.PayType = ((int)OrderInfo.PaymentType.WeChart).ToString(); info.SignType = sign_type; info.BusiPartner = busi_partner; info.Version = version; info.OrderDesc = info_order; info.NotifyUrl = notify_url; info.ReturnUrl = string.Format(url_return, lblOrderID.Text); info.RequestIP = userreq_ip; info.OrderUrl = url_order; info.OrderValid = valid_order; info.Timestamp = timestamp; info.Risk = "pass"; info.DimensionUrl = string.Empty; info.CreatedBy = SysContext.CurrentUserID.ToString(); info.CreateDate = DateTime.Now; info.Status = ((int)OrderInfo.OrderStatus.NotPay).ToString(); OrderDetailInfo dInfo = new OrderDetailInfo(); dInfo.OrderDetailID = YinTongUtil.getCurrentDateTimeStr(); dInfo.OrderID = info.OrderID; dInfo.GoodsName = lblGoodsName.Text; dInfo.Cost = lblCost.Text; info.DimensionUrl = returnStr["dimension_url"]; info.OrderNO = returnStr["no_order"]; info.DetailInfos.Add(dInfo); OrderHelper helper = new OrderHelper(); helper.AddOrder(info); string imgurl = QRCodeHelper.CreateQR(returnStr["dimension_url"]); //helper.UpdateDemitionUrl(lblOrderID.Text, returnStr["dimension_url"], returnStr["no_order"]); timer.Enabled = true; imgCode.ImageUrl = "~/images/" + imgurl; lblTitle.Text = "微信支付-扫面下方二维码完成支付"; ScriptManager.RegisterStartupScript(btnNext, btnNext.GetType(), "show", "javascript:showdiv();", true); } } }
public ActionResult ReLLCash(string no_order, int bu) { //原页面路径:/admin/ReLLCash.aspx string json = ""; if (string.IsNullOrEmpty(no_order) || bu <= 0) { json = @"{""ret"":0,""msg"":""参数错误""}"; } if (bu > 0 && no_order != "") { //生成连连新支付单号 string LLNew_ordid = YinTongUtil.getCurrentDateTimeStr(); string sql = " select Acct_name,Card_no,no_order,dt_order,money_order,city_code,bank_code,brabank_name from hx_td_LL_cash where paystate=2 and no_order='" + no_order + "' "; // sql = " select OutAcctId,InAcctId,TransAmt from hx_td_LLpay_re_cash where htype=0 and h_state=0 and OrdId='" + OrdId + "' and no_order='" + no_order + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { string Remarks = "原订单号:" + no_order + " 支付失败 替新订单 " + LLNew_ordid + " 重新支付 <br>"; sql = "update hx_td_LL_cash set no_order='" + LLNew_ordid + "' ,Remarks='" + Remarks + "' where paystate=2 and no_order='" + no_order + "'"; DbHelperSQL.RunSql(sql); sql = " update hx_td_LLpay_re_cash set no_order='" + LLNew_ordid + "' where htype=1 and no_order='" + no_order + "'"; DbHelperSQL.RunSql(sql); M_LLPay m = new M_LLPay(); m.Acct_name = dt.Rows[0]["acct_name"].ToString(); m.Card_no = dt.Rows[0]["card_no"].ToString(); m.No_order = LLNew_ordid; m.Dt_order = dt.Rows[0]["dt_order"].ToString(); m.Money_order = dt.Rows[0]["money_order"].ToString(); m.City_code = dt.Rows[0]["city_code"].ToString(); m.Bank_code = dt.Rows[0]["bank_code"].ToString(); m.Brabank_name = dt.Rows[0]["brabank_name"].ToString(); sql = "update hx_td_LL_cash set paystate=5 where paystate=2 and no_order='" + LLNew_ordid + "'"; DbHelperSQL.RunSql(sql); BLL.EF.LLpay llp = new BLL.EF.LLpay(); string str = llp.cashpay(m); Response.Write(str); YinTongUtil.writelog("单个重新批付及时处理" + no_order + "批付成功 str=" + str); var Objlist = JObject.Parse(str); if (Objlist["ret_code"].ToString() == "0000") { sql = "update hx_td_LL_cash set paystate=1 ,OperTime='" + DateTime.Now.ToString() + "' where paystate= 5 and no_order='" + LLNew_ordid + "'"; DbHelperSQL.RunSql(sql); json = @"{""ret"":1,""msg"":""重新批付成功""}"; // CommonOperate.Show_Msg("重新批付成功 :" + sql); YinTongUtil.writelog("单个重新批付及时处理" + no_order + "批付成功 "); Response.End(); } else { sql = "update hx_td_LL_cash set paystate=2 ,OperTime='" + DateTime.Now.ToString() + "' where paystate= 5 and no_order='" + LLNew_ordid + "'"; DbHelperSQL.RunSql(sql); json = @"{""ret"":0,""msg"":""批付失败""}"; //CommonOperate.Show_Msg("批付失败"); Response.End(); } YinTongUtil.writelog("前面处理付款:" + str); } } //json = @"{""ret"":-1,""msg"":""功能待完善""}"; return(Content(json, "text/json")); }