PageRenderTime 103ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 1ms

/MTData.WebAPI/Controllers/Bad/TransactionRequestController.cs

https://bitbucket.org/stuarthealey/canada
C# | 7067 lines | 5030 code | 1082 blank | 955 comment | 885 complexity | f03191693f6236c5927ffc6e1bdd840f MD5 | raw file
  1. using System;
  2. using System.Configuration;
  3. using System.Collections.ObjectModel;
  4. using System.Collections.Generic;
  5. using System.Xml.Linq;
  6. using System.Globalization;
  7. using System.IO;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Linq;
  11. using System.Xml.Linq;
  12. using System.Threading;
  13. using System.Web.Http;
  14. using System.Xml;
  15. using System.Xml.Serialization;
  16. using MTD.Core.DataTransferObjects;
  17. using MTD.Core.Service.Interface;
  18. using MTData.WebAPI.Models;
  19. using MTData.WebAPI.Resources;
  20. using Ninject;
  21. using System.Net;
  22. using MTData.Utility;
  23. using MTData.WebAPI.schema;
  24. using System.Web.Configuration;
  25. using MTData.WebAPI.Common;
  26. using MTData.WebAPI.CanadaCert;
  27. using MTData.WebAPI.CanadaCommon;
  28. using MTData.WebAPI.schema;
  29. namespace MTData.WebAPI.Controllers
  30. {
  31. public class TransactionRequestController : BaseController
  32. {
  33. #region Load Constructor
  34. private static int _count = 0;
  35. private const string Ecommerce = "Ecommerce";
  36. private const string Retail = "Retail";
  37. private const string Credit = "Credit";
  38. private const string Debit = "Debit";
  39. private const string TokenOnly = "TokenOnly";
  40. private const string TAKey = "TAKey";
  41. private const string Void = "Void";
  42. private const string Timeout = "Timeout";
  43. private const string Completion = "Completion";
  44. private const string Refund = "Refund";
  45. private const string Authorization = "Authorization";
  46. private const string Visa = "Visa";
  47. private const string Amex = "Amex";
  48. private const string Diners = "Diners";
  49. private const string MasterCard = "MasterCard";
  50. private const string Discover = "Discover";
  51. private const string Sale = "Sale";
  52. private const string EMV2KEY = "EMV2KEY";
  53. private const string FileCRCValue = "3E30";
  54. private const string FileSizeValue = "15593";
  55. private const string ReqFBMaxSizeValue = "999";
  56. private const string CAPKUpdate = "CAPKUpdate";
  57. private const string CAPKDownload = "CAPKDownload";
  58. private const string BookerAppPayment = "BookerAppPayment";
  59. protected string IndustryType;
  60. protected string PaymentType;
  61. private string unreachableUrlResponse;
  62. private int retryCount;
  63. protected string TransactionType;
  64. private static ITerminalService _terminalService;
  65. private StringBuilder _logMessage;
  66. readonly ILogger _logger = new Logger();
  67. public TransactionRequestController([Named("TerminalService")] ITerminalService terminalService, StringBuilder logMessage)
  68. : base(terminalService, logMessage)
  69. {
  70. _terminalService = terminalService;
  71. _logMessage = logMessage;
  72. }
  73. private readonly GMFMessageVariants _gmfMsgVar = new GMFMessageVariants();
  74. private readonly CreditRequestDetails _creditReq = new CreditRequestDetails(); // Credit request for Ecomm/retail transaction
  75. private readonly PinlessDebitRequestDetails _pinlessDebit = new PinlessDebitRequestDetails(); // Debit request for Ecomm transaction
  76. private readonly DebitRequestDetails _debitReq = new DebitRequestDetails(); // Debit request for Retail transaction
  77. private readonly AdminRequestDetails _adminReq = new AdminRequestDetails();
  78. private readonly VoidTOReversalRequestDetails _revDetails = new VoidTOReversalRequestDetails(); // Void TO Reversal Request
  79. private readonly TARequestDetails _taRequest = new TARequestDetails();
  80. private readonly MessageProcessor _objMessageProcessor = new MessageProcessor();
  81. public static readonly string StrAppPath = Assembly.GetCallingAssembly().Location;
  82. #endregion
  83. /// <summary>
  84. /// Purpose : Finding credit and debit card request of Retail and ecommerce domain for First Data. Transaction Implemented Authorization, Completion, Sale, Refund, Void.
  85. /// Function Name : CreateTransactionRequest
  86. /// Created By : Salil Gupta
  87. /// Created On : 03/10/2015
  88. /// Modificatios Made : Madhuri Tanwar
  89. /// Modidified On : 07/27/2015
  90. /// </summary>
  91. /// <param name="transactionRequest"></param>
  92. /// <returns></returns>
  93. public IHttpActionResult CreateTransactionRequest(TransactionRequest transactionRequest)
  94. {
  95. try
  96. {
  97. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  98. MethodBase.GetCurrentMethod().Name + ";");
  99. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  100. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  101. string industryType = transactionRequest.IndustryType;
  102. string paymentType = transactionRequest.PaymentType.ToString();
  103. string transactionType = (transactionRequest.TransactionType == Void || transactionRequest.TransactionType == Timeout)
  104. ? Void
  105. : transactionRequest.TransType.ToString();
  106. switch (industryType)
  107. {
  108. #region Ecommerce
  109. case Ecommerce:
  110. if (paymentType == Credit)
  111. {
  112. switch (transactionType)
  113. {
  114. case Void:
  115. VoidTOReversalRequestDetails creditRequestVoid = ReversalRequest(transactionRequest);
  116. return Ok(creditRequestVoid);
  117. default:
  118. CreditRequestDetails creditRequest = CreateEcommerceRequest(transactionRequest);
  119. return Ok(creditRequest);
  120. }
  121. }
  122. if (paymentType == Debit)
  123. {
  124. PinlessDebitRequestDetails debitSale = CreatePinlessDebitRequest(transactionRequest);
  125. return Ok(debitSale);
  126. }
  127. break;
  128. #endregion
  129. #region Retail
  130. case Retail:
  131. var entryMode = (PaymentEntryMode)Enum.Parse(typeof(PaymentEntryMode), transactionRequest.EntryMode, true);
  132. var txnType = (PaymentTransactionType)Enum.Parse(typeof(PaymentTransactionType), transactionType, true);
  133. switch (entryMode)
  134. {
  135. #region Swiped
  136. case PaymentEntryMode.Swiped:
  137. if (paymentType == PaymentCardType.Credit.ToString())
  138. {
  139. switch (txnType)
  140. {
  141. case PaymentTransactionType.Void:
  142. VoidTOReversalRequestDetails creditRequestVerification =
  143. ReversalRequestMsr(transactionRequest);
  144. return Ok(creditRequestVerification);
  145. default:
  146. CreditRequestDetails creditRequest = CreateRetailRequest(transactionRequest);
  147. return Ok(creditRequest);
  148. }
  149. }
  150. else if (paymentType == PaymentCardType.Debit.ToString())
  151. {
  152. DebitRequestDetails debitCard = CreatePinDebitRequest(transactionRequest);
  153. return Ok(debitCard);
  154. }
  155. break;
  156. #endregion
  157. #region FSwiped
  158. case PaymentEntryMode.FSwiped:
  159. if (paymentType == PaymentCardType.Credit.ToString())
  160. {
  161. switch (txnType)
  162. {
  163. case PaymentTransactionType.Void:
  164. VoidTOReversalRequestDetails creditRequestVerification = ReversalRequestEmv(transactionRequest);
  165. return Ok(creditRequestVerification);
  166. default: //Full EMV Transaction
  167. CreditRequestDetails creditRequest = CreateFallbackMsrRequest(transactionRequest);
  168. return Ok(creditRequest);
  169. }
  170. }
  171. else if (paymentType == PaymentCardType.Debit.ToString())
  172. {
  173. DebitRequestDetails debitCard = CreateFallbackMsrDebitRequest(transactionRequest);
  174. return Ok(debitCard);
  175. }
  176. break;
  177. #endregion
  178. #region EmvContact
  179. case PaymentEntryMode.EmvContact:
  180. if (paymentType == PaymentCardType.Credit.ToString())
  181. {
  182. switch (txnType)
  183. {
  184. case PaymentTransactionType.Void:
  185. VoidTOReversalRequestDetails creditRequestVerification = ReversalRequestEmv(transactionRequest);
  186. return Ok(creditRequestVerification);
  187. default: //Full EMV Transaction
  188. CreditRequestDetails creditRequest = CreateEmvContactRequest(transactionRequest);
  189. return Ok(creditRequest);
  190. }
  191. }
  192. else if (paymentType == PaymentCardType.Debit.ToString())
  193. {
  194. DebitRequestDetails debitCard = CreateEmvContactPinDebitRequest(transactionRequest);
  195. return Ok(debitCard);
  196. }
  197. break;
  198. #endregion
  199. #region EmvContactless
  200. case PaymentEntryMode.EmvContactless:
  201. if (paymentType == PaymentCardType.Credit.ToString())
  202. {
  203. switch (txnType)
  204. {
  205. case PaymentTransactionType.Void:
  206. VoidTOReversalRequestDetails creditRequestVerification = ReversalRequestEmvContactless(transactionRequest);
  207. return Ok(creditRequestVerification);
  208. default: //Full EMV Transaction
  209. CreditRequestDetails creditRequest = CreateEmvContactlessRequest(transactionRequest);
  210. return Ok(creditRequest);
  211. }
  212. }
  213. else if (paymentType == PaymentCardType.Debit.ToString())
  214. {
  215. switch (txnType)
  216. {
  217. case PaymentTransactionType.Void:
  218. VoidTOReversalRequestDetails DebitRequestVerification = ReversalRequestDebitEmvContactless(transactionRequest);
  219. return Ok(DebitRequestVerification);
  220. default: //Full EMV Transaction
  221. DebitRequestDetails debitCard = CreateEmvContactlessPinDebitRequest(transactionRequest);
  222. return Ok(debitCard);
  223. }
  224. }
  225. break;
  226. #endregion
  227. #region MSRContactless
  228. case PaymentEntryMode.MSRContactless:
  229. if (paymentType == PaymentCardType.Credit.ToString())
  230. {
  231. switch (txnType)
  232. {
  233. case PaymentTransactionType.Void:
  234. VoidTOReversalRequestDetails creditRequestVerification = ReversalRequestMsrContactless(transactionRequest);
  235. return Ok(creditRequestVerification);
  236. default:
  237. CreditRequestDetails creditRequest = CreateMSRContactlessRequest(transactionRequest);
  238. return Ok(creditRequest);
  239. }
  240. }
  241. else if (paymentType == PaymentCardType.Debit.ToString())
  242. {
  243. switch (txnType)
  244. {
  245. case PaymentTransactionType.Void:
  246. VoidTOReversalRequestDetails DebitRequestVerification = ReversalRequestDebitMsrContactless(transactionRequest);
  247. return Ok(DebitRequestVerification);
  248. default: //Full EMV Transaction
  249. DebitRequestDetails debitCard = CreateCOntactlessMSRPinDebitRequest(transactionRequest);
  250. return Ok(debitCard);
  251. }
  252. }
  253. break;
  254. #endregion
  255. }
  256. break;
  257. #endregion
  258. #region Token
  259. case TokenOnly:
  260. TARequestDetails creditTaRequest = TaRequest(transactionRequest);
  261. return Ok(creditTaRequest);
  262. break;
  263. case TAKey:
  264. TARequestDetails creditTaKeyRequest = TaKeyRequest(transactionRequest);
  265. return Ok(creditTaKeyRequest);
  266. break;
  267. #endregion
  268. #region CAPK
  269. case CAPKUpdate:
  270. AdminRequestDetails updateAdminRequestDetails = CreateEmvContactUpdateCapkRequest(transactionRequest);
  271. return Ok(updateAdminRequestDetails);
  272. break;
  273. case CAPKDownload:
  274. AdminRequestDetails downloadAdminRequestDetails = CreateEmvContactDownloadCapkRequest(transactionRequest);
  275. return Ok(downloadAdminRequestDetails);
  276. break;
  277. #endregion
  278. #region bookerApp
  279. case BookerAppPayment:
  280. CreditRequestDetails bookerAppCreditRequest = BookerAppRequest(transactionRequest);
  281. return Ok(bookerAppCreditRequest);
  282. break;
  283. #endregion
  284. }
  285. }
  286. catch (Exception ex)
  287. {
  288. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  289. }
  290. return Ok();
  291. }
  292. /// <summary>
  293. /// Purpose : Creating credit card request
  294. /// Function Name : CreateRequest
  295. /// Created By : Salil Gupta
  296. /// Created On : 03/16/2015
  297. /// Modificatios Made : ****************************
  298. /// Modidified On : 04/017/2015 "MM/DD/YYYY"
  299. /// </summary>
  300. /// <param name="transactionRequest"></param>
  301. /// <returns></returns>
  302. private CreditRequestDetails CreateEcommerceRequest(TransactionRequest transactionRequest)
  303. {
  304. try
  305. {
  306. if (!transactionRequest.IsNull())
  307. {
  308. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  309. MethodBase.GetCurrentMethod().Name + ";");
  310. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  311. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  312. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  313. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  314. {
  315. mtdTransaction = _terminalService.Completion(
  316. transactionRequest.RapidConnectAuthId,
  317. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  318. if (mtdTransaction.IsNull())
  319. return null;
  320. }
  321. #region Common Group
  322. CommonGrp cmnGrp = new CommonGrp();
  323. /* The payment type of the transaction. */
  324. PymtTypeType typePayment = transactionRequest.PaymentType;
  325. cmnGrp.PymtType = typePayment;
  326. cmnGrp.PymtTypeSpecified = true;
  327. /* merchant category code. */
  328. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  329. /* The type of transaction being performed. */
  330. cmnGrp.TxnType = transactionRequest.TransType;
  331. cmnGrp.TxnTypeSpecified = true;
  332. /* The local date and time in which the transaction was performed. */
  333. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  334. /* The transmission date and time of the transaction (in GMT/UCT). */
  335. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  336. /* A number assigned by the merchant to uniquely reference the transaction.
  337. * This number must be unique within a day per Merchant ID per Terminal ID. */
  338. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  339. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  340. {
  341. cmnGrp.RefNum = mtdTransaction.TransRefNo;
  342. cmnGrp.OrderNum = mtdTransaction.TransOrderNo;
  343. }
  344. else
  345. {
  346. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  347. cmnGrp.OrderNum = cmnGrp.RefNum;
  348. }
  349. /* An ID assigned by First Data, for the Third Party Processor or
  350. * Software Vendor that generated the transaction. */
  351. cmnGrp.TPPID = transactionRequest.TppId;
  352. /* A unique ID assigned to a terminal. */
  353. cmnGrp.TermID = transactionRequest.TerminalId;
  354. /* A unique ID assigned by First Data, to identify the Merchant. */
  355. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  356. cmnGrp.GroupID = transactionRequest.GroupId;
  357. //Group ID value will be assigned by First Data.
  358. //get terminal id from transaction request
  359. cmnGrp.POSEntryMode = PaymentAPIResources.EcomPosEntryMode;
  360. cmnGrp.POSCondCode = POSCondCodeType.Item59;
  361. cmnGrp.POSCondCodeSpecified = true;
  362. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  363. cmnGrp.TermCatCodeSpecified = true;
  364. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item10;
  365. cmnGrp.TermEntryCapabltSpecified = true;
  366. cmnGrp.TermLocInd = TermLocIndType.Item1;
  367. cmnGrp.TermLocIndSpecified = true;
  368. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  369. cmnGrp.CardCaptCapSpecified = true;
  370. EcommGrp ecomgrp = new EcommGrp();
  371. ecomgrp.EcommTxnInd = EcommTxnIndType.Item03;
  372. ecomgrp.EcommTxnIndSpecified = true;
  373. if (!string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase))
  374. ecomgrp.EcommURL = PaymentAPIResources.EcomUrl;
  375. _creditReq.EcommGrp = ecomgrp;
  376. /* The amount of the transaction. This may be an authorization amount,
  377. * adjustment amount or a reversal based on the type of transaction.
  378. * It is inclusive of all additional amounts.
  379. * It is submitted in the currency represented by the Transaction Currency field.
  380. * The field is overwritten in the response for a partial authorization. */
  381. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  382. string amt = num.ToString("0.00").Replace(".", string.Empty);
  383. cmnGrp.TxnAmt = Convert.ToString(amt);
  384. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  385. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  386. /* An indicator that describes the location of the terminal. */
  387. /* Indicates Group ID. */
  388. _creditReq.CommonGrp = cmnGrp;
  389. #endregion
  390. CardGrp cardGrp = new CardGrp();
  391. #region Transarmor group
  392. if (string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase))
  393. {
  394. cardGrp.AcctNum = transactionRequest.CardNumber;
  395. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  396. cardGrp.CardType = transactionRequest.CardType;
  397. cardGrp.CardTypeSpecified = true;
  398. cardGrp.CCVInd = CCVIndType.Prvded;
  399. cardGrp.CCVIndSpecified = true;
  400. cardGrp.CCVData = transactionRequest.CardCvv;
  401. _creditReq.CardGrp = cardGrp;
  402. TAGrp taGrp = new TAGrp();
  403. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  404. taGrp.SctyLvlSpecified = true;
  405. taGrp.TknType = transactionRequest.TokenType;
  406. _creditReq.TAGrp = taGrp;
  407. }
  408. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.CurrentCultureIgnoreCase))
  409. {
  410. if (mtdTransaction != null)
  411. {
  412. XmlDocument xmlDoc = new XmlDocument();
  413. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  414. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  415. var response = CommonFunctions.GetMCResponse(xmlString);
  416. xmlDoc.LoadXml(response);
  417. var aVSResultCode = xmlDoc.SelectSingleNode("CreditResponse/CardGrp/AVSResultCode");
  418. var cCVResultCode = xmlDoc.SelectSingleNode("CreditResponse/CardGrp/CCVResultCode");
  419. cardGrp.CardType = transactionRequest.CardType;
  420. cardGrp.CardTypeSpecified = true;
  421. if (aVSResultCode != null)
  422. {
  423. cardGrp.AVSResultCode = (AVSResultCodeType)Enum.Parse(typeof(AVSResultCodeType), aVSResultCode.InnerText);
  424. cardGrp.AVSResultCodeSpecified = true;
  425. }
  426. if (cCVResultCode != null)
  427. {
  428. cardGrp.CCVResultCode = (CCVResultCodeType)Enum.Parse(typeof(CCVResultCodeType), cCVResultCode.InnerText);
  429. cardGrp.CCVResultCodeSpecified = true;
  430. }
  431. }
  432. _creditReq.CardGrp = cardGrp;
  433. TAGrp taGrp = new TAGrp();
  434. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  435. taGrp.SctyLvlSpecified = true;
  436. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  437. taGrp.TknType = transactionRequest.TokenType;
  438. _creditReq.TAGrp = taGrp;
  439. }
  440. if (string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.CurrentCultureIgnoreCase))
  441. {
  442. cardGrp.CardType = transactionRequest.CardType;
  443. cardGrp.CardTypeSpecified = true;
  444. _creditReq.CardGrp = cardGrp;
  445. TAGrp taGrp = new TAGrp();
  446. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  447. taGrp.SctyLvlSpecified = true;
  448. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  449. taGrp.TknType = transactionRequest.TokenType;
  450. _creditReq.TAGrp = taGrp;
  451. }
  452. #endregion
  453. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  454. {
  455. #region Additional Amount Group
  456. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  457. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  458. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  459. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  460. addAmtGrpArr[0] = addAmtGrp;
  461. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  462. #endregion
  463. }
  464. #region Visa Group
  465. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  466. {
  467. VisaGrp visaGrp = new VisaGrp();
  468. visaGrp.VisaBID = PaymentAPIResources.VisaBID;
  469. visaGrp.VisaAUAR = PaymentAPIResources.VisaAUAR;
  470. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  471. {
  472. visaGrp.ACI = ACIType.Y;
  473. visaGrp.ACISpecified = true;
  474. visaGrp.TaxAmtCapablt = TaxAmtCapabltType.Item1;
  475. visaGrp.TaxAmtCapabltSpecified = true;
  476. }
  477. else
  478. {
  479. visaGrp.ACI = ACIType.T;
  480. visaGrp.ACISpecified = true;
  481. }
  482. _creditReq.Item = visaGrp;
  483. }
  484. if (((string.Equals(cardGrp.CardType.ToString(), MasterCard, StringComparison.OrdinalIgnoreCase)) && (string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))))
  485. {
  486. MCGrp mcGrp = new MCGrp();
  487. XmlDocument xmlDoc = new XmlDocument();
  488. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  489. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  490. var response = CommonFunctions.GetMCResponse(xmlString);
  491. xmlDoc.LoadXml(response);
  492. var banknetData = xmlDoc.SelectSingleNode("CreditResponse/MCGrp/BanknetData");
  493. if (banknetData != null) { mcGrp.BanknetData = banknetData.InnerText; }
  494. _creditReq.Item = mcGrp;
  495. }
  496. #endregion
  497. #region AmexGrp Group
  498. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  499. {
  500. AmexGrp amexgrp = new AmexGrp();
  501. if (mtdTransaction != null)
  502. {
  503. amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  504. XmlDocument xmlDoc = new XmlDocument();
  505. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  506. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  507. var response = CommonFunctions.GetMCResponse(xmlString);
  508. xmlDoc.LoadXml(response);
  509. var amExPOSData = xmlDoc.SelectSingleNode("CreditResponse/AmexGrp/AmExPOSData");
  510. if (amExPOSData != null)
  511. { amexgrp.AmExPOSData = amExPOSData.InnerText; }
  512. }
  513. _creditReq.Item = amexgrp;
  514. }
  515. #endregion
  516. #region Discover Group
  517. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  518. {
  519. DSGrp dsGrp = new DSGrp();
  520. if (mtdTransaction != null)
  521. {
  522. XmlDocument xmlDoc = new XmlDocument();
  523. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  524. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  525. var response = CommonFunctions.GetMCResponse(xmlString);
  526. xmlDoc.LoadXml(response);
  527. var discProcCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscProcCode");
  528. if (discProcCode != null)
  529. {
  530. dsGrp.DiscProcCode = discProcCode.InnerText;
  531. }
  532. var discPOSEntry = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSEntry");
  533. if (discPOSEntry != null)
  534. {
  535. dsGrp.DiscPOSEntry = discPOSEntry.InnerText;
  536. }
  537. var discRespCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscRespCode");
  538. if (discRespCode != null)
  539. {
  540. dsGrp.DiscRespCode = discRespCode.InnerText;
  541. }
  542. var discPOSData = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSData");
  543. if (discPOSData != null)
  544. {
  545. dsGrp.DiscPOSData = discPOSData.InnerText;
  546. }
  547. var discTransQualifier = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscTransQualifier");
  548. if (discTransQualifier != null)
  549. {
  550. dsGrp.DiscTransQualifier = discTransQualifier.InnerText;
  551. }
  552. var discNRID = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscNRID");
  553. if (discNRID != null)
  554. {
  555. dsGrp.DiscNRID = discNRID.InnerText;
  556. }
  557. dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  558. }
  559. _creditReq.Item = dsGrp;
  560. }
  561. #endregion
  562. #region Customer info Group
  563. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress) || !string.IsNullOrEmpty(transactionRequest.ZipCode))
  564. {
  565. if (!string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  566. {
  567. CustInfoGrp custinfo = new CustInfoGrp();
  568. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress))
  569. {
  570. custinfo.AVSBillingAddr = transactionRequest.StreetAddress;
  571. }
  572. if (!string.IsNullOrEmpty(transactionRequest.ZipCode))
  573. {
  574. custinfo.AVSBillingPostalCode = transactionRequest.ZipCode;
  575. }
  576. _creditReq.CustInfoGrp = custinfo;
  577. }
  578. }
  579. #endregion
  580. #region addAm Group
  581. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  582. {
  583. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  584. if (mtdTransaction != null)
  585. {
  586. XmlDocument xmlDoc = new XmlDocument();
  587. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  588. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  589. var response = CommonFunctions.GetMCResponse(xmlString);
  590. xmlDoc.LoadXml(response);
  591. var originalamt = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  592. if (originalamt != null)
  593. {
  594. var amountP = originalamt.InnerText;
  595. addAmtGrp.AddAmt = amountP.PadLeft(12, '0');
  596. }
  597. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  598. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  599. addAmtGrp.AddAmtTypeSpecified = true;
  600. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  601. var originalamt1 = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  602. if (originalamt1 != null)
  603. {
  604. var amtP = originalamt1.InnerText;
  605. addAmtGrp1.AddAmt = amtP.PadLeft(12, '0');
  606. }
  607. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  608. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  609. addAmtGrp1.AddAmtTypeSpecified = true;
  610. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  611. addAmtGrpArr[0] = addAmtGrp;
  612. addAmtGrpArr[1] = addAmtGrp1;
  613. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  614. }
  615. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  616. if (mtdTransaction != null)
  617. {
  618. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  619. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  620. XmlDocument xmlDoc = new XmlDocument();
  621. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  622. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  623. if (trnmsnDateTime != null)
  624. {
  625. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  626. }
  627. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan);
  628. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode);
  629. }
  630. _creditReq.OrigAuthGrp = orgAuthgrp;
  631. }
  632. #endregion
  633. _gmfMsgVar.Item = _creditReq;
  634. transactionRequest.Stan = cmnGrp.STAN;
  635. transactionRequest.TransRefNo = cmnGrp.RefNum;
  636. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  637. return _creditReq;
  638. }
  639. }
  640. catch (Exception ex)
  641. {
  642. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  643. }
  644. return null;
  645. }
  646. /// <summary>
  647. /// Purpose : Creating credit card request
  648. /// Function Name : CreateRequest
  649. /// Created By : Salil Gupta
  650. /// Created On : 03/16/2015
  651. /// Modificatios Made : Madhuri Tanwar
  652. /// Modidified On : 06/012/2015 "MM/DD/YYYY"
  653. /// </summary>
  654. /// <param name="transactionRequest"></param>
  655. /// <returns></returns>
  656. private CreditRequestDetails CreateRetailRequest(TransactionRequest transactionRequest)
  657. {
  658. try
  659. {
  660. if (!transactionRequest.IsNull())
  661. {
  662. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  663. MethodBase.GetCurrentMethod().Name + ";");
  664. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  665. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  666. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  667. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  668. {
  669. mtdTransaction = _terminalService.Completion(
  670. transactionRequest.RapidConnectAuthId,
  671. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  672. if (mtdTransaction.IsNull())
  673. return null;
  674. }
  675. #region Common Group
  676. CommonGrp cmnGrp = new CommonGrp();
  677. /* The payment type of the transaction. */
  678. PymtTypeType typePayment = transactionRequest.PaymentType;
  679. cmnGrp.PymtType = typePayment;
  680. cmnGrp.PymtTypeSpecified = true;
  681. /* merchant category code. */
  682. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  683. /* The type of transaction being performed. */
  684. cmnGrp.TxnType = transactionRequest.TransType;
  685. cmnGrp.TxnTypeSpecified = true;
  686. /* The local date and time in which the transaction was performed. */
  687. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  688. /* The transmission date and time of the transaction (in GMT/UCT). */
  689. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  690. /* A number assigned by the merchant to uniquely reference the transaction.
  691. * This number must be unique within a day per Merchant ID per Terminal ID. */
  692. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  693. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  694. //cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MerchantID, transactionRequest.TerminalID);//"480061115979";
  695. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  696. {
  697. cmnGrp.RefNum = mtdTransaction.TransRefNo;
  698. cmnGrp.OrderNum = mtdTransaction.TransOrderNo;
  699. }
  700. else
  701. {
  702. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  703. cmnGrp.OrderNum = cmnGrp.RefNum;
  704. }
  705. /* An ID assigned by First Data, for the Third Party Processor or
  706. * Software Vendor that generated the transaction. */
  707. cmnGrp.TPPID = transactionRequest.TppId;
  708. /* A unique ID assigned to a terminal. */
  709. cmnGrp.TermID = transactionRequest.TerminalId;
  710. //get terminal id from transaction request
  711. /* A unique ID assigned by First Data, to identify the Merchant. */
  712. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  713. cmnGrp.GroupID = transactionRequest.GroupId;
  714. //Group ID value will be assigned by First Data.
  715. //get terminal id from transaction request
  716. cmnGrp.POSEntryMode = PaymentAPIResources.RetailPosEntryMode;
  717. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  718. cmnGrp.POSCondCodeSpecified = true;
  719. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  720. cmnGrp.TermCatCodeSpecified = true;
  721. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  722. cmnGrp.TermEntryCapabltSpecified = true;
  723. cmnGrp.TermLocInd = TermLocIndType.Item0;
  724. cmnGrp.TermLocIndSpecified = true;
  725. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  726. cmnGrp.CardCaptCapSpecified = true;
  727. /* The amount of the transaction. This may be an authorization amount,
  728. * adjustment amount or a reversal amount based on the type of transaction.
  729. * It is inclusive of all additional amounts.
  730. * It is submitted in the currency represented by the Transaction Currency field.
  731. * The field is overwritten in the response for a partial authorization. */
  732. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  733. string amt = num.ToString("0.00").Replace(".", string.Empty);
  734. cmnGrp.TxnAmt = Convert.ToString(amt);
  735. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  736. /* The numeric currency of the Transaction Amount. */
  737. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  738. _creditReq.CommonGrp = cmnGrp;
  739. #endregion
  740. #region Transarmor group
  741. CardGrp cardGrp = new CardGrp();
  742. if (string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase))
  743. {
  744. cardGrp.CardType = transactionRequest.CardType;
  745. cardGrp.CardTypeSpecified = true;
  746. _creditReq.CardGrp = cardGrp;
  747. TAGrp taGrp = new TAGrp();
  748. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  749. taGrp.SctyLvlSpecified = true;
  750. taGrp.EncrptType = EncrptTypeType.RSA;
  751. taGrp.EncrptTypeSpecified = true;
  752. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  753. taGrp.EncrptTrgtSpecified = true;
  754. taGrp.KeyID = transactionRequest.KeyId;
  755. taGrp.EncrptBlock = transactionRequest.Track3Data;
  756. taGrp.TknType = transactionRequest.TokenType;
  757. _creditReq.TAGrp = taGrp;
  758. }
  759. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.CurrentCultureIgnoreCase))
  760. {
  761. if (mtdTransaction != null) cardGrp.CardType = (CardTypeType)Enum.Parse(typeof(CardTypeType), mtdTransaction.CardType);
  762. transactionRequest.CardType = cardGrp.CardType;
  763. cardGrp.CardTypeSpecified = true;
  764. _creditReq.CardGrp = cardGrp;
  765. TAGrp taGrp = new TAGrp();
  766. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  767. taGrp.SctyLvlSpecified = true;
  768. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  769. taGrp.TknType = transactionRequest.TokenType;
  770. _creditReq.TAGrp = taGrp;
  771. }
  772. #endregion
  773. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  774. {
  775. #region Additional Amount Group
  776. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  777. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  778. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  779. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  780. addAmtGrpArr[0] = addAmtGrp;
  781. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  782. #endregion
  783. }
  784. #region Visa Group
  785. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  786. {
  787. VisaGrp visaGrp = new VisaGrp();
  788. visaGrp.VisaBID = PaymentAPIResources.VisaBID;
  789. visaGrp.VisaAUAR = PaymentAPIResources.VisaAUAR;
  790. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  791. {
  792. visaGrp.ACI = ACIType.Y;
  793. visaGrp.ACISpecified = true;
  794. visaGrp.TaxAmtCapablt = TaxAmtCapabltType.Item1;
  795. visaGrp.TaxAmtCapabltSpecified = true;
  796. }
  797. else
  798. if (mtdTransaction != null)
  799. {
  800. XmlDocument xmlDoc = new XmlDocument();
  801. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  802. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  803. var response = CommonFunctions.GetMCResponse(xmlString);
  804. xmlDoc.LoadXml(response);
  805. var aCI = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/ACI");
  806. if (aCI != null)
  807. {
  808. visaGrp.ACI = (ACIType)Enum.Parse(typeof(ACIType), aCI.InnerText);
  809. visaGrp.ACISpecified = true;
  810. }
  811. var cardLevelResult = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/CardLevelResult");
  812. if (cardLevelResult != null)
  813. {
  814. visaGrp.CardLevelResult = cardLevelResult.InnerText;
  815. }
  816. var transID = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/TransID");
  817. if (transID != null)
  818. {
  819. visaGrp.TransID = transID.InnerText;
  820. }
  821. }
  822. _creditReq.Item = visaGrp;
  823. }
  824. if (((string.Equals(cardGrp.CardType.ToString(), MasterCard, StringComparison.OrdinalIgnoreCase)) && (string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))))
  825. {
  826. MCGrp mcGrp = new MCGrp();
  827. XmlDocument xmlDoc = new XmlDocument();
  828. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  829. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  830. var response = CommonFunctions.GetMCResponse(xmlString);
  831. xmlDoc.LoadXml(response);
  832. var banknetData = xmlDoc.SelectSingleNode("CreditResponse/MCGrp/BanknetData");
  833. if (banknetData != null)
  834. {
  835. mcGrp.BanknetData = banknetData.InnerText;
  836. }
  837. _creditReq.Item = mcGrp;
  838. }
  839. #endregion
  840. #region AmexGrp Group
  841. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  842. {
  843. AmexGrp amexgrp = new AmexGrp();
  844. if (mtdTransaction != null)
  845. {
  846. amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  847. XmlDocument xmlDoc = new XmlDocument();
  848. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  849. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  850. var response = CommonFunctions.GetMCResponse(xmlString);
  851. xmlDoc.LoadXml(response);
  852. var amExPOSData = xmlDoc.SelectSingleNode("CreditResponse/AmexGrp/AmExPOSData");
  853. if (amExPOSData != null)
  854. {
  855. amexgrp.AmExPOSData = amExPOSData.InnerText;
  856. }
  857. }
  858. _creditReq.Item = amexgrp;
  859. }
  860. #endregion
  861. #region Discover Group
  862. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  863. {
  864. DSGrp dsGrp = new DSGrp();
  865. if (mtdTransaction != null)
  866. {
  867. XmlDocument xmlDoc = new XmlDocument();
  868. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  869. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  870. var response = CommonFunctions.GetMCResponse(xmlString);
  871. xmlDoc.LoadXml(response);
  872. var discProcCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscProcCode");
  873. if (discProcCode != null)
  874. {
  875. dsGrp.DiscProcCode = discProcCode.InnerText;
  876. }
  877. var discPOSEntry = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSEntry");
  878. if (discPOSEntry != null)
  879. {
  880. dsGrp.DiscPOSEntry = discPOSEntry.InnerText;
  881. }
  882. var discRespCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscRespCode");
  883. if (discRespCode != null)
  884. {
  885. dsGrp.DiscRespCode = discRespCode.InnerText;
  886. }
  887. var discPOSData = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSData");
  888. if (discPOSData != null)
  889. {
  890. dsGrp.DiscPOSData = discPOSData.InnerText;
  891. }
  892. var discTransQualifier = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscTransQualifier");
  893. if (discTransQualifier != null)
  894. {
  895. dsGrp.DiscTransQualifier = discTransQualifier.InnerText;
  896. }
  897. var discNRID = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscNRID");
  898. if (discNRID != null)
  899. {
  900. dsGrp.DiscNRID = discNRID.InnerText;
  901. }
  902. dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  903. }
  904. _creditReq.Item = dsGrp;
  905. }
  906. #endregion
  907. #region Customer info Group
  908. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress) || !string.IsNullOrEmpty(transactionRequest.ZipCode))
  909. {
  910. if (!string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  911. {
  912. CustInfoGrp custinfo = new CustInfoGrp();
  913. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress))
  914. {
  915. custinfo.AVSBillingAddr = transactionRequest.StreetAddress;
  916. }
  917. if (!string.IsNullOrEmpty(transactionRequest.ZipCode))
  918. {
  919. custinfo.AVSBillingPostalCode = transactionRequest.ZipCode;
  920. }
  921. _creditReq.CustInfoGrp = custinfo;
  922. }
  923. }
  924. #endregion
  925. #region addAm Group
  926. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  927. {
  928. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  929. if (mtdTransaction != null)
  930. {
  931. XmlDocument xmlDoc = new XmlDocument();
  932. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  933. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  934. var response = CommonFunctions.GetMCResponse(xmlString);
  935. xmlDoc.LoadXml(response);
  936. var originalamt = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  937. if (originalamt != null)
  938. {
  939. var amntP = originalamt.InnerText;
  940. addAmtGrp.AddAmt = amntP.PadLeft(12, '0');
  941. }
  942. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  943. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  944. addAmtGrp.AddAmtTypeSpecified = true;
  945. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  946. var originalamt1 = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  947. if (originalamt1 != null)
  948. {
  949. var amnt = originalamt1.InnerText;
  950. addAmtGrp1.AddAmt = amnt.PadLeft(12, '0');
  951. }
  952. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  953. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  954. addAmtGrp1.AddAmtTypeSpecified = true;
  955. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  956. addAmtGrpArr[0] = addAmtGrp;
  957. addAmtGrpArr[1] = addAmtGrp1;
  958. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  959. }
  960. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  961. if (mtdTransaction != null)
  962. {
  963. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  964. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  965. XmlDocument xmlDoc = new XmlDocument();
  966. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  967. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  968. if (trnmsnDateTime != null)
  969. {
  970. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  971. }
  972. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan);
  973. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode);
  974. }
  975. _creditReq.OrigAuthGrp = orgAuthgrp;
  976. }
  977. #endregion
  978. /* Add the data populated object to GMF message variant object */
  979. _gmfMsgVar.Item = _creditReq;
  980. transactionRequest.Stan = cmnGrp.STAN;
  981. transactionRequest.TransRefNo = cmnGrp.RefNum;
  982. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  983. return _creditReq;
  984. }
  985. }
  986. catch (Exception ex)
  987. {
  988. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  989. }
  990. return null;
  991. }
  992. /// <summary>
  993. /// Purpose : Creating credit card request
  994. /// Function Name : CreateRequest
  995. /// Created By : Madhuri Tanwar
  996. /// Created On : 06/5/2015
  997. /// Modificatios Made : ****************************
  998. /// Modidified On : 06/5/2015 "MM/DD/YYYY"
  999. /// </summary>
  1000. /// <param name="transactionRequest"></param>
  1001. /// <returns></returns>
  1002. private CreditRequestDetails CreateEmvContactRequest(TransactionRequest transactionRequest)
  1003. {
  1004. try
  1005. {
  1006. if (!transactionRequest.IsNull())
  1007. {
  1008. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  1009. MethodBase.GetCurrentMethod().Name + ";");
  1010. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  1011. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  1012. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  1013. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  1014. {
  1015. mtdTransaction = _terminalService.Completion(
  1016. transactionRequest.RapidConnectAuthId,
  1017. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  1018. if (mtdTransaction.IsNull())
  1019. return null;
  1020. }
  1021. #region Common Group
  1022. CommonGrp cmnGrp = new CommonGrp();
  1023. /* The payment type of the transaction. */
  1024. PymtTypeType typePayment = transactionRequest.PaymentType;
  1025. cmnGrp.PymtType = typePayment;
  1026. cmnGrp.PymtTypeSpecified = true;
  1027. /* merchant category code. */
  1028. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  1029. /* The type of transaction being performed. */
  1030. cmnGrp.TxnType = transactionRequest.TransType;
  1031. cmnGrp.TxnTypeSpecified = true;
  1032. /* The local date and time in which the transaction was performed. */
  1033. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  1034. /* The transmission date and time of the transaction (in GMT/UCT). */
  1035. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  1036. /* A number assigned by the merchant to uniquely reference the transaction.
  1037. * This number must be unique within a day per Merchant ID per Terminal ID. */
  1038. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1039. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  1040. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1041. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  1042. cmnGrp.OrderNum = cmnGrp.RefNum;
  1043. /* An ID assigned by First Data, for the Third Party Processor or
  1044. * Software Vendor that generated the transaction. */
  1045. cmnGrp.TPPID = transactionRequest.TppId;
  1046. /* A unique ID assigned to a terminal. */
  1047. cmnGrp.TermID = transactionRequest.TerminalId;
  1048. //get terminal id from transaction request
  1049. /* A unique ID assigned by First Data, to identify the Merchant. */
  1050. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  1051. cmnGrp.GroupID = transactionRequest.GroupId;
  1052. //Group ID value will be assigned by First Data.
  1053. //get terminal id from transaction request
  1054. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactEMVPosEntryMode;
  1055. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  1056. cmnGrp.POSCondCodeSpecified = true;
  1057. // cmnGrp.TermCatCode = TermCatCodeType.Item01;
  1058. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  1059. cmnGrp.TermCatCodeSpecified = true;
  1060. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  1061. cmnGrp.TermEntryCapabltSpecified = true;
  1062. cmnGrp.TermLocInd = TermLocIndType.Item0;
  1063. cmnGrp.TermLocIndSpecified = true;
  1064. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  1065. cmnGrp.CardCaptCapSpecified = true;
  1066. /* The amount of the transaction. This may be an authorization amount,
  1067. * adjustment amount or a reversal amount based on the type of transaction.
  1068. * It is inclusive of all additional amounts.
  1069. * It is submitted in the currency represented by the Transaction Currency field.
  1070. * The field is overwritten in the response for a partial authorization. */
  1071. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  1072. string amt = num.ToString("0.00").Replace(".", string.Empty);
  1073. cmnGrp.TxnAmt = Convert.ToString(amt);
  1074. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  1075. /* The numeric currency of the Transaction Amount. */
  1076. cmnGrp.TxnCrncy = transactionRequest.CurrencyCode;
  1077. /* An indicator that describes the location of the terminal. */
  1078. /* Indicates Group ID. */
  1079. _creditReq.CommonGrp = cmnGrp;
  1080. #endregion
  1081. CardGrp cardGrp = new CardGrp();
  1082. #region Transarmor group
  1083. if (string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase))
  1084. {
  1085. cardGrp.CardType = transactionRequest.CardType;
  1086. cardGrp.CardTypeSpecified = true;
  1087. _creditReq.CardGrp = cardGrp;
  1088. //For RSA
  1089. TAGrp taGrp = new TAGrp();
  1090. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  1091. taGrp.SctyLvlSpecified = true;
  1092. taGrp.EncrptType = EncrptTypeType.RSA;
  1093. taGrp.EncrptTypeSpecified = true;
  1094. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  1095. taGrp.EncrptTrgtSpecified = true;
  1096. taGrp.KeyID = transactionRequest.KeyId;
  1097. taGrp.EncrptBlock = transactionRequest.Track3Data;
  1098. taGrp.TknType = transactionRequest.TokenType;
  1099. _creditReq.TAGrp = taGrp;
  1100. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.CurrentCultureIgnoreCase))
  1101. {
  1102. //cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  1103. cardGrp.CardType = transactionRequest.CardType;
  1104. cardGrp.CardTypeSpecified = true;
  1105. _creditReq.CardGrp = cardGrp;
  1106. TAGrp taGrp1 = new TAGrp();
  1107. taGrp1.SctyLvl = SctyLvlType.EncrptTknizatn;
  1108. taGrp1.SctyLvlSpecified = true;
  1109. taGrp1.Tkn = mtdTransaction.CardToken.Decrypt();
  1110. taGrp1.TknType = transactionRequest.TokenType;
  1111. _creditReq.TAGrp = taGrp1;
  1112. }
  1113. #endregion
  1114. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  1115. {
  1116. #region Additional Amount Group
  1117. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1118. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  1119. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  1120. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  1121. addAmtGrpArr[0] = addAmtGrp;
  1122. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  1123. #endregion
  1124. }
  1125. #region emv group
  1126. EMVGrp emvGrp = new EMVGrp();
  1127. emvGrp.EMVData = transactionRequest.EmvData;
  1128. if (transactionRequest.CardSeq != null && transactionRequest.CardSeq != "000")
  1129. {
  1130. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  1131. }
  1132. _creditReq.EMVGrp = emvGrp;
  1133. #endregion
  1134. #region PIN Group
  1135. if (!string.IsNullOrEmpty(transactionRequest.DebitPin) && !string.IsNullOrEmpty(transactionRequest.KeySerialNumber))
  1136. {
  1137. PINGrp pinGroup = new PINGrp();
  1138. pinGroup.PINData = transactionRequest.DebitPin;
  1139. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber;
  1140. _creditReq.PINGrp = pinGroup;
  1141. }
  1142. #endregion
  1143. #region Visa Group
  1144. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  1145. {
  1146. VisaGrp visaGrp = new VisaGrp();
  1147. visaGrp.ACI = ACIType.Y;
  1148. visaGrp.ACISpecified = true;
  1149. _creditReq.Item = visaGrp;
  1150. }
  1151. #endregion
  1152. #region AmexGrp Group
  1153. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1154. {
  1155. AmexGrp amexgrp = new AmexGrp();
  1156. if (mtdTransaction != null) amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  1157. _creditReq.Item = amexgrp;
  1158. }
  1159. #endregion
  1160. #region Discover Group
  1161. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  1162. {
  1163. DSGrp dsGrp = new DSGrp();
  1164. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  1165. _creditReq.Item = dsGrp;
  1166. }
  1167. #endregion
  1168. #region addAm Group
  1169. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1170. {
  1171. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1172. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  1173. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  1174. addAmtGrp.AddAmt = addamt;
  1175. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  1176. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1177. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  1178. addAmtGrp.AddAmtTypeSpecified = true;
  1179. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  1180. addAmtGrp1.AddAmt = addamt;
  1181. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  1182. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1183. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  1184. addAmtGrp1.AddAmtTypeSpecified = true;
  1185. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  1186. addAmtGrpArr[0] = addAmtGrp;
  1187. addAmtGrpArr[1] = addAmtGrp1;
  1188. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  1189. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  1190. if (mtdTransaction != null)
  1191. {
  1192. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId; // "OK3542";
  1193. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  1194. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  1195. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan); //"000001";
  1196. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode); //"002";
  1197. }
  1198. _creditReq.OrigAuthGrp = orgAuthgrp;
  1199. }
  1200. #endregion
  1201. /* Add the data populated object to GMF message variant object */
  1202. _gmfMsgVar.Item = _creditReq;
  1203. transactionRequest.Stan = cmnGrp.STAN;
  1204. transactionRequest.TransRefNo = cmnGrp.RefNum;
  1205. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  1206. return _creditReq;
  1207. }
  1208. }
  1209. }
  1210. catch (Exception ex)
  1211. {
  1212. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  1213. }
  1214. return null;
  1215. }
  1216. /// <summary>
  1217. /// Purpose : Creating pinless debit request
  1218. /// Function Name : CreateEmvContactlessRequest
  1219. /// Created By : Madhuri Tanwar
  1220. /// Created On : 01/11/2016
  1221. /// Modificatios Made : ****************************
  1222. /// Modidified On : "MM/DD/YYYY"
  1223. /// </summary>
  1224. /// <param name="transactionRequest"></param>
  1225. /// <returns></returns>
  1226. private CreditRequestDetails CreateEmvContactlessRequest(TransactionRequest transactionRequest)
  1227. {
  1228. try
  1229. {
  1230. if (!transactionRequest.IsNull())
  1231. {
  1232. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " + MethodBase.GetCurrentMethod().Name + ";");
  1233. _logMessage.Append(String.Format(CultureInfo.InvariantCulture, " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  1234. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  1235. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  1236. {
  1237. mtdTransaction = _terminalService.Completion(
  1238. transactionRequest.RapidConnectAuthId,
  1239. transactionRequest.SerialNumber,
  1240. transactionRequest.MtdMerchantId);
  1241. if (mtdTransaction.IsNull())
  1242. return null;
  1243. }
  1244. #region Common Group
  1245. CommonGrp cmnGrp = new CommonGrp();
  1246. /* The payment type of the transaction. */
  1247. PymtTypeType typePayment = transactionRequest.PaymentType;
  1248. cmnGrp.PymtType = typePayment;
  1249. cmnGrp.PymtTypeSpecified = true;
  1250. /* merchant category code. */
  1251. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  1252. /* The type of transaction being performed. */
  1253. cmnGrp.TxnType = transactionRequest.TransType;
  1254. cmnGrp.TxnTypeSpecified = true;
  1255. /* The local date and time in which the transaction was performed. */
  1256. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  1257. /* The transmission date and time of the transaction (in GMT/UCT). */
  1258. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  1259. /* A number assigned by the merchant to uniquely reference the transaction.
  1260. * This number must be unique within a day per Merchant ID per Terminal ID. */
  1261. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1262. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  1263. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1264. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  1265. cmnGrp.OrderNum = cmnGrp.RefNum;
  1266. /* An ID assigned by First Data, for the Third Party Processor or
  1267. * Software Vendor that generated the transaction. */
  1268. cmnGrp.TPPID = transactionRequest.TppId;
  1269. /* A unique ID assigned to a terminal. */
  1270. cmnGrp.TermID = transactionRequest.TerminalId;
  1271. //get terminal id from transaction request
  1272. /* A unique ID assigned by First Data, to identify the Merchant. */
  1273. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  1274. cmnGrp.GroupID = transactionRequest.GroupId;
  1275. //Group ID value will be assigned by First Data.
  1276. //get terminal id from transaction request
  1277. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactlessEMVPosEntryMode;
  1278. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  1279. cmnGrp.POSCondCodeSpecified = true;
  1280. // cmnGrp.TermCatCode = TermCatCodeType.Item01;
  1281. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  1282. cmnGrp.TermCatCodeSpecified = true;
  1283. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  1284. cmnGrp.TermEntryCapabltSpecified = true;
  1285. cmnGrp.TermLocInd = TermLocIndType.Item0;
  1286. cmnGrp.TermLocIndSpecified = true;
  1287. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  1288. cmnGrp.CardCaptCapSpecified = true;
  1289. /* The amount of the transaction. This may be an authorization amount,
  1290. * adjustment amount or a reversal amount based on the type of transaction.
  1291. * It is inclusive of all additional amounts.
  1292. * It is submitted in the currency represented by the Transaction Currency field.
  1293. * The field is overwritten in the response for a partial authorization. */
  1294. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  1295. string amt = num.ToString("0.00").Replace(".", string.Empty);
  1296. cmnGrp.TxnAmt = Convert.ToString(amt);
  1297. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  1298. /* The numeric currency of the Transaction Amount. */
  1299. cmnGrp.TxnCrncy = transactionRequest.CurrencyCode;
  1300. /* An indicator that describes the location of the terminal. */
  1301. /* Indicates Group ID. */
  1302. _creditReq.CommonGrp = cmnGrp;
  1303. #endregion
  1304. CardGrp cardGrp = new CardGrp();
  1305. #region Transarmor group
  1306. if (string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase))
  1307. {
  1308. cardGrp.CardType = transactionRequest.CardType;
  1309. cardGrp.CardTypeSpecified = true;
  1310. if ((!string.Equals(cardGrp.CardType.ToString(), MasterCard, StringComparison.OrdinalIgnoreCase)) || (!string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase)))
  1311. {
  1312. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  1313. }
  1314. _creditReq.CardGrp = cardGrp;
  1315. //For RSA
  1316. TAGrp taGrp = new TAGrp();
  1317. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  1318. taGrp.SctyLvlSpecified = true;
  1319. taGrp.EncrptType = EncrptTypeType.RSA;
  1320. taGrp.EncrptTypeSpecified = true;
  1321. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  1322. taGrp.EncrptTrgtSpecified = true;
  1323. taGrp.KeyID = transactionRequest.KeyId;
  1324. taGrp.EncrptBlock = transactionRequest.Track3Data;
  1325. taGrp.TknType = transactionRequest.TokenType;
  1326. _creditReq.TAGrp = taGrp;
  1327. }
  1328. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.CurrentCultureIgnoreCase))
  1329. {
  1330. cardGrp.CardType = transactionRequest.CardType;
  1331. cardGrp.CardTypeSpecified = true;
  1332. _creditReq.CardGrp = cardGrp;
  1333. TAGrp taGrp = new TAGrp();
  1334. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  1335. taGrp.SctyLvlSpecified = true;
  1336. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  1337. taGrp.TknType = transactionRequest.TokenType;
  1338. _creditReq.TAGrp = taGrp;
  1339. }
  1340. #endregion
  1341. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  1342. {
  1343. #region Additional Amount Group
  1344. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1345. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  1346. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  1347. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  1348. addAmtGrpArr[0] = addAmtGrp;
  1349. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  1350. #endregion
  1351. }
  1352. #region emv group
  1353. EMVGrp emvGrp = new EMVGrp();
  1354. emvGrp.EMVData = transactionRequest.EmvData;
  1355. if (transactionRequest.CardSeq != null && transactionRequest.CardSeq != "000")
  1356. {
  1357. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  1358. }
  1359. _creditReq.EMVGrp = emvGrp;
  1360. #endregion
  1361. #region Visa Group
  1362. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  1363. {
  1364. VisaGrp visaGrp = new VisaGrp();
  1365. //visaGrp.VisaBID = PaymentAPIResources.VisaBID;
  1366. //visaGrp.VisaAUAR = PaymentAPIResources.VisaAUAR;
  1367. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1368. {
  1369. visaGrp.ACI = ACIType.Y;
  1370. visaGrp.ACISpecified = true;
  1371. //visaGrp.TaxAmtCapablt = TaxAmtCapabltType.Item1;
  1372. //visaGrp.TaxAmtCapabltSpecified = true;
  1373. }
  1374. else
  1375. {
  1376. visaGrp.ACI = ACIType.T;
  1377. visaGrp.ACISpecified = true;
  1378. }
  1379. _creditReq.Item = visaGrp;
  1380. }
  1381. if (string.Equals(cardGrp.CardType.ToString(), MasterCard, StringComparison.OrdinalIgnoreCase))
  1382. {
  1383. MCGrp mcGrp = new MCGrp();
  1384. mcGrp.DevTypeInd = "0";
  1385. _creditReq.Item = mcGrp;
  1386. }
  1387. #endregion
  1388. #region PIN Group
  1389. if (!string.IsNullOrEmpty(transactionRequest.DebitPin) && !string.IsNullOrEmpty(transactionRequest.KeySerialNumber))
  1390. {
  1391. PINGrp pinGroup = new PINGrp();
  1392. pinGroup.PINData = transactionRequest.DebitPin;
  1393. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber;
  1394. _creditReq.PINGrp = pinGroup;
  1395. }
  1396. #endregion
  1397. #region AmexGrp Group
  1398. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1399. {
  1400. AmexGrp amexgrp = new AmexGrp();
  1401. if (mtdTransaction != null) amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  1402. _creditReq.Item = amexgrp;
  1403. }
  1404. #endregion
  1405. #region Discover Group
  1406. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  1407. {
  1408. DSGrp dsGrp = new DSGrp();
  1409. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  1410. _creditReq.Item = dsGrp;
  1411. }
  1412. #endregion
  1413. #region addAm Group
  1414. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1415. {
  1416. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1417. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  1418. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  1419. addAmtGrp.AddAmt = addamt;
  1420. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  1421. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1422. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  1423. addAmtGrp.AddAmtTypeSpecified = true;
  1424. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  1425. addAmtGrp1.AddAmt = addamt;
  1426. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  1427. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1428. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  1429. addAmtGrp1.AddAmtTypeSpecified = true;
  1430. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  1431. addAmtGrpArr[0] = addAmtGrp;
  1432. addAmtGrpArr[1] = addAmtGrp1;
  1433. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  1434. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  1435. if (mtdTransaction != null)
  1436. {
  1437. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId; // "OK3542";
  1438. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  1439. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  1440. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan); //"000001";
  1441. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode); //"002";
  1442. }
  1443. _creditReq.OrigAuthGrp = orgAuthgrp;
  1444. }
  1445. #endregion
  1446. /* Add the data populated object to GMF message variant object */
  1447. _gmfMsgVar.Item = _creditReq;
  1448. transactionRequest.Stan = cmnGrp.STAN;
  1449. transactionRequest.TransRefNo = cmnGrp.RefNum;
  1450. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  1451. return _creditReq;
  1452. }
  1453. }
  1454. catch (Exception ex)
  1455. {
  1456. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  1457. }
  1458. return null;
  1459. }
  1460. /// <summary>
  1461. /// Purpose : Creating credit card request
  1462. /// Function Name : CreateRequest
  1463. /// Created By : Madhuri Tanwar
  1464. /// Created On : 02/27/2016
  1465. /// Modificatios Made : Madhuri Tanwar
  1466. /// Modidified On : "MM/DD/YYYY"
  1467. /// </summary>
  1468. /// <param name="transactionRequest"></param>
  1469. /// <returns></returns>
  1470. private CreditRequestDetails CreateMSRContactlessRequest(TransactionRequest transactionRequest)
  1471. {
  1472. try
  1473. {
  1474. if (!transactionRequest.IsNull())
  1475. {
  1476. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  1477. MethodBase.GetCurrentMethod().Name + ";");
  1478. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  1479. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  1480. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  1481. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  1482. {
  1483. mtdTransaction = _terminalService.Completion(
  1484. transactionRequest.RapidConnectAuthId,
  1485. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  1486. if (mtdTransaction.IsNull())
  1487. return null;
  1488. }
  1489. #region Common Group
  1490. CommonGrp cmnGrp = new CommonGrp();
  1491. /* The payment type of the transaction. */
  1492. PymtTypeType typePayment = transactionRequest.PaymentType;
  1493. cmnGrp.PymtType = typePayment;
  1494. cmnGrp.PymtTypeSpecified = true;
  1495. /* merchant category code. */
  1496. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  1497. /* The type of transaction being performed. */
  1498. cmnGrp.TxnType = transactionRequest.TransType;
  1499. cmnGrp.TxnTypeSpecified = true;
  1500. /* The local date and time in which the transaction was performed. */
  1501. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  1502. /* The transmission date and time of the transaction (in GMT/UCT). */
  1503. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  1504. /* A number assigned by the merchant to uniquely reference the transaction.
  1505. * This number must be unique within a day per Merchant ID per Terminal ID. */
  1506. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1507. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  1508. //cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MerchantID, transactionRequest.TerminalID);//"480061115979";
  1509. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1510. {
  1511. cmnGrp.RefNum = mtdTransaction.TransRefNo;
  1512. cmnGrp.OrderNum = mtdTransaction.TransOrderNo;
  1513. }
  1514. else
  1515. {
  1516. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1517. cmnGrp.OrderNum = cmnGrp.RefNum;
  1518. }
  1519. /* An ID assigned by First Data, for the Third Party Processor or
  1520. * Software Vendor that generated the transaction. */
  1521. cmnGrp.TPPID = transactionRequest.TppId;
  1522. /* A unique ID assigned to a terminal. */
  1523. cmnGrp.TermID = transactionRequest.TerminalId;
  1524. //get terminal id from transaction request
  1525. /* A unique ID assigned by First Data, to identify the Merchant. */
  1526. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  1527. cmnGrp.GroupID = transactionRequest.GroupId;
  1528. //Group ID value will be assigned by First Data.
  1529. //get terminal id from transaction request
  1530. cmnGrp.POSEntryMode = PaymentAPIResources.MSRContactlessEntryMode;
  1531. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  1532. cmnGrp.POSCondCodeSpecified = true;
  1533. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  1534. cmnGrp.TermCatCodeSpecified = true;
  1535. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  1536. cmnGrp.TermEntryCapabltSpecified = true;
  1537. cmnGrp.TermLocInd = TermLocIndType.Item0;
  1538. cmnGrp.TermLocIndSpecified = true;
  1539. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  1540. cmnGrp.CardCaptCapSpecified = true;
  1541. /* The amount of the transaction. This may be an authorization amount,
  1542. * adjustment amount or a reversal amount based on the type of transaction.
  1543. * It is inclusive of all additional amounts.
  1544. * It is submitted in the currency represented by the Transaction Currency field.
  1545. * The field is overwritten in the response for a partial authorization. */
  1546. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  1547. string amt = num.ToString("0.00").Replace(".", string.Empty);
  1548. cmnGrp.TxnAmt = Convert.ToString(amt);
  1549. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  1550. /* The numeric currency of the Transaction Amount. */
  1551. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  1552. _creditReq.CommonGrp = cmnGrp;
  1553. #endregion
  1554. #region Transarmor group
  1555. CardGrp cardGrp = new CardGrp();
  1556. if (string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase))
  1557. {
  1558. cardGrp.CardType = transactionRequest.CardType;
  1559. cardGrp.CardTypeSpecified = true;
  1560. _creditReq.CardGrp = cardGrp;
  1561. TAGrp taGrp = new TAGrp();
  1562. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  1563. taGrp.SctyLvlSpecified = true;
  1564. taGrp.EncrptType = EncrptTypeType.RSA;
  1565. taGrp.EncrptTypeSpecified = true;
  1566. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  1567. taGrp.EncrptTrgtSpecified = true;
  1568. taGrp.KeyID = transactionRequest.KeyId;
  1569. taGrp.EncrptBlock = transactionRequest.Track3Data;
  1570. taGrp.TknType = transactionRequest.TokenType;
  1571. _creditReq.TAGrp = taGrp;
  1572. }
  1573. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.CurrentCultureIgnoreCase))
  1574. {
  1575. if (mtdTransaction != null) cardGrp.CardType = (CardTypeType)Enum.Parse(typeof(CardTypeType), mtdTransaction.CardType);
  1576. transactionRequest.CardType = cardGrp.CardType;
  1577. cardGrp.CardTypeSpecified = true;
  1578. _creditReq.CardGrp = cardGrp;
  1579. TAGrp taGrp = new TAGrp();
  1580. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  1581. taGrp.SctyLvlSpecified = true;
  1582. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  1583. taGrp.TknType = transactionRequest.TokenType;
  1584. _creditReq.TAGrp = taGrp;
  1585. }
  1586. #endregion
  1587. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  1588. {
  1589. #region Additional Amount Group
  1590. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1591. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  1592. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  1593. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  1594. addAmtGrpArr[0] = addAmtGrp;
  1595. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  1596. #endregion
  1597. }
  1598. #region Visa Group
  1599. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  1600. {
  1601. VisaGrp visaGrp = new VisaGrp();
  1602. visaGrp.VisaBID = PaymentAPIResources.VisaBID;
  1603. visaGrp.VisaAUAR = PaymentAPIResources.VisaAUAR;
  1604. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1605. {
  1606. visaGrp.ACI = ACIType.Y;
  1607. visaGrp.ACISpecified = true;
  1608. visaGrp.TaxAmtCapablt = TaxAmtCapabltType.Item1;
  1609. visaGrp.TaxAmtCapabltSpecified = true;
  1610. }
  1611. _creditReq.Item = visaGrp;
  1612. }
  1613. if (string.Equals(cardGrp.CardType.ToString(), MasterCard, StringComparison.OrdinalIgnoreCase))
  1614. {
  1615. MCGrp mcGrp = new MCGrp();
  1616. mcGrp.DevTypeInd = "0";
  1617. _creditReq.Item = mcGrp;
  1618. }
  1619. #endregion
  1620. #region AmexGrp Group
  1621. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1622. {
  1623. AmexGrp amexgrp = new AmexGrp();
  1624. if (mtdTransaction != null)
  1625. {
  1626. amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  1627. XmlDocument xmlDoc = new XmlDocument();
  1628. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  1629. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  1630. var response = CommonFunctions.GetMCResponse(xmlString);
  1631. xmlDoc.LoadXml(response);
  1632. var amExPOSData = xmlDoc.SelectSingleNode("CreditResponse/AmexGrp/AmExPOSData");
  1633. if (amExPOSData != null)
  1634. {
  1635. amexgrp.AmExPOSData = amExPOSData.InnerText;
  1636. }
  1637. }
  1638. _creditReq.Item = amexgrp;
  1639. }
  1640. #endregion
  1641. #region Discover Group
  1642. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  1643. {
  1644. DSGrp dsGrp = new DSGrp();
  1645. if (mtdTransaction != null)
  1646. {
  1647. XmlDocument xmlDoc = new XmlDocument();
  1648. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  1649. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  1650. var response = CommonFunctions.GetMCResponse(xmlString);
  1651. xmlDoc.LoadXml(response);
  1652. var discProcCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscProcCode");
  1653. if (discProcCode != null)
  1654. {
  1655. dsGrp.DiscProcCode = discProcCode.InnerText;
  1656. }
  1657. var discPOSEntry = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSEntry");
  1658. if (discPOSEntry != null)
  1659. {
  1660. dsGrp.DiscPOSEntry = discPOSEntry.InnerText;
  1661. }
  1662. var discRespCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscRespCode");
  1663. if (discRespCode != null)
  1664. {
  1665. dsGrp.DiscRespCode = discRespCode.InnerText;
  1666. }
  1667. var discPOSData = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSData");
  1668. if (discPOSData != null)
  1669. {
  1670. dsGrp.DiscPOSData = discPOSData.InnerText;
  1671. }
  1672. var discTransQualifier = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscTransQualifier");
  1673. if (discTransQualifier != null)
  1674. {
  1675. dsGrp.DiscTransQualifier = discTransQualifier.InnerText;
  1676. }
  1677. var discNRID = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscNRID");
  1678. if (discNRID != null)
  1679. {
  1680. dsGrp.DiscNRID = discNRID.InnerText;
  1681. }
  1682. dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  1683. }
  1684. _creditReq.Item = dsGrp;
  1685. }
  1686. #endregion
  1687. #region emv group
  1688. EMVGrp emvGrp = new EMVGrp();
  1689. emvGrp.EMVData = transactionRequest.EmvData;
  1690. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  1691. _debitReq.EMVGrp = emvGrp;
  1692. #endregion
  1693. #region PIN Group
  1694. if (!string.IsNullOrEmpty(transactionRequest.DebitPin) && !string.IsNullOrEmpty(transactionRequest.KeySerialNumber))
  1695. {
  1696. PINGrp pinGroup = new PINGrp();
  1697. pinGroup.PINData = transactionRequest.DebitPin;
  1698. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber;
  1699. _creditReq.PINGrp = pinGroup;
  1700. }
  1701. #endregion
  1702. #region Customer info Group
  1703. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress) || !string.IsNullOrEmpty(transactionRequest.ZipCode))
  1704. {
  1705. if (!string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1706. {
  1707. CustInfoGrp custinfo = new CustInfoGrp();
  1708. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress))
  1709. {
  1710. custinfo.AVSBillingAddr = transactionRequest.StreetAddress;
  1711. }
  1712. if (!string.IsNullOrEmpty(transactionRequest.ZipCode))
  1713. {
  1714. custinfo.AVSBillingPostalCode = transactionRequest.ZipCode;
  1715. }
  1716. _creditReq.CustInfoGrp = custinfo;
  1717. }
  1718. }
  1719. #endregion
  1720. #region addAm Group
  1721. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1722. {
  1723. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1724. if (mtdTransaction != null)
  1725. {
  1726. XmlDocument xmlDoc = new XmlDocument();
  1727. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  1728. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  1729. var response = CommonFunctions.GetMCResponse(xmlString);
  1730. xmlDoc.LoadXml(response);
  1731. var originalamt = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  1732. if (originalamt != null)
  1733. {
  1734. var amntP = originalamt.InnerText;
  1735. addAmtGrp.AddAmt = amntP.PadLeft(12, '0');
  1736. }
  1737. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1738. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  1739. addAmtGrp.AddAmtTypeSpecified = true;
  1740. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  1741. var originalamt1 = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  1742. if (originalamt1 != null)
  1743. {
  1744. var amnt = originalamt1.InnerText;
  1745. addAmtGrp1.AddAmt = amnt.PadLeft(12, '0');
  1746. }
  1747. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1748. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  1749. addAmtGrp1.AddAmtTypeSpecified = true;
  1750. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  1751. addAmtGrpArr[0] = addAmtGrp;
  1752. addAmtGrpArr[1] = addAmtGrp1;
  1753. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  1754. }
  1755. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  1756. if (mtdTransaction != null)
  1757. {
  1758. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  1759. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  1760. XmlDocument xmlDoc = new XmlDocument();
  1761. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  1762. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  1763. if (trnmsnDateTime != null)
  1764. {
  1765. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  1766. }
  1767. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan);
  1768. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode);
  1769. }
  1770. _creditReq.OrigAuthGrp = orgAuthgrp;
  1771. }
  1772. #endregion
  1773. /* Add the data populated object to GMF message variant object */
  1774. _gmfMsgVar.Item = _creditReq;
  1775. transactionRequest.Stan = cmnGrp.STAN;
  1776. transactionRequest.TransRefNo = cmnGrp.RefNum;
  1777. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  1778. return _creditReq;
  1779. }
  1780. }
  1781. catch (Exception ex)
  1782. {
  1783. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  1784. }
  1785. return null;
  1786. }
  1787. /// <summary>
  1788. /// Purpose : Creating pinless debit request
  1789. /// Function Name : CreatePinlessDebitRequest
  1790. /// Created By : Madhuri Tanwar
  1791. /// Created On : 03/20/2015
  1792. /// Modificatios Made : ****************************
  1793. /// Modidified On : 04/10/2015 "MM/DD/YYYY"
  1794. /// </summary>
  1795. /// <param name="transactionRequest"></param>
  1796. /// <returns></returns>
  1797. private PinlessDebitRequestDetails CreatePinlessDebitRequest(TransactionRequest transactionRequest)
  1798. {
  1799. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  1800. this transaction should be populated.*/
  1801. try
  1802. {
  1803. if (!transactionRequest.IsNull())
  1804. {
  1805. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  1806. MethodBase.GetCurrentMethod().Name + ";");
  1807. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  1808. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  1809. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  1810. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  1811. {
  1812. mtdTransaction = _terminalService.Completion(
  1813. transactionRequest.RapidConnectAuthId,
  1814. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  1815. if (mtdTransaction.IsNull())
  1816. return null;
  1817. }
  1818. #region Common Group
  1819. /* Populate values for Common Group */
  1820. CommonGrp cmnGrp = new CommonGrp();
  1821. /* The payment type of the transaction. */
  1822. cmnGrp.PymtType = PymtTypeType.PLDebit;
  1823. cmnGrp.PymtTypeSpecified = true;
  1824. /* The type of transaction being performed. */
  1825. cmnGrp.TxnType = transactionRequest.TransactionType == Void
  1826. ? TxnTypeType.Sale
  1827. : transactionRequest.TransType;
  1828. cmnGrp.TxnTypeSpecified = true;
  1829. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  1830. /* The local date and time in which the transaction was performed. */
  1831. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  1832. /* The transmission date and time of the transaction (in GMT/UCT). */
  1833. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  1834. /* A number assigned by the merchant to uniquely reference the transaction.
  1835. * This number must be unique within a day per Merchant ID per Terminal ID. */
  1836. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1837. /* A number assigned by the merchant to uniquely reference a set of transactions.
  1838. * sThis number must be unique within a day for a given Merchant ID/ Terminal ID. */
  1839. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  1840. /* Order number of the transaction */
  1841. cmnGrp.OrderNum = cmnGrp.RefNum;
  1842. /* An ID assigned by First Data, for the Third Party Processor or
  1843. * Software Vendor that generated the transaction. */
  1844. cmnGrp.TPPID = transactionRequest.TppId;
  1845. /* A unique ID assigned to a terminal. */
  1846. cmnGrp.TermID = transactionRequest.TerminalId;
  1847. /* A unique ID assigned by First Data, to identify the Merchant. */
  1848. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  1849. /* An identifier used to indicate the terminal’s account number entry mode
  1850. * and authentication capability via the Point-of-Service. */
  1851. cmnGrp.POSEntryMode = PaymentAPIResources.EcomPosEntryMode;
  1852. /* An identifier used to indicate the authorization conditions at the Point-of-Service (POS). */
  1853. cmnGrp.POSCondCode = POSCondCodeType.Item59;
  1854. cmnGrp.POSCondCodeSpecified = true;
  1855. /* An identifier used to describe the type of terminal being used for the transaction. */
  1856. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  1857. cmnGrp.TermCatCodeSpecified = true;
  1858. /* An identifier used to indicate the entry mode capability of the terminal. */
  1859. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item00;
  1860. cmnGrp.TermEntryCapabltSpecified = true;
  1861. /* The amount of the transaction. This may be an authorization amount,
  1862. * adjustment amount or a reversal amount based on the type of transaction.
  1863. * It is inclusive of all additional amounts.
  1864. * It is submitted in the currency represented by the Transaction Currency field.
  1865. * The field is overwritten in the response for a partial authorization. */
  1866. //decimal amt = Convert.ToDecimal(transactionRequest.TransactionAmount);
  1867. //amt = amt*100;
  1868. //cmnGrp.TxnAmt = Convert.ToString(amt);
  1869. //cmnGrp.TxnAmt = cmnGrp.TxnAmt.Replace(".00", string.Empty).PadLeft(12, '0');
  1870. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  1871. string amt = num.ToString("0.00").Replace(".", string.Empty);
  1872. cmnGrp.TxnAmt = Convert.ToString(amt);
  1873. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  1874. /* The numeric currency of the Transaction Amount. */
  1875. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  1876. /* An indicator that describes the location of the terminal. */
  1877. cmnGrp.TermLocInd = TermLocIndType.Item1;
  1878. cmnGrp.TermLocIndSpecified = true;
  1879. /* Indicates whether or not the terminal has the capability to capture the card data. */
  1880. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  1881. cmnGrp.CardCaptCapSpecified = true;
  1882. /* Indicates Group ID. */
  1883. cmnGrp.GroupID = transactionRequest.GroupId;
  1884. //Group ID value will be assigned by First Data. //This is dummy value. Please use the actual value
  1885. _pinlessDebit.CommonGrp = cmnGrp;
  1886. #endregion
  1887. #region Card Group
  1888. /* Populate values for Card Group */
  1889. CardGrp crdGrp = new CardGrp();
  1890. TAGrp taGrp = new TAGrp();
  1891. if (string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase) ||
  1892. string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase))
  1893. {
  1894. if (transactionRequest.TransactionType == Void)
  1895. {
  1896. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  1897. }
  1898. else
  1899. crdGrp.AcctNum = transactionRequest.CardNumber;
  1900. }
  1901. else
  1902. {
  1903. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  1904. }
  1905. crdGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  1906. _pinlessDebit.CardGrp = crdGrp;
  1907. #endregion
  1908. #region TAgrp
  1909. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  1910. taGrp.SctyLvlSpecified = true;
  1911. taGrp.TknType = transactionRequest.TokenType;
  1912. _pinlessDebit.TAGrp = taGrp;
  1913. #endregion
  1914. #region Ecommerce Group
  1915. EcommGrp ecomgrp = new EcommGrp();
  1916. ecomgrp.EcommTxnInd = EcommTxnIndType.Item03;
  1917. ecomgrp.EcommTxnIndSpecified = true;
  1918. ecomgrp.EcommURL = PaymentAPIResources.EcomUrl;
  1919. _pinlessDebit.EcommGrp = ecomgrp;
  1920. #endregion
  1921. #region addAm Group
  1922. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  1923. {
  1924. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  1925. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  1926. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  1927. addAmtGrp.AddAmt = addamt;
  1928. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  1929. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1930. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  1931. addAmtGrp.AddAmtTypeSpecified = true;
  1932. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  1933. addAmtGrp1.AddAmt = addamt;
  1934. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  1935. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  1936. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  1937. addAmtGrp1.AddAmtTypeSpecified = true;
  1938. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  1939. addAmtGrpArr[0] = addAmtGrp;
  1940. addAmtGrpArr[1] = addAmtGrp1;
  1941. _pinlessDebit.AddtlAmtGrp = addAmtGrpArr;
  1942. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  1943. if (mtdTransaction != null)
  1944. {
  1945. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId; // "OK3542";
  1946. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  1947. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  1948. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan); //"000001";
  1949. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode); //"002";
  1950. }
  1951. _pinlessDebit.OrigAuthGrp = orgAuthgrp;
  1952. }
  1953. #endregion
  1954. /* Add the data populated object to GMF message variant object */
  1955. _gmfMsgVar.Item = _pinlessDebit;
  1956. transactionRequest.Stan = cmnGrp.STAN;
  1957. transactionRequest.TransRefNo = cmnGrp.RefNum;
  1958. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  1959. return _pinlessDebit;
  1960. }
  1961. }
  1962. catch (Exception ex)
  1963. {
  1964. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  1965. }
  1966. return null;
  1967. }
  1968. /// <summary>
  1969. /// Purpose : Creating pin debit request
  1970. /// Function Name : CreatePinDebitRequest
  1971. /// Created By : Madhuri Tanwar
  1972. /// Created On : 03/20/2015
  1973. /// Modificatios Made : ****************************
  1974. /// Modidified On : 04/20/2015 "MM/DD/YYYY"
  1975. /// </summary>
  1976. /// <param name="transactionRequest"></param>
  1977. /// <returns></returns>
  1978. private DebitRequestDetails CreatePinDebitRequest(TransactionRequest transactionRequest)
  1979. {
  1980. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  1981. this transaction should be populated.*/
  1982. try
  1983. {
  1984. if (!transactionRequest.IsNull())
  1985. {
  1986. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  1987. MethodBase.GetCurrentMethod().Name + ";");
  1988. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  1989. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  1990. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  1991. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  1992. {
  1993. mtdTransaction = _terminalService.Completion(
  1994. transactionRequest.RapidConnectAuthId,
  1995. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  1996. if (mtdTransaction.IsNull())
  1997. return null;
  1998. }
  1999. #region Common Group
  2000. /* Populate values for Common Group */
  2001. CommonGrp cmnGrp = new CommonGrp();
  2002. /* The payment type of the transaction. */
  2003. cmnGrp.PymtType = PymtTypeType.Debit;
  2004. cmnGrp.PymtTypeSpecified = true;
  2005. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  2006. /* The type of transaction being performed. */
  2007. cmnGrp.TxnType = transactionRequest.TransactionType == Void ? TxnTypeType.Sale : transactionRequest.TransType;
  2008. cmnGrp.TxnTypeSpecified = true;
  2009. /* The local date and time in which the transaction was performed. */
  2010. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  2011. /* The transmission date and time of the transaction (in GMT/UCT). */
  2012. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  2013. /* A number assigned by the merchant to uniquely reference the transaction.
  2014. * This number must be unique within a day per Merchant ID per Terminal ID. */
  2015. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2016. /* A number assigned by the merchant to uniquely reference a set of transactions.
  2017. * sThis number must be unique within a day for a given Merchant ID/ Terminal ID. */
  2018. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2019. /* Order number of the transaction*/
  2020. cmnGrp.OrderNum = cmnGrp.RefNum;
  2021. /* An ID assigned by First Data, for the Third Party Processor or
  2022. * Software Vendor that generated the transaction. */
  2023. cmnGrp.TPPID = transactionRequest.TppId;
  2024. /* A unique ID assigned to a terminal. */
  2025. cmnGrp.TermID = transactionRequest.TerminalId;
  2026. /* A unique ID assigned by First Data, to identify the Merchant. */
  2027. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  2028. /* An identifier used to indicate the terminal’s account number entry mode
  2029. * and authentication capability via the Point-of-Service. */
  2030. cmnGrp.POSEntryMode = PaymentAPIResources.RetailPosEntryMode;
  2031. /* An identifier used to indicate the authorization conditions at the Point-of-Service (POS). */
  2032. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  2033. cmnGrp.POSCondCodeSpecified = true;
  2034. /* An identifier used to describe the type of terminal being used for the transaction. */
  2035. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  2036. cmnGrp.TermCatCodeSpecified = true;
  2037. /* An identifier used to indicate the entry mode capability of the terminal. */
  2038. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item01;
  2039. cmnGrp.TermEntryCapabltSpecified = true;
  2040. /* The amount of the transaction. This may be an authorization amount,
  2041. * adjustment amount or a reversal amount based on the type of transaction.
  2042. * It is inclusive of all additional amounts.
  2043. * It is submitted in the currency represented by the Transaction Currency field.
  2044. * The field is overwritten in the response for a partial authorization. */
  2045. //cmnGrp.TxnAmt = transactionRequest.TransactionAmount;
  2046. //decimal amt = Convert.ToDecimal(transactionRequest.TransactionAmount);
  2047. //amt = amt * 100;
  2048. //cmnGrp.TxnAmt = Convert.ToString(amt);
  2049. //cmnGrp.TxnAmt = cmnGrp.TxnAmt.Replace(".00", string.Empty).PadLeft(12, '0');
  2050. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  2051. string amt = num.ToString("0.00").Replace(".", string.Empty);
  2052. cmnGrp.TxnAmt = Convert.ToString(amt);
  2053. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  2054. /* The numeric currency of the Transaction Amount. */
  2055. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  2056. /* An indicator that describes the location of the terminal. */
  2057. cmnGrp.TermLocInd = TermLocIndType.Item0;
  2058. cmnGrp.TermLocIndSpecified = true;
  2059. /* Indicates whether or not the terminal has the capability to capture the card data. */
  2060. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  2061. cmnGrp.CardCaptCapSpecified = true;
  2062. /* Indicates Group ID. */
  2063. cmnGrp.GroupID = transactionRequest.GroupId; //Group ID value will be assigned by First Data. //This is dummy value. Please use the actual value
  2064. _debitReq.CommonGrp = cmnGrp;
  2065. #endregion
  2066. #region TAgrp
  2067. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2068. {
  2069. TAGrp taGrp = new TAGrp();
  2070. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2071. taGrp.SctyLvlSpecified = true;
  2072. taGrp.Tkn = StringExtension.Decrypt(mtdTransaction.CardToken);
  2073. taGrp.TknType = transactionRequest.TokenType;
  2074. _debitReq.TAGrp = taGrp;
  2075. }
  2076. else
  2077. {
  2078. TAGrp taGrp = new TAGrp();
  2079. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2080. taGrp.SctyLvlSpecified = true;
  2081. taGrp.EncrptType = EncrptTypeType.RSA;
  2082. taGrp.EncrptTypeSpecified = true;
  2083. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  2084. taGrp.EncrptTrgtSpecified = true;
  2085. taGrp.KeyID = transactionRequest.KeyId; //"VAR11;TEST1";
  2086. taGrp.EncrptBlock = transactionRequest.Track3Data;
  2087. taGrp.TknType = transactionRequest.TokenType;
  2088. _debitReq.TAGrp = taGrp;
  2089. #region PIN Group
  2090. /* Populate values for PIN Group */
  2091. PINGrp pinGroup = new PINGrp();
  2092. /* The PIN Data for the Debit or EBT transaction being submitted.
  2093. * HEXADecimal value need to be entered. */
  2094. pinGroup.PINData = transactionRequest.DebitPin;
  2095. //pinGroup.PINData = transactionRequest.PinData; // remove hard code
  2096. /* Provides the initialization vector for DUKPT PIN Debit and EBT transactions. */
  2097. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber; // remove hard code
  2098. //pinGroup.KeySerialNumData = transactionRequest.KeySerNumData;
  2099. _debitReq.PINGrp = pinGroup;
  2100. #endregion
  2101. }
  2102. #endregion
  2103. #region Additional Amount Group
  2104. if (string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.OrdinalIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.OrdinalIgnoreCase))
  2105. {
  2106. /* Populate values for Additional Amount Group */
  2107. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2108. /* An identifier used to indicate whether or not the
  2109. * terminal/software can support partial authorization approvals. */
  2110. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  2111. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  2112. /* Creating a generic array of Additional Amount
  2113. * Group type to sent the data to as an array */
  2114. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  2115. addAmtGrpArr[0] = addAmtGrp;
  2116. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  2117. }
  2118. #endregion
  2119. #region addAm Group
  2120. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2121. {
  2122. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2123. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  2124. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  2125. addAmtGrp.AddAmt = addamt;
  2126. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  2127. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  2128. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  2129. addAmtGrp.AddAmtTypeSpecified = true;
  2130. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  2131. addAmtGrp1.AddAmt = addamt;
  2132. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  2133. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  2134. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  2135. addAmtGrp1.AddAmtTypeSpecified = true;
  2136. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  2137. addAmtGrpArr[0] = addAmtGrp;
  2138. addAmtGrpArr[1] = addAmtGrp1;
  2139. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  2140. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  2141. if (mtdTransaction != null)
  2142. {
  2143. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId; // "OK3542";
  2144. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  2145. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  2146. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan); //"000001";
  2147. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode); //"002";
  2148. }
  2149. _debitReq.OrigAuthGrp = orgAuthgrp;
  2150. }
  2151. #endregion
  2152. /* Add the data populated object to GMF message variant object */
  2153. _gmfMsgVar.Item = _debitReq;
  2154. transactionRequest.Stan = cmnGrp.STAN;
  2155. transactionRequest.TransRefNo = cmnGrp.RefNum;
  2156. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  2157. return _debitReq;
  2158. }
  2159. }
  2160. catch (Exception ex)
  2161. {
  2162. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  2163. }
  2164. return null;
  2165. }
  2166. /// <summary>
  2167. /// Purpose : Creating pin debit request for contact EMV
  2168. /// Function Name : CreateEmvContactPinDebitRequest
  2169. /// Created By : Madhuri Tanwar
  2170. /// Created On : 07/27/2015
  2171. /// Modificatios Made : ****************************
  2172. /// Modidified On : 04/20/2015 "MM/DD/YYYY"
  2173. /// </summary>
  2174. /// <param name="transactionRequest"></param>
  2175. /// <returns></returns>
  2176. private DebitRequestDetails CreateEmvContactPinDebitRequest(TransactionRequest transactionRequest)
  2177. {
  2178. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  2179. this transaction should be populated.*/
  2180. try
  2181. {
  2182. if (!transactionRequest.IsNull())
  2183. {
  2184. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  2185. MethodBase.GetCurrentMethod().Name + ";");
  2186. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  2187. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  2188. #region Common Group
  2189. CommonGrp cmnGrp = new CommonGrp();
  2190. /* The payment type of the transaction. */
  2191. cmnGrp.PymtType = PymtTypeType.Debit;
  2192. cmnGrp.PymtTypeSpecified = true;
  2193. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  2194. /* The type of transaction being performed. */
  2195. cmnGrp.TxnType = transactionRequest.TransactionType == Void ? TxnTypeType.Sale : transactionRequest.TransType;
  2196. cmnGrp.TxnTypeSpecified = true;
  2197. /* The local date and time in which the transaction was performed. */
  2198. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  2199. /* The transmission date and time of the transaction (in GMT/UCT). */
  2200. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  2201. /* A number assigned by the merchant to uniquely reference the transaction.
  2202. * This number must be unique within a day per Merchant ID per Terminal ID. */
  2203. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2204. /* A number assigned by the merchant to uniquely reference a set of transactions.
  2205. * sThis number must be unique within a day for a given Merchant ID/ Terminal ID. */
  2206. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2207. /* Order number of the transaction*/
  2208. cmnGrp.OrderNum = cmnGrp.RefNum;
  2209. /* An ID assigned by First Data, for the Third Party Processor or
  2210. * Software Vendor that generated the transaction. */
  2211. cmnGrp.TPPID = transactionRequest.TppId;
  2212. /* A unique ID assigned to a terminal. */
  2213. cmnGrp.TermID = transactionRequest.TerminalId;
  2214. /* A unique ID assigned by First Data, to identify the Merchant. */
  2215. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  2216. /* An identifier used to indicate the terminal’s account number entry mode
  2217. * and authentication capability via the Point-of-Service. */
  2218. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactEMVPosEntryMode;
  2219. /* An identifier used to indicate the authorization conditions at the Point-of-Service (POS). */
  2220. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  2221. cmnGrp.POSCondCodeSpecified = true;
  2222. /* An identifier used to describe the type of terminal being used for the transaction. */
  2223. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  2224. cmnGrp.TermCatCodeSpecified = true;
  2225. /* An identifier used to indicate the entry mode capability of the terminal. */
  2226. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  2227. cmnGrp.TermEntryCapabltSpecified = true;
  2228. /* The amount of the transaction. This may be an authorization amount,
  2229. * adjustment amount or a reversal amount based on the type of transaction.
  2230. * It is inclusive of all additional amounts.
  2231. * It is submitted in the currency represented by the Transaction Currency field.
  2232. * The field is overwritten in the response for a partial authorization. */
  2233. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  2234. string amt = num.ToString("0.00").Replace(".", string.Empty);
  2235. cmnGrp.TxnAmt = Convert.ToString(amt);
  2236. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  2237. /* The numeric currency of the Transaction Amount. */
  2238. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  2239. /* An indicator that describes the location of the terminal. */
  2240. cmnGrp.TermLocInd = TermLocIndType.Item0;
  2241. cmnGrp.TermLocIndSpecified = true;
  2242. /* Indicates whether or not the terminal has the capability to capture the card data. */
  2243. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  2244. cmnGrp.CardCaptCapSpecified = true;
  2245. /* Indicates Group ID. */
  2246. cmnGrp.GroupID = transactionRequest.GroupId; //Group ID value will be assigned by First Data. //This is dummy value. Please use the actual value
  2247. _debitReq.CommonGrp = cmnGrp;
  2248. #endregion
  2249. #region TAgrp
  2250. TAGrp taGrp = new TAGrp();
  2251. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2252. taGrp.SctyLvlSpecified = true;
  2253. taGrp.EncrptType = EncrptTypeType.RSA;
  2254. taGrp.EncrptTypeSpecified = true;
  2255. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  2256. taGrp.EncrptTrgtSpecified = true;
  2257. taGrp.KeyID = transactionRequest.KeyId; //"VAR11;TEST1";
  2258. taGrp.EncrptBlock = transactionRequest.Track3Data;
  2259. taGrp.TknType = transactionRequest.TokenType;
  2260. _debitReq.TAGrp = taGrp;
  2261. #endregion
  2262. #region PIN Group
  2263. PINGrp pinGroup = new PINGrp();
  2264. pinGroup.PINData = transactionRequest.DebitPin;
  2265. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber;
  2266. _debitReq.PINGrp = pinGroup;
  2267. #endregion
  2268. #region emv group
  2269. EMVGrp emvGrp = new EMVGrp();
  2270. emvGrp.EMVData = transactionRequest.EmvData;
  2271. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  2272. _debitReq.EMVGrp = emvGrp;
  2273. #endregion
  2274. #region Additional Amount Group
  2275. if (string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.OrdinalIgnoreCase))
  2276. {
  2277. /* Populate values for Additional Amount Group */
  2278. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2279. /* An identifier used to indicate whether or not the
  2280. * terminal/software can support partial authorization approvals. */
  2281. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  2282. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  2283. /* Creating a generic array of Additional Amount
  2284. * Group type to sent the data to as an array */
  2285. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  2286. addAmtGrpArr[0] = addAmtGrp;
  2287. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  2288. }
  2289. #endregion
  2290. /* Add the data populated object to GMF message variant object */
  2291. _gmfMsgVar.Item = _debitReq;
  2292. transactionRequest.Stan = cmnGrp.STAN;
  2293. transactionRequest.TransRefNo = cmnGrp.RefNum;
  2294. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  2295. return _debitReq;
  2296. }
  2297. }
  2298. catch (Exception ex)
  2299. {
  2300. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  2301. }
  2302. return null;
  2303. }
  2304. /// <summary>
  2305. ///
  2306. /// </summary>
  2307. /// <param name="transactionRequest"></param>
  2308. /// <returns></returns>
  2309. private DebitRequestDetails CreateEmvContactlessPinDebitRequest(TransactionRequest transactionRequest)
  2310. {
  2311. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  2312. this transaction should be populated.*/
  2313. try
  2314. {
  2315. if (!transactionRequest.IsNull())
  2316. {
  2317. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  2318. MethodBase.GetCurrentMethod().Name + ";");
  2319. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  2320. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  2321. #region Common Group
  2322. CommonGrp cmnGrp = new CommonGrp();
  2323. /* The payment type of the transaction. */
  2324. cmnGrp.PymtType = PymtTypeType.Debit;
  2325. cmnGrp.PymtTypeSpecified = true;
  2326. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  2327. /* The type of transaction being performed. */
  2328. cmnGrp.TxnType = transactionRequest.TransactionType == Void ? TxnTypeType.Sale : transactionRequest.TransType;
  2329. cmnGrp.TxnTypeSpecified = true;
  2330. /* The local date and time in which the transaction was performed. */
  2331. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  2332. /* The transmission date and time of the transaction (in GMT/UCT). */
  2333. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  2334. /* A number assigned by the merchant to uniquely reference the transaction.
  2335. * This number must be unique within a day per Merchant ID per Terminal ID. */
  2336. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2337. /* A number assigned by the merchant to uniquely reference a set of transactions.
  2338. * sThis number must be unique within a day for a given Merchant ID/ Terminal ID. */
  2339. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2340. /* Order number of the transaction*/
  2341. cmnGrp.OrderNum = cmnGrp.RefNum;
  2342. /* An ID assigned by First Data, for the Third Party Processor or
  2343. * Software Vendor that generated the transaction. */
  2344. cmnGrp.TPPID = transactionRequest.TppId;
  2345. /* A unique ID assigned to a terminal. */
  2346. cmnGrp.TermID = transactionRequest.TerminalId;
  2347. /* A unique ID assigned by First Data, to identify the Merchant. */
  2348. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  2349. /* An identifier used to indicate the terminal’s account number entry mode
  2350. * and authentication capability via the Point-of-Service. */
  2351. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactEMVPosEntryMode;
  2352. /* An identifier used to indicate the authorization conditions at the Point-of-Service (POS). */
  2353. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  2354. cmnGrp.POSCondCodeSpecified = true;
  2355. /* An identifier used to describe the type of terminal being used for the transaction. */
  2356. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  2357. cmnGrp.TermCatCodeSpecified = true;
  2358. /* An identifier used to indicate the entry mode capability of the terminal. */
  2359. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  2360. cmnGrp.TermEntryCapabltSpecified = true;
  2361. /* The amount of the transaction. This may be an authorization amount,
  2362. * adjustment amount or a reversal amount based on the type of transaction.
  2363. * It is inclusive of all additional amounts.
  2364. * It is submitted in the currency represented by the Transaction Currency field.
  2365. * The field is overwritten in the response for a partial authorization. */
  2366. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  2367. string amt = num.ToString("0.00").Replace(".", string.Empty);
  2368. cmnGrp.TxnAmt = Convert.ToString(amt);
  2369. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  2370. /* The numeric currency of the Transaction Amount. */
  2371. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  2372. /* An indicator that describes the location of the terminal. */
  2373. cmnGrp.TermLocInd = TermLocIndType.Item0;
  2374. cmnGrp.TermLocIndSpecified = true;
  2375. /* Indicates whether or not the terminal has the capability to capture the card data. */
  2376. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  2377. cmnGrp.CardCaptCapSpecified = true;
  2378. /* Indicates Group ID. */
  2379. cmnGrp.GroupID = transactionRequest.GroupId; //Group ID value will be assigned by First Data. //This is dummy value. Please use the actual value
  2380. _debitReq.CommonGrp = cmnGrp;
  2381. #endregion
  2382. #region TAgrp
  2383. TAGrp taGrp = new TAGrp();
  2384. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2385. taGrp.SctyLvlSpecified = true;
  2386. taGrp.EncrptType = EncrptTypeType.RSA;
  2387. taGrp.EncrptTypeSpecified = true;
  2388. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  2389. taGrp.EncrptTrgtSpecified = true;
  2390. taGrp.KeyID = transactionRequest.KeyId; //"VAR11;TEST1";
  2391. taGrp.EncrptBlock = transactionRequest.Track3Data;
  2392. taGrp.TknType = transactionRequest.TokenType;
  2393. _debitReq.TAGrp = taGrp;
  2394. #endregion
  2395. #region PIN Group
  2396. PINGrp pinGroup = new PINGrp();
  2397. pinGroup.PINData = transactionRequest.DebitPin;
  2398. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber;
  2399. _debitReq.PINGrp = pinGroup;
  2400. #endregion
  2401. #region emv group
  2402. EMVGrp emvGrp = new EMVGrp();
  2403. emvGrp.EMVData = transactionRequest.EmvData;
  2404. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  2405. _creditReq.EMVGrp = emvGrp;
  2406. #endregion
  2407. #region Additional Amount Group
  2408. if (string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.OrdinalIgnoreCase))
  2409. {
  2410. /* Populate values for Additional Amount Group */
  2411. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2412. /* An identifier used to indicate whether or not the
  2413. * terminal/software can support partial authorization approvals. */
  2414. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  2415. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  2416. /* Creating a generic array of Additional Amount
  2417. * Group type to sent the data to as an array */
  2418. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  2419. addAmtGrpArr[0] = addAmtGrp;
  2420. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  2421. }
  2422. #endregion
  2423. /* Add the data populated object to GMF message variant object */
  2424. _gmfMsgVar.Item = _debitReq;
  2425. transactionRequest.Stan = cmnGrp.STAN;
  2426. transactionRequest.TransRefNo = cmnGrp.RefNum;
  2427. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  2428. return _debitReq;
  2429. }
  2430. }
  2431. catch (Exception ex)
  2432. {
  2433. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  2434. }
  2435. return null;
  2436. }
  2437. /// <summary>
  2438. /// Purpose : Creating pin debit request
  2439. /// Function Name : CreateCOntactlessMSRPinDebitRequest
  2440. /// Created By : Madhuri Tanwar
  2441. /// Created On : 02/27/2016
  2442. /// Modificatios Made : ****************************
  2443. /// Modidified On : "MM/DD/YYYY"
  2444. /// </summary>
  2445. /// <param name="transactionRequest"></param>
  2446. /// <returns></returns>
  2447. private DebitRequestDetails CreateCOntactlessMSRPinDebitRequest(TransactionRequest transactionRequest)
  2448. {
  2449. try
  2450. {
  2451. if (!transactionRequest.IsNull())
  2452. {
  2453. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  2454. MethodBase.GetCurrentMethod().Name + ";");
  2455. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  2456. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  2457. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  2458. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  2459. {
  2460. mtdTransaction = _terminalService.Completion(
  2461. transactionRequest.RapidConnectAuthId,
  2462. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  2463. if (mtdTransaction.IsNull())
  2464. return null;
  2465. }
  2466. #region Common Group
  2467. /* Populate values for Common Group */
  2468. CommonGrp cmnGrp = new CommonGrp();
  2469. /* The payment type of the transaction. */
  2470. cmnGrp.PymtType = PymtTypeType.Debit;
  2471. cmnGrp.PymtTypeSpecified = true;
  2472. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  2473. /* The type of transaction being performed. */
  2474. cmnGrp.TxnType = transactionRequest.TransactionType == Void ? TxnTypeType.Sale : transactionRequest.TransType;
  2475. cmnGrp.TxnTypeSpecified = true;
  2476. /* The local date and time in which the transaction was performed. */
  2477. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  2478. /* The transmission date and time of the transaction (in GMT/UCT). */
  2479. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  2480. /* A number assigned by the merchant to uniquely reference the transaction.
  2481. * This number must be unique within a day per Merchant ID per Terminal ID. */
  2482. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2483. /* A number assigned by the merchant to uniquely reference a set of transactions.
  2484. * sThis number must be unique within a day for a given Merchant ID/ Terminal ID. */
  2485. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2486. /* Order number of the transaction*/
  2487. cmnGrp.OrderNum = cmnGrp.RefNum;
  2488. /* An ID assigned by First Data, for the Third Party Processor or
  2489. * Software Vendor that generated the transaction. */
  2490. cmnGrp.TPPID = transactionRequest.TppId;
  2491. /* A unique ID assigned to a terminal. */
  2492. cmnGrp.TermID = transactionRequest.TerminalId;
  2493. /* A unique ID assigned by First Data, to identify the Merchant. */
  2494. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  2495. /* An identifier used to indicate the terminal’s account number entry mode
  2496. * and authentication capability via the Point-of-Service. */
  2497. cmnGrp.POSEntryMode = PaymentAPIResources.MSRContactlessEntryMode;
  2498. /* An identifier used to indicate the authorization conditions at the Point-of-Service (POS). */
  2499. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  2500. cmnGrp.POSCondCodeSpecified = true;
  2501. /* An identifier used to describe the type of terminal being used for the transaction. */
  2502. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  2503. cmnGrp.TermCatCodeSpecified = true;
  2504. /* An identifier used to indicate the entry mode capability of the terminal. */
  2505. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  2506. cmnGrp.TermEntryCapabltSpecified = true;
  2507. /* The amount of the transaction. This may be an authorization amount,
  2508. * adjustment amount or a reversal amount based on the type of transaction.
  2509. * It is inclusive of all additional amounts.
  2510. * It is submitted in the currency represented by the Transaction Currency field.
  2511. * The field is overwritten in the response for a partial authorization. */
  2512. //cmnGrp.TxnAmt = transactionRequest.TransactionAmount;
  2513. //decimal amt = Convert.ToDecimal(transactionRequest.TransactionAmount);
  2514. //amt = amt * 100;
  2515. //cmnGrp.TxnAmt = Convert.ToString(amt);
  2516. //cmnGrp.TxnAmt = cmnGrp.TxnAmt.Replace(".00", string.Empty).PadLeft(12, '0');
  2517. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  2518. string amt = num.ToString("0.00").Replace(".", string.Empty);
  2519. cmnGrp.TxnAmt = Convert.ToString(amt);
  2520. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  2521. /* The numeric currency of the Transaction Amount. */
  2522. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  2523. /* An indicator that describes the location of the terminal. */
  2524. cmnGrp.TermLocInd = TermLocIndType.Item0;
  2525. cmnGrp.TermLocIndSpecified = true;
  2526. /* Indicates whether or not the terminal has the capability to capture the card data. */
  2527. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  2528. cmnGrp.CardCaptCapSpecified = true;
  2529. /* Indicates Group ID. */
  2530. cmnGrp.GroupID = transactionRequest.GroupId; //Group ID value will be assigned by First Data. //This is dummy value. Please use the actual value
  2531. _debitReq.CommonGrp = cmnGrp;
  2532. #endregion
  2533. #region TAgrp
  2534. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2535. {
  2536. TAGrp taGrp = new TAGrp();
  2537. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2538. taGrp.SctyLvlSpecified = true;
  2539. taGrp.Tkn = StringExtension.Decrypt(mtdTransaction.CardToken);
  2540. taGrp.TknType = transactionRequest.TokenType;
  2541. _debitReq.TAGrp = taGrp;
  2542. }
  2543. else
  2544. {
  2545. TAGrp taGrp = new TAGrp();
  2546. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2547. taGrp.SctyLvlSpecified = true;
  2548. taGrp.EncrptType = EncrptTypeType.RSA;
  2549. taGrp.EncrptTypeSpecified = true;
  2550. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  2551. taGrp.EncrptTrgtSpecified = true;
  2552. taGrp.KeyID = transactionRequest.KeyId; //"VAR11;TEST1";
  2553. taGrp.EncrptBlock = transactionRequest.Track3Data;
  2554. taGrp.TknType = transactionRequest.TokenType;
  2555. _debitReq.TAGrp = taGrp;
  2556. }
  2557. #endregion
  2558. #region PIN Group
  2559. PINGrp pinGroup = new PINGrp();
  2560. if (!string.IsNullOrEmpty(transactionRequest.DebitPin) && !string.IsNullOrEmpty(transactionRequest.KeySerialNumber))
  2561. {
  2562. pinGroup.PINData = transactionRequest.DebitPin;
  2563. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber;
  2564. }
  2565. _debitReq.PINGrp = pinGroup;
  2566. #endregion
  2567. #region Additional Amount Group
  2568. if (string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.OrdinalIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.OrdinalIgnoreCase))
  2569. {
  2570. /* Populate values for Additional Amount Group */
  2571. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2572. /* An identifier used to indicate whether or not the
  2573. * terminal/software can support partial authorization approvals. */
  2574. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  2575. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  2576. /* Creating a generic array of Additional Amount
  2577. * Group type to sent the data to as an array */
  2578. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  2579. addAmtGrpArr[0] = addAmtGrp;
  2580. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  2581. }
  2582. #endregion
  2583. #region addAm Group
  2584. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2585. {
  2586. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2587. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  2588. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  2589. addAmtGrp.AddAmt = addamt;
  2590. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  2591. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  2592. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  2593. addAmtGrp.AddAmtTypeSpecified = true;
  2594. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  2595. addAmtGrp1.AddAmt = addamt;
  2596. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  2597. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  2598. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  2599. addAmtGrp1.AddAmtTypeSpecified = true;
  2600. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  2601. addAmtGrpArr[0] = addAmtGrp;
  2602. addAmtGrpArr[1] = addAmtGrp1;
  2603. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  2604. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  2605. if (mtdTransaction != null)
  2606. {
  2607. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId; // "OK3542";
  2608. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  2609. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  2610. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan); //"000001";
  2611. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode); //"002";
  2612. }
  2613. _debitReq.OrigAuthGrp = orgAuthgrp;
  2614. }
  2615. #endregion
  2616. /* Add the data populated object to GMF message variant object */
  2617. _gmfMsgVar.Item = _debitReq;
  2618. transactionRequest.Stan = cmnGrp.STAN;
  2619. transactionRequest.TransRefNo = cmnGrp.RefNum;
  2620. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  2621. return _debitReq;
  2622. }
  2623. }
  2624. catch (Exception ex)
  2625. {
  2626. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  2627. }
  2628. return null;
  2629. }
  2630. /// <summary>
  2631. /// Purpose : Creating fallback MSR for credit
  2632. /// Function Name : CreateFallbackMsrRequest
  2633. /// Created By : Madhuri Tanwar
  2634. /// Created On : 08/4/2015
  2635. /// Modificatios Made : ****************************
  2636. /// Modidified On : "MM/DD/YYYY"
  2637. /// </summary>
  2638. /// <param name="transactionRequest"></param>
  2639. /// <returns></returns>
  2640. private CreditRequestDetails CreateFallbackMsrRequest(TransactionRequest transactionRequest)
  2641. {
  2642. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  2643. this transaction should be populated.*/
  2644. try
  2645. {
  2646. if (!transactionRequest.IsNull())
  2647. {
  2648. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  2649. MethodBase.GetCurrentMethod().Name + ";");
  2650. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  2651. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  2652. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  2653. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  2654. {
  2655. mtdTransaction = _terminalService.Completion(
  2656. transactionRequest.RapidConnectAuthId,
  2657. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  2658. if (mtdTransaction.IsNull())
  2659. return null;
  2660. }
  2661. #region Common Group
  2662. CommonGrp cmnGrp = new CommonGrp();
  2663. /* The payment type of the transaction. */
  2664. PymtTypeType typePayment = transactionRequest.PaymentType;
  2665. cmnGrp.PymtType = typePayment;
  2666. cmnGrp.PymtTypeSpecified = true;
  2667. /* merchant category code. */
  2668. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  2669. /* The type of transaction being performed. */
  2670. cmnGrp.TxnType = transactionRequest.TransType;
  2671. cmnGrp.TxnTypeSpecified = true;
  2672. /* The local date and time in which the transaction was performed. */
  2673. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  2674. /* The transmission date and time of the transaction (in GMT/UCT). */
  2675. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  2676. /* A number assigned by the merchant to uniquely reference the transaction.
  2677. * This number must be unique within a day per Merchant ID per Terminal ID. */
  2678. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2679. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  2680. //cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MerchantID, transactionRequest.TerminalID);//"480061115979";
  2681. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2682. //"480061115979";
  2683. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  2684. cmnGrp.OrderNum = cmnGrp.RefNum; //"162091864975";
  2685. /* An ID assigned by First Data, for the Third Party Processor or
  2686. * Software Vendor that generated the transaction. */
  2687. cmnGrp.TPPID = transactionRequest.TppId;
  2688. /* A unique ID assigned to a terminal. */
  2689. cmnGrp.TermID = transactionRequest.TerminalId;
  2690. //get terminal id from transaction request
  2691. /* A unique ID assigned by First Data, to identify the Merchant. */
  2692. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  2693. cmnGrp.GroupID = transactionRequest.GroupId;
  2694. //Group ID value will be assigned by First Data.
  2695. //get terminal id from transaction request
  2696. cmnGrp.POSEntryMode = PaymentAPIResources.FSwipePosEntryMode;
  2697. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  2698. cmnGrp.POSCondCodeSpecified = true;
  2699. cmnGrp.TermCatCode = TermCatCodeType.Item12;
  2700. cmnGrp.TermCatCodeSpecified = true;
  2701. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  2702. cmnGrp.TermEntryCapabltSpecified = true;
  2703. cmnGrp.TermLocInd = TermLocIndType.Item0;
  2704. cmnGrp.TermLocIndSpecified = true;
  2705. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  2706. cmnGrp.CardCaptCapSpecified = true;
  2707. /* The amount of the transaction. This may be an authorization amount,
  2708. * adjustment amount or a reversal amount based on the type of transaction.
  2709. * It is inclusive of all additional amounts.
  2710. * It is submitted in the currency represented by the Transaction Currency field.
  2711. * The field is overwritten in the response for a partial authorization. */
  2712. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  2713. string amt = num.ToString("0.00").Replace(".", string.Empty);
  2714. cmnGrp.TxnAmt = Convert.ToString(amt);
  2715. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  2716. /* The numeric currency of the Transaction Amount. */
  2717. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  2718. /* An indicator that describes the location of the terminal. */
  2719. /* Indicates Group ID. */
  2720. _creditReq.CommonGrp = cmnGrp;
  2721. #endregion
  2722. CardGrp cardGrp = new CardGrp();
  2723. #region Transarmor group
  2724. if (string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.CurrentCultureIgnoreCase))
  2725. {
  2726. cardGrp.CardType = transactionRequest.CardType;
  2727. cardGrp.CardTypeSpecified = true;
  2728. _creditReq.CardGrp = cardGrp;
  2729. //For RSA
  2730. TAGrp taGrp = new TAGrp();
  2731. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2732. taGrp.SctyLvlSpecified = true;
  2733. taGrp.EncrptType = EncrptTypeType.RSA;
  2734. taGrp.EncrptTypeSpecified = true;
  2735. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  2736. taGrp.EncrptTrgtSpecified = true;
  2737. taGrp.KeyID = transactionRequest.KeyId;
  2738. taGrp.EncrptBlock = transactionRequest.Track3Data;
  2739. taGrp.TknType = transactionRequest.TokenType;
  2740. _creditReq.TAGrp = taGrp;
  2741. }
  2742. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.CurrentCultureIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.CurrentCultureIgnoreCase))
  2743. {
  2744. if (mtdTransaction != null) cardGrp.CardType = (CardTypeType)Enum.Parse(typeof(CardTypeType), mtdTransaction.CardType);//mtdTransaction.CardType;
  2745. transactionRequest.CardType = cardGrp.CardType;
  2746. cardGrp.CardTypeSpecified = true;
  2747. _creditReq.CardGrp = cardGrp;
  2748. TAGrp taGrp = new TAGrp();
  2749. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2750. taGrp.SctyLvlSpecified = true;
  2751. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  2752. taGrp.TknType = transactionRequest.TokenType;
  2753. _creditReq.TAGrp = taGrp;
  2754. }
  2755. #endregion
  2756. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  2757. {
  2758. #region Additional Amount Group
  2759. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2760. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  2761. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  2762. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  2763. addAmtGrpArr[0] = addAmtGrp;
  2764. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  2765. #endregion
  2766. }
  2767. #region Visa Group
  2768. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  2769. {
  2770. VisaGrp visaGrp = new VisaGrp();
  2771. visaGrp.VisaBID = PaymentAPIResources.VisaBID;
  2772. visaGrp.VisaAUAR = PaymentAPIResources.VisaAUAR;
  2773. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2774. {
  2775. visaGrp.ACI = ACIType.Y;
  2776. visaGrp.ACISpecified = true;
  2777. visaGrp.TaxAmtCapablt = TaxAmtCapabltType.Item1;
  2778. visaGrp.TaxAmtCapabltSpecified = true;
  2779. }
  2780. else
  2781. {
  2782. visaGrp.ACI = ACIType.T;
  2783. visaGrp.ACISpecified = true;
  2784. }
  2785. _creditReq.Item = visaGrp;
  2786. }
  2787. #endregion
  2788. #region AmexGrp Group
  2789. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2790. {
  2791. AmexGrp amexgrp = new AmexGrp();
  2792. if (mtdTransaction != null) amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  2793. _creditReq.Item = amexgrp;
  2794. }
  2795. #endregion
  2796. #region Discover Group
  2797. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  2798. {
  2799. DSGrp dsGrp = new DSGrp();
  2800. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  2801. _creditReq.Item = dsGrp;
  2802. }
  2803. #endregion
  2804. #region Customer info Group
  2805. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress) || !string.IsNullOrEmpty(transactionRequest.ZipCode))
  2806. {
  2807. if (!string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2808. {
  2809. CustInfoGrp custinfo = new CustInfoGrp();
  2810. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress))
  2811. {
  2812. custinfo.AVSBillingAddr = transactionRequest.StreetAddress;
  2813. }
  2814. if (!string.IsNullOrEmpty(transactionRequest.ZipCode))
  2815. {
  2816. custinfo.AVSBillingPostalCode = transactionRequest.ZipCode;
  2817. }
  2818. _creditReq.CustInfoGrp = custinfo;
  2819. }
  2820. }
  2821. #endregion
  2822. #region addAm Group
  2823. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2824. {
  2825. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  2826. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  2827. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  2828. addAmtGrp.AddAmt = addamt;
  2829. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  2830. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  2831. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  2832. addAmtGrp.AddAmtTypeSpecified = true;
  2833. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  2834. addAmtGrp1.AddAmt = addamt;
  2835. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  2836. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  2837. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  2838. addAmtGrp1.AddAmtTypeSpecified = true;
  2839. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  2840. addAmtGrpArr[0] = addAmtGrp;
  2841. addAmtGrpArr[1] = addAmtGrp1;
  2842. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  2843. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  2844. if (mtdTransaction != null)
  2845. {
  2846. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  2847. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  2848. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  2849. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan);
  2850. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode);
  2851. }
  2852. _creditReq.OrigAuthGrp = orgAuthgrp;
  2853. }
  2854. #endregion
  2855. /* Add the data populated object to GMF message variant object */
  2856. _gmfMsgVar.Item = _creditReq;
  2857. transactionRequest.Stan = cmnGrp.STAN;
  2858. transactionRequest.TransRefNo = cmnGrp.RefNum;
  2859. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  2860. return _creditReq;
  2861. }
  2862. }
  2863. catch (Exception ex)
  2864. {
  2865. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  2866. }
  2867. return null;
  2868. }
  2869. /// <summary>
  2870. /// Purpose : Creating fallback MSR for debit
  2871. /// Function Name : CreateFallbackMsrDebitRequest
  2872. /// Created By : Madhuri Tanwar
  2873. /// Created On : 08/18/2015
  2874. /// Modificatios Made : ****************************
  2875. /// Modidified On : "MM/DD/YYYY"
  2876. /// </summary>
  2877. /// <param name="transactionRequest"></param>
  2878. /// <returns></returns>
  2879. private DebitRequestDetails CreateFallbackMsrDebitRequest(TransactionRequest transactionRequest)
  2880. {
  2881. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  2882. this transaction should be populated.*/
  2883. try
  2884. {
  2885. if (!transactionRequest.IsNull())
  2886. {
  2887. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  2888. MethodBase.GetCurrentMethod().Name + ";");
  2889. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  2890. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  2891. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  2892. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  2893. {
  2894. mtdTransaction = _terminalService.Completion(
  2895. transactionRequest.RapidConnectAuthId,
  2896. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  2897. if (mtdTransaction.IsNull())
  2898. return null;
  2899. }
  2900. #region Common Group
  2901. /* Populate values for Common Group */
  2902. CommonGrp cmnGrp = new CommonGrp();
  2903. /* The payment type of the transaction. */
  2904. cmnGrp.PymtType = PymtTypeType.Debit;
  2905. cmnGrp.PymtTypeSpecified = true;
  2906. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  2907. /* The type of transaction being performed. */
  2908. cmnGrp.TxnType = transactionRequest.TransactionType == Void ? TxnTypeType.Sale : transactionRequest.TransType;
  2909. cmnGrp.TxnTypeSpecified = true;
  2910. /* The local date and time in which the transaction was performed. */
  2911. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  2912. /* The transmission date and time of the transaction (in GMT/UCT). */
  2913. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  2914. /* A number assigned by the merchant to uniquely reference the transaction.
  2915. * This number must be unique within a day per Merchant ID per Terminal ID. */
  2916. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2917. /* A number assigned by the merchant to uniquely reference a set of transactions.
  2918. * sThis number must be unique within a day for a given Merchant ID/ Terminal ID. */
  2919. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  2920. /* Order number of the transaction*/
  2921. cmnGrp.OrderNum = cmnGrp.RefNum;
  2922. /* An ID assigned by First Data, for the Third Party Processor or
  2923. * Software Vendor that generated the transaction. */
  2924. cmnGrp.TPPID = transactionRequest.TppId;
  2925. /* A unique ID assigned to a terminal. */
  2926. cmnGrp.TermID = transactionRequest.TerminalId;
  2927. /* A unique ID assigned by First Data, to identify the Merchant. */
  2928. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  2929. /* An identifier used to indicate the terminal’s account number entry mode
  2930. * and authentication capability via the Point-of-Service. */
  2931. cmnGrp.POSEntryMode = PaymentAPIResources.FSwipePosEntryMode;
  2932. /* An identifier used to indicate the authorization conditions at the Point-of-Service (POS). */
  2933. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  2934. cmnGrp.POSCondCodeSpecified = true;
  2935. /* An identifier used to describe the type of terminal being used for the transaction. */
  2936. cmnGrp.TermCatCode = TermCatCodeType.Item12;
  2937. cmnGrp.TermCatCodeSpecified = true;
  2938. /* An identifier used to indicate the entry mode capability of the terminal. */
  2939. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  2940. cmnGrp.TermEntryCapabltSpecified = true;
  2941. /* The amount of the transaction. This may be an authorization amount,
  2942. * adjustment amount or a reversal amount based on the type of transaction.
  2943. * It is inclusive of all additional amounts.
  2944. * It is submitted in the currency represented by the Transaction Currency field.
  2945. * The field is overwritten in the response for a partial authorization. */
  2946. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  2947. string amt = num.ToString("0.00").Replace(".", string.Empty);
  2948. cmnGrp.TxnAmt = Convert.ToString(amt);
  2949. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  2950. /* The numeric currency of the Transaction Amount. */
  2951. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  2952. /* An indicator that describes the location of the terminal. */
  2953. cmnGrp.TermLocInd = TermLocIndType.Item0;
  2954. cmnGrp.TermLocIndSpecified = true;
  2955. /* Indicates whether or not the terminal has the capability to capture the card data. */
  2956. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  2957. cmnGrp.CardCaptCapSpecified = true;
  2958. /* Indicates Group ID. */
  2959. cmnGrp.GroupID = transactionRequest.GroupId; //Group ID value will be assigned by First Data.
  2960. _debitReq.CommonGrp = cmnGrp;
  2961. #endregion
  2962. #region TAgrp
  2963. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  2964. {
  2965. TAGrp taGrp = new TAGrp();
  2966. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2967. taGrp.SctyLvlSpecified = true;
  2968. taGrp.Tkn = StringExtension.Decrypt(mtdTransaction.CardToken);
  2969. taGrp.TknType = transactionRequest.TokenType;
  2970. _debitReq.TAGrp = taGrp;
  2971. }
  2972. else
  2973. {
  2974. TAGrp taGrp = new TAGrp();
  2975. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  2976. taGrp.SctyLvlSpecified = true;
  2977. taGrp.EncrptType = EncrptTypeType.RSA;
  2978. taGrp.EncrptTypeSpecified = true;
  2979. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  2980. taGrp.EncrptTrgtSpecified = true;
  2981. taGrp.KeyID = transactionRequest.KeyId;
  2982. taGrp.EncrptBlock = transactionRequest.Track3Data;
  2983. taGrp.TknType = transactionRequest.TokenType;//PaymentAPIResources.TknType;//"1173";
  2984. _debitReq.TAGrp = taGrp;
  2985. #region PIN Group
  2986. /* Populate values for PIN Group */
  2987. PINGrp pinGroup = new PINGrp();
  2988. /* The PIN Data for the Debit or EBT transaction being submitted.
  2989. * HEXADecimal value need to be entered. */
  2990. pinGroup.PINData = transactionRequest.DebitPin;
  2991. //pinGroup.PINData = transactionRequest.PinData; // remove hard code
  2992. /* Provides the initialization vector for DUKPT PIN Debit and EBT transactions. */
  2993. pinGroup.KeySerialNumData = transactionRequest.KeySerialNumber; // remove hard code
  2994. //pinGroup.KeySerialNumData = transactionRequest.KeySerNumData;
  2995. _debitReq.PINGrp = pinGroup;
  2996. #endregion
  2997. }
  2998. #endregion
  2999. #region Additional Amount Group
  3000. if (string.Equals(cmnGrp.TxnType.ToString(), Sale, StringComparison.OrdinalIgnoreCase) || string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.OrdinalIgnoreCase))
  3001. {
  3002. /* Populate values for Additional Amount Group */
  3003. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  3004. /* An identifier used to indicate whether or not the
  3005. * terminal/software can support partial authorization approvals. */
  3006. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  3007. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  3008. /* Creating a generic array of Additional Amount
  3009. * Group type to sent the data to as an array */
  3010. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  3011. addAmtGrpArr[0] = addAmtGrp;
  3012. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  3013. }
  3014. #endregion
  3015. #region addAm Group
  3016. if (string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  3017. {
  3018. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  3019. double amt1 = Convert.ToDouble(mtdTransaction.Amount);
  3020. string addamt = amt1.ToString("0.00").Replace(".", string.Empty);
  3021. addAmtGrp.AddAmt = addamt;
  3022. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  3023. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  3024. addAmtGrp.AddAmtType = AddAmtTypeType.FirstAuthAmt;
  3025. addAmtGrp.AddAmtTypeSpecified = true;
  3026. AddtlAmtGrp addAmtGrp1 = new AddtlAmtGrp();
  3027. addAmtGrp1.AddAmt = addamt;
  3028. addAmtGrp1.AddAmt = addAmtGrp1.AddAmt.PadLeft(12, '0');
  3029. addAmtGrp1.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  3030. addAmtGrp1.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  3031. addAmtGrp1.AddAmtTypeSpecified = true;
  3032. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[2];
  3033. addAmtGrpArr[0] = addAmtGrp;
  3034. addAmtGrpArr[1] = addAmtGrp1;
  3035. _debitReq.AddtlAmtGrp = addAmtGrpArr;
  3036. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  3037. if (mtdTransaction != null)
  3038. {
  3039. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId; // "OK3542";
  3040. orgAuthgrp.OrigLocalDateTime = mtdTransaction.LocalDateTime;
  3041. orgAuthgrp.OrigTranDateTime = mtdTransaction.TransmissionDateTime;
  3042. orgAuthgrp.OrigSTAN = Convert.ToString(mtdTransaction.Stan); //"000001";
  3043. orgAuthgrp.OrigRespCode = Convert.ToString(mtdTransaction.ResponseCode); //"002";
  3044. }
  3045. _debitReq.OrigAuthGrp = orgAuthgrp;
  3046. }
  3047. #endregion
  3048. /* Add the data populated object to GMF message variant object */
  3049. _gmfMsgVar.Item = _debitReq;
  3050. transactionRequest.Stan = cmnGrp.STAN;
  3051. transactionRequest.TransRefNo = cmnGrp.RefNum;
  3052. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  3053. return _debitReq;
  3054. }
  3055. }
  3056. catch (Exception ex)
  3057. {
  3058. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  3059. }
  3060. return null;
  3061. }
  3062. /// <summary>
  3063. /// Purpose : Creating Reversal Void transaction request
  3064. /// Function Name : ReversalRequest
  3065. /// Created By : Madhuri Tanwar
  3066. /// Created On : 03/20/2015
  3067. /// Modificatios Made : ****************************
  3068. /// Modidified On : 04/02/2015 "MM/DD/YYYY"
  3069. /// </summary>
  3070. /// <param name="transactionRequest"></param>
  3071. /// <returns></returns>
  3072. public VoidTOReversalRequestDetails ReversalRequest(TransactionRequest transactionRequest)
  3073. {
  3074. try
  3075. {
  3076. if (!transactionRequest.IsNull())
  3077. {
  3078. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  3079. MethodBase.GetCurrentMethod().Name + ";");
  3080. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  3081. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  3082. #region Common Group
  3083. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  3084. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  3085. {
  3086. mtdTransaction = _terminalService.Completion(
  3087. transactionRequest.RapidConnectAuthId,
  3088. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3089. if (mtdTransaction.IsNull())
  3090. return null;
  3091. }
  3092. /* Populate values for Common Group */
  3093. CommonGrp cmnGrp = new CommonGrp();
  3094. /* The payment type of the transaction. */
  3095. PymtTypeType typePayment = transactionRequest.PaymentType;
  3096. cmnGrp.PymtType = typePayment;
  3097. cmnGrp.PymtTypeSpecified = true;
  3098. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  3099. cmnGrp.ReversalIndSpecified = true;
  3100. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  3101. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  3102. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  3103. cmnGrp.TxnType = TxnTypeType.Sale;
  3104. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  3105. cmnGrp.TxnType = TxnTypeType.Refund;
  3106. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  3107. cmnGrp.TxnType = TxnTypeType.Authorization;
  3108. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  3109. cmnGrp.TxnType = TxnTypeType.Completion;
  3110. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  3111. {
  3112. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3113. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  3114. }
  3115. cmnGrp.TxnTypeSpecified = true;
  3116. /* The local date and time in which the transaction was performed. */
  3117. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  3118. /* The transmission date and time of the transaction (in GMT/UCT). */
  3119. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  3120. /* A number assigned by the merchant to uniquely reference the transaction.
  3121. * This number must be unique within a day per Merchant ID per Terminal ID. */
  3122. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3123. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  3124. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3125. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  3126. cmnGrp.OrderNum = cmnGrp.RefNum;
  3127. /* An ID assigned by First Data, for the Third Party Processor or
  3128. * Software Vendor that generated the transaction. */
  3129. cmnGrp.TPPID = transactionRequest.TppId;
  3130. /* A unique ID assigned to a terminal. */
  3131. cmnGrp.TermID = transactionRequest.TerminalId;
  3132. /* A unique ID assigned by First Data, to identify the Merchant. */
  3133. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  3134. cmnGrp.POSEntryMode = PaymentAPIResources.EcomPosEntryMode;
  3135. cmnGrp.POSCondCode = POSCondCodeType.Item59;
  3136. cmnGrp.POSCondCodeSpecified = true;
  3137. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  3138. cmnGrp.TermCatCodeSpecified = true;
  3139. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item10;
  3140. cmnGrp.TermEntryCapabltSpecified = true;
  3141. cmnGrp.TermLocInd = TermLocIndType.Item1;
  3142. cmnGrp.TermLocIndSpecified = true;
  3143. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  3144. cmnGrp.CardCaptCapSpecified = true;
  3145. EcommGrp ecomgrp = new EcommGrp();
  3146. ecomgrp.EcommTxnInd = EcommTxnIndType.Item03;
  3147. ecomgrp.EcommTxnIndSpecified = true;
  3148. if (!string.Equals(transactionRequest.TransactionType, Void, StringComparison.CurrentCultureIgnoreCase) && !string.Equals(mtdTransaction.TxnType, Authorization, StringComparison.CurrentCultureIgnoreCase))
  3149. {
  3150. ecomgrp.EcommURL = PaymentAPIResources.EcomUrl;
  3151. }
  3152. _revDetails.EcommGrp = ecomgrp;
  3153. /* The amount of the transaction. This may be an authorization amount,
  3154. * adjustment amount or a reversal amount based on the type of transaction.
  3155. * It is inclusive of all additional amounts.
  3156. * It is submitted in the currency represented by the Transaction Currency field.
  3157. * The field is overwritten in the response for a partial authorization. */
  3158. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  3159. string amt = num.ToString("0.00").Replace(".", string.Empty);
  3160. cmnGrp.TxnAmt = Convert.ToString(amt);
  3161. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  3162. /* The numeric currency of the Transaction Amount. */
  3163. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  3164. /* An indicator that describes the location of the terminal. */
  3165. /* Indicates Group ID. */
  3166. cmnGrp.GroupID = transactionRequest.GroupId;
  3167. _revDetails.CommonGrp = cmnGrp;
  3168. #endregion
  3169. /* Populate values for Card Group */
  3170. #region Card Group
  3171. CardGrp cardGrp = new CardGrp();
  3172. TAGrp taGrp = new TAGrp();
  3173. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  3174. {
  3175. cardGrp.AcctNum = transactionRequest.CardNumber;
  3176. }
  3177. else
  3178. {
  3179. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  3180. }
  3181. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  3182. cardGrp.CardType = transactionRequest.CardType;
  3183. cardGrp.CardTypeSpecified = true;
  3184. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  3185. taGrp.SctyLvlSpecified = true;
  3186. taGrp.TknType = transactionRequest.TokenType;
  3187. _revDetails.TAGrp = taGrp;
  3188. _revDetails.CardGrp = cardGrp;
  3189. #endregion
  3190. #region Additional Amount Group
  3191. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  3192. addAmtGrp.AddAmt = Convert.ToString(amt);
  3193. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  3194. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  3195. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  3196. addAmtGrp.AddAmtTypeSpecified = true;
  3197. if (transactionRequest.TransactionType != Void)
  3198. {
  3199. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  3200. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  3201. }
  3202. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  3203. addAmtGrpArr[0] = addAmtGrp;
  3204. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  3205. #endregion
  3206. #region Discover Group
  3207. if (cardGrp.CardType.ToString().Equals(Discover))
  3208. {
  3209. DSGrp dsGrp = new DSGrp();
  3210. if (transactionRequest.TransactionType == Void)
  3211. {
  3212. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  3213. _revDetails.Item = dsGrp;
  3214. }
  3215. }
  3216. #endregion
  3217. #region Visa Group
  3218. if (cardGrp.CardType.ToString().Equals(Visa))
  3219. {
  3220. VisaGrp visaGrp = new VisaGrp();
  3221. visaGrp.ACI = !string.Equals(transactionRequest.TransactionType, Void,
  3222. StringComparison.CurrentCultureIgnoreCase) ? ACIType.Y : ACIType.T;
  3223. visaGrp.ACISpecified = true;
  3224. _revDetails.Item = visaGrp;
  3225. }
  3226. #endregion
  3227. // this group required for visa completion trax
  3228. #region originalAuth Group
  3229. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  3230. if (mtdTransaction != null)
  3231. {
  3232. switch (transactionRequest.TransactionType)
  3233. {
  3234. case Void:
  3235. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  3236. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  3237. break;
  3238. }
  3239. switch (mtdTransaction.TxnType)
  3240. {
  3241. case Void:
  3242. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  3243. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  3244. break;
  3245. }
  3246. XmlDocument xmlDoc = new XmlDocument();
  3247. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  3248. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  3249. if (localDateTime != null)
  3250. {
  3251. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  3252. }
  3253. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  3254. if (trnmsnDateTime != null)
  3255. {
  3256. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  3257. }
  3258. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  3259. }
  3260. _revDetails.OrigAuthGrp = orgAuthgrp;
  3261. #endregion
  3262. /* Add the data populated object to GMF message variant object */
  3263. _gmfMsgVar.Item = _revDetails;
  3264. transactionRequest.Stan = cmnGrp.STAN;
  3265. transactionRequest.TransRefNo = cmnGrp.RefNum;
  3266. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  3267. return _revDetails;
  3268. }
  3269. }
  3270. catch (Exception ex)
  3271. {
  3272. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  3273. }
  3274. return null;
  3275. }
  3276. /// <summary>
  3277. /// Purpose : Creating Reversal Void transaction request
  3278. /// Function Name : ReversalRequestMsr
  3279. /// Created By : Madhuri Tanwar
  3280. /// Created On : 03/20/2015
  3281. /// Modificatios Made : ****************************
  3282. /// Modidified On : "MM/DD/YYYY"
  3283. /// </summary>
  3284. /// <param name="transactionRequest"></param>
  3285. /// <returns></returns>
  3286. public VoidTOReversalRequestDetails ReversalRequestMsr(TransactionRequest transactionRequest)
  3287. {
  3288. try
  3289. {
  3290. if (!transactionRequest.IsNull())
  3291. {
  3292. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  3293. MethodBase.GetCurrentMethod().Name + ";");
  3294. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  3295. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  3296. #region Common Group
  3297. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  3298. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  3299. {
  3300. mtdTransaction = _terminalService.Completion(
  3301. transactionRequest.RapidConnectAuthId,
  3302. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3303. if (mtdTransaction.IsNull())
  3304. return null;
  3305. }
  3306. /* Populate values for Common Group */
  3307. CommonGrp cmnGrp = new CommonGrp();
  3308. /* The payment type of the transaction. */
  3309. PymtTypeType typePayment = transactionRequest.PaymentType;
  3310. cmnGrp.PymtType = typePayment;
  3311. cmnGrp.PymtTypeSpecified = true;
  3312. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  3313. cmnGrp.ReversalIndSpecified = true;
  3314. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  3315. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  3316. //cmnGrp.MerchCatCode = "5965";
  3317. /* The type of transaction being performed. */
  3318. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  3319. cmnGrp.TxnType = TxnTypeType.Sale;
  3320. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  3321. cmnGrp.TxnType = TxnTypeType.Refund;
  3322. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  3323. cmnGrp.TxnType = TxnTypeType.Authorization;
  3324. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  3325. cmnGrp.TxnType = TxnTypeType.Completion;
  3326. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  3327. {
  3328. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3329. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  3330. }
  3331. cmnGrp.TxnTypeSpecified = true;
  3332. /* The local date and time in which the transaction was performed. */
  3333. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  3334. /* The transmission date and time of the transaction (in GMT/UCT). */
  3335. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  3336. /* A number assigned by the merchant to uniquely reference the transaction.
  3337. * This number must be unique within a day per Merchant ID per Terminal ID. */
  3338. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3339. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  3340. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3341. //"480061115979";
  3342. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  3343. cmnGrp.OrderNum = cmnGrp.RefNum; //"162091864975";
  3344. /* An ID assigned by First Data, for the Third Party Processor or
  3345. * Software Vendor that generated the transaction. */
  3346. cmnGrp.TPPID = transactionRequest.TppId;
  3347. /* A unique ID assigned to a terminal. */
  3348. cmnGrp.TermID = transactionRequest.TerminalId;
  3349. /* A unique ID assigned by First Data, to identify the Merchant. */
  3350. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  3351. cmnGrp.POSEntryMode = PaymentAPIResources.RetailPosEntryMode;
  3352. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  3353. cmnGrp.POSCondCodeSpecified = true;
  3354. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  3355. cmnGrp.TermCatCodeSpecified = true;
  3356. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item10;
  3357. cmnGrp.TermEntryCapabltSpecified = true;
  3358. cmnGrp.TermLocInd = TermLocIndType.Item1;
  3359. cmnGrp.TermLocIndSpecified = true;
  3360. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  3361. cmnGrp.CardCaptCapSpecified = true;
  3362. /* The amount of the transaction. This may be an authorization amount,
  3363. * adjustment amount or a reversal amount based on the type of transaction.
  3364. * It is inclusive of all additional amounts.
  3365. * It is submitted in the currency represented by the Transaction Currency field.
  3366. * The field is overwritten in the response for a partial authorization. */
  3367. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  3368. string amt = num.ToString("0.00").Replace(".", string.Empty);
  3369. cmnGrp.TxnAmt = Convert.ToString(amt);
  3370. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  3371. /* The numeric currency of the Transaction Amount. */
  3372. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  3373. /* An indicator that describes the location of the terminal. */
  3374. /* Indicates Group ID. */
  3375. cmnGrp.GroupID = transactionRequest.GroupId;
  3376. _revDetails.CommonGrp = cmnGrp;
  3377. #endregion
  3378. /* Populate values for Card Group */
  3379. #region Card Group
  3380. CardGrp cardGrp = new CardGrp();
  3381. TAGrp taGrp = new TAGrp();
  3382. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  3383. {
  3384. taGrp.EncrptType = EncrptTypeType.RSA;
  3385. taGrp.EncrptTypeSpecified = true;
  3386. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  3387. taGrp.EncrptTrgtSpecified = true;
  3388. taGrp.KeyID = transactionRequest.KeyId;
  3389. taGrp.EncrptBlock = transactionRequest.Track3Data;
  3390. }
  3391. else
  3392. {
  3393. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  3394. }
  3395. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  3396. taGrp.SctyLvlSpecified = true;
  3397. taGrp.TknType = transactionRequest.TokenType;
  3398. cardGrp.CardType = transactionRequest.CardType;
  3399. cardGrp.CardTypeSpecified = true;
  3400. _revDetails.TAGrp = taGrp;
  3401. _revDetails.CardGrp = cardGrp;
  3402. #endregion
  3403. #region Additional Amount Group
  3404. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  3405. addAmtGrp.AddAmt = Convert.ToString(amt);
  3406. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  3407. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  3408. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  3409. addAmtGrp.AddAmtTypeSpecified = true;
  3410. if (transactionRequest.TransactionType != Void)
  3411. {
  3412. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  3413. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  3414. }
  3415. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  3416. addAmtGrpArr[0] = addAmtGrp;
  3417. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  3418. #endregion
  3419. #region Discover Group
  3420. if (cardGrp.CardType.ToString().Equals(Discover))
  3421. {
  3422. DSGrp dsGrp = new DSGrp();
  3423. if (transactionRequest.TransactionType == Void)
  3424. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  3425. _revDetails.Item = dsGrp;
  3426. }
  3427. #endregion
  3428. #region Visa Group
  3429. if (cardGrp.CardType.ToString().Equals(Visa))
  3430. {
  3431. VisaGrp visaGrp = new VisaGrp();
  3432. visaGrp.ACI = !string.Equals(transactionRequest.TransactionType, Void,
  3433. StringComparison.CurrentCultureIgnoreCase) ? ACIType.Y : ACIType.T;
  3434. visaGrp.ACISpecified = true;
  3435. _revDetails.Item = visaGrp;
  3436. }
  3437. #endregion
  3438. // this group required for visa completion trax
  3439. #region originalAuth Group
  3440. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  3441. if (mtdTransaction != null)
  3442. {
  3443. switch (transactionRequest.TransactionType)
  3444. {
  3445. case Void:
  3446. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  3447. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  3448. break;
  3449. }
  3450. switch (mtdTransaction.TxnType)
  3451. {
  3452. case Void:
  3453. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  3454. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  3455. break;
  3456. }
  3457. XmlDocument xmlDoc = new XmlDocument();
  3458. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  3459. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  3460. if (localDateTime != null)
  3461. {
  3462. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  3463. }
  3464. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  3465. if (trnmsnDateTime != null)
  3466. {
  3467. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  3468. }
  3469. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  3470. }
  3471. _revDetails.OrigAuthGrp = orgAuthgrp;
  3472. #endregion
  3473. /* Add the data populated object to GMF message variant object */
  3474. _gmfMsgVar.Item = _revDetails;
  3475. transactionRequest.Stan = cmnGrp.STAN;
  3476. transactionRequest.TransRefNo = cmnGrp.RefNum;
  3477. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  3478. return _revDetails;
  3479. }
  3480. }
  3481. catch (Exception ex)
  3482. {
  3483. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  3484. }
  3485. return null;
  3486. }
  3487. /// <summary>
  3488. /// Purpose : Creating Reversal Void and TOR transaction request
  3489. /// Function Name : ReversalRequestEmv
  3490. /// Created By : Madhuri Tanwar
  3491. /// Created On : 11/24/2015
  3492. /// Modificatios Made : ****************************
  3493. /// Modidified On : "MM/DD/YYYY"
  3494. /// </summary>
  3495. /// <param name="transactionRequest"></param>
  3496. /// <returns></returns>
  3497. public VoidTOReversalRequestDetails ReversalRequestEmv(TransactionRequest transactionRequest)
  3498. {
  3499. try
  3500. {
  3501. if (!transactionRequest.IsNull())
  3502. {
  3503. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  3504. MethodBase.GetCurrentMethod().Name + ";");
  3505. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  3506. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  3507. #region Common Group
  3508. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  3509. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  3510. {
  3511. mtdTransaction = _terminalService.Completion(
  3512. transactionRequest.RapidConnectAuthId,
  3513. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3514. if (mtdTransaction.IsNull())
  3515. return null;
  3516. }
  3517. /* Populate values for Common Group */
  3518. CommonGrp cmnGrp = new CommonGrp();
  3519. /* The payment type of the transaction. */
  3520. PymtTypeType typePayment = transactionRequest.PaymentType;
  3521. cmnGrp.PymtType = typePayment;
  3522. cmnGrp.PymtTypeSpecified = true;
  3523. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  3524. cmnGrp.ReversalIndSpecified = true;
  3525. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  3526. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  3527. //cmnGrp.MerchCatCode = "5965";
  3528. /* The type of transaction being performed. */
  3529. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  3530. cmnGrp.TxnType = TxnTypeType.Sale;
  3531. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  3532. cmnGrp.TxnType = TxnTypeType.Refund;
  3533. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  3534. cmnGrp.TxnType = TxnTypeType.Authorization;
  3535. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  3536. cmnGrp.TxnType = TxnTypeType.Completion;
  3537. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  3538. {
  3539. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3540. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  3541. }
  3542. cmnGrp.TxnTypeSpecified = true;
  3543. /* The local date and time in which the transaction was performed. */
  3544. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  3545. /* The transmission date and time of the transaction (in GMT/UCT). */
  3546. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  3547. /* A number assigned by the merchant to uniquely reference the transaction.
  3548. * This number must be unique within a day per Merchant ID per Terminal ID. */
  3549. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3550. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  3551. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3552. //"480061115979";
  3553. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  3554. cmnGrp.OrderNum = cmnGrp.RefNum; //"162091864975";
  3555. /* An ID assigned by First Data, for the Third Party Processor or
  3556. * Software Vendor that generated the transaction. */
  3557. cmnGrp.TPPID = transactionRequest.TppId;
  3558. /* A unique ID assigned to a terminal. */
  3559. cmnGrp.TermID = transactionRequest.TerminalId;
  3560. /* A unique ID assigned by First Data, to identify the Merchant. */
  3561. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  3562. cmnGrp.GroupID = transactionRequest.GroupId;
  3563. //Group ID value will be assigned by First Data.
  3564. //get terminal id from transaction request
  3565. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactEMVPosEntryMode;
  3566. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  3567. cmnGrp.POSCondCodeSpecified = true;
  3568. // cmnGrp.TermCatCode = TermCatCodeType.Item01;
  3569. cmnGrp.TermCatCode = TermCatCodeType.Item12;
  3570. cmnGrp.TermCatCodeSpecified = true;
  3571. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item08;
  3572. cmnGrp.TermEntryCapabltSpecified = true;
  3573. cmnGrp.TermLocInd = TermLocIndType.Item0;
  3574. cmnGrp.TermLocIndSpecified = true;
  3575. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  3576. cmnGrp.CardCaptCapSpecified = true;
  3577. /* The amount of the transaction. This may be an authorization amount,
  3578. * adjustment amount or a reversal amount based on the type of transaction.
  3579. * It is inclusive of all additional amounts.
  3580. * It is submitted in the currency represented by the Transaction Currency field.
  3581. * The field is overwritten in the response for a partial authorization. */
  3582. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  3583. string amt = num.ToString("0.00").Replace(".", string.Empty);
  3584. cmnGrp.TxnAmt = Convert.ToString(amt);
  3585. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  3586. /* The numeric currency of the Transaction Amount. */
  3587. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  3588. /* An indicator that describes the location of the terminal. */
  3589. /* Indicates Group ID. */
  3590. cmnGrp.GroupID = transactionRequest.GroupId;
  3591. _revDetails.CommonGrp = cmnGrp;
  3592. #endregion
  3593. /* Populate values for Card Group */
  3594. #region Card Group
  3595. CardGrp cardGrp = new CardGrp();
  3596. TAGrp taGrp = new TAGrp();
  3597. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  3598. {
  3599. taGrp.EncrptType = EncrptTypeType.RSA;
  3600. taGrp.EncrptTypeSpecified = true;
  3601. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  3602. taGrp.EncrptTrgtSpecified = true;
  3603. taGrp.KeyID = transactionRequest.KeyId;
  3604. taGrp.EncrptBlock = transactionRequest.Track3Data;
  3605. }
  3606. else
  3607. {
  3608. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  3609. }
  3610. cardGrp.CardType = transactionRequest.CardType;
  3611. cardGrp.CardTypeSpecified = true;
  3612. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  3613. taGrp.SctyLvlSpecified = true;
  3614. taGrp.TknType = transactionRequest.TokenType;
  3615. _revDetails.TAGrp = taGrp;
  3616. _revDetails.CardGrp = cardGrp;
  3617. #endregion
  3618. #region Visa Group
  3619. if (cardGrp.CardType.ToString().Equals(Visa))
  3620. {
  3621. VisaGrp visaGrp = new VisaGrp();
  3622. if (transactionRequest.TransactionType != Void)
  3623. {
  3624. visaGrp.ACI = ACIType.Y;
  3625. visaGrp.ACISpecified = true;
  3626. }
  3627. else
  3628. if (mtdTransaction != null)
  3629. {
  3630. XmlDocument xmlDoc = new XmlDocument();
  3631. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  3632. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  3633. var response = CommonFunctions.GetMCResponse(xmlString);
  3634. xmlDoc.LoadXml(response);
  3635. var aCI = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/ACI");
  3636. if (aCI != null)
  3637. {
  3638. visaGrp.ACI = (ACIType)Enum.Parse(typeof(ACIType), aCI.InnerText);
  3639. visaGrp.ACISpecified = true;
  3640. }
  3641. var transID = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/TransID");
  3642. if (transID != null)
  3643. {
  3644. visaGrp.TransID = transID.InnerText;
  3645. }
  3646. }
  3647. _revDetails.Item = visaGrp;
  3648. }
  3649. #endregion
  3650. #region MC Group
  3651. if (cardGrp.CardType.ToString().Equals(MasterCard))
  3652. {
  3653. MCGrp mcGrp = new MCGrp();
  3654. if (transactionRequest.TransactionType == Void)
  3655. {
  3656. if (mtdTransaction != null)
  3657. {
  3658. XmlDocument xmlDoc = new XmlDocument();
  3659. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  3660. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  3661. var response = CommonFunctions.GetMCResponse(xmlString);
  3662. xmlDoc.LoadXml(response);
  3663. var banknetData = xmlDoc.SelectSingleNode("CreditResponse/MCGrp/BanknetData");
  3664. if (banknetData != null)
  3665. {
  3666. mcGrp.BanknetData = banknetData.InnerText;
  3667. }
  3668. }
  3669. _revDetails.Item = mcGrp;
  3670. }
  3671. }
  3672. #endregion
  3673. #region Amex Group
  3674. if (cardGrp.CardType.ToString().Equals(Amex))
  3675. {
  3676. AmexGrp amexgrp = new AmexGrp();
  3677. if (transactionRequest.TransactionType == Void)
  3678. {
  3679. if (mtdTransaction != null)
  3680. {
  3681. amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  3682. XmlDocument xmlDoc = new XmlDocument();
  3683. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  3684. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  3685. var response = CommonFunctions.GetMCResponse(xmlString);
  3686. xmlDoc.LoadXml(response);
  3687. var amExPOSData = xmlDoc.SelectSingleNode("CreditResponse/AmexGrp/AmExPOSData");
  3688. if (amExPOSData != null)
  3689. {
  3690. amexgrp.AmExPOSData = amExPOSData.InnerText;
  3691. }
  3692. }
  3693. _revDetails.Item = amexgrp;
  3694. }
  3695. }
  3696. #endregion
  3697. #region Discover Group
  3698. if (cardGrp.CardType.ToString().Equals(Discover))
  3699. {
  3700. DSGrp dsGrp = new DSGrp();
  3701. if (transactionRequest.TransactionType == Void)
  3702. {
  3703. if (mtdTransaction != null)
  3704. {
  3705. XmlDocument xmlDoc = new XmlDocument();
  3706. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  3707. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  3708. var response = CommonFunctions.GetMCResponse(xmlString);
  3709. xmlDoc.LoadXml(response);
  3710. var discProcCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscProcCode");
  3711. if (discProcCode != null)
  3712. {
  3713. dsGrp.DiscProcCode = discProcCode.InnerText;
  3714. }
  3715. var discPOSEntry = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSEntry");
  3716. if (discPOSEntry != null)
  3717. {
  3718. dsGrp.DiscPOSEntry = discPOSEntry.InnerText;
  3719. }
  3720. var discRespCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscRespCode");
  3721. if (discRespCode != null)
  3722. {
  3723. dsGrp.DiscRespCode = discRespCode.InnerText;
  3724. }
  3725. var discPOSData = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSData");
  3726. if (discPOSData != null)
  3727. {
  3728. dsGrp.DiscPOSData = discPOSData.InnerText;
  3729. }
  3730. var discTransQualifier = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscTransQualifier");
  3731. if (discTransQualifier != null)
  3732. {
  3733. dsGrp.DiscTransQualifier = discTransQualifier.InnerText;
  3734. }
  3735. var discNRID = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscNRID");
  3736. if (discNRID != null)
  3737. {
  3738. dsGrp.DiscNRID = discNRID.InnerText;
  3739. }
  3740. }
  3741. _revDetails.Item = dsGrp;
  3742. }
  3743. }
  3744. #endregion
  3745. #region emv group
  3746. EMVGrp emvGrp = new EMVGrp();
  3747. emvGrp.EMVData = transactionRequest.EmvData;
  3748. if (transactionRequest.CardSeq != null && transactionRequest.TransactionType != Void)
  3749. {
  3750. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  3751. }
  3752. _revDetails.EMVGrp = emvGrp;
  3753. #endregion
  3754. #region addAm Group
  3755. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  3756. if (mtdTransaction != null)
  3757. {
  3758. if (transactionRequest.TransactionType == Void)
  3759. {
  3760. XmlDocument xmlDoc = new XmlDocument();
  3761. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  3762. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  3763. var response = CommonFunctions.GetMCResponse(xmlString);
  3764. xmlDoc.LoadXml(response);
  3765. var originalamt = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  3766. if (originalamt != null)
  3767. {
  3768. var amountP = originalamt.InnerText;
  3769. addAmtGrp.AddAmt = amountP.PadLeft(12, '0');
  3770. }
  3771. }
  3772. if (transactionRequest.TransactionType != Void)
  3773. {
  3774. addAmtGrp.AddAmt = Convert.ToString(amt);
  3775. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  3776. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  3777. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  3778. }
  3779. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  3780. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  3781. addAmtGrp.AddAmtTypeSpecified = true;
  3782. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  3783. addAmtGrpArr[0] = addAmtGrp;
  3784. //addAmtGrpArr[1] = addAmtGrp1;
  3785. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  3786. }
  3787. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  3788. if (mtdTransaction != null)
  3789. {
  3790. switch (transactionRequest.TransactionType)
  3791. {
  3792. case Void:
  3793. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  3794. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  3795. break;
  3796. }
  3797. switch (mtdTransaction.TxnType)
  3798. {
  3799. case Void:
  3800. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  3801. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  3802. break;
  3803. }
  3804. XmlDocument xmlDoc = new XmlDocument();
  3805. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  3806. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  3807. if (localDateTime != null)
  3808. {
  3809. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  3810. }
  3811. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  3812. if (trnmsnDateTime != null)
  3813. {
  3814. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  3815. }
  3816. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  3817. }
  3818. _revDetails.OrigAuthGrp = orgAuthgrp;
  3819. #endregion
  3820. _gmfMsgVar.Item = _revDetails;
  3821. transactionRequest.Stan = cmnGrp.STAN;
  3822. transactionRequest.TransRefNo = cmnGrp.RefNum;
  3823. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  3824. return _revDetails;
  3825. }
  3826. }
  3827. catch (Exception ex)
  3828. {
  3829. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  3830. }
  3831. return null;
  3832. }
  3833. /// <summary>
  3834. /// Purpose : Creating Reversal Void and TOR transaction request
  3835. /// Function Name : ReversalRequestEmvContactless
  3836. /// Created By : Madhuri Tanwar
  3837. /// Created On : 02/12/2016
  3838. /// Modificatios Made : ****************************
  3839. /// Modidified On : "MM/DD/YYYY"
  3840. /// </summary>
  3841. /// <param name="transactionRequest"></param>
  3842. /// <returns></returns>
  3843. public VoidTOReversalRequestDetails ReversalRequestEmvContactless(TransactionRequest transactionRequest)
  3844. {
  3845. try
  3846. {
  3847. if (!transactionRequest.IsNull())
  3848. {
  3849. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  3850. MethodBase.GetCurrentMethod().Name + ";");
  3851. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  3852. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  3853. #region Common Group
  3854. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  3855. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  3856. {
  3857. mtdTransaction = _terminalService.Completion(
  3858. transactionRequest.RapidConnectAuthId,
  3859. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3860. if (mtdTransaction.IsNull())
  3861. return null;
  3862. }
  3863. /* Populate values for Common Group */
  3864. CommonGrp cmnGrp = new CommonGrp();
  3865. /* The payment type of the transaction. */
  3866. PymtTypeType typePayment = transactionRequest.PaymentType;
  3867. cmnGrp.PymtType = typePayment;
  3868. cmnGrp.PymtTypeSpecified = true;
  3869. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  3870. cmnGrp.ReversalIndSpecified = true;
  3871. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  3872. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  3873. //cmnGrp.MerchCatCode = "5965";
  3874. /* The type of transaction being performed. */
  3875. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  3876. cmnGrp.TxnType = TxnTypeType.Sale;
  3877. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  3878. cmnGrp.TxnType = TxnTypeType.Refund;
  3879. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  3880. cmnGrp.TxnType = TxnTypeType.Authorization;
  3881. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  3882. cmnGrp.TxnType = TxnTypeType.Completion;
  3883. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  3884. {
  3885. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  3886. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  3887. }
  3888. cmnGrp.TxnTypeSpecified = true;
  3889. /* The local date and time in which the transaction was performed. */
  3890. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  3891. /* The transmission date and time of the transaction (in GMT/UCT). */
  3892. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  3893. /* A number assigned by the merchant to uniquely reference the transaction.
  3894. * This number must be unique within a day per Merchant ID per Terminal ID. */
  3895. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3896. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  3897. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  3898. //"480061115979";
  3899. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  3900. cmnGrp.OrderNum = mtdTransaction.TransRefNo; //cmnGrp.RefNum; //"162091864975";
  3901. /* An ID assigned by First Data, for the Third Party Processor or
  3902. * Software Vendor that generated the transaction. */
  3903. cmnGrp.TPPID = transactionRequest.TppId;
  3904. /* A unique ID assigned to a terminal. */
  3905. cmnGrp.TermID = transactionRequest.TerminalId;
  3906. /* A unique ID assigned by First Data, to identify the Merchant. */
  3907. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  3908. cmnGrp.GroupID = transactionRequest.GroupId;
  3909. //Group ID value will be assigned by First Data.
  3910. //get terminal id from transaction request
  3911. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactlessEMVPosEntryMode;
  3912. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  3913. cmnGrp.POSCondCodeSpecified = true;
  3914. // cmnGrp.TermCatCode = TermCatCodeType.Item01;
  3915. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  3916. cmnGrp.TermCatCodeSpecified = true;
  3917. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  3918. cmnGrp.TermEntryCapabltSpecified = true;
  3919. cmnGrp.TermLocInd = TermLocIndType.Item0;
  3920. cmnGrp.TermLocIndSpecified = true;
  3921. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  3922. cmnGrp.CardCaptCapSpecified = true;
  3923. /* The amount of the transaction. This may be an authorization amount,
  3924. * adjustment amount or a reversal amount based on the type of transaction.
  3925. * It is inclusive of all additional amounts.
  3926. * It is submitted in the currency represented by the Transaction Currency field.
  3927. * The field is overwritten in the response for a partial authorization. */
  3928. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  3929. string amt = num.ToString("0.00").Replace(".", string.Empty);
  3930. cmnGrp.TxnAmt = Convert.ToString(amt);
  3931. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  3932. /* The numeric currency of the Transaction Amount. */
  3933. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  3934. /* An indicator that describes the location of the terminal. */
  3935. /* Indicates Group ID. */
  3936. cmnGrp.GroupID = transactionRequest.GroupId;
  3937. _revDetails.CommonGrp = cmnGrp;
  3938. #endregion
  3939. /* Populate values for Card Group */
  3940. #region Card Group
  3941. CardGrp cardGrp = new CardGrp();
  3942. TAGrp taGrp = new TAGrp();
  3943. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  3944. {
  3945. taGrp.EncrptType = EncrptTypeType.RSA;
  3946. taGrp.EncrptTypeSpecified = true;
  3947. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  3948. taGrp.EncrptTrgtSpecified = true;
  3949. taGrp.KeyID = transactionRequest.KeyId;
  3950. taGrp.EncrptBlock = transactionRequest.Track3Data;
  3951. }
  3952. else
  3953. {
  3954. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  3955. }
  3956. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  3957. cardGrp.CardType = transactionRequest.CardType;
  3958. cardGrp.CardTypeSpecified = true;
  3959. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  3960. taGrp.SctyLvlSpecified = true;
  3961. taGrp.TknType = transactionRequest.TokenType;
  3962. _revDetails.TAGrp = taGrp;
  3963. _revDetails.CardGrp = cardGrp;
  3964. #endregion
  3965. #region Visa Group
  3966. if (cardGrp.CardType.ToString().Equals(Visa))
  3967. {
  3968. VisaGrp visaGrp = new VisaGrp();
  3969. if (transactionRequest.TransactionType != Void)
  3970. {
  3971. visaGrp.ACI = ACIType.Y;
  3972. visaGrp.ACISpecified = true;
  3973. }
  3974. else
  3975. if (mtdTransaction != null)
  3976. {
  3977. XmlDocument xmlDoc = new XmlDocument();
  3978. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  3979. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  3980. var response = CommonFunctions.GetMCResponse(xmlString);
  3981. xmlDoc.LoadXml(response);
  3982. var aCI = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/ACI");
  3983. if (aCI != null)
  3984. {
  3985. visaGrp.ACI = (ACIType)Enum.Parse(typeof(ACIType), aCI.InnerText);
  3986. visaGrp.ACISpecified = true;
  3987. }
  3988. var transID = xmlDoc.SelectSingleNode("CreditResponse/VisaGrp/TransID");
  3989. if (transID != null)
  3990. {
  3991. visaGrp.TransID = transID.InnerText;
  3992. }
  3993. }
  3994. _revDetails.Item = visaGrp;
  3995. }
  3996. #endregion
  3997. #region MC Group
  3998. if (cardGrp.CardType.ToString().Equals(MasterCard))
  3999. {
  4000. MCGrp mcGrp = new MCGrp();
  4001. mcGrp.DevTypeInd = "0";
  4002. if (transactionRequest.TransactionType == Void)
  4003. {
  4004. if (mtdTransaction != null)
  4005. {
  4006. XmlDocument xmlDoc = new XmlDocument();
  4007. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  4008. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  4009. var response = CommonFunctions.GetMCResponse(xmlString);
  4010. xmlDoc.LoadXml(response);
  4011. var banknetData = xmlDoc.SelectSingleNode("CreditResponse/MCGrp/BanknetData");
  4012. if (banknetData != null)
  4013. {
  4014. mcGrp.BanknetData = banknetData.InnerText;
  4015. }
  4016. }
  4017. _revDetails.Item = mcGrp;
  4018. }
  4019. _revDetails.Item = mcGrp;
  4020. }
  4021. #endregion
  4022. #region Amex Group
  4023. if (cardGrp.CardType.ToString().Equals(Amex))
  4024. {
  4025. AmexGrp amexgrp = new AmexGrp();
  4026. if (transactionRequest.TransactionType == Void)
  4027. {
  4028. if (mtdTransaction != null)
  4029. {
  4030. amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  4031. XmlDocument xmlDoc = new XmlDocument();
  4032. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  4033. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  4034. var response = CommonFunctions.GetMCResponse(xmlString);
  4035. xmlDoc.LoadXml(response);
  4036. var amExPOSData = xmlDoc.SelectSingleNode("CreditResponse/AmexGrp/AmExPOSData");
  4037. if (amExPOSData != null)
  4038. {
  4039. amexgrp.AmExPOSData = amExPOSData.InnerText;
  4040. }
  4041. }
  4042. _revDetails.Item = amexgrp;
  4043. }
  4044. }
  4045. #endregion
  4046. #region Discover Group
  4047. if (cardGrp.CardType.ToString().Equals(Discover))
  4048. {
  4049. DSGrp dsGrp = new DSGrp();
  4050. if (transactionRequest.TransactionType == Void)
  4051. {
  4052. if (mtdTransaction != null)
  4053. {
  4054. XmlDocument xmlDoc = new XmlDocument();
  4055. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  4056. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  4057. var response = CommonFunctions.GetMCResponse(xmlString);
  4058. xmlDoc.LoadXml(response);
  4059. var discProcCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscProcCode");
  4060. if (discProcCode != null)
  4061. {
  4062. dsGrp.DiscProcCode = discProcCode.InnerText;
  4063. }
  4064. var discPOSEntry = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSEntry");
  4065. if (discPOSEntry != null)
  4066. {
  4067. dsGrp.DiscPOSEntry = discPOSEntry.InnerText;
  4068. }
  4069. var discRespCode = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscRespCode");
  4070. if (discRespCode != null)
  4071. {
  4072. dsGrp.DiscRespCode = discRespCode.InnerText;
  4073. }
  4074. var discPOSData = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscPOSData");
  4075. if (discPOSData != null)
  4076. {
  4077. dsGrp.DiscPOSData = discPOSData.InnerText;
  4078. }
  4079. var discTransQualifier = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscTransQualifier");
  4080. if (discTransQualifier != null)
  4081. {
  4082. dsGrp.DiscTransQualifier = discTransQualifier.InnerText;
  4083. }
  4084. var discNRID = xmlDoc.SelectSingleNode("CreditResponse/DSGrp/DiscNRID");
  4085. if (discNRID != null)
  4086. {
  4087. dsGrp.DiscNRID = discNRID.InnerText;
  4088. }
  4089. }
  4090. _revDetails.Item = dsGrp;
  4091. }
  4092. }
  4093. #endregion
  4094. #region emv group
  4095. EMVGrp emvGrp = new EMVGrp();
  4096. emvGrp.EMVData = transactionRequest.EmvData;
  4097. if (transactionRequest.CardSeq != null && transactionRequest.TransactionType != Void)
  4098. {
  4099. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  4100. }
  4101. _revDetails.EMVGrp = emvGrp;
  4102. #endregion
  4103. #region addAm Group
  4104. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  4105. if (mtdTransaction != null)
  4106. {
  4107. if (transactionRequest.TransactionType == Void)
  4108. {
  4109. XmlDocument xmlDoc = new XmlDocument();
  4110. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  4111. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  4112. var response = CommonFunctions.GetMCResponse(xmlString);
  4113. xmlDoc.LoadXml(response);
  4114. var originalamt = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  4115. if (originalamt != null)
  4116. {
  4117. var amountP = originalamt.InnerText;
  4118. addAmtGrp.AddAmt = amountP.PadLeft(12, '0');
  4119. }
  4120. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  4121. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  4122. addAmtGrp.AddAmtTypeSpecified = true;
  4123. }
  4124. if (transactionRequest.TransactionType != Void)
  4125. {
  4126. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  4127. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  4128. }
  4129. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  4130. addAmtGrpArr[0] = addAmtGrp;
  4131. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  4132. }
  4133. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  4134. if (mtdTransaction != null)
  4135. {
  4136. switch (transactionRequest.TransactionType)
  4137. {
  4138. case Void:
  4139. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  4140. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  4141. break;
  4142. }
  4143. switch (mtdTransaction.TxnType)
  4144. {
  4145. case Void:
  4146. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  4147. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  4148. break;
  4149. }
  4150. XmlDocument xmlDoc = new XmlDocument();
  4151. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  4152. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  4153. if (localDateTime != null)
  4154. {
  4155. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  4156. }
  4157. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  4158. if (trnmsnDateTime != null)
  4159. {
  4160. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  4161. }
  4162. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  4163. }
  4164. _revDetails.OrigAuthGrp = orgAuthgrp;
  4165. #endregion
  4166. _gmfMsgVar.Item = _revDetails;
  4167. transactionRequest.Stan = cmnGrp.STAN;
  4168. transactionRequest.TransRefNo = cmnGrp.RefNum;
  4169. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  4170. return _revDetails;
  4171. }
  4172. }
  4173. catch (Exception ex)
  4174. {
  4175. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  4176. }
  4177. return null;
  4178. }
  4179. /// <summary>
  4180. /// Purpose : Creating Reversal Void and TOR transaction request
  4181. /// Function Name : ReversalRequestDebitEmvContactless
  4182. /// Created By : Madhuri Tanwar
  4183. /// Created On : 06/12/2016
  4184. /// Modificatios Made : ****************************
  4185. /// Modidified On : "MM/DD/YYYY"
  4186. /// </summary>
  4187. /// <param name="transactionRequest"></param>
  4188. /// <returns></returns>
  4189. public VoidTOReversalRequestDetails ReversalRequestDebitEmvContactless(TransactionRequest transactionRequest)
  4190. {
  4191. try
  4192. {
  4193. if (!transactionRequest.IsNull())
  4194. {
  4195. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  4196. MethodBase.GetCurrentMethod().Name + ";");
  4197. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  4198. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  4199. #region Common Group
  4200. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  4201. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  4202. {
  4203. mtdTransaction = _terminalService.Completion(
  4204. transactionRequest.RapidConnectAuthId,
  4205. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4206. if (mtdTransaction.IsNull())
  4207. return null;
  4208. }
  4209. /* Populate values for Common Group */
  4210. CommonGrp cmnGrp = new CommonGrp();
  4211. /* The payment type of the transaction. */
  4212. PymtTypeType typePayment = transactionRequest.PaymentType;
  4213. cmnGrp.PymtType = typePayment;
  4214. cmnGrp.PymtTypeSpecified = true;
  4215. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  4216. cmnGrp.ReversalIndSpecified = true;
  4217. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  4218. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  4219. //cmnGrp.MerchCatCode = "5965";
  4220. /* The type of transaction being performed. */
  4221. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  4222. cmnGrp.TxnType = TxnTypeType.Sale;
  4223. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  4224. cmnGrp.TxnType = TxnTypeType.Refund;
  4225. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  4226. cmnGrp.TxnType = TxnTypeType.Authorization;
  4227. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  4228. cmnGrp.TxnType = TxnTypeType.Completion;
  4229. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  4230. {
  4231. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4232. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  4233. }
  4234. cmnGrp.TxnTypeSpecified = true;
  4235. /* The local date and time in which the transaction was performed. */
  4236. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  4237. /* The transmission date and time of the transaction (in GMT/UCT). */
  4238. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  4239. /* A number assigned by the merchant to uniquely reference the transaction.
  4240. * This number must be unique within a day per Merchant ID per Terminal ID. */
  4241. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4242. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  4243. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4244. //"480061115979";
  4245. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  4246. cmnGrp.OrderNum = mtdTransaction.TransRefNo; //cmnGrp.RefNum; //"162091864975";
  4247. /* An ID assigned by First Data, for the Third Party Processor or
  4248. * Software Vendor that generated the transaction. */
  4249. cmnGrp.TPPID = transactionRequest.TppId;
  4250. /* A unique ID assigned to a terminal. */
  4251. cmnGrp.TermID = transactionRequest.TerminalId;
  4252. /* A unique ID assigned by First Data, to identify the Merchant. */
  4253. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  4254. cmnGrp.GroupID = transactionRequest.GroupId;
  4255. //Group ID value will be assigned by First Data.
  4256. //get terminal id from transaction request
  4257. cmnGrp.POSEntryMode = PaymentAPIResources.RetailContactlessEMVPosEntryMode;
  4258. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  4259. cmnGrp.POSCondCodeSpecified = true;
  4260. // cmnGrp.TermCatCode = TermCatCodeType.Item01;
  4261. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  4262. cmnGrp.TermCatCodeSpecified = true;
  4263. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  4264. cmnGrp.TermEntryCapabltSpecified = true;
  4265. cmnGrp.TermLocInd = TermLocIndType.Item0;
  4266. cmnGrp.TermLocIndSpecified = true;
  4267. cmnGrp.CardCaptCap = CardCaptCapType.Item1;
  4268. cmnGrp.CardCaptCapSpecified = true;
  4269. /* The amount of the transaction. This may be an authorization amount,
  4270. * adjustment amount or a reversal amount based on the type of transaction.
  4271. * It is inclusive of all additional amounts.
  4272. * It is submitted in the currency represented by the Transaction Currency field.
  4273. * The field is overwritten in the response for a partial authorization. */
  4274. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  4275. string amt = num.ToString("0.00").Replace(".", string.Empty);
  4276. cmnGrp.TxnAmt = Convert.ToString(amt);
  4277. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  4278. /* The numeric currency of the Transaction Amount. */
  4279. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  4280. /* An indicator that describes the location of the terminal. */
  4281. /* Indicates Group ID. */
  4282. cmnGrp.GroupID = transactionRequest.GroupId;
  4283. _revDetails.CommonGrp = cmnGrp;
  4284. #endregion
  4285. /* Populate values for Card Group */
  4286. #region Card Group
  4287. CardGrp cardGrp = new CardGrp();
  4288. TAGrp taGrp = new TAGrp();
  4289. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  4290. {
  4291. taGrp.EncrptType = EncrptTypeType.RSA;
  4292. taGrp.EncrptTypeSpecified = true;
  4293. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  4294. taGrp.EncrptTrgtSpecified = true;
  4295. taGrp.KeyID = transactionRequest.KeyId;
  4296. taGrp.EncrptBlock = transactionRequest.Track3Data;
  4297. }
  4298. else
  4299. {
  4300. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  4301. }
  4302. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  4303. // cardGrp.CardType = transactionRequest.CardType;
  4304. // cardGrp.CardTypeSpecified = true;
  4305. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  4306. taGrp.SctyLvlSpecified = true;
  4307. taGrp.TknType = transactionRequest.TokenType;
  4308. _revDetails.TAGrp = taGrp;
  4309. _revDetails.CardGrp = cardGrp;
  4310. #endregion
  4311. #region emv group
  4312. EMVGrp emvGrp = new EMVGrp();
  4313. emvGrp.EMVData = transactionRequest.EmvData;
  4314. if (transactionRequest.CardSeq != null && transactionRequest.TransactionType != Void)
  4315. {
  4316. emvGrp.CardSeqNum = transactionRequest.CardSeq;
  4317. }
  4318. _revDetails.EMVGrp = emvGrp;
  4319. #endregion
  4320. #region addAm Group
  4321. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  4322. if (mtdTransaction != null)
  4323. {
  4324. if (transactionRequest.TransactionType == Void)
  4325. {
  4326. XmlDocument xmlDoc = new XmlDocument();
  4327. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  4328. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  4329. var response = CommonFunctions.GetMCResponse(xmlString);
  4330. xmlDoc.LoadXml(response);
  4331. var originalamt = xmlDoc.SelectSingleNode("CreditResponse/CommonGrp/TxnAmt");
  4332. if (originalamt != null)
  4333. {
  4334. var amountP = originalamt.InnerText;
  4335. addAmtGrp.AddAmt = amountP.PadLeft(12, '0');
  4336. }
  4337. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  4338. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  4339. addAmtGrp.AddAmtTypeSpecified = true;
  4340. }
  4341. if (transactionRequest.TransactionType != Void)
  4342. {
  4343. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  4344. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  4345. }
  4346. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  4347. addAmtGrpArr[0] = addAmtGrp;
  4348. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  4349. }
  4350. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  4351. if (mtdTransaction != null)
  4352. {
  4353. switch (transactionRequest.TransactionType)
  4354. {
  4355. case Void:
  4356. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  4357. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  4358. break;
  4359. }
  4360. switch (mtdTransaction.TxnType)
  4361. {
  4362. case Void:
  4363. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  4364. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  4365. break;
  4366. }
  4367. XmlDocument xmlDoc = new XmlDocument();
  4368. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  4369. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  4370. if (localDateTime != null)
  4371. {
  4372. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  4373. }
  4374. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  4375. if (trnmsnDateTime != null)
  4376. {
  4377. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  4378. }
  4379. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  4380. }
  4381. _revDetails.OrigAuthGrp = orgAuthgrp;
  4382. #endregion
  4383. _gmfMsgVar.Item = _revDetails;
  4384. transactionRequest.Stan = cmnGrp.STAN;
  4385. transactionRequest.TransRefNo = cmnGrp.RefNum;
  4386. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  4387. return _revDetails;
  4388. }
  4389. }
  4390. catch (Exception ex)
  4391. {
  4392. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  4393. }
  4394. return null;
  4395. }
  4396. /// <summary>
  4397. /// Purpose : Creating Reversal Void transaction request
  4398. /// Function Name : ReversalRequestMsrContactless
  4399. /// Created By : Madhuri Tanwar
  4400. /// Created On : 02/23/2016
  4401. /// Modificatios Made : ****************************
  4402. /// Modidified On : "MM/DD/YYYY"
  4403. /// </summary>
  4404. /// <param name="transactionRequest"></param>
  4405. /// <returns></returns>
  4406. public VoidTOReversalRequestDetails ReversalRequestMsrContactless(TransactionRequest transactionRequest)
  4407. {
  4408. try
  4409. {
  4410. if (!transactionRequest.IsNull())
  4411. {
  4412. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  4413. MethodBase.GetCurrentMethod().Name + ";");
  4414. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  4415. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  4416. #region Common Group
  4417. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  4418. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  4419. {
  4420. mtdTransaction = _terminalService.Completion(
  4421. transactionRequest.RapidConnectAuthId,
  4422. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4423. if (mtdTransaction.IsNull())
  4424. return null;
  4425. }
  4426. /* Populate values for Common Group */
  4427. CommonGrp cmnGrp = new CommonGrp();
  4428. /* The payment type of the transaction. */
  4429. PymtTypeType typePayment = transactionRequest.PaymentType;
  4430. cmnGrp.PymtType = typePayment;
  4431. cmnGrp.PymtTypeSpecified = true;
  4432. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  4433. cmnGrp.ReversalIndSpecified = true;
  4434. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  4435. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  4436. //cmnGrp.MerchCatCode = "5965";
  4437. /* The type of transaction being performed. */
  4438. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  4439. cmnGrp.TxnType = TxnTypeType.Sale;
  4440. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  4441. cmnGrp.TxnType = TxnTypeType.Refund;
  4442. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  4443. cmnGrp.TxnType = TxnTypeType.Authorization;
  4444. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  4445. cmnGrp.TxnType = TxnTypeType.Completion;
  4446. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  4447. {
  4448. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4449. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  4450. }
  4451. cmnGrp.TxnTypeSpecified = true;
  4452. /* The local date and time in which the transaction was performed. */
  4453. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  4454. /* The transmission date and time of the transaction (in GMT/UCT). */
  4455. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  4456. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4457. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  4458. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4459. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  4460. cmnGrp.OrderNum = mtdTransaction.TransRefNo;
  4461. /* An ID assigned by First Data, for the Third Party Processor or
  4462. * Software Vendor that generated the transaction. */
  4463. cmnGrp.TPPID = transactionRequest.TppId;
  4464. /* A unique ID assigned to a terminal. */
  4465. cmnGrp.TermID = transactionRequest.TerminalId;
  4466. /* A unique ID assigned by First Data, to identify the Merchant. */
  4467. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  4468. cmnGrp.POSEntryMode = PaymentAPIResources.MSRContactlessEntryMode;
  4469. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  4470. cmnGrp.POSCondCodeSpecified = true;
  4471. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  4472. cmnGrp.TermCatCodeSpecified = true;
  4473. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  4474. cmnGrp.TermEntryCapabltSpecified = true;
  4475. cmnGrp.TermLocInd = TermLocIndType.Item1;
  4476. cmnGrp.TermLocIndSpecified = true;
  4477. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  4478. cmnGrp.CardCaptCapSpecified = true;
  4479. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  4480. string amt = num.ToString("0.00").Replace(".", string.Empty);
  4481. cmnGrp.TxnAmt = Convert.ToString(amt);
  4482. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  4483. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  4484. cmnGrp.GroupID = transactionRequest.GroupId;
  4485. _revDetails.CommonGrp = cmnGrp;
  4486. #endregion
  4487. #region Card Group
  4488. CardGrp cardGrp = new CardGrp();
  4489. TAGrp taGrp = new TAGrp();
  4490. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  4491. {
  4492. taGrp.EncrptType = EncrptTypeType.RSA;
  4493. taGrp.EncrptTypeSpecified = true;
  4494. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  4495. taGrp.EncrptTrgtSpecified = true;
  4496. taGrp.KeyID = transactionRequest.KeyId;
  4497. taGrp.EncrptBlock = transactionRequest.Track3Data;
  4498. }
  4499. else
  4500. {
  4501. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  4502. }
  4503. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  4504. taGrp.SctyLvlSpecified = true;
  4505. taGrp.TknType = transactionRequest.TokenType;
  4506. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  4507. cardGrp.CardType = transactionRequest.CardType;
  4508. cardGrp.CardTypeSpecified = true;
  4509. _revDetails.TAGrp = taGrp;
  4510. _revDetails.CardGrp = cardGrp;
  4511. #endregion
  4512. #region Additional Amount Group
  4513. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  4514. if (transactionRequest.TransactionType == Void)
  4515. {
  4516. addAmtGrp.AddAmt = Convert.ToString(amt);
  4517. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  4518. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  4519. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  4520. addAmtGrp.AddAmtTypeSpecified = true;
  4521. }
  4522. else
  4523. {
  4524. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  4525. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  4526. }
  4527. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  4528. addAmtGrpArr[0] = addAmtGrp;
  4529. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  4530. #endregion
  4531. #region Discover Group
  4532. if (cardGrp.CardType.ToString().Equals(Discover))
  4533. {
  4534. DSGrp dsGrp = new DSGrp();
  4535. if (transactionRequest.TransactionType == Void)
  4536. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  4537. _revDetails.Item = dsGrp;
  4538. }
  4539. #endregion
  4540. #region Visa Group
  4541. if (cardGrp.CardType.ToString().Equals(Visa))
  4542. {
  4543. VisaGrp visaGrp = new VisaGrp();
  4544. visaGrp.ACI = !string.Equals(transactionRequest.TransactionType, Void,
  4545. StringComparison.CurrentCultureIgnoreCase) ? ACIType.Y : ACIType.T;
  4546. visaGrp.ACISpecified = true;
  4547. _revDetails.Item = visaGrp;
  4548. }
  4549. #endregion
  4550. #region originalAuth Group
  4551. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  4552. if (mtdTransaction != null)
  4553. {
  4554. switch (transactionRequest.TransactionType)
  4555. {
  4556. case Void:
  4557. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  4558. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  4559. break;
  4560. }
  4561. switch (mtdTransaction.TxnType)
  4562. {
  4563. case Void:
  4564. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  4565. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  4566. break;
  4567. }
  4568. XmlDocument xmlDoc = new XmlDocument();
  4569. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  4570. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  4571. if (localDateTime != null)
  4572. {
  4573. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  4574. }
  4575. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  4576. if (trnmsnDateTime != null)
  4577. {
  4578. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  4579. }
  4580. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  4581. }
  4582. _revDetails.OrigAuthGrp = orgAuthgrp;
  4583. #endregion
  4584. _gmfMsgVar.Item = _revDetails;
  4585. transactionRequest.Stan = cmnGrp.STAN;
  4586. transactionRequest.TransRefNo = cmnGrp.RefNum;
  4587. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  4588. return _revDetails;
  4589. }
  4590. }
  4591. catch (Exception ex)
  4592. {
  4593. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  4594. }
  4595. return null;
  4596. }
  4597. /// <summary>
  4598. /// Purpose : Creating Reversal Void transaction request
  4599. /// Function Name : ReversalRequestDebitMsrContactless
  4600. /// Created By : Madhuri Tanwar
  4601. /// Created On : 06/12/2016
  4602. /// Modificatios Made : ****************************
  4603. /// Modidified On : "MM/DD/YYYY"
  4604. /// </summary>
  4605. /// <param name="transactionRequest"></param>
  4606. /// <returns></returns>
  4607. public VoidTOReversalRequestDetails ReversalRequestDebitMsrContactless(TransactionRequest transactionRequest)
  4608. {
  4609. try
  4610. {
  4611. if (!transactionRequest.IsNull())
  4612. {
  4613. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  4614. MethodBase.GetCurrentMethod().Name + ";");
  4615. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  4616. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  4617. #region Common Group
  4618. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  4619. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  4620. {
  4621. mtdTransaction = _terminalService.Completion(
  4622. transactionRequest.RapidConnectAuthId,
  4623. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4624. if (mtdTransaction.IsNull())
  4625. return null;
  4626. }
  4627. CommonGrp cmnGrp = new CommonGrp();
  4628. PymtTypeType typePayment = transactionRequest.PaymentType;
  4629. cmnGrp.PymtType = typePayment;
  4630. cmnGrp.PymtTypeSpecified = true;
  4631. cmnGrp.ReversalInd = transactionRequest.TransactionType == Void ? ReversalIndType.Void : ReversalIndType.Timeout;
  4632. cmnGrp.ReversalIndSpecified = true;
  4633. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  4634. MTDTransactionDto mtdVoidTransaction = new MTDTransactionDto();
  4635. if (mtdTransaction != null && mtdTransaction.TxnType == Sale)
  4636. cmnGrp.TxnType = TxnTypeType.Sale;
  4637. if (mtdTransaction != null && mtdTransaction.TxnType == Refund)
  4638. cmnGrp.TxnType = TxnTypeType.Refund;
  4639. if (mtdTransaction != null && mtdTransaction.TxnType == Authorization)
  4640. cmnGrp.TxnType = TxnTypeType.Authorization;
  4641. if (mtdTransaction != null && mtdTransaction.TxnType == Completion)
  4642. cmnGrp.TxnType = TxnTypeType.Completion;
  4643. if (mtdTransaction != null && mtdTransaction.TxnType == Void)
  4644. {
  4645. mtdVoidTransaction = _terminalService.Completion(Convert.ToString(mtdTransaction.Id), transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4646. cmnGrp.TxnType = (TxnTypeType)Enum.Parse(typeof(TxnTypeType), mtdVoidTransaction.TxnType);
  4647. }
  4648. cmnGrp.TxnTypeSpecified = true;
  4649. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;
  4650. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;
  4651. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4652. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4653. cmnGrp.OrderNum = mtdTransaction.TransOrderNo;
  4654. cmnGrp.TPPID = transactionRequest.TppId;
  4655. cmnGrp.TermID = transactionRequest.TerminalId;
  4656. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  4657. cmnGrp.POSEntryMode = PaymentAPIResources.MSRContactlessEntryMode;
  4658. cmnGrp.POSCondCode = POSCondCodeType.Item00;
  4659. cmnGrp.POSCondCodeSpecified = true;
  4660. cmnGrp.TermCatCode = TermCatCodeType.Item01;
  4661. cmnGrp.TermCatCodeSpecified = true;
  4662. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item04;
  4663. cmnGrp.TermEntryCapabltSpecified = true;
  4664. cmnGrp.TermLocInd = TermLocIndType.Item1;
  4665. cmnGrp.TermLocIndSpecified = true;
  4666. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  4667. cmnGrp.CardCaptCapSpecified = true;
  4668. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  4669. string amt = num.ToString("0.00").Replace(".", string.Empty);
  4670. cmnGrp.TxnAmt = Convert.ToString(amt);
  4671. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  4672. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  4673. cmnGrp.GroupID = transactionRequest.GroupId;
  4674. _revDetails.CommonGrp = cmnGrp;
  4675. #endregion
  4676. #region Card Group
  4677. CardGrp cardGrp = new CardGrp();
  4678. TAGrp taGrp = new TAGrp();
  4679. if (transactionRequest.TransactionType != Void && (mtdTransaction.TxnType == Sale || mtdTransaction.TxnType == Authorization))
  4680. {
  4681. taGrp.EncrptType = EncrptTypeType.RSA;
  4682. taGrp.EncrptTypeSpecified = true;
  4683. taGrp.EncrptTrgt = EncrptTrgtType.Track2;
  4684. taGrp.EncrptTrgtSpecified = true;
  4685. taGrp.KeyID = transactionRequest.KeyId;
  4686. taGrp.EncrptBlock = transactionRequest.Track3Data;
  4687. }
  4688. else
  4689. {
  4690. taGrp.Tkn = mtdTransaction.CardToken.Decrypt();
  4691. }
  4692. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  4693. taGrp.SctyLvlSpecified = true;
  4694. taGrp.TknType = transactionRequest.TokenType;
  4695. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  4696. _revDetails.TAGrp = taGrp;
  4697. _revDetails.CardGrp = cardGrp;
  4698. #endregion
  4699. #region Additional Amount Group
  4700. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  4701. if (transactionRequest.TransactionType != Void)
  4702. {
  4703. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  4704. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  4705. }
  4706. else
  4707. {
  4708. addAmtGrp.AddAmt = Convert.ToString(amt);
  4709. addAmtGrp.AddAmt = addAmtGrp.AddAmt.PadLeft(12, '0');
  4710. addAmtGrp.AddAmtCrncy = PaymentAPIResources.Cur_USA;
  4711. addAmtGrp.AddAmtType = AddAmtTypeType.TotalAuthAmt;
  4712. addAmtGrp.AddAmtTypeSpecified = true;
  4713. }
  4714. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  4715. addAmtGrpArr[0] = addAmtGrp;
  4716. _revDetails.AddtlAmtGrp = addAmtGrpArr;
  4717. #endregion
  4718. #region originalAuth Group
  4719. OrigAuthGrp orgAuthgrp = new OrigAuthGrp();
  4720. if (mtdTransaction != null)
  4721. {
  4722. switch (transactionRequest.TransactionType)
  4723. {
  4724. case Void:
  4725. orgAuthgrp.OrigAuthID = mtdTransaction.AuthId;
  4726. orgAuthgrp.OrigRespCode = mtdTransaction.ResponseCode;
  4727. break;
  4728. }
  4729. switch (mtdTransaction.TxnType)
  4730. {
  4731. case Void:
  4732. orgAuthgrp.OrigAuthID = mtdVoidTransaction.AuthId;
  4733. orgAuthgrp.OrigRespCode = mtdVoidTransaction.ResponseCode;
  4734. break;
  4735. }
  4736. XmlDocument xmlDoc = new XmlDocument();
  4737. xmlDoc.LoadXml(mtdTransaction.RequestXml);
  4738. var localDateTime = xmlDoc.SelectSingleNode("TransactionRequest/LocalDateTime");
  4739. if (localDateTime != null)
  4740. {
  4741. orgAuthgrp.OrigLocalDateTime = localDateTime.InnerText;
  4742. }
  4743. var trnmsnDateTime = xmlDoc.SelectSingleNode("TransactionRequest/TrnmsnDateTime");
  4744. if (trnmsnDateTime != null)
  4745. {
  4746. orgAuthgrp.OrigTranDateTime = trnmsnDateTime.InnerText;
  4747. }
  4748. orgAuthgrp.OrigSTAN = mtdTransaction.Stan;
  4749. }
  4750. _revDetails.OrigAuthGrp = orgAuthgrp;
  4751. #endregion
  4752. /* Add the data populated object to GMF message variant object */
  4753. _gmfMsgVar.Item = _revDetails;
  4754. transactionRequest.Stan = cmnGrp.STAN;
  4755. transactionRequest.TransRefNo = cmnGrp.RefNum;
  4756. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  4757. return _revDetails;
  4758. }
  4759. }
  4760. catch (Exception ex)
  4761. {
  4762. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  4763. }
  4764. return null;
  4765. }
  4766. ///// <summary>
  4767. ///// Purpose : Creating Transarmor request
  4768. ///// Function Name : TaRequest
  4769. ///// Created By : Madhuri Tanwar
  4770. ///// Created On : 04/20/2015
  4771. ///// Modificatios Made : ****************************
  4772. ///// Modidified On : "MM/DD/YYYY"
  4773. ///// </summary>
  4774. ///// <param name="transactionRequest"></param>
  4775. ///// <returns></returns>
  4776. public TARequestDetails TaRequest(TransactionRequest transactionRequest)
  4777. {
  4778. try
  4779. {
  4780. if (!transactionRequest.IsNull())
  4781. {
  4782. #region Common Group
  4783. /* Populate values for Common Group */
  4784. CommonGrp cmnGrp = new CommonGrp();
  4785. /* The payment type of the transaction. */
  4786. PymtTypeType typePayment = transactionRequest.PaymentType;
  4787. cmnGrp.PymtType = typePayment;
  4788. cmnGrp.PymtTypeSpecified = true;
  4789. /* The type of transaction being performed. */
  4790. cmnGrp.TxnType = TxnTypeType.TATokenRequest;
  4791. cmnGrp.TxnTypeSpecified = true;
  4792. /* The local date and time in which the transaction was performed. */
  4793. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  4794. /* The transmission date and time of the transaction (in GMT/UCT). */
  4795. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  4796. /* A number assigned by the merchant to uniquely reference the transaction.
  4797. * This number must be unique within a day per Merchant ID per Terminal ID. */
  4798. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4799. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  4800. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4801. //"480061115979";
  4802. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  4803. //cmnGrp.OrderNum = cmnGrp.RefNum; //"162091864975";
  4804. /* An ID assigned by First Data, for the Third Party Processor or
  4805. * Software Vendor that generated the transaction. */
  4806. cmnGrp.TPPID = transactionRequest.TppId;
  4807. /* A unique ID assigned to a terminal. */
  4808. cmnGrp.TermID = transactionRequest.TerminalId;
  4809. /* A unique ID assigned by First Data, to identify the Merchant. */
  4810. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  4811. /* Indicates Group ID. */
  4812. cmnGrp.GroupID = transactionRequest.GroupId;
  4813. _taRequest.CommonGrp = cmnGrp;
  4814. #endregion
  4815. #region Card Group
  4816. /* Populate values for Card Group */
  4817. CardGrp cardGrp = new CardGrp();
  4818. cardGrp.AcctNum = transactionRequest.CardNumber;
  4819. _taRequest.CardGrp = cardGrp;
  4820. #endregion
  4821. #region TransArmor group
  4822. /* Populate values for Card Group */
  4823. TAGrp taGrp = new TAGrp();
  4824. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  4825. taGrp.SctyLvlSpecified = true;
  4826. taGrp.TknType = transactionRequest.TokenType;
  4827. _taRequest.TAGrp = taGrp;
  4828. #endregion
  4829. /* Add the data populated object to GMF message variant object */
  4830. _gmfMsgVar.Item = _taRequest;
  4831. transactionRequest.Stan = cmnGrp.STAN;
  4832. transactionRequest.TransRefNo = cmnGrp.RefNum;
  4833. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  4834. return _taRequest;
  4835. }
  4836. }
  4837. catch (Exception ex)
  4838. {
  4839. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  4840. }
  4841. return null;
  4842. }
  4843. /// <summary>
  4844. /// Purpose : Creating Transarmor request
  4845. /// Function Name : TaRequest
  4846. /// Created By : Madhuri Tanwar
  4847. /// Created On : 09/20/2015
  4848. /// Modificatios Made : ****************************
  4849. /// Modidified On : "MM/DD/YYYY"
  4850. /// </summary>
  4851. /// <param name="transactionRequest"></param>
  4852. /// <returns></returns>
  4853. public TARequestDetails TaKeyRequest(TransactionRequest transactionRequest)
  4854. {
  4855. try
  4856. {
  4857. if (!transactionRequest.IsNull())
  4858. {
  4859. #region Common Group
  4860. /* Populate values for Common Group */
  4861. CommonGrp cmnGrp = new CommonGrp();
  4862. /* The payment type of the transaction. */
  4863. //PymtTypeType typePayment = transactionRequest.PaymentType;
  4864. //cmnGrp.PymtType = typePayment;
  4865. //cmnGrp.PymtTypeSpecified = true;
  4866. /* The type of transaction being performed. */
  4867. cmnGrp.TxnType = TxnTypeType.TAKeyRequest;
  4868. cmnGrp.TxnTypeSpecified = true;
  4869. /* The local date and time in which the transaction was performed. */
  4870. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  4871. /* The transmission date and time of the transaction (in GMT/UCT). */
  4872. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  4873. /* A number assigned by the merchant to uniquely reference the transaction.
  4874. * This number must be unique within a day per Merchant ID per Terminal ID. */
  4875. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4876. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  4877. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4878. //"480061115979";
  4879. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  4880. //cmnGrp.OrderNum = cmnGrp.RefNum; //"162091864975";
  4881. /* An ID assigned by First Data, for the Third Party Processor or
  4882. * Software Vendor that generated the transaction. */
  4883. cmnGrp.TPPID = transactionRequest.TppId;
  4884. /* A unique ID assigned to a terminal. */
  4885. cmnGrp.TermID = transactionRequest.TerminalId;
  4886. /* A unique ID assigned by First Data, to identify the Merchant. */
  4887. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  4888. /* Indicates Group ID. */
  4889. cmnGrp.GroupID = transactionRequest.GroupId;
  4890. _taRequest.CommonGrp = cmnGrp;
  4891. #endregion
  4892. #region TransArmor group
  4893. /* Populate values for Card Group */
  4894. TAGrp taGrp = new TAGrp();
  4895. taGrp.SctyLvl = SctyLvlType.EncrptTknizatn;
  4896. taGrp.SctyLvlSpecified = true;
  4897. taGrp.EncrptType = EncrptTypeType.RSA;
  4898. taGrp.EncrptTypeSpecified = true;
  4899. _taRequest.TAGrp = taGrp;
  4900. #endregion
  4901. /* Add the data populated object to GMF message variant object */
  4902. _gmfMsgVar.Item = _taRequest;
  4903. transactionRequest.Stan = cmnGrp.STAN;
  4904. transactionRequest.TransRefNo = cmnGrp.RefNum;
  4905. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  4906. return _taRequest;
  4907. }
  4908. }
  4909. catch (Exception ex)
  4910. {
  4911. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  4912. }
  4913. return null;
  4914. }
  4915. /// <summary>
  4916. /// Purpose : Creating credit card request
  4917. /// Function Name : CreateRequest
  4918. /// Created By : Salil Gupta
  4919. /// Created On : 03/16/2015
  4920. /// Modificatios Made : ****************************
  4921. /// Modidified On : 04/017/2015 "MM/DD/YYYY"
  4922. /// </summary>
  4923. /// <param name="transactionRequest"></param>
  4924. /// <returns></returns>
  4925. private CreditRequestDetails BookerAppRequest(TransactionRequest transactionRequest)
  4926. {
  4927. /* Based on the GMF Specification UMF_Schema_V1.1.14.xsd, fields that are mandatory or related to
  4928. this transaction should be populated.*/
  4929. try
  4930. {
  4931. if (!transactionRequest.IsNull())
  4932. {
  4933. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  4934. MethodBase.GetCurrentMethod().Name + ";");
  4935. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  4936. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  4937. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  4938. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  4939. {
  4940. mtdTransaction = _terminalService.Completion(
  4941. transactionRequest.RapidConnectAuthId,
  4942. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  4943. if (mtdTransaction.IsNull())
  4944. return null;
  4945. }
  4946. #region Common Group
  4947. CommonGrp cmnGrp = new CommonGrp();
  4948. /* The payment type of the transaction. */
  4949. PymtTypeType typePayment = transactionRequest.PaymentType;
  4950. cmnGrp.PymtType = typePayment;
  4951. cmnGrp.PymtTypeSpecified = true;
  4952. /* merchant category code. */
  4953. cmnGrp.MerchCatCode = transactionRequest.MCCode;
  4954. /* The type of transaction being performed. */
  4955. cmnGrp.TxnType = transactionRequest.TransType;
  4956. cmnGrp.TxnTypeSpecified = true;
  4957. /* The local date and time in which the transaction was performed. */
  4958. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  4959. /* The transmission date and time of the transaction (in GMT/UCT). */
  4960. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  4961. /* A number assigned by the merchant to uniquely reference the transaction.
  4962. * This number must be unique within a day per Merchant ID per Terminal ID. */
  4963. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4964. /* A number assigned by the merchant to uniquely reference a set of transactions. */
  4965. //cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MerchantID, transactionRequest.TerminalID);//"480061115979";
  4966. cmnGrp.RefNum = GetReferenceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  4967. //"480061115979";
  4968. /* A number assigned by the merchant to uniquely reference a transaction order sequence. */
  4969. cmnGrp.OrderNum = cmnGrp.RefNum; //"162091864975";
  4970. /* An ID assigned by First Data, for the Third Party Processor or
  4971. * Software Vendor that generated the transaction. */
  4972. cmnGrp.TPPID = transactionRequest.TppId;
  4973. /* A unique ID assigned to a terminal. */
  4974. cmnGrp.TermID = transactionRequest.TerminalId;
  4975. //get terminal id from transaction request
  4976. /* A unique ID assigned by First Data, to identify the Merchant. */
  4977. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  4978. cmnGrp.GroupID = transactionRequest.GroupId;
  4979. //Group ID value will be assigned by First Data.
  4980. //get terminal id from transaction request
  4981. cmnGrp.POSEntryMode = PaymentAPIResources.EcomPosEntryMode;
  4982. cmnGrp.POSCondCode = POSCondCodeType.Item59;
  4983. cmnGrp.POSCondCodeSpecified = true;
  4984. cmnGrp.TermCatCode = TermCatCodeType.Item00;
  4985. cmnGrp.TermCatCodeSpecified = true;
  4986. cmnGrp.TermEntryCapablt = TermEntryCapabltType.Item10;
  4987. cmnGrp.TermEntryCapabltSpecified = true;
  4988. cmnGrp.TermLocInd = TermLocIndType.Item1;
  4989. cmnGrp.TermLocIndSpecified = true;
  4990. cmnGrp.CardCaptCap = CardCaptCapType.Item0;
  4991. cmnGrp.CardCaptCapSpecified = true;
  4992. EcommGrp ecomgrp = new EcommGrp();
  4993. ecomgrp.EcommTxnInd = EcommTxnIndType.Item03;
  4994. ecomgrp.EcommTxnIndSpecified = true;
  4995. if (!string.Equals(cmnGrp.TxnType.ToString(), Authorization, StringComparison.CurrentCultureIgnoreCase))
  4996. ecomgrp.EcommURL = PaymentAPIResources.EcomUrl;
  4997. _creditReq.EcommGrp = ecomgrp;
  4998. /* The amount of the transaction. This may be an authorization amount,
  4999. * adjustment amount or a reversal based on the type of transaction.
  5000. * It is inclusive of all additional amounts.
  5001. * It is submitted in the currency represented by the Transaction Currency field.
  5002. * The field is overwritten in the response for a partial authorization. */
  5003. double num = Convert.ToDouble(transactionRequest.TransactionAmount);
  5004. string amt = num.ToString("0.00").Replace(".", string.Empty);
  5005. cmnGrp.TxnAmt = Convert.ToString(amt);
  5006. cmnGrp.TxnAmt = cmnGrp.TxnAmt.PadLeft(12, '0');
  5007. cmnGrp.TxnCrncy = PaymentAPIResources.Cur_USA;
  5008. /* An indicator that describes the location of the terminal. */
  5009. /* Indicates Group ID. */
  5010. _creditReq.CommonGrp = cmnGrp;
  5011. #endregion
  5012. CardGrp cardGrp = new CardGrp();
  5013. cardGrp.CardType = transactionRequest.CardType;
  5014. cardGrp.CardTypeSpecified = true;
  5015. cardGrp.CardExpiryDate = transactionRequest.ExpiryDate;
  5016. TAGrp taGrp = new TAGrp();
  5017. taGrp.SctyLvl = SctyLvlType.Tknizatn;
  5018. taGrp.SctyLvlSpecified = true;
  5019. if (!string.IsNullOrEmpty(transactionRequest.RCCIToken))
  5020. taGrp.Tkn = transactionRequest.RCCIToken.Decrypt();
  5021. else
  5022. {
  5023. cardGrp.AcctNum = transactionRequest.CardNumber;
  5024. cardGrp.CCVInd = CCVIndType.Prvded;
  5025. cardGrp.CCVIndSpecified = true;
  5026. cardGrp.CCVData = transactionRequest.CardCvv;
  5027. }
  5028. taGrp.TknType = transactionRequest.TokenType;
  5029. _creditReq.TAGrp = taGrp;
  5030. _creditReq.CardGrp = cardGrp;
  5031. #region Additional Amount Group
  5032. AddtlAmtGrp addAmtGrp = new AddtlAmtGrp();
  5033. addAmtGrp.PartAuthrztnApprvlCapablt = PartAuthrztnApprvlCapabltType.Item1;
  5034. addAmtGrp.PartAuthrztnApprvlCapabltSpecified = true;
  5035. AddtlAmtGrp[] addAmtGrpArr = new AddtlAmtGrp[1];
  5036. addAmtGrpArr[0] = addAmtGrp;
  5037. _creditReq.AddtlAmtGrp = addAmtGrpArr;
  5038. #endregion
  5039. // Only for Visa Card
  5040. #region Visa Group
  5041. if (string.Equals(cardGrp.CardType.ToString(), Visa, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase))
  5042. {
  5043. VisaGrp visaGrp = new VisaGrp();
  5044. visaGrp.VisaBID = PaymentAPIResources.VisaBID;
  5045. visaGrp.VisaAUAR = PaymentAPIResources.VisaAUAR;
  5046. if (!string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  5047. {
  5048. visaGrp.ACI = ACIType.Y;
  5049. visaGrp.ACISpecified = true;
  5050. visaGrp.TaxAmtCapablt = TaxAmtCapabltType.Item1;
  5051. visaGrp.TaxAmtCapabltSpecified = true;
  5052. }
  5053. else
  5054. {
  5055. visaGrp.ACI = ACIType.T;
  5056. visaGrp.ACISpecified = true;
  5057. }
  5058. _creditReq.Item = visaGrp;
  5059. }
  5060. #endregion
  5061. #region AmexGrp Group
  5062. if (string.Equals(cardGrp.CardType.ToString(), Amex, StringComparison.OrdinalIgnoreCase) && string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  5063. {
  5064. AmexGrp amexgrp = new AmexGrp();
  5065. // amexgrp.AmExPOSData ="";
  5066. if (mtdTransaction != null) amexgrp.AmExTranID = mtdTransaction.GatewayTxnId;
  5067. _creditReq.Item = amexgrp;
  5068. }
  5069. #endregion
  5070. #region Discover Group
  5071. if ((string.Equals(cardGrp.CardType.ToString(), Diners, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), Discover, StringComparison.OrdinalIgnoreCase) || string.Equals(cardGrp.CardType.ToString(), "JCB", StringComparison.OrdinalIgnoreCase)) && string.Equals(cmnGrp.TxnType.ToString(), "completion", StringComparison.OrdinalIgnoreCase))
  5072. {
  5073. DSGrp dsGrp = new DSGrp();
  5074. if (mtdTransaction != null) dsGrp.DiscNRID = mtdTransaction.GatewayTxnId;
  5075. _creditReq.Item = dsGrp;
  5076. }
  5077. #endregion
  5078. #region Customer info Group
  5079. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress) || !string.IsNullOrEmpty(transactionRequest.ZipCode))
  5080. {
  5081. if (!string.Equals(cmnGrp.TxnType.ToString(), Refund, StringComparison.OrdinalIgnoreCase) && !string.Equals(cmnGrp.TxnType.ToString(), Completion, StringComparison.OrdinalIgnoreCase))
  5082. {
  5083. CustInfoGrp custinfo = new CustInfoGrp();
  5084. if (!string.IsNullOrEmpty(transactionRequest.StreetAddress))
  5085. {
  5086. custinfo.AVSBillingAddr = transactionRequest.StreetAddress;
  5087. }
  5088. if (!string.IsNullOrEmpty(transactionRequest.ZipCode))
  5089. {
  5090. custinfo.AVSBillingPostalCode = transactionRequest.ZipCode;
  5091. }
  5092. _creditReq.CustInfoGrp = custinfo;
  5093. }
  5094. }
  5095. #endregion
  5096. /* Add the data populated object to GMF message variant object */
  5097. _gmfMsgVar.Item = _creditReq;
  5098. transactionRequest.Stan = cmnGrp.STAN;
  5099. transactionRequest.TransRefNo = cmnGrp.RefNum;
  5100. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  5101. return _creditReq;
  5102. }
  5103. }
  5104. catch (Exception ex)
  5105. {
  5106. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5107. }
  5108. return null;
  5109. }
  5110. /// <summary>
  5111. /// Purpose : Generate Client Ref Number in the format STAN|TPPID, right justified and left padded with "0"
  5112. /// Function Name : GetClientRef
  5113. /// Created By : Umesh
  5114. /// Created On : 03/23/2015
  5115. /// Modificatios Made : ****************************
  5116. /// Modidified On : 04/02/2015 "MM/DD/YYYY"
  5117. /// </summary>
  5118. /// <returns></returns>
  5119. public static string GetClientRef(string projectId)
  5120. {
  5121. int transactionId = new Random(Guid.NewGuid().GetHashCode()).Next(10000, 99999);
  5122. string clientRef = transactionId + "V" + "003000";
  5123. clientRef = "00" + clientRef;
  5124. return clientRef;
  5125. }
  5126. /// <summary>
  5127. /// Purpose : The method will convert the GMF transaction object into an XML string
  5128. /// Function Name : GetXmlData
  5129. /// Created By : Umesh
  5130. /// Created On : 03/24/2015
  5131. /// Modificatios Made : ****************************
  5132. /// Modidified On : 04/02/2015 "MM/DD/YYYY"
  5133. /// </summary>
  5134. /// <returns></returns>
  5135. public String GetXmlData()
  5136. {
  5137. try
  5138. {
  5139. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " + MethodBase.GetCurrentMethod().Name + ";");
  5140. _logMessage.Append(String.Format(CultureInfo.InvariantCulture, " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5141. string xmlString;
  5142. MemoryStream memoryStream;
  5143. using (memoryStream = new MemoryStream())
  5144. {
  5145. XmlSerializer xs = new XmlSerializer(_gmfMsgVar.GetType());
  5146. XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
  5147. XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
  5148. ns.Add("", "com/firstdata/Merchant/gmfV4.02");
  5149. xs.Serialize(xmlTextWriter, _gmfMsgVar, ns);
  5150. memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
  5151. var encoding = new UTF8Encoding();
  5152. xmlString = encoding.GetString(memoryStream.ToArray());
  5153. memoryStream.Dispose();
  5154. xmlString = xmlString.Substring(1, xmlString.Length - 1);
  5155. }
  5156. return xmlString;
  5157. }
  5158. catch (Exception ex)
  5159. {
  5160. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5161. }
  5162. return null;
  5163. }
  5164. /// <summary>
  5165. /// Purpose : datawire entities
  5166. /// Function Name : DatawireEntities
  5167. /// Created By : Madhuri Tanwar
  5168. /// Created On : 29/March/2016
  5169. /// Modificatios Made : ****************************
  5170. /// Modidified On : "MM/DD/YYYY"
  5171. private DatawireEntities DataWireEntities
  5172. {
  5173. get { return _objMessageProcessor.ObjDatawireEntities; }
  5174. set
  5175. {
  5176. _objMessageProcessor.ObjDatawireEntities = value;
  5177. }
  5178. }
  5179. /// <summary>
  5180. /// Purpose : Sending request to register the terminal with datawire
  5181. /// Function Name : SendRegistrationRequest
  5182. /// Created By : Salil Gupta
  5183. /// Created On : 03/25/2015
  5184. /// Modificatios Made : ****************************
  5185. /// Modidified On : 04/02/2015 "MM/DD/YYYY"
  5186. /// </summary>
  5187. /// <param name="clientRef"></param>
  5188. /// <param name="fdMerchantobj"></param>
  5189. /// <param name="tId"></param>
  5190. /// <returns></returns>
  5191. public DatawireResponse SendRegistrationRequest(fDMerchantDto fdMerchantobj, string tId)
  5192. {
  5193. DatawireResponse datawireResponse = new DatawireResponse();
  5194. try
  5195. {
  5196. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5197. MethodBase.GetCurrentMethod().Name + ";");
  5198. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5199. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5200. ResponseType res;
  5201. ServicePointManager.Expect100Continue = true;
  5202. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  5203. ServiceURL.SrsServiceUrl = WebConfigurationManager.AppSettings["SrsURL"];
  5204. using (srsService client = new srsService())
  5205. {
  5206. MTData.WebAPI.schema.ReqClientIDType reqClientIdType = new MTData.WebAPI.schema.ReqClientIDType();
  5207. reqClientIdType.App = fdMerchantobj.App;
  5208. reqClientIdType.DID = "";
  5209. reqClientIdType.Auth = fdMerchantobj.GroupId + "" + fdMerchantobj.FDMerchantID + "|" + tId;
  5210. reqClientIdType.ClientRef = GetClientRef(fdMerchantobj.ProjectId);
  5211. RegistrationType registrationType = new RegistrationType();
  5212. registrationType.ServiceID = Convert.ToString(fdMerchantobj.ServiceId);
  5213. MTData.WebAPI.schema.RequestType requestType = new MTData.WebAPI.schema.RequestType();
  5214. requestType.ReqClientID = reqClientIdType;
  5215. requestType.Item = registrationType;
  5216. client.UserAgent = WebConfigurationManager.AppSettings["UserAgent"];// "Android Taxi v1.0";
  5217. res = client.SrsOperation(requestType);
  5218. if (res.Status.StatusCode.ToString() != "OK")
  5219. {
  5220. datawireResponse.Status = res.Status.StatusCode.ToString();
  5221. datawireResponse.Value = res.Status.Value;
  5222. datawireResponse.ClientRef = res.RespClientID.ClientRef;
  5223. datawireResponse.Did = res.RespClientID.DID;
  5224. datawireResponse.Version = res.Version;
  5225. }
  5226. }
  5227. if (res.Status.StatusCode.ToString() == "OK")
  5228. {
  5229. ResponseType activeResponse = SendActivationRequest(res.RespClientID.DID, fdMerchantobj, tId);
  5230. if (activeResponse.Status.StatusCode.ToString() == "OK")
  5231. {
  5232. try
  5233. {
  5234. datawireResponse.Status = res.Status.StatusCode.ToString();
  5235. datawireResponse.Value = res.Status.Value;
  5236. datawireResponse.ClientRef = res.RespClientID.ClientRef;
  5237. datawireResponse.Did = res.RespClientID.DID;
  5238. datawireResponse.Version = res.Version;
  5239. return datawireResponse;
  5240. }
  5241. catch (Exception ex)
  5242. {
  5243. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5244. }
  5245. }
  5246. }
  5247. else if (res.Status.StatusCode == StatusCodeType.Retry ||
  5248. res.Status.StatusCode == StatusCodeType.InternalError ||
  5249. res.Status.StatusCode == StatusCodeType.OtherError)
  5250. {
  5251. while (_count < 3)
  5252. {
  5253. Thread.Sleep(3000);
  5254. _count++;
  5255. SendRegistrationRequest(fdMerchantobj, tId);
  5256. }
  5257. }
  5258. return datawireResponse;
  5259. }
  5260. catch (Exception ex)
  5261. {
  5262. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5263. }
  5264. return null;
  5265. }
  5266. /// <summary>
  5267. /// Purpose : Sending request to register the terminal with datawire
  5268. /// Function Name : SendActivationRequest
  5269. /// Created By : Salil Gupta
  5270. /// Created On : 03/25/2015
  5271. /// Modificatios Made : ****************************
  5272. /// Modidified On : 04/02/2015 "MM/DD/YYYY"
  5273. /// </summary>
  5274. /// <param name="clientRef"></param>
  5275. /// <param name="dId"></param>
  5276. /// <param name="fdMerchantobj"></param>
  5277. /// <param name="tId"></param>
  5278. /// <returns></returns>
  5279. private ResponseType SendActivationRequest(string dId, fDMerchantDto fdMerchantobj, string tId)
  5280. {
  5281. try
  5282. {
  5283. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5284. MethodBase.GetCurrentMethod().Name + ";");
  5285. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5286. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5287. ResponseType response;
  5288. ServicePointManager.Expect100Continue = true;
  5289. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  5290. ServiceURL.SrsServiceUrl = WebConfigurationManager.AppSettings["SrsURL"];
  5291. using (srsService client = new srsService())
  5292. {
  5293. MTData.WebAPI.schema.ReqClientIDType reqClientIdType = new MTData.WebAPI.schema.ReqClientIDType();
  5294. reqClientIdType.App = fdMerchantobj.App; //"RAPIDCONNECTSRS";
  5295. reqClientIdType.DID = dId;
  5296. reqClientIdType.Auth = fdMerchantobj.GroupId + "" + fdMerchantobj.FDMerchantID + "|" + tId;
  5297. reqClientIdType.ClientRef = GetClientRef(fdMerchantobj.ProjectId);
  5298. ActivationType activationType = new ActivationType();
  5299. activationType.ServiceID = Convert.ToString(fdMerchantobj.ServiceId);
  5300. MTData.WebAPI.schema.RequestType requestType = new MTData.WebAPI.schema.RequestType();
  5301. requestType.ReqClientID = reqClientIdType;
  5302. requestType.Item = activationType;
  5303. client.UserAgent = WebConfigurationManager.AppSettings["UserAgent"];
  5304. response = client.SrsOperation(requestType);
  5305. if (response.Status.StatusCode.ToString() == "OK")
  5306. {
  5307. response.RespClientID.DID = reqClientIdType.DID;
  5308. response.RespClientID.ClientRef = reqClientIdType.ClientRef;
  5309. }
  5310. }
  5311. return response;
  5312. }
  5313. catch (Exception ex)
  5314. {
  5315. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5316. }
  5317. return null;
  5318. }
  5319. /// <summary>
  5320. /// Purpose : registration for canada
  5321. /// Function Name : CanadaSendRegistrationRequest
  5322. /// Created By : Madhuri Tanwar
  5323. /// Created On : 29/March/2016
  5324. /// Modificatios Made : ****************************
  5325. /// Modidified On : "MM/DD/YYYY"
  5326. public string SendRegistrationRequestCN(fDMerchantDto fdMerchantobj, string tId, int merchantId)
  5327. {
  5328. string xmlresponseAct = string.Empty;
  5329. string registerResponse = string.Empty;
  5330. string xmlResponse = string.Empty;
  5331. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5332. MethodBase.GetCurrentMethod().Name + ";");
  5333. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5334. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5335. try
  5336. {
  5337. var mid = fdMerchantobj.FDMerchantID;
  5338. var tid = tId;
  5339. string clientReferId = CnTransactionMessage.GetCanadaClientRef();
  5340. DataWireEntities = new DatawireEntities
  5341. {
  5342. AppID = fdMerchantobj.App,
  5343. MID = mid,
  5344. TID = tid,
  5345. ServiceId = Convert.ToString(fdMerchantobj.ServiceId),
  5346. ClientRefId = clientReferId,
  5347. AuthID = fdMerchantobj.FDMerchantID + "|" + tId,
  5348. TransactionTime = DateTime.Now
  5349. };
  5350. double transTime;
  5351. xmlResponse = SendHttpRequest(DataWireRequestType.Registration, out transTime);
  5352. #region reg response
  5353. string returnCode = CommonFunctions.GetReturnCode(xmlResponse);
  5354. if (!string.IsNullOrEmpty(returnCode) && !returnCode.Equals(MessageTypeDW.StatusSuccess))
  5355. {
  5356. ErrorLogging.LogDatawireExceptions(returnCode);
  5357. }
  5358. string status = CommonFunctions.GetStatus(xmlResponse);
  5359. if (!string.IsNullOrEmpty(status))
  5360. {
  5361. ErrorLogging.LogDatawireExceptions(status);
  5362. if (status.ToLower().Equals(MessageTypeDW.accessdenied.ToString()))
  5363. {
  5364. xmlResponse = MessageTypeDW.AccessDenied.ToString();
  5365. return xmlResponse;
  5366. }
  5367. if (status.ToLower().Equals(MessageTypeDW.authenticationerror.ToString()))
  5368. {
  5369. xmlResponse = MessageTypeDW.AuthenticationError.ToString();
  5370. return xmlResponse;
  5371. }
  5372. if (status.ToLower().Equals(MessageTypeDW.retry))
  5373. {
  5374. retryCount += 1;
  5375. if (retryCount <= 3)
  5376. SendRegistrationRequestCN(fdMerchantobj, tId, merchantId);
  5377. else
  5378. {
  5379. xmlResponse = MessageTypeDW.TransactionCancel.ToString();
  5380. return xmlResponse;
  5381. }
  5382. }
  5383. IEnumerable<string> serviceDiscoveryUrls = null;
  5384. string did1 = String.Empty;
  5385. if (status.ToLower().Equals(MessageTypeDW.ok.ToString()))
  5386. {
  5387. did1 = CommonFunctions.GetDid(xmlResponse);
  5388. serviceDiscoveryUrls = CommonFunctions.GetUrls(xmlResponse);
  5389. DataWireEntities.DiscoveryUrls = new Collection<string>();
  5390. DataWireEntities.DID = did1;
  5391. foreach (string urls in serviceDiscoveryUrls)
  5392. {
  5393. DataWireEntities.DiscoveryUrls.Add(urls);
  5394. }
  5395. xmlresponseAct = SendActivationRequest(xmlResponse);
  5396. }
  5397. #endregion
  5398. string statusAct = CommonFunctions.GetStatus(xmlresponseAct);
  5399. if (!string.IsNullOrEmpty(statusAct))
  5400. {
  5401. ErrorLogging.LogDatawireExceptions(statusAct);
  5402. if (statusAct.ToLower().Equals(MessageTypeDW.accessdenied.ToString()))
  5403. {
  5404. xmlresponseAct = MessageTypeDW.AccessDenied.ToString();
  5405. return xmlresponseAct;
  5406. }
  5407. if (statusAct.ToLower().Equals(MessageTypeDW.authenticationerror.ToString()))
  5408. {
  5409. xmlresponseAct = MessageTypeDW.AuthenticationError.ToString();
  5410. return xmlresponseAct;
  5411. }
  5412. if (statusAct.ToLower().Equals(MessageTypeDW.notfound.ToString()))
  5413. {
  5414. xmlresponseAct = MessageTypeDW.NoTicketProvisioned.ToString();
  5415. return xmlresponseAct;
  5416. }
  5417. if (statusAct.ToLower().Equals(MessageTypeDW.ok.ToString()))
  5418. {
  5419. ServiceDiscoveryParametersDto discoveryParemeters = new ServiceDiscoveryParametersDto { DiscoveryUrls = serviceDiscoveryUrls.ToList(), DID = did1, XmlResponse = xmlResponse, MerchantId = merchantId, TID = tid };
  5420. _terminalService.SaveServiceDiscoveryUrls(discoveryParemeters);
  5421. string DiscovercyResponse = ServiceDiscovery();
  5422. }
  5423. return xmlResponse;
  5424. }
  5425. }
  5426. return xmlResponse;
  5427. }
  5428. catch (Exception ex)
  5429. {
  5430. throw;
  5431. }
  5432. return xmlResponse;
  5433. }
  5434. /// <summary>
  5435. /// Purpose : Activation for canada
  5436. /// Function Name : SendActivationRequest
  5437. /// Created By : Madhuri Tanwar
  5438. /// Created On : 29/March/2016
  5439. /// Modificatios Made : ****************************
  5440. /// Modidified On : "MM/DD/YYYY"
  5441. public string SendActivationRequest(string xmlRegResponse)
  5442. {
  5443. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5444. MethodBase.GetCurrentMethod().Name + ";");
  5445. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5446. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5447. string xmlResponse = null;
  5448. try
  5449. {
  5450. double transTime = 0;
  5451. _logMessage.AppendLine("send datwire activation request.");
  5452. xmlResponse = SendHttpRequest(DataWireRequestType.Activation, out transTime);
  5453. }
  5454. catch (Exception ex)
  5455. {
  5456. throw;
  5457. }
  5458. return xmlResponse;
  5459. }
  5460. /// <summary>
  5461. /// Purpose : service discovery
  5462. /// Function Name : ServiceDiscovery
  5463. /// Created By : Madhuri Tanwar
  5464. /// Created On : 01/april/2016
  5465. /// Modificatios Made : ****************************
  5466. /// Modidified On : "MM/DD/YYYY"
  5467. public string ServiceDiscovery()
  5468. {
  5469. string xmlResponse = string.Empty;
  5470. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " + MethodBase.GetCurrentMethod().Name + ";");
  5471. _logMessage.Append(String.Format(CultureInfo.InvariantCulture, " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5472. try
  5473. {
  5474. var datawireDetails = _terminalService.GetRandomMerchantDetail();
  5475. var fDmerchantDetail = _terminalService.GetFDMerchant(Convert.ToInt32(datawireDetails.MerchantId));
  5476. List<string> discoveryUrls = _terminalService.GetServiceDiscoveryUrls();
  5477. if (discoveryUrls != null && discoveryUrls.Count > 0)
  5478. {
  5479. for (int retry = 0; retry <= 2; retry++)
  5480. {
  5481. foreach (string url in discoveryUrls)
  5482. {
  5483. xmlResponse = SendServiceDiscoveryRequest(url + "/" + Global.ServiceID, fDmerchantDetail);
  5484. if (!string.IsNullOrEmpty(xmlResponse))
  5485. {
  5486. #region Response handling
  5487. GetServiceUrlData(xmlResponse, fDmerchantDetail, datawireDetails);
  5488. var sortedServiceProviderUrls =
  5489. DataWireEntities.ServiceProviderUrls.OrderBy(o => o.TransactionTime).ToList();
  5490. var sortedDatawireServiceUrls =
  5491. new Collection<DatawireServiceUrls>(sortedServiceProviderUrls);
  5492. if (sortedDatawireServiceUrls.Count > 0)
  5493. {
  5494. DataWireEntities.AssignServiceUrl(sortedDatawireServiceUrls);
  5495. DataWireEntities.ActiveUrl = DataWireEntities.ServiceProviderUrls[0].Url;
  5496. DataWireEntities.MaxNumberOfTransaction =
  5497. DataWireEntities.ServiceProviderUrls[0].MaximumTransactionInPackage;
  5498. DataWireEntities.TransactionCount = 0;
  5499. DataWireEntities.TransactionTime = DateTime.Now;
  5500. var serviceProviderUrlDto = AssignDatawireEntitiesToServiceProvider(DataWireEntities.ServiceProviderUrls, DataWireEntities.ActiveUrl);
  5501. Global.UrlList = _terminalService.SaveServiceProviderUrls(serviceProviderUrlDto);
  5502. break;
  5503. }
  5504. #endregion
  5505. }
  5506. }
  5507. if (!string.IsNullOrEmpty(xmlResponse))
  5508. break;
  5509. }
  5510. }
  5511. }
  5512. catch (Exception ex)
  5513. {
  5514. throw;
  5515. }
  5516. return xmlResponse;
  5517. }
  5518. /// <summary>
  5519. /// Purpose : sending ping request
  5520. /// Function Name : SendPingRequest
  5521. /// Created By : Madhuri Tanwar
  5522. /// Created On : 01/april/2016
  5523. /// Modificatios Made : ****************************
  5524. /// Modidified On : "MM/DD/YYYY"
  5525. public string SendPingRequest(string pingUrl, fDMerchantDto fdmerchnt, string tId, string did)
  5526. {
  5527. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5528. MethodBase.GetCurrentMethod().Name + ";");
  5529. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5530. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5531. string url = fdmerchnt.ServiceUrl;
  5532. string xmlResponse = string.Empty;
  5533. try
  5534. {
  5535. var mid = fdmerchnt.FDMerchantID;
  5536. var tid = tId;
  5537. string clientReferId = GetClientRef(fdmerchnt.ProjectId);
  5538. _logMessage.AppendLine("set entities paramerters .");
  5539. DataWireEntities = new DatawireEntities
  5540. {
  5541. AppID = fdmerchnt.App,
  5542. MID = mid,
  5543. TID = tid,
  5544. ServiceId = Convert.ToString(fdmerchnt.ServiceId),
  5545. ClientRefId = clientReferId,
  5546. AuthID = fdmerchnt.FDMerchantID + "|" + tId,
  5547. DID = did,
  5548. TransactionTime = DateTime.Now
  5549. };
  5550. double transTime = 0;
  5551. _logMessage.AppendLine("send ping request.");
  5552. xmlResponse = SendHttpRequest(DataWireRequestType.Ping, out transTime, pingUrl: url);
  5553. }
  5554. catch (Exception ex)
  5555. {
  5556. throw;
  5557. }
  5558. return xmlResponse;
  5559. }
  5560. /// <summary>
  5561. /// Purpose : sending service discovery request
  5562. /// Function Name : SendServiceDiscoveryRequest
  5563. /// Created By : Madhuri Tanwar
  5564. /// Created On : 01/april/2016
  5565. /// Modificatios Made : ****************************
  5566. /// Modidified On : "MM/DD/YYYY"
  5567. private string SendServiceDiscoveryRequest(string requestUrl, fDMerchantDto fdmerchnt)
  5568. {
  5569. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5570. MethodBase.GetCurrentMethod().Name + ";");
  5571. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5572. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5573. string xmlResponse = string.Empty;
  5574. try
  5575. {
  5576. _logMessage.AppendLine("service registration request process start.");
  5577. var objWebrequest = (HttpWebRequest)WebRequest.Create(requestUrl);
  5578. objWebrequest.UserAgent = Global.UserAgent;
  5579. objWebrequest.Method = "GET";
  5580. objWebrequest.Headers.Add(HttpRequestHeader.CacheControl, "no-cache");
  5581. objWebrequest.KeepAlive = true;
  5582. objWebrequest.Timeout = 10000;
  5583. _logMessage.AppendLine("service registration response process start.");
  5584. var response = (HttpWebResponse)objWebrequest.GetResponse();
  5585. var receiveStream = response.GetResponseStream();
  5586. if (receiveStream != null)
  5587. {
  5588. var readStream = new StreamReader(receiveStream, Encoding.UTF8);
  5589. xmlResponse = readStream.ReadToEnd();
  5590. response.Close();
  5591. readStream.Close();
  5592. }
  5593. }
  5594. catch (Exception ex)
  5595. {
  5596. return null;
  5597. }
  5598. return xmlResponse;
  5599. }
  5600. /// <summary>
  5601. /// Purpose : Send request
  5602. /// Function Name : SendHttpRequest
  5603. /// Created By : Madhuri Tanwar
  5604. /// Created On : 29/March/2016
  5605. /// Modificatios Made : ****************************
  5606. /// Modidified On : "MM/DD/YYYY"
  5607. private string SendHttpRequest(DataWireRequestType requestType, out double transTime, int timeOut = 10000, string sequenceNumber = "", string pingUrl = "", string payloadData = "")
  5608. {
  5609. transTime = 0;
  5610. try
  5611. {
  5612. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5613. MethodBase.GetCurrentMethod().Name + ";");
  5614. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5615. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5616. HttpWebRequest objWebrequest = null;
  5617. byte[] buf = null;
  5618. string xmlResponse = string.Empty;
  5619. switch (requestType)
  5620. {
  5621. case DataWireRequestType.Registration:
  5622. {
  5623. _logMessage.AppendLine("merchant registration request process start.");
  5624. string xmlRequest = CommonFunctions.GenerateDataWireXml((int)DataWireRequestType.Registration,
  5625. DataWireEntities);
  5626. buf = Encoding.UTF8.GetBytes(xmlRequest);
  5627. objWebrequest = (HttpWebRequest)WebRequest.Create(WebConfigurationManager.AppSettings["RegistrationServerUrl"]);
  5628. break;
  5629. }
  5630. case DataWireRequestType.Activation:
  5631. {
  5632. _logMessage.AppendLine("merchant Activation request process start.");
  5633. var xmlString = CommonFunctions.GenerateDataWireXml((int)DataWireRequestType.Activation,
  5634. DataWireEntities);
  5635. buf = Encoding.UTF8.GetBytes(xmlString);
  5636. objWebrequest = (HttpWebRequest)WebRequest.Create(WebConfigurationManager.AppSettings["RegistrationServerUrl"]);
  5637. break;
  5638. }
  5639. case DataWireRequestType.Ping:
  5640. {
  5641. #region Create request
  5642. _logMessage.AppendLine("merchant ping request process start.");
  5643. string xmlRequest = CommonFunctions.GenerateDataWireXml((int)DataWireRequestType.Ping,
  5644. DataWireEntities);
  5645. buf = Encoding.UTF8.GetBytes(xmlRequest);
  5646. objWebrequest = (HttpWebRequest)WebRequest.Create(pingUrl);
  5647. #endregion
  5648. break;
  5649. }
  5650. }
  5651. _logMessage.AppendLine(" request process start.");
  5652. if (objWebrequest != null)
  5653. {
  5654. objWebrequest.UserAgent = "vxnapi_xml_3_2_0_19";
  5655. objWebrequest.Method = "POST";
  5656. objWebrequest.ContentLength = buf.Length;
  5657. objWebrequest.KeepAlive = true;
  5658. objWebrequest.Headers.Add(HttpRequestHeader.CacheControl, "no-cache");
  5659. objWebrequest.ContentType = "text/xml";
  5660. objWebrequest.Timeout = timeOut;
  5661. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
  5662. | SecurityProtocolType.Tls11
  5663. | SecurityProtocolType.Tls12
  5664. | SecurityProtocolType.Ssl3;
  5665. ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  5666. using (var stream = objWebrequest.GetRequestStream())
  5667. {
  5668. stream.Write(buf, 0, buf.Length);
  5669. }
  5670. _logMessage.AppendLine("response process start.");
  5671. DateTime beforeRequest = DateTime.Now;
  5672. var response = (HttpWebResponse)objWebrequest.GetResponse();
  5673. DateTime afterRequest = DateTime.Now;
  5674. TimeSpan timeSpan = afterRequest - beforeRequest;
  5675. transTime = (double)timeSpan.TotalMilliseconds;
  5676. var receiveStream = response.GetResponseStream();
  5677. if (receiveStream != null)
  5678. {
  5679. var readStream = new StreamReader(receiveStream, Encoding.UTF8);
  5680. xmlResponse = readStream.ReadToEnd();
  5681. response.Close();
  5682. readStream.Close();
  5683. }
  5684. }
  5685. return xmlResponse;
  5686. }
  5687. catch { return null; }
  5688. }
  5689. /// <summary>
  5690. /// Purpose : Creating credit card request
  5691. /// Function Name : CreateEmvContactCapkRequest
  5692. /// Created By : Madhuri Tanwar
  5693. /// Created On : 10/20/2015
  5694. /// Modificatios Made : ****************************
  5695. /// Modidified On : "MM/DD/YYYY"
  5696. /// </summary>
  5697. /// <param name="transactionRequest"></param>
  5698. /// <returns></returns>
  5699. private AdminRequestDetails CreateEmvContactUpdateCapkRequest(TransactionRequest transactionRequest)
  5700. {
  5701. try
  5702. {
  5703. if (!transactionRequest.IsNull())
  5704. {
  5705. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5706. MethodBase.GetCurrentMethod().Name + ";");
  5707. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5708. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5709. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  5710. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  5711. {
  5712. mtdTransaction = _terminalService.Completion(
  5713. transactionRequest.RapidConnectAuthId,
  5714. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  5715. if (mtdTransaction.IsNull())
  5716. return null;
  5717. }
  5718. #region Common Group
  5719. CommonGrp cmnGrp = new CommonGrp();
  5720. //cmnGrp.TxnType = TxnTypeType.FileDownload;
  5721. cmnGrp.TxnType = transactionRequest.TransType;
  5722. cmnGrp.TxnTypeSpecified = true;
  5723. /* The local date and time in which the transaction was performed. */
  5724. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  5725. /* The transmission date and time of the transaction (in GMT/UCT). */
  5726. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  5727. /* A number assigned by the merchant to uniquely reference the transaction.
  5728. * This number must be unique within a day per Merchant ID per Terminal ID. */
  5729. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  5730. cmnGrp.TPPID = transactionRequest.TppId;
  5731. /* A unique ID assigned to a terminal. */
  5732. cmnGrp.TermID = transactionRequest.TerminalId;
  5733. //get terminal id from transaction request
  5734. /* A unique ID assigned by First Data, to identify the Merchant. */
  5735. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  5736. cmnGrp.GroupID = transactionRequest.GroupId;
  5737. _adminReq.CommonGrp = cmnGrp;
  5738. #endregion
  5739. #region FileDLGrp Group
  5740. FileDLGrp fileDlgrp = new FileDLGrp();
  5741. fileDlgrp.FileType = EMV2KEY;
  5742. fileDlgrp.FunCode = "R";
  5743. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  5744. {
  5745. XmlDocument xmlDoc = new XmlDocument();
  5746. xmlDoc.LoadXml(mtdTransaction.ResponseXml);
  5747. string xmlString = CommonFunctions.GetXmlAsString(xmlDoc);
  5748. var response = CommonFunctions.GetMCResponse(xmlString);
  5749. xmlDoc.LoadXml(response);
  5750. var currFileCreatDt = xmlDoc.SelectSingleNode("AdminResponse/FileDLGrp/CurrFileCreationDt");
  5751. if (currFileCreatDt != null)
  5752. { fileDlgrp.CurrFileCreationDt = currFileCreatDt.InnerText; }
  5753. var fileSize = xmlDoc.SelectSingleNode("AdminResponse/FileDLGrp/FileSize");
  5754. if (fileSize != null)
  5755. { fileDlgrp.FileSize = fileSize.InnerText; }
  5756. var fileCRC16 = xmlDoc.SelectSingleNode("AdminResponse/FileDLGrp/FileCRC16");
  5757. if (fileCRC16 != null)
  5758. { fileDlgrp.FileCRC16 = fileCRC16.InnerText; }
  5759. }
  5760. else
  5761. {
  5762. fileDlgrp.CurrFileCreationDt = PaymentAPIResources.CurrFileCreationDt;
  5763. fileDlgrp.FileSize = FileSizeValue;
  5764. fileDlgrp.FileCRC16 = FileCRCValue;
  5765. }
  5766. _adminReq.FileDLGrp = fileDlgrp;
  5767. #endregion
  5768. _gmfMsgVar.Item = _adminReq;
  5769. transactionRequest.Stan = cmnGrp.STAN;
  5770. transactionRequest.TransRefNo = cmnGrp.RefNum;
  5771. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  5772. return _adminReq;
  5773. }
  5774. }
  5775. catch (Exception ex)
  5776. {
  5777. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5778. }
  5779. return null;
  5780. }
  5781. /// <summary>
  5782. /// Purpose : Creating credit card request
  5783. /// Function Name : CreateEmvContactCapkRequest
  5784. /// Created By : Madhuri Tanwar
  5785. /// Created On : 10/20/2015
  5786. /// Modificatios Made : ****************************
  5787. /// Modidified On : "MM/DD/YYYY"
  5788. /// </summary>
  5789. /// <param name="transactionRequest"></param>
  5790. /// <returns></returns>
  5791. private AdminRequestDetails CreateEmvContactDownloadCapkRequest(TransactionRequest transactionRequest)
  5792. {
  5793. try
  5794. {
  5795. if (!transactionRequest.IsNull())
  5796. {
  5797. _logMessage.Append("Controller Name:-" + GetType().Name + "; Method Name :- " +
  5798. MethodBase.GetCurrentMethod().Name + ";");
  5799. _logMessage.Append(String.Format(CultureInfo.InvariantCulture,
  5800. " Date:-" + DateTime.Now.ToShortDateString() + "; Time:- " + DateTime.Now.ToShortTimeString()));
  5801. MTDTransactionDto mtdTransaction = new MTDTransactionDto();
  5802. if (!string.IsNullOrEmpty(transactionRequest.RapidConnectAuthId))
  5803. {
  5804. mtdTransaction = _terminalService.Completion(
  5805. transactionRequest.RapidConnectAuthId,
  5806. transactionRequest.SerialNumber, transactionRequest.MtdMerchantId);
  5807. if (mtdTransaction.IsNull())
  5808. return null;
  5809. }
  5810. #region Common Group
  5811. CommonGrp cmnGrp = new CommonGrp();
  5812. cmnGrp.TxnType = transactionRequest.TransType;
  5813. cmnGrp.TxnTypeSpecified = true;
  5814. /* The local date and time in which the transaction was performed. */
  5815. cmnGrp.LocalDateTime = transactionRequest.LocalDateTime;//DateTime.Now.ToString("yyyyMMddHHmmss");
  5816. /* The transmission date and time of the transaction (in GMT/UCT). */
  5817. cmnGrp.TrnmsnDateTime = transactionRequest.TrnmsnDateTime;//DateTime.UtcNow.ToString("yyyyMMddHHmmss");
  5818. cmnGrp.STAN = GetSystemTraceNumber(transactionRequest.MtdMerchantId, transactionRequest.TerminalId);
  5819. cmnGrp.TPPID = transactionRequest.TppId;
  5820. cmnGrp.TermID = transactionRequest.TerminalId;
  5821. /* A unique ID assigned by First Data, to identify the Merchant. */
  5822. cmnGrp.MerchID = transactionRequest.FdMerchantId;
  5823. cmnGrp.GroupID = transactionRequest.GroupId;
  5824. _adminReq.CommonGrp = cmnGrp;
  5825. #endregion
  5826. #region FileDLGrp Group
  5827. FileDLGrp fileDlgrp = new FileDLGrp();
  5828. fileDlgrp.FileType = EMV2KEY;
  5829. fileDlgrp.FunCode = "D";
  5830. if (!string.IsNullOrEmpty(transactionRequest.FbSeq))
  5831. { fileDlgrp.FBSeq = transactionRequest.FbSeq; }
  5832. fileDlgrp.ReqFBMaxSize = ReqFBMaxSizeValue;
  5833. if (!string.IsNullOrEmpty(transactionRequest.ReqFileOff))
  5834. { fileDlgrp.ReqFileOffset = transactionRequest.ReqFileOff; }
  5835. else
  5836. {
  5837. fileDlgrp.FBSeq = PaymentAPIResources.FBSeq;
  5838. fileDlgrp.ReqFBMaxSize = ReqFBMaxSizeValue;
  5839. fileDlgrp.ReqFileOffset = PaymentAPIResources.ReqFileOffset;
  5840. }
  5841. _adminReq.FileDLGrp = fileDlgrp;
  5842. #endregion
  5843. _gmfMsgVar.Item = _adminReq;
  5844. transactionRequest.Stan = cmnGrp.STAN;
  5845. transactionRequest.TransRefNo = cmnGrp.RefNum;
  5846. transactionRequest.TransOrderNo = cmnGrp.OrderNum;
  5847. return _adminReq;
  5848. }
  5849. }
  5850. catch (Exception ex)
  5851. {
  5852. _logger.LogInfoFatel(_logMessage.ToString(), ex);
  5853. }
  5854. return null;
  5855. }
  5856. private void GetServiceUrlData(string xmlResponse, fDMerchantDto fdMerchantDto, DatawireDto datawireDto)
  5857. {
  5858. try
  5859. {
  5860. var xEle = XElement.Parse(xmlResponse);
  5861. var xElementServiceProviders = xEle.Descendants(MessageTypeDW.ServiceProvider.ToString());
  5862. var elements = xElementServiceProviders as IList<XElement> ?? xElementServiceProviders.ToList();
  5863. List<DatawireServiceUrls> serviceUrls = new List<DatawireServiceUrls>();
  5864. for (int retry = 0; retry <= 2; retry++)
  5865. {
  5866. for (var i = 0; i < elements.Count(); i++)
  5867. {
  5868. var element = elements.ElementAt(i).Element(MessageTypeDW.URL.ToString());
  5869. var objServiceUrls = new DatawireServiceUrls();
  5870. if (element != null)
  5871. {
  5872. objServiceUrls.Url = element.Value;
  5873. }
  5874. var urlTransactionTime = SendPingUrlRequest(objServiceUrls.Url, fdMerchantDto, datawireDto);
  5875. objServiceUrls.TransactionTime = urlTransactionTime;
  5876. var xElement = elements.ElementAt(i).Element(MessageTypeDW.MaxTransactionsInPackage.ToString());
  5877. if (xElement != null)
  5878. objServiceUrls.MaximumTransactionInPackage = Convert.ToInt32(xElement.Value, CultureInfo.InvariantCulture);
  5879. if (urlTransactionTime != 0)
  5880. serviceUrls.Add(objServiceUrls);
  5881. }
  5882. if (serviceUrls != null && serviceUrls.Count > 0)
  5883. break;
  5884. }
  5885. foreach (DatawireServiceUrls url in serviceUrls)
  5886. {
  5887. DataWireEntities.ServiceProviderUrls.Add(url);
  5888. }
  5889. }
  5890. catch (Exception ex)
  5891. {
  5892. throw;
  5893. }
  5894. }
  5895. public static String GetMessage(MessageTypeDW search)
  5896. {
  5897. try
  5898. {
  5899. var doc = new XmlDocument();
  5900. doc.Load(ResourceFilePath);
  5901. var xdoc = XDocument.Parse(doc.InnerXml);
  5902. var nodes = doc.SelectNodes("Response/ServiceDiscoveryResponse/ServiceProvider/URL");
  5903. var result = (from c in xdoc.Descendants("item")
  5904. where ((String)c.Attribute("key")).Equals(search.ToString())
  5905. select c.Attribute("value").Value).FirstOrDefault();
  5906. return result;
  5907. }
  5908. catch (Exception ex)
  5909. {
  5910. throw;
  5911. }
  5912. }
  5913. private static string ResourceFilePath
  5914. {
  5915. get
  5916. {
  5917. string strResorcePath = StrAppPath.Remove(StrAppPath.LastIndexOf('\\'));
  5918. strResorcePath += @"\MessagesResource.xml";
  5919. return strResorcePath;
  5920. }
  5921. }
  5922. private long SendPingUrlRequest(string pingUrl, fDMerchantDto fdMerchantDto, DatawireDto datawireDto)
  5923. {
  5924. try
  5925. {
  5926. double transTime;
  5927. DataWireEntities = new DatawireEntities
  5928. {
  5929. AppID = fdMerchantDto.App,
  5930. MID = fdMerchantDto.FDMerchantID,
  5931. TID = datawireDto.RCTerminalId,
  5932. ServiceId = Global.ServiceID,
  5933. ClientRefId = CnTransactionMessage.GetCanadaClientRef(),
  5934. AuthID = fdMerchantDto.FDMerchantID + "|" + datawireDto.RCTerminalId,
  5935. DID = datawireDto.DID,
  5936. TransactionTime = DateTime.Now
  5937. };
  5938. var xmlResponse = SendHttpRequest(DataWireRequestType.Ping, out transTime, pingUrl: pingUrl);
  5939. #region Response hanldling
  5940. if (string.IsNullOrEmpty(xmlResponse))
  5941. {
  5942. return 0;
  5943. }
  5944. var xEle = XElement.Parse(xmlResponse);
  5945. //extract the time of transaction from xml response
  5946. var time = (from p in xEle.Descendants(MessageTypeDW.ServiceCost.ToString())
  5947. let element = p.Element(MessageTypeDW.TransactionTimeMs.ToString())
  5948. where element != null
  5949. select new
  5950. {
  5951. TransactionTimeMs = Convert.ToString(element.Value, CultureInfo.InvariantCulture)
  5952. }).ToList();
  5953. long transactionTime;
  5954. var isLongTransTime = long.TryParse(time[0].TransactionTimeMs, out transactionTime);
  5955. transactionTime = transactionTime + (long)transTime;
  5956. if (isLongTransTime)//for CA1806
  5957. {
  5958. return transactionTime;
  5959. }
  5960. #endregion
  5961. }
  5962. catch (Exception ex)
  5963. {
  5964. return 0;
  5965. }
  5966. return 0;
  5967. }
  5968. public ServiceProviderUrlDto AssignDatawireEntitiesToServiceProvider(Collection<DatawireServiceUrls> datawireService, string activeUrl)
  5969. {
  5970. ServiceProviderUrlDto serviceProviderUrlDto = new ServiceProviderUrlDto();
  5971. List<DatawireServiceUrlDto> datawireUrlDto = new List<DatawireServiceUrlDto>();
  5972. foreach (DatawireServiceUrls datawireUrl in datawireService)
  5973. {
  5974. datawireUrlDto.Add(AssignData(datawireUrl));
  5975. }
  5976. serviceProviderUrlDto.ServiceProviderUrls = datawireUrlDto;
  5977. serviceProviderUrlDto.ActiveUrl = activeUrl;
  5978. return serviceProviderUrlDto;
  5979. }
  5980. public DatawireServiceUrlDto AssignData(DatawireServiceUrls serviceUrls)
  5981. {
  5982. return new DatawireServiceUrlDto { Url = serviceUrls.Url, TransactionTime = serviceUrls.TransactionTime, MaximumTransactionInPackage = serviceUrls.MaximumTransactionInPackage };
  5983. }
  5984. }
  5985. }