|
@ -58,74 +58,6 @@ namespace TPApiServices.SendMNRemit.Services |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private SendMNAuthResponsetModel GetToken(string user)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// SendMNAuthResponsetModel tokenResponse = new SendMNAuthResponsetModel();
|
|
|
|
|
|
// ThirdPartyRepo thirdPartyRepo = new ThirdPartyRepo();
|
|
|
|
|
|
// try
|
|
|
|
|
|
// {
|
|
|
|
|
|
// TokenDataNew token = new TokenDataNew
|
|
|
|
|
|
// {
|
|
|
|
|
|
// PartnerCode = "SENDMN",
|
|
|
|
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// //check token in DB
|
|
|
|
|
|
// var tokenDB = thirdPartyRepo.GetTokenNew(user, token);
|
|
|
|
|
|
// if (tokenDB.ResponseCode == "2" || tokenDB.ResponseCode == "3")
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var requestBody = new SendMNModel
|
|
|
|
|
|
// {
|
|
|
|
|
|
// AgentCode = agentCode,
|
|
|
|
|
|
// AuthKey = authKey,
|
|
|
|
|
|
// UserName = userName
|
|
|
|
|
|
// };
|
|
|
|
|
|
// var client = new RestClient(baseUrl);
|
|
|
|
|
|
// var request = new RestRequest("/api/Authentication", Method.POST);
|
|
|
|
|
|
|
|
|
|
|
|
// request.AddHeader("Content-Type", "application/json");
|
|
|
|
|
|
// request.AddHeader("UserName", userName);
|
|
|
|
|
|
// request.AddHeader("AgentCode", agentCode);
|
|
|
|
|
|
// request.AddHeader("AuthKey", authKey);
|
|
|
|
|
|
|
|
|
|
|
|
// request.RequestFormat = DataFormat.Json;
|
|
|
|
|
|
// request.AddJsonBody(requestBody);
|
|
|
|
|
|
|
|
|
|
|
|
// tokenResponse = client.Execute<SendMNAuthResponsetModel>(request).Data;
|
|
|
|
|
|
|
|
|
|
|
|
// _log.Info($"SENDMNAPI|GETTOKEN|RESPONSE : {JsonConvert.SerializeObject(tokenResponse)}");
|
|
|
|
|
|
|
|
|
|
|
|
// //save token in DB
|
|
|
|
|
|
// token.ExpiryTime = 10 * 60;
|
|
|
|
|
|
// token.Token = tokenResponse.Detail.Token;
|
|
|
|
|
|
// token.RefreshToken = tokenResponse.Detail.ProcessIdentifier;
|
|
|
|
|
|
// token.TokenType = "Bearer";
|
|
|
|
|
|
|
|
|
|
|
|
// tokenDB = thirdPartyRepo.GetTokenNew(user, token);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// tokenResponse.Code = "0";
|
|
|
|
|
|
// tokenResponse.Detail = new Detail { Token = tokenDB.Id, ProcessIdentifier = tokenDB.Extra };
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// tokenResponse.Code = "999";
|
|
|
|
|
|
|
|
|
|
|
|
// tokenResponse.Detail.Note = ex.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
// _log.Error($"SENDMNAPI|GETTOKEN|EXCEPTION OCCURED : {JsonConvert.SerializeObject(tokenResponse)}");
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// return tokenResponse;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
private SendMNAuthResponsetModel GetToken(string user) |
|
|
private SendMNAuthResponsetModel GetToken(string user) |
|
|
{ |
|
|
{ |
|
|
SendMNAuthResponsetModel tokenResponse = new SendMNAuthResponsetModel(); |
|
|
SendMNAuthResponsetModel tokenResponse = new SendMNAuthResponsetModel(); |
|
@ -187,6 +119,92 @@ namespace TPApiServices.SendMNRemit.Services |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private TPResponse GetExRate(SendExRateRequestModel model)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var exResponse = new TPResponse();
|
|
|
|
|
|
|
|
|
|
|
|
// try
|
|
|
|
|
|
// {
|
|
|
|
|
|
// // Get token
|
|
|
|
|
|
// SendMNAuthResponsetModel tokenResponse = GetToken(model.RequestBy);
|
|
|
|
|
|
|
|
|
|
|
|
// if (tokenResponse.Code != "0")
|
|
|
|
|
|
// {
|
|
|
|
|
|
// exResponse.ResponseCode = "1";
|
|
|
|
|
|
// exResponse.Msg = tokenResponse.Detail.Note;
|
|
|
|
|
|
// _log.Error($"SENDMNAPI|EXRATE.GETTOKEN()|RESPONSE : {JsonConvert.SerializeObject(exResponse)}");
|
|
|
|
|
|
// return exResponse;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var body = new SendExRateRequestModel
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Body = new Body
|
|
|
|
|
|
// {
|
|
|
|
|
|
// SendingCountry = "UK",
|
|
|
|
|
|
// ReceivingCountry = "MN",
|
|
|
|
|
|
// ReceivingCurrency = "MNT"
|
|
|
|
|
|
// },
|
|
|
|
|
|
// Signature = "", // Placeholder for the generated signature
|
|
|
|
|
|
// ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// // Generate signature using the constructed body and token response
|
|
|
|
|
|
// string signature = GenerateSignatureExRate(body, tokenResponse);
|
|
|
|
|
|
|
|
|
|
|
|
// // Assign the generated signature to the body
|
|
|
|
|
|
// body.Signature = signature;
|
|
|
|
|
|
|
|
|
|
|
|
// _log.Info($"SENDMNAPI|EXRATE|REQUEST BODY : {JsonConvert.SerializeObject(body)}");
|
|
|
|
|
|
|
|
|
|
|
|
// // Send request
|
|
|
|
|
|
// var client = new RestClient(baseUrl);
|
|
|
|
|
|
// var request = new RestRequest("/CalculateExRate", Method.POST)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// RequestFormat = DataFormat.Json
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// request.AddHeader("Content-Type", "application/json");
|
|
|
|
|
|
// request.AddHeader("Authorization", "Bearer " + tokenResponse.Detail.Token);
|
|
|
|
|
|
// request.AddHeader("UserName", userName);
|
|
|
|
|
|
// request.AddHeader("AgentCode", agentCode);
|
|
|
|
|
|
// request.AddJsonBody(body);
|
|
|
|
|
|
|
|
|
|
|
|
// var response = client.Execute<SendMNExRateResponseModel>(request);
|
|
|
|
|
|
|
|
|
|
|
|
// //_log.Info($"SENDMNAPI|EXRATE|RESPONSE : {response.Content}");
|
|
|
|
|
|
|
|
|
|
|
|
// // _log.Info($"SENDMNAPI|EXRATE|RESPONSE : {response.Content} | ResponseCode: {exResponse.ResponseCode}, Id: {exResponse.Id}, Extra: {exResponse.Extra}");
|
|
|
|
|
|
// // Process response
|
|
|
|
|
|
// //_log.Info($"SENDMNAPI|EXRATE|RESPONSE : {response.Content} | ResponseCode: {exRateResponse.Code}, Id: {exRateResponse.Detail.ForexSession}, Extra: {exRateResponse.Detail.Rate}");
|
|
|
|
|
|
// var exRateResponse = response.Data;
|
|
|
|
|
|
// _log.Info($"SENDMNAPI|EXRATE|RESPONSE : {response.Content} | ResponseCode: {exRateResponse.Code}, Id: {exRateResponse.Detail.ForexSession}, Extra: {exRateResponse.Detail.Rate}");
|
|
|
|
|
|
|
|
|
|
|
|
// if (exRateResponse.Code == "0")
|
|
|
|
|
|
// {
|
|
|
|
|
|
// exResponse.ResponseCode = "0";
|
|
|
|
|
|
// exResponse.Id = exRateResponse.Detail.ForexSession;
|
|
|
|
|
|
// exResponse.Extra = exRateResponse.Detail.Rate;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// exResponse.ResponseCode = "1";
|
|
|
|
|
|
// exResponse.Extra = exRateResponse.Code;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// exResponse.Msg = exRateResponse.Msg ?? exRateResponse.Message;
|
|
|
|
|
|
// exResponse.Data = exRateResponse;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// exResponse.ResponseCode = "999";
|
|
|
|
|
|
// exResponse.Msg = ex.ToString();
|
|
|
|
|
|
// _log.Error($"SENDMNAPI|SENDTRANSACTION|EXCEPTION OCCURRED|RESPONSE : {JsonConvert.SerializeObject(exResponse)}");
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// return exResponse;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
private TPResponse GetExRate(SendExRateRequestModel model) |
|
|
private TPResponse GetExRate(SendExRateRequestModel model) |
|
|
{ |
|
|
{ |
|
|
var exResponse = new TPResponse(); |
|
|
var exResponse = new TPResponse(); |
|
@ -209,9 +227,11 @@ namespace TPApiServices.SendMNRemit.Services |
|
|
{ |
|
|
{ |
|
|
Body = new Body |
|
|
Body = new Body |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
SendingCountry = "UK", |
|
|
SendingCountry = "UK", |
|
|
ReceivingCountry = "MN", |
|
|
ReceivingCountry = "MN", |
|
|
ReceivingCurrency = "MNT" |
|
|
ReceivingCurrency = "MNT" |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
Signature = "", // Placeholder for the generated signature
|
|
|
Signature = "", // Placeholder for the generated signature
|
|
|
ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier |
|
|
ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier |
|
@ -275,8 +295,6 @@ namespace TPApiServices.SendMNRemit.Services |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TPResponse SendTransaction(SendTransaction model) |
|
|
public TPResponse SendTransaction(SendTransaction model) |
|
|
{ |
|
|
{ |
|
|
TPResponse txnResponse = new TPResponse(); |
|
|
TPResponse txnResponse = new TPResponse(); |
|
@ -359,7 +377,7 @@ namespace TPApiServices.SendMNRemit.Services |
|
|
{ |
|
|
{ |
|
|
txnResponse.ResponseCode = "0";//success
|
|
|
txnResponse.ResponseCode = "0";//success
|
|
|
txnResponse.Id = sendTxnResponse.Detail.ControlNo; |
|
|
txnResponse.Id = sendTxnResponse.Detail.ControlNo; |
|
|
txnResponse.Extra = sendTxnResponse.Detail.ControlNo; |
|
|
|
|
|
|
|
|
txnResponse.Extra = exRateResponse.Extra; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|