protected override void ParseResponse(BinaryReader br)
        {
            base.ParseResponse(br);

            if (DeviceResponseCode == "000000")
            {
                TotalRecords    = int.Parse(br.ReadToCode(ControlCodes.FS));
                RecordNumber    = int.Parse(br.ReadToCode(ControlCodes.FS));
                HostResponse    = new HostResponse(br);
                CardType        = ((TerminalCardType)int.Parse(br.ReadToCode(ControlCodes.FS))).ToString().Replace("_", " ");
                TransactionType = ((TerminalTransactionType)int.Parse(br.ReadToCode(ControlCodes.FS))).ToString().Replace("_", " ");

                int originalTransactionTypeId;
                if (int.TryParse(br.ReadToCode(ControlCodes.FS), out originalTransactionTypeId))
                {
                    TerminalTransactionType transType = (TerminalTransactionType)originalTransactionTypeId;
                    OriginalTransactionType = transType.ToString().Replace("_", " ");
                }

                AmountResponse     = new AmountResponse(br);
                AccountResponse    = new AccountResponse(br);
                TraceResponse      = new TraceResponse(br);
                CashierResponse    = new CashierSubGroup(br);
                CommercialResponse = new CommercialResponse(br);
                CheckSubResponse   = new CheckSubGroup(br);
                ExtDataResponse    = new ExtDataSubGroup(br);

                MapResponse();
            }
        }
示例#2
0
        internal override TerminalResponse ManageTransaction(TerminalManageBuilder builder)
        {
            var amounts = new AmountRequest();
            var account = new AccountRequest();
            var trace   = new TraceRequest {
                ReferenceNumber     = builder.ReferenceNumber.ToString(),
                ClientTransactionId = builder.ClientTransactionId
            };
            var extData = new ExtDataSubGroup();

            // amounts
            if (builder.Amount.HasValue)
            {
                var _amount = builder.Amount;
                amounts.TransactionAmount = "{0:c}".FormatWith(_amount).ToNumeric();
            }

            // ADDING THIS HERE CAUSES IT TO FAIL SKIPPING IT HERE
            //if (gratuity.HasValue)
            //    amounts.TipAmount = "{0:c}".FormatWith(gratuity).ToNumeric();

            if (builder.PaymentMethod != null)
            {
                if (builder.PaymentMethod is TransactionReference)
                {
                    var reference = builder.PaymentMethod as TransactionReference;
                    if (!string.IsNullOrEmpty(reference.TransactionId))
                    {
                        extData[EXT_DATA.HOST_REFERENCE_NUMBER] = reference.TransactionId;
                    }
                }
                else if (builder.PaymentMethod is GiftCard)
                {
                    var card = builder.PaymentMethod as GiftCard;
                    account.AccountNumber = card.Number;
                }
            }

            string transType = MapTransactionType(builder.TransactionType);

            switch (builder.PaymentMethodType)
            {
            case PaymentMethodType.Credit:
                return(DoCredit(transType, amounts, account, trace, new AvsRequest(), new CashierSubGroup(), new CommercialRequest(), new EcomSubGroup(), extData));

            case PaymentMethodType.Gift:
                var messageId = builder.Currency == CurrencyType.CURRENCY ? PAX_MSG_ID.T06_DO_GIFT : PAX_MSG_ID.T08_DO_LOYALTY;
                return(DoGift(messageId, transType, amounts, account, trace, new CashierSubGroup(), extData));

            case PaymentMethodType.EBT:
                return(DoEBT(transType, amounts, account, trace, new CashierSubGroup()));

            default:
                throw new UnsupportedTransactionException();
            }
        }
示例#3
0
        protected override void ParseResponse(BinaryReader br)
        {
            base.ParseResponse(br);

            if (DeviceResponseCode == "000000")
            {
                hostResponse    = new HostResponse(br);
                transactionType = br.ReadToCode(ControlCodes.FS);
                amountResponse  = new AmountResponse(br);
                traceResponse   = new TraceResponse(br);
                extDataResponse = new ExtDataSubGroup(br);
            }
        }
        protected override void ParseResponse(BinaryReader br)
        {
            base.ParseResponse(br);

            if (DeviceResponseCode == "000000")
            {
                hostResponse    = new HostResponse(br);
                transactionType = ((TerminalTransactionType)Int32.Parse(br.ReadToCode(ControlCodes.FS))).ToString().Replace("_", " ");
                amountResponse  = new AmountResponse(br);
                traceResponse   = new TraceResponse(br);
                extDataResponse = new ExtDataSubGroup(br);
            }
        }
示例#5
0
        internal IDeviceMessage BuildReportTransaction(TerminalReportBuilder builder)
        {
            string messageId = MapReportType(builder.ReportType);

            IDeviceMessage request = null;

            switch (builder.ReportType)
            {
            case TerminalReportType.LocalDetailReport: {
                var criteria = builder.SearchBuilder;

                // additional data
                var additionalData = new ExtDataSubGroup();
                if (criteria.MerchantId.HasValue)
                {
                    additionalData[EXT_DATA.MERCHANT_ID] = criteria.MerchantId.ToString();
                }
                if (!string.IsNullOrEmpty(criteria.MerchantName))
                {
                    additionalData[EXT_DATA.MERCHANT_NAME] = criteria.MerchantName;
                }

                request = TerminalUtilities.BuildRequest(
                    messageId,
                    "00",          // EDC TYPE SET TO ALL
                    ControlCodes.FS,
                    criteria.TransactionType.HasValue ? ((int)criteria.TransactionType.Value).ToString().PadLeft(2, '0') : string.Empty,
                    ControlCodes.FS,
                    criteria.CardType.HasValue ? ((int)criteria.CardType.Value).ToString().PadLeft(2, '0') : string.Empty,
                    ControlCodes.FS,
                    criteria.RecordNumber.HasValue ? criteria.RecordNumber.ToString() : string.Empty,
                    ControlCodes.FS,
                    criteria.TerminalReferenceNumber.HasValue ? criteria.TerminalReferenceNumber.ToString() : string.Empty,
                    ControlCodes.FS,
                    criteria.AuthCode ?? string.Empty,
                    ControlCodes.FS,
                    criteria.ReferenceNumber ?? string.Empty,
                    ControlCodes.FS,
                    additionalData
                    );
            }
            break;

            default: {
                throw new UnsupportedTransactionException(string.Format("Unsupported report type: {0}", builder.ReportType.ToString()));
            };
            }

            return(request);
        }
示例#6
0
        protected override void ParseResponse(BinaryReader br)
        {
            base.ParseResponse(br);

            if (acceptedCodes.Contains(DeviceResponseCode))
            {
                HostResponse    = new HostResponse(br);
                TransactionType = ((TerminalTransactionType)Int32.Parse(br.ReadToCode(ControlCodes.FS))).ToString().Replace("_", " ");
                AmountResponse  = new AmountResponse(br);
                AccountResponse = new AccountResponse(br);
                TraceResponse   = new TraceResponse(br);
                ExtDataResponse = new ExtDataSubGroup(br);

                MapResponse();
            }
        }
示例#7
0
        protected override void ParseResponse(BinaryReader br)
        {
            base.ParseResponse(br);

            if (DeviceResponseCode == "000000")
            {
                HostResponse       = new HostResponse(br);
                TransactionType    = ((TerminalTransactionType)Int32.Parse(br.ReadToCode(ControlCodes.FS))).ToString().Replace("_", " ");
                AmountResponse     = new AmountResponse(br);
                AccountResponse    = new AccountResponse(br);
                TraceResponse      = new TraceResponse(br);
                AvsResponse        = new AvsResponse(br);
                CommercialResponse = new CommercialResponse(br);
                EcomResponse       = new EcomSubGroup(br);
                ExtDataResponse    = new ExtDataSubGroup(br);

                MapResponse();
            }
        }
示例#8
0
        internal override TerminalResponse ProcessTransaction(TerminalAuthBuilder builder)
        {
            // create sub groups
            var amounts = new AmountRequest();
            var account = new AccountRequest();
            var avs     = new AvsRequest();
            var trace   = new TraceRequest {
                ReferenceNumber = builder.ReferenceNumber.ToString()
            };
            var cashier    = new CashierSubGroup();
            var commercial = new CommercialRequest();
            var ecom       = new EcomSubGroup();
            var extData    = new ExtDataSubGroup();

            // amounts sub group
            amounts.TransactionAmount = "{0:c}".FormatWith(builder.Amount).ToNumeric();
            amounts.CashBackAmount    = "{0:c}".FormatWith(builder.CashBackAmount).ToNumeric();
            amounts.TipAmount         = "{0:c}".FormatWith(builder.Gratuity).ToNumeric();
            amounts.TaxAmount         = "{0:c}".FormatWith(builder.TaxAmount).ToNumeric();

            // account sub group
            if (builder.PaymentMethod != null)
            {
                if (builder.PaymentMethod is CreditCardData)
                {
                    var card = builder.PaymentMethod as CreditCardData;
                    if (string.IsNullOrEmpty(card.Token))
                    {
                        account.AccountNumber = card.Number;
                        account.EXPD          = "{0}{1}".FormatWith(card.ExpMonth, card.ExpYear);
                        if (builder.TransactionType != TransactionType.Verify && builder.TransactionType != TransactionType.Refund)
                        {
                            account.CvvCode = card.Cvn;
                        }
                    }
                    else
                    {
                        extData[EXT_DATA.TOKEN] = card.Token;
                    }
                }
                else if (builder.PaymentMethod is TransactionReference)
                {
                    var reference = builder.PaymentMethod as TransactionReference;
                    if (!string.IsNullOrEmpty(reference.AuthCode))
                    {
                        trace.AuthCode = reference.AuthCode;
                    }
                    if (!string.IsNullOrEmpty(reference.TransactionId))
                    {
                        extData[EXT_DATA.HOST_REFERENCE_NUMBER] = reference.TransactionId;
                    }
                }
                else if (builder.PaymentMethod is GiftCard)
                {
                    var card = builder.PaymentMethod as GiftCard;
                    account.AccountNumber = card.Number;
                }
                else if (builder.PaymentMethod is EBTCardData)
                {
                    var card = builder.PaymentMethod as EBTCardData;
                }
            }
            if (builder.AllowDuplicates)
            {
                account.DupOverrideFlag = "1";
            }

            // Avs Sub Group
            if (builder.Address != null)
            {
                avs.ZipCode = builder.Address.PostalCode;
                avs.Address = builder.Address.StreetAddress1;
            }

            // Trace Sub Group
            trace.InvoiceNumber = builder.InvoiceNumber;

            // Commercial Group
            commercial.CustomerCode = builder.CustomerCode;
            commercial.PoNumber     = builder.PoNumber;
            commercial.TaxExempt    = builder.TaxExempt;
            commercial.TaxExemptId  = builder.TaxExemptId;

            // Additional Info sub group
            if (builder.RequestMultiUseToken)
            {
                extData[EXT_DATA.TOKEN_REQUEST] = "1";
            }

            if (builder.SignatureCapture)
            {
                extData[EXT_DATA.SIGNATURE_CAPTURE] = "1";
            }

            string transType = MapTransactionType(builder.TransactionType, builder.RequestMultiUseToken);

            switch (builder.PaymentMethodType)
            {
            case PaymentMethodType.Credit:
                return(DoCredit(transType, amounts, account, trace, avs, cashier, commercial, ecom, extData));

            case PaymentMethodType.Debit:
                return(DoDebit(transType, amounts, account, trace, cashier, extData));

            case PaymentMethodType.Gift:
                var messageId = builder.Currency == CurrencyType.CURRENCY ? PAX_MSG_ID.T06_DO_GIFT : PAX_MSG_ID.T08_DO_LOYALTY;
                return(DoGift(messageId, transType, amounts, account, trace, cashier, extData));

            case PaymentMethodType.EBT:
                if (builder.Currency != null)
                {
                    account.EbtType = builder.Currency.ToString().Substring(0, 1);
                }
                return(DoEBT(transType, amounts, account, trace, cashier));

            default:
                throw new UnsupportedTransactionException();
            }
        }
示例#9
0
        internal CheckSubResponse DoCheck(string txnType, AmountRequest amounts, CheckSubGroup check, TraceRequest trace, CashierSubGroup cashier, ExtDataSubGroup extData)
        {
            var response = DoTransaction(PAX_MSG_ID.T12_DO_CHECK, txnType, amounts, check, trace, cashier, extData);

            return(new CheckSubResponse(response));
        }
示例#10
0
        internal GiftResponse DoGift(string messageId, string txnType, AmountRequest amounts, AccountRequest accounts, TraceRequest trace, CashierSubGroup cashier, ExtDataSubGroup extData = null)
        {
            var response = DoTransaction(messageId, txnType, amounts, accounts, trace, cashier, extData);

            return(new GiftResponse(response));
        }
示例#11
0
        internal DebitResponse DoDebit(string txnType, AmountRequest amounts, AccountRequest accounts, TraceRequest trace, CashierSubGroup cashier, ExtDataSubGroup extData)
        {
            var response = DoTransaction(PAX_MSG_ID.T02_DO_DEBIT, txnType, amounts, accounts, trace, cashier, extData);

            return(new DebitResponse(response));
        }
示例#12
0
        internal CreditResponse DoCredit(string txnType, AmountRequest amounts, AccountRequest accounts, TraceRequest trace, AvsRequest avs, CashierSubGroup cashier, CommercialRequest commercial, EcomSubGroup ecom, ExtDataSubGroup extData)
        {
            var response = DoTransaction(PAX_MSG_ID.T00_DO_CREDIT, txnType, amounts, accounts, trace, avs, cashier, commercial, ecom, extData);

            return(new CreditResponse(response));
        }
示例#13
0
 internal IDeviceMessage BuildCheck(string txnType, AmountRequest amounts, CheckSubGroup check, TraceRequest trace, CashierSubGroup cashier, ExtDataSubGroup extData)
 {
     return(BuildRequest(PAX_MSG_ID.T12_DO_CHECK, txnType, amounts, check, trace, cashier, extData));
 }
示例#14
0
 internal IDeviceMessage BuildGift(string messageId, string txnType, AmountRequest amounts, AccountRequest accounts, TraceRequest trace, CashierSubGroup cashier, ExtDataSubGroup extData = null)
 {
     return(BuildRequest(messageId, txnType, amounts, accounts, trace, cashier, extData));
 }
示例#15
0
 internal IDeviceMessage BuildDebit(string txnType, AmountRequest amounts, AccountRequest accounts, TraceRequest trace, CashierSubGroup cashier, ExtDataSubGroup extData)
 {
     return(BuildRequest(PAX_MSG_ID.T02_DO_DEBIT, txnType, amounts, accounts, trace, cashier, extData));
 }
示例#16
0
 internal IDeviceMessage BuildCredit(string txnType, AmountRequest amounts, AccountRequest accounts, TraceRequest trace, AvsRequest avs, CashierSubGroup cashier, CommercialRequest commercial, EcomSubGroup ecom, ExtDataSubGroup extData)
 {
     return(BuildRequest(PAX_MSG_ID.T00_DO_CREDIT, txnType, amounts, accounts, trace, avs, cashier, commercial, ecom, extData));
 }