public override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleAuthorisationResponseBuilder respBuilder;
            SchemeAuthorisationResult schemeAuthResult;

            nextStage(context);

            respBuilder      = context.responseBuilder();
            schemeAuthResult = respBuilder.AuthorisationResult;

            string authCode = null;

            if (schemeAuthResult != null)
            {
                authCode = schemeAuthResult.SchemeAuthCode;
            }

            // As we maunally set this value it should only ever happen with Visa.
            if ((!string.ReferenceEquals(authCode, null)) && (authCode.Equals("REJECT")) && (respBuilder.AuthScheme == AuthScheme.VISA))
            {
                respBuilder.ResponseCode = ResponseCode.FORMAT_ERROR;
            }
            else
            {
                respBuilder.ResponseCode = responseMapper.mapResponseCode(schemeAuthResult, respBuilder.ResponseCode, respBuilder.AuthScheme);
            }
            respBuilder.CvvResponseCode = responseMapper.mapCvvResponseCode(schemeAuthResult, respBuilder.AuthScheme);

            respBuilder.AvsAddressResponseCode = responseMapper.mapAvsAddressResponseCode(schemeAuthResult, respBuilder.AuthScheme);

            respBuilder.AvsPostalCodeResponseCode = responseMapper.mappedAvsPostalResponseCodeCode(schemeAuthResult, respBuilder.AuthScheme);

            //Logger.info("Mapped response code is " + respBuilder.ResponseCode);
        }
Beispiel #2
0
        protected internal override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder builder = context.saleBuild();
            SalePostRequest      request = context.Request;
            AcceptorDetail       defaultAcceptorDetail = builder.Terminal.DefaultAcceptorDetail;
            AcceptorDetail       dynamicAcceptor;

            if (request.hasDynamicAcceptor())
            {
                // So we have dynamic acceptor details provided, try to use.
                dynamicAcceptor = _acceptorUtil.obtainExplicitAcceptor(builder.Terminal, request.getDynamicAcceptorName(), request.getDynamicAcceptorStreet(), request.getDynamicAcceptorCity(), request.getDynamicAcceptorState(), request.getDynamicAcceptorPostalCode(), request.getDynamicAcceptorCustomerServicePhone(), request.getDynamicAcceptorSubMerchantId(), defaultAcceptorDetail.CustomerServiceEmail);

                if (dynamicAcceptor != null)
                {
                    //Logger.info("Dynamic Acceptor associated: " + dynamicAcceptor);
                    builder.ExplictAcceptor = dynamicAcceptor;
                }
                else
                {
                    //Logger.warn("Ignoring supplied Dynamic Acceptor");
                }
            }
            else
            {
                //Logger.warn("No Dynamic Acceptor - doing nothing");
            }

            nextStg(context);
        }
        public override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder builder  = context.saleBuild();
            PANRange             binRange = builder.getCard().getPANRange();
            Scheme scheme = schemeCheck.getSchemeFromPanRange(binRange);

            if ((binRange == null) || (scheme == null))
            {
                // TODO: Throw exception rather than this?
                context.Response.ResponseCode = ResponseCode.NO_BIN_FOR_CARD_NUMBER;
                return;
            }
            else
            {
                //Logger.info("Scheme: " + scheme.AuthScheme);
                context.Scheme = scheme;
            }
            CardDate cardExpiryDate = builder.Card.ExpiryDate;

            if (cardExpiryDate == null)
            {
                //Logger.warn("Card expiry date is outside of maximum limit");
                context.Response.ResponseCode = ResponseCode.CARD_EXPIRY_DATE_INVALID;
                return;
            }
            nextStage(context);
        }
Beispiel #4
0
        public override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder saleBuilder;
            SalePostRequest      request = context.Request;

            saleBuilder = context.saleBuild();
            saleBuilder.setBID(request.getBID()).setMID(request.getTerminalMID()).setTID(request.getTerminalTID());
            nextStage(context);
        }
        public override void stageExecute(SalePostContext context)
        {
            CardRepo_CardBuilder cardBuilder;
            SalePostRequest      request = context.Request;

            cardBuilder = context.saleBuild().cardBuilder();
            cardBuilder.setNumber(cardUtility.buildCardNumber(request.getCardNumber())).setIssueDate(cardUtility.buildCardDate(request.getCardDateIssue())).setExpiryDate(cardUtility.buildCardDate(request.getCardDateExpiry())).setAVSData(cardUtility.buildAVSData(request.getCardAddress(), request.getCardPostalCode())).setCVV(request.getCardCVV());
            nextStage(context);
            throw new NotImplementedException();
        }
Beispiel #6
0
        protected internal override void stageExecute(SalePostContext context)
        {
            SaleRepo.AuthenticationDataBuilder authDataBuilder;
            SalePostRequest request = context.Request;

            //if (request.getAuthenticationECIFlag()!= null)
            //{
            authDataBuilder = context.saleBuild().authenticationDataBuilder();

            authDataBuilder.setECIFlag(request.getAuthenticationECIFlag()).setXID(request.getAuthenticationXID()).setACSData(request.getAuthenticationACSData()).set3DsVersion(request.getAuthentication3DsVersion()).setDsTransId(request.getAuthenticationDsTransId());
            //}
            nextStg(context);
        }
Beispiel #7
0
        public override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder saleBuilder;
            SalePostRequest      request = context.Request;

            saleBuilder = context.saleBuild();
            saleBuilder.setGatewayRef(request.getGatewayReference()).setAuthType(request.getAuthType()).setCurrencyAmount(request.getAmount(), request.getCurrency()).setRecurrenceFlag(request.getRecurrenceFlag()).setExemptionIndicator(request.getExemptionIndicator());
            //Logger.info("Gateway Reference: " + request.GatewayReference);
            //Logger.info("Sale AuthType: " + request.AuthType + ", Recurrence: " + request.RecurrenceFlag);
            //Logger.info("Amount: " + request.Amount + " " + request.Currency.name());
            //Logger.info("Exemption Indicator: " + request.ExemptionIndicator);
            nextStage(context);
        }
Beispiel #8
0
        protected internal override void stageExecute(SalePostContext context)
        {
            Sale   dispatchSale = context.getSale();
            Scheme dispatchScheme;
            SchemeAuthorisationResultOrResponse schemeAuthResultOrResp;

            dispatchScheme = context.getScheme();
            //Logger.info("Dispatching sale: " + dispatchSale.Id + " to scheme: " + dispatchScheme.AuthScheme);

            schemeAuthResultOrResp = dispatchScheme.authoriseSale(dispatchSale, null);
            context.responseBuilder().AuthorisationResult.SchemeAuthCode = schemeAuthResultOrResp.AuthResult.SchemeAuthCode;
            context.responseBuilder().ResponseCode = schemeAuthResultOrResp.ResponseCode;
        }
Beispiel #9
0
        protected internal override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder builder = context.saleBuild();
            SalePostRequest      request = context.Request;
            string softDescriptor        = request.getSoftDescriptor();

            if (!string.ReferenceEquals(softDescriptor, null))
            {
                //Logger.info("Setting Soft Desciptor on Sale: " + softDescriptor);
                builder.SoftDescriptor = softDescriptor;
            }

            nextStg(context);
        }
Beispiel #10
0
        public override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder saleBuilder;
            SalePostRequest      request = context.Request;

            saleBuilder = context.saleBuild();
            if ((!string.ReferenceEquals(request.getRecipientSurname(), null)) || (request.getRecipientDOB() != null) || (!string.ReferenceEquals(request.getRecipientSurname(), null)) || (!string.ReferenceEquals(request.getDynamicAcceptorSubMerchantId(), null)))
            {
                SaleRepo.FundsRecipientBuilder recipBuilder = saleBuilder.fundsRecipientBuilder();

                recipBuilder.setSurname(request.getRecipientSurname()).setDoB(request.getRecipientDOB()).setPostalCode(request.getRecipientPostalCode()).setAccountNumber(request.getRecipientAccountNumber());
            }
            nextStage(context);
        }
        public override void stageExecute(SalePostContext context)
        {
            if (AuthScheme.AMEX.Equals(context.getScheme().AuthScheme))
            {
                AmexServiceEstablishmentEntity entity = serviceEstablishmentDao.findByCurrency(context.Request.getCurrency().ToString());
                //AmexServiceEstablishmentEntity entity = serviceEstablishmentDao.findByCurrency(context.Request.Currency.CurrencyCode);
                if (entity == null)
                {
                    // throw new EndpointException(string.Format("Invalid Amex Currency: '{0}'", context.Request.Currency.CurrencyCode));
                }
            }

            nextStage(context);
        }
Beispiel #12
0
        public Task Invoke(HttpContext httpContext)
        {
            PanRanges panRanges = new PanRanges();
            long      input     = 12210200000;
            var       result    = panRanges.findPanRange(input);


            SalePostContext      context = null;
            SalePostSetupContext salePostSetupContextMiddleware = new SalePostSetupContext(saleRepo, next);

            salePostSetupContextMiddleware.stageExecute(context);

            return(_next(httpContext));
        }
Beispiel #13
0
        protected internal override void stageExecute(SalePostContext context)
        {
            long?  stan;
            Scheme scheme = context.getScheme();

            if (scheme == null)
            {
                //throw new EndpointException("Context Scheme not yet defined");
            }
            stan = scheme.createStan(context.saleBuild().Timestamp);
            //Logger.info("STAN generated for sale: " + stan);
            context.saleBuild().setSTAN(scheme.AuthScheme, stan);
            nextStg(context);
        }
Beispiel #14
0
        protected internal override void stageExecute(SalePostContext context)
        {
            Terminal_Lock @lock = null;

            try
            {
                Sale     sale     = context.saleBuild().createdSale();
                Terminal terminal = sale.Terminal;
                @lock = terminal.@lock(sale.Id.ToString(), sale.Card, context.getScheme().AuthScheme);
                if (@lock != null)
                {
                    // Have the lock.. continue on.
                    //Logger.info("Locked terminal");
                    context.setTerminalStatistics(@lock.CardStatistics, @lock.SchemeStatistics);
                    nextStg(context);
                }
                else
                {
                    // Cannot get lock - Not an error - Already locked, so indicate undesired
                    // concurrency.
                    //Logger.warn("Failed to lock terminal");

                    context.responseBuilder().ResponseCode = ResponseCode.CONCURRENT_AUTHS;
                }
            }
            finally
            {
                if (@lock != null)
                {
                    Action       action;
                    ResponseCode responseCode;

                    responseCode = context.responseBuilder().ResponseCode;
                    if (responseCode != null)
                    {
                        //action = responseCode.Action;
                        action = Action.APPROVE;
                    }
                    else
                    {
                        //Logger.warn("No scheme result");
                        action = Action.DO_NOT_ACCEPT;
                    }
                    //Logger.info("Unlocking, recording Action: {}", action.name());
                    @lock.unlock(action);
                }
            }
        }
Beispiel #15
0
        public override void stageExecute(SalePostContext context)
        {
            CostDesignatorParameters  costDesignatorParameters = null;
            SchemeAuthorisationResult schemeAuthResult;

            SaleRepo.SaleAuthorisationResponseBuilder respBuilder;

            nextStage(context);

            respBuilder      = context.responseBuilder();
            schemeAuthResult = respBuilder.AuthorisationResult;
            //Check the scheme response(if an exception is thrown, let it ripple through
            //if ((schemeAuthResult == null) || (respBuilder.ResponseCode.Action != core_develop.cashflows.core.authorisation.Action.APPROVE))
            if ((schemeAuthResult == null))
            {
                //Logger.debug("Auth request not approved, or no scheme response, " + "so no cost parameters will be calculated");
            }
            else
            {
                try
                {
                    costDesignatorParameters = costingUtility.determineParameters(schemeAuthResult, respBuilder.AuthScheme, context.getSale());

                    if (costDesignatorParameters == null)
                    {
                        //Logger.warn("Could not determine cost descriptor parameters.");
                        // Setting this response code means the 'open' sale will not be removed,
                        // and therefore the next reversal job will reverseSaleAuthorisation the
                        // authorisation previously sent
                        respBuilder.ResponseCode = ResponseCode.COULD_NOT_DETERMINE_COST;
                    }
                    else
                    {
                        respBuilder.CostDesignatorParameters = costDesignatorParameters;
                    }
                }


                //catch (CostingTerminalConfigurationException cte)
                catch (Exception)
                {
                    //Logger.warn("Terminal miscofiguration", cte);
                    respBuilder.ResponseCode = ResponseCode.TXN_TERMINAL_CONFIG_MISMATCH;
                }
            }
        }
Beispiel #16
0
        protected internal override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder saleBuilder = context.saleBuild();
            SalePostRequest      request     = context.Request;

            if (String.IsNullOrEmpty(request.getAuthMode().ToString()))
            {
                //Logger.info("Setting Sale auth mode to default:" + defaultAuthMode);
                //saleBuilder.AuthMode = DefaultAuthMode;
                saleBuilder.AuthMode = AuthMode.FINAL;
            }
            else
            {
                //Logger.info("Setting Sale auth mode to:" + request.AuthMode);
                saleBuilder.AuthMode = request.getAuthMode();
            }
            nextStg(context);
        }
Beispiel #17
0
        protected internal override void stageExecute(SalePostContext context)
        {
            Terminal terminal;

            terminal = context.saleBuild().Terminal;
            if (terminal == null)
            {
                //Logger.warn("Terminal not found");
                context.Response.ResponseCode = ResponseCode.INVALID_TERMINAL;
            }
            else if (terminal.Status != TerminalStatus.LIVE)
            {
                //Logger.warn("Terminal is not live");
                context.Response.ResponseCode = ResponseCode.TERMINAL_NOT_LIVE;
            }
            else
            {
                //Logger.info("Terminal found.");
                nextStg(context);
            }
        }
        public override void stageExecute(SalePostContext context)
        {
            SalePostResponse response = context.Response;

            SaleRepo.SaleBuilder saleBuilder = context.saleBuild();
            PANRange             binRange    = null;
            Card         card = saleBuilder.Card;
            ResponseCode?failureResponseCode = null;;

            if (card != null)
            {
                binRange = card.PANRange;
            }
            if (binRange != null)
            {
                Terminal terminal = saleBuilder.Terminal;
                if (terminal != null)
                {
                    failureResponseCode = checkSchemeFundsRecipient(binRange, terminal, saleBuilder.FundsRecipient, binRange.Scheme, saleBuilder.DebtRepayFlag);
                }
                else
                {
                    //Logger.warn("Sale doesn't have associated terminal = " + "Cannot perform Funds recipient check");
                }
            }
            else
            {
                //Logger.info("Not performing FundsRecipient check - Not a VISA/Mastercard card");
            }
            //nextStage(context);
            if (failureResponseCode.HasValue)
            {
                response.ResponseCode = (ResponseCode)failureResponseCode;
            }
            else
            {
                nextStage(context);
            }
        }
Beispiel #19
0
        protected internal override void stageExecute(SalePostContext context)
        {
            string arn;

            SaleRepo.SaleAuthorisationResponseBuilder saleRespBuilder;
            Sale builtSale;

            nextStg(context);

            saleRespBuilder = context.responseBuilder();
            builtSale       = context.getSale();
            //arn = arnGenerator.generateARN(saleRespBuilder.ResponseCode, builtSale.Terminal.BID, saleRespBuilder.AuthScheme, builtSale.Timestamp, Action.APPROVE);
            arn = null;
            if (!string.ReferenceEquals(arn, null))
            {
                saleRespBuilder.ARN = arn;
            }
            else
            {
                //Logger.info("No ARN generated for Sale");
            }
        }
Beispiel #20
0
        //public override void Invoke(SalePostContext context)
        //{
        //    bool createFailed = true;
        //    SaleBuilder saleBuilder;
        //    nextStage(context);
        //    saleBuilder = context.saleBuild();
        //    if (saleBuilder.createdSale() == null)
        //    {
        //        //Logger.warn("Sale was not stored - Creating Failed Sale");
        //    }
        //    else if (context.responseBuilder().createdResponse() == null)
        //    {
        //        //Logger.warn("SaleAuthResponse was not stored - Creating Failed Sale");
        //    }
        //    else
        //    {
        //        createFailed = false;
        //    }
        //    if (createFailed)
        //    {
        //        SalePostRequest request;

        //        ResponseCode responseCode;
        //        FailedSaleBuilder failedSaleBuilder = saleBuilder.failedSaleBuilder();
        //        responseCode = context.Response.ResponseCode;
        //        if (responseCode == null)
        //        {
        //            // Oh - Don't have anything, set a sensible default...
        //            responseCode = ResponseCode.UNKNOWN;
        //            context.Response.ResponseCode = responseCode;
        //        }
        //        request = context.Request;
        //        failedSaleBuilder.setAuthScheme(saleBuilder.AuthScheme).setResponseCode(responseCode).setGatewayRef(request.getGatewayReference()).setAuthType((request.getAuthType() != null) ? request.getAuthType().ToString() : null).setAmount(request.getAmount()).setCurrencyCode((request.getCurrency() != null) ? request.getCurrency().ToString() : null).setRecurrenceFlag((request.getRecurrenceFlag() != null) ? request.getRecurrenceFlag().ToString() : null).setTerminalBID(request.getBID()).setTerminalMID(request.getTerminalMID()).setTerminalTID(request.getTerminalTID()).setCardNumber(request.getCardNumber()).setCardDateIssue(request.getCardDateIssue()).setCardDateExpiry(request.getCardDateExpiry()).setCardAddress(request.getCardAddress()).setCardPostalCode(request.getCardPostalCode()).setAuthentECI(request.getAuthenticationECIFlag()).setAuthentXID(request.getAuthenticationXID()).setAuthentACS(request.getAuthenticationACSData()).setAuthent3DsVersion(request.getAuthentication3DsVersion()).setAuthMode((request.getAuthMode() != null) ? request.getAuthMode().ToString() : null).setDebtRepayFlag(saleBuilder.getDebtRepayFlag());

        //        long? failedSaleId = failedSaleBuilder.create();
        //        //Logger.warn("Failed sale stored with Id: " + failedSaleId);
        //    }
        //}
        protected internal override void stageExecute(SalePostContext context)
        {
            bool        createFailed = true;
            SaleBuilder saleBuilder;

            nextStg(context);
            saleBuilder = context.saleBuild();
            if (saleBuilder.createdSale() == null)
            {
                //Logger.warn("Sale was not stored - Creating Failed Sale");
            }
            else if (context.responseBuilder().createdResponse() == null)
            {
                //Logger.warn("SaleAuthResponse was not stored - Creating Failed Sale");
            }
            else
            {
                createFailed = false;
            }
            if (createFailed)
            {
                SalePostRequest request;

                ResponseCode      responseCode;
                FailedSaleBuilder failedSaleBuilder = saleBuilder.failedSaleBuilder();
                responseCode = context.Response.ResponseCode;
                if (responseCode == null)
                {
                    // Oh - Don't have anything, set a sensible default...
                    responseCode = ResponseCode.UNKNOWN;
                    context.Response.ResponseCode = responseCode;
                }
                request = context.Request;
                failedSaleBuilder.setAuthScheme(saleBuilder.AuthScheme).setResponseCode(responseCode).setGatewayRef(request.getGatewayReference()).setAuthType((request.getAuthType() != null) ? request.getAuthType().ToString() : null).setAmount(request.getAmount()).setCurrencyCode((request.getCurrency() != null) ? request.getCurrency().ToString() : null).setRecurrenceFlag((request.getRecurrenceFlag() != null) ? request.getRecurrenceFlag().ToString() : null).setTerminalBID(request.getBID()).setTerminalMID(request.getTerminalMID()).setTerminalTID(request.getTerminalTID()).setCardNumber(request.getCardNumber()).setCardDateIssue(request.getCardDateIssue()).setCardDateExpiry(request.getCardDateExpiry()).setCardAddress(request.getCardAddress()).setCardPostalCode(request.getCardPostalCode()).setAuthentECI(request.getAuthenticationECIFlag()).setAuthentXID(request.getAuthenticationXID()).setAuthentACS(request.getAuthenticationACSData()).setAuthent3DsVersion(request.getAuthentication3DsVersion()).setAuthMode((request.getAuthMode() != null) ? request.getAuthMode().ToString() : null).setDebtRepayFlag(saleBuilder.getDebtRepayFlag());

                long?failedSaleId = failedSaleBuilder.create();
                //Logger.warn("Failed sale stored with Id: " + failedSaleId);
            }
        }
Beispiel #21
0
        public override void stageExecute(SalePostContext context)
        {
            bool         isDebtRepayTrans;
            ResponseCode errorCode;

            SaleRepo.SaleBuilder saleBuilder = context.saleBuild();
            Card     card = saleBuilder.Card;
            bool     debtRepaymentProfileFlag = context.Request.getDebtRepayFlag();
            Terminal terminal = saleBuilder.Terminal;

            errorCode        = debtRepaymentSetUpUtility.checkDebtRepayFlag(card, debtRepaymentProfileFlag, terminal);
            isDebtRepayTrans = debtRepaymentSetUpUtility.isDebtRepaymentTrans(card, terminal, debtRepaymentProfileFlag);
            if (errorCode != null)
            {
                context.Response.ResponseCode = errorCode;
            }
            else
            {
                //Logger.info("Setting debt repayment flag: " + isDebtRepayTrans);
                saleBuilder.DebtRepayFlag = isDebtRepayTrans;
                nextStage(context);
            }
        }
        public override void stageExecute(SalePostContext context)
        {
            ActionStatistics schemeStats = context.getTerminalSchemeStatitics();
            AuthScheme       scheme      = context.saleBuild().AuthScheme;

            if ((scheme != null) && (schemeStats != null))
            {
                if (terminalStatsCheckUtility.isUnderThreshold(schemeStats, scheme))
                {
                    nextStage(context);
                }
                else
                {
                    // Over threshold and approval rate too low - Block the transaction.
                    context.responseBuilder().ResponseCode = ResponseCode.SCHEME_AUTH_LIMIT_REACHED;
                }
            }
            else
            {
                // Cannot get stats, can't guarantee won't exceed limits, so have to decline.
                //Logger.error("Cannot get scheme statistics, or determine scheme - " + "Rejecting transaction");
                context.responseBuilder().ResponseCode = ResponseCode.COULD_NOT_CHECK_AUTH_LIMIT;
            }
        }
        public override void stageExecute(SalePostContext context)
        {
            ActionStatistics cardStats = context.getTerminalCardStatistics();

            if (cardStats != null)
            {
                if (cardTerminalStatsUtility.isUnderThreshold(cardStats))
                {
                    // card stats ok, haven't reached the limit, so continue.
                    nextStage(context);
                }
                else
                {
                    // Limit reached...
                    context.responseBuilder().ResponseCode = ResponseCode.CARD_AUTH_LIMIT_REACHED;
                }
            }
            else
            {
                // Cannot get stats, can't guarantee won't exceed limits, so have to decline.
                //Logger.error("Cannot get card statistics - Rejecting transaction");
                context.responseBuilder().ResponseCode = ResponseCode.COULD_NOT_CHECK_AUTH_LIMIT;
            }
        }
Beispiel #24
0
 public override void Invoke(SalePostContext context)
 {
     _next.Invoke(context);
 }
Beispiel #25
0
 public override void stageExecute(SalePostContext context)
 {
     SaleRepo.SaleBuilder builder = saleRepo.initialSaleBuilder();
     context.SaleBuilder = (SaleRepo)builder;
     nextStage(context);
 }
Beispiel #26
0
 protected override void stageExecute(SalePostContext context)
 {
     //throw new NotImplementedException();
 }
Beispiel #27
0
        //public SalePostSetupContext(SalePostFailedSaleCreation nxt) : base(nxt)
        //{
        //    _nextStage = nxt;
        //}

        //public override void Invoke(SalePostContext context)
        //{
        //    SaleRepo.SaleBuilder builder = _saleRepo.initialSaleBuilder();
        //    context.SaleBuilder = (SaleRepo)builder;
        //    _next.Invoke(context);
        //}

        protected internal override void stageExecute(SalePostContext context)
        {
            SaleRepo.SaleBuilder builder = _saleRepo.initialSaleBuilder();
            context.SaleBuilder = (SaleRepo)builder;
            nextStg(context);
        }
Beispiel #28
0
 public void stageExecute(SalePostContext context)
 {
     //throw new NotImplementedException();
 }