티스토리 뷰

System.Net.HttpWebRequest wReq;

            System.Net.HttpWebResponse wRes;


            Uri uri = new Uri("https://www.allthegate.com/payment/mobilev2/transaction/ansim.jsp?storeID=" + StoreId + "&trackingID=" + tracking_id + "&type=approve");

            wReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);

            wReq.Method = "GET";

            wReq.ServicePoint.Expect100Continue = false;


            using (wRes = (HttpWebResponse)wReq.GetResponse())

            {

                

                System.IO.Stream respPostStream = wRes.GetResponseStream();

                System.IO.StreamReader readerPost = new System.IO.StreamReader(respPostStream, Encoding.GetEncoding("utf-8"), true);

                JsonResult js = Json(readerPost.ReadToEnd(), JsonRequestBehavior.AllowGet);


                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

                AllTheGateMobileResultEntity allTheGateMobileResultEntity = serializer.Deserialize<AllTheGateMobileResultEntity>(js.Data.ToString());

                allTheGateMobileResultEntity.JsonData = js.Data.ToString();

                

                #region JsonData


                string OrderNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    OrderNo = allTheGateMobileResultEntity.data["OrderNo"];

                }


                string AgentNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    AgentNo = allTheGateMobileResultEntity.data["AgentNo"];

                }


                // 성공 여부

                string Success = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    Success = allTheGateMobileResultEntity.data["Success"];

                }


                // 승인 번호

                string AdmNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    AgentNo = allTheGateMobileResultEntity.data["AdmNo"];

                }


                // 승인 시각

                string AdmTime = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    AdmTime = allTheGateMobileResultEntity.data["AdmTime"];

                }


                string DealNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    DealNo = allTheGateMobileResultEntity.data["DealNo"];

                }


                string EscrowSendNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    EscrowSendNo = allTheGateMobileResultEntity.data["EscrowSendNo"];

                }


                string CardName = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    CardName = allTheGateMobileResultEntity.data["CardName"];

                }


                string CardName2 = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    CardName2 = allTheGateMobileResultEntity.data["CardName2"];

                }


                string CardType = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    CardType = allTheGateMobileResultEntity.data["CardType"];

                }


                string DealWon = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    DealWon = allTheGateMobileResultEntity.data["DealWon"];

                }


                string DataCode = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    DataCode = allTheGateMobileResultEntity.data["Code"];

                }


                string SendNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    SendNo = allTheGateMobileResultEntity.data["SendNo"];

                } 


                string CardType2 = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    CardType2 = allTheGateMobileResultEntity.data["CardType2"];

                }


                string PayType = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    PayType = allTheGateMobileResultEntity.data["PayType"];

                }


                string CardPartialMm = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    DataCode = allTheGateMobileResultEntity.data["CardPartialMm"];

                }


                string DeviId = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    DeviId = allTheGateMobileResultEntity.data["DeviId"];                   

                }


                string OrdNo = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    OrdNo = allTheGateMobileResultEntity.data["OrdNo"];

                }


                // 금액

                string Amt = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    Amt = allTheGateMobileResultEntity.data["Amt"];

                }


                string EscrowYn = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    EscrowYn = allTheGateMobileResultEntity.data["EscrowYn"];

                }


                string NetCancelId = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    NetCancelId = allTheGateMobileResultEntity.data["NetCancelId"];

                }


                string AuthTy = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    AuthTy = allTheGateMobileResultEntity.data["AuthTy"];

                }


                string SubTy = string.Empty;

                if (allTheGateMobileResultEntity.data != null)

                {

                    SubTy = allTheGateMobileResultEntity.data["SubTy"];

                }


                #endregion               

                

                if ("y".Equals(Success))

                {


                    #region 결제 정보 로그 작성

                    AllTheGateResultLogEntity allTheGateResultLogEntity = new AllTheGateResultLogEntity();

                    allTheGateResultLogEntity.Amt = Amt;

                    allTheGateResultLogEntity.ApprNo = AdmNo;

                    allTheGateResultLogEntity.ApprTm = AdmTime;

                    allTheGateResultLogEntity.AuthTy = "card";

                    allTheGateResultLogEntity.BusiCd = string.Empty; // 전문 코드

                    allTheGateResultLogEntity.CardCd = string.Empty; // 카드사 코드

                    allTheGateResultLogEntity.CardNm = CardName;

                    allTheGateResultLogEntity.mTId = EscrowSendNo;

                    allTheGateResultLogEntity.ResMsg = allTheGateMobileResultEntity.message;

                    allTheGateResultLogEntity.SuccYn = Success;

                    allTheGateResultLogEntity.VirNo = string.Empty;

                    allTheGateResultLogEntity.VIRTUAL_CENTERCD = string.Empty;

                    allTheGateResultLogEntity.VIRTUAL_DEPODT = string.Empty;

                    allTheGateResultLogEntity.OrderNo = OrderNo;

                    

                    string message = OrderSheetWriteComplete(allTheGateResultLogEntity);

                    #endregion


                    return Content(string.Format(this.javascriptRedirect, Url.Action("OrderSheetWriteResult", "ShoppingCart"), "text/html"));


                }

                else

                {

                    return Content(string.Format(javascriptAlert, "[ErrorCode : M-000] 모바일 결제 오류"), "text/html");

                }


            }

728x90
반응형