Ejemplo n.º 1
0
        internal static string TransactionTypeToServiceName(HpsTransactionType transactionType)
        {
            switch (transactionType)
            {
            case HpsTransactionType.Authorize: return(ItemChoiceType1.CreditAuth.ToString());

            case HpsTransactionType.Capture: return(ItemChoiceType1.CreditAddToBatch.ToString());

            case HpsTransactionType.Charge: return(ItemChoiceType1.CreditSale.ToString());

            case HpsTransactionType.Refund: return(ItemChoiceType1.CreditReturn.ToString());

            case HpsTransactionType.Reverse: return(ItemChoiceType1.CreditReversal.ToString());

            case HpsTransactionType.Verify: return(ItemChoiceType1.CreditAccountVerify.ToString());

            case HpsTransactionType.List: return(ItemChoiceType1.ReportActivity.ToString());

            case HpsTransactionType.Get: return(ItemChoiceType1.ReportTxnDetail.ToString());

            case HpsTransactionType.Void: return(ItemChoiceType1.CreditVoid.ToString());

            case HpsTransactionType.BatchClose: return(ItemChoiceType1.BatchClose.ToString());

            case HpsTransactionType.SecurityError: return("SecurityError");

            default: return(String.Empty);
            }
        }
        internal HpsReportTransactionSummary[] FromResponse(PosResponseVer10 response, HpsTransactionType? filterBy = null) {
            var reportResponse = (PosReportActivityRspType)response.Transaction.Item;
            
            List<HpsReportTransactionSummary> transactions = new List<HpsReportTransactionSummary>();
            string serviceName = string.Empty;
            if (filterBy.HasValue)
                serviceName = TransactionTypeToServiceName(filterBy.Value);

            foreach (var charge in reportResponse.Details) {
                var trans = new HpsReportTransactionSummary();
                trans.FromResponse(response);

                trans.OriginalTransactionId = charge.OriginalGatewayTxnId;
                trans.MaskedCardNumber = charge.MaskedCardNbr;
                trans.ResponseCode = charge.IssuerRspCode;
                trans.ResponseText = charge.IssuerRspText;
                trans.Amount = charge.Amt;
                trans.SettlementAmount = charge.SettlementAmt;
                trans.TransactionUtcDate = charge.TxnDT;
                trans.TransactionType = ServiceNameToTransactionType(charge.ServiceName);
                if (filterBy.HasValue)
                    trans.TransactionType = filterBy.Value;

                if (charge.GatewayRspCode != 0 || charge.IssuerRspCode != "00") {
                    trans.Exceptions = new HpsChargeExceptions();
                    if (charge.GatewayRspCode != 0)
                        trans.Exceptions.GatewayException = HpsGatewayResponseValidation.GetException(charge.GatewayRspCode, charge.GatewayRspMsg);
                    if (charge.IssuerRspCode != "00")
                        trans.Exceptions.IssuerException = HpsIssuerResponseValidation.GetException(charge.GatewayRspCode, charge.IssuerRspCode, charge.IssuerRspText);
                }
                transactions.Add(trans);
            }

            return transactions.ToArray();
        }
 internal static string TransactionTypeToServiceName(HpsTransactionType transactionType)
 {
     switch (transactionType)
     {
         case HpsTransactionType.Authorize: return ItemChoiceType1.CreditAuth.ToString();
         case HpsTransactionType.Capture: return ItemChoiceType1.CreditAddToBatch.ToString();
         case HpsTransactionType.Charge: return ItemChoiceType1.CreditSale.ToString();
         case HpsTransactionType.Refund: return ItemChoiceType1.CreditReturn.ToString();
         case HpsTransactionType.Reverse: return ItemChoiceType1.CreditReversal.ToString();
         case HpsTransactionType.Verify: return ItemChoiceType1.CreditAccountVerify.ToString();
         case HpsTransactionType.List: return ItemChoiceType1.ReportActivity.ToString();
         case HpsTransactionType.Get: return ItemChoiceType1.ReportTxnDetail.ToString();
         case HpsTransactionType.Void: return ItemChoiceType1.CreditVoid.ToString();
         case HpsTransactionType.BatchClose: return ItemChoiceType1.BatchClose.ToString();
         case HpsTransactionType.SecurityError: return "SecurityError";
         default: return String.Empty;
     }
 }
Ejemplo n.º 4
0
 public CreditListBuilder WithFilterBy(HpsTransactionType filterBy)
 {
     this.filterBy = filterBy;
     return(this);
 }
Ejemplo n.º 5
0
        /// <summary>Gets a of transaction summaries between a set of dates and filtered if specified.</summary>
        /// <param name="utcStart">Start date.</param>
        /// <param name="utcEnd">End date.</param>
        /// <param name="filterBy">Filter the result set.</param>
        /// <returns>The list of transaction summaries.</returns>
        public List<HpsReportTransactionSummary> List(DateTime? utcStart = null, DateTime? utcEnd = null, HpsTransactionType? filterBy = null)
        {
            HpsInputValidation.CheckDateNotFuture(utcStart);
            HpsInputValidation.CheckDateNotFuture(utcEnd);

            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                ItemElementName = ItemChoiceType1.ReportActivity,
                Item = new PosReportActivityReqType
                {
                    DeviceIdSpecified = false
                }
            };

            var item = (PosReportActivityReqType)transaction.Item;
            if (utcStart != null)
            {
                item.RptStartUtcDT = utcStart.Value;
                item.RptStartUtcDTSpecified = true;
            }

            if (utcEnd != null)
            {
                item.RptEndUtcDT = utcEnd.Value;
                item.RptEndUtcDTSpecified = true;
            }

            /* Submit the transaction. */
            var rsp = DoTransaction(transaction).Ver10;
            HpsGatewayResponseValidation.CheckResponse(rsp, ItemChoiceType2.ReportActivity);

            var reportResponse = (PosReportActivityRspType)rsp.Transaction.Item;
            var serviceName = filterBy.HasValue ? HpsTransaction.TransactionTypeToServiceName(filterBy.Value) : string.Empty;
            var transactionList = new List<HpsReportTransactionSummary>();
            foreach (var charge in reportResponse.Details)
            {
                if (!filterBy.HasValue || charge.ServiceName == serviceName)
                {
                    transactionList.Add(new HpsReportTransactionSummary
                    {
                        TransactionId = charge.GatewayTxnId,
                        OriginalTransactionId = charge.OriginalGatewayTxnId,
                        MaskedCardNumber = charge.MaskedCardNbr,
                        ResponseCode = charge.IssuerRspCode,
                        ResponseText = charge.IssuerRspText,
                        Amount = charge.Amt,
                        SettlementAmount = charge.SettlementAmt,
                        TransactionUtcDate = charge.TxnUtcDT,
                        TransactionType = filterBy.HasValue ? filterBy : HpsTransaction.ServiceNameToTransactionType(charge.ServiceName),
                        Exceptions = (charge.GatewayRspCode != 0 || charge.IssuerRspCode != "00") ? new HpsChargeExceptions
                        {
                            GatewayException = HpsGatewayResponseValidation.GetException(charge.GatewayRspCode, charge.GatewayRspMsg),
                            IssuerException = HpsIssuerResponseValidation.GetException(charge.GatewayTxnId, charge.IssuerRspCode, charge.IssuerRspText)
                        }
                        : null
                    });
                }
            }

            return transactionList;
        }