Browse Source

sendMN changes

master
Shakun Shrestha 3 months ago
parent
commit
75b5692ddc
  1. 4
      Business/App.config
  2. 7
      Business/BusinessLogic/TPApiServices/Factory/ApiFactoryServices.cs
  3. 1
      Common/Models/StaticData.cs
  4. 24
      TPServices/App.config
  5. 183
      TPServices/SendMNRemit/Model/SendMNModel.cs
  6. 677
      TPServices/SendMNRemit/Services/SendMNAPI.cs
  7. 6
      TPServices/TPServices.csproj
  8. 1
      TPServices/packages.config
  9. 2
      ThirdPartyAPIs/ApiControllers/ThirdPartyAPIController.cs
  10. 34
      ThirdPartyAPIs/App_Data/Templates/BANK_TRANSFER_TXN_PENDING.html
  11. 21
      ThirdPartyAPIs/Web.config

4
Business/App.config

@ -45,9 +45,7 @@
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/soapnew.ws"
binding="basicHttpBinding" bindingConfiguration="PostcodeAnywhere_Soap"
contract="LoqateApi.PostcodeAnywhere_Soap" name="PostcodeAnywhere_Soap" />
<endpoint address="http://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/soapnew.ws" binding="basicHttpBinding" bindingConfiguration="PostcodeAnywhere_Soap" contract="LoqateApi.PostcodeAnywhere_Soap" name="PostcodeAnywhere_Soap" />
</client>
</system.serviceModel>
</configuration>

7
Business/BusinessLogic/TPApiServices/Factory/ApiFactoryServices.cs

@ -2,6 +2,7 @@
using Common.Utility;
using GMENepal.GMENepalAPIService;
using log4net;
using TPApiServices.SendMNRemit.Services;
using TPService.GCC.Services;
using Unity;
@ -26,7 +27,11 @@ namespace Business.BusinessLogic.TPApiServices.Factory
log.Debug("Choose Provider as GCC ");
apiFactory = _container.Resolve<GCCAPI>();
}
else if (providerNo == GetStatic.ReadWebConfig("sendMN", ""))
{
log.Debug("Choose Provider as SENDMN ");
apiFactory = _container.Resolve<SendMNAPI>();
}
return apiFactory;
}
}

1
Common/Models/StaticData.cs

@ -8,6 +8,7 @@ namespace Common.Models
public string CountryIsoCode { get; set; }
public string Type { get; set; }
public string MethodName { get; set; }
public string ControlNo { get; set; }
}
public class PurposeOfRemitance

24
TPServices/App.config

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
@ -12,28 +12,26 @@
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://api.gccremit.com/SendAPI.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_ISendAPI" contract="GCCReference.ISendAPI"
name="BasicHttpsBinding_ISendAPI" />
<endpoint address="https://api.gccremit.com/SendAPI.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_ISendAPI" contract="GCCReference.ISendAPI" name="BasicHttpsBinding_ISendAPI" />
</client>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Unity.Abstractions" publicKeyToken="6d32ff45e0ccc69f" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0"/>
<assemblyIdentity name="Unity.Abstractions" publicKeyToken="6d32ff45e0ccc69f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

183
TPServices/SendMNRemit/Model/SendMNModel.cs

@ -0,0 +1,183 @@
using Common.Models.RequestResponse;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TPApiServices.SendMNRemit.Model
{
public class SendMNModel
{
public string AgentCode { get; set; }
public string AuthKey { get; set; }
public string UserName { get; set; }
}
public class SendMNAuthResponsetModel
{
public string Code { get; set; }
public string Message { get; set; }
public string ProcessIdentifier { get; set; }
public Detail Detail { get; set; }
// public string Detail { get; set; }
}
public class Detail
{
public string ProcessIdentifier { get; set; }
public string Token { get; set; }
public string Note { get; set; }
public string ForexSSessionId { get; set; }
public string PartnerTranNo { get; set; }
public string PaymentMethod { get; set; }
public string SendingAmount { get; set; }
public string SendingCurrency { get; set; }
public string SendingCountry { get; set; }
public string ReceivingAmount { get; set; }
public string ReceivingCurrency { get; set; }
public string ReceivingCountry { get; set; }
public string ExRate { get; set; }
public string ControlNo { get; set; }
public string PaidDate { get; set; }
public string Status { get; set; }
public DateTime ExpiryTime { get; set; }
public string Rate { get; set; }
public string ForexSession { get; set; }
}
public class SendMNStatusRequestModel
{
public string ProcessIdentifier { get; set; }
public string Token { get; set; }
public string Note { get; set; }
public Body Body{ get; set; }
public string Signature { get; set; }
}
public class SendExRateRequestModel
{
public string ProcessIdentifier { get; set; }
public string Signature { get; set; }
public string SendingCountry { get; set; }
public string ReceivingCurrency { get; set; }
public string ReceivingCountry { get; set; }
public string RequestBy { get; set; }
public Body Body { get; set; }
}
public class Body
{
public string ControlNo { get; set; }
public Sender Sender { get; set; }
public Receiver Receiver { get; set; }
public Detail Detail { get; set; }
public string SendingCountry { get; set; }
public string ReceivingCountry { get; set; }
public string ReceivingCurrency { get; set; }
}
public class SendMNSendTransactionRequestModel
{
public string ProcessIdentifier { get; set; }
public string Signature { get; set; }
public Body Body { get; set; }
}
//public class SendMNExRateRequestModel
//{
// public string ProcessIdentifier { get; set; }
// public string Signature { get; set; }
// public Body Body { get; set; }
//}
public class SendMNSendTransactionResponseModel
{
public Detail Detail { get; set; }
//public Data Data { get; set; }
public string Code { get; set; }
public object Msg { get; set; }
public object Message { get; set; }
}
public class SendMNExRateResponseModel
{
public Detail Detail { get; set; }
//public Data Data { get; set; }
public string Code { get; set; }
public string Msg { get; set; }
public string Message { get; set; }
}
public class Sender
{
public string TransferReason { get; set; }
public string FundSource { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string NativeCountry { get; set; }
public string City { get; set; }
public string Address { get; set; }
public string IdType { get; set; }
public string idNumber { get; set; }
public string Mobile { get; set; }
public string Email { get; set; }
}
public class Receiver
{
public string Bank { get; set; }
public string AccountNo { get; set; }
public string Relation { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string NativeCountry { get; set; }
public string City { get; set; }
public string Address { get; set; }
public string Mobile { get; set; }
}
public class SendMNGetAccountNameModel
{
public string ProcessIdentifier { get; set; }
public string Signature { get; set; }
public string AccountNo { get; set; }
public string BankCode { get; set; }
}
public class SendMNGResponseNameModel
{
public string ResponseCode { get; set; }
public string Data { get; set; }
public string Msg { get; set; }
}
public class SendMNStatusResponseModel
{
public string ResponseCode { get; set; }
public string Data { get; set; }
public string Msg { get; set; }
public string Code { get; set; }
public string Message { get; set; }
public Detail Detail { get; set; }
}
}

677
TPServices/SendMNRemit/Services/SendMNAPI.cs

@ -0,0 +1,677 @@
using Common.Models;
using Common.Models.Bank_Account;
using Common.Models.ExchangeRate;
using Common.Models.RequestResponse;
using Common.Models.Status;
using Common.Models.TxnModel;
using Common.TPService;
using Common.Utility;
using log4net;
using Newtonsoft.Json;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using TPApiServices.SendMNRemit.Model;
namespace TPApiServices.SendMNRemit.Services
{
public class SendMNAPI : ITPApiServices
{
private readonly ILog _log = LogManager.GetLogger(typeof(SendMNAPI));
protected string baseUrl { get; set; }
protected string userName { get; set; }
protected string authKey { get; set; }
protected string agentCode { get; set; }
public SendMNAPI()
{
baseUrl = GetStatic.ReadWebConfig("sendmn_base_url", "");
userName = GetStatic.ReadWebConfig("sendmn_user_name", "");
authKey = GetStatic.ReadWebConfig("sendmn_auth_key", "");
agentCode = GetStatic.ReadWebConfig("sendmn_agent_code", "");
}
public TPResponse GetTPResponse<T>(T model, string MethodName) where T : class
{
switch (MethodName)
{
//case "exRate":
// return GetExRate(model as SendExRateRequestModel);
case "send":
return SendTransaction(model as SendTransaction);
case "verify":
return AccountVerifySendMN(model as AccountValidate);
case "status":
return GetStatusSendMN(model as GetStatus);
case "staticData":
return GetStaticData(model as StaticData);
default:
throw new NotImplementedException();
}
}
private SendMNAuthResponsetModel GetToken(string user)
{
SendMNAuthResponsetModel tokenResponse = new SendMNAuthResponsetModel();
try
{
var requestBody = new SendMNModel
{
AgentCode = agentCode,
AuthKey = authKey,
UserName = userName
};
var client = new RestClient(baseUrl);
var request = new RestRequest("/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);
_log.Info($"SENDMNAPI|GETTOKEN|REQUEST URL: {client.BaseUrl}{request.Resource}");
_log.Info($"SENDMNAPI|GETTOKEN|REQUEST HEADERS: {JsonConvert.SerializeObject(request.Parameters.Where(p => p.Type == ParameterType.HttpHeader).Select(p => new { p.Name, p.Value }))}");
_log.Info($"SENDMNAPI|GETTOKEN|REQUEST BODY: {JsonConvert.SerializeObject(requestBody)}");
var response = client.Execute<SendMNAuthResponsetModel>(request);
tokenResponse = response.Data;
//tokenResponse = response.ProcessIdentifier;
if (tokenResponse != null && tokenResponse.Code == "0")
{
tokenResponse.Detail.ExpiryTime = DateTime.UtcNow.AddMinutes(90);
_log.Info($"SENDMNAPI|GETTOKEN|RESPONSE : {JsonConvert.SerializeObject(tokenResponse)}");
}
else
{
_log.Error($"SENDMNAPI|GETTOKEN|ERROR RESPONSE : {JsonConvert.SerializeObject(tokenResponse)}");
}
}
catch (Exception ex)
{
tokenResponse = new SendMNAuthResponsetModel
{
Code = "999",
Detail = new Detail { Note = ex.ToString() }
};
_log.Error($"SENDMNAPI|GETTOKEN|EXCEPTION OCCURRED : {JsonConvert.SerializeObject(tokenResponse)}");
}
return tokenResponse;
}
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;
}
public TPResponse SendTransaction(SendTransaction model)
{
TPResponse txnResponse = new TPResponse();
txnResponse.ResponseCode = "1";
txnResponse.Msg = "Error sending transaction to partner!";
try
{
var exRateResponse = GetExRate(new SendExRateRequestModel
{
RequestBy = model.RequestBy,
});
if (exRateResponse.ResponseCode != "0")
{
txnResponse.ResponseCode = "1";
txnResponse.Msg = exRateResponse.Msg;
_log.Error($"SENDMNAPI|SENDTRANSACTION.GETEXRATE()|RESPONSE : {JsonConvert.SerializeObject(txnResponse)}");
return txnResponse;
}
// If exchange rate retrieval was successful, proceed with sending the transaction
var tokenResponse = GetToken(model.RequestBy);
if (tokenResponse == null || tokenResponse.Code != "0")
{
txnResponse.ResponseCode = "1";
txnResponse.Msg = tokenResponse?.Detail?.Note ?? "Token response is null";
_log.Error($"SENDMNAPI|SENDTRANSACTION.GETTOKEN()|RESPONSE : {JsonConvert.SerializeObject(txnResponse)}");
return txnResponse;
}
// Update the model with exchange rate details
model.Transaction.FOREX_SESSION_ID = exRateResponse.Id;
model.Transaction.ExRate = decimal.Parse(exRateResponse.Extra);
var requestBody = MapSendTxnDetails(model);
if (requestBody == null)
{
txnResponse.ResponseCode = "1";
txnResponse.Msg = "Request body mapping failed";
_log.Error($"SENDMNAPI|SENDTRANSACTION.MAPSENDTXNDETAILS()|RESPONSE : {JsonConvert.SerializeObject(txnResponse)}");
return txnResponse;
}
requestBody.ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier;
requestBody.Signature = GenerateSignature(requestBody, tokenResponse);
_log.Info($"SENDMNAPI|SENDTRANSACTION|REQUEST BODY : {JsonConvert.SerializeObject(requestBody)}");
var client = new RestClient(baseUrl);
var request = new RestRequest("/sendTxn", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + tokenResponse.Detail.Token);
request.AddHeader("UserName", userName);
request.AddHeader("AgentCode", agentCode);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(requestBody);
var TxnResponse = client.Execute<SendMNSendTransactionResponseModel>(request);
if (TxnResponse == null || TxnResponse.Data == null)
{
txnResponse.ResponseCode = "1";
txnResponse.Msg = "Transaction response is null";
_log.Error($"SENDMNAPI|SENDTRANSACTION.EXECUTE()|RESPONSE : {JsonConvert.SerializeObject(txnResponse)}");
return txnResponse;
}
var sendTxnResponse = TxnResponse.Data;
_log.Info($"SENDMNAPI|SENDTRANSACTION|RESPONSE : {TxnResponse.Content}");
if (sendTxnResponse.Code == "0")
{
txnResponse.ResponseCode = "0";//success
txnResponse.Id = sendTxnResponse.Detail.ControlNo;
txnResponse.Extra = exRateResponse.Extra;
}
else
{
txnResponse.ResponseCode = "1";//failed
txnResponse.Extra = sendTxnResponse.Code;
}
txnResponse.Msg = sendTxnResponse.Msg as string ?? sendTxnResponse.Message as string;
txnResponse.Data = sendTxnResponse;
}
catch (Exception ex)
{
txnResponse.ResponseCode = "999";
txnResponse.Msg = ex.ToString();
_log.Error($"SENDMNAPI|SENDTRANSACTION|EXCEPTION OCCURED|RESPONSE : {JsonConvert.SerializeObject(txnResponse)}");
}
return txnResponse;
}
private TPResponse GetStaticData(StaticData model)
{
TPResponse statusResponse = new TPResponse();
statusResponse.ResponseCode = "1";
statusResponse.Msg = "Error fetching transaction status!";
try
{
var tokenResponse = GetToken(model.RequestBy);
if (tokenResponse.Code != "0")
{
statusResponse.ResponseCode = "1";
statusResponse.Msg = tokenResponse.Detail.Note;
_log.Error($"SENDMNAPI|GETSTATUSSENDMN.GETTOKEN()|RESPONSE : {JsonConvert.SerializeObject(statusResponse)}");
return statusResponse;
}
var requestBody = new SendMNStatusRequestModel { Body = new Body { ControlNo = model.ControlNo } };
requestBody.ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier;
requestBody.Signature = GenerateSignatureStatus(requestBody, tokenResponse);
_log.Info($"SENDMNAPI|GETSTATUSSENDMN|REQUEST BODY : {JsonConvert.SerializeObject(requestBody)}");
var client = new RestClient(baseUrl);
var request = new RestRequest("/CheckStatusTxn", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + tokenResponse.Detail.Token);
request.AddHeader("UserName", userName);
request.AddHeader("AgentCode", agentCode);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(requestBody);
var getStatusResponse = client.Execute<SendMNStatusResponseModel>(request).Data;
_log.Info($"SENDMNAPI|GETSTATUSSENDMN|RESPONSE : {JsonConvert.SerializeObject(getStatusResponse)}");
statusResponse.ResponseCode = getStatusResponse.Code;
statusResponse.Msg = getStatusResponse.Message;
if (getStatusResponse.Code == "0")
{
statusResponse.Id = getStatusResponse.Detail.ControlNo;
statusResponse.Extra = getStatusResponse.Detail.PartnerTranNo;
statusResponse.Extra2 = getStatusResponse.Detail.Status;
statusResponse.Extra3 = string.IsNullOrEmpty(getStatusResponse.Detail.PaidDate) ? "" : getStatusResponse.Detail.PaidDate;
}
statusResponse.Data = getStatusResponse;
}
catch (Exception ex)
{
statusResponse.ResponseCode = "999";
statusResponse.Msg = ex.ToString();
_log.Error($"SENDMNAPI|GETSTATUSSENDMN|EXCEPTION OCCURED|RESPONSE : {JsonConvert.SerializeObject(statusResponse)}");
}
return statusResponse;
}
private TPResponse GetStatusSendMN(GetStatus model)
{
TPResponse statusResponse = new TPResponse();
statusResponse.ResponseCode = "1";
statusResponse.Msg = "Error fetching transaction status!";
try
{
var tokenResponse = GetToken(model.RequestBy);
if (tokenResponse.Code != "0")
{
statusResponse.ResponseCode = "1";
statusResponse.Msg = tokenResponse.Detail.Note;
_log.Error($"SENDMNAPI|GETSTATUSSENDMN.GETTOKEN()|RESPONSE : {JsonConvert.SerializeObject(statusResponse)}");
return statusResponse;
}
var requestBody = new SendMNStatusRequestModel { Body = new Body { ControlNo = model.ControlNo } };
requestBody.ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier;
requestBody.Signature = GenerateSignatureStatus(requestBody, tokenResponse);
_log.Info($"SENDMNAPI|GETSTATUSSENDMN|REQUEST BODY : {JsonConvert.SerializeObject(requestBody)}");
var client = new RestClient(baseUrl);
var request = new RestRequest("/CheckStatusTxn", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + tokenResponse.Detail.Token);
request.AddHeader("UserName", userName);
request.AddHeader("AgentCode", agentCode);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(requestBody);
var getStatusResponse = client.Execute<SendMNStatusResponseModel>(request).Data;
_log.Info($"SENDMNAPI|GETSTATUSSENDMN|RESPONSE : {JsonConvert.SerializeObject(getStatusResponse)}");
statusResponse.ResponseCode = getStatusResponse.Code;
statusResponse.Msg = getStatusResponse.Message;
if (getStatusResponse.Code == "0")
{
statusResponse.Id = getStatusResponse.Detail.ControlNo;
statusResponse.Extra = getStatusResponse.Detail.Status;
statusResponse.Extra2 = getStatusResponse.Detail.PartnerTranNo;
statusResponse.Extra3 = string.IsNullOrEmpty(getStatusResponse.Detail.PaidDate) ? "" : getStatusResponse.Detail.PaidDate;
}
statusResponse.Data = getStatusResponse;
}
catch (Exception ex)
{
statusResponse.ResponseCode = "999";
statusResponse.Msg = ex.ToString();
_log.Error($"SENDMNAPI|GETSTATUSSENDMN|EXCEPTION OCCURED|RESPONSE : {JsonConvert.SerializeObject(statusResponse)}");
}
return statusResponse;
}
private TPResponse AccountVerifySendMN(AccountValidate model)
{
TPResponse accountResponse = new TPResponse();
accountResponse.ResponseCode = "1";
accountResponse.Msg = "Error fetching account details!";
try
{
var tokenResponse = GetToken(model.RequestBy);
if (tokenResponse.Code != "0")
{
accountResponse.ResponseCode = "1";
accountResponse.Msg = tokenResponse.Detail.Note;
_log.Error($"SENDMNAPI|ACCOUNTVERIFYSENDMN.GETTOKEN()|RESPONSE : {JsonConvert.SerializeObject(accountResponse)}");
return accountResponse;
}
var requestBody = new SendMNGetAccountNameModel { AccountNo = model.AccountNumber, BankCode = model.BankCode };
requestBody.ProcessIdentifier = tokenResponse.Detail.ProcessIdentifier;
requestBody.Signature = GenerateSignatureAccName(requestBody, tokenResponse);
_log.Info($"SENDMNAPI|ACCOUNTVERIFYSENDMN|REQUEST BODY : {JsonConvert.SerializeObject(requestBody)}");
var client = new RestClient(baseUrl);
var request = new RestRequest("/Common/getAccountName", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + tokenResponse.Detail.Token);
request.AddHeader("UserName", userName);
request.AddHeader("AgentCode", agentCode);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(requestBody);
var accountDetailsResponse = client.Execute<SendMNGResponseNameModel>(request);
var getAccountDetailsResponse = accountDetailsResponse.Data;
_log.Info($"SENDMNAPI|ACCOUNTVERIFYSENDMN|RESPONSE : {accountDetailsResponse.Content}");
accountResponse.ResponseCode = getAccountDetailsResponse.ResponseCode;
accountResponse.Msg = "Success";
if (getAccountDetailsResponse.ResponseCode == "SUCCESS")
{
accountResponse.ResponseCode = "0";
accountResponse.Extra = getAccountDetailsResponse.Data;
accountResponse.Extra2 = model.AccountNumber;
}
else
{
accountResponse.ResponseCode = "1";
accountResponse.Msg = $"{getAccountDetailsResponse.ResponseCode} - {getAccountDetailsResponse.Msg}";
}
accountResponse.Data = getAccountDetailsResponse;
}
catch (Exception ex)
{
accountResponse.ResponseCode = "999";
accountResponse.Msg = ex.ToString();
_log.Error($"SENDMNAPI|ACCOUNTVERIFYSENDMN|EXCEPTION OCCURED|RESPONSE : {JsonConvert.SerializeObject(accountResponse)}");
}
return accountResponse;
}
public SendMNSendTransactionRequestModel MapSendTxnDetails(SendTransaction model)
{
return new SendMNSendTransactionRequestModel
{
Body = new Body
{
Sender = new Sender
{
TransferReason = model.Transaction.PurposeOfRemittanceName,
FundSource = model.Sender.SourceOfFund,
FirstName = model.Sender.SFirstName,
MiddleName = model.Sender.SMiddleName,
LastName = model.Sender.SLastName1,
NativeCountry = model.Sender.SNativeCountry,
City = model.Sender.SCityId,
Address = model.Sender.SCityId,
IdType = model.Sender.SIdType,
idNumber = model.Sender.SIdNo,
Mobile = model.Sender.SMobile,
Email = model.Sender.SEmail
},
Receiver = new Receiver
{
Bank = model.Agent.PBankId,//"MGO394687",
AccountNo = model.Receiver.UnitaryBankAccountNo,//"5431109819",
Relation = model.Receiver.RelWithSenderName,
FirstName = model.Receiver.RFirstName,
MiddleName = model.Receiver.RMiddleName,
LastName = model.Receiver.RLastName,
NativeCountry = model.Receiver.RNativeCountry,
City = model.Receiver.RCity,
Address = model.Receiver.RAdd1,
Mobile = model.Receiver.RMobile
},
Detail = new Detail
{
ForexSSessionId = model.Transaction.FOREX_SESSION_ID,
PartnerTranNo = model.Transaction.JMEControlNo,
PaymentMethod = model.Transaction.PaymentType,
SendingAmount = Convert.ToString(model.Transaction.TAmt),
SendingCurrency = model.Transaction.CollCurr,
SendingCountry = "UK",//model.Sender.SCountryName,
ReceivingAmount = Convert.ToString(model.Transaction.PAmt),
ReceivingCurrency = "MNT",//model.Transaction.PCurr,
ReceivingCountry = "MN",//model.Receiver.RCountry,
ExRate = Convert.ToString(model.Transaction.ExRate)
}
}
};
}
private string GenerateSignature(SendMNSendTransactionRequestModel body, SendMNAuthResponsetModel token)
{
string hashValue = "";
string textToEncrypt = userName + agentCode + body.Body.Sender.TransferReason + body.Body.Sender.FundSource + body.Body.Sender.FirstName + body.Body.Sender.MiddleName
+ body.Body.Sender.LastName + body.Body.Sender.NativeCountry + body.Body.Sender.City + body.Body.Sender.Address + body.Body.Sender.IdType + body.Body.Sender.idNumber
+ body.Body.Sender.Mobile + body.Body.Sender.Email + body.Body.Receiver.Bank + body.Body.Receiver.AccountNo + body.Body.Receiver.Relation + body.Body.Receiver.FirstName
+ body.Body.Receiver.MiddleName + body.Body.Receiver.LastName + body.Body.Receiver.NativeCountry + body.Body.Receiver.City + body.Body.Receiver.Address
+ body.Body.Receiver.Mobile + body.Body.Detail.ForexSSessionId + body.Body.Detail.PartnerTranNo + body.Body.Detail.PaymentMethod + body.Body.Detail.SendingAmount
+ body.Body.Detail.SendingCurrency + body.Body.Detail.SendingCountry + body.Body.Detail.ReceivingAmount + body.Body.Detail.ReceivingCurrency + body.Body.Detail.ReceivingCountry
+ body.Body.Detail.ExRate + token.Detail.ProcessIdentifier;
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(textToEncrypt);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
hashValue = sb.ToString();
}
return hashValue;
}
private string GenerateSignatureExRate(SendExRateRequestModel requestBody, SendMNAuthResponsetModel tokenResponse)
{
string hashValue = "";
string textToEncrypt = userName + agentCode + requestBody.Body.ReceivingCountry + requestBody.Body.SendingCountry + requestBody.Body.ReceivingCurrency + tokenResponse.Detail.ProcessIdentifier;
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(textToEncrypt);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
hashValue = sb.ToString();
}
return hashValue;
}
private string GenerateSignatureStatic(StaticData requestBody, SendMNAuthResponsetModel tokenResponse)
{
string hashValue = "";
string textToEncrypt = userName + agentCode + requestBody.Type + tokenResponse.Detail.ProcessIdentifier;
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(textToEncrypt);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
hashValue = sb.ToString();
}
return hashValue;
}
private string GenerateSignatureStatus(SendMNStatusRequestModel requestBody, SendMNAuthResponsetModel tokenResponse)
{
string hashValue = "";
string textToEncrypt = userName + agentCode + requestBody.Body.ControlNo + tokenResponse.Detail.ProcessIdentifier;
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(textToEncrypt);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
hashValue = sb.ToString();
}
return hashValue;
}
private string GenerateSignatureAccName(SendMNGetAccountNameModel requestBody, SendMNAuthResponsetModel tokenResponse)
{
string hashValue = "";
string textToEncrypt = userName + agentCode;
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(textToEncrypt);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
hashValue = sb.ToString();
}
return hashValue;
}
}
}

6
TPServices/TPServices.csproj

@ -43,10 +43,14 @@
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.7.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -64,6 +68,8 @@
<Compile Include="GCC\Services\GCCAPI.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SendMNRemit\Model\SendMNModel.cs" />
<Compile Include="SendMNRemit\Services\SendMNAPI.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

1
TPServices/packages.config

@ -2,4 +2,5 @@
<packages>
<package id="log4net" version="2.0.8" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" />
<package id="RestSharp" version="106.11.7" targetFramework="net461" />
</packages>

2
ThirdPartyAPIs/ApiControllers/ThirdPartyAPIController.cs

@ -15,11 +15,11 @@ using Common.Models.Status;
using Common.Models.TxnAmendModel;
using Common.Models.TxnModel;
using log4net;
using Newtonsoft.Json;
using System;
using System.Web.Http;
using Common.Utility;
using Common.Models.DigitalSignature;
using Newtonsoft.Json;
namespace ThirdPartyAPIs.ApiControllers
{

34
ThirdPartyAPIs/App_Data/Templates/BANK_TRANSFER_TXN_PENDING.html

@ -2,10 +2,12 @@
<body>
<div style="color:#434444; padding: 15px; font-family: Roboto; font-size: 15px; margin-top: 20px">
<!--<div style="text-align: right;">
<img src="https://japanremit.com/assets/img/jmelogo.jpg" alt="IME London" class="CToWUd" height="90">
</div>-->
<div style="color:#434444; padding: 15px; font-family: Roboto; font-size: 15px; margin-top: 10px">
<div style="text-align: left;">
<img src="https://imelondon.co.uk/assets/images/logo.png" alt="imelondon" class="CToWUd" height="50" width="150" style="height: 50px;width:150;border:0;">
<img src="https://imelondon.co.uk/assets/dist/images/imelondan.svg" alt="imelondon" class="CToWUd" height="50" width="155" style="height: 50px;width:155px;border:0;">
</div>
<br />
<hr style="background-color: #fff; border-top: 1.5px solid #2B3C90; border-bottom: none;" />
@ -13,22 +15,21 @@
<div class="body">
Dear <strong>{CustomerName}</strong>,
<p style="margin-top: 20px">
Thank you for your transaction. Please kindly deposit the total amount of £{CollectAmt} in the following bank account. Your transaction
will be released once the amount is credited in our account with the reference number given below. If we do not get the deposit in two working days,
your transaction will be cancelled. Please note that the transfer amount should exactly match with your transaction amount.<br />
<b>You can now start sending money to your loved ones. </b>
</p>
<p style="margin-top: 20px">
Thank you for your transaction. Please kindly deposit the total amount of £{CollectAmt} in the following bank account. Your transaction
will be released once the amount is credited in our account with the reference number given below. If we do not get the deposit in the end of the day,
your transaction will be cancelled. Please note that the transfer amount should exactly match with your transaction amount.<br />
</p>
<p style="margin-top: 20px">
Our Bank Information<br />
<ol style=" list-style-type: none; /* Remove bullets */ padding: 0; /* Remove padding */ margin-left: 30px; /* Remove margins */">
<li>Bank Name: CLEAR BANK </li>
<li>Account Name: IME LONDON </li>
<li>Sort Code: 04-08-42 </li>
<li>Accoutn Number: 00000042 </li>
<li>Sort Code: 04-06-93 </li>
<li>Account Number: 00000151 </li>
<li>Reference: {CustomerName} </li>
<li><b>Subhida UK Ltd is the registered name of IME London.</b></li>
<!--<li><b>Subhida UK Ltd is the registered name of IME London.</b></li>-->
</ol>
</p>
@ -37,7 +38,12 @@
For further details please visit our website www.imelondon.co.uk<br />
</p>
<p style="margin-top: 20px">
<b>
Note: If you face any problems while transferring money into IME London account due to account validation, please disregard
the notice and proceed with the transaction, as some of the banks may not provide account validation for business accounts.<br />
</b>
</p>
</div>
<p style="margin-top: 20px;">

21
ThirdPartyAPIs/Web.config

@ -56,13 +56,14 @@
<add key="gme_user_name" value="SubidhaSendAPI" />
<add key="gme_password" value="Gmesend@123" />
<add key="gme_partnerId" value="BRNNP9943" />
<add key="gme_key" value="1!VE_#A>DAD#$%%$(8DH|}{+_Privat_)(@(*#@@R_Kops_@ngrY_BD%#DS^6" />
<add key="gme_key" value="1!VE_#A&gt;DAD#$%%$(8DH|}{+_Privat_)(@(*#@@R_Kops_@ngrY_BD%#DS^6" />
<!-- API PartnerId-->
<add key="gmenepal" value="394397" />
<add key="gccremit" value="394449" />
<add key="sendMN" value="394502" />
<!-- END API PartnerId-->
<!--GCC Remit API -->
<!--<add key="gcc_base_url" value="http://demo.api.gccremit.com/SendAPI.svc" />
<add key="gcc_password" value="demo123@" />
@ -76,6 +77,14 @@
<add key="gcc_partnerId" value="11069047" />
<!-- END API PartnerId-->
<!--SendMN Remit API -->
<add key="sendmn_base_url" value="https://sendmnapi.sendmoney.mn/api" />
<add key="sendmn_user_name" value="IME Agent" />
<add key="sendmn_auth_key" value="n2PmKhD1V5IwRdDT5pMeOS/x+W4PH3L4nRxvnCoyVhE=" />
<add key="sendmn_agent_code" value="MGO394732" />
<!--SMS API URL-->
<add key="onewaysmsURL" value="https://api.textmarketer.co.uk/gateway/" />
<add key="onewaysmsURLStatus" value="http://gateway.onewaysms.jp:10001/bulktrx.aspx" />
@ -98,7 +107,7 @@
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" maxRequestLength="16240"/>
<httpRuntime targetFramework="4.6.1" maxRequestLength="16240" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
@ -106,7 +115,7 @@
<system.net>
<mailSettings>
<!--<smtp deliveryMethod="Network" from="no-reply@japanremit.com">-->
<smtp deliveryMethod="Network" from="JME Support &lt;no-reply@japanremit.com&gt;">
<smtp deliveryMethod="Network" from="JME Support &lt;no-reply@japanremit.com&gt;">
<network host="smtp.office365.com" userName="no-reply@japanremit.com" password="Zov68016" port="587" defaultCredentials="false" enableSsl="true" />
</smtp>
</mailSettings>
@ -374,9 +383,7 @@
<dns value="combanksrv.com" />
</identity>
</endpoint>
<endpoint address="http://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/soapnew.ws"
binding="basicHttpBinding" bindingConfiguration="PostcodeAnywhere_Soap"
contract="LoqateApi.PostcodeAnywhere_Soap" name="PostcodeAnywhere_Soap" />
<endpoint address="http://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/soapnew.ws" binding="basicHttpBinding" bindingConfiguration="PostcodeAnywhere_Soap" contract="LoqateApi.PostcodeAnywhere_Soap" name="PostcodeAnywhere_Soap" />
</client>
<behaviors>
<endpointBehaviors>

Loading…
Cancel
Save