public void SetSign() { var dic = GetDic(); string sign2 = YinTongUtil.addSign(dic, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); sign = sign2; }
public void button1Clicked(object sender, EventArgs args) { //组织参数 SortedDictionary <string, string> sParaTemp = getBaseParamDict(); //加签 string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); 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); }
protected void timer_Tick(object sender, EventArgs e) { //timer.Enabled = false; OrderInfo info = new OrderInfo(lblOrderID.Text); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); Encoding encoding = Encoding.GetEncoding("utf-8"); sParaTemp.Add("no_order", info.OrderNO);//20170425140229 sParaTemp.Add("oid_partner", LigerRM.Common.Payment.WeChartParentConfig.OID_PARTNER); sParaTemp.Add("sign_type", WeChartParentConfig.SIGN_TYPE); string sign = YinTongUtil.addSign(sParaTemp, WeChartParentConfig.TRADER_PRI_KEY, WeChartParentConfig.MD5_KEY); sParaTemp.Add("sign", sign); HttpWebResponse response = CreatePostHttpResponse(ServerURLConfig.WECHARTQUERY_URL, sParaTemp, encoding); Stream stream = response.GetResponseStream(); //获取响应的字符串流 StreamReader sr = new StreamReader(stream); //创建一个stream读取流 string html = sr.ReadToEnd(); //从头读到尾,放到字符串html Dictionary <string, string> ret = new Dictionary <string, string>(); ret = JSONHelper.FromJson <Dictionary <string, string> >(html); if (ret["ret_code"] == "000000" && ret.Keys.Contains("pay_status") && ret["pay_status"] == "0") { Response.Redirect("ReturnUrl.aspx?OrderID=" + lblOrderID.Text); timer.Enabled = false; } }
/// <summary> /// API付款 /// </summary> /// public string cashpay(M_LLPay p) { SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", PartnerConfig.OID_PARTNER); sParaTemp.Add("api_version", PartnerConfig.CashVERSION); // sParaTemp.Add("acct_name", HttpUtility.UrlEncode(p.Acct_name)); sParaTemp.Add("acct_name", p.Acct_name); sParaTemp.Add("card_no", p.Card_no); sParaTemp.Add("no_order", p.No_order); sParaTemp.Add("dt_order", p.Dt_order); sParaTemp.Add("money_order", p.Money_order); sParaTemp.Add("flag_card", "0"); // sParaTemp.Add("info_order", HttpUtility.UrlEncode("P2P投资回款")); sParaTemp.Add("info_order", "P2P投资回款"); sParaTemp.Add("notify_url", PartnerConfig.PAYNOTIFY_URL); sParaTemp.Add("city_code", p.City_code); sParaTemp.Add("bank_code", p.Bank_code); //sParaTemp.Add("brabank_name", HttpUtility.UrlEncode(p.Brabank_name)); sParaTemp.Add("brabank_name", p.Brabank_name); sParaTemp.Add("sign_type", PartnerConfig.CASHSIGN_TYPE); string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.CashTRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); string reqJson = YinTongUtil.dictToJson(sParaTemp); YinTongUtil.writelog("付款银行卡卡bin信息查询-请求报文[" + reqJson + "]"); string responseJSON = postJson(ServerURLConfig.CASHPAY_URL, reqJson); return(responseJSON); /* * SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>(); * sParaTemp.Add("oid_partner", PartnerConfig.OID_PARTNER); * sParaTemp.Add("api_version", PartnerConfig.CashVERSION); * sParaTemp.Add("acct_name", "张长江"); * sParaTemp.Add("card_no", "9559980014443530812"); * sParaTemp.Add("no_order", "20150908120120"); * sParaTemp.Add("dt_order", "20150908120120"); * sParaTemp.Add("money_order", "0.05"); * sParaTemp.Add("flag_card", "0"); * sParaTemp.Add("info_order", "p2p投资回款"); * sParaTemp.Add("notify_url", PartnerConfig.PAYNOTIFY_URL); * sParaTemp.Add("city_code", "110000"); * sParaTemp.Add("bank_code", "01030000"); * sParaTemp.Add("brabank_name", "丽泽桥支行"); * sParaTemp.Add("sign_type", PartnerConfig.SIGN_TYPE); * string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); * sParaTemp.Add("sign", sign); * string reqJson = YinTongUtil.dictToJson(sParaTemp); * YinTongUtil.writelog("银行卡卡bin信息查询-请求报文[" + reqJson + "]"); * string responseJSON = postJson(ServerURLConfig.CASHPAY_URL, reqJson); * return responseJSON; */ }
public string orderquery(string orderid) { string url = "https://yintong.com.cn/traderapi/orderquery.htm"; SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", PartnerConfig.OID_PARTNER); sParaTemp.Add("no_order", "" + orderid + ""); sParaTemp.Add("sign_type", PartnerConfig.CASHSIGN_TYPE); string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.CashTRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); string reqJson = YinTongUtil.dictToJson(sParaTemp); YinTongUtil.writelog("代付查询订单信息-请求报文[" + reqJson + "]"); string responseJSON = postJson(url, reqJson); return(responseJSON); }
/// <summary> /// 卡bin校验查询 /// </summary> /// public string queryCardBin() { SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", PartnerConfig.OID_PARTNER); sParaTemp.Add("card_no", Request["card_no"]); sParaTemp.Add("sign_type", PartnerConfig.SIGN_TYPE); string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); string reqJson = YinTongUtil.dictToJson(sParaTemp); Console.WriteLine("银行卡卡bin信息查询-请求报文[" + reqJson + "]"); string responseJSON = Utils.HttpPostByte(ServerURLConfig.QUERY_BANKCARD_URL, reqJson); Console.WriteLine("银行卡卡bin信息查询-响应报文[" + responseJSON + "]"); return(responseJSON); }
/// <summary> /// 用户已绑定银行卡信息查询 /// </summary> /// public string queryBankcardList() { SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", PartnerConfig.OID_PARTNER); sParaTemp.Add("user_id", Request["user_id"]); sParaTemp.Add("offset", "0"); sParaTemp.Add("sign_type", PartnerConfig.SIGN_TYPE); string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); string reqJson = YinTongUtil.dictToJson(sParaTemp); Console.WriteLine("用户已绑定银行列表查询-请求报文[" + reqJson + "]"); string responseJSON = postJson(ServerURLConfig.QUERY_USER_BANKCARD_URL, reqJson); Console.WriteLine("用户已绑定银行列表查询-响应报文[" + responseJSON + "]"); return(responseJSON); }
public ResultInfo <string> UnBind(RequestParam <RequestPayEntity> reqst) { var ri = new ResultInfo <string>("99999"); var sql = string.Format("SELECT no_agree FROM dbo.hx_td_LLPay_bindCard WHERE Usrid={0} AND BankCard='{1}'", reqst.body.userId, reqst.body.bankCard); LoggerHelper.Info(sql); var res = DbHelper.Query(sql); if (res != null && res.Tables[0].Rows.Count > 0) { SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", PartnerConfig.OID_PARTNER); sParaTemp.Add("user_id", reqst.body.userId); sParaTemp.Add("pay_type", "D"); sParaTemp.Add("no_agree", res.Tables[0].Rows[0]["no_agree"].ToString()); sParaTemp.Add("sign_type", PartnerConfig.SIGN_TYPE); string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, PartnerConfig.MD5_KEY); sParaTemp.Add("sign", sign); string reqJson = YinTongUtil.dictToJson(sParaTemp); LoggerHelper.Info("解绑-请求报文[" + reqJson + "]"); string responseJSON = HttpHelper.Post(ServerURLConfig.BANK_CARD_UNBIND_URL, reqJson); LoggerHelper.Info(responseJSON); ri.code = "1"; ri.message = ""; ri.body = responseJSON; } return(ri); }
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); } } }
static void Main(string[] args) { //com.lianlianpay.security.utils.LianLianPaySecurity.isNull("1"); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("acct_name", "测试"); //版本号 sParaTemp.Add("api_version", "1.0"); //版本号 sParaTemp.Add("bank_name", "招商银行"); sParaTemp.Add("card_no", "6245882402098823"); sParaTemp.Add("dt_order", DateTime.Now.ToString("yyyyMMddHHmmss")); sParaTemp.Add("flag_card", "0"); sParaTemp.Add("info_order", "打款");//订单描述 sParaTemp.Add("money_order", "0.01"); sParaTemp.Add("no_order", DateTime.Now.ToString("yyyyMMddHHmmss")); sParaTemp.Add("notify_url", "http://ht.laidaibei.com/notify_url.aspx"); sParaTemp.Add("oid_partner", "201609130000219023");//商户编号 sParaTemp.Add("platform", "jd.com"); sParaTemp.Add("sign_type", "RSA"); //签名 string sign = YinTongUtil.addSign(sParaTemp, PartnerConfig.TRADER_PRI_KEY, string.Empty); sParaTemp["sign"] = sign; string reqJson = YinTongUtil.dictToJson(sParaTemp); var json = ""; try { json = com.lianlianpay.security.utils.LianLianPaySecurity.encrypt(reqJson, PartnerConfig.YT_PUB_KEY); } catch (Exception ex) { Console.WriteLine("异常信息:" + ex.ToString()); } var http = (HttpWebRequest)WebRequest.Create(new Uri("https://instantpay.lianlianpay.com/paymentapi/payment.htm")); http.Accept = "application/json"; http.ContentType = "application/json"; http.Method = "POST"; Console.WriteLine(reqJson); var pay = ($"{{\"pay_load\":\"{json}\",\"oid_partner\":\"{PartnerConfig.OID_PARTNER}\"}}").Replace("\r\n", "\\r\\n"); byte[] bytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(pay); Stream newStream = http.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); var response = http.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream); var content = sr.ReadToEnd(); //调用付款申请接口,同步返回0000,是指创建连连支付单成功,订单处于付款处理中状态,最终的付款状态由异步通知告知 //出现1002,2005,4006,4007,4009,9999这6个返回码时或者没返回码,抛exception(或者对除了0000之后的code都查询一遍查询接口)调用付款结果查询接口, //明确订单状态,不能私自设置订单为失败状态,以免造成这笔订单在连连付款成功了,而商户设置为失败,用户重新发起付款请求,造成重复付款,商户资金损失 Console.WriteLine(content); //对连连响应报文内容需要用连连公钥验签 Console.ReadKey(); }