コード例 #1
0
        public AmendValidationResponse AmendValidation(AmendData amendData)
        {
            var agentData     = amendData.AmendOperationRequest;
            var validationReq = amendData.ValidationRequests.LastOrDefault();
            var agent         = _agents.GetAgent(agentData.AgentId, agentData.AgentPos);

            _agentConnectConfig.DecorateRequest(validationReq);
            var response = _testRunner.AgentConnect.AmendValidation(agent, validationReq);

            return(response);
        }
コード例 #2
0
        public TransactionLookupData TransactionLookupForAmend(AmendData amendData)
        {
            var transactionLookupData = new TransactionLookupData();

            transactionLookupData.Set(TransactionLookupRequestFactory.TransanctionLookupRequestForAmend(amendData.AmendOperationRequest.ReferenceNumber));
            var req = TransactionLookupRequestFactory.TransanctionLookupRequestForAmend(amendData.AmendOperationRequest.ReferenceNumber);

            req.AgentID       = amendData.AmendOperationRequest.AgentId;
            req.AgentSequence = amendData.AmendOperationRequest.AgentPos;
            transactionLookupData.Set(req);
            transactionLookupData.Set(_acIntegration.TransactionLookup(transactionLookupData.TransactionLookupReq));
            return(transactionLookupData);
        }
コード例 #3
0
        /// <summary>
        ///     Run this transaction
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></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 sendData = new SendData(sendRequest);

            sendData = SendOperations.SendCompleteForExistingCustomer(sendData);

            var referenceNumber = sendData?.CompleteSessionResp?.Payload?.ReferenceNumber;

            var amendRequest = new AmendOperationRequest
            {
                AgentState      = sendParameters.AgentState,
                ReferenceNumber = referenceNumber
            };

            amendRequest.PopulateAgentData(sendParameters.AgentState);
            var amendData = new AmendData(amendRequest);

            amendData.Set(sendData);
            AmendOperations.AmendComplete(amendData);

            return(new TransactionResult {
                Result = amendData
            });
        }
コード例 #4
0
        private void CompleteSession(AmendData amendData)
        {
            var mgiSessionId = amendData.ValidationResponses.Last().Payload.MgiSessionID;

            var completeSessionRequest = CompleteSessionRequestFactory.CompleteSendRequest(mgiSessionId);

            completeSessionRequest.AgentID        = amendData.AmendOperationRequest.AgentId;
            completeSessionRequest.MgiSessionType = SessionType.AMD;
            completeSessionRequest.AgentSequence  = amendData.AmendOperationRequest.AgentPos;
            var completeSessionResponse = _acIntegration.CompleteSession(completeSessionRequest);
            var errors = completeSessionResponse.Errors ?? new List <BusinessError>();

            amendData.Set(errors);

            amendData.Set(completeSessionRequest);
            amendData.Set(completeSessionResponse);
        }
コード例 #5
0
        public void Amend_ShouldSucceedForSendingAgent()
        {
            var sendRequest = new SendRequest
            {
                AgentState = AgentLocation.MN,
                Country    = Country.Usa,
                State      = State.Ny,
                SendCurr   = Currency.Usd,
                AmtRange   = AmountRange.NoIdsNoThirdParty,
                FeeType    = ItemChoiceType1.amountIncludingFee
            };

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

            sendData = sendOperations.SendCompleteForExistingCustomer(sendData);
            var sendCompleteSessionResponse = sendData.CompleteSessionResp;

            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsFalse(sendCompleteSessionResponse.Errors.Any(), "Send Failed.");

            //Get the transaction reference number
            string referenceNumber = sendCompleteSessionResponse.Payload?.ReferenceNumber;
            //Amend with single validate
            var request = new AmendOperationRequest
            {
                AgentState      = AgentLocation.MN,
                ReferenceNumber = referenceNumber
            };

            request.PopulateAgentData(request.AgentState);

            var amendData = new AmendData(request);

            amendData.Set(sendData);
            amendOperations.SingleValidate(amendData);
            Assert.IsFalse(amendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{amendData.Errors?.Log()}");
            amendOperations.AmendComplete(amendData);
            var lastAmendValidationResponse = amendData.ValidationResponses.LastOrDefault();

            // ASSERT ALL THE THINGS
            Assert.IsFalse(amendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{amendData.Errors?.Log()}");
            Assert.IsTrue(lastAmendValidationResponse.Payload.FieldsToCollect.Any());
        }
コード例 #6
0
        public void Amend_TransactionLookup()
        {
            var sendRequest = new SendRequest
            {
                AgentState = AgentLocation.MN,
                Country    = Country.Usa,
                State      = State.Ny,
                SendCurr   = Currency.Usd,
                AmtRange   = AmountRange.NoIdsNoThirdParty,
                FeeType    = ItemChoiceType1.amountIncludingFee
            };

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

            sendData = sendOperations.SendCompleteForExistingCustomer(sendData);
            var sendCompleteSessionResponse = sendData.CompleteSessionResp;

            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsFalse(sendCompleteSessionResponse.Errors.Any(), "Send Failed.");

            //Get the transaction reference number
            var referenceNumber = sendCompleteSessionResponse.Payload.ReferenceNumber;
            //Transaction lookup
            var request = new AmendOperationRequest
            {
                AgentState      = AgentLocation.MN,
                ReferenceNumber = referenceNumber
            };

            request.PopulateAgentData(request.AgentState);
            var amendData = new AmendData(request);

            amendData.Set(sendData);
            amendOperations.TransactionLookup(amendData);
            var tranLookupResponse = amendData.TransactionLookup.TransactionLookupResp;

            //ASSERT the resposne.
            Assert.IsFalse(tranLookupResponse.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{tranLookupResponse.Errors?.Log()}");
            Assert.IsTrue(tranLookupResponse.Payload.TransactionStatus == TransactionStatusType.AVAIL);
            Assert.IsFalse(string.IsNullOrEmpty(tranLookupResponse.Payload.MgiSessionID));
        }
コード例 #7
0
        public void TransactionLookup(AmendData amendData)
        {
            try
            {
                amendData.Set(_tranLookupOperations.TransactionLookupForAmend(amendData));
                var errors = amendData.TransactionLookup.TransactionLookupResp.Errors ?? new List <BusinessError>();
                amendData.Set(errors);
            }
            catch (AgentConnectException acExp)
            {
                var error = new BusinessError
                {
                    ErrorCategory = "AC Exception",
                    ErrorCode     = acExp.ErrorCode.ToString(),
                    Message       = acExp.Message
                };

                amendData.Set(error);
            }
        }
コード例 #8
0
        public AmendData SingleValidate(AmendData amendData)
        {
            try
            {
                // Get the all fields grouping and types for generation
                amendData.Set(_gafOperations.GetInfoKeysWithGroupTypes(amendData.AmendOperationRequest.AgentId, amendData.AmendOperationRequest.AgentPos, amendData.GafInfoKeysWithGroups, GetAllFieldsTransactionType.Amend));

                // Transaction Lookup
                TransactionLookup(amendData);
                if (DataErrorHandler.CheckForNestedErrors(amendData).Any())
                {
                    return(amendData);
                }

                if (amendData.TransactionLookup.TransactionLookupResp.Payload.TransactionStatus != TransactionStatusType.AVAIL)
                {
                    var error = new BusinessError
                    {
                        ErrorCategory = "Custom Error",
                        ErrorCode     = string.Empty,
                        Message       = "Transaction not available for AMEND."
                    };

                    amendData.Set(error);
                }
                // Validate Receive
                _validationOperations.AmendValidate(amendData);
            }
            catch (AgentConnectException acExp)
            {
                var error = new BusinessError
                {
                    ErrorCategory = "AC Exception",
                    ErrorCode     = acExp.ErrorCode.ToString(),
                    Message       = acExp.Message
                };

                amendData.Set(error);
            }
            return(amendData);
        }
コード例 #9
0
        public void AmendTransaction_Complete()
        {
            var sendRequest = new SendRequest
            {
                AgentState = AgentLocation.MN,
                Country    = Country.Usa,
                State      = State.Ny,
                SendCurr   = Currency.Usd,
                AmtRange   = AmountRange.NoIdsNoThirdParty,
                FeeType    = ItemChoiceType1.amountIncludingFee
            };

            sendRequest.PopulateAgentData(sendRequest.AgentState);

            var sendData = new SendData(sendRequest);

            sendData = sendOperations.SendCompleteForExistingCustomer(sendData);
            var sendCompleteSessionResponse = sendData.CompleteSessionResp;

            Assert.IsFalse(sendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendData.Errors?.Log()}");
            Assert.IsFalse(sendCompleteSessionResponse.Errors.Any(), "Send Failed.");

            string referenceNumber = sendCompleteSessionResponse.Payload?.ReferenceNumber;

            var request = new AmendOperationRequest
            {
                AgentState      = AgentLocation.MN,
                ReferenceNumber = referenceNumber
            };

            request.PopulateAgentData(request.AgentState);

            var amendData = new AmendData(request);

            amendData.Set(sendData);
            amendOperations.AmendComplete(amendData);
            Assert.IsFalse(amendData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{amendData.Errors?.Log()}");
            Assert.IsFalse(string.IsNullOrEmpty(amendData.CompleteSessionResp.Payload.ReferenceNumber));
        }
コード例 #10
0
        public AmendData AmendComplete(AmendData amendData)
        {
            try
            {
                // Get the all fields grouping and types for generation
                _gafOperations.GetInfoKeysWithGroupTypes(amendData.AmendOperationRequest.AgentId, amendData.AmendOperationRequest.AgentPos, amendData.GafInfoKeysWithGroups, GetAllFieldsTransactionType.Amend);

                // Transaction Lookup
                TransactionLookup(amendData);
                if (DataErrorHandler.CheckForNestedErrors(amendData).Any())
                {
                    return(amendData);
                }

                if (amendData.TransactionLookup.TransactionLookupResp.Payload.TransactionStatus != TransactionStatusType.AVAIL)
                {
                    var error = new BusinessError
                    {
                        ErrorCategory = "Custom Error",
                        ErrorCode     = string.Empty,
                        Message       = "Transaction not available for AMEND."
                    };

                    amendData.Set(error);
                }

                // Validate Amend
                _validationOperations.AmendValidate(amendData);

                // Final Validate(s)
                _validationOperations.AmendValidateUntilReadyForCommit(amendData);
                if (DataErrorHandler.CheckForNestedErrors(amendData).Any())
                {
                    return(amendData);
                }
                if (amendData.ValidationResponses.Last().Payload.ReadyForCommit)
                {
                    CompleteSession(amendData);
                }
                else
                {
                    var error = new BusinessError
                    {
                        ErrorCategory = "Custom Error",
                        ErrorCode     = string.Empty,
                        Message       = "Not ready to commit yet"
                    };

                    amendData.Set(error);
                }
            }
            catch (AgentConnectException acExp)
            {
                var error = new BusinessError
                {
                    ErrorCategory = "AC Exception",
                    ErrorCode     = acExp.ErrorCode.ToString(),
                    Message       = acExp.Message
                };

                amendData.Set(error);
            }
            return(amendData);
        }