public TransactionLookupData TransactionLookupForSendReversal(SendReversalData sendReversalData) { var transactionLookupData = new TransactionLookupData(); var req = TransactionLookupRequestFactory.TransanctionLookupRequestForSendReversal(sendReversalData.SendReversalRequest.ReferenceNumber); req.AgentID = sendReversalData.SendReversalRequest.AgentId; req.AgentSequence = sendReversalData.SendReversalRequest.AgentPos; transactionLookupData.Set(req); transactionLookupData.Set(_acIntegration.TransactionLookup(transactionLookupData.TransactionLookupReq)); return(transactionLookupData); }
public SendReversalValidationResponse SendReversalValidation(SendReversalData sendReversalData) { var agentData = sendReversalData.SendReversalRequest; var validationReq = sendReversalData.ValidationRequests.LastOrDefault(); var agent = _agents.GetAgent(agentData.AgentId, agentData.AgentPos); _agentConnectConfig.DecorateRequest(validationReq); var response = _testRunner.AgentConnect.SendReversalValidation(agent, validationReq); return(response); }
/// <summary> /// Run this transaction. /// </summary> /// <param name="parameters"></param> /// <returns></returns> public override ITransactionResult Transaction(object parameters) { var sendReversalParameters = (SendReversalParameters)parameters; TestConfig.TestSettings = new IntegrationTestSettingsModel { AcEnvironment = sendReversalParameters.Environment }; var amtRangeParsed = Enum.TryParse(sendReversalParameters.AmtRange, true, out AmountRange amtRange); var itemChoiceTypeParsed = Enum.TryParse(sendReversalParameters.FeeType, true, out ItemChoiceType1 itemChoiceType); var sendRequest = new SendRequest { Environment = sendReversalParameters.Environment, AgentCountryIsoCode = sendReversalParameters.AgentCountryIsoCode, AgentId = sendReversalParameters.AgentId, AgentPos = sendReversalParameters.AgentPos, AgentState = sendReversalParameters.GetAgentState(), Amount = (double)sendReversalParameters.CustomAmount, AmtRange = amtRangeParsed ? amtRange : AmountRange.CustomAmount, Country = sendReversalParameters.Country, State = sendReversalParameters.State, FeeType = itemChoiceTypeParsed ? itemChoiceType : ItemChoiceType1.amountExcludingFee, SendCurr = sendReversalParameters.SendCurr, ServiceOption = sendReversalParameters.ServiceOption, ThirdPartyType = sendReversalParameters.ThirdPartyType }; var sendData = new SendData(sendRequest); sendData = SendOperations.SendCompleteForNewCustomer(sendData); var sendReversalRequest = new SendReversalRequest { AgentId = sendReversalParameters.AgentId, AgentPos = sendReversalParameters.AgentPos, AgentCountryIsoCode = sendReversalParameters.AgentCountryIsoCode, AgentState = sendReversalParameters.AgentState, ReferenceNumber = sendData.CompleteSessionResp.Payload.ReferenceNumber, RefundReason = new EnumeratedIdentifierInfo { Identifier = sendReversalParameters.RefundReason }, RefundFee = sendReversalParameters.RefundFee }; var sendReversalData = new SendReversalData(sendReversalRequest); sendReversalData = SendReversalOperations.SendReversalComplete(sendReversalData); return(new TransactionResult { Result = sendReversalData }); }
private SendReversalData CompleteSession(SendReversalData sendReversalData) { var mgiSessionId = sendReversalData.ValidationResponses.Last().Payload.MgiSessionID; var completeSessionRequest = CompleteSessionRequestFactory.CompleteSendReversalRequest(mgiSessionId); completeSessionRequest.AgentID = sendReversalData.SendReversalRequest.AgentId; completeSessionRequest.AgentSequence = sendReversalData.SendReversalRequest.AgentPos; sendReversalData.Set(completeSessionRequest); var completeSessionResponse = _acIntegration.CompleteSession(completeSessionRequest); var errors = completeSessionResponse.Errors ?? new List <BusinessError>(); sendReversalData.Set(errors); sendReversalData.Set(completeSessionResponse); return(sendReversalData); }
public void SendReversal_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; //SendReversal with single validate var sendReversalRequest = new SendReversalRequest { AgentState = AgentLocation.MN, ReferenceNumber = referenceNumber }; sendReversalRequest.PopulateAgentData(sendReversalRequest.AgentState); var sendReversalData = new SendReversalData(sendReversalRequest); sendReversalData = sendReversalOperations.SingleValidate(sendReversalData); var lastValidationResponse = sendReversalData.ValidationResponses.LastOrDefault(); // ASSERT ALL THE THINGS Assert.IsFalse(sendReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendReversalData.Errors?.Log()}"); Assert.IsTrue(lastValidationResponse.Payload.ReadyForCommit || lastValidationResponse.Payload.FieldsToCollect.Any()); }
public void SendReversal_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 sendReversalRequest = new SendReversalRequest { AgentState = AgentLocation.MN, ReferenceNumber = referenceNumber }; sendReversalRequest.PopulateAgentData(sendReversalRequest.AgentState); var sendReversalData = new SendReversalData(sendReversalRequest); sendReversalData = sendReversalOperations.TransactionLookup(sendReversalData); var tranLookupResponse = sendReversalData.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)); }
public void SendReversalTransaction_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 sendReversalRequest = new SendReversalRequest { AgentState = AgentLocation.MN, ReferenceNumber = referenceNumber, RefundReason = new EnumeratedIdentifierInfo { Identifier = "NO_RCV_LOC" }, RefundFee = true }; sendReversalRequest.PopulateAgentData(sendReversalRequest.AgentState); var sendReversalData = new SendReversalData(sendReversalRequest); sendReversalData = sendReversalOperations.SendReversalComplete(sendReversalData); Assert.IsFalse(sendReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendReversalData.Errors?.Log()}"); Assert.IsFalse(string.IsNullOrEmpty(sendReversalData.CompleteSessionResp.Payload.ReferenceNumber)); }
public void SendReversalTransaction_ShouldFailForNonSendingAgent() { 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 sendReversalRequest = new SendReversalRequest { AgentState = AgentLocation.NY, ReferenceNumber = referenceNumber }; sendReversalRequest.PopulateAgentData(sendReversalRequest.AgentState); var sendReversalData = new SendReversalData(sendReversalRequest); sendReversalData = sendReversalOperations.SingleValidate(sendReversalData); Assert.IsFalse(sendReversalData.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{sendReversalData.Errors?.Log()}"); var lastValidationResponse = sendReversalData.ValidationResponses.LastOrDefault(); Assert.IsTrue(lastValidationResponse.Errors.Any()); }
public SendReversalData TransactionLookup(SendReversalData sendReversalData) { try { sendReversalData.Set(_tranLookupOperations.TransactionLookupForSendReversal(sendReversalData)); var errors = sendReversalData.TransactionLookup.TransactionLookupResp.Errors ?? new List <BusinessError>(); sendReversalData.Set(errors); } catch (AgentConnectException acExp) { var error = new BusinessError { ErrorCategory = "AC Exception", ErrorCode = acExp.ErrorCode.ToString(), Message = acExp.Message }; sendReversalData.Set(error); } return(sendReversalData); }
public SendReversalData SingleValidate(SendReversalData sendReversalData) { try { // Transaction Lookup TransactionLookup(sendReversalData); if (DataErrorHandler.CheckForNestedErrors(sendReversalData).Any()) { return(sendReversalData); } if (sendReversalData.TransactionLookup.TransactionLookupResp.Payload.TransactionStatus != TransactionStatusType.AVAIL) { var error = new BusinessError { ErrorCategory = "Custom Error", ErrorCode = string.Empty, Message = "Transaction not available for Send Reversal." }; sendReversalData.Set(error); } // Validate Receive _validationOperations.SendReversalValidate(sendReversalData); } catch (AgentConnectException acExp) { var error = new BusinessError { ErrorCategory = "AC Exception", ErrorCode = acExp.ErrorCode.ToString(), Message = acExp.Message }; sendReversalData.Set(error); } return(sendReversalData); }
public SendReversalData SendReversalComplete(SendReversalData sendReversalData) { try { // Transaction Lookup TransactionLookup(sendReversalData); if (DataErrorHandler.CheckForNestedErrors(sendReversalData).Any()) { return(sendReversalData); } if (sendReversalData.TransactionLookup.TransactionLookupResp.Payload.TransactionStatus != TransactionStatusType.AVAIL) { var error = new BusinessError { ErrorCategory = "Custom Error", ErrorCode = string.Empty, Message = "Transaction not available for SendReversal." }; sendReversalData.Set(error); } // Validate SendReversal _validationOperations.SendReversalValidate(sendReversalData); // Final Validate(s) _validationOperations.SendReversalValidateUntilReadyForCommit(sendReversalData); if (DataErrorHandler.CheckForNestedErrors(sendReversalData).Any()) { return(sendReversalData); } if (sendReversalData.ValidationResponses.Last().Payload.ReadyForCommit) { CompleteSession(sendReversalData); } else { var error = new BusinessError { ErrorCategory = "Custom Error", ErrorCode = string.Empty, Message = "Not ready to commit yet" }; sendReversalData.Set(error); } } catch (AgentConnectException acExp) { var error = new BusinessError { ErrorCategory = "AC Exception", ErrorCode = acExp.ErrorCode.ToString(), Message = acExp.Message }; sendReversalData.Set(error); } return(sendReversalData); }