You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
357 lines
19 KiB
357 lines
19 KiB
using Business.BusinessLogic.TPApiServices.TPServices;
|
|
using Common.Models;
|
|
using Common.Models.Address;
|
|
using Common.Models.Agent;
|
|
using Common.Models.Bank;
|
|
using Common.Models.Bank_Account;
|
|
using Common.Models.Notification;
|
|
using Common.Models.ExchangeRate;
|
|
using Common.Models.Payer;
|
|
using Common.Models.RequestResponse;
|
|
using Common.Models.Sender;
|
|
using Common.Models.SendSMS;
|
|
using Common.Models.SendTransactionMobile;
|
|
using Common.Models.Status;
|
|
using Common.Models.TxnAmendModel;
|
|
using Common.Models.TxnModel;
|
|
using log4net;
|
|
using System;
|
|
using System.Web.Http;
|
|
using Common.Utility;
|
|
using Common.Models.DigitalSignature;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace ThirdPartyAPIs.ApiControllers
|
|
{
|
|
[RoutePrefix("api/v1")]
|
|
public class ThirdPartyAPIController : ApiController
|
|
{
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(ThirdPartyAPIController));
|
|
private readonly ThirdPartyServices _sendTxnServices;
|
|
|
|
public ThirdPartyAPIController(ThirdPartyServices sendTxnServices)
|
|
{
|
|
_sendTxnServices = sendTxnServices;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("Tp/ping")]
|
|
public IHttpActionResult Ping()
|
|
{
|
|
_log.Debug("Ping " + JsonConvert.SerializeObject("Mobile Api Call Successfully"));
|
|
return Ok(new TPResponse() { Id = "1", Msg = "Mobile Api Call Successfully" });
|
|
}
|
|
|
|
[Route("TP/SMSApi")]
|
|
[HttpPost]
|
|
public IHttpActionResult SendSMSApi(SMSRequestModel model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = string.IsNullOrEmpty(model.ControlNo) ? model.MobileNumber : model.ControlNo;
|
|
LogicalThreadContext.Properties["MethodName"] = "SendSMSApi";
|
|
_log.Debug("SendSMSApi Request: " + JsonConvert.SerializeObject(model));
|
|
var response = _sendTxnServices.GetTPResponse(model, "SMSApi");
|
|
_log.Debug("SendSMSApi Response: " + JsonConvert.SerializeObject(response));
|
|
|
|
return Json(response);
|
|
}
|
|
|
|
[Route("TP/ExRate")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetExRate(ExchangeRate model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName ?? model.RequestedBy;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["MethodName"] = "GetExRate";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("ExRate Request: " + JsonConvert.SerializeObject(model));
|
|
var response = _sendTxnServices.GetTPResponse(model, "exRate");
|
|
_log.Debug("GetExRate Response: " + JsonConvert.SerializeObject(response));
|
|
return Json(response);
|
|
}
|
|
|
|
[Route("TP/GetStatus")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetStatus(GetStatus model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.ControlNo;
|
|
LogicalThreadContext.Properties["MethodName"] = "GetStatus";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("GetStatus Request: " + JsonConvert.SerializeObject(model));
|
|
var response = _sendTxnServices.GetTPResponse(model, "status");
|
|
_log.Debug("GetStatus Response: " + JsonConvert.SerializeObject(response));
|
|
return Json(response);
|
|
}
|
|
|
|
[Route("TP/sendTxn")]
|
|
[HttpPost]
|
|
public IHttpActionResult SendTransaction(SendTransaction model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.Transaction.JMEControlNo;
|
|
LogicalThreadContext.Properties["MethodName"] = "SendTransaction";
|
|
LogicalThreadContext.Properties["user_name"] = model.TranId;
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("SendTransaction Request: " + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "send");
|
|
LogicalThreadContext.Properties["MethodName"] = "SendTransaction";
|
|
_log.Debug("SendTransaction Response: " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/mobileSendTxn")]
|
|
[HttpPost]
|
|
public IHttpActionResult OnlineOrMobileSendTransaction(SendTransactionMobile model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.RequestedBy;
|
|
LogicalThreadContext.Properties["MethodName"] = "OnlineOrMobileSendTransaction";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("OnlineOrMobileSendTransaction Request: " + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "sendV2");
|
|
_log.Debug("OnlineOrMobileSendTransaction Response: " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/releaseTxn")]
|
|
[HttpPost]
|
|
public IHttpActionResult ReleaseTransaction(TFReleaseTxnRequest model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName ?? model.RequestBy;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.TfPin;
|
|
LogicalThreadContext.Properties["MethodName"] = "ReleaseTransaction";
|
|
_log.Debug("Transaction release initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "release");
|
|
_log.Debug("Transaction release Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/cancelTxn")]
|
|
[HttpPost]
|
|
public IHttpActionResult CancelTransaction(CancelTxn model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.PartnerPinNo;
|
|
LogicalThreadContext.Properties["MethodName"] = "CancelTransaction";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("CancelTransaction initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "cancelSend");
|
|
_log.Debug("CancelTransaction Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/amendTxn")]
|
|
[HttpPost]
|
|
public IHttpActionResult AmendmentRequest(AmendTransaction model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.TfPinno;
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
LogicalThreadContext.Properties["MethodName"] = "AmendmentRequest";
|
|
_log.Debug("AmendmentRequest initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "amendment");
|
|
_log.Debug("AmendmentRequest Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/bankList")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetBankList(BankRequest model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["MethodName"] = "GetBankList";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
_log.Debug("GetBankList initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "bankList");
|
|
//_log.Debug("GetBankList Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/agentList")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetAgentList(AgentRequest model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["MethodName"] = "GetAgentList";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
_log.Debug("GetAgentList initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "agentList");
|
|
//_log.Debug("GetAgentList Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/addressList")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetAddressList(AddressRequest model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["MethodName"] = "GetAddressList";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("GetAgentList initiated" + JsonConvert.SerializeObject(model));
|
|
|
|
string method = "address";
|
|
if (model.MethodType!=null && model.MethodType.Equals("loqate"))
|
|
{
|
|
method = "loqate";
|
|
}
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, method);
|
|
//_log.Debug("GetAgentList Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/senderInfo")]
|
|
[HttpPost]
|
|
public IHttpActionResult SenderInformation(SenderRequest model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("SenderInformation initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "senderinfo");
|
|
//_log.Debug("GetAgentList Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/getData")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetStaticData(StaticData model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("SenderInformation initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "staticData");
|
|
//_log.Debug("GetAgentList Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
[Route("TP/payer")]
|
|
[HttpPost]
|
|
public IHttpActionResult GetPayerData(PayerRequest model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["MethodName"] = "GetPayerData";
|
|
//if (string.IsNullOrEmpty(model.SessionId) || string.IsNullOrWhiteSpace(model.SessionId))
|
|
// model.SessionId = GetStatic.GetSessionId();
|
|
_log.Debug("SenderInformation initiated" + JsonConvert.SerializeObject(model));
|
|
TPResponse response = _sendTxnServices.GetTPResponse(model, "payer");
|
|
//_log.Debug("GetAgentList Response " + JsonConvert.SerializeObject(response));
|
|
return Ok(response);
|
|
}
|
|
|
|
|
|
[Route("TP/Verify")]
|
|
[HttpPost]
|
|
public IHttpActionResult VerifyAccount(AccountValidate model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ProcessId))
|
|
model.ProcessId = Guid.NewGuid().ToString();
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = string.IsNullOrEmpty(model.ControlNo) ? model.AccountNumber : model.ControlNo;
|
|
LogicalThreadContext.Properties["MethodName"] = "VerifyAccount";
|
|
_log.Debug("VerifyAccount Request: " + JsonConvert.SerializeObject(model));
|
|
var response = _sendTxnServices.GetTPResponse(model, "verify");
|
|
_log.Debug("VerifyAccount Response: " + JsonConvert.SerializeObject(response));
|
|
|
|
return Json(response);
|
|
}
|
|
[Route("TP/NotificationAPI")]
|
|
[HttpPost]
|
|
public IHttpActionResult SendNotificationApi(SendNotificationRequest model)
|
|
{
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.ControlNo;
|
|
LogicalThreadContext.Properties["client_ip_address"] = new GetClientIpAddress().GetIpAddress(Request);
|
|
LogicalThreadContext.Properties["MethodName"] = "SendNotificationApi";
|
|
|
|
_log.Debug("SendNotificationApi Request: " + JsonConvert.SerializeObject(model));
|
|
|
|
var response = _sendTxnServices.GetTPResponse(model, "SendNotificationApi");
|
|
_log.Debug("SendNotificationApi Response: " + JsonConvert.SerializeObject(response));
|
|
return Json(response);
|
|
}
|
|
|
|
[Route("TP/JWTHelper")]
|
|
[HttpPost]
|
|
public IHttpActionResult JWTHelper(JWTRequest model)
|
|
{
|
|
LogicalThreadContext.Properties["processId"] = model.ProcessId;
|
|
LogicalThreadContext.Properties["requestBy"] = model.UserName;
|
|
LogicalThreadContext.Properties["Provider"] = model.ProviderId;
|
|
LogicalThreadContext.Properties["ControlNo"] = model.ControlNo;
|
|
LogicalThreadContext.Properties["client_ip_address"] = new GetClientIpAddress().GetIpAddress(Request);
|
|
LogicalThreadContext.Properties["MethodName"] = "JWTHelper";
|
|
_log.Debug("JWTHelper Request: " + JsonConvert.SerializeObject(model));
|
|
var response = _sendTxnServices.GetTPResponse(model, "JWTHelper");
|
|
_log.Debug("JWTHelper Response: " + JsonConvert.SerializeObject(response));
|
|
return Json(response);
|
|
}
|
|
}
|
|
}
|