using Business.KFTCBusiness; using Business.SendMoney; using Common; using Common.KFTC; using Common.Model; using Common.Model.KFTCRegistration; using JsonRx.AuthFilter; using JsonRx.Helper; using log4net; using Newtonsoft.Json; using System; using System.Web.Http; namespace JsonRx.Api { /// /// This is route prefix to make KFTC registration /// [RoutePrefix("api/v1/kftc")] public class KftcController : ApiController { private readonly IKftcProcessBusiness _business; /// /// public KftcController() { } /// /// /// public KftcController(KftcProcessBusiness business) { _business = business; } private static readonly ILog Log = LogManager.GetLogger(typeof(KftcController)); /// /// /// /// [HttpGet] [TokenAuthentication] [Route("GetKftcParameters/{user}")] public IHttpActionResult GetKftcParameters(string user) { JsonRxResponse resp = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetKftcParameters"; Log.Debug("Log1 : GetKftcParameters started : header : " + Request); if (user == null) { resp.ErrorCode = "1"; resp.Msg = "Invalid Parameters."; resp.Data = new { }; return Ok(resp); } var email = Util.GetUsername(Request); if (!email.ToLower().Equals(user.ToLower())) { resp.ErrorCode = "1"; resp.Msg = "Invalid Parameters."; resp.Data = new { }; return Ok(resp); } var customerId = Util.GetCustomerId(Request); var kftcLangauge = Util.GetKFTCLanguage(Request); var kftcClientId = Util.GetKFTCClientId(Request); Log.Debug("key:Kftc-GetKftcParameters process started"); resp = _business.RegistrationKFTC(customerId, kftcLangauge, kftcClientId); Log.Debug(resp); return Ok(resp); } /// /// /// /// /// [HttpPost] [TokenAuthentication] [Route("DeleteAccount/{user}")] public IHttpActionResult DeleteAccount(string user, DeleteRequest req) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DeleteAccount"; Log.Debug("Log1: DeleteAccount started : header : " + Request); if (user == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid Parameters."; jxRes.Data = new { }; } var email = Util.GetUsername(Request); //if (!email.ToLower().Equals(user.ToLower())) //{ // jxRes.ErrorCode = "1"; // jxRes.Msg = "Invalid Parameters."; // jxRes.Data = new {}; //} var customerId = Util.GetCustomerId(Request); //var fintechUseNo = Util.GetFintechUseNo(Request); //var accessToken = Util.GetAccessToken(Request); //var customerId = "1"; Log.Debug("key:Kftc-DeleteAccount process started(inquiry)"); jxRes = _business.CancelAccount("inquiry", req, customerId); Log.Debug("result:Kftc-DeleteAccount process started(inquiry):" + jxRes.ErrorCode); if (jxRes.ErrorCode == "0") { Log.Debug("key:Kftc-DeleteAccount process started(transfer)"); jxRes = _business.CancelAccount("transfer", req, customerId); Log.Debug("result:Kftc-DeleteAccount process started(transfer):" + jxRes.ErrorCode); if (jxRes.ErrorCode == "0") { jxRes = _business.DeleteAccount(req, customerId); } } Log.Debug("result:Kftc-DeleteAccount process ended:ErrorCode=" + jxRes.ErrorCode + ",Msg=" + jxRes.Msg); return Ok(jxRes); } /// /// /// /// /// [HttpPost] [TokenAuthentication] [Route("GetOTP")] public IHttpActionResult GetOPTNumber(OTP_Request oTP) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetOPTNumber"; Log.Debug("Log1: GetOPTNumber started : header : " + Request); if (oTP.userId == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid Parameters."; jxRes.Data = new { Message = jxRes.Msg }; } var email = Util.GetUsername(Request); if (!email.ToLower().Equals(oTP.userId.ToLower())) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid Parameters."; jxRes.Data = new { Message = jxRes.Msg }; } var customerId = Util.GetCustomerId(Request); Log.Debug("key:Kftc-GetOPTNumber process started"); jxRes = _business.GetOPTNumber(customerId, oTP.userId, oTP.amount, oTP.kftcId); return Ok(jxRes); } /// /// /// /// /// [HttpGet] [TokenAuthentication] [Route("KFTCBankList")] public IHttpActionResult GetKFTCBankList() { LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetKFTCBankList"; Log.Debug("Starting Get KFTCBankList"); var resp = _business.GetKFTCBankList(); return Ok(resp); } /// /// /// /// /// [HttpPost] [TokenAuthentication] [Route("CheckRealName")] public IHttpActionResult CheckRealName(CheckRealNameModel model) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "CheckRealName"; Log.Debug("Starting Real Name Checking" + JsonConvert.SerializeObject(model)); if (model == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid parameters."; jxRes.Data = new { Message = jxRes.Msg }; return Ok(jxRes); } jxRes = _business.KFTC_RealNameCheck_V2(model); return Ok(jxRes); } [HttpGet] [TokenAuthentication] [Route("CheckKFTCAccounts/{user}")] public IHttpActionResult CheckKFTCAccounts(string user) { JsonRxResponse resp = new JsonRxResponse(); LogicalThreadContext.Properties["TraceId"] = Guid.NewGuid(); LogicalThreadContext.Properties["MethodName"] = "CheckKFTCAccounts"; Log.Debug("Log1 : CheckKFTCAccounts started : header : " + Request); if (user == null) { resp.ErrorCode = "1"; resp.Msg = "Invalid Parameters."; resp.Data = new { }; return Ok(resp); } var email = Util.GetUsername(Request); //email = "maxkim@gmeremit.com"; if (!email.ToLower().Equals(user.ToLower())) { resp.ErrorCode = "1"; resp.Msg = "Invalid Parameters."; resp.Data = new { }; return Ok(resp); } var customerId = Util.GetCustomerId(Request); var kftcLangauge = Util.GetKFTCLanguage(Request); var kftcClientId = Util.GetKFTCClientId(Request); //customerId = "85074"; //kftcLangauge = "ko"; //kftcClientId = "l7xx9a67eaeb6a684f15b441769931d582b3"; Log.Debug("key:Kftc-CheckKFTCAccounts process started"); resp = _business.CheckKFTCAccounts(customerId, kftcLangauge, kftcClientId); return Ok(resp); } /* 2019.09 Dana */ [HttpPost] [TokenAuthentication] [Route("CheckBalance")] public IHttpActionResult CheckBalance(CheckBalanceModel model) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "CheckBalance"; Log.Debug("Starting Balance Checking" + JsonConvert.SerializeObject(model)); if (model == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid parameters."; return Ok(jxRes); } jxRes = _business.CheckBalance(model); return Ok(jxRes); } /* 2019.09 Dana */ [HttpPost] [TokenAuthentication] [Route("DomeRemitStart")] public IHttpActionResult DomeRemitStart(CheckRealNameModel model) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DomeRemitStart"; Log.Debug("Starting Domestic Remittance basic information : " + model.CustomerId); if (model.CustomerId == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid parameters."; jxRes.Data = new { Message = jxRes.Msg }; return Ok(jxRes); } jxRes = _business.DomeRemitStart(model.CustomerId); return Ok(jxRes); } /* 2019.09 Dana */ [HttpPost] [TokenAuthentication] [Route("GetRecipientInfo")] public IHttpActionResult GetRecipientInfo(CheckRealNameModel model) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetRecipientInfo"; Log.Debug("Starting Get Recipient Information" + JsonConvert.SerializeObject(model)); if (model == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid parameters."; jxRes.Data = new { Message = jxRes.Msg }; return Ok(jxRes); } //jxRes = _business.GetRecipientInfo(model); //for test Response.recipientInfo info = new Response.recipientInfo(); info.RecipientName = "홍길동"; info.RecipientPhone = "01012345678"; jxRes.ErrorCode = "0"; jxRes.Msg = "Success"; jxRes.Data = info; return Ok(jxRes); } /* 2019.09 Dana */ [HttpPost] [TokenAuthentication] [Route("GetRecentHistories")] public IHttpActionResult GetRecentHistories(RecentHistoryModel model) { JsonRxResponse jxRes = new JsonRxResponse(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetRecentHistories"; Log.Debug("Starting Get Recent History" + JsonConvert.SerializeObject(model)); if (model == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid parameters."; jxRes.Data = new { Message = jxRes.Msg }; return Ok(jxRes); } jxRes = _business.GetRecentHistories(model); return Ok(jxRes); } /* 2019.09 Dana */ [HttpPost] [TokenAuthentication] [Route("SendDomeRimit")] public IHttpActionResult SendDomeRimit(DomeRimitRequestModel model) { DbResult _dbRes = new DbResult(); JsonRxResponse jxRes = new JsonRxResponse(); jxRes.SetResponse("1", "Invalid transaction requested", null); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = model.UserId; LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "SendDomeRimit"; Log.Debug("Starting Domestic Remittance" + JsonConvert.SerializeObject(model)); if (model == null) { jxRes.ErrorCode = "1"; jxRes.Msg = "Invalid parameters."; jxRes.Data = new { Message = jxRes.Msg }; return Ok(jxRes); } if (ModelState.IsValid)// OTP인증 { Log.Debug("Domestic Remittance OTP Validate Start : " + Convert.ToString(model.txnPassword)); //model.txnPassword = StringExtension.ToVirtualKeyDecryptString(model.txnPassword); model.txnPassword = model.txnPassword; string type = ""; if (model.type == "wallet") { type = "wallet"; } else { type = (model.isUseBiometric) ? "wallet" : "autodebit"; } Log.Debug("is biometric use: " + Convert.ToString(model.isUseBiometric)); _dbRes = _business.CheckLoginPassword(model.UserId, model.txnPassword, type, model.CustomerId); if (_dbRes.ResponseCode == "0") { DomesticRemitModel DRModel = new DomesticRemitModel(); DRModel.SetRequestData(model); jxRes = _business.SendDomeRimit(DRModel); return Ok(jxRes); } else { jxRes.SetResponse("1", _dbRes.Msg, null); return Ok(jxRes); } } //jxRes = _business.SendDomeRimit(model); // for UAT Test return Ok(jxRes); } } }