using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using NP.Model; using NP.Base.Auth; namespace NP.FO.Controllers { public class FOBaseController : NP.Base.BaseController { protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (Request.AcceptTypes == null && !Request.Url.AbsolutePath.ToUpper().StartsWith("/OPEN/") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/PAYVBANKMONEY")) { if ("Y".Equals(GetConfig("isdebug"))) { var rtn = System.Threading.Tasks.Task.Run(async () => Console.WriteLine(await Dao.Log( new NP.Model.PageLog() { uno = SUserInfo.UserNo, uip = GetUserIP(), logsite = 1, loginfo = "fobaseempry: "+Request.Url.ToString() + Request.Params.ToString() }))); } filterContext.Result = new EmptyResult(); } else { if (Request.IsSecureConnection && (Request.Url.AbsolutePath.ToUpper().StartsWith("/CROOM/") || Request.Url.AbsolutePath.ToUpper() == "/CROOM" || Request.Url.AbsolutePath.ToUpper().StartsWith("/CDMS/")) && Request.Url.AbsolutePath.ToUpper() != "/CDMS/HTTPS") { //Response.Redirect("http://" + Request.Url.Host + Request.Url.PathAndQuery, true); filterContext.Result = new RedirectResult("http://" + Request.Url.Host + Request.Url.PathAndQuery); } else if ("Y".Equals(GetConfig("usessl")) && !Request.IsSecureConnection && !Request.Url.AbsolutePath.StartsWith("/Open/") && !(Request.Url.AbsolutePath.ToUpper().StartsWith("/CROOM/") || Request.Url.AbsolutePath.ToUpper() == "/CROOM") && !(Request.Url.AbsolutePath.ToUpper().StartsWith("/CDMS/") || Request.Url.AbsolutePath.ToUpper() == "/CDMS") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/ERROR")) { filterContext.Result = new RedirectResult("https://" + Request.Url.Host + Request.Url.PathAndQuery); } //여기서 로그 남겨? base.OnActionExecuting(filterContext); var cm = new Model.MenuPage() { }; //if (Request.Url.AbsolutePath.ToUpper().StartsWith("/DIVISION/A")) //{ // cm = GetMENUPAGES.Where(w => (w.usertype == 0 || w.usertype == SUserInfo.UserType) && w.pageurl.Equals(Request.Url.PathAndQuery)).OrderByDescending(od => od.pdepth).FirstOrDefault(); //} //else //{ cm = GetMENUPAGES.Where(w => (w.usertype == 0 || w.usertype == SUserInfo.UserType) && (w.pageurl ?? "").ToUpper().Equals(Request.Url.AbsolutePath.ToUpper())).OrderByDescending(od => od.pdepth).FirstOrDefault(); //} if (cm != null || Request.Url.AbsolutePath.ToUpper().Equals("/HOME/HTML") || Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/BANEMAIL") || Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/LOGOUT") || Request.Url.AbsolutePath.ToUpper().StartsWith("/BOARD/")) { ViewBag.Title = (cm ?? new Model.MenuPage()).pagename; ViewBag.MenuPage = (cm ?? new Model.MenuPage()); ViewBag.MenuPageNo = (cm ?? new Model.MenuPage()).pno; ViewBag.Menus = GetMENUPAGES.Where(w => w.usertype == 0 || w.usertype == base.SUserInfo.UserType).ToList(); if (!Request.IsAjaxRequest()) { ViewBag.TopMenu = GetGnbTop(SUserInfo.UserNo); ViewBag.TopMenu2 = SUserInfo.UserNo < 1 ? GNBTOP2 : GNBTOP2AUTH; ViewBag.TopMenu3 = SUserInfo.UserNo < 1 ? GNBTOP3 : GNBTOP3AUTH; ViewBag.TopMenuM = SUserInfo.UserNo < 1 ? GNBTOPM : GNBTOPMAUTH; var pno = GetInt(Request["menupageno"]); if (pno > 0) { ViewBag.MenuPage = GetMENUPAGES.Where(w => w.pno == pno).FirstOrDefault(); ViewBag.MenuPageNo = ViewBag.MenuPage.pno; ViewBag.Title = ViewBag.MenuPage.pagename; } } //접속로그 if (Request.Url.AbsolutePath.ToUpper() != "/ACCOUNT/INDEX") { var rtn = System.Threading.Tasks.Task.Run(async () => Console.WriteLine(await Dao.Log( new NP.Model.PageLog() { uno = SUserInfo.UserNo, uip = GetUserIP(), logsite = 1, pno = cm.pno < 1 ? (int?)null : cm.pno, loginfo = (cm.ppagename ?? "") + " > " + cm.pagename }))); } } else if (GetMENUPAGES.Where(w => (w.pageurl ?? "").ToUpper().Equals(Request.Url.AbsolutePath.ToUpper())).OrderByDescending(od => od.pdepth).FirstOrDefault() != null //&& !Request.Url.AbsolutePath.ToUpper().StartsWith("/CDMS/PLAY") //&& !Request.Url.AbsolutePath.ToUpper().StartsWith("/CONTENTS") ) { filterContext.Result = new RedirectResult("/Account/Index?fobase=xx&ru=" + Request.Url.AbsolutePath, true); //학습창 등이 안뜨고 로그인창으로 갈 경우 여기에 urlreferrer suserinfo, viewbag.ssuser~, GetMENUPAGES 등의 값들을 로깅해본다. //~~ //Response.Redirect("/Account/Index?ru=" + Request.Url.AbsolutePath, true); } else if (!Request.Url.AbsolutePath.ToUpper().StartsWith("/OPEN/") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/HOME/POPUP") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/ERROR") && Request.Url.AbsolutePath.ToUpper() != "/ACCOUNT/ADMINEE") { filterContext.Result = new RedirectResult("/Account/Error"); } //if (Request.IsSecureConnection && //!Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/") && //!Request.Url.AbsolutePath.ToUpper().StartsWith("/OPEN/")) //{ // //Redirect("http://" + Request.Url.Host + Request.Url.PathAndQuery); // filterContext.Result = new RedirectResult("http://" + Request.Url.Host + Request.Url.PathAndQuery); //} else if (GetMENUPAGES.Where(w => (w.pageurl ?? "").ToUpper().Equals(Request.Url.AbsolutePath.ToUpper())).OrderByDescending(od => od.pdepth).FirstOrDefault() != null //&& !Request.Url.AbsolutePath.ToUpper().StartsWith("/CDMS/PLAY") //&& !Request.Url.AbsolutePath.ToUpper().StartsWith("/CONTENTS") ) { filterContext.Result = new RedirectResult("/Account/Index?fobase=1&ru=" + Request.Url.AbsolutePath, true); SetError("fobaseerror:path=" + Request.Url.AbsolutePath + "&urlrefer=" + Request.UrlReferrer + "&userinfo=" + SUserInfo.UserNo + "&ssuer=" + ViewBag.SSUserNo); //학습창 등이 안뜨고 로그인창으로 갈 경우 여기에 urlreferrer suserinfo, viewbag.ssuser~, GetMENUPAGES 등의 값들을 로깅해본다. //~~ //Response.Redirect("/Account/Index?ru=" + Request.Url.AbsolutePath, true); } else if (!Request.Url.AbsolutePath.ToUpper().StartsWith("/OPEN/") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/HOME/POPUP") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/ERROR") && Request.Url.AbsolutePath.ToUpper() != "/ACCOUNT/ADMINEE") { filterContext.Result = new RedirectResult("/Account/Error"); } //if (Request.IsSecureConnection && //!Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/") && //!Request.Url.AbsolutePath.ToUpper().StartsWith("/OPEN/")) //{ // //Redirect("http://" + Request.Url.Host + Request.Url.PathAndQuery); // filterContext.Result = new RedirectResult("http://" + Request.Url.Host + Request.Url.PathAndQuery); //} } } private static IList POPUPS { get; set; } public IList GetPOPUPS { get { if (POPUPS == null) { POPUPS = Dao.Get("mm.popups", new System.Collections.Hashtable() { { "isopen", 1} }); POPUP = null; } return POPUPS; } set { POPUPS = value; } } private static String POPUP { get; set; } public String GetPOPUP { get { if (POPUP == null) { var popups = GetPOPUPS; POPUP = ""; if (GetPOPUPS.Count() > 0) { POPUP = string.Join("nptechpopuplistseparator", GetPOPUPS.Select(s => string.Format("{0}nptechpopupseparator{1}nptechpopupseparator{2}nptechpopupseparator{3}nptechpopupseparator{4}nptechpopupseparator{5}nptechpopupseparator{6}nptechpopupseparator{7}nptechpopupseparator{8}" , s.pno, s.ptitle, "", s.toppx, s.leftpx, s.pwidth, s.pheight+37, s.purl, s.zindex + 100))); } } return POPUP; } set { POPUP = value; } } private static IList BANNERS { get; set; } public IList GetBANNERS { get { if (BANNERS == null) { BANNERS = Dao.Get("mm.banners", new System.Collections.Hashtable() { { "isopen", 1 } }); BANNER = null; BANNERCROOM = null; } return BANNERS; } set { BANNERS = value; } } private static String BANNER { get; set; } public String GetBANNER { get { if (BANNER == null) { //var banners = GetBANNERS; BANNER = ""; if (GetBANNERS.Where(w => w.ismain == 0).Count() > 0) { BANNER = string.Join("", GetBANNERS.Where(w => w.ismain == 0).Select(s => string.Format("
\"\"
", (new BaseModel()).rootfolder + s.fileurl, (new BaseModel()).rootfolder + s.fileurl2, string.IsNullOrEmpty(s.burl)?"": s.burl.ToLower().StartsWith("http")? ("onclick=\"window.open('" + s.burl + "')\"") : ("onclick=\"location.href='" + s.burl + "'\""), string.IsNullOrEmpty(s.burl)?"":"cursor:pointer;" ))); } } return BANNER; } set { BANNER = value; } } private static String BANNERCROOM { get; set; } public String GetBANNERCROOM { get { if (BANNERCROOM == null) { //var banners = GetBANNERS; BANNERCROOM = ""; if (GetBANNERS.Where(w => w.ismain == 1).Count() > 0) { //BANNERCROOM = string.Join("", GetBANNERS.Where(w => w.ismain == 1).Select(s => // string.Format("
\"\"
" // , (new BaseModel()).rootfolder + s.fileurl, (new BaseModel()).rootfolder + s.fileurl2))); } } return BANNERCROOM; } set { BANNERCROOM = value; } } private static IList MENUPAGES { get; set; } public IList GetMENUPAGES { get { if (MENUPAGES == null) { MENUPAGES = Dao.Get("mm.pages", new System.Collections.Hashtable() { { "isopen", 9 } }); GNBTOP = null; } return MENUPAGES.ToList(); } set { MENUPAGES = value; } } private static String GNBTOP { get; set; } private static String GNBTOPAUTH { get; set; } private static String GNBTOP2 { get; set; } private static String GNBTOP2AUTH { get; set; } private static String GNBTOP3 { get; set; } private static String GNBTOP3AUTH { get; set; } private static String GNBTOPM { get; set; } private static String GNBTOPMAUTH { get; set; } public String GetGnbTop(int usertype) { if (GNBTOP == null) { System.Text.StringBuilder sb = new System.Text.StringBuilder(""); System.Text.StringBuilder sbauth = new System.Text.StringBuilder(""); System.Text.StringBuilder sb2 = new System.Text.StringBuilder(""); System.Text.StringBuilder sb2auth = new System.Text.StringBuilder(""); System.Text.StringBuilder sbm = new System.Text.StringBuilder(""); System.Text.StringBuilder sbmauth = new System.Text.StringBuilder(""); var tops = ""; var topsauth = ""; foreach (var m in GetMENUPAGES.Where(w => w.pdepth == 0 && w.isopen == 1)) { var mp = m.pagetype == 0 ? GetMENUPAGES.Where(w => w.pagetype > 0 && (w.m0 == m.pno || w.m1 == m.pno || w.m2 == m.pno || w.m3 == m.pno || w.m4 == m.pno)).FirstOrDefault() ?? new Model.MenuPage() { } : m; sbauth.Append(string.Format("
  • {4}", mp.pno, mp.pagetype, mp.pageurl ?? "", m.refcode??"", m.pagename, m.pno)); topsauth += string.Format("
  • {0}
  • ", m.pagename, m.pno); if (m.usertype == 0) { sb.Append(string.Format("
  • {4}", mp.pno, mp.pagetype, mp.pageurl ?? "", m.refcode ?? "", m.pagename)); tops += string.Format("
  • {0}
  • ", m.pagename); } sb2.Append("
    • "); sb2auth.Append("
      • "); foreach (var m2 in GetMENUPAGES.Where(w => w.pdepth == 1 && w.isopen == 1 && w.ppno == m.pno && w.pagetype != 4)) { sb2auth.Append(string.Format("
      • {3}
      • ", m2.pno, m2.pagetype, m2.pageurl ?? "", m2.pagename, m2.pno)); if (m.usertype == 0 && m2.usertype == 0) { sb2.Append(string.Format("
      • {3}
      • ", m2.pno, m2.pagetype, m2.pageurl ?? "", m2.pagename, m2.pno)); } } sb2.Append("
    • "); sb2auth.Append("
  • "); sbmauth.Append(string.Format("
  • {0}
      ", m.pagename, m.pno)); if (m.usertype == 0) { sbm.Append(string.Format("
    • {0}
        ", m.pagename, m.pno)); } foreach (var m2 in GetMENUPAGES.Where(w => w.pdepth == 1 && w.isopen == 1 && w.ppno == m.pno && w.pagetype != 4)) { sbmauth.Append(string.Format("
      • {3}
      • ", m2.pno, m2.pagetype, m2.pageurl ?? "", m2.pagename, m2.pno)); if (m.usertype == 0) { sbm.Append(string.Format("
      • {3}
      • ", m2.pno, m2.pagetype, m2.pageurl ?? "", m2.pagename, m2.pno)); } } sbmauth.Append("
    • "); if (m.usertype == 0) { sbm.Append("
  • "); } } GNBTOP = sb.ToString(); GNBTOPAUTH = sbauth.ToString(); GNBTOP2 = tops; GNBTOP2AUTH = topsauth; GNBTOP3 = sb2.ToString(); GNBTOP3AUTH = sb2auth.ToString(); GNBTOPM = sbm.ToString(); GNBTOPMAUTH = sbmauth.ToString(); } return usertype < 1 ? GNBTOP : GNBTOPAUTH; } protected void ResetMenu() { MENUPAGES = null; } protected void ResetPopup() { POPUPS = null; } protected void ResetBanner() { BANNERS = null; } private System.Security.Authentication.SslProtocols ExtractSslProtocol(System.IO.Stream stream) { if (stream is null) return System.Security.Authentication.SslProtocols.None; System.Reflection.BindingFlags bindingFlags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic; System.IO.Stream metaStream = stream; if (stream.GetType().BaseType == typeof(System.IO.Compression.GZipStream)) { metaStream = (stream as System.IO.Compression.GZipStream).BaseStream; } else if (stream.GetType().BaseType == typeof(System.IO.Compression.DeflateStream)) { metaStream = (stream as System.IO.Compression.DeflateStream).BaseStream; } var connection = metaStream.GetType().GetProperty("Connection", bindingFlags).GetValue(metaStream); if (!(bool)connection.GetType().GetProperty("UsingSecureStream", bindingFlags).GetValue(connection)) { // Not a Https connection return System.Security.Authentication.SslProtocols.None; } var tlsStream = connection.GetType().GetProperty("NetworkStream", bindingFlags).GetValue(connection); var tlsState = tlsStream.GetType().GetField("m_Worker", bindingFlags).GetValue(tlsStream); return (System.Security.Authentication.SslProtocols)tlsState.GetType().GetProperty("SslProtocol", bindingFlags).GetValue(tlsState); } protected void PayAll(VMPay vm) { //ViewBag.IsOldTLS = false; //try //{ // if (Request.IsSecureConnection) // { // System.Net.Security.SslStream sss = new System.Net.Security.SslStream(Request.UrlReferrer.); // Console.WriteLine(sss.SslProtocol); // //if (ssp.SslProtocol != System.Security.Authentication.SslProtocols.Tls12) // //{ // // ViewBag.IsOldTLS = true; // //} // } //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} vm.PayItems = new List() { }; if (vm.ispaycart) { //장바구니에서 결제 진입 vm.PayItems = Dao.Get("pay.payitems.forcartpay", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo } }); vm.User = Dao.Get("users.users", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo } }).First(); } else if (vm.ispaycert && vm.payno > 0) { //자격증강좌는 신청 시점에는 금액이 0이므로 결제시점에 현재가격으로 갱신해준다. vm.PayItems = Dao.Get("pay.payitems.forcertpay", new System.Collections.Hashtable() { { "payno", vm.payno }, { "userno", SUserInfo.UserNo} }); vm.User = Dao.Get("users.users", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo } }).First(); } else if (vm.ispayexam) { vm.PayItems = Dao.Get("pay.payitems.forexampay", new System.Collections.Hashtable() { { "exno", vm.exno }, { "userno", SUserInfo.UserNo } }); vm.User = Dao.Get("users.users", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo } }).First(); } else { //구매상품데이터를 추출한다. foreach (var d in vm.items.Split(';')) { var dd = d.Split(':'); vm.PayItems.Add(new PayItem() { ptype = GetInt(dd[0]), itemno = GetLong(dd[1]), pcnt = GetInt(dd[2]), userno = vm.isgroup == 0 ? SUserInfo.UserNo : GetInt(dd[3]), isrebate = GetInt(dd[4]), fgno = dd[5] == "0" ? (Int64?)null : GetLong(dd[5]) }); } var pis = Dao.Get("pay.payitems.forpay", new System.Collections.Hashtable(){ {"userno", SUserInfo.UserNo }, { "cmnos0", string.Join(",", vm.PayItems.Where(w=>w.ptype == 0).Select(s=>s.itemno).Distinct()) }, {"bknos", string.Join(",", vm.PayItems.Where(w=>w.ptype == 2).Select(s=>s.itemno)) } }); vm.User = Dao.Get("users.users", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo } }).First(); foreach(var pi in vm.PayItems) { var item = pis.Where(w => w.ptype == pi.ptype && w.itemno == pi.itemno).First(); pi.days = item.days; pi.itemname = item.itemname; pi.orgamt = item.orgamt; pi.discamt = item.discamt; pi.payamt = item.payamt; pi.cshape = item.cshape; } } vm.pginfo = GetConfig("pginfo"); vm.pginfomobile = GetConfig("pginfomobile"); vm.signkey = ComputeHash(vm.pginfo.Split('|')[2]); //vm.payitemname = Utf8ToEuckr(); vm.viewname5 = GetConfig("fronturl") + "/Course/PayClose"; vm.previewname = vm.previewname ?? "/My/Cart"; vm.deliveramt = GetInt(GetConfig("deliveramt")); } //private String Utf8ToEuckr(String s) //{ // byte[] pbSource = System.Text.Encoding.UTF8.GetBytes(s); // byte[] pbDest = System.Text.Encoding.Convert( // System.Text.Encoding.UTF8, System.Text.Encoding.GetEncoding("euc-kr"), pbSource); // pbSource = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding("euc-kr"), System.Text.Encoding.UTF8, pbDest); // char[] psUnicode = System.Text.UTF8Encoding.UTF8.GetChars(pbSource); // return new string(psUnicode); //} protected ActionResult PayReturn(VMPay vm) { if (vm.payno > 0 && vm.absptype == 6) { //0원강좌 결제 vm.Pay = new Pay() { payno = vm.payno, ptype = vm.absptype, oid2 = "free" + vm.payno }; vm.PayItemResults = Dao.Get("pay.payitems", vm.Pay.payno); } else { if (string.IsNullOrEmpty(Request["P_NOTI"])) { ViewBag.OffCode = OffCode; System.Collections.Specialized.NameValueCollection parameters = Request.Params; System.Collections.IEnumerator enumerator = parameters.GetEnumerator(); System.Text.StringBuilder sb = new System.Text.StringBuilder("paramMap : "); while (enumerator.MoveNext()) { string key = enumerator.Current.ToString(); sb.Append(string.Format("{0}={1}&", key, HttpUtility.UrlEncode(parameters[key]))); } //##################### // 인증이 성공일 경우만 //##################### vm.Pay = new Pay() { payno = GetLong(parameters["orderNumber"].Substring(2)), uno = SUserInfo.UserNo, uip = GetUserIP() }; if ("0000".Equals(parameters["resultCode"])) { var pginfo = GetConfig("pginfo").Split('|'); //############################################ // 1.전문 필드 값 설정(***가맹점 개발수정***) //############################################ String mid = parameters.Get("mid"); // 가맹점 ID 수신 받은 데이터로 설정 Int64 oid = GetLong(parameters["orderNumber"].Substring(2));//주문번호 np + payno String signKey = pginfo[2]; // 가맹점에 제공된 키(이니라이트키) (가맹점 수정후 고정) !!!절대!! 전문 데이터로 설정금지 string timeTemp = "" + DateTime.UtcNow.Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds; string[] artime = timeTemp.Split('.'); String timestamp = artime[0]; String charset = "UTF-8"; // 리턴형식[UTF-8,EUC-KR](가맹점 수정후 고정) String format = "JSON"; // 리턴형식[XML,JSON,NVP](가맹점 수정후 고정) String authToken = parameters.Get("authToken"); // 취소 요청 tid에 따라서 유동적(가맹점 수정후 고정) String authUrl = parameters.Get("authUrl"); // 승인요청 API url(수신 받은 값으로 설정, 임의 세팅 금지) String netCancel = parameters.Get("netCancelUrl"); // 망취소 API url(수신 받은 값으로 설정, 임의 세팅 금지) String mKey = ComputeHash(signKey); // 가맹점 확인을 위한 signKey를 해시값으로 변경 (SHA-256방식 사용) String merchantData = parameters.Get("merchantData"); // 가맹점 관리데이터 수신 //##################### // 2.signature 생성 //##################### String signParam = "authToken=" + @authToken + "×tamp=" + timestamp; String signature = ComputeHash(signParam); //##################### // 3.API 요청 전문 생성 //##################### System.Collections.Generic.Dictionary authMap = new System.Collections.Generic.Dictionary(); authMap.Add("mid", mid); // 필수 authMap.Add("authToken", HttpUtility.UrlEncode(authToken)); // 필수 - 반드시 urlencode 해서 전달. authMap.Add("timestamp", timestamp); // 필수 authMap.Add("signature", signature); // 필수 authMap.Add("charset", charset); // default=UTF-8 authMap.Add("format", format); // default=XML authMap.Add("mkey", mKey); // default=XML String cancelMsg = "결제오류|" + oid; vm.Pay.payno = oid; //이거 확인 MOID? try { //##################### // 4.API 통신 시작 //##################### String authResultString = ""; authResultString = processHTTP(authMap, authUrl); //############################################################ //5.API 통신결과 처리(***가맹점 개발수정***) //############################################################ String strReplace = authResultString.Replace(",", "&").Replace(":", "=").Replace("\"", "").Replace(" ", "").Replace("\n", "").Replace("}", "").Replace("{", ""); System.Collections.Generic.Dictionary resultMap = parseStringToMap(strReplace); //문자열을 MAP형식으로 파싱 /************************* 결제보안 추가 START ****************************/ Dictionary secureMap = new Dictionary(); if (resultMap["resultCode"] == "R201") { vm.Pay.payresult = "1:결제완료"; //기결제 건(새로고침) vm.Pay.oid2 = pginfo[4] + vm.Pay.payno; vm.PayItemResults = Dao.Get("pay.payitems", vm.Pay.payno); return View("PayReturn", vm); } secureMap.Add("mid", mid); //mid secureMap.Add("tstamp", timestamp); //timestemp secureMap.Add("MOID", resultMap["MOID"]); //MOID secureMap.Add("TotPrice", resultMap["TotPrice"]); //TotPrice vm.Pay.pgkey = (resultMap.ContainsKey("tid") ? resultMap["tid"] : "null"); vm.Pay.ptype = "Card".Equals(resultMap.ContainsKey("payMethod") ? resultMap["payMethod"] : "") ? 1 : "DirectBank".Equals(resultMap.ContainsKey("payMethod") ? resultMap["payMethod"] : "") ? 2 : 3; vm.Pay.payamt = GetInt(resultMap.ContainsKey("TotPrice") ? resultMap["TotPrice"] : "0"); vm.Pay.payno = GetLong((resultMap.ContainsKey("MOID") ? resultMap["MOID"] : "np0").Substring(2)); //(resultMap.ContainsKey("applDate") ? resultMap["applDate"] : "null") //승인날짜 //(resultMap.ContainsKey("applTime") ? resultMap["applTime"] : "null")//승인시간 // signature 데이터 생성 String secureSignature = makeSignatureAuth(secureMap); /************************* 결제보안 추가 END ****************************/ if ("0000".Equals((resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "null")) && secureSignature.Equals(resultMap["authSignature"])) //결제보안 추가 { /***************************************************************************** * 여기에 가맹점 내부 DB에 결제 결과를 반영하는 관련 프로그램 코드를 구현한다. [중요!] 승인내용에 이상이 없음을 확인한 뒤 가맹점 DB에 해당건이 정상처리 되었음을 반영함 처리중 에러 발생시 망취소를 한다. ******************************************************************************/ vm.Pay = Dao.Get("pay.pay", new System.Collections.Hashtable() { { "payno", oid }, { "userno", SUserInfo.UserNo }, { "pstatus21", 0 } }).FirstOrDefault(); if (vm.Pay == null) { vm.Pay = new Pay() { payno = oid, uno = SUserInfo.UserNo, uip = GetUserIP() }; vm.Pay.payresult = "0:결제상품 오류(E1)"; cancelMsg += "|결제상품 오류(E1)"; vm.Pay = new Pay() { payno = oid, uno = SUserInfo.UserNo, uip = GetUserIP() }; throw new Exception("결제상품 오류(E1)"); } else { vm.Pay.uno = SUserInfo.UserNo; vm.Pay.uip = GetUserIP(); //if (vm.Pay.ptypecode != (resultMap.ContainsKey("payMethod") ? resultMap["payMethod"] : "x")) //{ // vm.Pay.payresult = "0:결제방식 오류(E2)"; // cancelMsg += "|결제방식 오류(E2)"; // throw new Exception("결제방식 오류(E2)"); //} if (vm.Pay.payamt != GetInt((resultMap["TotPrice"] ?? "").Replace(",", ""))) { vm.Pay.payresult = "0:결제금액 오류(E3)"; cancelMsg += "|결제금액 오류(E3)"; throw new Exception("결제금액 오류(E3)"); } else { if (vm.Pay.ptype == 3) { //가상계좌 vm.Pay.vactnum = resultMap.ContainsKey("VACT_Num") ? resultMap["VACT_Num"] : null; vm.Pay.vactbankcode = resultMap.ContainsKey("VACT_BankCode") ? resultMap["VACT_BankCode"] : null; vm.Pay.vactbankname = resultMap.ContainsKey("vactBankName") ? resultMap["vactBankName"] : null; vm.Pay.vactname = resultMap.ContainsKey("VACT_Name") ? resultMap["VACT_Name"] : null; vm.Pay.vactinname = resultMap.ContainsKey("VACT_InputName") ? resultMap["VACT_InputName"] : null; //resultMap.ContainsKey("VACT_Date") ? resultMap["VACT_Date"] : "null" 송금일자 확인, 송금 전인데? //resultMap.ContainsKey("VACT_Time") ? resultMap["VACT_Date"] : "null" 송금시간 확인, 송금 전인데? } else if (vm.Pay.ptype == 2) { //실시간계좌이체 vm.Pay.vactbankcode = resultMap.ContainsKey("ACCT_BankCode") ? resultMap["ACCT_BankCode"] : null; vm.Pay.cshrrcode = resultMap.ContainsKey("CSHR_ResultCode") ? resultMap["CSHR_ResultCode"] : null; vm.Pay.cshrtype = resultMap.ContainsKey("CSHR_Type") ? resultMap["CSHR_Type"] : null; } else {//카드 vm.Pay.cardquota = resultMap.ContainsKey("CARD_Quota") ? resultMap["CARD_Quota"] : null; int quota = Convert.ToInt16((resultMap.ContainsKey("CARD_Quota") ? resultMap["CARD_Quota"] : "01")); if ("1".Equals((resultMap.ContainsKey("CARD_Interest") ? resultMap["CARD_Interest"] : "null")) || "1".Equals((resultMap.ContainsKey("EventCode") ? resultMap["EventCode"] : "null"))) { vm.Pay.cardquotatype = 1; } vm.Pay.cardeventcode = resultMap.ContainsKey("EventCode") ? resultMap["EventCode"] : null; vm.Pay.cardnum = resultMap.ContainsKey("CARD_Num") ? resultMap["CARD_Num"] : null; vm.Pay.iscardpoint = "1".Equals((resultMap.ContainsKey("point") ? resultMap["point"] : "null")) ? 1 : 0; vm.Pay.cardcode = resultMap.ContainsKey("CARD_Code") ? resultMap["CARD_Code"] : null; vm.Pay.cardbankcode = resultMap.ContainsKey("CARD_BankCode") ? resultMap["CARD_BankCode"] : null; vm.Pay.cardprtccode = resultMap.ContainsKey("CARD_PRTC_CODE") ? resultMap["CARD_PRTC_CODE"] : null; vm.Pay.checkflag = resultMap.ContainsKey("CARD_CheckFlag") ? resultMap["CARD_CheckFlag"] : null; if ((resultMap.ContainsKey("OCB_Num") ? resultMap["OCB_Num"] : "null") != null && (resultMap.ContainsKey("OCB_Num") ? resultMap["OCB_Num"] : "null") != "") { vm.Pay.ocbnum = resultMap.ContainsKey("OCB_Num") ? resultMap["OCB_Num"] : null; vm.Pay.ocbappno = resultMap.ContainsKey("OCB_SaveApplNum") ? resultMap["OCB_SaveApplNum"] : null; vm.Pay.ocbprice = resultMap.ContainsKey("OCB_PayPrice") ? resultMap["OCB_PayPrice"] : null; } if ((resultMap.ContainsKey("GSPT_Num") ? resultMap["GSPT_Num"] : "null") != null && (resultMap.ContainsKey("GSPT_Num") ? resultMap["GSPT_Num"] : "null") != "") { vm.Pay.gsnum = resultMap.ContainsKey("GSPT_Num") ? resultMap["GSPT_Num"] : null; vm.Pay.gsremain = resultMap.ContainsKey("GSPT_Remains") ? resultMap["GSPT_Remains"] : null; vm.Pay.gsprice = resultMap.ContainsKey("GSPT_ApplPrice") ? resultMap["GSPT_ApplPrice"] : null; } if ((resultMap.ContainsKey("UNPT_CardNum") ? resultMap["UNPT_CardNum"] : "null") != null && (resultMap.ContainsKey("UNPT_CardNum") ? resultMap["UNPT_CardNum"] : "null") != "") { vm.Pay.unum = resultMap.ContainsKey("UNPT_CardNum") ? resultMap["UNPT_CardNum"] : null; vm.Pay.upoint = resultMap.ContainsKey("UPNT_UsablePoint") ? resultMap["UPNT_UsablePoint"] : null; vm.Pay.uprice = resultMap.ContainsKey("UPNT_PayPrice") ? resultMap["UPNT_PayPrice"] : null; } } vm.Pay.payresult = resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : null; vm.Pay.payresultmsg = resultMap.ContainsKey("resultMsg") ? resultMap["resultMsg"] : null; vm.Pay.pgkey = resultMap.ContainsKey("tid") ? resultMap["tid"] : null; vm.Pay.uno = SUserInfo.UserNo; vm.Pay.uip = GetUserIP(); //상품구매완료 처리 (최소 3건 업데이트 (pay, paydata, payitem) if (Dao.Save("pay.paylect", vm.Pay) < 3) { vm.Pay.payresult = "0:구매완료 실패(E4)"; cancelMsg += "|구매완료 실패(E4)"; throw new Exception("구매완료 실패(E4)"); } vm.Pay.payresult = "1:결제완료"; //if (GetConfig("ispaytest") == "1" && vm.Pay.ptype != 3) //{ // vm.Pay.payresult = "1:구매완료 성공 개발단 망취소(S1)"; // String netcancelResultString = processHTTP(authMap, netCancel); // 망취소 요청 API url(고정, 임의 세팅 금지) //} try { vm.Pay.oid2 = pginfo[4] + vm.Pay.payno; vm.PayItemResults = Dao.Get("pay.payitems", vm.Pay.payno); } catch (Exception exresult) { SetError(exresult.StackTrace); } } } //System.Collections.Generic.Dictionary checkMap = new System.Collections.Generic.Dictionary(); //checkMap.Add("mid", mid); // 필수 //checkMap.Add("authToken", HttpUtility.UrlEncode(authToken)); // 필수 - 반드시 urlencode 해서 전달. //checkMap.Add("applDate", (resultMap.ContainsKey("applDate") ? resultMap["applDate"] : "null")); // 필수 //checkMap.Add("applTime", (resultMap.ContainsKey("applTime") ? resultMap["applTime"] : "null")); // 필수 //checkMap.Add("timestamp", timestamp); // 필수 //checkMap.Add("signature", signature); // 필수 //checkMap.Add("charset", charset); // default=UTF-8 //checkMap.Add("format", format); // default=XML } else { vm.Pay.payresult = resultMap.ContainsKey("resultMsg") ? ("0:" + resultMap["resultMsg"]) : "0:결제취소"; vm.Pay.cancelresult = resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : ""; //결제보안키가 다른 경우. if (!secureSignature.Equals(resultMap["authSignature"]) && "0000".Equals((resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "null"))) { cancelMsg += "|보안키오류(E41)"; vm.Pay.payresult = "0:보안키오류(E41)"; //망취소 if ("0000".Equals((resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "null"))) { vm.Pay.payresult = "0:데이터 위변조 에크 오류(E42)"; cancelMsg += "|데이터위변조 체크 실패(E42)"; throw new Exception("데이터 위변조 체크 실패"); } else { try { Dao.Save("pay.pay.fail", new System.Collections.Hashtable() { {"payno", oid },{"pstatus", 66 }, { "payresult", (resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "").Substring(0, 100)}, {"payresultmsg", (resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "").Substring(0, 100) },{ "uno", SUserInfo.UserNo},{"uip", GetUserIP() } }); } catch (Exception ex2) { SetError(cancelMsg += "|" + (cancelMsg ?? "") + "|" + ex2.StackTrace); } } } else { vm.Pay.payresult = "0:결제오류(기타)(E44)"; try { Dao.Save("pay.pay.fail", new System.Collections.Hashtable() { {"payno", oid },{"pstatus", 66 }, { "payresult", (resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "").Substring(0, 100)}, {"payresultmsg", (resultMap.ContainsKey("resultCode") ? resultMap["resultCode"] : "").Substring(0, 100) },{ "uno", SUserInfo.UserNo},{"uip", GetUserIP() } }); } catch (Exception ex2) { SetError(cancelMsg += "|" + (cancelMsg ?? "") + "|" + ex2.StackTrace); } } } // 수신결과를 파싱후 resultCode가 "0000"이면 승인성공 이외 실패 // 가맹점에서 스스로 파싱후 내부 DB 처리 후 화면에 결과 표시 // payViewType을 popup으로 해서 결제를 하셨을 경우 // 내부처리후 스크립트를 이용해 opener의 화면 전환처리를 하세요 //throw new Exception("강제 Exception"); } catch (Exception ex) { //#################################### // 실패시 처리(***가맹점 개발수정***) //#################################### //---- db 저장 실패시 등 예외처리----// //##################### // 망취소 API //##################### String netcancelResultString = processHTTP(authMap, netCancel); // 망취소 요청 API url(고정, 임의 세팅 금지) // 취소 결과 확인 //Response.Write("

    " + netcancelResultString.Replace("<", "<").Replace(">", ">") + "

    "); //망취소기록 try { vm.Pay.cancelresult = (vm.Pay.cancelresult ?? "") + "|" + netcancelResultString; vm.Pay.pstatus = 66; Dao.Save("pay.pay.fail", vm.Pay); SetError(cancelMsg += "|" + (netcancelResultString ?? "") + "|" + ex.StackTrace); } catch (Exception ex2) { SetError(cancelMsg += "|" + (netcancelResultString ?? "") + "|" + ex2.StackTrace); } vm.Pay.payresult = "0:결제중 오류(E101)"; } } else { //############# // 인증 실패시 //############# vm.Pay.payresult = "0:인증실패"; vm.Pay.cancelresult = HttpUtility.UrlDecode(sb.ToString()); } } else { var noti = Request["P_NOTI"]; //모바일 vm.pginfo = GetConfig("pginfo"); vm.IsMobilePay = true; System.Collections.Specialized.NameValueCollection parameters = Request.Params; if ("00".Equals(parameters.Get("P_STATUS"))) { String strReplace = ""; try { //데이터베이스 System.Collections.Generic.Dictionary authMap = new System.Collections.Generic.Dictionary(); authMap.Add("P_TID", parameters.Get("P_TID"));// 필수 authMap.Add("P_MID", vm.pginfo.Split('|')[1]); // 필수 //결제승인요청 String authResultString = processHTTP(authMap, parameters.Get("P_REQ_URL")); strReplace = authResultString.Replace(",", "&").Replace(":", "=").Replace("\"", "").Replace(" ", "").Replace("\n", "").Replace("}", "").Replace("{", ""); System.Collections.Generic.Dictionary resultMap = parseStringToMap(strReplace); if ("00".Equals(resultMap["P_STATUS"])) { //db처리 try { Int64 oid = GetLong(resultMap["P_OID"].Substring(2)); vm.Pay = Dao.Get("pay.pay", new System.Collections.Hashtable() { { "payno", oid }, { "userno", SUserInfo.UserNo } }).FirstOrDefault(); if (vm.Pay == null) { vm.Pay = new Pay() { payno = 0, payresultmsg = "주문내역오류입니다." }; throw new Exception("결제상품 오류(E1)"); } else if (vm.Pay.pstatus == 1 || vm.Pay.pstatus == 22) { vm.Pay = new Pay() { payno = 0, payresultmsg = "이미 결제된 주문내역입니다." }; } else { vm.Pay.uno = SUserInfo.UserNo; vm.Pay.uip = GetUserIP(); if (vm.Pay.payamt != GetInt((resultMap["P_AMT"] ?? "").Replace(",", ""))) { vm.Pay = new Pay() { payno = 0, payresultmsg = "결제금액 오류입니다." }; throw new Exception("결제금액 오류(E3)"); } else { //if (GetConfig("ispaytest") == "1" && vm.Pay.ptype != 3) //{ // try // { // //개발단 망취소 // System.Collections.Generic.Dictionary authMapCancel = new System.Collections.Generic.Dictionary(); // authMapCancel.Add("P_TID", parameters.Get("P_TID")); // authMapCancel.Add("P_MID", vm.pginfo.Split('|')[1]); // authMapCancel.Add("P_AMT", vm.Pay.payamt.ToString()); // authMapCancel.Add("P_OID", resultMap["P_OID"]); // authResultString = processHTTP(authMapCancel, parameters.Get("P_REQ_URL").Substring(0, parameters.Get("P_REQ_URL").Length - parameters.Get("P_REQ_URL").Split('/').Last().Length) + "payNetCancel.ini", true); // strReplace = authResultString.Replace(",", "&").Replace(":", "=").Replace("\"", "").Replace(" ", "").Replace("\n", "").Replace("}", "").Replace("{", ""); // System.Collections.Generic.Dictionary resultMapCancel = parseStringToMap(strReplace); // if ("00".Equals(resultMapCancel["P_STATUS"])) // { // Console.WriteLine(resultMapCancel["P_TID"] + ":" + resultMapCancel["P_RMESG1"]); // } // else // { // Console.WriteLine(EuckrToUtf8(resultMapCancel["P_RMESG1"])); // } // } // catch (Exception excancel) // { // SetError(excancel.Message); // } //} if (vm.Pay.ptype == 3) { #region 가상계좌파라미터전문 //가상계좌 //"P_STATUS=00&P_AUTH_DT=20190819174235&P_AUTH_NO=&P_RMESG1=성공적으로 처리 하였습니다.&P_RMESG2= //&P_TID =INIMX_VBNKINIpayTest20190819174235894667&P_FN_CD1=&P_AMT=1000&P_TYPE=VBANK&P_UNAME=npuser1name&P_MID=INIpayTest //&P_OID=te170&P_NOTI=MOBILE|/OffDetail?cmno=87|170 //&P_NEXT_URL=https://phd.nptc.kr:8080/Course/OffPayReturn&P_MNAME= //&P_NOTEURL=https://phd.nptc.kr:8080/Account/PayVBankMoney //&P_VACT_NUM=07500531297112 //&P_VACT_DATE=20190825 //&P_VACT_TIME=235900 //&P_VACT_NAME=(주)케이지이니시 //&P_VACT_BANK_CODE=03 //&P_CSHR_CODE=0000&P_CSHR_MSG=정상처리되었습니다.&P_CSHR_AMT=1000 //&P_CSHR_SUP_AMT=1000&P_CSHR_TAX=0&P_CSHR_SRVC_AMT=0&P_CSHR_TYPE=0&P_CSHR_DT=20190819174235&P_CSHR_AUTH_NO=" #endregion vm.Pay.vactnum = resultMap["P_VACT_NUM"]; vm.Pay.vactbankcode = resultMap["P_VACT_BANK_CODE"]; vm.Pay.vactbankname = GetBankName(resultMap["P_VACT_BANK_CODE"]); vm.Pay.vactname = resultMap["P_VACT_NAME"]; //vm.Pay.vactinname = resultMap.ContainsKey("VACT_InputName") ? resultMap["VACT_InputName"] : null; 입금자명 안주네? } else if (vm.Pay.ptype == 2) { #region 실시간계좌이체 파라미터전문 /* * 실시간계좌이체 P_STATUS=00 P_AUTH_DT =20190820154747 P_AUTH_NO= P_RMESG1=성공적으로처리하였습니다. P_RMESG2= P_TID=INIMX_DBNKINIpayTest20190820154747214066 P_FN_CD1=04 P_AMT=1000 P_TYPE=BANK P_UNAME=npuser1name P_MID=INIpayTest P_OID=te222 P_NOTI=MOBILE|/OffDetail?cmno=87|222 P_NEXT_URL=https=//phd.nptc.kr=8080/Course/OffPayReturn P_MNAME= P_NOTEURL= P_FN_NM=KB국민은행 P_ACCT_NUM=*********58215 P_CSHR_CODE=0000 P_CSHR_MSG=정상처리되었습니다. P_CSHR_AMT=1000 P_CSHR_SUP_AMT=1000 P_CSHR_TAX=0 P_CSHR_SRVC_AMT=0 P_CSHR_TYPE=0 P_CSHR_DT=20190820154747 P_CSHR_AUTH_NO=266393740 */ #endregion vm.Pay.vactnum = resultMap["P_ACCT_NUM"]; vm.Pay.vactbankcode = resultMap["P_FN_CD1"]; vm.Pay.vactbankname = resultMap["P_FN_NM"]; vm.Pay.cshrrcode = resultMap["CSHR_ResultCode"]; vm.Pay.cshrtype = resultMap["CSHR_Type"]; vm.Pay.cshrauthno = resultMap["P_CSHR_AUTH_NO"]; } else { #region 신용카드 파라미터전문 //카드 //P_STATUS=00 //P_AUTH_DT =20190820154214 //P_AUTH_NO =30025104 //P_RMESG1=성공적으로처리하였습니다. //P_RMESG2=00 //P_TID=INIMX_ISP_INIpayTest20190820154214874779 //P_FN_CD1=06 //P_AMT=1000 //P_TYPE=CARD //P_UNAME=npuser1name //P_MID=INIpayTest //P_OID=te219 //P_NOTI=MOBILE|/OffDetail?cmno=87|219 //P_NEXT_URL=https=//phd.nptc.kr=8080/Course/OffPayReturn //P_MNAME= //P_NOTEURL= //P_CARD_MEMBER_NUM= //P_CARD_NUM=943646*********7 //P_CARD_ISSUER_CODE=04 //P_CARD_PURCHASE_CODE=06 //P_CARD_PRTC_CODE=1 //P_CARD_INTEREST=0 //P_CARD_CHECKFLAG=1 //P_CARD_ISSUER_NAME=국민카드 //P_CARD_PURCHASE_NAME=국민계열 //P_FN_NM=국민계열 //P_ISP_CARDCODE=000204040015606 //P_CARD_APPLPRICE=1000 #endregion vm.Pay.cardquota = resultMap["P_RMESG2"]; vm.Pay.cardquotatype = GetInt(resultMap["P_CARD_INTEREST"]); vm.Pay.cardnum = resultMap["P_CARD_NUM"]; vm.Pay.cardcode = resultMap["P_FN_CD1"]; vm.Pay.cardbankcode = resultMap["P_CARD_ISSUER_CODE"]; vm.Pay.cardprtccode = resultMap["P_CARD_PURCHASE_CODE"]; vm.Pay.checkflag = resultMap["P_CARD_CHECKFLAG"]; vm.Pay.vactname = resultMap["P_AUTH_NO"]; } vm.Pay.payresult = resultMap["P_STATUS"]; vm.Pay.payresultmsg = resultMap["P_RMESG1"]; vm.Pay.pgkey = resultMap["P_TID"]; vm.Pay.uno = SUserInfo.UserNo; vm.Pay.uip = GetUserIP(); //상품구매완료 처리 (최소 3건 업데이트 (pay, paydata, payitem) if (Dao.Save("pay.paylect", vm.Pay) < 3) { //vm.Pay.payresult = "0:구매완료 실패(E4)"; vm.Pay = new Pay() { payno = 0, payresultmsg = "상품DB처리 중 오류발생" }; throw new Exception("구매완료 실패(E4)"); } vm.Pay.payresult = "1:결제완료"; try { vm.Pay.oid2 = vm.pginfo.Split('|')[4] + vm.Pay.payno; vm.PayItemResults = Dao.Get("pay.payitems", vm.Pay.payno); } catch (Exception exresult) { SetError(exresult.StackTrace); } return View("PayReturn", vm); } } } catch (Exception ex2) { SetError("모바일결제오류망취소: " + noti.Split('|')[1] + ": " + ex2.Message); //망취소요청 try { vm.Pay = new Pay() { payno = 0, payresultmsg = "상품 DB처리중 오류발생" }; //개발단 망취소 System.Collections.Generic.Dictionary authMapCancel = new System.Collections.Generic.Dictionary(); authMapCancel.Add("P_TID", parameters.Get("P_TID")); authMapCancel.Add("P_MID", vm.pginfo.Split('|')[1]); authMapCancel.Add("P_AMT", vm.Pay.payamt.ToString()); authMapCancel.Add("P_OID", resultMap["P_OID"]); authResultString = processHTTP(authMapCancel, parameters.Get("P_REQ_URL").Substring(0, parameters.Get("P_REQ_URL").Length - parameters.Get("P_REQ_URL").Split('/').Last().Length) + "payNetCancel.ini", true); strReplace = authResultString.Replace(",", "&").Replace(":", "=").Replace("\"", "").Replace(" ", "").Replace("\n", "").Replace("}", "").Replace("{", ""); System.Collections.Generic.Dictionary resultMapCancel = parseStringToMap(strReplace); if ("00".Equals(resultMapCancel["P_STATUS"])) { Console.WriteLine(resultMapCancel["P_TID"] + ":" + resultMapCancel["P_RMESG1"]); } else { SetError("모바일망취소실패2: " + noti.Split('|')[1] + ": " + (resultMapCancel["P_RMESG1"] ?? "")); } } catch (Exception ex3) { SetError("모바일망취소실패1: " + noti.Split('|')[1] + ": " + ex2.Message); } } vm.Pay = new Pay() { payno = 1, payresultmsg = Request["P_RMESG1"] }; } else { //Dictionary secureMap = new Dictionary(); //if (resultMap["resultCode"] == "R201") //{ vm.Pay = new Pay() { payno = GetLong(Request["P_NOTI"].Split('|')[2]), oid2 = GetConfig("pginfo").Split('|')[4] + GetLong(Request["P_NOTI"].Split('|')[2]) }; vm.Pay.payresult = "1:결제완료"; //기결제 건(새로고침) vm.PayItemResults = Dao.Get("pay.payitems", vm.Pay.payno); return View("PayReturn", vm); //} //SetError("모바일결제오류02: " + noti.Split('|')[1] + ": "); //vm.Pay = new Pay() { payno = 0, payresultmsg = "결제사 승인오류발생" }; } } catch (Exception ex) { SetError("모바일결제오류01: " + noti.Split('|')[1] + ": " + ex.Message); vm.Pay = new Pay() { payno = 0, payresultmsg = "결제사 연결중 오류발생" }; } } else { vm.Pay = new Pay() { payno = 0, payresultmsg = Request["P_RMESG1"] + "
    결제완료화면에서 이전화면으로 돌아가면서 이동하면 발생하는 경우일 수 있습니다." }; } } } return View("PayReturn", vm); } } }