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.

670 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
1 year 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. DiscountedFee = m.discountedFee ?? "0"
  177. };
  178. Log.Debug("Calculate | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(model));
  179. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<ExRateCalculate, APIJsonResponse>(model, "TP/ExRate", out jsonResponse);
  180. Log.Debug("Calculate | TPAPI RRESPONSE : " + JsonConvert.SerializeObject(result));
  181. response = new JsonRxResponse()
  182. {
  183. ErrorCode = result.ResponseCode,
  184. Id = result.Id,
  185. Msg = result.Msg,
  186. Data = result.Data,
  187. Extra = result.Extra,
  188. Extra2 = result.Extra1,
  189. FootNoteMessage = result.FootNoteMessage
  190. };
  191. return response;
  192. }
  193. catch (Exception ex)
  194. {
  195. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  196. response.SetResponse("1", "Error occured while calculating ex-rate");
  197. return response;
  198. }
  199. }
  200. public JsonRxResponse TrackTransaction(TrackTransactionParam param)
  201. {
  202. JsonRxResponse jsonRx = new JsonRxResponse();
  203. try
  204. {
  205. jsonRx = _repo.TrackTransaction(param);
  206. Log.Debug("TrackTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  207. if (!jsonRx.ErrorCode.Equals("0"))
  208. {
  209. Log.Debug("TrackTransaction | Error occurred while calling TrackTransaction..." + "ControlNo: " + param.ControlNo);
  210. return jsonRx;
  211. }
  212. return jsonRx;
  213. }
  214. catch (Exception ex)
  215. {
  216. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  217. jsonRx.SetResponse("1", "Error occurred while fetching the paystatus of the transaction.");
  218. return jsonRx;
  219. }
  220. }
  221. public JsonRxResponse AmendTransaction(TrackTransactionParam param)
  222. {
  223. JsonRxResponse jsonRx = new JsonRxResponse();
  224. try
  225. {
  226. jsonRx = _repo.AmendTransaction(param);
  227. Log.Debug("AmendTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  228. if (!jsonRx.ErrorCode.Equals("0"))
  229. {
  230. return jsonRx;
  231. }
  232. string body = "Hello JME Support, <br>";
  233. body += param.UserId + " Send Amendment request for JME No: " + param.ControlNo;
  234. body += param.Body;
  235. //EmailParameters _emailParams = new EmailParameters()
  236. //{
  237. // To = ApplicationConfig.ReadWebConfig("JMESupport"),
  238. // MsgSubject = "Amendment request for JME No: " + param.ControlNo,
  239. // MsgBody = body
  240. //};
  241. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  242. //Task.Run(() =>
  243. //{
  244. // SendNotificationRequest request = new SendNotificationRequest()
  245. // {
  246. // IsBulkNotification = false,
  247. // UserName = param.UserId,
  248. // ProcessId = param.ControlNo,
  249. // ProviderId = param.ControlNo,
  250. // NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  251. // Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD,
  252. // Recipients = new List<RecipientViewModel>()
  253. // {
  254. // new RecipientViewModel()
  255. // {
  256. // NotificationContent = new NotificationDTO() {
  257. // Body = body,
  258. // //Title will be set by mapping json
  259. // },
  260. // Address= ApplicationConfig.ReadWebConfig("JMESupport")
  261. // }
  262. // }
  263. // };
  264. // NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  265. //});
  266. return jsonRx;
  267. }
  268. catch (Exception ex)
  269. {
  270. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  271. jsonRx.SetResponse("1", "Error occurred while requesting the transaction amendment request.");
  272. return jsonRx;
  273. }
  274. }
  275. public JsonRxResponse AmendTransactionV2(AmendTransactionParam param)
  276. {
  277. JsonRxResponse jsonRx = new JsonRxResponse();
  278. try
  279. {
  280. var xml = GetXMLValues(param);
  281. jsonRx = _repo.AmendTransactionV2(param, xml);
  282. Log.Debug("AmendTransactionV2 | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  283. if (!jsonRx.ErrorCode.Equals("0"))
  284. {
  285. return jsonRx;
  286. }
  287. //string body = "Hello JME Support, <br>";
  288. //body += param.UserId + " Send Amendment request for JME No: " + param.ControlNo;
  289. //body += param.Body;
  290. //EmailParameters _emailParams = new EmailParameters()
  291. //{
  292. // To = ApplicationConfig.ReadWebConfig("JMESupport"),
  293. // MsgSubject = "Amendment request for JME No: " + param.ControlNo,
  294. // MsgBody = body
  295. //};
  296. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  297. return jsonRx;
  298. }
  299. catch (Exception ex)
  300. {
  301. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  302. jsonRx.SetResponse("1", "Error occurred while requesting the transaction amendment request.");
  303. return jsonRx;
  304. }
  305. }
  306. private string GetXMLValues(AmendTransactionParam param)
  307. {
  308. StringBuilder sb = new StringBuilder("<root>");
  309. foreach (var item in param.ChangeParams)
  310. {
  311. sb.Append("<row");
  312. sb.Append(string.Format(" CloumnName=\"{0}\" ColumnValue=\"{1}\"", item.Key, item.Value));
  313. sb.Append(" />");
  314. }
  315. sb.AppendLine("</root>");
  316. return sb.ToString();
  317. }
  318. public JsonRxResponse CancelTransaction(TrackTransactionParam param)
  319. {
  320. JsonRxResponse jsonRx = new JsonRxResponse();
  321. try
  322. {
  323. jsonRx = _repo.CancelTransaction(param);
  324. Log.Debug("CancelTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  325. if (!jsonRx.ErrorCode.Equals("0"))
  326. {
  327. return jsonRx;
  328. }
  329. //string body = "Hello JME Support, <br>";
  330. //body += param.UserId + " Send cancellation request for JME No: " + param.ControlNo;
  331. //body += param.Body;
  332. //EmailParameters _emailParams = new EmailParameters()
  333. //{
  334. // To = ApplicationConfig.ReadWebConfig("JMESupport"),
  335. // MsgSubject = "Cancellation request for JME No: " + param.ControlNo,
  336. // MsgBody = body
  337. //};
  338. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  339. return jsonRx;
  340. }
  341. catch (Exception ex)
  342. {
  343. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  344. jsonRx.SetResponse("1", "Error occurred while requesting the transaction cancel.");
  345. return jsonRx;
  346. }
  347. }
  348. public JsonRxResponse RejectTransaction(RejectTransactionParam param)
  349. {
  350. JsonRxResponse jsonRx = new JsonRxResponse();
  351. //JsonRxResponse response = new JsonRxResponse();
  352. APIJsonResponse jsonResponse = new APIJsonResponse();
  353. try
  354. {
  355. DbResult _dbRes = _repo.GetTxnApproveData(param.UserId, param.TranId);
  356. Log.Debug("RejectTransaction | GetTxnApproveData RESPONSE : " + JsonConvert.SerializeObject(_dbRes));
  357. if (_dbRes.Extra == "True" || _dbRes.Extra == "1")//is realtime
  358. {
  359. CancelTxnPartner model = new CancelTxnPartner()
  360. {
  361. ProviderId = _dbRes.Msg,
  362. PartnerPinNo = _dbRes.Id,
  363. CancelReason = "41",
  364. ProcessId = param.ProcessId
  365. };
  366. Log.Debug("RejectTransaction | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(model));
  367. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<CancelTxnPartner, APIJsonResponse>(model, "TP/cancelTxn", out jsonResponse);
  368. Log.Debug("RejectTransaction | TPAPI RRESPONSE : " + JsonConvert.SerializeObject(result));
  369. if (result.ResponseCode == "0")
  370. {
  371. jsonRx = _repo.RejectTransaction(param);
  372. }
  373. else
  374. {
  375. jsonRx = new JsonRxResponse()
  376. {
  377. ErrorCode = result.ResponseCode,
  378. Id = result.Id,
  379. Msg = result.Msg,
  380. Data = result.Data,
  381. Extra = result.Extra,
  382. Extra2 = result.Extra1
  383. };
  384. }
  385. return jsonRx;
  386. }
  387. else
  388. {
  389. jsonRx = _repo.RejectTransaction(param);
  390. Log.Debug("RejectTransaction | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  391. }
  392. return jsonRx;
  393. }
  394. catch (Exception ex)
  395. {
  396. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  397. jsonRx.SetResponse("1", "Error occurred while rejecting the transaction.");
  398. return jsonRx;
  399. }
  400. }
  401. public Common.Model.DbResult CheckLoginPassword(string user, string txnPassword, string paymentType, string customerId)
  402. {
  403. return _repo.CheckLoginPassword(user, txnPassword, paymentType, customerId);
  404. }
  405. public Common.Model.DbResult CheckLoginPIN(string user, string txnPassword, string paymentType, string customerId)
  406. {
  407. return _repo.CheckLoginPIN(user, txnPassword, paymentType, customerId);
  408. }
  409. public JsonRxResponse SendTransaction(MobileRemitRequest model)
  410. {
  411. JsonRxResponse response = new JsonRxResponse();
  412. APIJsonResponse jsonResponse = new APIJsonResponse();
  413. try
  414. {
  415. TpSendMoney tp = new TpSendMoney()
  416. {
  417. CalBy = model.CalBy,
  418. CDDI = new CustomerDueDiligence()
  419. {
  420. PurposeOfRemittance = model.PurposeOfRemittance,
  421. RelWithSender = model.RelWithSender,
  422. SourceOfFund = model.SourceOfFund,
  423. otherPurposeOfRemittance = model.otherPurposeOfRemittance,
  424. otherSourceOfFund = model.otherSourceOfFund,
  425. GoodsOrigin = model.GoodsOrigin,
  426. GoodsType = model.GoodsType,
  427. PortOfShipment = model.PortOfShipment
  428. },
  429. CollAmt = model.CollAmt,
  430. CollCurr = model.CollCurr,
  431. DeliveryMethodId = Convert.ToInt32(model.DeliveryMethodId == "" || model.DeliveryMethodId == null ? "0" : model.DeliveryMethodId),
  432. ExRate = model.ExRate,
  433. ForexSessionId = model.FOREX_SESSION_ID,
  434. IsRealtime = false,
  435. PaymentType = model.PaymentType,
  436. PayoutAmt = model.PayoutAmt == "" ? "0" : model.PayoutAmt,
  437. PayoutCurr = model.PCurr,
  438. PayOutPartnerId = Convert.ToInt32(model.PayOutPartner == "" || model.PayOutPartner == null ? "0" : model.PayOutPartner),
  439. // PBankId = model.DeliveryMethodId == "2" ? Convert.ToInt32(model.PAgent == "" || model.PAgent == null ? "0" : model.PAgent) : 0,
  440. PBankId = Convert.ToInt32(model.PAgent == "" || model.PAgent == null ? "0" : model.PAgent),
  441. PBranchId = Convert.ToInt32(model.PBranch == "" || model.PBranch == null ? "0" : model.PBranch),
  442. PCountryId = 0,
  443. ProcessId = model.ProcessId,
  444. ProviderId = "",
  445. Receiver = new ReceiverInfo() { ReceiverId = model.ReceiverId, AccountNo = model.ReceiverAccountNo },
  446. RequestedBy = "mobile",
  447. ScDiscount = model.Discount,
  448. //SchemeId = model.schemeId,
  449. SCountryId = 0,
  450. SenderId = model.SenderId,
  451. ServiceCharge = model.ServiceCharge,
  452. SessionId = "",
  453. SIpAddress = model.IpAddress,
  454. SourceType = "",
  455. TpExRate = model.TpExRate,
  456. TpPCurr = model.TpPCurr,
  457. TransferAmt = model.TransferAmt,
  458. UserName = model.User,
  459. DiscountedFee = model.DiscountedFee,
  460. SiteId = ConfigurationManager.AppSettings["sitereference"].ToString(),
  461. isPromoCode = model.isPromoCode,
  462. promoRowId = model.promoRowId,
  463. promoCode = model.promoCode
  464. };
  465. Log.Debug("DOTRANSACTION | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(tp));
  466. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<TpSendMoney, APIJsonResponse>(tp, "TP/mobileSendTxn", out jsonResponse);
  467. Log.Debug("DOTRANSACTION | TPAPI RESPONSE : " + JsonConvert.SerializeObject(result));
  468. response = new JsonRxResponse()
  469. {
  470. ErrorCode = result.ResponseCode,
  471. Id = result.Id,
  472. Msg = result.Msg,
  473. Data = result.Data,
  474. Extra = result.Extra,
  475. Extra2 = result.Extra2,
  476. Extra3 = result.Extra3,
  477. Extra4 = result.Extra4
  478. };
  479. if (response.ErrorCode.Equals("0"))
  480. {
  481. //var randomPassword = PasswordGenerator.GenerateRandomPassword(new PasswordGenerator.PasswordOptions()
  482. //{ RequireDigit = true, RequiredLength = 10, RequiredUniqueChars = 2, RequireLowercase = true, RequireNonAlphanumeric = true, RequireUppercase = true });
  483. string eID = HttpUtility.UrlEncode(AesOperation.EncryptString(ConfigurationManager.AppSettings["encryptKey"].ToString(), result.Id));
  484. string eCn = HttpUtility.UrlEncode(AesOperation.EncryptString(ConfigurationManager.AppSettings["encryptKey"].ToString(), result.Extra));
  485. var trustpaymentCallback = ApplicationConfig.ReadWebConfig("trustpaymentCallback");
  486. var trustpaymentSuccess = ApplicationConfig.ReadWebConfig("trustpaymentSuccess");
  487. var trustpaymentFail = ApplicationConfig.ReadWebConfig("trustpaymentFail");
  488. Gateway gateway = new Gateway()
  489. {
  490. Code = result.Extra2,
  491. IsRedirect = result.Extra3.Equals("Y") ? true : false,
  492. //Token = randomPassword,
  493. RedirectURL = result.Extra3.Equals("Y") ? $"{trustpaymentCallback}?id={eID}&ref={response.Extra4}&cn={eCn}&token=" : "",
  494. CheckSuccessURL = result.Extra3.Equals("Y") ? trustpaymentSuccess : "",
  495. CheckFailURL = result.Extra3.Equals("Y") ? trustpaymentFail : ""
  496. };
  497. response.Data = gateway;
  498. string email = model.User;
  499. try
  500. {
  501. if (!result.Extra3.Equals("Y"))
  502. {
  503. UserDetails userDetails = _requestServices.GetUserDetails(email);
  504. List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
  505. bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = userDetails.FullName });
  506. bodyMappings.Add(new Notify.Mapping() { SValue = "CollectAmt", SText = GetStatic.ShowDecimal(model.CollAmt) });
  507. SendNotificationRequest request = new SendNotificationRequest()
  508. {
  509. IsBulkNotification = false,
  510. UserName = userDetails.Email,
  511. ProviderId = "BankTransferTxnPendingStatus",
  512. NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  513. Template = Common.Model.Enum.NotifyTemplate.BANK_TRANSFER_TXN_PENDING,
  514. Recipients = new List<RecipientViewModel>()
  515. {
  516. new RecipientViewModel()
  517. {
  518. NotificationContent = new NotificationDTO() {
  519. Body = JsonConvert.SerializeObject(bodyMappings),
  520. //Title will be set by mapping json
  521. },
  522. Address= userDetails.Email
  523. }
  524. }
  525. };
  526. NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  527. }
  528. }
  529. catch (Exception ex)
  530. {
  531. Log.Error("BankTransferTxnPendingStatus", ex);
  532. }
  533. }
  534. return response;
  535. }
  536. catch (Exception ex)
  537. {
  538. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  539. response.SetResponse("1", "Error occured while SendTransaction");
  540. return response;
  541. }
  542. }
  543. public JsonRxResponse AccountValidation(AccountValidationModel model)
  544. {
  545. JsonRxResponse response = new JsonRxResponse();
  546. APIJsonResponse jsonResponse = new APIJsonResponse();
  547. try
  548. {
  549. string providerid = string.Empty;
  550. string paymentMode = model.PaymentMode ?? "";
  551. string remarks = string.Empty;
  552. bool allowProceed = true;
  553. AccountValidate accountValidate = new AccountValidate()
  554. {
  555. AccountNumber = model.AccountNumber,
  556. BankCode = model.BankCode,
  557. UserName = model.UserName,
  558. ReceiverName = !string.IsNullOrEmpty(model.ReceiverName) ? model.ReceiverName : Utilities.GetFullName(model.FirstName, model.MiddleName, model.LastName),
  559. ControlNo = model.ControlNo ?? "",
  560. PaymentMode = model.PaymentMode,
  561. SessionId = "",
  562. ProcessId = model.ProcessId
  563. };
  564. if (string.IsNullOrEmpty(providerid))
  565. {
  566. if (model.BankCountry.Equals("BD"))
  567. {
  568. providerid = "394414";
  569. paymentMode = model.Equals("2") ? "AC" : "MW";
  570. }
  571. else if (model.BankCountry.Equals("NP"))
  572. {
  573. providerid = "394397";
  574. if (model.BankCode == "2454")
  575. accountValidate.BankCode = "IMEPAY";
  576. else if (model.BankCode == "2662")
  577. accountValidate.BankCode = "KHALTI";
  578. }
  579. else if (model.BankCountry.Equals("LK"))
  580. {
  581. providerid = "394400";
  582. }
  583. else if (model.BankCountry.Equals("VD"))
  584. {
  585. providerid = "394132";
  586. }
  587. }
  588. accountValidate.ProviderId = providerid;
  589. Log.Debug("AccountValidation | DATA SENT TO TPAPI : " + JsonConvert.SerializeObject(accountValidate));
  590. APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<AccountValidate, APIJsonResponse>(accountValidate, "TP/Verify", out jsonResponse);
  591. Log.Debug("AccountValidation | TPAPI RESPONSE : " + JsonConvert.SerializeObject(result));
  592. response = new JsonRxResponse()
  593. {
  594. ErrorCode = result.ResponseCode.Equals("0") ? "0" : "1",
  595. Id = result.Id,
  596. Msg = result.ResponseCode.Equals("0") ? "Validation Success" : "Validation Failed",
  597. Data = result.Data,
  598. Extra = allowProceed ? "Y" : "N",
  599. Extra2 = result.Extra1,
  600. Extra3 = result.Extra3
  601. };
  602. return response;
  603. }
  604. catch (Exception ex)
  605. {
  606. Log.Error("AccountValidation", ex);
  607. response.SetResponse("1", "Error occured while AccountValidation");
  608. return response;
  609. }
  610. }
  611. }
  612. }