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.

594 lines
26 KiB

11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
10 months ago
9 months ago
9 months ago
11 months ago
11 months ago
11 months ago
11 months ago
9 months ago
11 months ago
11 months ago
9 months ago
11 months ago
  1. using Common.Models.Bank;
  2. using Common.Models.Bank_Account;
  3. using Common.Models.ExchangeRate;
  4. using Common.Models.Reports;
  5. using Common.Models.RequestResponse;
  6. using Common.Models.Status;
  7. using Common.Models.TxnModel;
  8. using Common.TPService;
  9. using Common.Utility;
  10. using GMENepal.GMEReference;
  11. using GMENepal.Model;
  12. using log4net;
  13. using Newtonsoft.Json;
  14. using System;
  15. using System.Linq;
  16. using System.Reflection;
  17. using System.Security.Cryptography;
  18. using System.Text;
  19. using Repository.DAO.ThirdParty;
  20. namespace GMENepal.GMENepalAPIService
  21. {
  22. public class GMENepalAPI : ITPApiServices
  23. {
  24. private readonly ILog _log = LogManager.GetLogger(typeof(GMENepalAPI));
  25. private readonly FastMoneyWebService _fastMoneyWeb = new FastMoneyWebService();
  26. string UserName = GetStatic.ReadWebConfig("gme_user_name", "");
  27. string Password = GetStatic.ReadWebConfig("gme_password", "");
  28. string PartnerId = GetStatic.ReadWebConfig("gme_partnerId", "");
  29. string GMEKey = GetStatic.ReadWebConfig("gme_key", "");
  30. public TPResponse GetTPResponse<T>(T model, string MethodName) where T : class
  31. {
  32. switch (MethodName)
  33. {
  34. case "send":
  35. return SendTransaction(model as SendTransaction);
  36. case "bankList":
  37. return GetBankList(model as BankRequest);
  38. case "exRate":
  39. return GetExRate(model as ExchangeRate);
  40. case "status":
  41. return GetTxnStatus(model as GetStatus);
  42. case "cancelSend":
  43. return CancelTransaction(model as CancelTxn);
  44. case "amendmentRequest":
  45. return ReconcileReport(model as TxnAmendment);
  46. case "verify":
  47. return AccountValidation(model as AccountValidate);
  48. case "release":
  49. return ReleseTrasaction(model as TFReleaseTxnRequest);
  50. default:
  51. return new TPResponse() { ResponseCode = "1", Msg = "Method Name Not Found !" };
  52. }
  53. }
  54. private TPResponse ReleseTrasaction(TFReleaseTxnRequest releaseRequest)
  55. {
  56. DbResult response = new DbResult();
  57. TPResponse _response = new TPResponse();
  58. try
  59. {
  60. _log.Info("ConfirmTransaction | REQUEST :" + JsonConvert.SerializeObject(releaseRequest));
  61. var res = _fastMoneyWeb.ConfirmTransaction(PartnerId, UserName, Password, releaseRequest.TfPin, releaseRequest.TxnId);
  62. _log.Info("ConfirmTransaction | RESPONSE :" + JsonConvert.SerializeObject(res));
  63. _response.Data = response;
  64. _response.Msg = res.Message;
  65. _response.ResponseCode = res.ErrorCode;
  66. }
  67. catch (Exception ex)
  68. {
  69. _response.ResponseCode = "1";
  70. _response.Msg = "Unknown error!";
  71. _log.ErrorFormat("ReleseTrasaction | Exception occured On AccountValidation Method At GMENepalApi ! Details :" + ex.Message);
  72. }
  73. return _response;
  74. }
  75. private TPResponse AccountValidation(AccountValidate accValidate)
  76. {
  77. DbResult response = new DbResult();
  78. TPResponse _response = new TPResponse();
  79. try
  80. {
  81. _log.Info("AccountValidation | REQUEST :" + JsonConvert.SerializeObject(accValidate).ToString());
  82. if (accValidate.BankCode.ToLower() == "imepay" || accValidate.BankCode.ToLower() == "khalti")
  83. {
  84. WalletUserDetailResponse walletResponse = _fastMoneyWeb.GetWalletDetails(PartnerId, UserName, Password, accValidate.BankCode.ToUpper()
  85. , accValidate.AccountNumber, "", GetAccValidateSignature(accValidate));
  86. response.ErrorCode = walletResponse.ResponseCode;
  87. response.Msg = walletResponse.ResponseMessage;
  88. response.Extra = walletResponse.FullName;
  89. response.Extra2 = JsonConvert.SerializeObject(walletResponse);
  90. }
  91. else
  92. {
  93. response = _fastMoneyWeb.AccountValidation(UserName, Password, accValidate.BankCode, accValidate.AccountNumber
  94. , accValidate.ReceiverName);
  95. }
  96. _log.Info("AccountValidation | RESPONSE :" + JsonConvert.SerializeObject(response).ToString());
  97. _response.Data = response;
  98. _response.Msg = response.Msg.Replace("Please Contact Head Office.", "Please check and re-submit!");
  99. _response.Extra = response.Extra;
  100. _response.ResponseCode = response.ErrorCode;
  101. }
  102. catch (Exception ex)
  103. {
  104. _response.ResponseCode = "1";
  105. _response.Msg = "Unknown error!";
  106. _log.ErrorFormat("Exception occured On AccountValidation Method At GMENepalApi ! Details :" + ex.Message);
  107. }
  108. return _response;
  109. }
  110. private string GetAccValidateSignature(AccountValidate accValidate)
  111. {
  112. string sign = GMEKey + PartnerId + UserName + Password + accValidate.AccountNumber;
  113. StringBuilder builder = new StringBuilder();
  114. using (SHA256 sha256Hash = SHA256.Create())
  115. {
  116. // ComputeHash - returns byte array
  117. byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(sign));
  118. // Convert byte array to a string
  119. for (int i = 0; i < bytes.Length; i++)
  120. {
  121. builder.Append(bytes[i].ToString("x2"));
  122. }
  123. }
  124. return builder.ToString();
  125. }
  126. private TPResponse GetBankList(BankRequest bankRequest)
  127. {
  128. if (bankRequest.IsBranch)
  129. return GetBankBranchList(bankRequest);
  130. GMEBankRequest bR = BankModelMap(bankRequest);
  131. TPResponse _response = new CustomModelValidaton().IsModelValid(bR);
  132. if (_response == null)
  133. {
  134. _response = new TPResponse();
  135. BankList[] getResponse = _fastMoneyWeb.GetBankList(bR.PartnerId, bR.UserName, bR.Password, bR.SessionId, bR.PaymentMethod, bR.ReceivingCountry);
  136. _response.Data = getResponse;
  137. _response.ResponseCode = getResponse.First().ErrorCode;
  138. _response.Msg = getResponse.First().Message;
  139. if (!_response.ResponseCode.Equals("0"))
  140. {
  141. _response.ResponseCode = "1";
  142. _log.ErrorFormat("Error Occured On GetBankList Method At GMENepalApi ! Details :" + getResponse);
  143. }
  144. }
  145. else
  146. {
  147. _log.Info("GetBankList | MODEL VALIDATION FAILED :" + JsonConvert.SerializeObject(bR).ToString());
  148. }
  149. return _response;
  150. }
  151. private TPResponse GetBankBranchList(BankRequest bRequest)
  152. {
  153. GMEBankBranchRequest bR = BankBranchModelMap(bRequest);
  154. TPResponse _response = new CustomModelValidaton().IsModelValid(bR);
  155. if (_response == null)
  156. {
  157. _response = new TPResponse();
  158. BankBranchList getResponse = _fastMoneyWeb.GetBankBranchList(bR.PartnerId, bR.UserName, bR.Password, bR.BankCode, bR.SessionId);
  159. _response.Data = getResponse.BRANCHES;
  160. _response.ResponseCode = getResponse.ErrorCode;
  161. _response.Msg = getResponse.Message;
  162. if (!_response.ResponseCode.Equals("0"))
  163. {
  164. _response.ResponseCode = "1";
  165. _log.ErrorFormat("Error Occured On GetBankBranchList Method At GMENepalApi ! Details :" + getResponse);
  166. }
  167. }
  168. else
  169. {
  170. _log.Info("GetBankBranchList | MODEL VALIDATION FAILED :" + JsonConvert.SerializeObject(bR).ToString());
  171. }
  172. return _response;
  173. }
  174. private TPResponse GetExRate(ExchangeRate exchangeRate)
  175. {
  176. GMEGetCalculationRequest gCR = GetExRateModelMap(exchangeRate);
  177. TPResponse _response = new CustomModelValidaton().IsModelValid(gCR);
  178. if (_response == null)
  179. {
  180. _response = new TPResponse();
  181. _log.Info("GetExRate | REQUEST :" + JsonConvert.SerializeObject(exchangeRate).ToString());
  182. GetCalculationResult model = _fastMoneyWeb.GetCalculation(
  183. gCR.PartnerId, gCR.UserName, gCR.Password, gCR.SessionId, gCR.ReceivingAgentId,
  184. gCR.RemitAmount, gCR.PaymentMethod, gCR.ReceivingCountry, gCR.CalculateBy
  185. );
  186. _log.Info("GetExRate | RESPONSE :" + JsonConvert.SerializeObject(model).ToString());
  187. _response.Data = model;
  188. _response.Msg = model.Message;
  189. _response.Extra = model.ExConfirmId;
  190. _response.ResponseCode = model.ErrorCode;
  191. if (!_response.ResponseCode.Equals("0"))
  192. {
  193. _response.ResponseCode = "1";
  194. _log.ErrorFormat("Error Occured On GetExRate Method At GMENepalApi ! Details :" + model);
  195. }
  196. }
  197. else
  198. {
  199. _log.Info("GetExRate | MODEL VALIDATION FAILED :" + JsonConvert.SerializeObject(gCR).ToString());
  200. }
  201. return _response;
  202. }
  203. private TPResponse SendTransaction(SendTransaction sendTransaction)
  204. {
  205. GMESendMoney gS = SendModelMap(sendTransaction);
  206. DbResult model = new DbResult();
  207. SendMoneyResult sendMoneyRes = new SendMoneyResult();
  208. TPResponse _response = new CustomModelValidaton().IsModelValid(gS);
  209. if (_response == null)
  210. {
  211. _response = new TPResponse();
  212. var dt = gS.TransactionDate.Split('-');
  213. string dateTxn = dt[1] + "-" + dt[2] + "-" + dt[0];
  214. _log.Info("SendTransaction | REQUEST :" + JsonConvert.SerializeObject(gS).ToString());
  215. if (gS.PaymentMethod.ToLower() == "c")
  216. {
  217. _response = new TPResponse();
  218. var exRate = _fastMoneyWeb.GetCalculation(
  219. gS.PartnerId, gS.UserName, gS.Password, gS.SessionId, "",
  220. "1000", "C", gS.BeneCountry, "P"
  221. );
  222. _log.Info("GetExRate | RESPONSE :" + JsonConvert.SerializeObject(model).ToString());
  223. var exConfirmId = exRate.ExConfirmId;
  224. sendMoneyRes = _fastMoneyWeb.SendMoney(PartnerId, UserName, Password, gS.ControlNo, exConfirmId, gS.MembershipId, gS.CustomerName, gS.CustomerAddress,
  225. gS.CustomerContact, gS.CustomerCity, gS.CustomerCountry, gS.CustomerIdType, gS.CustomerIdNumber, gS.BeneName, gS.BeneAddress, gS.BeneContact, gS.BeneCity
  226. , gS.BeneCountry, gS.Profession, gS.IncomeSource, gS.Relationship, gS.PurposeOfRemittance, gS.SendingAmount, gS.ReceivingAmount, gS.PaymentMethod
  227. , gS.BankCode, gS.BankName, gS.BankBranchName, gS.BankAccountNumber, dateTxn, gS.CalculateBy, gS.FreeCharge);
  228. _log.Info("SendTransaction | RESPONSE :" + JsonConvert.SerializeObject(sendMoneyRes).ToString());
  229. _response.ResponseCode = sendMoneyRes.ErrorCode;
  230. _response.Msg = sendMoneyRes.Message;
  231. _response.Extra = exRate.UsdVsNpr;
  232. _response.Extra2 = sendMoneyRes.PinNo;
  233. _response.Id = sendMoneyRes.TranId;
  234. _response.Data = sendMoneyRes;
  235. return _response;
  236. }
  237. else if (gS.PaymentMethod.ToLower() == "w" && (gS.BankCode.ToLower() == "imepay" || gS.BankCode.ToLower() == "khalti"))
  238. {
  239. model = _fastMoneyWeb.RealTimeWalletDeposit(PartnerId, UserName, Password, gS.BankCode, gS.CustomerName, gS.CustomerAddress
  240. , gS.CustomerContact, gS.CustomerCountry, gS.CustomerIdType, gS.CustomerIdNumber, gS.BeneName, gS.BeneAddress
  241. , gS.BankAccountNumber, gS.BeneCountry, gS.IncomeSource, gS.Relationship, gS.PurposeOfRemittance, Convert.ToString(gS.CollectionAmount)
  242. , gS.CollectionCurrency, gS.SendingAmount, gS.ReceivingAmount, gS.FreeCharge, gS.PayoutCommCurr, dateTxn, gS.ControlNo
  243. , gS.SenderCostRate, gS.ReceiverCostRate, Convert.ToString(gS.ExRate), gS.Signature);
  244. }
  245. else
  246. {
  247. AccountValidate accValidate = new AccountValidate
  248. {
  249. BankCode = gS.BankCode,
  250. AccountNumber = gS.BankAccountNumber,
  251. ReceiverName = gS.BeneName,
  252. ControlNo = gS.ControlNo,
  253. PaymentMode = gS.PaymentMethod
  254. };
  255. var response = AccountValidation(accValidate);
  256. if (response.ResponseCode.Equals("0") || response.ResponseCode.Equals("100"))
  257. {
  258. var exRateBank = _fastMoneyWeb.GetCalculation(gS.PartnerId, gS.UserName, gS.Password, gS.SessionId, "", "1000", "B", gS.BeneCountry, "P");
  259. model = _fastMoneyWeb.ProcessBankDeposit(gS.PartnerId, gS.UserName, gS.Password, gS.ControlNo, exRateBank.ExConfirmId
  260. , gS.MembershipId, gS.CustomerName, gS.CustomerAddress, gS.CustomerContact, gS.CustomerCity, gS.CustomerCountry
  261. , gS.CustomerIdType, gS.CustomerIdNumber, gS.BeneName, gS.BeneAddress, gS.BeneContact, gS.BeneCity, gS.BeneCountry, gS.Profession
  262. , gS.IncomeSource, gS.Relationship, gS.PurposeOfRemittance, gS.SendingAmount, gS.ReceivingAmount, gS.PaymentMethod, gS.BankCode
  263. , gS.BankName, gS.BankAccountNumber, dateTxn, gS.CalculateBy, gS.FreeCharge, gS.ControlNo, gS.PayoutCurrency, gS.ReceiverCostRate
  264. , gS.SenderCostRate, gS.Signature);
  265. _response.Extra = exRateBank.UsdVsNpr;
  266. }
  267. else
  268. {
  269. ThirdPartyRepo thirdPartyRepo = new ThirdPartyRepo();
  270. thirdPartyRepo.SyncTxnAsComment(sendTransaction.ProviderId, sendTransaction.TranId.ToString(), gS.ControlNo, "", response.Msg);
  271. _response.ResponseCode = response.ResponseCode;
  272. _response.Msg = response.Msg;
  273. return _response;
  274. }
  275. }
  276. _log.Info("SendTransaction | RESPONSE :" + JsonConvert.SerializeObject(model).ToString());
  277. _response.ResponseCode = model.ErrorCode;
  278. _response.Msg = model.Msg;
  279. _response.Extra2 = model.Extra2;
  280. _response.Id = model.Id;
  281. _response.Data = model;
  282. }
  283. else
  284. {
  285. _log.Info("SendTransaction | MODEL VALIDATION FAILED :" + JsonConvert.SerializeObject(gS).ToString());
  286. }
  287. return _response;
  288. }
  289. private TPResponse GetTxnStatus(GetStatus getStatus)
  290. {
  291. if (getStatus.IsFromPartnerPinNo)
  292. return GetTxnByPartnerPin(getStatus);
  293. GMEGetStatus gS = StatusModelMap(getStatus);
  294. TPResponse _response = new CustomModelValidaton().IsModelValid(gS);
  295. if (_response == null)
  296. {
  297. _response = new TPResponse();
  298. _log.Info("GetTxnStatus | REQUEST :" + JsonConvert.SerializeObject(gS).ToString());
  299. var model = _fastMoneyWeb.GetStatus(gS.PartnerId, gS.UserName, gS.Password, gS.PinNo, gS.SessionId);
  300. _log.Info("GetTxnStatus | RESPONSE :" + JsonConvert.SerializeObject(model).ToString());
  301. _response.ResponseCode = model.ErrorCode;
  302. _response.Msg = model.Message;
  303. _response.Extra2 = model.Status;
  304. _response.Data = model;
  305. _response.Extra = model.ExRate;
  306. if (!_response.ResponseCode.Equals("0"))
  307. {
  308. _response.ResponseCode = "1";
  309. }
  310. }
  311. else
  312. {
  313. _log.Info("GetTxnStatus | MODEL VALIDATION FAILED :" + JsonConvert.SerializeObject(gS).ToString());
  314. }
  315. return _response;
  316. }
  317. private TPResponse GetTxnByPartnerPin(GetStatus getStatus)
  318. {
  319. GMEGetStatusByPartnerPinNo gSP = StatusByPartmerIdModelMap(getStatus);
  320. TPResponse _response = new CustomModelValidaton().IsModelValid(gSP);
  321. if (_response == null)
  322. {
  323. _response = new TPResponse();
  324. _log.Info("GetTxnByPartnerPin | REQUEST :" + JsonConvert.SerializeObject(gSP).ToString());
  325. GetStatusByPartnerPinNoResult model = _fastMoneyWeb.GetStatusByPartnerPinNo(gSP.PartnerId, gSP.UserName, gSP.Password, gSP.PinNo, gSP.SessionId);
  326. _log.Info("GetTxnByPartnerPin | RESPONSE :" + JsonConvert.SerializeObject(model).ToString());
  327. _response.Data = model;
  328. _response.ResponseCode = model.ErrorCode;
  329. _response.Msg = model.Message;
  330. if (!_response.ResponseCode.Equals("0"))
  331. {
  332. _response.ResponseCode = "1";
  333. }
  334. }
  335. else
  336. {
  337. _log.Info("GetTxnByPartnerPin | MODEL VALIDATION FAILED :" + JsonConvert.SerializeObject(gSP).ToString());
  338. }
  339. return _response;
  340. }
  341. private TPResponse CancelTransaction(CancelTxn cancelTxn)
  342. {
  343. GMECancelTransaction gCT = CancelTxnModelMap(cancelTxn);
  344. TPResponse _response = new CustomModelValidaton().IsModelValid(gCT);
  345. if (_response == null)
  346. {
  347. _response = new TPResponse();
  348. CancelTransactionResult model = _fastMoneyWeb.CancelTransaction(gCT.PartnerId, gCT.UserName, gCT.Password, gCT.PinNo, gCT.SessionId, gCT.CancelRemarks);
  349. _response.Data = model;
  350. _response.ResponseCode = model.ErrorCode;
  351. _response.Msg = model.Message;
  352. if (!_response.ResponseCode.Equals("0"))
  353. {
  354. _response.ResponseCode = "1";
  355. _log.ErrorFormat("Error Occured On CancelTransaction Method At GMENepalApi ! Details :" + model);
  356. }
  357. }
  358. else
  359. {
  360. _log.Error("Error Validating Model!");
  361. }
  362. return _response;
  363. }
  364. private TPResponse ReconcileReport(TxnAmendment txnAmendment)
  365. {
  366. GMEReconcileReport rCR = ReconcileReportMap(txnAmendment);
  367. TPResponse _response = new CustomModelValidaton().IsModelValid(rCR);
  368. if (_response == null)
  369. {
  370. _response = new TPResponse();
  371. ReconcileReportResult[] model = _fastMoneyWeb.ReconcileReport(rCR.PartnerId, rCR.UserName, rCR.Password, rCR.SessionId, rCR.ReportType, rCR.FromDate, rCR.ToDate);
  372. _response.Data = model;
  373. _response.ResponseCode = model.First().ErrorCode;
  374. _response.Msg = model.First().Message;
  375. if (!_response.ResponseCode.Equals("0"))
  376. {
  377. _response.ResponseCode = "1";
  378. _log.ErrorFormat("Error Occured On ReconcileReport Method At GMENepalApi ! Details :" + model);
  379. }
  380. }
  381. else
  382. {
  383. _log.Error("Error Validating Model!");
  384. }
  385. return _response;
  386. }
  387. #region dataMapping
  388. private GMEBankRequest BankModelMap(BankRequest bK)
  389. {
  390. return new GMEBankRequest()
  391. {
  392. PaymentMethod = bK.PaymentMethod,
  393. ReceivingCountry = bK.CountryCode
  394. };
  395. }
  396. private GMEBankBranchRequest BankBranchModelMap(BankRequest bK)
  397. {
  398. return new GMEBankBranchRequest()
  399. {
  400. BankCode = bK.BankName
  401. };
  402. }
  403. private GMEGetCalculationRequest GetExRateModelMap(ExchangeRate eR)
  404. {
  405. return new GMEGetCalculationRequest()
  406. {
  407. CalculateBy = eR.CalcBy,
  408. PaymentMethod = eR.PaymentType == "Wallet" ? "W" : eR.PaymentType,
  409. ReceivingAgentId = eR.PAgentName,
  410. ReceivingCountry = eR.PCountryName,
  411. RemitAmount = eR.CalcBy == "P" ? eR.CAmount.ToString() : eR.PAmount.ToString()
  412. };
  413. }
  414. private GMESendMoney SendModelMap(SendTransaction sT)
  415. {
  416. return new GMESendMoney()
  417. {
  418. Signature = GetSignature(sT),
  419. ControlNo = sT.Transaction.JMEControlNo,
  420. PayoutCurrency = sT.Transaction.PCurr,
  421. SenderCostRate = "",
  422. ReceiverCostRate = Convert.ToString(sT.Transaction.SettlementDollarRate),
  423. ExConfirmId = null,
  424. MembershipId = null,
  425. CustomerName = sT.Sender.SFullName,
  426. CustomerAddress = sT.Sender.SAddress,
  427. CustomerContact = sT.Sender.SMobile,
  428. CustomerCity = sT.Sender.SCityId,
  429. CustomerCountry = sT.Sender.SCountryName,
  430. CustomerIdType = sT.Sender.SIdType,
  431. CustomerIdNumber = sT.Sender.SIdNo,
  432. BeneName = sT.Receiver.RFullName,
  433. BeneAddress = sT.Receiver.RAdd1,
  434. BeneContact = sT.Receiver.RMobile,
  435. BeneCity = sT.Receiver.RCity,
  436. BeneCountry = sT.Receiver.RCountry,
  437. Profession = sT.Sender.SOccuptionName,
  438. IncomeSource = sT.Sender.SourceOfFund,
  439. Relationship = sT.Receiver.RelWithSenderName,
  440. PurposeOfRemittance = sT.Transaction.PurposeOfRemittanceName,
  441. SendingAmount = sT.Transaction.TAmt.ToString(),
  442. ReceivingAmount = sT.Transaction.PAmt.ToString(),
  443. PaymentMethod = sT.Transaction.PaymentType,
  444. BankCode = sT.Agent.PBankId,
  445. BankName = sT.Agent.PBankName,
  446. BankBranchName = sT.Agent.PBankBranchName,
  447. BankAccountNumber = sT.Receiver.RAccountNo,
  448. TransactionDate = sT.Transaction.TxnDate,
  449. CollectionCurrency = sT.Transaction.CollCurr,
  450. CollectionAmount = sT.Transaction.CAmt,
  451. ExRate = sT.Transaction.ExRate,
  452. PayoutCommCurr = "NPR",
  453. CalculateBy = "P",/*sT.Transaction.CalBy*/
  454. FreeCharge = Convert.ToString(sT.Transaction.ServiceCharge) /*sT.Transaction.IsManualSc*/
  455. };
  456. }
  457. private string GetSignature(SendTransaction sT)
  458. {
  459. string sign = "";
  460. if (sT.Agent.PBankId.ToLower() == "imepay" || sT.Agent.PBankId.ToLower() == "khalti")
  461. sign = GMEKey + PartnerId + UserName + Password + sT.Receiver.RAccountNo + sT.Transaction.PAmt;
  462. else
  463. sign = GMEKey + UserName + Password + sT.Transaction.JMEControlNo + sT.Transaction.PAmt + sT.Receiver.RAccountNo + sT.Agent.PBankId;
  464. StringBuilder builder = new StringBuilder();
  465. using (SHA256 sha256Hash = SHA256.Create())
  466. {
  467. // ComputeHash - returns byte array
  468. byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(sign));
  469. // Convert byte array to a string
  470. for (int i = 0; i < bytes.Length; i++)
  471. {
  472. builder.Append(bytes[i].ToString("x2"));
  473. }
  474. }
  475. return builder.ToString();
  476. }
  477. private GMESendMoneyV2 SendV2ModelMap(SendTransaction sT)
  478. {
  479. GMESendMoney model = SendModelMap(sT);
  480. return new GMESendMoneyV2()
  481. {
  482. GMESendMoney = model,
  483. PCostRate = sT.Transaction.ExRate.ToString(),
  484. SCostRate = sT.Transaction.SettlementDollarRate.ToString()
  485. };
  486. }
  487. private GMEGetStatus StatusModelMap(GetStatus gS)
  488. {
  489. return new GMEGetStatus()
  490. {
  491. PinNo = gS.ControlNo
  492. };
  493. }
  494. private GMEGetStatusByPartnerPinNo StatusByPartmerIdModelMap(GetStatus gS)
  495. {
  496. return new GMEGetStatusByPartnerPinNo()
  497. {
  498. PinNo = gS.PartnerPinNo
  499. };
  500. }
  501. private GMECancelTransaction CancelTxnModelMap(CancelTxn cT)
  502. {
  503. return new GMECancelTransaction()
  504. {
  505. PinNo = cT.PartnerPinNo
  506. };
  507. }
  508. private GMEReconcileReport ReconcileReportMap(TxnAmendment rR)
  509. {
  510. return new GMEReconcileReport()
  511. {
  512. FromDate = rR.FromDate,
  513. ReportType = rR.ReportType,
  514. ToDate = rR.ToDate
  515. };
  516. }
  517. private GMEGetAgentSOABalance SOABalanceModelMap(AgentSOAReport aR)
  518. {
  519. return new GMEGetAgentSOABalance()
  520. {
  521. AgentMapCode = aR.AgentMapCode
  522. };
  523. }
  524. #endregion dataMapping
  525. }
  526. }