using Common; using Common.Helper; using Common.KFTC; using Common.Model; using Common.Model.AutoRefund; using Common.Model.KFTCRegistration; using Common.Model.KftcSendMoney; using Common.Model.SendMoney; using log4net; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Repository.AutoRefund; using Repository.Coupon; using Repository.KFTCRepository; using Repository.Mobile; using Repository.SendMoney; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading; using System.Web; namespace Business.KFTCBusiness { public class KftcProcessBusiness : IKftcProcessBusiness { private readonly IKftcProcessRepository _repo; private readonly IMobileServicesRepo _mobilerepo; private readonly ISendMoneyRepository _sendrepo; private readonly IAutoRefundRepository _autorepo; private readonly ICouponRepository icouponrepo; private static readonly ILog Log = LogManager.GetLogger(typeof(KftcProcessBusiness)); public KftcProcessBusiness(KftcProcessRepository repo, CouponRepository icouponrepo, MobileServicesRepo mobilerepo, SendMoneyRepository sendrepo, AutoRefundRepository autorepo) { _repo = repo; this.icouponrepo = icouponrepo; _mobilerepo = mobilerepo; _sendrepo = sendrepo; _autorepo = autorepo; } #region AUTO DEBIT ACCOUNT REGISTRATION public JsonRxResponse RegistrationKFTC(string customerId, string lang, string client_id) { JsonRxResponse res = new JsonRxResponse(); try { string URL = GetKftcUrl(customerId, lang, client_id); List AccountList = GetAccountList(customerId); AccountList.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", ""))); List
ListLangauge = GetKftcLanguage(customerId); List
ListHeader = GetKftcHeader(customerId); KftcCommonResponse Response = new KftcCommonResponse() { AccountList = AccountList, Header = ListHeader, URL = URL, Language = ListLangauge }; res.ErrorCode = "0"; res.Msg = "Success"; res.Data = Response; return res; } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); res.SetResponse("1", "Exception tracked : " + ex.Message, null); res.Data = new { }; return res; } } private List
GetKftcLanguage(string customerId) { DataTable dt = _repo.GetKftcLanguage(customerId); List
ListLanguage = new List
(); if (dt == null || dt.Rows.Count <= 0) { return ListLanguage; } foreach (DataRow row in dt.Rows) { Header language = new Header(); language.Key = row["key"].ToString(); language.Value = row["value"].ToString(); ListLanguage.Add(language); }; return ListLanguage; } private string GetKftcUrl(string customerId, string lang, string client_id) { var custId = "mobile_" + customerId; //for test //client_id = "B41lT2TeaECwRA4ITjGsbHOGAnm5gPBojPC1zTRq"; Guid g = Guid.NewGuid(); string stateValue = g.ToString().Replace("-", ""); var auth = new Common.KFTC.Request.Authorize(); auth.response_type = "code"; auth.client_id = client_id; auth.redirect_uri = KFTC_GME.callback_url; auth.scope = "login inquiry transfer"; auth.client_info = custId; auth.state = stateValue; auth.auth_type = "1"; auth.bg_color = "#F4F8FB"; auth.txt_color = "#000000"; auth.btn1_color = "#EF343B"; auth.btn2_color = "#22246B"; //auth.lang = lang; auth.edit_option = "off"; string _URL = @"oauth/2.0/authorize?@query"; var jObj = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(auth)); var query = String.Join("&", jObj.Children().Cast().Select(jp => jp.Name.Equals("redirect_uri") ? jp.Name + "=" + (jp.Value.ToString()) : jp.Name + "=" + HttpUtility.UrlEncode(jp.Value.ToString()))); return ApplicationConfig.ReadWebConfig("KFTC_HOST_NAME", "") + _URL.Replace("@query", query); } private List
GetKftcHeader(string customerId) { DataRow dr = _repo.GetCustomerData(customerId); List
listKftcHeader = new List
(); string[] param = new string[] { "Kftc-Bfop-UserSeqNo", "Kftc-Bfop-UserCI", "Kftc-Bfop-UserName" , "Kftc-Bfop-UserInfo","Kftc-Bfop-UserCellNo","Kftc-Bfop-PhoneCarrier","Kftc-Bfop-UserEmail"}; if (dr == null) { //KftcHeader.Add("Kftc-Bfop-UserSeqNo", ""); //KftcHeader.Add("Kftc-Bfop-UserCI", ""); //KftcHeader.Add("Kftc-Bfop-UserName", ""); //KftcHeader.Add("Kftc-Bfop-UserInfo", ""); //KftcHeader.Add("Kftc-Bfop-UserCellNo", ""); //KftcHeader.Add("Kftc-Bfop-PhoneCarrier", ""); //KftcHeader.Add("Kftc-Bfop-UserEmail", ""); foreach (var item in param) { Header KftcHeader = new Header(); KftcHeader.Key = item; KftcHeader.Value = ""; listKftcHeader.Add(KftcHeader); } } else { Header KftcHeader1 = new Header(); KftcHeader1.Key = "Kftc-Bfop-UserSeqNo"; KftcHeader1.Value = string.IsNullOrEmpty(dr["userSeqNo"].ToString()) ? "" : dr["userSeqNo"].ToString(); listKftcHeader.Add(KftcHeader1); Header KftcHeader2 = new Header(); KftcHeader2.Key = "Kftc-Bfop-UserCI"; KftcHeader2.Value = string.IsNullOrEmpty(dr["userCi"].ToString()) ? "" : dr["userCi"].ToString(); listKftcHeader.Add(KftcHeader2); Header KftcHeader3 = new Header(); KftcHeader3.Key = "Kftc-Bfop-UserName"; KftcHeader3.Value = string.IsNullOrEmpty(dr["userName"].ToString()) ? "" : dr["userName"].ToString(); listKftcHeader.Add(KftcHeader3); Header KftcHeader4 = new Header(); KftcHeader4.Key = "Kftc-Bfop-UserInfo"; KftcHeader4.Value = string.IsNullOrEmpty(dr["userInfo"].ToString()) ? "" : dr["userInfo"].ToString(); listKftcHeader.Add(KftcHeader4); Header KftcHeader5 = new Header(); KftcHeader5.Key = "Kftc-Bfop-UserCellNo"; KftcHeader5.Value = string.IsNullOrEmpty(dr["UserCellNo"].ToString()) ? "" : dr["UserCellNo"].ToString(); listKftcHeader.Add(KftcHeader5); Header KftcHeader6 = new Header(); KftcHeader6.Key = "Kftc-Bfop-PhoneCarrier"; KftcHeader6.Value = ""; listKftcHeader.Add(KftcHeader6); Header KftcHeader7 = new Header(); KftcHeader7.Key = "Kftc-Bfop-UserEmail"; KftcHeader7.Value = string.IsNullOrEmpty(dr["UserEmail"].ToString()) ? "" : dr["UserEmail"].ToString(); listKftcHeader.Add(KftcHeader7); } return listKftcHeader; } /* * KFTC_CUSTOMER_SUB 테이블에 등록된 계좌정보를 가져온다. * */ private List GetAccountList(string customerId) { var accessToken = ""; //see again List _accountDetails = new List(); List _delAccountList = new List(); AccountDetails _accDetail = new AccountDetails(); DataTable dt = _repo.GetAccountList(customerId); if (dt == null || dt.Rows.Count <= 0) { return _accountDetails; } string IsSyncAccList = dt.Rows[0]["IsSyncAccList"].ToString(); List _accList = new List(); if (IsSyncAccList == "Y") { DataRow customer = _repo.GetCustomerData(customerId); if (customer != null) { string userSeqNo = customer["userSeqNo"].ToString(); //how?? Response.account_list _accountList = AccountListAPI(userSeqNo, accessToken, customerId); _accList = _accountList.res_list; } } foreach (DataRow item in dt.Rows) { AccountDetails _account = new AccountDetails(); _account.KftcAccountId = item["RowId"].ToString(); _account.BankCode = item["BankCode"].ToString(); _account.BankCodeStd = item["BankCode"].ToString(); _account.IsInboundPennyTestRequested = Convert.ToBoolean(item["IsInboundPennyTestRequested"]); // _account.AccessToken = item["access_token"].ToString(); //_account.TokenType = item["tokenType"].ToString(); //_account.Scope = item["scope"].ToString(); //_account.UserCi = item["userCi"].ToString(); //_account.CustomerId = item["customerId"].ToString(); //_account.UserSeqNo = item["userSeqNo"].ToString(); //_account.FintechUseNo = item["fintechUseNo"].ToString(); //_account.BankCodeStd = item["bankCodeStd"].ToString(); _account.BankName = item["bankName"].ToString(); //_account.AccountNum = item["accountNum"].ToString(); _account.AccountNumMasked = item["accountNumMasked"].ToString(); //_account.AccountName = item["accountName"].ToString(); _account.IsShowRefresh = item["IsShowRefresh"].ToString(); if (IsSyncAccList == "Y") { if (_accList.Count > 0) { bool bSearch = false; foreach (var acc in _accList) { if ((_account.AccountNum == acc.account_num) && (acc.transfer_agree_yn == "Y")) { bSearch = true; _accountDetails.Add(_account); break; } } if (!bSearch) { _delAccountList.Add(_account); } } } else { _accountDetails.Add(_account); } } if (_delAccountList.Count > 0) { foreach (var account in _delAccountList) { _repo.DeleteAccount(account); } } return _accountDetails; } /* * 등록계좌조회 API * */ private Response.account_list AccountListAPI(string userSeqNo, string accessToken, string customerId) { Response.account_list _accountList = new Response.account_list(); DbResult _logResp = new DbResult(); string _acclistURL = @"v2.0/account/list?user_seq_no=@user_seq_no&include_cancel_yn=@include_cancel_yn&sort_order=@sort_order"; try { Request.list req = new Request.list(); req.user_seq_no = userSeqNo; // user_seq_no; req.sort_order = "D"; // Descending, A:Ascending req.include_cancel_yn = "N"; // 해지계좌 불포함, Y:해지계좌 포함 _logResp = _repo.LogRequestKFTC(customerId, "Account/List", "URL: " + _acclistURL + " RequestData: " + JsonConvert.SerializeObject(req), ""); Log.Debug("[KFTC-API-REQ] account/list : [customerId]:" + customerId + " [REQ URL]:" + _acclistURL + " [REQ DATA]:" + JsonConvert.SerializeObject(req)); KFTCPostGet kftcRequest = new KFTCPostGet(); var acclistResult = kftcRequest.GetFromKFTC(_acclistURL.Replace("@user_seq_no", req.user_seq_no) .Replace("@include_cancel_yn", req.include_cancel_yn) .Replace("@sort_order", req.sort_order), accessToken); if (string.IsNullOrEmpty(acclistResult)) { _accountList.rsp_code = "0101"; _accountList.rsp_message = "FAILED TO KFTC OPEN-FLATFORM (ACCOUNT/LIST) QUERY!"; _repo.LogResponseKFTC(_logResp.Id, null, _accountList.rsp_code, _accountList.rsp_message); return _accountList; } _accountList = JsonConvert.DeserializeObject(acclistResult); Log.Debug("[KFTC-API-RES] account/list : " + acclistResult); _repo.LogResponseKFTC(_logResp.Id, acclistResult, _accountList.rsp_code, _accountList.rsp_message); } catch (Exception ex) { _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message); _accountList.rsp_code = "0101"; _accountList.rsp_message = ex.Message; Log.Debug("[KFTC-API-EXCEPTION] account/list :" + ex.Message); } return _accountList; } #endregion AUTO DEBIT ACCOUNT REGISTRATION /* --------------------------------------------------------------------- * 계좌해지 API * --------------------------------------------------------------------- */ public JsonRxResponse CancelAccount(string cancelType, DeleteRequest req, string customerId) { DbResult _dbRes = new DbResult(); DbResult _logResp = new DbResult(); JsonRxResponse res = new JsonRxResponse(); KFTCPostGet kftcRequest = new KFTCPostGet(); var kftcLogId = Crypto.Decrypt(req.KftcLogId, Utilities.ReadWebConfig("ktft_client_info_salt", "")); try { var request = _repo.GetAccountKFTCInfo(customerId, kftcLogId); /* 2019.10.10 KFTC 계좌 서비스승인 정보조회 Dana*/ var fintechUseNo = request["FintechUseNo"].ToString(); var accessToken = request["AccessToken"].ToString(); string inquiryAgreeYn = request["inquiryAgreeYn"].ToString(); string transferAgreeYn = request["transferAgreeYn"].ToString(); string _cancelURL = @"v2.0/account/cancel"; if (null == request) { res.ErrorCode = "1"; res.Msg = "Error:Invalid auto debit account"; return res; } if (cancelType == "inquiry" && inquiryAgreeYn != "Y") { res.SetResponse("0", "This account has already been deleted.", null); } if (cancelType == "transfer" && transferAgreeYn != "Y") { res.SetResponse("0", "This account has already been deleted.", null); } Request.account_cancel reqObj = new Request.account_cancel(); reqObj.scope = cancelType; reqObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호 reqObj.fintech_use_num = fintechUseNo; string reqData = JsonConvert.SerializeObject(reqObj); _logResp = _repo.LogRequestKFTC(customerId, "AccountCancel", reqData); Log.Debug("[KFTC-API-REQ] account/cancel : [customerId]:" + customerId + " [REQ Data]:" + reqData); /*계좌해지요청* */ var resp = kftcRequest.PostToKFTC(_cancelURL, accessToken, reqData); /** 사용자 계좌해지요청 실패!!! * */ if (string.IsNullOrEmpty(resp)) { res.ErrorCode = "999"; res.Msg = "FAILED TO KFTC OPEN-FLATFORM (ACCOUNT/CANCEL)!"; _repo.LogResponseKFTC(_logResp.Id, null, res.ErrorCode, res.Msg); return res; } var respObj = JsonConvert.DeserializeObject(resp); _repo.LogResponseKFTC(_logResp.Id, resp, respObj.rsp_code, respObj.rsp_message); string processId = _logResp.Extra; Log.Debug("[KFTC-API-RES] account/cancel : " + resp); if (respObj.rsp_code == "A0000") { res.ErrorCode = "0"; res.Msg = "Account deleted successfully!"; res.Data = new { }; } else { res.ErrorCode = "1"; res.Msg = respObj.rsp_message; res.Data = new { }; } return res; } catch (Exception ex) { res.ErrorCode = "1"; res.Msg = "Error:Invalid auto debit account"; return res; } } public JsonRxResponse GetOPTNumber(string customerId, string user, string amount, string kftcId) { JsonRxResponse res = new JsonRxResponse(); DbResult dbResult = new DbResult(); try { kftcId = Crypto.Decrypt(kftcId, Utilities.ReadWebConfig("ktft_client_info_salt", "")); dbResult = _repo.GetOPTNumber(customerId, user, amount, kftcId); res.SetResponse(dbResult.ResponseCode, dbResult.Msg, ""); return res; } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); res.SetResponse("1", "Exception tracked : " + ex.Message, null); return res; } } public DbResult SendAutoDebit(string CustomerId, string KftcCustRegdId, string CollAmt, string schemaId, string serviceCharge) { DbResult _dbRes = new DbResult(); KftcSendMoneyRequest request = _repo.GetCustomerKFTCInfo(CustomerId, KftcCustRegdId); if (null == request) { _dbRes.SetError("1", "Error:Invalid auto debit account", null); return _dbRes; } request.CollAmt = CollAmt.Split('.')[0]; DbResult _logResp = new DbResult(); /* * empty check * */ if (string.IsNullOrWhiteSpace(request.CustomerId) || string.IsNullOrWhiteSpace(request.AccessToken) || string.IsNullOrWhiteSpace(request.FintechUseNo) || string.IsNullOrWhiteSpace(CollAmt) || string.IsNullOrWhiteSpace(request.AccountName) || string.IsNullOrWhiteSpace(request.BankCode) || string.IsNullOrWhiteSpace(request.AccountNum) || string.IsNullOrWhiteSpace(request.AccHolderInfoType) || string.IsNullOrWhiteSpace(request.AccHolderInfo)) { _dbRes.ResponseCode = "999"; _dbRes.Msg = "Oops! Something went wrong please re-login and try again."; return _dbRes; } request.processId = DateTime.Now.Ticks + request.CustomerId; /* * 참가은행 상태조회 * @Max:2018.09 * */ //_dbRes = CheckBankStatus(request); //if (_dbRes.ResponseCode != "A0000") //{ // return _dbRes; //} /* * 예금주 실명번호 조회 * @Max:2018.09. * */ //if (String.IsNullOrEmpty(request.AccHolderInfoType) == true) //{ // _dbRes.ResponseCode = "999"; // _dbRes.Msg = "[FAIL] Customer's real name number type is null "; // return _dbRes; //} //if (String.IsNullOrEmpty(request.AccHolderInfo) == true) //{ // _dbRes.ResponseCode = "999"; // _dbRes.Msg = "[FAIL] Customer's real name number is null "; // return _dbRes; //} //if (String.IsNullOrEmpty(request.AccountNum) == true) //{ // _dbRes.ResponseCode = "999"; // _dbRes.Msg = "[FAIL] Customer's real number is null "; // return _dbRes; //} //var accountHolderInfoType = request.AccHolderInfoType; //var accountHolderInfo = request.AccHolderInfo.Replace("-", "").Trim(); //request.AccHolderInfo = accountHolderInfo; /* * 실명계좌조회 : Ver 1 */ //_dbRes = CheckRealName(request); ///* 계좌실명조회가 실패하면... */ //if (_dbRes.ResponseCode != "A0000") //{ // return _dbRes; //} /* * 실명계좌조회 : Ver 2 */ CheckRealNameModel model = new CheckRealNameModel() { CustomerId = CustomerId, BankCode = request.BankCode, AccountNumber = request.AccountNum }; var jsonRx = KFTC_RealNameCheck_V2(model); if (jsonRx.ErrorCode != "0") { _dbRes.SetError("1", jsonRx.Msg, null); return _dbRes; } /* * 출금이체 서비스 * * */ // 쿠폰 아이디가 있으면 쿠폰 할인 금액을 구한다. string discountvalue = "0"; if (!string.IsNullOrWhiteSpace(schemaId)) { Log.Debug("coupon started" + schemaId.ToString() + " charge" + serviceCharge.ToString()); discountvalue = icouponrepo.GetCouponDiscountValue(schemaId, serviceCharge); } var req = new Common.KFTC.Request.withdraw(); req.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호 req.cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", ""); req.cntr_account_num = ApplicationConfig.ReadWebConfig("GME_WITHDRAW_ACCNO", ""); req.dps_print_content = request.AccountName; //입금계좌내역 req.fintech_use_num = request.FintechUseNo; //산업은행-1234567890 req.tran_amt = (Convert.ToDouble(request.CollAmt) - Convert.ToDouble(discountvalue)).ToString(); //거래금액 req.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); //요청일시 req.req_client_name = request.AccountName; req.req_client_bank_code = request.BankCode; req.req_client_account_num = request.AccountNum; req.req_client_num = request.CustomerId; req.transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", ""); string tranDtime = req.tran_dtime; //string tranDtime_1 = DateTime.Now.AddSeconds(-1).ToString("yyyyMMddHHmmss"); string _URL = ApplicationConfig.ReadWebConfig("TRANSFER_WITHDRAW", ""); //@"transfer/withdraw"; var access_token = request.AccessToken; string postData = JsonConvert.SerializeObject(req); //log request _logResp = _repo.LogRequestKFTC(request.CustomerId, "DebitAccount", "access_token :" + access_token + "req :" + postData); Log.Debug("[KFTC-API-REQ] transfer/Withdraw : [customerId]:" + request.CustomerId + " [REQ URL]:" + _URL + " [REQ DATA]:" + postData); KFTCPostGet kftcRequest = new KFTCPostGet(); try { /* * 출금이체 요청 * */ var resp = kftcRequest.PostToKFTC(_URL, access_token, postData); /* * 출금이체 요청 실패!!! * */ if (string.IsNullOrEmpty(resp)) { _dbRes.ResponseCode = "999"; _dbRes.Msg = "FAILED TO KFTC OPEN-FLATFORM (TRANSFER/WITHDRAW)!"; //log response _repo.LogResponseKFTC(_logResp.Id, resp, _dbRes.ResponseCode, _dbRes.Msg); return _dbRes; } var respObj = JsonConvert.DeserializeObject(resp); Log.Debug("[KFTC-API-RES] transfer/Withdraw : " + resp); //log response _repo.LogResponseKFTC(_logResp.Id, resp, respObj.rsp_code, (respObj.rsp_code == "A0000") ? "Success!" : respObj.rsp_message); if (respObj.rsp_code == "A0001" || respObj.rsp_code == "A0003" || respObj.rsp_code == "A0007" || respObj.bank_rsp_code == "400") { Thread.Sleep(1 * 60 * 1000); /* 이체결과확인 * */ respObj = CheckWithdrawResult(ref respObj, request.CustomerId, "1"); if (respObj.rsp_code == "A0001" || respObj.rsp_code == "A0003" || respObj.rsp_code == "A0007" || respObj.bank_rsp_code == "400") { Thread.Sleep(2 * 60 * 1000); /* 이체결과확인 * */ respObj = CheckWithdrawResult(ref respObj, request.CustomerId, "2"); if (respObj.rsp_code == "A0001" || respObj.rsp_code == "A0003" || respObj.rsp_code == "A0007" || respObj.bank_rsp_code == "400") { _dbRes.ResponseCode = respObj.rsp_code; _dbRes.Msg = respObj.rsp_message; _dbRes.Id = respObj.api_tran_id; _dbRes.Extra = respObj.api_tran_dtm; return _dbRes; } } } DbResult _saveKFTCData = new DbResult(); if (respObj.rsp_code == "A0000") { /* * COPIED FROM ONLINE * * @PRALHAD-2019.01.08 * */ //string fromTime = respObj.api_tran_dtm.Substring(0, 14); //max-20180615 //_dbRes = CheckRemittant(fromTime, customerId, accountNum, accountName, processId); //respObj.remittance_check = (_dbRes.ErrorCode == "A0000") ? "Y" : "N"; respObj.remittance_check = "Y"; _saveKFTCData = _repo.SaveKFTCTranData(respObj, request.CustomerId); //if (_dbRes.ErrorCode != "A0000") //{ // return _dbRes; //} } _dbRes.ResponseCode = respObj.rsp_code; _dbRes.Msg = respObj.rsp_message; _dbRes.Id = _saveKFTCData.Id; // USED FOR AUTO DEBIT REFURN _dbRes.Extra = request.AccountNum; _dbRes.Extra2 = request.BankCode; return _dbRes; } catch (Exception ex) { //log response _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message); _dbRes.SetError("999", ex.Message, null); return _dbRes; } } // check GME bank status and customer bank Status private DbResult CheckBankStatus(KftcSendMoneyRequest request) { DbResult dbRes = new DbResult(); DbResult logRes = new DbResult(); KFTCPostGet kftcRequest = new KFTCPostGet(); //string _URL = @"bank/status"; //string httpUrl = ApplicationConfig.ReadWebConfig("BANK_STATUS", ""); //using Open banking 2019.10 @Dana disable //using Open banking 2019.10 @Dana string httpUrl = @"v2.0/bank/status"; string access_token = request.GmeAccessToken; string gmeBankCode = request.GmeBankCode; string processId = request.processId; //log request logRes = _repo.LogRequestKFTC(request.CustomerId, "CheckBankStatus", "_URL :" + httpUrl + " access_token :" + access_token, processId); try { /* * 참가은행 상태조회!!! * */ var resBankStatusStr = kftcRequest.GetFromKFTC(httpUrl, access_token); /* * 참가은행 상태조회 실패!!! * */ if (string.IsNullOrEmpty(resBankStatusStr)) { dbRes.ResponseCode = "999"; dbRes.Msg = "[FAIL] KFTC OPEN-FLATFORM (BANK/STATUS)!"; //log response _repo.LogResponseKFTC(logRes.Id, null, dbRes.ResponseCode, dbRes.Msg); return dbRes; } var resBankStatusObj = JsonConvert.DeserializeObject(resBankStatusStr); //log response //_utility.LogResponseKFTC(_logResp.Id, resp, bankList.rsp_code, bankList.rsp_message); //정상응답이 아닌경우... if (resBankStatusObj.rsp_code != "A0000") { dbRes.SetError("999", resBankStatusObj.rsp_message, null); //log response _repo.LogResponseKFTC(logRes.Id, null, resBankStatusObj.rsp_code, dbRes.Msg); return dbRes; } List bankUnit = resBankStatusObj.res_list; //dbRes.Extra = logRes.Extra; //dbRes.Id = ""; //고객은행과 GME은행이 정상이면 "YY" string bankStatus = "N"; foreach (var item in bankUnit) { //customer bank if (item.bank_code_std == request.BankCode) { bankStatus = item.bank_status; } } if (bankStatus != "Y") { dbRes.ResponseCode = "999"; dbRes.Msg = String.Format("[FAIL] This bank{0} service is not available right now, please try again later !!", request.BankCode); //log response _repo.LogResponseKFTC(logRes.Id, null, dbRes.ResponseCode, dbRes.Msg); return dbRes; } bankStatus = "N"; foreach (var item in bankUnit) { //GME bank if (item.bank_code_std == gmeBankCode) { bankStatus = item.bank_status; } } if (bankStatus != "Y") { dbRes.ResponseCode = "999"; dbRes.Msg = String.Format("[FAIL] This bank {0} service is not available right now, please try again later !!", gmeBankCode); //log response _repo.LogResponseKFTC(logRes.Id, null, dbRes.ResponseCode, dbRes.Msg); return dbRes; } //성공 dbRes.SetError("A0000", "", null); return dbRes; } catch (Exception ex) { dbRes.SetError("999", ex.Message, null); //log response _repo.LogResponseKFTC(logRes.Id, "Exception occured", "999", ex.Message); return dbRes; } } // CUSTOMER ACCOUNT DETAIL VERIFICATION public DbResult CheckRealName(KftcSendMoneyRequest request) { DbResult _dbRes = new DbResult(); DbResult _logResp = new DbResult(); KFTCPostGet kftcRequest = new KFTCPostGet(); string httpUrl = ApplicationConfig.ReadWebConfig("INQUIRY_REALNAME", ""); //@"inquiry/real_name"; string oob_access_token = request.GmeAccessToken; string processId = request.processId; //주민등록번호 Resident registration number if (request.AccHolderInfoType == "8008") { request.AccHolderInfoType = "1"; } //외국인등록번호 Foreigner registration number else if (request.AccHolderInfoType == "1302") { request.AccHolderInfoType = "2"; } //여권번호이면 조합주민번호로 조회 Passport with Combination no else if (request.AccHolderInfoType == "10997") { request.AccHolderInfoType = "5"; } //사업자등록번호 Company Registration Number else if (request.AccHolderInfoType == "10988") { request.AccHolderInfoType = "6"; } var reqRealNameObj = new Common.KFTC.Request.real_name(); reqRealNameObj.bank_code_std = request.BankCode; reqRealNameObj.account_num = request.AccountNum; reqRealNameObj.account_holder_info_type = request.AccHolderInfoType; reqRealNameObj.account_holder_info = request.AccHolderInfo; reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); try { string reqRealNameStr = JsonConvert.SerializeObject(reqRealNameObj); //로그-요청로그 _logResp = _repo.LogRequestKFTC(request.CustomerId, httpUrl, reqRealNameStr, processId); var resRealNameStr = kftcRequest.PostToKFTC(httpUrl, oob_access_token, reqRealNameStr); /* * 계좌실명조회 실패!!! * */ if (string.IsNullOrEmpty(resRealNameStr)) { _dbRes.ResponseCode = "999"; _dbRes.Msg = "[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name)"; //로그-결과로그(실패) _repo.LogResponseKFTC(_logResp.Id, null, _dbRes.ResponseCode, _dbRes.Msg); return _dbRes; } var resRealNameObj = JsonConvert.DeserializeObject(resRealNameStr); //응답메시지가 성공일때... if (resRealNameObj.rsp_code == "A0000" && resRealNameObj.bank_rsp_code == "000") { _dbRes.ResponseCode = "A0000"; _dbRes.Msg = "[SUCCESS] KFTC OPEN-FLATFORM INQUIRY"; } //응답메시지가 성공이 아닐때.. else if (resRealNameObj.rsp_code != "A0000") { _dbRes.ResponseCode = resRealNameObj.rsp_code; _dbRes.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM INQUIRY rsp_message:{0}", resRealNameObj.rsp_message); //_dbRes.Msg = String.Format("[FAIL] inquiry/real_name : rsp_message={0}, req_type={1}, req_num={2}, res_type={3}, res_num={4}", // resRealNameObj.rsp_message, // accountHolderInfoType, // accountHolderInfo, // resRealNameObj.account_holder_info_type, // resRealNameObj.account_holder_info); } else if (resRealNameObj.bank_rsp_code != "000") { _dbRes.ResponseCode = resRealNameObj.bank_rsp_code; _dbRes.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM INQUIRY bank_rsp_message:{0}", resRealNameObj.bank_rsp_message); //_dbRes.Msg = String.Format("[FAIL] inquiry/real_name : rsp_message={0}, req_type={1}, req_num={2}, res_type={3}, res_num={4}", // resRealNameObj.bank_rsp_message, // accountHolderInfoType, // accountHolderInfo, // resRealNameObj.account_holder_info_type, // resRealNameObj.account_holder_info); } else { _dbRes.ResponseCode = resRealNameObj.rsp_code; _dbRes.Msg = "[FAIL] KFTC OPEN-FLATFORM INQUIRY"; } // 로그-응답로그 _repo.LogResponseKFTC(_logResp.Id, resRealNameStr, _dbRes.ResponseCode, _dbRes.Msg); _dbRes.SetError(_dbRes.ResponseCode, _dbRes.Msg, null); return _dbRes; } catch (Exception ex) { //로그-응답로그 _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message); _dbRes.SetError("999", ex.Message, null); return _dbRes; } } /* * KFTC 이체결과조회 * */ private Response.withdraw CheckWithdrawResult(ref Response.withdraw withdrawObj, string customerId, string tryCount) { string url = @"v2.0/transfer/result"; var reqObj = new Request.result(); reqObj.check_type = "1"; //1:출금이체, 2:입금이체 reqObj.req_cnt = "1"; //요청건수 reqObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); ; //요청일시 reqObj.req_list = new List(); var reqUnitObj = new Request.result_unit(); reqUnitObj.tran_no = "1"; // 거래순번 reqUnitObj.org_bank_tran_id = withdrawObj.bank_tran_id; ; // "12345678901234567890"; //원거래 고유번호 reqUnitObj.org_bank_tran_date = withdrawObj.bank_tran_date; // "20180101"; //원거래 일자 reqUnitObj.org_tran_amt = withdrawObj.tran_amt; // "1000"; //원거래금액 reqObj.req_list.Add(reqUnitObj); string reqData = JsonConvert.SerializeObject(reqObj); //log request DbResult _logResp = _repo.LogRequestKFTC(customerId, "DebitAccount:Retry:" + tryCount, JsonConvert.SerializeObject(reqObj)); Log.Debug("[KFTC-API-REQ] transfer/result : [customerId]:" + customerId + " [REQ DATA]:" + JsonConvert.SerializeObject(reqObj)); Response.withdraw resObj = new Response.withdraw(); var gme = _repo.GetGMEMaster(); if (gme == null) { resObj.rsp_code = "999"; resObj.rsp_message = "[transfer/result] Failed to bring GME token"; _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message); return resObj; } var gmeAccessToken = gme["accessToken"].ToString(); KFTCPostGet kftcRequest = new KFTCPostGet(); var resData = kftcRequest.PostToKFTC(url, gmeAccessToken, reqData); if (string.IsNullOrEmpty(resData)) { resObj.rsp_code = "999"; resObj.rsp_message = "[transfer/result] Failed to Open-banking transfer/result"; _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message); return resObj; } resObj = JsonConvert.DeserializeObject(resData); //log response _repo.LogResponseKFTC(_logResp.Id, resData, resObj.rsp_code, resObj.rsp_message); Log.Debug("[KFTC-API-RES] transfer/result : " + resData); return resObj; } /* ------------------------------------ * 광주은행 입금이체 * ------------------------------------ * */ // refund of auto debit failed transaction public DbResult RefundAutoDebit(AutoDebitRefund refundInfo, AccountTransferToBank withdrawalInfo) { //UPDATE FAIL LOG FOR AUTO DEBIT TRANSACTION var resp1 = _repo.LogFailTransactionForAutoDebit(refundInfo.rowId, refundInfo.ErrorCode, refundInfo.ErrorMsg, withdrawalInfo.amount); if (resp1.ResponseCode == "1") { return resp1; } DbResult dbResult = new DbResult() { ResponseCode = "1", Msg = "Failed!" }; try { KJAutoRefundModel kj = new KJAutoRefundModel() { flag = "Autodebit_REQ", customerId = refundInfo.CustomerId, customerSummary = "", amount = withdrawalInfo.amount, action = "REQ", actionDate = "", actionBy = refundInfo.CustomerId, bankCode = withdrawalInfo.receiveInstitution, bankAccountNo = withdrawalInfo.receiveAccountNo, }; dbResult = _repo.SendAutoRefund(kj); kj.rowId = dbResult.Id; /* KJ 입금이체 실행 * */ var body = JsonConvert.SerializeObject(withdrawalInfo); var resp = KwangjuBankApi.TransferAmount(body); var dbApiRes = JsonConvert.DeserializeObject(resp); if (dbApiRes.ErrorCode != "0") { kj.flag = "Autodebit_FAIL"; kj.action = "FAIL"; } else { kj.flag = "SUCCESS"; kj.action = "SUCCESS"; } dbResult = _repo.SendAutoRefund(kj); } catch (Exception e) { dbResult.ResponseCode = "1"; dbResult.Msg = e.Message; } return dbResult; } /* * ------------------------------------ * 입금이체 결과조회 API * ------------------------------------ * */ // Response.deposit으로 return하기 위한 함수 private Response.deposit CheckDepositResult(ref Response.deposit depositObj, string customerId, string tryCount) { string url = @"v2.0/transfer/result"; var reqObj = new Request.result(); reqObj.check_type = "2"; //1:출금이체, 2:입금이체 reqObj.req_cnt = "1"; //요청건수 reqObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); ; //요청일시 reqObj.req_list = new List(); var reqUnitObj = new Request.result_unit(); reqUnitObj.tran_no = depositObj.res_list[0].tran_no; reqUnitObj.org_bank_tran_id = depositObj.res_list[0].bank_tran_id; reqUnitObj.org_bank_tran_date = depositObj.res_list[0].bank_tran_date; //거래일자 reqUnitObj.org_tran_amt = depositObj.res_list[0].tran_amt; //거래금액 reqObj.req_list.Add(reqUnitObj); string reqData = JsonConvert.SerializeObject(reqObj); //log request DbResult _logResp = _repo.LogRequestKFTC(customerId, "DebitAccount:Retry:" + tryCount, JsonConvert.SerializeObject(reqObj)); Log.Debug("[KFTC-API-REQ] transfer/result : [customerId]:" + customerId + " [REQ DATA]:" + JsonConvert.SerializeObject(reqObj)); Response.deposit resObj = new Response.deposit(); var gme = _repo.GetGMEMaster(); if (gme == null) { resObj.rsp_code = "999"; resObj.rsp_message = "[transfer/result] Failed to bring GME token"; _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message); return resObj; } var gmeAccessToken = gme["accessToken"].ToString(); KFTCPostGet kftcRequest = new KFTCPostGet(); var resData = kftcRequest.PostToKFTC(url, gmeAccessToken, reqData); if (string.IsNullOrEmpty(resData)) { resObj.rsp_code = "999"; resObj.rsp_message = "[transfer/result] Failed to Open-banking transfer/result"; _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message); return resObj; } resObj = JsonConvert.DeserializeObject(resData); //log response _repo.LogResponseKFTC(_logResp.Id, resData, resObj.rsp_code, resObj.rsp_message); Log.Debug("[KFTC-API-RES] transfer/result : " + resData); return resObj; } public JsonRxResponse GetKFTCBankList() { JsonRxResponse jsonRx = new JsonRxResponse(); List listBank = new List(); try { Log.DebugFormat("GetKFTCBankList | Calling GetKFTCBankList"); var dt = _repo.GetKftcBankList(); if (dt == null || dt.Rows.Count <= 0) { Log.Debug("GetKFTCBankList | Returning null while calling the GetKFTCBankList."); jsonRx.SetResponse("1", "Could not fetch the exrate data."); return jsonRx; } foreach (DataRow row in dt.Rows) { BankInformation bank = new BankInformation(); bank.RowId = row["rowId"].ToString(); bank.BankCode = row["bankCode"].ToString(); bank.BankName = row["bankName"].ToString(); listBank.Add(bank); } jsonRx.SetResponse("0", "Success"); jsonRx.Data = listBank; Log.Debug("GetKFTCBankList | Calling GetKFTCBankList Success..."); return jsonRx; } catch (Exception ex) { Log.Error("Something Went Wrong, Please Try Again!!", ex); jsonRx.SetResponse("1", "Could not fetch the GetKFTCBankList details."); return jsonRx; } } public JsonRxResponse KFTC_RealNameCheck_V2(CheckRealNameModel model) { JsonRxResponse jsonRx = new JsonRxResponse(); DbResult _dbRes = new DbResult(); DbResult _logResp = new DbResult(); KFTCPostGet kftcRequest = new KFTCPostGet(); bool isSuccess = false; string saveIdNumber = ""; var reqRealNameObj = new Common.KFTC.Request.real_name(); // KFTC Open Banking 2019.10 @Dana // Disable string httpUrl = // ApplicationConfig.ReadWebConfig("INQUIRY_REALNAME", ""); //@"inquiry/real_name"; var gme = _repo.GetGMEMaster(); if (gme == null) { jsonRx.SetResponse("1", "Failed to bring GME token.", null); return jsonRx; } var gmeAccessToken = gme["accessToken"].ToString(); var customer = _repo.GetCustomerMaster(model.CustomerId); if (customer == null) { jsonRx.SetResponse("1", "Failed to bring customer information.", null); return jsonRx; } var kcm = _repo.GetRealNameCheck(model.CustomerId); if (kcm != null) { // 은행거래 고유번호 //reqRealNameObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); reqRealNameObj.bank_tran_id = getBankTranId(); reqRealNameObj.account_holder_info_type = kcm["accHolderInfoType"].ToString(); reqRealNameObj.account_holder_info = kcm["accHolderInfo"].ToString().Replace("-", ""); reqRealNameObj.bank_code_std = model.BankCode; reqRealNameObj.account_num = model.AccountNumber; reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); isSuccess = KFTC_RealNameCheck_Common(reqRealNameObj, gmeAccessToken, model.CustomerId); } if (isSuccess == false) { var idType = customer["idType"].ToString(); var idNumber = customer["idNumber"].ToString().Replace("-", ""); var dob = customer["dob"].ToString(); var gender = customer["gender"].ToString(); var country = customer["country"].ToString(); var processId = DateTime.Now.Ticks + model.CustomerId; int pos = 0; for (int j = idNumber.Length - 1; j > 0; j--) { char ch = idNumber[j]; if (ch >= 0x30 && ch <= 0x39) { pos = j; break; } } var combNumber = idNumber.Substring(pos - 4, 5); string[] idTypes = { "1", "2", "3", "4", "5", "6", "E", "1", "2", "3", "4", "5", "6", "E" }; for (int i = 0; i < 14; i++) { // 은행거래 고유번호 //reqRealNameObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); reqRealNameObj.bank_tran_id = getBankTranId(); reqRealNameObj.bank_code_std = model.BankCode; reqRealNameObj.account_num = model.AccountNumber; reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); reqRealNameObj.account_holder_info_type = idTypes[i]; if (i < 7) { reqRealNameObj.account_holder_info = idNumber; } else { reqRealNameObj.account_holder_info = String.Format("{0}{1}{2}{3}", dob, gender, country, combNumber); } saveIdNumber = reqRealNameObj.account_holder_info.Insert(6, "-"); isSuccess = KFTC_RealNameCheck_Common(reqRealNameObj, gmeAccessToken, model.CustomerId); if (isSuccess == true) { _repo.SetRealNameData(model.CustomerId, reqRealNameObj.account_holder_info_type, saveIdNumber); break; } } // endof for (int i = 0; i < 14; i++) } if (isSuccess == true) { jsonRx.SetResponse("0", "Code:A0000, Msg:Success to check the real name of the account.", null); } else { jsonRx.SetResponse("1", "Failed to check the real name of the account.", null); } return jsonRx; } public bool KFTC_RealNameCheck_Common(Common.KFTC.Request.real_name requestObj, string gmeAccessToken, string customerId) { KFTCPostGet kftcRequest = new KFTCPostGet(); DbResult dbResult = new DbResult(); DbResult logResult = new DbResult(); var httpUrl = ApplicationConfig.ReadWebConfig("INQUIRY_REALNAME", ""); //@"inquiry/real_name"; var processId = DateTime.Now.Ticks + customerId; bool bRet = false; try { string requestStr = JsonConvert.SerializeObject(requestObj); //로그-요청로그(TBL_KFTC_LOG) logResult = _repo.LogRequestKFTC(customerId, httpUrl, requestStr, processId); Log.Debug("[KFTC-API-REQ] inquiry/real_name : [customerId]:" + customerId + " [REQ DATA]:" + requestStr); var responseStr = kftcRequest.PostToKFTC(httpUrl, gmeAccessToken, requestStr); /* * 계좌실명조회 실패!!! * */ if (string.IsNullOrEmpty(responseStr)) { dbResult.ResponseCode = "999"; dbResult.Msg = "[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name) RESPONSE IS NULL"; //로그-결과로그(실 패) _repo.LogResponseKFTC(logResult.Id, null, dbResult.ResponseCode, dbResult.Msg); return false; } var responseObj = JsonConvert.DeserializeObject(responseStr); Log.Debug("[KFTC-API-RES] inquiry/real_name : " + responseStr); //응답메시지가 성공일때... if (responseObj.rsp_code == "A0000" && responseObj.bank_rsp_code == "000") { bRet = true; dbResult.ResponseCode = "A0000"; dbResult.Msg = "[SUCCESS] KFTC OPEN-FLATFORM (inquiry/real_name)"; _repo.LogResponseKFTC(logResult.Id, responseStr, dbResult.ResponseCode, dbResult.Msg); } else { if (responseObj.rsp_code != "A0000") { dbResult.ResponseCode = responseObj.rsp_code; dbResult.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name) rsp_message:{0}", responseObj.rsp_message); } else if (responseObj.bank_rsp_code != "000") { dbResult.ResponseCode = responseObj.bank_rsp_code; dbResult.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name) bank_rsp_message:{0}", responseObj.bank_rsp_message); } else { dbResult.ResponseCode = responseObj.rsp_code; dbResult.Msg = "[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name)"; } // 로그-응답로그 _repo.LogResponseKFTC(logResult.Id, responseStr, dbResult.ResponseCode, dbResult.Msg); } } catch (Exception ex) { //로그-응답로그 _repo.LogResponseKFTC(logResult.Id, "Exception Error", "999", ex.Message); return false; } return bRet; } /* * Manual token refresh * */ public JsonRxResponse CheckKFTCAccounts(string customerId, string lang, string client_id) { JsonRxResponse res = new JsonRxResponse(); try { string URL = GetUrl_AuthorizeAccounts(customerId, lang, client_id); List AccountList = GetAccountList(customerId); AccountList.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", ""))); List
ListLangauge = GetKftcLanguage(customerId); List
ListHeader = GetKftcHeader(customerId); KftcCommonResponse Response = new KftcCommonResponse() { AccountList = AccountList, Header = ListHeader, URL = URL, Language = ListLangauge }; res.ErrorCode = "0"; res.Msg = "Success"; res.Data = Response; return res; } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); res.SetResponse("1", "Exception tracked : " + ex.Message, null); res.Data = new { }; return res; } } /* Open Banking 2019.10 Dana */ private string GetUrl_AuthorizeAccounts(string customerId, string lang, string client_id) { var custId = "mobile_" + customerId; Guid g = Guid.NewGuid(); string stateValue = g.ToString().Replace("-", ""); var auth = new Common.KFTC.Request.authorize_account(); auth.response_type = "code"; auth.client_id = client_id; auth.redirect_uri = KFTC_GME.callback_url; auth.scope = "login inquiry transfer"; auth.client_info = custId; auth.state = stateValue; //using Open banking 2019.10 @Dana auth.auth_type = "1"; auth.bg_color = "#F4F8FB"; auth.txt_color = "#000000"; auth.btn1_color = "#EF343B"; auth.btn2_color = "#22246B"; //auth.lang = lang; auth.edit_option = "off"; auth.invoke_type = "ajax"; string _URL = @"oauth/2.0/authorize_account?@query"; //using Open banking 2019.10 @Dana var jObj = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(auth)); var query = String.Join("&", jObj.Children().Cast().Select(jp => jp.Name.Equals("redirect_uri") ? jp.Name + "=" + (jp.Value.ToString()) : jp.Name + "=" + HttpUtility.UrlEncode(jp.Value.ToString()))); return ApplicationConfig.ReadWebConfig("KFTC_HOST_NAME", "") + _URL.Replace("@query", query); } /* 2019.09 Dana */ public JsonRxResponse CheckBalance(CheckBalanceModel model) // CustomerId Type FintechUseNo { JsonRxResponse res = new JsonRxResponse(); DbResult _logResp = new DbResult(); if (model.Type == "wallet") // wallet일때 { DbResult _resp = new DbResult(); _resp = _repo.GetUserEmail(model.CustomerId); if (_resp.Id == null) { res.ErrorCode = "1"; res.Msg = "FAILED TO Load UserId"; return res; } var bal = _sendrepo.GetCurrentBalance(_resp.Id); if (bal != null) { Response.balance walletBalance = new Response.balance(); walletBalance.balance_amt = bal; res.ErrorCode = "0"; res.Msg = "Success"; res.Data = walletBalance; return res; } else { res.ErrorCode = "1"; res.Msg = "FAILED TO Load Wallet Balance"; return res; } } else //은행계좌라면 API호출해서 잔액조회 { var customerDetail = _repo.GetAccountList(model.CustomerId); var accessToken = customerDetail.Rows[0]["access_token"].ToString(); //accessToken = "b37d092c-6912-42d8-9876-d13eb23e55ad"; string url = @"v2.0/account/balance/fin_num?bank_tran_id=@bankId&fintech_use_num=@finnum&tran_dtime=@time"; string bankId = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호 string requestTime = DateTime.Now.ToString("yyyyMMddHHmmss"); try { KFTCPostGet kftcRequest = new KFTCPostGet(); url = url.Replace("@bankId", bankId).Replace("@finnum", model.FintechUseNo).Replace("@time", requestTime); var balanceResult = kftcRequest.GetFromKFTC(url, accessToken); _logResp = _repo.LogRequestKFTC(model.CustomerId, "account/balance", "URL: " + url + "access_token: " + accessToken, ""); Log.Debug("[KFTC-API-REQ] account/balance : [customerId]:" + model.CustomerId + " [REQ URL]:" + url); /* 잔액조회 실패 Check Balance fail */ if (string.IsNullOrEmpty(balanceResult)) { res.ErrorCode = "1"; res.Msg = "FAILED TO KFTC OPEN-FLATFORM (Account/Balance) QUERY!"; _repo.LogResponseKFTC(_logResp.Id, null, res.ErrorCode, res.Msg); return res; } var respObj = JsonConvert.DeserializeObject(balanceResult); Log.Debug("[KFTC-API-RES] account/balance : " + balanceResult); if (respObj.rsp_code == "A0000") { res.ErrorCode = "0"; res.Msg = "Success"; res.Data = JsonConvert.DeserializeObject(balanceResult); _repo.LogResponseKFTC(_logResp.Id, balanceResult, respObj.rsp_code, respObj.rsp_message); return res; } else { res.ErrorCode = "1"; res.Msg = respObj.rsp_message; _repo.LogResponseKFTC(_logResp.Id, balanceResult, respObj.rsp_code, respObj.rsp_message); return res; } } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); res.SetResponse("1", "Exception tracked : " + ex.Message, null); _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message); return res; } } } /* 2019.09 Dana */ public JsonRxResponse DomeRemitStart(string customerId) { JsonRxResponse res = new JsonRxResponse(); DbResult _resp = new DbResult(); _resp = _repo.GetKFTCServiceFee("DomesticRemittance", "KFTC"); //KFTC service fee if (_resp.Id == null) { res.ErrorCode = "1"; res.Msg = "FAILED TO Load Service Fee."; return res; } DbResult _resp2 = new DbResult(); _resp2 = _repo.GetKFTCServiceFee("DomesticRemittance", "KJWallet"); //Wallet service fee if (_resp2.Id == null) { res.ErrorCode = "1"; res.Msg = "FAILED TO Load Service Fee."; return res; } List accountsData = _repo.GetWalletAccountList(customerId); if (accountsData == null) // Account가 없으면 Fail { res.ErrorCode = "1"; res.Msg = "FAILED TO Load Account List."; return res; } accountsData.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", ""))); List bankData = new List(); var dt = _repo.GetKftcBankList(); if (dt == null || dt.Rows.Count <= 0) //BankList가 없으면 Fail { res.ErrorCode = "1"; res.Msg = "FAILED TO KFTC Bank List."; return res; } foreach (DataRow row in dt.Rows) { BankInformation bank = new BankInformation(); bank.RowId = row["rowId"].ToString(); bank.BankCode = row["bankCode"].ToString(); bank.BankName = row["bankName"].ToString(); bankData.Add(bank); } Response.dome_default body = new Response.dome_default() { accounts = accountsData, banks = bankData, servicefee = _resp.Id, servicefee_wallet = _resp2.Id }; res.ErrorCode = "0"; res.Msg = "Success"; res.Data = body; return res; } public JsonRxResponse GetRecentHistories(RecentHistoryModel model) { JsonRxResponse res = new JsonRxResponse(); List historyData = new List(); var dt = _repo.GetRecentHistories(model); if (dt == null || dt.Rows.Count <= 0) //Recent History가 없는 경우 { res.ErrorCode = "0"; res.Msg = "0 Recent Histories txn."; res.Data = historyData; return res; } foreach (DataRow row in dt.Rows) { Response.RecentHistory hisData = new Response.RecentHistory(); BankInformation bankDate = new BankInformation(); bankDate.RowId = row["rowId"].ToString(); bankDate.BankCode = row["bankCode"].ToString(); bankDate.BankName = row["bankName"].ToString(); hisData.bank = bankDate; hisData.recipient_account = row["recipient_account"].ToString(); hisData.recipient_name = row["recipient_name"].ToString(); historyData.Add(hisData); } res.ErrorCode = "0"; res.Msg = "Success"; res.Data = historyData; return res; } /* 2019.09 Dana */ public JsonRxResponse GetRecipientInfo(CheckRealNameModel model) // customerId BankCode AccountNumber { JsonRxResponse res = new JsonRxResponse(); Response.recipientInfo info = new Response.recipientInfo(); DbResult _resp = new DbResult(); var resp = KwangjuBankApi.BankAccountName(model.BankCode, model.AccountNumber); //광주은행 API를 이용하여 계좌주명 추출 if (resp == null) { res.ErrorCode = "1"; res.Msg = "Please Check Recipient Bank Account."; return res; } var dbApiRes = JsonConvert.DeserializeObject(resp); if (dbApiRes.ErrorCode != "0") { res.ErrorCode = "1"; res.Msg = "Please Check Recipient Bank Account."; return res; } else { info.RecipientName = dbApiRes.Msg; _resp = _repo.GetRecipientMobileNo(model); //Recipient MobileNo 추출 info.RecipientPhone = _resp.Id; res.ErrorCode = "0"; res.Msg = "Success"; res.Data = info; return res; } } /* * ------------------------------------ * Domestic Remittance 송금시작 2019.09 Dana * ------------------------------------ * */ public JsonRxResponse SendDomeRimit(DomesticRemitModel model) { JsonRxResponse JsonRx = new JsonRxResponse { ErrorCode = "1", Msg = "Domestic Remittance Request cannot proceed further. Please contact GME head office." }; DbResult _resp = new DbResult(); DbResult _serviceResp = new DbResult(); Response.domesticTran domeTran = new Response.domesticTran(); //model.RecipientName = "(주)글로벌머니익스프레스입니다."; string customerName = ""; string customerBankCode = "034"; string customerAccountNo = ""; if (model.type == "wallet") { _serviceResp = _repo.GetKFTCServiceFee("DomesticRemittance", "KJWallet"); //service fee if (_serviceResp.Id == null) { JsonRx.ErrorCode = "1"; JsonRx.Msg = "FAILED TO Load Service Fee."; return JsonRx; } model.ServiceFee = _serviceResp.Id; var customerDetail = _repo.GetGMECustomerList(model.CustomerId); customerName = customerDetail.Rows[0]["fullName"].ToString(); customerAccountNo = customerDetail.Rows[0]["walletAccountNo"].ToString(); model.SetSenderData(customerName, customerBankCode, customerAccountNo); //var processId = ""; // Domestic request log //DomesticHistoryModel historyModel = new DomesticHistoryModel(); //historyModel.SetWalletHistoryData(model); //_resp = _repo.requestKFTCDomesticHistory(historyModel); //processId = _resp.Id; JsonRxResponse wallet_result = SendDomeRimit_wallet_withdraw(model); if (wallet_result.ErrorCode == "0") { domeTran.CustomerId = model.CustomerId; domeTran.TranNo = wallet_result.Id; //성공메세지 JsonRx.ErrorCode = "0"; JsonRx.Msg = "Success"; JsonRx.Data = domeTran; return JsonRx; } else { JsonRx.ErrorCode = "1"; JsonRx.Msg = wallet_result.Msg; return JsonRx; } } else if (model.type == "autodebit") { _serviceResp = _repo.GetKFTCServiceFee("DomesticRemittance", "KFTC"); //service fee if (_serviceResp.Id == null) { JsonRx.ErrorCode = "1"; JsonRx.Msg = "FAILED TO Load Service Fee."; return JsonRx; } model.ServiceFee = _serviceResp.Id; // service fee var customerDetail = _repo.GetKFTCAccountInfo(model.CustomerId, model.FintechUseNo); if (customerDetail == null) { JsonRx.ErrorCode = "1"; JsonRx.Msg = "FAILED TO Sender's Account Information."; return JsonRx; } customerName = customerDetail["accountName"].ToString(); customerBankCode = customerDetail["bankCodeStd"].ToString(); customerAccountNo = customerDetail["accountNum"].ToString(); model.SetSenderData(customerName, customerBankCode, customerAccountNo); //출금이체 var withdraw_result = SendDomeRimit_withdraw(model); if (withdraw_result.ErrorCode == "0") // 출금 성공 -> 입금시도 withdraw success -> deposit { //입금이체 var deposit_result = SendDomeRimit_deposit(model); if (deposit_result.ErrorCode == "0") { //voucher already splited //국내이체에 전체성공하면 core table에 데이터생성하는 프로시저 실행 //_repo.startPushFromDomestit(model.processId); domeTran.CustomerId = model.CustomerId; domeTran.TranNo = model.processId; //성공메세지 JsonRx.ErrorCode = "0"; JsonRx.Msg = "Success"; JsonRx.Data = domeTran; return JsonRx; } //else //{ // //출금 원복 // //request log // //_resp = _repo.requestKFTCDomesticHistory(model, processId, "refund"); // JsonRx.ErrorCode = "1"; // refund 성공여부와 관계없이 무조건 에러표시(입금이체가 실패했으므로) var // rejec_result = SendDomeRimit_refund(model); if (rejec_result.ErrorCode == // "0") JsonRx.Msg = deposit_result.Msg;//입금에러메세지 else JsonRx.Msg = // rejec_result.Msg; //만약 원복도 실패하면 원복실패 에러메세지를 보여줌 // return JsonRx; //} } else// 출금 실패 withdraw success fail { JsonRx = withdraw_result; return JsonRx; } } return JsonRx; } /* * ------------------------------------------------------------------------ * Domestic Remittance autobebit 출금이체 API호출 2019.09 Dana * ------------------------------------------------------------------------ * */ public JsonRxResponse SendDomeRimit_withdraw(DomesticRemitModel model) { DbResult _logResp = new DbResult(); JsonRxResponse jsonResponse = new JsonRxResponse(); DbResult _resp = new DbResult(); //1.KFTC_DOMESTIC_HISTORY insert (실계좌-withdraw) DomesticHistoryModel withdrawModel = new DomesticHistoryModel(); withdrawModel.SetWithdrawData(model); _resp = _repo.requestKFTCDomesticHistory(withdrawModel); model.processId = _resp.Id; model.transferType = "withdraw"; //2.KFTC 출금이체 API 실행 jsonResponse = KftcTransferWithdraw(model); jsonResponse.Id = model.processId; if (jsonResponse.ErrorCode == "0") { //3.KFTC_DOMESTIC_HISTORY update(실계좌-withdraw) var respObj_withdraw = JsonConvert.DeserializeObject(jsonResponse.Extra); _repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, model); } else { //3.KFTC_DOMESTIC_HISTORY update(실계좌-withdraw) if (string.IsNullOrEmpty(jsonResponse.Extra) == true) { _repo.responseKFTCDomesticHistory_withdraw(null, model); } else { var respObj_withdraw = JsonConvert.DeserializeObject(jsonResponse.Extra); _repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, model); } } return jsonResponse; } public JsonRxResponse KftcTransferWithdraw(DomesticRemitModel model) { JsonRxResponse jsonResponse = new JsonRxResponse(); DbResult logResult = new DbResult(); KFTCPostGet kftcRequest_withdraw = new KFTCPostGet(); //var gme = _repo.GetGMEMaster(); //if (gme == null) //{ // jsonResponse.SetResponse("1", "Failed to bring GME token.", null); // return jsonResponse; //} //var gmeAccessToken = gme["accessToken"].ToString(); var accessTokenTemplate = _repo.GetAccountList(model.CustomerId); var accessToken = accessTokenTemplate.Rows[0]["access_token"].ToString(); var customerDetail = _repo.GetKFTCAccountInfo(model.CustomerId, model.FintechUseNo); if (customerDetail == null) { jsonResponse.SetResponse("1", "Failed to bring customer account number.", null); return jsonResponse; } var amt = (Convert.ToDecimal(model.SentAmount) + Convert.ToDecimal(model.ServiceFee)).ToString(); var withdrawObj = new Common.KFTC.Request.withdraw(); withdrawObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호 withdrawObj.cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", ""); withdrawObj.cntr_account_num = ApplicationConfig.ReadWebConfig("GME_WITHDRAW_ACCNO", ""); //withdrawObj.dps_print_content = lengSubstring(10, "D_" + model.RecipientName); //입금계좌 인자내역 withdrawObj.dps_print_content = lengSubstring(10, "D_" + model.senderName); //입금계좌 인자내역 withdrawObj.fintech_use_num = model.FintechUseNo; //출금계좌 핀테크번호 withdrawObj.tran_amt = amt; //거래금액 withdrawObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); //요청일시 withdrawObj.req_client_name = customerDetail["accountName"].ToString(); withdrawObj.req_client_bank_code = customerDetail["bankCodeStd"].ToString(); withdrawObj.req_client_account_num = customerDetail["accountNum"].ToString(); withdrawObj.req_client_num = model.CustomerId; withdrawObj.transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", ""); string withdraw_url = ApplicationConfig.ReadWebConfig("TRANSFER_WITHDRAW", ""); string withdrawData = JsonConvert.SerializeObject(withdrawObj); logResult = _repo.LogRequestKFTC(model.CustomerId, "Domestic Remittance/withdraw", "access_token :" + accessToken + "req :" + withdrawData); Log.Debug("[KFTC-API-REQ] transfer/withdraw : [customerId]:" + model.CustomerId + " [REQ DATA]:" + withdrawData); var result_withdraw = kftcRequest_withdraw.PostToKFTC(withdraw_url, accessToken, withdrawData); /* 출금 실패 withdraw fail */ if (string.IsNullOrEmpty(result_withdraw)) { jsonResponse.ErrorCode = "1"; jsonResponse.Msg = "FAILED TO KFTC OPEN-FLATFORM (transfer/withdraw) QUERY!"; _repo.LogResponseKFTC(logResult.Id, null, jsonResponse.ErrorCode, jsonResponse.Msg); return jsonResponse; } var respObj_withdraw = JsonConvert.DeserializeObject(result_withdraw); Log.Debug("[KFTC-API-RES] transfer/withdraw : " + result_withdraw); if (respObj_withdraw.rsp_code == "A0001" || respObj_withdraw.rsp_code == "A0003" || respObj_withdraw.rsp_code == "A0007" || respObj_withdraw.bank_rsp_code == "400") { Thread.Sleep(1 * 60 * 1000); /* 이체결과확인 */ respObj_withdraw = CheckWithdrawResult(ref respObj_withdraw, model.CustomerId, "1"); //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); if (respObj_withdraw.rsp_code == "A0001" || respObj_withdraw.rsp_code == "A0003" || respObj_withdraw.rsp_code == "A0007" || respObj_withdraw.bank_rsp_code == "400") { Thread.Sleep(2 * 60 * 1000); /* 이체결과확인 */ respObj_withdraw = CheckWithdrawResult(ref respObj_withdraw, model.CustomerId, "2"); //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); if (respObj_withdraw.rsp_code == "A0001" || respObj_withdraw.rsp_code == "A0003" || respObj_withdraw.rsp_code == "A0007" || respObj_withdraw.bank_rsp_code == "400") { jsonResponse.ErrorCode = "1"; jsonResponse.Msg = respObj_withdraw.rsp_message; jsonResponse.Extra = JsonConvert.SerializeObject(respObj_withdraw); _repo.LogResponseKFTC(logResult.Id, result_withdraw, respObj_withdraw.rsp_code, respObj_withdraw.rsp_message); //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); // Domestic 출금이체 response log return jsonResponse; } } } if (respObj_withdraw.rsp_code == "A0000") { jsonResponse.ErrorCode = "0"; jsonResponse.Msg = "Success"; jsonResponse.Extra = JsonConvert.SerializeObject(respObj_withdraw); _repo.LogResponseKFTC(logResult.Id, result_withdraw, respObj_withdraw.rsp_code, respObj_withdraw.rsp_message); //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); // Domestic 출금이체 response log return jsonResponse; } else { jsonResponse.ErrorCode = "1"; jsonResponse.Msg = respObj_withdraw.rsp_message; jsonResponse.Extra = JsonConvert.SerializeObject(respObj_withdraw); _repo.LogResponseKFTC(logResult.Id, result_withdraw, respObj_withdraw.rsp_code, respObj_withdraw.rsp_message); //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); // Domestic 출금이체 response log return jsonResponse; } } /* * ------------------------------------------------------------------------ * Domestic Remittance autobebit 입금이체 API호출 2019.09 Dana * ------------------------------------------------------------------------ * */ public JsonRxResponse SendDomeRimit_deposit(DomesticRemitModel model) { JsonRxResponse jsonResponse = new JsonRxResponse(); DbResult _resp = new DbResult(); //1.KFTC_DOMESTIC_HISTORY insert (실계좌-withdraw) DomesticHistoryModel depositModel = new DomesticHistoryModel(); depositModel.SetDepositData(model); _resp = _repo.requestKFTCDomesticHistory(depositModel); //2.KFTC 입금이체 API실행 model.transferType = "deposit"; jsonResponse = KftcTransferDeposit(model); jsonResponse.Id = model.processId; if (jsonResponse.ErrorCode == "0") { //3.KJ_AUTO_REFUND update KJAutoRefundModel kjModel = new KJAutoRefundModel(); kjModel.SetDepositData("Domestic", "SUCCESS", model); _resp = _repo.SendAutoRefund(kjModel); //4.KFTC_DOMESTIC_HISTORY update(실계좌-deposit) var depositObj = JsonConvert.DeserializeObject(jsonResponse.Extra); _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model); } else { //3.KJ_AUTO_REFUND update KJAutoRefundModel kjModel = new KJAutoRefundModel(); kjModel.SetDepositData("Domestic", "FAIL", model); _resp = _repo.SendAutoRefund(kjModel); //4.KFTC_DOMESTIC_HISTORY update(실계좌-depoit) if (string.IsNullOrEmpty(jsonResponse.Extra) == true) { _repo.responseKFTCDomesticHistory_DepositRefund(null, model); } else { var depositObj = JsonConvert.DeserializeObject(jsonResponse.Extra); _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model); } } return jsonResponse; } public JsonRxResponse KftcTransferDeposit(DomesticRemitModel model) { JsonRxResponse jsonResponse = new JsonRxResponse(); DbResult logResult = new DbResult(); KFTCPostGet kftcRequest = new KFTCPostGet(); var gme = _repo.GetGMEMaster(); if (gme == null) { jsonResponse.SetResponse("1", "Failed to bring GME token.", null); return jsonResponse; } var gmeAccessToken = gme["accessToken"].ToString(); //string customerName = ""; //string customerBankCode = "034"; //string customerAccountNo = ""; //if(model.type=="wallet") //{ // var customerDetail = _repo.GetGMECustomerList(model.CustomerId); // customerName = customerDetail.Rows[0]["fullName"].ToString(); // customerAccountNo = customerDetail.Rows[0]["walletAccountNo"].ToString(); //} //else if(model.type=="autodebit") //{ // var customerDetail = _repo.GetKFTCAccountInfo(model.CustomerId, model.FintechUseNo); // if (customerDetail == null) // { // jsonResponse.SetResponse("1", "Failed to bring customer account number.", null); // return jsonResponse; // } // customerName = customerDetail["accountName"].ToString(); // customerBankCode = customerDetail["bankCodeStd"].ToString(); // customerAccountNo = customerDetail["accountNum"].ToString(); //} Request.deposit deposit_req = new Request.deposit() { cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", ""), cntr_account_num = ApplicationConfig.ReadWebConfig("GME_DEPOSIT_ACCNO", ""), wd_pass_phrase = ApplicationConfig.ReadWebConfig("pass_phrase", ""), // "입금이체용 암호문구"; wd_print_content = lengSubstring(10, "D_" + model.senderName),//출금계좌인자내역(GME통장내역) name_check_option = "off", req_cnt = "1", tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"), req_list = new List() }; var tranAmt = (model.transferType == "refund") ? (Convert.ToDecimal(model.SentAmount) + Convert.ToDecimal(model.ServiceFee)).ToString() : model.SentAmount; Request.bank_account bank = new Request.bank_account() { bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"), // 은행거래 고유번호 tran_no = "1", bank_code_std = model.RecipientBankCode,//입금은행코드 account_num = model.RecipientAccountNo,//입금계좌번호 account_holder_name = lengSubstring(10, model.RecipientName),//입금계좌 예금주명 print_content = lengSubstring(10, model.senderName),//입금계좌인자내역 tran_amt = tranAmt, //입금금액 req_client_name = lengSubstring(10, model.senderName), req_client_bank_code = model.senderBankCode, req_client_account_num = model.senderAccountNo, req_client_num = model.CustomerId, transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", "") }; deposit_req.req_list.Add(bank); var deposit_body = JsonConvert.SerializeObject(deposit_req); /* KFTC 입금 API 호출 TRANSFER/DEPOSIT start */ try { string deposit_url = @"v2.0/transfer/deposit/acnt_num"; logResult = _repo.LogRequestKFTC(model.CustomerId, "Domestic Remittance/deposit", "access_token :" + gmeAccessToken + "req :" + deposit_body); Log.Debug("[KFTC-API-REQ] transfer/deposit : [customerId]:" + model.CustomerId + " [REQ DATA]:" + deposit_body); var deposit_result = kftcRequest.PostToKFTC(deposit_url, gmeAccessToken, deposit_body); /* 입금이체 요청 실패 TRANSFER/DEPOSIT fail */ if (string.IsNullOrEmpty(deposit_result)) { jsonResponse.ErrorCode = "1"; jsonResponse.Msg = "FAILED TO KFTC OPEN-FLATFORM (TRANSFER/DEPOSIT)!"; _repo.LogResponseKFTC(logResult.Id, deposit_result, jsonResponse.ErrorCode, jsonResponse.Msg); return jsonResponse; } /* 입금이체 API 결과처리 TRANSFER/DEPOSIT result */ var objDepositRst = JsonConvert.DeserializeObject(deposit_result); Log.Debug("[KFTC-API-RES] transfer/deposit : " + deposit_result); /* 처리중으로 나오면 결과 재확인 result re-check */ if (objDepositRst.rsp_code == "A0001" || objDepositRst.rsp_code == "A0003" || objDepositRst.rsp_code == "A0007" || objDepositRst.res_list[0].bank_rsp_code == "400" || objDepositRst.res_list[0].bank_rsp_code == "803" || objDepositRst.res_list[0].bank_rsp_code == "804") { Thread.Sleep(1 * 60 * 1000); /* 이체결과 조회 */ objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "1"); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, flag); if (objDepositRst.rsp_code == "A0001" || objDepositRst.rsp_code == "A0003" || objDepositRst.rsp_code == "A0007" || objDepositRst.res_list[0].bank_rsp_code == "400" || objDepositRst.res_list[0].bank_rsp_code == "803" || objDepositRst.res_list[0].bank_rsp_code == "804") { Thread.Sleep(2 * 60 * 1000); objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "2"); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, flag); if (objDepositRst.rsp_code == "A0001" || objDepositRst.rsp_code == "A0003" || objDepositRst.rsp_code == "A0007" || objDepositRst.res_list[0].bank_rsp_code == "400" || objDepositRst.res_list[0].bank_rsp_code == "803" || objDepositRst.res_list[0].bank_rsp_code == "804") { //실패로그 남기기 jsonResponse.ErrorCode = "1"; jsonResponse.Msg = objDepositRst.rsp_message; jsonResponse.Extra = JsonConvert.SerializeObject(objDepositRst); _repo.LogResponseKFTC(logResult.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message); return jsonResponse; } } } if (objDepositRst.rsp_code == "A0000") { jsonResponse.ErrorCode = "0"; jsonResponse.Msg = "Success"; jsonResponse.Extra = JsonConvert.SerializeObject(objDepositRst); //jsonResponse.Data = objDepositRst; _repo.LogResponseKFTC(logResult.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, flag); // Domestic 입금이체 response log //kjModel.action = "SUCCESS"; //_repo.SendAutoRefund(kjModel); return jsonResponse; } else { jsonResponse.ErrorCode = "1"; jsonResponse.Msg = objDepositRst.rsp_message; jsonResponse.Extra = JsonConvert.SerializeObject(objDepositRst); _repo.LogResponseKFTC(logResult.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, flag); // Domestic 입금이체 response log //kjModel.action = "FAIL"; //_repo.SendAutoRefund(kjModel); return jsonResponse; } } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); jsonResponse.SetResponse("1", "Exception tracked : " + ex.Message, null); _repo.LogResponseKFTC(logResult.Id, "Exception occured!", "999", ex.Message); //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, flag); //kjModel.action = "FAIL"; //_repo.SendAutoRefund(kjModel); return jsonResponse; } } /* * ------------------------------------------------------------------------ * Domestic Remittance autobebit 환불(입금이체)API호출 2019.09 Dana * ------------------------------------------------------------------------ * */ public JsonRxResponse SendDomeRimit_refund(DomesticRemitModel model) { JsonRxResponse jsonResponse = new JsonRxResponse(); DbResult _resp = new DbResult(); //1.KFTC_DOMESTIC_HISTORY insert (실계좌-refund) DomesticHistoryModel refundModel = new DomesticHistoryModel(); refundModel.SetRefundData(model); _resp = _repo.requestKFTCDomesticHistory(refundModel); //2.KFTC 입금이체 API실행 model.transferType = "refund"; jsonResponse = KftcTransferDeposit(model); jsonResponse.Id = model.processId; if (jsonResponse.ErrorCode == "0") { //3.KJ_AUTO_REFUND insert KJAutoRefundModel kjModel = new KJAutoRefundModel(); kjModel.SetRefundData("Domestic", "SUCCESS", model); _resp = _repo.SendAutoRefund(kjModel); //4.KFTC_DOMESTIC_HISTORY update(실계좌-refund) var depositObj = JsonConvert.DeserializeObject(jsonResponse.Extra); _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model); } else { //3.KJ_AUTO_REFUND update KJAutoRefundModel kjModel = new KJAutoRefundModel(); kjModel.SetRefundData("Domestic", "FAIL", model); _resp = _repo.SendAutoRefund(kjModel); //4.KFTC_DOMESTIC_HISTORY update(실계좌-refund) if (string.IsNullOrEmpty(jsonResponse.Extra) == true) { _repo.responseKFTCDomesticHistory_DepositRefund(null, model); } else { var depositObj = JsonConvert.DeserializeObject(jsonResponse.Extra); _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model); } } return jsonResponse; } public Common.Model.DbResult CheckLoginPassword(string user, string txnPassword, string paymentType, string customerId) { return _repo.CheckLoginPassword(user, txnPassword, paymentType, customerId); } /* * ------------------------------------------------------------------------ * Domestic Remittance wallet 입금(출금이체 함수호출) 2019.09 Dana * ------------------------------------------------------------------------ * */ public JsonRxResponse SendDomeRimit_wallet_withdraw(DomesticRemitModel model) { JsonRxResponse JsonRx = new JsonRxResponse { ErrorCode = "1", Msg = "Domestic Remittance(wallet) Request cannot proceed further. Please contact GME head office." }; DbResult _resp = new DbResult(); //1.KFTC_DOMESTIC_HISTORY insert (가상계좌-walletwithdraw) DomesticHistoryModel historyModel = new DomesticHistoryModel(); historyModel.SetWalletHistoryData(model); _resp = _repo.requestKFTCDomesticHistory(historyModel); JsonRx.Id = model.processId = _resp.Id; ////2. KFTC_DOMESTIC_HISTORY update(가상계좌-walletwithdraw) //Response.withdraw response = new Response.withdraw();//log에 응답 성공 message넣기 //response.rsp_code = "A0000"; //_repo.responseKFTCDomesticHistory_withdraw(response, model); // Domestic 출금 response log(API호출이 없으므로 무조건 성공으로) //3. KJ_AUTO_REFUND insert (REQ) KJAutoRefundModel kjModel = new KJAutoRefundModel(); kjModel.SetDepositData("DomesticWallet", "REQ", model); _resp = _repo.SendAutoRefund(kjModel); if (_resp.ResponseCode != "0") { JsonRx.ErrorCode = "1"; JsonRx.Msg = "FAIL.Check your Wallet and Wallet Balance."; return JsonRx; } kjModel.rowId = _resp.Id; //4. KFTC_DOMESTIC_HISTORY insert(가상계좌-deposit) //var GMEcustomerDetail = _repo.GetGMECustomerList(model.CustomerId); DomesticHistoryModel depositModel = new DomesticHistoryModel(); depositModel.SetDepositData(model); _repo.requestKFTCDomesticHistory(depositModel);// Domestic 입금이체 request log //5. KFTC 입금이체 API 이용 (deposit) JsonRxResponse depositResult = new JsonRxResponse(); model.transferType = "deposit"; depositResult = KftcTransferDeposit(model); //6. KFTC_DOMESTIC_HISTORY update(가상계좌-deposit) if (string.IsNullOrEmpty(depositResult.Extra) == true) { _repo.responseKFTCDomesticHistory_DepositRefund(null, model); } else { var respObj = JsonConvert.DeserializeObject(depositResult.Extra); _repo.responseKFTCDomesticHistory_DepositRefund(respObj, model); } if (depositResult.ErrorCode != "0") { //7. KJ_AUTO_REFUND update (FAIL) kjModel.SetRefundData("DomesticWallet_FAIL", "FAIL", model); _resp = _repo.SendAutoRefund(kjModel); //8. KFTC_DOMESTIC_HISTORY Insert(가상계좌-refund) DomesticHistoryModel refundModel = new DomesticHistoryModel(); refundModel.SetRefundData(model); _repo.requestKFTCDomesticHistory(refundModel); //이건 필요없을것 같다..... //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, "refund"); JsonRx.ErrorCode = "1"; JsonRx.Msg = depositResult.Msg; return JsonRx; } else { //7. KJ_AUTO_REFUND update (SUCCESS) kjModel.SetDepositData("DomesticWallet_SUCC", "SUCCESS", model); _resp = _repo.SendAutoRefund(kjModel); JsonRx.ErrorCode = "0"; JsonRx.Msg = "Success"; return JsonRx; } } /* * ------------------------------------------------------------------------ * Domestic Remittance wallet 출금이체(Using KFTC) 2019.09 Dana * ------------------------------------------------------------------------ * */ public JsonRxResponse SendDomeRimit_wallet_Deposit(DomesticRemitModel model) { JsonRxResponse res = new JsonRxResponse(); DbResult _logResp = new DbResult(); DbResult _resp = new DbResult(); var gme = _repo.GetGMEMaster(); if (gme == null) { res.SetResponse("1", "Failed to bring GME token.", null); return res; } var gmeAccessToken = gme["accessToken"].ToString(); // 입금시에는 GME AccessToken 사용 /* @Max 수정 */ //고객의 이름, 가상계좌번호 var customerDetail = _repo.GetGMECustomerList(model.CustomerId); //var customerDetail = _repo.GetAccountList(model.CustomerId); Request.deposit deposit_req = new Request.deposit() { cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", ""), cntr_account_num = ApplicationConfig.ReadWebConfig("GME_DEPOSIT_ACCNO", ""), wd_pass_phrase = ApplicationConfig.ReadWebConfig("pass_phrase", ""), // "입금이체용 암호문구"; wd_print_content = lengSubstring(10, "D_" + model.RecipientName), //출금계좌인자내역 name_check_option = "off", req_cnt = "1", tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"), req_list = new List() }; Request.bank_account bank = new Request.bank_account() { bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"), // 은행거래 고유번호 tran_no = "1", bank_code_std = model.RecipientBankCode,//입금은행코드 account_num = model.RecipientAccountNo,//입금계좌번호 account_holder_name = lengSubstring(10, model.RecipientName),//입금계좌 예금주명 print_content = lengSubstring(10, model.RecipientName),//입금계좌인자내역 tran_amt = Convert.ToDecimal(model.SentAmount).ToString(), //입금금액 req_client_name = customerDetail.Rows[0]["fullName"].ToString(), req_client_bank_code = "034", //가상은행코드 req_client_account_num = customerDetail.Rows[0]["walletAccountNo"].ToString(), req_client_num = model.CustomerId, transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", "") // transfer }; deposit_req.req_list.Add(bank); var deposit_body = JsonConvert.SerializeObject(deposit_req); /* KFTC 입금 API 호출 TRANSFER/DEPOSIT start */ try { KFTCPostGet kftcRequest = new KFTCPostGet(); string deposit_url = @"v2.0/transfer/deposit/acnt_num"; var deposit_result = kftcRequest.PostToKFTC(deposit_url, gmeAccessToken, deposit_body); _logResp = _repo.LogRequestKFTC(model.CustomerId, "Domestic Remittance/deposit", "access_token :" + gmeAccessToken + "req :" + deposit_body); /* 입금이체 요청 실패 TRANSFER/DEPOSIT fail */ if (string.IsNullOrEmpty(deposit_result)) { res.ErrorCode = "1"; res.Msg = "FAILED TO KFTC OPEN-FLATFORM (TRANSFER/DEPOSIT)!"; _repo.LogResponseKFTC(_logResp.Id, deposit_result, res.ErrorCode, res.Msg); //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, "deposit"); return res; } /* 입금이체 API 결과처리 TRANSFER/DEPOSIT result */ var objDepositRst = JsonConvert.DeserializeObject(deposit_result); _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, (objDepositRst.rsp_code == "A0000") ? "Success!" : objDepositRst.rsp_message); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log /* 처리중으로 나오면 결과 재확인 result re-check */ if (objDepositRst.rsp_code == "A0001" || objDepositRst.rsp_code == "A0003" || objDepositRst.rsp_code == "A0007" || objDepositRst.res_list[0].bank_rsp_code == "400" || objDepositRst.res_list[0].bank_rsp_code == "803" || objDepositRst.res_list[0].bank_rsp_code == "804") { Thread.Sleep(1 * 60 * 1000); /* 이체결과 조회 */ objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "1"); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, "deposit"); if (objDepositRst.rsp_code == "A0001" || objDepositRst.rsp_code == "A0003" || objDepositRst.rsp_code == "A0007" || objDepositRst.res_list[0].bank_rsp_code == "400" || objDepositRst.res_list[0].bank_rsp_code == "803" || objDepositRst.res_list[0].bank_rsp_code == "804") { Thread.Sleep(2 * 60 * 1000); objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "2"); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, "deposit"); if (objDepositRst.rsp_code == "A0001" || objDepositRst.rsp_code == "A0003" || objDepositRst.rsp_code == "A0007" || objDepositRst.res_list[0].bank_rsp_code == "400" || objDepositRst.res_list[0].bank_rsp_code == "803" || objDepositRst.res_list[0].bank_rsp_code == "804") { //실패로그 남기기 res.ErrorCode = "1"; res.Msg = objDepositRst.rsp_message; res.Id = objDepositRst.api_tran_id; res.Extra = objDepositRst.api_tran_dtm; _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log return res; } } } if (objDepositRst.rsp_code == "A0000") { res.ErrorCode = "0"; res.Msg = "Success"; res.Extra = JsonConvert.SerializeObject(objDepositRst); _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log return res; } else { res.ErrorCode = "1"; res.Msg = objDepositRst.rsp_message; _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message); //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log return res; } } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); res.SetResponse("1", "Exception tracked : " + ex.Message, null); _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message); //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log return res; } } /* 입금이체 시 사용. substring하기 위한 함수 @Dana */ public string lengSubstring(int subLength, string str) { string result = ""; if (str.Length >= subLength) result = str.Substring(0, subLength); else result = str; return result; } public JsonRxResponse DeleteAccount(DeleteRequest req, string customerId) { JsonRxResponse res = new JsonRxResponse(); KftcSendMoneyRequest request; try { var kftcLogId = Crypto.Decrypt(req.KftcLogId, Utilities.ReadWebConfig("ktft_client_info_salt", "")); request = _repo.GetCustomerKFTCInfo(customerId, kftcLogId); if (null == request) { res.ErrorCode = "1"; res.Msg = "Error:Invalid auto debit account"; return res; } DbResult dbResult = new DbResult(); DbResult logResult = new DbResult(); var fintechUseNo = request.FintechUseNo; logResult = _repo.LogRequestKFTC(customerId, "DBDelete", "CustomerId :" + customerId + " fintechUseNo :" + fintechUseNo); dbResult = _repo.DeleteAccount(customerId, fintechUseNo); _repo.LogResponseKFTC(logResult.Id, JsonConvert.SerializeObject(dbResult), dbResult.ResponseCode, dbResult.Msg); res.ErrorCode = dbResult.ResponseCode; res.Msg = dbResult.Msg; res.Data = new { Message = dbResult.Msg }; return res; } catch (Exception ex) { res.ErrorCode = "1"; res.Msg = "Error:Invalid auto debit account"; return res; } } private string getBankTranId() { //f3aa2cd1-1e9b-41fd-80f1-fd518cac9b81 Guid guid = Guid.NewGuid(); string guidSub = guid.ToString().Replace("-", ""); Random rndNum = new Random(); int rNum = rndNum.Next(0, 29); string unique = guidSub.Substring(rNum, 3); string bankTranId = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmss") + unique; return bankTranId.ToUpper(); } public JsonRxResponse RegistrationKFTC_V4(string email, string lang, string client_id) { JsonRxResponse res = new JsonRxResponse(); var customerId = ""; try { var dbResult = _repo.GetCustomerIdEmail(email); if (dbResult != null) { customerId = dbResult.Msg; string URL = GetKftcUrl(customerId, lang, client_id); //List AccountList = GetAccountList(customerId); //AccountList.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", ""))); List
ListLangauge = GetKftcLanguage(customerId); List
ListHeader = GetKftcHeader_V4(customerId); KftcCommonResponse Response = new KftcCommonResponse() { Header = ListHeader, URL = URL, Language = ListLangauge }; res.ErrorCode = "0"; res.Msg = "Success"; res.Data = Response; return res; } else { res.ErrorCode = "1"; res.Msg = "failed"; res.Data = null; return res; } } catch (Exception ex) { Log.Error("Exception tracked : " + ex.Message, ex); res.SetResponse("1", "Exception tracked : " + ex.Message, null); res.Data = new { }; return res; } } private List
GetKftcHeader_V4(string customerId) { DataRow dr = _repo.GetCustomerData_V4(customerId); List
listKftcHeader = new List
(); string[] param = new string[] { "Kftc-Bfop-UserSeqNo", "Kftc-Bfop-UserCI", "Kftc-Bfop-UserName" , "Kftc-Bfop-UserInfo","Kftc-Bfop-UserCellNo","Kftc-Bfop-PhoneCarrier","Kftc-Bfop-UserEmail"}; if (dr == null) { //KftcHeader.Add("Kftc-Bfop-UserSeqNo", ""); //KftcHeader.Add("Kftc-Bfop-UserCI", ""); //KftcHeader.Add("Kftc-Bfop-UserName", ""); //KftcHeader.Add("Kftc-Bfop-UserInfo", ""); //KftcHeader.Add("Kftc-Bfop-UserCellNo", ""); //KftcHeader.Add("Kftc-Bfop-PhoneCarrier", ""); //KftcHeader.Add("Kftc-Bfop-UserEmail", ""); foreach (var item in param) { Header KftcHeader = new Header(); KftcHeader.Key = item; KftcHeader.Value = ""; listKftcHeader.Add(KftcHeader); } } else { Header KftcHeader1 = new Header(); KftcHeader1.Key = "Kftc-Bfop-UserSeqNo"; KftcHeader1.Value = string.IsNullOrEmpty(dr["userSeqNo"].ToString()) ? "" : dr["userSeqNo"].ToString(); listKftcHeader.Add(KftcHeader1); Header KftcHeader2 = new Header(); KftcHeader2.Key = "Kftc-Bfop-UserCI"; KftcHeader2.Value = string.IsNullOrEmpty(dr["userCi"].ToString()) ? "" : dr["userCi"].ToString(); listKftcHeader.Add(KftcHeader2); Header KftcHeader3 = new Header(); KftcHeader3.Key = "Kftc-Bfop-UserName"; KftcHeader3.Value = string.IsNullOrEmpty(dr["userName"].ToString()) ? "" : dr["userName"].ToString(); listKftcHeader.Add(KftcHeader3); Header KftcHeader4 = new Header(); KftcHeader4.Key = "Kftc-Bfop-UserInfo"; KftcHeader4.Value = string.IsNullOrEmpty(dr["userInfo"].ToString()) ? "" : dr["userInfo"].ToString(); listKftcHeader.Add(KftcHeader4); Header KftcHeader5 = new Header(); KftcHeader5.Key = "Kftc-Bfop-UserCellNo"; KftcHeader5.Value = string.IsNullOrEmpty(dr["UserCellNo"].ToString()) ? "" : dr["UserCellNo"].ToString(); listKftcHeader.Add(KftcHeader5); Header KftcHeader6 = new Header(); KftcHeader6.Key = "Kftc-Bfop-PhoneCarrier"; KftcHeader6.Value = ""; listKftcHeader.Add(KftcHeader6); Header KftcHeader7 = new Header(); KftcHeader7.Key = "Kftc-Bfop-UserEmail"; KftcHeader7.Value = string.IsNullOrEmpty(dr["UserEmail"].ToString()) ? "" : dr["UserEmail"].ToString(); listKftcHeader.Add(KftcHeader7); Header KftcHeader8 = new Header(); KftcHeader8.Key = "Kftc-Bfop-AccountNum"; KftcHeader8.Value = string.IsNullOrEmpty(dr["AccountNum"].ToString()) ? "" : dr["AccountNum"].ToString(); listKftcHeader.Add(KftcHeader8); Header KftcHeader9 = new Header(); KftcHeader9.Key = "Kftc-Bfop-BankCodeStd"; KftcHeader9.Value = string.IsNullOrEmpty(dr["BankCodeStd"].ToString()) ? "" : dr["BankCodeStd"].ToString(); listKftcHeader.Add(KftcHeader9); } return listKftcHeader; } public bool SetRealNameDataIdWise(RealNameCheckDetails realNameCheckDetails) { var idNumber = realNameCheckDetails.idNumber.ToString().Replace("-", ""); var reqRealNameObj = new Common.KFTC.Request.real_name(); var processId = DateTime.Now.Ticks + realNameCheckDetails.customerId; bool isSuccess = false; string saveIdNumber = ""; //string[] idTypes = { "2", "5", "4", "1", "4" }; string[] idTypes = { "2", "1", "4", "5", "6", "3", "E", "4" }; for (int i = 0; i < 8; i++) { reqRealNameObj.bank_code_std = realNameCheckDetails.BankCode; reqRealNameObj.account_num = realNameCheckDetails.AccountNumber; reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); //조합주민번호를 만들어서 체크 if (i == 7) { int pos = 0; for (int j = idNumber.Length - 1; j > 0; j--) { char ch = idNumber[j]; if (ch >= 0x30 && ch <= 0x39) { pos = j; break; } } reqRealNameObj.account_holder_info_type = idTypes[i]; reqRealNameObj.account_holder_info = String.Format("{0}{1}{2}{3}", realNameCheckDetails.dob, realNameCheckDetails.gender, realNameCheckDetails.country, realNameCheckDetails.idNumber.Substring(pos - 4, 5)); } else { reqRealNameObj.account_holder_info_type = idTypes[i]; reqRealNameObj.account_holder_info = idNumber; } saveIdNumber = reqRealNameObj.account_holder_info.Insert(6, "-"); isSuccess = KFTC_RealNameCheck_Common(reqRealNameObj, realNameCheckDetails.gmeAccessToken, realNameCheckDetails.customerId); if (isSuccess == true) { _repo.SetRealNameData(realNameCheckDetails.customerId, reqRealNameObj.account_holder_info_type, saveIdNumber); break; } } return isSuccess; } } }