/// <summary> /// /// </summary> /// <returns></returns> string SendToSupp() { string msg = string.Empty; try { ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(TypeId); if (chanelTypeInfo == null) { msg = "找不到通道,请联系商务或系统管理员处理。"; } else { int card_type = 0; if (int.TryParse(chanelTypeInfo.code, out card_type)) { string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx"; string postData = string.Format( "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}", card_type, UserId, CardNo, CardPwd, FaceValue, 0, DateTime.Now.Ticks.ToString(), callBackurl); string sign = viviLib.Security.Cryptography.MD5(postData + CurrentUser.APIKey); postData += "&sign=" + sign + "&attach=cardsell"; string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.ashx"; string callback = WebClientHelper.GetString(postUrl, postData, "GET", System.Text.Encoding.GetEncoding("GB2312"), 10000); if (callback == "opstate=0") { msg = "true"; } else { msg = callback; } } else { msg = "系统故障"; } } } catch (Exception ex) { msg = ex.Message; } return(msg); }
/// <summary> /// -1:签名较验失败或未知错误 /// </summary> /// <param name="directCard"></param> /// <returns></returns> public static string CheckParameter(ChargeCardDirectInfo directCard) { if (directCard == null) { return("-1"); } if (string.IsNullOrEmpty(directCard.p0_Cmd) || string.IsNullOrEmpty(directCard.p1_MerId) || string.IsNullOrEmpty(directCard.p2_Order) || string.IsNullOrEmpty(directCard.p3_Amt) || string.IsNullOrEmpty(directCard.p4_verifyAmt) || string.IsNullOrEmpty(directCard.p8_Url) || string.IsNullOrEmpty(directCard.pa7_cardAmt) || string.IsNullOrEmpty(directCard.pa8_cardNo) || string.IsNullOrEmpty(directCard.pa9_cardPwd) || string.IsNullOrEmpty(directCard.pd_FrpId) || string.IsNullOrEmpty(directCard.pr_NeedResponse) || string.IsNullOrEmpty(directCard.hmac)) { directCard.Msg = "必要的参数不能为空"; return("-1"); } int userId = 0; if (!int.TryParse(directCard.p1_MerId, out userId)) { directCard.Msg = "账号格式不正确"; return("-1"); } directCard.UserId = userId; decimal p3Amt = 0M; if (!decimal.TryParse(directCard.p3_Amt, out p3Amt)) { directCard.Msg = "支付金额不正确"; return("66"); } directCard.OrderAmt = p3Amt; var userInfo = BLL.User.Factory.GetCacheUserBaseInfo(userId); if (userInfo == null) { directCard.Msg = "商户不存在"; return("-1");// } //annulCard.User = userInfo; directCard.APIkey = userInfo.APIKey; directCard.ManageId = userInfo.manageId; #region directCard.CardNum = 0; if (!string.IsNullOrEmpty(directCard.pa8_cardNo)) { directCard.CardNos = directCard.pa8_cardNo.Split(','); directCard.CardNum = directCard.CardNos.Length; } if (directCard.CardNum == 0) { directCard.Msg = "至少需要一张卡"; return("5");// } if (directCard.CardNum > 10) { directCard.Msg = "卡数量过多,目前最多支持10张卡"; return("5");// } if (!string.IsNullOrEmpty(directCard.pa7_cardAmt)) { directCard.CardAmts = directCard.pa7_cardAmt.Split(','); } if (!string.IsNullOrEmpty(directCard.pa9_cardPwd)) { directCard.CardPwds = directCard.pa9_cardPwd.Split(','); } if (directCard.CardAmts == null || directCard.CardAmts.Length != directCard.CardNum) { directCard.Msg = "卡面额组填写错误"; return("8001");// } if (directCard.CardPwds == null || directCard.CardPwds.Length != directCard.CardNum) { directCard.Msg = "卡号密码为空或者数量不相等"; return("8002");// } directCard.CardFaceValues = new decimal[] { directCard.CardNum }; for (int i = 0; i < directCard.CardNum; i++) { if (string.IsNullOrEmpty(directCard.CardNos[i])) { directCard.Msg = "卡号密码为空或者数量不相等"; return("8002");// } } for (int i = 0; i < directCard.CardNum; i++) { if (string.IsNullOrEmpty(directCard.CardPwds[i])) { directCard.Msg = "卡号密码为空或者数量不相等"; return("8002");// } } for (int i = 0; i < directCard.CardNum; i++) { decimal tempAmt = 0M; if (!decimal.TryParse(directCard.CardAmts[i], out tempAmt)) { directCard.Msg = "卡面额组填写错误"; return("8001");// } else { directCard.CardFaceValues[i] = tempAmt; } } #endregion int typeId = Common.GetChannelTypeId(directCard.pd_FrpId, directCard.CardNos[0]); if (typeId == 0) { directCard.Msg = "支付通道不存在"; return("-1");// } directCard.TypeId = typeId; if (!CheckSign(directCard, userInfo.APIKey)) { directCard.Msg = "签名失败"; return("-1");// } var chanelInfo = ChannelType.GetCacheModel(typeId); if (chanelInfo == null) { directCard.Msg = typeId.ToString(CultureInfo.InvariantCulture) + "通道不存在"; return("112");//业务状态不可用,未开通此类卡业务 } if (chanelInfo.isOpen == OpenEnum.AllClose) { directCard.Msg = typeId.ToString(CultureInfo.InvariantCulture) + "未开通此类卡业务"; return("112");//业务状态不可用,未开通此类卡业务 } int cardType = Utility.CodeMapping(typeId); directCard.CardType = cardType; return("1");// }
public void ProcessRequest(HttpContext context) { string result = string.Empty; try { string orderid = viviLib.Web.WebBase.GetFormString("orderid", ""); string cardNo = viviLib.Web.WebBase.GetFormString("cardNo", ""); string cardPwd = viviLib.Web.WebBase.GetFormString("cardPwd", ""); string faceValue = viviLib.Web.WebBase.GetFormString("faceValue", ""); string typeId = viviLib.Web.WebBase.GetFormString("typeId", ""); string userId = viviLib.Web.WebBase.GetFormString("userId", ""); string sign = viviLib.Web.WebBase.GetFormString("sign", ""); string apikey = string.Empty; int typeid = 0; int.TryParse(typeId, out typeid); int?_manageId = 0; int _faceValue = 0; try { _faceValue = Convert.ToInt32(decimal.Round(Convert.ToDecimal(faceValue), 0).ToString()); } catch { } int _userid = 0; if ( string.IsNullOrEmpty(orderid) || string.IsNullOrEmpty(cardNo) || string.IsNullOrEmpty(cardPwd) || string.IsNullOrEmpty(faceValue) || string.IsNullOrEmpty(typeId) || string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(sign)) { result = "参数不正确"; } else { if (!string.IsNullOrEmpty(userId)) { if (int.TryParse(userId, out _userid)) { } } if (_userid == 0) { result = "用户不存在"; } else { UserInfo userInfo = viviapi.BLL.User.Factory.GetCacheUserBaseInfo(_userid); if (userInfo == null || userInfo.Status != 2) { result = "用户不存在"; } else { apikey = userInfo.APIKey; _manageId = userInfo.manageId; } } } if (string.IsNullOrEmpty(result)) { string plain = orderid + cardNo + cardPwd + faceValue + typeId + userId + apikey; //viviLib.Logging.LogHelper.Write(plain); string localsign = viviLib.Security.Cryptography.MD5(plain); //viviLib.Logging.LogHelper.Write(localsign); //viviLib.Logging.LogHelper.Write(sign); if (localsign != sign) { result = "签名不正确"; } } if (string.IsNullOrEmpty(result)) { ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(typeid); if (chanelTypeInfo == null) { result = "找不到通道,请联系商务或系统管理员处理。"; } else { #region 提交到网关 int card_type = 0; if (int.TryParse(chanelTypeInfo.code, out card_type)) { string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx"; string postData = string.Format( "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}", card_type, userId, cardNo, cardPwd, faceValue, 0, DateTime.Now.Ticks.ToString(), callBackurl); sign = viviLib.Security.Cryptography.MD5(postData + apikey); postData += "&sign=" + sign + "&attach=clientCardsell"; string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.ashx"; string callback = WebClientHelper.GetString(postUrl, postData, "GET", System.Text.Encoding.GetEncoding("GB2312"), 10000); if (callback == "opstate=0") { result = "success"; } else { result = "提卡失败"; } } else { result = "系统故障"; } #endregion } } } catch (Exception ex) { result = "系统故障"; } context.Response.ContentType = "text/plain"; context.Response.Write(result); }
void LoadData() { DataTable data = viviapi.BLL.Channel.ChannelType.GetCacheList(); if (!data.Columns.Contains("payrate")) { data.Columns.Add("payrate", typeof(double)); } if (!data.Columns.Contains("plmodestatus")) { data.Columns.Add("plmodestatus", typeof(string)); } if (!data.Columns.Contains("usermodestatus")) { data.Columns.Add("usermodestatus", typeof(string)); } foreach (DataRow dr in data.Rows) { //if (dr["release"] != DBNull.Value && Convert.ToBoolean(dr["release"]) == false) //{ // //data.Rows.Remove(dr); // continue; //} int typeId = int.Parse(dr["typeId"].ToString()); bool isuserOpen = true; bool issysOpen = false; ChannelTypeUserInfo setting = ChannelTypeUsers.GetCacheModel(UserId, typeId); if (setting != null) { if (setting.userIsOpen.HasValue) { isuserOpen = setting.userIsOpen.Value; } } ChannelTypeInfo typeInfo = ChannelType.GetCacheModel(typeId); switch (typeInfo.isOpen) { case OpenEnum.AllClose: issysOpen = false; break; case OpenEnum.AllOpen: issysOpen = true; break; case OpenEnum.Close: issysOpen = false; if (setting != null) { if (setting.sysIsOpen.HasValue) { issysOpen = setting.sysIsOpen.Value; } } break; case OpenEnum.Open: issysOpen = true; if (setting != null && setting.sysIsOpen.HasValue) { issysOpen = setting.sysIsOpen.Value; } break; } dr["payrate"] = 100 * viviapi.BLL.Finance.PayRate.Instance.GetUserPayRate(this.UserId, Convert.ToInt32(dr["typeId"])); if (isuserOpen) { dr["usermodestatus"] = "right"; } else { dr["usermodestatus"] = "wrong"; } if (issysOpen) { dr["plmodestatus"] = "right"; } else { dr["plmodestatus"] = "wrong"; } } rpt_paymode.DataSource = data; rpt_paymode.DataBind(); }
/// <summary> /// /// </summary> /// <returns></returns> string SendToSupp() { string msg = string.Empty; try { ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(CardInfoID); if (chanelTypeInfo == null) { msg = "找不到通道,请联系商务或系统管理员处理。"; } else { int card_type = 0; if (int.TryParse(chanelTypeInfo.code, out card_type)) { string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx"; StringBuilder cardno = new StringBuilder(); StringBuilder cardpwd = new StringBuilder(); int totalValue = CardPairsList.Count * Convert.ToInt32(ParValue); int currentIndex = 1; foreach (KeyValuePair <string, string> pair in CardPairsList) { cardno.Append(pair.Key); cardpwd.Append(pair.Value); if (currentIndex < CardPairsList.Count) { cardno.Append(";"); cardpwd.Append(";"); } currentIndex++; } string postData = // string.Format( "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}", card_type, UserId, cardno.ToString(), cardpwd.ToString(), ParValue, 0, DateTime.Now.Ticks.ToString(), callBackurl); string sign = viviLib.Security.Cryptography.MD5(postData + CurrentUser.APIKey); postData += "&sign=" + sign + "&attach=cardsell" + "&totalvalue=" + totalValue.ToString(); string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.aspx"; string callback = WebClientHelper.GetString(postUrl, postData, "GET", System.Text.Encoding.GetEncoding("GB2312"), 10000); if (callback == "opstate=1" || callback == "opstate=0")//提交成功,返回状态码true { msg = "true"; } else { msg = callback; } } else { msg = "系统故障"; } } } catch (Exception ex) { msg = ex.Message; } return(msg); }
public void ProcessRequest(HttpContext context) { string msg = string.Empty; try { string userid = viviLib.Web.WebBase.GetFormString("userid", string.Empty); if (!string.IsNullOrEmpty(userid)) { int UserId = 0; if (int.TryParse(userid, out UserId)) { DataTable dtcardtypes = new DataTable(); dtcardtypes.Columns.Add("typeid", typeof(int)); dtcardtypes.Columns.Add("typename", typeof(string)); dtcardtypes.Columns.Add("facevalues", typeof(string)); DataTable data = viviapi.BLL.Channel.ChannelType.GetCacheList(); DataTable facevalue = viviapi.BLL.Channel.Channel.GetCardChanels(UserId, 0, 0, 1); foreach (DataRow dr in data.Rows) { int typeId = int.Parse(dr["typeId"].ToString()); if (typeId < 103 || typeId == 300 || typeId == 114) { continue; } bool isuserOpen = true; bool issysOpen = false; //用户关闭 ChannelTypeUserInfo setting = viviapi.BLL.Channel.ChannelTypeUsers.GetCacheModel(UserId, typeId); if (setting != null) { if (setting.userIsOpen.HasValue) { isuserOpen = setting.userIsOpen.Value; if (!isuserOpen) { continue; } } } ChannelTypeInfo typeInfo = ChannelType.GetCacheModel(typeId); switch (typeInfo.isOpen) { case OpenEnum.AllClose: issysOpen = false; break; case OpenEnum.AllOpen: issysOpen = true; break; case OpenEnum.Close: issysOpen = false; if (setting != null) { if (setting.sysIsOpen.HasValue) { issysOpen = setting.sysIsOpen.Value; } } break; case OpenEnum.Open: issysOpen = true; if (setting != null && setting.sysIsOpen.HasValue) { if (setting.sysIsOpen.HasValue) { issysOpen = setting.sysIsOpen.Value; } } break; } if (!isuserOpen) { continue; } if (!issysOpen) { continue; } DataRow _dr = dtcardtypes.NewRow(); _dr["typeid"] = typeId; _dr["typename"] = dr["modetypename"]; _dr["facevalues"] = GetFaceValues(facevalue, typeId); dtcardtypes.Rows.Add(_dr); } msg = "success" + Newtonsoft.Json.JsonConvert.SerializeObject(dtcardtypes, Newtonsoft.Json.Formatting.Indented); } } } catch { } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }