Browse Source

Merge branch 'GuavaPay' of http://202.166.220.79:3000/IME-LONDON/ThirdPartyAPI into staging

# Conflicts:
#	TPServices/TPServices.csproj
staging
Leeza Baidar 3 weeks ago
parent
commit
440666b481
  1. 6
      Business/BusinessLogic/TPApiServices/Factory/ApiFactoryServices.cs
  2. 98
      TPServices/GuavaPayRemit/Model/GuavaPayModel.cs
  3. 234
      TPServices/GuavaPayRemit/Services/GuavaPayAPI.cs
  4. 4
      TPServices/TPServices.csproj
  5. 38
      ThirdPartyAPIs/Web.config

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

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

98
TPServices/GuavaPayRemit/Model/GuavaPayModel.cs

@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TPApiServices.GuavaPayRemit.Model
{
public class GuavaPayModel
{
public string clientId { get; set; }
public string secretKey { get; set; }
}
public class AuthResponseModel
{
public string accessToken { get; set; }
public string refreshToken { get; set; }
public string Message { get; set; }
public string Code { get; set; }
public DateTime ExpiryTime { get; set; }
}
public class GuavaSendTransaction
{
public string Country { get; set; }
public string AgentName { get; set; }
public string Amount { get; set; }
public string Currency { get; set; }
public string AgentTransactionId { get; set; }
public string CallBackUrl { get; set; }
public Sender senderClient { get; set; }
public Receiver receiverClient { get; set; }
}
public class Sender
{
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string BirthDate { get; set; }
public string zipCode { get; set; }
public DocumentInfo documentInfo { get; set; }
}
public class DocumentInfo
{
public string DocumentType { get; set; }
public string DocumentNumber { get; set; }
public string RDocumentNumber { get; set; }
public string DocumentIssuedCountry { get; set; }
public string DocumentIssuedDate { get; set; }
public string DocumentEndDate { get; set; }
}
public class Receiver
{
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
public DocumentInfo documentInfo { get; set; }
public AccountInfo accountInfo { get; set; }
}
public class AccountInfo
{
public string AccountNumber { get; set; }
public string BankName { get; set; }
public string BankBranchCode { get; set; }
public string BankCode { get; set; }
}
public class SendTransactionResponse
{
public string Status { get; set; }
public string StatusDescription { get; set; }
public string RRN { get; set; }
public string Fee { get; set; }
public string Rate { get; set; }
public string StatusCode { get; set; }
public string Msg { get; set; }
public string Message { get; set; }
public List<string> Errors { get; internal set; }
}
public class StatusResponseModel
{
public string statusDescription;
public string referenceCode { get; set; }
public string Status { get; set; }
//public Detail Detail { get; set; }
}
}

234
TPServices/GuavaPayRemit/Services/GuavaPayAPI.cs

@ -0,0 +1,234 @@
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.Net;
using System.Text;
using System.Threading.Tasks;
using TPApiServices.GuavaPayRemit.Model;
namespace TPApiServices.GuavaPayRemit.Services
{
public class GuavaPayAPI : ITPApiServices
{
private readonly ILog _log = LogManager.GetLogger(typeof(GuavaPayAPI));
protected string baseUrl { get; set; }
protected string clientId { get; set; }
protected string secretKey { get; set; }
protected string agentCode { get; set; }
public GuavaPayAPI()
{
baseUrl = GetStatic.ReadWebConfig("guavaPay_base_url", "");
clientId = GetStatic.ReadWebConfig("guavaPay_clint_Id", "");
secretKey = GetStatic.ReadWebConfig("guavaPay_secret_key", "");
//agentCode = GetStatic.ReadWebConfig("guavaPay_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 GetStatus(model as GetStatus);
//case "staticData":
// return GetStaticData(model as StaticData);
default:
throw new NotImplementedException();
}
}
private AuthResponseModel GetToken(string user)
{
AuthResponseModel tokenResponse = new AuthResponseModel();
try
{
var requestBody = new GuavaPayModel
{
clientId = clientId,
secretKey = secretKey//"7cf3288cc67d4a2b965a5d41a4005fc1123fa64081"
};
var client = new RestClient(baseUrl);
var request = new RestRequest("/v2/auth", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(requestBody);
_log.Info($"GUAVAPAYAPI|GETTOKEN|REQUEST URL: {client.BaseUrl}{request.Resource}");
_log.Info($"GUAVAPAYAPI|GETTOKEN|REQUEST BODY: {JsonConvert.SerializeObject(requestBody)}");
var response = client.Execute(request);
if (response.StatusCode == HttpStatusCode.OK)
{
tokenResponse = JsonConvert.DeserializeObject<AuthResponseModel>(response.Content);
tokenResponse.ExpiryTime = DateTime.UtcNow.AddMinutes(90);
_log.Info($"GUAVAPAYAPI|GETTOKEN|RESPONSE : {JsonConvert.SerializeObject(tokenResponse)}");
}
else
{
_log.Error($"GUAVAPAYAPI|GETTOKEN|ERROR RESPONSE : {response.Content}");
}
}
catch (Exception ex)
{
tokenResponse = new AuthResponseModel
{
Code = "999"
};
_log.Error($"GUAVAPAYAPI|GETTOKEN|EXCEPTION OCCURRED : {ex}");
}
return tokenResponse;
}
private TPResponse GetStatus(GetStatus model)
{
TPResponse statusResponse = new TPResponse();
var tokenResponse = GetToken(model.RequestBy);
var client = new RestClient(baseUrl);
var request = new RestRequest($"/v2/transactions/{model.PartnerPinNo}/status", Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + tokenResponse.accessToken);
request.RequestFormat = DataFormat.Json;
// request.AddJsonBody(requestBody);
var getStatusResponse = client.Execute<StatusResponseModel>(request).Data;
//var statusres = getStatusResponse.Data;
_log.Info($"GUAVAPAYAPI|GETSTATUSSENDMN|RESPONSE : {JsonConvert.SerializeObject(getStatusResponse)}");
statusResponse.ResponseCode = "0";
statusResponse.Id = getStatusResponse.referenceCode;
statusResponse.Extra2 = getStatusResponse.Status;
statusResponse.Extra4 = getStatusResponse.statusDescription;
statusResponse.Data = getStatusResponse;
return statusResponse;
}
public TPResponse SendTransaction(SendTransaction model)
{
TPResponse txnResponse = new TPResponse();
try
{
var tokenResponse = GetToken(model.RequestBy); // Method to get the token
var requestBody = MapSendTxnDetails(model); // Method to map transaction details
_log.Info($"GUAVAPAYAPI|SENDTRANSACTION|REQUEST BODY : {JsonConvert.SerializeObject(requestBody)}");
var client = new RestClient(baseUrl);
if (model?.Transaction == null || string.IsNullOrEmpty(model.Transaction.PaymentType))
{
throw new ArgumentNullException("Transaction or PaymentType is null or empty.");
}
_log.Info($"GUAVAPAYAPI|SENDTRANSACTION|PAYMENT TYPE : {model.Transaction.PaymentType}");
string endpoint = model.Transaction.PaymentType == "CASH" ? "/v2/payments/cash" : "/v2/payments/account";
var request = new RestRequest(endpoint, Method.POST);
// request = new RestRequest(endpoint, Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + tokenResponse.accessToken);
request.AddJsonBody(requestBody);
request.RequestFormat = DataFormat.Json;
var txnResponseData = client.Execute<SendTransactionResponse>(request);
var sendTxnResponse = txnResponseData.Data;
_log.Info($"GUAVAPAYAPI|SENDTRANSACTION|REQUEST URL: {client.BaseUrl}{request.Resource}");
_log.Info($"GUAVAPAYAPI|SENDTRANSACTION|RESPONSE : {txnResponseData.Content}");
if (sendTxnResponse != null)
{
_log.Info($"GUAVAPAYAPI|SENDTRANSACTION|RESPONSE DATA : {JsonConvert.SerializeObject(sendTxnResponse)}");
if (string.IsNullOrEmpty(sendTxnResponse.RRN) || string.IsNullOrEmpty(sendTxnResponse.Rate) ||
string.IsNullOrEmpty(sendTxnResponse.Status) || string.IsNullOrEmpty(sendTxnResponse.Fee) ||
string.IsNullOrEmpty(sendTxnResponse.StatusDescription))
{
txnResponse.ResponseCode = "1";
txnResponse.Msg = "One or more critical response fields are null.";
_log.Warn($"GUAVAPAYAPI|SENDTRANSACTION|MISSING FIELDS: " +
$"RRN: {sendTxnResponse.RRN}, " +
$"Rate: {sendTxnResponse.Rate}, " +
$"Status: {sendTxnResponse.Status}, " +
$"Fee: {sendTxnResponse.Fee}, " +
$"StatusDescription: {sendTxnResponse.StatusDescription}");
}
else
{
txnResponse.ResponseCode = "0";
txnResponse.Id = sendTxnResponse.RRN;
txnResponse.Extra = sendTxnResponse.Rate;
txnResponse.Extra2 = sendTxnResponse.Status;
txnResponse.Extra3 = sendTxnResponse.Fee;
txnResponse.Extra4 = sendTxnResponse.StatusDescription;
txnResponse.Data = sendTxnResponse;
}
}
else
{
txnResponse.ResponseCode = "1";
txnResponse.Msg = "Response data is null";
_log.Warn($"GUAVAPAYAPI|SENDTRANSACTION|RESPONSE DATA IS NULL");
}
}
catch (Exception ex)
{
txnResponse.ResponseCode = "999";
txnResponse.Msg = ex.ToString();
_log.Error($"GUAVAPAYAPI|SENDTRANSACTION|EXCEPTION OCCURRED|RESPONSE : {JsonConvert.SerializeObject(txnResponse)}");
}
return txnResponse;
}
public GuavaSendTransaction MapSendTxnDetails(SendTransaction model)
{
return new GuavaSendTransaction
{
senderClient = new Sender
{
FirstName = model.Sender.SFirstName,
MiddleName = model.Sender.SMiddleName,
LastName = model.Sender.SLastName1,
Address = model.Sender.SCityId,
BirthDate = model.Sender.SBirthDate,
Phone = model.Sender.SMobile,
zipCode = model.Sender.SZipCode,
documentInfo = new DocumentInfo
{
DocumentType = model.Sender.SIdType,
DocumentNumber = model.Sender.SIdNo,
DocumentIssuedCountry = model.Sender.SCountryName,
DocumentIssuedDate = model.Sender.SIdIssueDate,
DocumentEndDate = model.Sender.SIdExpiryDate,
}
},
receiverClient = new Receiver
{
FirstName = model.Receiver.RFirstName,
MiddleName = model.Receiver.RMiddleName,
LastName = model.Receiver.RLastName,
Phone = model.Receiver.RMobile,
documentInfo = new DocumentInfo
{
DocumentNumber = model.Receiver.RIdNo
},
accountInfo = new AccountInfo
{
AccountNumber = model.Receiver.UnitaryBankAccountNo,// "1312431424141414",
BankName = model.Agent.PBankName, //"MeezanBank"
BankBranchCode = model.Agent.PAgentName,
BankCode = model.Agent.PBranchId
}
},
Country = model.Receiver.RNativeCountry,
AgentName = model.Agent.PBankId, //"MeezanBank",
Amount = Convert.ToString(model.Transaction.PAmt),
AgentTransactionId = model.Transaction.JMEControlNo,
Currency = model.Transaction.PCurr,
CallBackUrl = ""
};
}
}
}

4
TPServices/TPServices.csproj

@ -71,8 +71,8 @@
</Compile>
<Compile Include="GCC\Model\GCCSendMoney.cs" />
<Compile Include="GCC\Services\GCCAPI.cs" />
<Compile Include="IME\Model\BankLists.cs" />
<Compile Include="IME\Model\BankValidation.cs" />
<Compile Include="GuavaPayRemit\Model\GuavaPayModel.cs" />
<Compile Include="GuavaPayRemit\Services\GuavaPayAPI.cs" />
<Compile Include="IME\Model\BranchList.cs" />
<Compile Include="IME\Model\CheckTranStatus.cs" />
<Compile Include="IME\Model\CreateTransaction.cs" />

38
ThirdPartyAPIs/Web.config

@ -17,8 +17,8 @@
<!--<add name="apiConnection" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=FastMoneyPro_Remit;uid=sa;pwd=DbAmin123" providerName="System.Data.SqlClient" />
<add name="LOGDB" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=LogDb;uid=sa;pwd=DbAmin123" providerName="System.Data.SqlClient" />-->
<add name="apiConnection" connectionString="server=77.68.90.58,1433;Database=FastMoneyPro_Remit;uid=remituser;pwd=U78SclK6" providerName="System.Data.SqlClient" />
<add name="LOGDB" connectionString="server=77.68.90.58,1433;Database=LogDb;uid=remituser;pwd=U78SclK6" providerName="System.Data.SqlClient" />
<add name="apiConnection" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=FastMoneyPro_Remit;uid=sa;pwd=DbAmin123" providerName="System.Data.SqlClient" />
<add name="LOGDB" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=LogDb;uid=sa;pwd=DbAmin123" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="apiAccessKey" value="KPb1ttRs3CJnORpVU8SmAKUs7a42vtvjzQ47gU0b4u0vxAEI0PgZref6puzkVhLTX2PRNMGCbnb2TglupsjV5AGhYvw8a8POTcUcFSrEdHmTkhkIGNvUvxSpKjUOXGFQWaGU1bxoqqUSaFOmNE5zGojVmwPoMy38CNLwnpQKjdsIuxCKGCApa2gWHJl9gebmIpUODv9jAZgmMEaXqyR4CLg4iSksfTyYNjdqxEE88P5THYt5GuNk8Ti6K2RxIKfPWY49hBOpiYnXcApgSDiKFYqQG9WuZ7cvDGJIWg5WgWKjGle8Y3OydhONXVkN5OMPXDA4VZkK4c5nM363Zkg4w4qdzWuwhsEoAwU4rej6sMRZue3L0BowBJja1OK0iPoTX70EexX8rviMLOZPUDwhxzkL3eODS69VEEbjHb8WSjhho5h3KnCE4tcqCWihwSZ8Yuyhw1rzIMNw2C8pN1GEJyXc6goIFkf7dmK9ynJSxu52D9GjOkKqoD7dFNFulOFVfgeCuhPDYG2A2c2RSvGHv24VDXvmGVaAMLiPtsTz5oD8f0na7fX1xGg0Qveh0KgQL5THnrMK6gm5Ky7O8nbecIxY" />
@ -62,29 +62,39 @@
<add key="gmenepal" value="394397" />
<add key="gccremit" value="394449" />
<add key="sendMN" value="394502" />
<add key="sendMN" value="394488" /> <!--Uat-->
<add key="guavaPay" value="394490" />
<!--Live-->
<!--<add key="sendMN" value="394502" />-->
<!-- END API PartnerId-->
<!--GCC Remit API -->
<!--<add key="gcc_base_url" value="http://demo.api.gccremit.com/SendAPI.svc" />
<!-- GCC UAT-->
<add key="gcc_base_url" value="http://demo.api.gccremit.com/SendAPI.svc" />
<add key="gcc_password" value="demo123@" />
<add key="gcc_securityKey" value="6HumnMSbNxltKc8UmOJ/mA==" />
<add key="gcc_partnerId" value="06327532" />-->
<add key="gcc_partnerId" value="06327532" />
<add key="gcc_base_url" value="https://api.gccremit.com/SendAPI.svc" />
<!-- GCC Live-->
<!--<add key="gcc_base_url" value="https://api.gccremit.com/SendAPI.svc" />
<add key="gcc_password" value="welcome123@" />
<add key="gcc_securityKey" value="t4W6KciZOZmpiH+9xcl7ng==" />
<add key="gcc_partnerId" value="11069047" />
<add key="gcc_partnerId" value="11069047" />-->
<!-- END API PartnerId-->
<!--Guava Pay Remit API -->
<add key="guavaPay_base_url" value="https://test.remiton.pro/api" />
<add key="guavaPay_clint_Id" value="f3d564dadcb5a4fe9ed0c06da6e3bb5785405bbf" />
<add key="guavaPay_secret_key" value="7cf3288cc67d4a2b965a5d41a4005fc1123fa64081" />
<!--SendMN Remit API -->
<add key="sendmn_base_url" value="https://sendmnapi.sendmoney.mn/api" />
<!--SendMN Remit API UAT -->
<add key="sendmn_base_url" value="http://dev-server-sendmn.eastus.cloudapp.azure.com/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" />
<!--SendMN Remit API Live -->
<!--<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" />
<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" />

Loading…
Cancel
Save