protected void Page_Load(object sender, EventArgs e) { int showid = Convert.ToInt32(Request["ShowID"]); ShowID.Value = showid.ToString(); List<UserShows> userShowsList = UserShows.getListUsersForShow(showid); foreach (UserShows us in userShowsList) { //List<OffLineTransactionSummary> offlineList = Transaction.getOfflineSummary(ShowID); Transaction trans = new Transaction(us.Userid, showid); TransactionSummary transSummary = new TransactionSummary(showid, us.Userid); User user = new User(us.Userid); if (trans.EnteredBy == (int)Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY) { String tmp = String.Format("<option value='{2}'> {0:000000} - {1} ({3:0.00})</option>", us.ID, user.Name, user.UserID, transSummary.Total); if (transSummary.Total >= 0) { PaidItemsList += tmp; } else { OutstandingItemsList += tmp; } } } }
internal static void Read(XmlReader reader, IList<TransactionSummary> transactions) { if (reader == null) throw new ArgumentNullException("reader"); if (transactions == null) throw new ArgumentNullException("transactions"); transactions.Clear(); if (reader.IsEmptyElement) { SerializationHelper.SkipNode(reader); } reader.ReadStartElement(TransactionSummaryListSerializer.Transactions); reader.MoveToContent(); while (!reader.EOF) { if (SerializationHelper.IsEndElement(reader, TransactionSummaryListSerializer.Transactions)) { SerializationHelper.SkipNode(reader); break; } if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case TransactionSerializerHelper.Transaction: TransactionSummary transaction = new TransactionSummary(); TransactionSummarySerializer.Read(reader, transaction); transactions.Add(transaction); break; default: SerializationHelper.SkipElement(reader); break; } } else { SerializationHelper.SkipNode(reader); } } }
/// <summary> /// /// </summary> /// <param name="reader"></param> /// <param name="transaction"></param> internal static void Read(XmlReader reader, TransactionSummary transaction, bool preApproval) { if (reader.IsEmptyElement) { XMLParserUtils.SkipNode(reader); return; } if (preApproval == true) { reader.ReadStartElement(TransactionSerializerHelper.PreApproval); } else { reader.ReadStartElement(TransactionSerializerHelper.Transaction); } reader.MoveToContent(); while (!reader.EOF) { if (preApproval == true) { if (XMLParserUtils.IsEndElement(reader, TransactionSerializerHelper.PreApproval)) { XMLParserUtils.SkipNode(reader); break; } } else { if (XMLParserUtils.IsEndElement(reader, TransactionSerializerHelper.Transaction)) { XMLParserUtils.SkipNode(reader); break; } } if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case TransactionSerializerHelper.Code: transaction.Code = reader.ReadElementContentAsString(); break; case TransactionSerializerHelper.Date: transaction.Date = reader.ReadElementContentAsDateTime(); break; case TransactionSerializerHelper.Reference: transaction.Reference = reader.ReadElementContentAsString(); break; case TransactionSerializerHelper.TransactionType: transaction.TransactionType = reader.ReadElementContentAsInt(); break; case TransactionSerializerHelper.TransactionStatus: if (preApproval == true) { transaction.Status = reader.ReadElementContentAsString(); } else { transaction.TransactionStatus = reader.ReadElementContentAsInt(); } break; case TransactionSerializerHelper.GrossAmount: transaction.GrossAmount = reader.ReadElementContentAsDecimal(); break; case TransactionSerializerHelper.DiscountAmount: transaction.DiscountAmount = reader.ReadElementContentAsDecimal(); break; case TransactionSerializerHelper.FeeAmount: transaction.FeeAmount = reader.ReadElementContentAsDecimal(); break; case TransactionSerializerHelper.NetAmount: transaction.NetAmount = reader.ReadElementContentAsDecimal(); break; case TransactionSerializerHelper.ExtraAmount: transaction.ExtraAmount = reader.ReadElementContentAsDecimal(); break; case TransactionSerializerHelper.LastEventDate: transaction.LastEventDate = reader.ReadElementContentAsDateTime(); break; case TransactionSerializerHelper.Name: transaction.Name = reader.ReadElementContentAsString(); break; case TransactionSerializerHelper.Tracker: transaction.Tracker = reader.ReadElementContentAsString(); break; case TransactionSerializerHelper.Charge: transaction.Charge = reader.ReadElementContentAsString(); break; case PaymentMethodSerializer.PaymentMethod: PaymentMethod paymentMethod = new PaymentMethod(); PaymentMethodSerializer.Read(reader, paymentMethod); transaction.PaymentMethod = paymentMethod; break; default: XMLParserUtils.SkipElement(reader); break; } } else { XMLParserUtils.SkipNode(reader); } } }
/// <summary> /// /// </summary> /// <param name="reader"></param> /// <param name="transactions"></param> internal static void Read(XmlReader reader, IList <TransactionSummary> transactions, bool preApproval) { transactions.Clear(); if (reader.IsEmptyElement) { XMLParserUtils.SkipNode(reader); } if (preApproval == true) { reader.ReadStartElement(TransactionSummaryListSerializer.PreApprovals); } else { reader.ReadStartElement(TransactionSummaryListSerializer.Transactions); } reader.MoveToContent(); while (!reader.EOF) { if (preApproval == true) { if (XMLParserUtils.IsEndElement(reader, TransactionSummaryListSerializer.PreApprovals)) { XMLParserUtils.SkipNode(reader); break; } } else { if (XMLParserUtils.IsEndElement(reader, TransactionSummaryListSerializer.Transactions)) { XMLParserUtils.SkipNode(reader); break; } } if (reader.NodeType == XmlNodeType.Element) { TransactionSummary transaction = new TransactionSummary(); switch (reader.Name) { case TransactionSerializerHelper.Transaction: TransactionSummarySerializer.Read(reader, transaction, preApproval); transactions.Add(transaction); break; case TransactionSerializerHelper.PreApproval: TransactionSummarySerializer.Read(reader, transaction, preApproval); transactions.Add(transaction); break; default: XMLParserUtils.SkipElement(reader); break; } } else { XMLParserUtils.SkipNode(reader); } } }
private bool TransactionIsPaid(TransactionSummary transaction) => (transaction?.TransactionStatus == TransactionStatus.Paid || transaction?.TransactionStatus == TransactionStatus.Available);
private T MapResponse <T>(string response, ReportType reportType) { var doc = JsonDoc.Parse(response); if (doc.Has("error")) { var error = doc.Get("error"); var errorType = error.GetValue <string>("errorType"); var errorCode = error.GetValue <string>("errorCode"); var errorMessage = error.GetValue <string>("errorMsg"); // If it's 1205, then it's no data... which is not an error if (errorCode != "1205") { throw new GatewayException(errorMessage, errorCode, errorType); } } Func <string, DateTime?> formatDate = (date) => { if (!string.IsNullOrEmpty(date)) { var pattern = "yyyy-MM-dd"; if (date.Contains(" ")) { pattern += " hh:mm:ss"; } return(DateTime.ParseExact(date, pattern, CultureInfo.InvariantCulture)); } return(null); }; T rvalue = Activator.CreateInstance <T>(); if (reportType.HasFlag(ReportType.FindTransactions)) { Func <JsonDoc, TransactionSummary> hydrateTransactionSummary = (root) => { var summary = new TransactionSummary { MerchantHierarchy = root.GetValue <string>("merchantHierarchy"), MerchantName = root.GetValue <string>("merchantName"), MerchantDbaName = root.GetValue <string>("merchantDbaName"), MerchantNumber = root.GetValue <string>("merchantNumber"), MerchantCategory = root.GetValue <string>("merchantCategory"), DepositDate = formatDate(root.GetValue <string>("transactionDepositDate")), DepositReference = root.GetValue <string>("transactionDepositReference"), DepositType = root.GetValue <string>("transactionDepositType"), ServiceName = root.GetValue <string>("transactionType"), OrderId = root.GetValue <string>("transactionOrderId"), TransactionLocalDate = formatDate(root.GetValue <string>("transactionLocalTime")), TransactionDate = formatDate(root.GetValue <string>("transactionTime")), Amount = root.GetValue <string>("transactionAmount").ToAmount(), Currency = root.GetValue <string>("transactionCurrency"), DepositAmount = root.GetValue <string>("transactionMerchantAmount").ToAmount(), DepositCurrency = root.GetValue <string>("transactionMerchantCurrency"), MerchantId = root.GetValue <string>("transactionMid"), TerminalId = root.GetValue <string>("transactionTid"), BatchSequenceNumber = root.GetValue <string>("transactionBatchReference"), EntryMode = root.GetValue <string>("transactionEntryMode"), AquirerReferenceNumber = root.GetValue <string>("transactionArn"), ReferenceNumber = root.GetValue <string>("transactionReferenceNumber"), CardType = root.GetValue <string>("transactionCardType"), MaskedCardNumber = root.GetValue <string>("transactionCardNo"), AuthCode = root.GetValue <string>("transactionAuthcode"), SchemeReferenceData = root.GetValue <string>("transactionSrd"), AdjustmentAmount = root.GetValue <string>("transactionAdjustAmount").ToAmount(), AdjustmentCurrency = root.GetValue <string>("transactionAdjustCurrency"), AdjustmentReason = root.GetValue <string>("transactionAdjustReason") }; return(summary); }; if (rvalue is IEnumerable <TransactionSummary> ) { var list = rvalue as List <TransactionSummary>; if (doc.Has("merchantTransactionDetails")) { foreach (var transaction in doc.GetEnumerator("merchantTransactionDetails")) { list.Add(hydrateTransactionSummary(transaction)); } } } } else if (reportType.HasFlag(ReportType.FindDepoits)) { Func <JsonDoc, DepositSummary> hydrateDepositSummary = (root) => { var summary = new DepositSummary { MerchantHierarchy = root.GetValue <string>("merchantHierarchy"), MerchantName = root.GetValue <string>("merchantName"), MerchantDbaName = root.GetValue <string>("merchantDba"), MerchantNumber = root.GetValue <string>("merchantNumber"), MerchantCategory = root.GetValue <string>("merchantCategory"), DepositDate = DateTime.Parse(root.GetValue <string>("depositDate")), Reference = root.GetValue <string>("depositReference"), Amount = root.GetValue <string>("depositPaymentAmount").ToAmount(), Currency = root.GetValue <string>("depositPaymentCurrency"), Type = root.GetValue <string>("depositType"), RoutingNumber = root.GetValue <string>("depositRoutingNumber"), AccountNumber = root.GetValue <string>("depositAccountNumber"), Mode = root.GetValue <string>("depositMode"), SummaryModel = root.GetValue <string>("depositSummaryModel"), SalesTotalCount = root.GetValue <int>("salesTotalNo"), SalesTotalAmount = root.GetValue <string>("salesTotalAmount").ToAmount(), SalesTotalCurrency = root.GetValue <string>("salesTotalCurrency"), RefundsTotalCount = root.GetValue <int>("refundsTotalNo"), RefundsTotalAmount = root.GetValue <string>("refundsTotalAmount").ToAmount(), RefundsTotalCurrency = root.GetValue <string>("refundsTotalCurrency"), ChargebackTotalCount = root.GetValue <int>("disputeCbTotalNo"), ChargebackTotalAmount = root.GetValue <string>("disputeCbTotalAmount").ToAmount(), ChargebackTotalCurrency = root.GetValue <string>("disputeCbTotalCurrency"), RepresentmentTotalCount = root.GetValue <int>("disputeRepresentmentTotalNo"), RepresentmentTotalAmount = root.GetValue <string>("disputeRepresentmentTotalAmount").ToAmount(), RepresentmentTotalCurrency = root.GetValue <string>("disputeRepresentmentTotalCurrency"), FeesTotalAmount = root.GetValue <string>("feesTotalAmount").ToAmount(), FeesTotalCurrency = root.GetValue <string>("feesTotalCurrency"), AdjustmentTotalCount = root.GetValue <int>("adjustmentTotalNumber"), AdjustmentTotalAmount = root.GetValue <string>("adjustmentTotalAmount").ToAmount(), AdjustmentTotalCurrency = root.GetValue <string>("adjustmentTotalCurrency") }; return(summary); }; if (rvalue is IEnumerable <DepositSummary> ) { var list = rvalue as List <DepositSummary>; if (doc.Has("merchantDepositDetails")) { foreach (var deposit in doc.GetEnumerator("merchantDepositDetails")) { list.Add(hydrateDepositSummary(deposit)); } } } } else if (reportType.HasFlag(ReportType.FindDisputes)) { Func <JsonDoc, DisputeSummary> hydrateDisputeSummary = (root) => { var summary = new DisputeSummary { MerchantHierarchy = root.GetValue <string>("merchantHierarchy"), MerchantName = root.GetValue <string>("merchantName"), MerchantDbaName = root.GetValue <string>("merchantDba"), MerchantNumber = root.GetValue <string>("merchantNumber"), MerchantCategory = root.GetValue <string>("merchantCategory"), DepositDate = formatDate(root.GetValue <string>("disputeDepositDate")), DepositReference = root.GetValue <string>("disputeDepositReference"), DepositType = root.GetValue <string>("disputeDepositType"), Type = root.GetValue <string>("disputeType"), CaseAmount = root.GetValue <string>("disputeCaseAmount").ToAmount(), CaseCurrency = root.GetValue <string>("disputeCaseCurrency"), CaseStatus = root.GetValue <string>("disputeCaseStatus"), CaseDescription = root.GetValue <string>("disputeCaseDescription"), TransactionOrderId = root.GetValue <string>("disputeTransactionOrderId"), TransactionLocalTime = formatDate(root.GetValue <string>("disputeTransactionLocalTime")), TransactionTime = formatDate(root.GetValue <string>("disputeTransactionTime")), TransactionType = root.GetValue <string>("disputeTransactionType"), TransactionAmount = root.GetValue <string>("disputeTransactionAmount").ToAmount(), TransactionCurrency = root.GetValue <string>("disputeTransactionCurrency"), CaseNumber = root.GetValue <string>("disputeCaseNo"), CaseTime = formatDate(root.GetValue <string>("disputeCaseTime")), CaseId = root.GetValue <string>("disputeCaseId"), CaseIdTime = formatDate(root.GetValue <string>("disputeCaseIdTime")), CaseMerchantId = root.GetValue <string>("disputeCaseMid"), CaseTerminalId = root.GetValue <string>("disputeCaseTid"), TransactionARN = root.GetValue <string>("disputeTransactionARN"), TransactionReferenceNumber = root.GetValue <string>("disputeTransactionReferenceNumber"), TransactionSRD = root.GetValue <string>("disputeTransactionSRD"), TransactionAuthCode = root.GetValue <string>("disputeTransactionAuthcode"), TransactionCardType = root.GetValue <string>("disputeTransactionCardType"), TransactionMaskedCardNumber = root.GetValue <string>("disputeTransactionCardNo"), Reason = root.GetValue <string>("disputeReason"), IssuerComment = root.GetValue <string>("disputeIssuerComment"), IssuerCaseNumber = root.GetValue <string>("disputeIssuerCaseNo"), DisputeAmount = root.GetValue <string>("disputeAmount").ToAmount(), DisputeCurrency = root.GetValue <string>("disputeCurrency"), DisputeCustomerAmount = root.GetValue <string>("disputeCustomerAmount").ToAmount(), DisputeCustomerCurrency = root.GetValue <string>("disputeCustomerCurrency"), RespondByDate = formatDate(root.GetValue <string>("disputeRespondByDate")), CaseOriginalReference = root.GetValue <string>("disputeCaseOriginalReference") }; return(summary); }; if (rvalue is IEnumerable <DisputeSummary> ) { var list = rvalue as List <DisputeSummary>; if (doc.Has("merchantDisputeDetails")) { foreach (var dispute in doc.GetEnumerator("merchantDisputeDetails")) { list.Add(hydrateDisputeSummary(dispute)); } } } } return(rvalue); }