using Business.TPApi; using Common; using Common.Helper; using Common.Model.Remit; using log4net; using Newtonsoft.Json; using System; namespace Business.Remit { public class RemitBusiness : IRemitBusiness { private readonly ThirdPartyAPI _tpApi = new ThirdPartyAPI(); private static readonly ILog Log = LogManager.GetLogger(typeof(RemitBusiness)); public RemitBusiness() { } public JsonRxResponse SearchTxnByControlNumber(SearchTxnModel searchTxn) { APIJsonResponse _apiJsonResponse = new APIJsonResponse(); JsonRxResponse _jsonResp = new JsonRxResponse(); try { Log.DebugFormat("SearchTxnByControlNumber | Calling SearchTxnByControlNumber method."); SearchTxnThirdparty _searchTxn = new SearchTxnThirdparty { PBranch = GetStatic.ReadWebConfig("sBranch", ""), ControlNo = searchTxn.controlNumber, ProcessId = searchTxn.ProcessId, RequestFrom = "mobile", SessionId = searchTxn.ProcessId, UserName = searchTxn.userID }; APIJsonResponse _result = new APIJsonResponse(); //uncoment after creating the lo0gic in TP API _result = _tpApi.ThirdPartyApiGetDataOnly(_searchTxn, "TP/payTxnCheck", out _apiJsonResponse); //for now putting hardcode value by creating a dummy method //_result = GetResponseDummyData(searchTxn); Log.Debug("SearchTxnByControlNumber | Calling SearchTxnByControlNumber with response..." + JsonConvert.SerializeObject(_result)); return _jsonResp = new JsonRxResponse() { ErrorCode = _result.ResponseCode, Id = _result.Id, Msg = _result.Msg, Data = _result.Data, Extra = _result.Extra, Extra2 = _result.Extra1 }; } catch (Exception ex) { Log.Error("Something Went Wrong, Please Try Again!!", ex); _jsonResp.SetResponse("1", "Could not complete the request."); return _jsonResp; } } public JsonRxResponse RedeemCashPayment(ConfirmTxnModel redeemTxn) { APIJsonResponse _apiJsonResponse = new APIJsonResponse(); JsonRxResponse _jsonResp = new JsonRxResponse(); try { Log.DebugFormat("RedeemCashPayment | Calling RedeemCashPayment method."); ConfirmTxnThirdParty _confirmTxn = new ConfirmTxnThirdParty { PBranch = GetStatic.ReadWebConfig("sBranch", ""), ControlNo = redeemTxn.controlNumber, ProcessId = redeemTxn.ProcessId, RequestFrom = "mobile", SessionId = redeemTxn.ProcessId, UserName = redeemTxn.userID, txnId = redeemTxn.txnId, password = redeemTxn.password }; APIJsonResponse _result = new APIJsonResponse(); //uncoment after creating the lo0gic in TP API _result = _tpApi.ThirdPartyApiGetDataOnly(_confirmTxn, "TP/payTxnConfirm", out _apiJsonResponse); Log.Debug("RedeemCashPayment | Calling RedeemCashPayment with response..." + JsonConvert.SerializeObject(_result)); //for now returning harcode success value return _jsonResp = new JsonRxResponse() { ErrorCode = _result.ResponseCode, Msg = _result.Msg, }; } catch (Exception ex) { Log.Error("Something Went Wrong, Please Try Again!!", ex); _jsonResp.SetResponse("1", "Could not complete the request."); return _jsonResp; } } public JsonRxResponse WithdrawWalletRequest(WithdrawWalletRequestModel withdrawWalletRequest) { APIJsonResponse _apiJsonResponse = new APIJsonResponse(); JsonRxResponse _jsonResp = new JsonRxResponse(); try { Log.DebugFormat("WithdrawWalletRequest | Calling WithdrawWalletRequest method."); APIJsonResponse _result = new APIJsonResponse(); withdrawWalletRequest.UserName = withdrawWalletRequest.userID; _result = _tpApi.ThirdPartyApiGetDataOnly(withdrawWalletRequest, "TP/withdrawWalletRequest", out _apiJsonResponse); Log.Debug("WithdrawWalletRequest | Calling WithdrawWalletRequest with response..." + JsonConvert.SerializeObject(_result)); //for now returning harcode success value return _jsonResp = new JsonRxResponse() { ErrorCode = _result.ResponseCode, Id = _result.Id, Msg = _result.Msg, Data = _result.Data, Extra = _result.Extra, Extra2 = _result.Extra1 }; } catch (Exception ex) { Log.Error("Something Went Wrong, Please Try Again!!", ex); _jsonResp.SetResponse("1", "Could not complete the request."); return _jsonResp; } } public JsonRxResponse WithdrawFromWallet(WithdrawFromWalletModel withdrawWallet) { APIJsonResponse _apiJsonResponse = new APIJsonResponse(); JsonRxResponse _jsonResp = new JsonRxResponse(); try { Log.DebugFormat("WithdrawFromWallet | Calling WithdrawFromWallet method."); APIJsonResponse _result = new APIJsonResponse(); withdrawWallet.UserName = withdrawWallet.userID; _result = _tpApi.ThirdPartyApiGetDataOnly(withdrawWallet, "TP/withdrawFromWallet", out _apiJsonResponse); Log.Debug("WithdrawFromWallet | Calling WithdrawFromWallet with response..." + JsonConvert.SerializeObject(_result)); //for now returning harcode success value return _jsonResp = new JsonRxResponse() { ErrorCode = _result.ResponseCode, Msg = _result.Msg }; } catch (Exception ex) { Log.Error("Something Went Wrong, Please Try Again!!", ex); _jsonResp.SetResponse("1", "Could not complete the request."); return _jsonResp; } } public APIJsonResponse GetResponseDummyData(SearchTxnModel searchTxn) { APIJsonResponse _apiResp = new APIJsonResponse(); if (searchTxn.controlNumber != "12345678") { _apiResp = new APIJsonResponse { ResponseCode = "1", Msg = "Invalid Transaction!" }; return _apiResp; } _apiResp = new APIJsonResponse { ResponseCode = "0", Msg = "Success" }; _apiResp.Data = new { txnId = "100001", sendingCountryCode = "NP", sendingCountryName = "Nepal", controlNo = searchTxn.controlNumber, tranDate = "2020-01-01", senderName = "Test Sender For Nepal", receiverName = "Test Recv. Name", receiverAddress = "Mongolia, test address", receiverMobile = "9848741445", status = "Unpaid", serviceFee = "0.00", exrate = "2.00", receivedAmount = "1000.00" }; return _apiResp; } private APIJsonResponse GetResponseDummyDataWithdraw(WithdrawWalletRequestModel withdrawWalletRequest) { APIJsonResponse _apiResp = new APIJsonResponse(); if (GetStatic.ParseDouble(withdrawWalletRequest.amount) > 100000) { _apiResp = new APIJsonResponse { ResponseCode = "1", Msg = "Withdraw amount can not be greater than 100,000!" }; return _apiResp; } if (GetStatic.ParseDouble(withdrawWalletRequest.amount) < 1000) { _apiResp = new APIJsonResponse { ResponseCode = "1", Msg = "Withdraw amount can not be less than 1000!" }; return _apiResp; } _apiResp = new APIJsonResponse { ResponseCode = "0", Msg = "Success" }; string sc = "0"; if (GetStatic.ParseDouble(withdrawWalletRequest.amount) > 1000 && GetStatic.ParseDouble(withdrawWalletRequest.amount) <= 10000) sc = "50"; if (GetStatic.ParseDouble(withdrawWalletRequest.amount) > 10000 && GetStatic.ParseDouble(withdrawWalletRequest.amount) <= 20000) sc = "80"; if (GetStatic.ParseDouble(withdrawWalletRequest.amount) > 20000 && GetStatic.ParseDouble(withdrawWalletRequest.amount) <= 50000) sc = "150"; if (GetStatic.ParseDouble(withdrawWalletRequest.amount) > 50000 && GetStatic.ParseDouble(withdrawWalletRequest.amount) <= 100000) sc = "250"; _apiResp.Data = new { bankName = "Mangolia test Bank", accountNo = "789748524", serviceCharge = sc, amount = withdrawWalletRequest.amount, noticeMessage = "This is test notice msg!" }; return _apiResp; } } }