Ejemplo n.º 1
0
        public ReceiveData ValidateUntilReadyForCommitForReceive(ReceiveData receiveData)
        {
            try
            {
                // Get the all fields grouping and types for generation
                receiveData.Set(_gafOperations.GetInfoKeysWithGroupTypes(receiveData.ReceiveRequest.AgentId, receiveData.ReceiveRequest.AgentPos, receiveData.GafInfoKeysWithGroups, GetAllFieldsTransactionType.Receive));
                // Transaction Lookup Request
                CreateTransactionLookupRequest(receiveData);
                // Transaction Lookup Response
                TransactionLookup(receiveData);

                // Initial Validate Receive
                _validationOperations.RecvValidate(receiveData, TestThirdPartyType.None);
                if (DataErrorHandler.CheckForNestedErrors(receiveData).Any())
                {
                    throw new AgentConnectException();
                }
                _validationOperations.RecvValidateUntilReadyForCommit(receiveData);
                if (DataErrorHandler.CheckForNestedErrors(receiveData).Any())
                {
                    throw new AgentConnectException();
                }
            }
            catch (AgentConnectException acExp)
            {
                receiveData.Set(new BusinessError
                {
                    ErrorCategory = "AC Exception",
                    ErrorCode     = acExp.ErrorCode.ToString(),
                    Message       = acExp.Message
                });
            }
            return(receiveData);
        }
Ejemplo n.º 2
0
        private void CompleteSession(ReceiveData receiveData)
        {
            receiveData.ReceiveRequest.PopulateAgentData(receiveData.ReceiveRequest.AgentState);
            var mgiSessionId = receiveData.ReceiveValidationResponses.Last().Payload.MgiSessionID;

            receiveData.Set(CompleteSessionRequestFactory.CompleteRecvRequest(mgiSessionId));
            if (receiveData.Staging)
            {
                receiveData.CompleteSessionRequest.Commit = false;
            }
            receiveData.CompleteSessionRequest.AgentID       = receiveData.ReceiveRequest.AgentId;
            receiveData.CompleteSessionRequest.AgentSequence = receiveData.ReceiveRequest.AgentPos;

            receiveData.Set(AcIntegration.CompleteSession(receiveData.CompleteSessionRequest));
        }
Ejemplo n.º 3
0
        public ReceiveData TransactionLookupForReceiveCompletion(ReceiveData receiveData)
        {
            receiveData.ReceiveRequest.PopulateAgentData(receiveData.ReceiveRequest.AgentState);
            var transactionLookupRequest =
                TransactionLookupRequestFactory.TransanctionLookupRequestForReceiveCompletion(receiveData.SendData.CompleteSessionResp.Payload.ReferenceNumber);

            transactionLookupRequest.AgentID       = receiveData.ReceiveRequest.AgentId;
            transactionLookupRequest.AgentSequence = receiveData.ReceiveRequest.AgentPos;

            receiveData.Set(transactionLookupRequest);
            var transactionLookupResponse =
                AcIntegration.TransactionLookup(receiveData.TransactionLookupRequest);

            receiveData.Set(transactionLookupResponse);            //TODO: This was StagedTransactionLookupRequest
            return(receiveData);
        }
Ejemplo n.º 4
0
        public void Recv_Complete()
        {
            var sendRequest = new SendRequest
            {
                AgentState = AgentLocation.MN,
                Country    = Country.Usa,
                State      = State.Ny,
                SendCurr   = Currency.Usd,
                AmtRange   = AmountRange.NoIdsNoThirdParty,
                FeeType    = ItemChoiceType1.amountExcludingFee
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);
            var sendData       = new SendData(sendRequest);
            var receiveRequest = new ReceiveRequest
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);

            var receiveData = new ReceiveData(receiveRequest);

            sendData = SendOperations.SendCompleteForNewCustomer(sendData);
            receiveData.Set(sendData);
            receiveData = ReceiveOperations.ReceiveComplete(receiveData);
            var transLookupResponse = TranLookupOperations.TransactionLookupForStatus(receiveRequest.AgentId, receiveRequest.AgentPos, receiveData.CompleteSessionResponse.Payload.ReferenceNumber);

            // ASSERT ALL THE THINGS
            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsFalse(receiveData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsTrue(transLookupResponse.TransactionLookupResp.Payload.TransactionStatus == TransactionStatusType.RECVD);
        }
Ejemplo n.º 5
0
        public void Recv_ValidationUntilReadyForCommit()
        {
            var sendRequest = new SendRequest
            {
                AgentState = AgentLocation.MN,
                Country    = Country.Usa,
                State      = State.Ny,
                SendCurr   = Currency.Usd,
                AmtRange   = AmountRange.NoIdsNoThirdParty,
                FeeType    = ItemChoiceType1.amountExcludingFee
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);
            var sendData       = new SendData(sendRequest);
            var receiveRequest = new ReceiveRequest
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);

            var receiveData = new ReceiveData(receiveRequest);

            SendOperations.SendCompleteForNewCustomer(sendData);
            receiveData.Set(sendData);
            ReceiveOperations.ValidateUntilReadyForCommitForReceive(receiveData);

            var receiveValidationResponse = receiveData.ReceiveValidationResponses?.FirstOrDefault();

            // ASSERT ALL THE THINGS
            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsTrue(receiveValidationResponse != null && receiveValidationResponse.Payload.ReadyForCommit);
        }
Ejemplo n.º 6
0
        public void ReceiveReversal_TransactionLookup()
        {
            //PERFORM send
            var sendRequest = new SendRequest
            {
                AgentState    = AgentLocation.MN,
                Country       = Country.Usa,
                State         = State.Ny,
                SendCurr      = Currency.Usd,
                AmtRange      = AmountRange.NoIdsNoThirdParty,
                FeeType       = ItemChoiceType1.amountExcludingFee,
                ServiceOption = ServiceOptionType.WillCall
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);
            var sendData = new SendData(sendRequest);

            sendData = _sendOperations.SendCompleteForExistingCustomer(sendData);

            //ASSERT send
            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");

            //PERFORM receive
            var receiveRequest = new ReceiveRequest
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);
            var receiveData = new ReceiveData(receiveRequest);

            receiveData.Set(sendData);
            _recvOperations.ReceiveComplete(receiveData);

            //ASSERT receive
            Assert.IsFalse(receiveData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveData.Errors?.Log()}");

            //PERFORM transaction lookup
            var request = new ReceiveReversalOperationRequest
            {
                AgentState      = AgentLocation.NY,
                ReferenceNumber = receiveData.SendData.CompleteSessionResp.Payload.ReferenceNumber
            };

            request.PopulateAgentData(request.AgentState);
            var receiveReversalData = new ReceiveReversalData(request);

            receiveReversalOperations.TransactionLookup(receiveReversalData);
            var transLookupResponse = receiveReversalData.TransactionLookup.TransactionLookupResp;

            //ASSERT transaction lookup
            Assert.IsTrue(transLookupResponse.Payload.TransactionStatus == TransactionStatusType.RECVD);
            Assert.IsFalse(receiveReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveReversalData.Errors?.Log()}");
            Assert.IsFalse(string.IsNullOrEmpty(transLookupResponse.Payload.MgiSessionID));
        }
Ejemplo n.º 7
0
        public void ReceiveReversal_ShouldSucceedForReceivingAgent()
        {
            //PERFORM send
            var sendRequest = new SendRequest
            {
                AgentState    = AgentLocation.MN,
                Country       = Country.Usa,
                State         = State.Ny,
                SendCurr      = Currency.Usd,
                AmtRange      = AmountRange.NoIdsNoThirdParty,
                FeeType       = ItemChoiceType1.amountExcludingFee,
                ServiceOption = ServiceOptionType.WillCall
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);
            var sendData = new SendData(sendRequest);

            sendData = _sendOperations.SendCompleteForExistingCustomer(sendData);

            //ASSERT send
            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");

            //PERFORM receive
            var receiveRequest = new ReceiveRequest
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);
            var receiveData = new ReceiveData(receiveRequest);

            receiveData.Set(sendData);
            _recvOperations.ReceiveComplete(receiveData);

            //ASSERT receive
            Assert.IsFalse(receiveData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveData.Errors?.Log()}");

            //Get the transaction reference number

            //ReceiveReversal with single validate
            var request = new ReceiveReversalOperationRequest
            {
                AgentState      = AgentLocation.NY,
                ReferenceNumber = receiveData.SendData.CompleteSessionResp.Payload.ReferenceNumber
            };

            request.PopulateAgentData(request.AgentState);

            var receiveReversalData    = receiveReversalOperations.SingleValidate(request);
            var lastValidationResponse = receiveReversalData.ValidationResponses.LastOrDefault();

            // ASSERT ALL THE THINGS
            Assert.IsFalse(receiveReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveReversalData.Errors?.Log()}");
            Assert.IsTrue(lastValidationResponse.Payload.ReadyForCommit || lastValidationResponse.Payload.FieldsToCollect.Any());
        }
Ejemplo n.º 8
0
        private void TransactionLookup(ReceiveData receiveData)
        {
            receiveData.ReceiveRequest.PopulateAgentData(receiveData.ReceiveRequest.AgentState);
            if (receiveData.TransactionLookupRequest == null)
            {
                CreateTransactionLookupRequest(receiveData);
            }
            receiveData.TransactionLookupRequest.AgentID       = receiveData.ReceiveRequest.AgentId;
            receiveData.TransactionLookupRequest.AgentSequence = receiveData.ReceiveRequest.AgentPos;

            receiveData.Set(AcIntegration.TransactionLookup(receiveData.TransactionLookupRequest));
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Implements transaction for Send
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns>Transaction result</returns>
        public override ITransactionResult Transaction(object parameters)
        {
            var sendParameters = (SendParameters)parameters;

            TestConfig.TestSettings = new IntegrationTestSettingsModel {
                AcEnvironment = sendParameters.Environment
            };

            var amtRangeParsed       = Enum.TryParse(sendParameters?.AmtRange, true, out AmountRange amtRange);
            var itemChoiceTypeParsed = Enum.TryParse(sendParameters?.FeeType, true, out ItemChoiceType1 itemChoiceType);
            var sendRequest          = new SendRequest
            {
                Environment         = sendParameters.Environment,
                AgentCountryIsoCode = sendParameters.AgentCountryIsoCode,
                AgentId             = sendParameters.AgentId,
                AgentPos            = sendParameters.AgentPos,
                AgentState          = sendParameters.GetAgentState(),
                Amount         = (double)sendParameters.CustomAmount,
                AmtRange       = amtRangeParsed ? amtRange : AmountRange.CustomAmount,
                Country        = sendParameters.Country,
                State          = sendParameters.State,
                FeeType        = itemChoiceTypeParsed ? itemChoiceType : ItemChoiceType1.amountExcludingFee,
                SendCurr       = sendParameters.SendCurr,
                ServiceOption  = sendParameters.ServiceOption,
                ThirdPartyType = sendParameters.ThirdPartyType
            };
            var receiveAgentState = sendParameters.State.Split('-')[1];
            var receiveRequest    = new ReceiveRequest
            {
                AgentState     = receiveAgentState,
                ThirdPartyType = sendParameters.ThirdPartyType
            };

            var sendData = new SendData(sendRequest);

            sendData = SendOperations.SendCompleteForNewCustomer(sendData);

            var receiveData = new ReceiveData(receiveRequest);

            receiveData.Set(sendData);
            receiveData = ReceiveOperations.ReceiveCompleteStaged(receiveData);

            return(new TransactionResult {
                Result = receiveData
            });
        }
Ejemplo n.º 10
0
        public void ReceiveReversalTransaction_Complete()
        {
            var sendRequest = new SendRequest
            {
                AgentState    = AgentLocation.MN,
                Country       = Country.Usa,
                State         = State.Ny,
                SendCurr      = Currency.Usd,
                AmtRange      = AmountRange.UnderOneHundred,
                FeeType       = ItemChoiceType1.amountExcludingFee,
                ServiceOption = ServiceOptionType.WillCall
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);
            var sendData       = new SendData(sendRequest);
            var receiveRequest = new ReceiveRequest
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);

            var receiveData = new ReceiveData(receiveRequest);

            sendData = _sendOperations.SendCompleteForExistingCustomer(sendData);
            receiveData.Set(sendData);
            _recvOperations.ReceiveComplete(receiveData);

            //Get the transaction reference number

            var request = new ReceiveReversalOperationRequest
            {
                AgentState      = AgentLocation.NY,
                ReferenceNumber = receiveData.SendData.CompleteSessionResp.Payload.ReferenceNumber
            };

            request.PopulateAgentData(request.AgentState);

            var receiveReversalData = receiveReversalOperations.ReceiveReversalComplete(request);

            Assert.IsFalse(receiveReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveReversalData.Errors?.Log()}");
            //Commented out as CompleteSessionResponse does not contain reference number when performing Receive Reversal. The above check for errors is enough.
            //Assert.IsFalse(string.IsNullOrEmpty(receiveReversalData.CompleteSessionResp.Payload.ReferenceNumber), "there was no reference number on the receive reversal completion response");
        }
Ejemplo n.º 11
0
        public void ReceiveReversalTransaction_ShouldFailForNonReceivingAgent()
        {
            var sendRequest = new SendRequest
            {
                AgentState    = AgentLocation.MN,
                Country       = Country.Usa,
                State         = State.Ny,
                SendCurr      = Currency.Usd,
                AmtRange      = AmountRange.NoIdsNoThirdParty,
                FeeType       = ItemChoiceType1.amountExcludingFee,
                ServiceOption = ServiceOptionType.WillCall
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);
            var sendData       = new SendData(sendRequest);
            var receiveRequest = new ReceiveRequest
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);

            var receiveData = new ReceiveData(receiveRequest);

            sendData = _sendOperations.SendCompleteForExistingCustomer(sendData);
            receiveData.Set(sendData);
            _recvOperations.ReceiveComplete(receiveData);

            var request = new ReceiveReversalOperationRequest
            {
                AgentState      = AgentLocation.MN,
                ReferenceNumber = receiveData.SendData.CompleteSessionResp.Payload.ReferenceNumber
            };

            request.PopulateAgentData(request.AgentState);

            var receiveReversalData = receiveReversalOperations.SingleValidate(request);

            Assert.IsFalse(receiveReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveReversalData.Errors?.Log()}");

            var lastValidationResponse = receiveReversalData.ValidationResponses.LastOrDefault();

            Assert.IsTrue(lastValidationResponse.Errors.Any());
        }
Ejemplo n.º 12
0
        public void Recv_StageReceive_SmallAmount_NewCustomer()
        {
            var sendRequest = new SendRequest
            {
                AgentState     = AgentLocation.MN,
                Country        = Country.Usa,
                State          = State.Ny,
                SendCurr       = Currency.Usd,
                AmtRange       = AmountRange.UnderOneHundred,
                FeeType        = ItemChoiceType1.amountExcludingFee,
                ThirdPartyType = TestThirdPartyType.None
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);

            var sendData = new SendData(sendRequest);

            sendData = SendOperations.SendCompleteForNewCustomer(sendData);
            var receiveRequest = new ReceiveRequest()
            {
                AgentState     = AgentLocation.NY,
                ThirdPartyType = TestThirdPartyType.None
            };

            receiveRequest.PopulateAgentData(receiveRequest.AgentState);
            var receiveData = new ReceiveData(receiveRequest);

            receiveData.Set(sendData);

            receiveData = ReceiveOperations.ReceiveCompleteStaged(receiveData);
            receiveData = ReceiveOperations.TransactionLookupForReceiveCompletion(receiveData);

            // ASSERT ALL THE THINGS
            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsFalse(receiveData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsFalse(receiveData.TransactionLookupResponse.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{receiveData.TransactionLookupResponse.Errors?.Log()}");
            Assert.IsTrue(receiveData.TransactionLookupResponse.Payload.TransactionStatus == TransactionStatusType.AVAIL);
        }