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.

667 lines
29 KiB

1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
  1. using Business.KFTCBusiness;
  2. using Business.TPApi;
  3. using Business.Utility;
  4. using Common;
  5. using Common.Helper;
  6. using Common.Language;
  7. using Common.Model;
  8. using Common.Model.Config;
  9. using Common.Model.Notification;
  10. using Common.Model.SendMoney;
  11. using Common.Model.TPSendMoney;
  12. using log4net;
  13. using Newtonsoft.Json;
  14. using PushNotification;
  15. using Repository.Coupon;
  16. using Repository.Mobile;
  17. using Repository.Reward;
  18. using Repository.SendMoney;
  19. using System;
  20. using System.Collections.Generic;
  21. using System.Configuration;
  22. using System.IO;
  23. using System.Runtime.Remoting.Messaging;
  24. using System.Text;
  25. using System.Threading.Tasks;
  26. using System.Web;
  27. using Notify = Common.Model.Notification;
  28. namespace Business.SendMoney
  29. {
  30. public class SendMoneyBusiness : ISendMoneyBusiness
  31. {
  32. private readonly ISendMoneyRepository _repo;
  33. private readonly IKftcProcessBusiness _kftcBuss;
  34. private readonly IRewardRepository _irewardrepo;
  35. private readonly ICouponRepository icouponrepo;
  36. private readonly IMobileServicesRepo _requestServices;
  37. private readonly ThirdPartyAPI _tpApi = new ThirdPartyAPI();
  38. private static readonly ILog Log = LogManager.GetLogger(typeof(SendMoneyBusiness));
  39. public SendMoneyBusiness(ISendMoneyRepository repo, IKftcProcessBusiness kftcBuss, IRewardRepository irewardrepo, ICouponRepository icouponrepo, IMobileServicesRepo requestServices)
  40. {
  41. _repo = repo;
  42. _kftcBuss = kftcBuss;
  43. _irewardrepo = irewardrepo;
  44. this.icouponrepo = icouponrepo;
  45. _requestServices = requestServices;
  46. }
  47. public JsonRxResponse LoadCountryServiceDetail(CountryServiceModel request)
  48. {
  49. JsonRxResponse jsonRx = new JsonRxResponse();
  50. try
  51. {
  52. jsonRx.SetResponse("1", "Error");
  53. CountryServiceDetail res = _repo.LoadCountryServiceDetail(request);
  54. if (res == null)
  55. {
  56. Log.Debug("LoadCountryServiceDetail | Returning null while fetching country service details.");
  57. return jsonRx;
  58. }
  59. Log.Debug("LoadCountryServiceDetail | Calling LoadCountryServiceDetail Success...");
  60. jsonRx.SetResponse("0", "Success");
  61. var path = GetStatic.ReadWebConfig("ServiceType_Resource", "");
  62. var text = File.ReadAllText(path);
  63. List<ServiceTypeDetails> sd = JsonConvert.DeserializeObject<List<ServiceTypeDetails>>(text);
  64. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  65. if (string.IsNullOrEmpty(lang))
  66. {
  67. lang = "en";
  68. }
  69. var idx = sd.FindIndex(x => x.countryCode == lang);
  70. var data = new ServiceTypeDetails();
  71. if (idx < 0)
  72. {
  73. data = sd[sd.FindIndex(x => x.countryCode == "en")];
  74. }
  75. else
  76. {
  77. data = sd[idx];
  78. }
  79. foreach (var item in res.PayoutMode)
  80. {
  81. switch (item.Mode.ToLower())
  82. {
  83. case "cash payment":
  84. item.ModeDescription = data.cashPayment;
  85. break;
  86. case "bank deposit":
  87. item.ModeDescription = data.bankDeposit;
  88. break;
  89. case "mobile wallet":
  90. item.ModeDescription = data.mobileWallet;
  91. break;
  92. case "home delivery":
  93. item.ModeDescription = data.homeDelivery;
  94. break;
  95. case "card payment":
  96. item.ModeDescription = data.cardPayment;
  97. break;
  98. }
  99. }
  100. jsonRx.Data = res;
  101. return jsonRx;
  102. }
  103. catch (Exception ex)
  104. {
  105. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  106. jsonRx.SetResponse("1", "Unable to fetch the country service details.");
  107. return jsonRx;
  108. }
  109. }
  110. public JsonRxResponse LoadBankBranch(string country, string bank, string search)
  111. {
  112. JsonRxResponse jsonRx = new JsonRxResponse();
  113. try
  114. {
  115. jsonRx.SetResponse("1", "Sorry, No branch found.");
  116. List<BankBranch> res = _repo.LoadBankBranch(country, bank, search);
  117. if (res == null)
  118. {
  119. Log.Debug("LoadCountryBankServiceDetail | Returning null while fetching the list of bank branches details.");
  120. return jsonRx;
  121. }
  122. Log.Debug("LoadBankBranch | DB Call Success..");
  123. jsonRx.SetResponse("0", "Success");
  124. jsonRx.Data = res;
  125. return jsonRx;
  126. }
  127. catch (Exception ex)
  128. {
  129. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  130. jsonRx.SetResponse("1", "Unable to fetch the list of bank branches details.");
  131. return jsonRx;
  132. }
  133. }
  134. public JsonRxResponse Calculate(ExRateCalculateRequest m)
  135. {
  136. JsonRxResponse response = new JsonRxResponse();
  137. APIJsonResponse jsonResponse = new APIJsonResponse();
  138. try
  139. {
  140. ExRateCalculate model = new ExRateCalculate()
  141. {
  142. SBranch = Convert.ToInt32(GetStatic.ReadWebConfig("sBranch", "")),
  143. SSuperAgent = Convert.ToInt32(GetStatic.ReadWebConfig("sSuperAgent", "")),
  144. AgentRefId = "",
  145. CalcBy = m.calcBy,
  146. CAmount = Convert.ToDecimal(m.cAmount == "" ? "0" : m.cAmount),
  147. CardOnline = "",
  148. CollCurrency = m.sCurrency,
  149. CouponCode = m.DeviceType,
  150. CustomerId = 0,
  151. IsManualSc = false,
  152. IsOnline = false,
  153. ManualSc = 0,
  154. PAgentId = Convert.ToInt32(m.pAgent == "" ? "0" : m.pAgent),
  155. PAgentName = "",
  156. PAmount = Convert.ToDecimal(m.pAmount == "" ? "0" : m.pAmount),
  157. PaymentType = m.paymentType,
  158. PayoutPartner = Convert.ToInt32(m.payoutPartner == "" ? "0" : m.payoutPartner),
  159. PCountry = Convert.ToInt32(m.pCountry == "" ? "0" : m.pCountry),
  160. pCountryCode = m.pCountryName,
  161. PCountryName = m.pCountryName,
  162. PCurrency = m.pCurrency,
  163. ProcessFor = "send",
  164. ProcessId = m.processId == "" ? Guid.NewGuid().ToString() : m.processId,
  165. ProviderId = "",
  166. RequestedBy = "mobile",
  167. SAgent = 0,
  168. SchemeId = m.schemeId,
  169. SCountry = Convert.ToInt32(m.sCountry == "" ? "0" : m.sCountry),
  170. SCurrency = m.sCurrency,
  171. ServiceType = m.serviceType,
  172. SessionId = Guid.NewGuid().ToString(),
  173. tPExRate = m.tpExRate,
  174. UserName = m.userId,
  175. DiscountedFee = Convert.ToDecimal(string.IsNullOrEmpty(m.discountedFee) ? "0" : m.discountedFee)
  176. };
  177. Log.Debug("Calculate | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(model));
  178. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<ExRateCalculate, APIJsonResponse>(model, "TP/ExRate", out jsonResponse);
  179. Log.Debug("Calculate | TPAPI RRESPONSE : " + JsonConvert.SerializeObject(result));
  180. response = new JsonRxResponse()
  181. {
  182. ErrorCode = result.ResponseCode,
  183. Id = result.Id,
  184. Msg = result.Msg,
  185. Data = result.Data,
  186. Extra = result.Extra,
  187. Extra2 = result.Extra1,
  188. FootNoteMessage = result.FootNoteMessage
  189. };
  190. return response;
  191. }
  192. catch (Exception ex)
  193. {
  194. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  195. response.SetResponse("1", "Error occured while calculating ex-rate");
  196. return response;
  197. }
  198. }
  199. public JsonRxResponse TrackTransaction(TrackTransactionParam param)
  200. {
  201. JsonRxResponse jsonRx = new JsonRxResponse();
  202. try
  203. {
  204. jsonRx = _repo.TrackTransaction(param);
  205. Log.Debug("TrackTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  206. if (!jsonRx.ErrorCode.Equals("0"))
  207. {
  208. Log.Debug("TrackTransaction | Error occurred while calling TrackTransaction..." + "ControlNo: " + param.ControlNo);
  209. return jsonRx;
  210. }
  211. return jsonRx;
  212. }
  213. catch (Exception ex)
  214. {
  215. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  216. jsonRx.SetResponse("1", "Error occurred while fetching the paystatus of the transaction.");
  217. return jsonRx;
  218. }
  219. }
  220. public JsonRxResponse AmendTransaction(TrackTransactionParam param)
  221. {
  222. JsonRxResponse jsonRx = new JsonRxResponse();
  223. try
  224. {
  225. jsonRx = _repo.AmendTransaction(param);
  226. Log.Debug("AmendTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  227. if (!jsonRx.ErrorCode.Equals("0"))
  228. {
  229. return jsonRx;
  230. }
  231. string body = "Hello JME Support, <br>";
  232. body += param.UserId + " Send Amendment request for JME No: " + param.ControlNo;
  233. body += param.Body;
  234. //EmailParameters _emailParams = new EmailParameters()
  235. //{
  236. // To = ApplicationConfig.ReadWebConfig("JMESupport"),
  237. // MsgSubject = "Amendment request for JME No: " + param.ControlNo,
  238. // MsgBody = body
  239. //};
  240. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  241. //Task.Run(() =>
  242. //{
  243. // SendNotificationRequest request = new SendNotificationRequest()
  244. // {
  245. // IsBulkNotification = false,
  246. // UserName = param.UserId,
  247. // ProcessId = param.ControlNo,
  248. // ProviderId = param.ControlNo,
  249. // NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  250. // Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD,
  251. // Recipients = new List<RecipientViewModel>()
  252. // {
  253. // new RecipientViewModel()
  254. // {
  255. // NotificationContent = new NotificationDTO() {
  256. // Body = body,
  257. // //Title will be set by mapping json
  258. // },
  259. // Address= ApplicationConfig.ReadWebConfig("JMESupport")
  260. // }
  261. // }
  262. // };
  263. // NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  264. //});
  265. return jsonRx;
  266. }
  267. catch (Exception ex)
  268. {
  269. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  270. jsonRx.SetResponse("1", "Error occurred while requesting the transaction amendment request.");
  271. return jsonRx;
  272. }
  273. }
  274. public JsonRxResponse AmendTransactionV2(AmendTransactionParam param)
  275. {
  276. JsonRxResponse jsonRx = new JsonRxResponse();
  277. try
  278. {
  279. var xml = GetXMLValues(param);
  280. jsonRx = _repo.AmendTransactionV2(param, xml);
  281. Log.Debug("AmendTransactionV2 | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  282. if (!jsonRx.ErrorCode.Equals("0"))
  283. {
  284. return jsonRx;
  285. }
  286. //string body = "Hello JME Support, <br>";
  287. //body += param.UserId + " Send Amendment request for JME No: " + param.ControlNo;
  288. //body += param.Body;
  289. //EmailParameters _emailParams = new EmailParameters()
  290. //{
  291. // To = ApplicationConfig.ReadWebConfig("JMESupport"),
  292. // MsgSubject = "Amendment request for JME No: " + param.ControlNo,
  293. // MsgBody = body
  294. //};
  295. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  296. return jsonRx;
  297. }
  298. catch (Exception ex)
  299. {
  300. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  301. jsonRx.SetResponse("1", "Error occurred while requesting the transaction amendment request.");
  302. return jsonRx;
  303. }
  304. }
  305. private string GetXMLValues(AmendTransactionParam param)
  306. {
  307. StringBuilder sb = new StringBuilder("<root>");
  308. foreach (var item in param.ChangeParams)
  309. {
  310. sb.Append("<row");
  311. sb.Append(string.Format(" CloumnName=\"{0}\" ColumnValue=\"{1}\"", item.Key, item.Value));
  312. sb.Append(" />");
  313. }
  314. sb.AppendLine("</root>");
  315. return sb.ToString();
  316. }
  317. public JsonRxResponse CancelTransaction(TrackTransactionParam param)
  318. {
  319. JsonRxResponse jsonRx = new JsonRxResponse();
  320. try
  321. {
  322. jsonRx = _repo.CancelTransaction(param);
  323. Log.Debug("CancelTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  324. if (!jsonRx.ErrorCode.Equals("0"))
  325. {
  326. return jsonRx;
  327. }
  328. //string body = "Hello JME Support, <br>";
  329. //body += param.UserId + " Send cancellation request for JME No: " + param.ControlNo;
  330. //body += param.Body;
  331. //EmailParameters _emailParams = new EmailParameters()
  332. //{
  333. // To = ApplicationConfig.ReadWebConfig("JMESupport"),
  334. // MsgSubject = "Cancellation request for JME No: " + param.ControlNo,
  335. // MsgBody = body
  336. //};
  337. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  338. return jsonRx;
  339. }
  340. catch (Exception ex)
  341. {
  342. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  343. jsonRx.SetResponse("1", "Error occurred while requesting the transaction cancel.");
  344. return jsonRx;
  345. }
  346. }
  347. public JsonRxResponse RejectTransaction(RejectTransactionParam param)
  348. {
  349. JsonRxResponse jsonRx = new JsonRxResponse();
  350. //JsonRxResponse response = new JsonRxResponse();
  351. APIJsonResponse jsonResponse = new APIJsonResponse();
  352. try
  353. {
  354. DbResult _dbRes = _repo.GetTxnApproveData(param.UserId, param.TranId);
  355. Log.Debug("RejectTransaction | GetTxnApproveData RESPONSE : " + JsonConvert.SerializeObject(_dbRes));
  356. if (_dbRes.Extra == "True" || _dbRes.Extra == "1")//is realtime
  357. {
  358. CancelTxnPartner model = new CancelTxnPartner()
  359. {
  360. ProviderId = _dbRes.Msg,
  361. PartnerPinNo = _dbRes.Id,
  362. CancelReason = "41",
  363. ProcessId = param.ProcessId
  364. };
  365. Log.Debug("RejectTransaction | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(model));
  366. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<CancelTxnPartner, APIJsonResponse>(model, "TP/cancelTxn", out jsonResponse);
  367. Log.Debug("RejectTransaction | TPAPI RRESPONSE : " + JsonConvert.SerializeObject(result));
  368. if (result.ResponseCode == "0")
  369. {
  370. jsonRx = _repo.RejectTransaction(param);
  371. }
  372. else
  373. {
  374. jsonRx = new JsonRxResponse()
  375. {
  376. ErrorCode = result.ResponseCode,
  377. Id = result.Id,
  378. Msg = result.Msg,
  379. Data = result.Data,
  380. Extra = result.Extra,
  381. Extra2 = result.Extra1
  382. };
  383. }
  384. return jsonRx;
  385. }
  386. else
  387. {
  388. jsonRx = _repo.RejectTransaction(param);
  389. Log.Debug("RejectTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  390. }
  391. return jsonRx;
  392. }
  393. catch (Exception ex)
  394. {
  395. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  396. jsonRx.SetResponse("1", "Error occurred while rejecting the transaction.");
  397. return jsonRx;
  398. }
  399. }
  400. public Common.Model.DbResult CheckLoginPassword(string user, string txnPassword, string paymentType, string customerId)
  401. {
  402. return _repo.CheckLoginPassword(user, txnPassword, paymentType, customerId);
  403. }
  404. public Common.Model.DbResult CheckLoginPIN(string user, string txnPassword, string paymentType, string customerId)
  405. {
  406. return _repo.CheckLoginPIN(user, txnPassword, paymentType, customerId);
  407. }
  408. public JsonRxResponse SendTransaction(MobileRemitRequest model)
  409. {
  410. JsonRxResponse response = new JsonRxResponse();
  411. APIJsonResponse jsonResponse = new APIJsonResponse();
  412. try
  413. {
  414. TpSendMoney tp = new TpSendMoney()
  415. {
  416. CalBy = model.CalBy,
  417. CDDI = new CustomerDueDiligence()
  418. {
  419. PurposeOfRemittance = model.PurposeOfRemittance,
  420. RelWithSender = model.RelWithSender,
  421. SourceOfFund = model.SourceOfFund,
  422. otherPurposeOfRemittance = model.otherPurposeOfRemittance,
  423. otherSourceOfFund = model.otherSourceOfFund,
  424. GoodsOrigin = model.GoodsOrigin,
  425. GoodsType = model.GoodsType,
  426. PortOfShipment = model.PortOfShipment
  427. },
  428. CollAmt = model.CollAmt,
  429. CollCurr = model.CollCurr,
  430. DeliveryMethodId = Convert.ToInt32(model.DeliveryMethodId == "" || model.DeliveryMethodId == null ? "0" : model.DeliveryMethodId),
  431. ExRate = model.ExRate,
  432. ForexSessionId = model.FOREX_SESSION_ID,
  433. IsRealtime = false,
  434. PaymentType = model.PaymentType,
  435. PayoutAmt = model.PayoutAmt == "" ? "0" : model.PayoutAmt,
  436. PayoutCurr = model.PCurr,
  437. PayOutPartnerId = Convert.ToInt32(model.PayOutPartner == "" || model.PayOutPartner == null ? "0" : model.PayOutPartner),
  438. // PBankId = model.DeliveryMethodId == "2" ? Convert.ToInt32(model.PAgent == "" || model.PAgent == null ? "0" : model.PAgent) : 0,
  439. PBankId = Convert.ToInt32(model.PAgent == "" || model.PAgent == null ? "0" : model.PAgent),
  440. PBranchId = Convert.ToInt32(model.PBranch == "" || model.PBranch == null ? "0" : model.PBranch),
  441. PCountryId = 0,
  442. ProcessId = model.ProcessId,
  443. ProviderId = "",
  444. Receiver = new ReceiverInfo() { ReceiverId = model.ReceiverId, AccountNo = model.ReceiverAccountNo },
  445. RequestedBy = "mobile",
  446. ScDiscount = model.Discount,
  447. //SchemeId = model.schemeId,
  448. SCountryId = 0,
  449. SenderId = model.SenderId,
  450. ServiceCharge = model.ServiceCharge,
  451. SessionId = "",
  452. SIpAddress = model.IpAddress,
  453. SourceType = "",
  454. TpExRate = model.TpExRate,
  455. TpPCurr = model.TpPCurr,
  456. TransferAmt = model.TransferAmt,
  457. UserName = model.User,
  458. DiscountedFee = model.DiscountedFee,
  459. SiteId = ConfigurationManager.AppSettings["sitereference"].ToString()
  460. };
  461. Log.Debug("DOTRANSACTION | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(tp));
  462. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<TpSendMoney, APIJsonResponse>(tp, "TP/mobileSendTxn", out jsonResponse);
  463. Log.Debug("DOTRANSACTION | TPAPI RESPONSE : " + JsonConvert.SerializeObject(result));
  464. response = new JsonRxResponse()
  465. {
  466. ErrorCode = result.ResponseCode,
  467. Id = result.Id,
  468. Msg = result.Msg,
  469. Data = result.Data,
  470. Extra = result.Extra,
  471. Extra2 = result.Extra2,
  472. Extra3 = result.Extra3,
  473. Extra4 = result.Extra4
  474. };
  475. if (response.ErrorCode.Equals("0"))
  476. {
  477. //var randomPassword = PasswordGenerator.GenerateRandomPassword(new PasswordGenerator.PasswordOptions()
  478. //{ RequireDigit = true, RequiredLength = 10, RequiredUniqueChars = 2, RequireLowercase = true, RequireNonAlphanumeric = true, RequireUppercase = true });
  479. string eID = HttpUtility.UrlEncode(AesOperation.EncryptString(ConfigurationManager.AppSettings["encryptKey"].ToString(), result.Id));
  480. string eCn = HttpUtility.UrlEncode(AesOperation.EncryptString(ConfigurationManager.AppSettings["encryptKey"].ToString(), result.Extra));
  481. var trustpaymentCallback = ApplicationConfig.ReadWebConfig("trustpaymentCallback");
  482. var trustpaymentSuccess = ApplicationConfig.ReadWebConfig("trustpaymentSuccess");
  483. var trustpaymentFail = ApplicationConfig.ReadWebConfig("trustpaymentFail");
  484. Gateway gateway = new Gateway()
  485. {
  486. Code = result.Extra2,
  487. IsRedirect = result.Extra3.Equals("Y") ? true : false,
  488. //Token = randomPassword,
  489. RedirectURL = result.Extra3.Equals("Y") ? $"{trustpaymentCallback}?id={eID}&ref={response.Extra4}&cn={eCn}&token=" : "",
  490. CheckSuccessURL = result.Extra3.Equals("Y") ? trustpaymentSuccess : "",
  491. CheckFailURL = result.Extra3.Equals("Y") ? trustpaymentFail : ""
  492. };
  493. response.Data = gateway;
  494. string email = model.User;
  495. try
  496. {
  497. if (!result.Extra3.Equals("Y"))
  498. {
  499. UserDetails userDetails = _requestServices.GetUserDetails(email);
  500. List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
  501. bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = userDetails.FullName });
  502. bodyMappings.Add(new Notify.Mapping() { SValue = "CollectAmt", SText = GetStatic.ShowDecimal(model.CollAmt) });
  503. SendNotificationRequest request = new SendNotificationRequest()
  504. {
  505. IsBulkNotification = false,
  506. UserName = userDetails.Email,
  507. ProviderId = "BankTransferTxnPendingStatus",
  508. NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  509. Template = Common.Model.Enum.NotifyTemplate.BANK_TRANSFER_TXN_PENDING,
  510. Recipients = new List<RecipientViewModel>()
  511. {
  512. new RecipientViewModel()
  513. {
  514. NotificationContent = new NotificationDTO() {
  515. Body = JsonConvert.SerializeObject(bodyMappings),
  516. //Title will be set by mapping json
  517. },
  518. Address= userDetails.Email
  519. }
  520. }
  521. };
  522. NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  523. }
  524. }
  525. catch (Exception ex)
  526. {
  527. Log.Error("BankTransferTxnPendingStatus", ex);
  528. }
  529. }
  530. return response;
  531. }
  532. catch (Exception ex)
  533. {
  534. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  535. response.SetResponse("1", "Error occured while SendTransaction");
  536. return response;
  537. }
  538. }
  539. public JsonRxResponse AccountValidation(AccountValidationModel model)
  540. {
  541. JsonRxResponse response = new JsonRxResponse();
  542. APIJsonResponse jsonResponse = new APIJsonResponse();
  543. try
  544. {
  545. string providerid = string.Empty;
  546. string paymentMode = model.PaymentMode ?? "";
  547. string remarks = string.Empty;
  548. bool allowProceed = true;
  549. AccountValidate accountValidate = new AccountValidate()
  550. {
  551. AccountNumber = model.AccountNumber,
  552. BankCode = model.BankCode,
  553. UserName = model.UserName,
  554. ReceiverName = !string.IsNullOrEmpty(model.ReceiverName) ? model.ReceiverName : Utilities.GetFullName(model.FirstName, model.MiddleName, model.LastName),
  555. ControlNo = model.ControlNo ?? "",
  556. PaymentMode = model.PaymentMode,
  557. SessionId = "",
  558. ProcessId = model.ProcessId
  559. };
  560. if (string.IsNullOrEmpty(providerid))
  561. {
  562. if (model.BankCountry.Equals("BD"))
  563. {
  564. providerid = "394414";
  565. paymentMode = model.Equals("2") ? "AC" : "MW";
  566. }
  567. else if (model.BankCountry.Equals("NP"))
  568. {
  569. providerid = "394397";
  570. if (model.BankCode == "2454")
  571. accountValidate.BankCode = "IMEPAY";
  572. else if (model.BankCode == "2662")
  573. accountValidate.BankCode = "KHALTI";
  574. }
  575. else if (model.BankCountry.Equals("LK"))
  576. {
  577. providerid = "394400";
  578. }
  579. else if (model.BankCountry.Equals("VD"))
  580. {
  581. providerid = "394132";
  582. }
  583. }
  584. accountValidate.ProviderId = providerid;
  585. Log.Debug("AccountValidation | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(accountValidate));
  586. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<AccountValidate, APIJsonResponse>(accountValidate, "TP/Verify", out jsonResponse);
  587. Log.Debug("AccountValidation | TPAPI RESPONSE : " + JsonConvert.SerializeObject(result));
  588. response = new JsonRxResponse()
  589. {
  590. ErrorCode = result.ResponseCode.Equals("0") ? "0" : "1",
  591. Id = result.Id,
  592. Msg = result.ResponseCode.Equals("0") ? "Validation Success" : "Validation Failed",
  593. Data = result.Data,
  594. Extra = allowProceed ? "Y" : "N",
  595. Extra2 = result.Extra1,
  596. Extra3 = result.Extra3
  597. };
  598. return response;
  599. }
  600. catch (Exception ex)
  601. {
  602. Log.Error("AccountValidation", ex);
  603. response.SetResponse("1", "Error occured while AccountValidation");
  604. return response;
  605. }
  606. }
  607. }
  608. }