From 90ffce5dbd845db5271176c22ebc104a0e88b07e Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 15 Apr 2020 14:23:37 +0100 Subject: [PATCH] Operator Id now recorded --- .../TransactionAggregateManagerTests.cs | 8 ++ .../Services/ITransactionAggregateManager.cs | 8 ++ .../Services/TransactionAggregateManager.cs | 17 +++- .../Services/TransactionDomainService.cs | 6 +- TransactionProcessor.Testing/TestData.cs | 5 +- .../AdditionalRequestDataRecordedEvent.cs | 18 +++- .../AdditionalResponseDataRecordedEvent.cs | 18 +++- .../TransactionAuthorisedByOperatorEvent.cs | 15 ++++ .../TransactionDeclinedByOperatorEvent.cs | 17 ++++ .../DomainEventTests.cs | 8 ++ .../TransactionAggregateTests.cs | 83 ++++++++++--------- .../TransactionAggregate.cs | 20 +++-- 12 files changed, 164 insertions(+), 59 deletions(-) diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs index 455a8e5e..0f6b308c 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs @@ -29,6 +29,7 @@ public async Task TransactionAggregateManager_AuthoriseTransaction_TransactionAu await transactionAggregateManager.AuthoriseTransaction(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.OperatorResponse, TestData.TransactionResponseCodeSuccess, TestData.ResponseMessage, @@ -62,6 +63,7 @@ public async Task TransactionAggregateManager_DeclineTransaction_TransactionDecl await transactionAggregateManager.DeclineTransaction(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.OperatorResponse, TestData.TransactionResponseCodeDeclinedByOperator, TestData.ResponseMessage, @@ -110,6 +112,7 @@ public async Task TransactionAggregateManager_RecordAdditionalRequestData_Additi await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData, CancellationToken.None); } @@ -125,6 +128,7 @@ public async Task TransactionAggregateManager_RecordAdditionalRequestData_NullAd await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.NullAdditionalTransactionMetaData, CancellationToken.None); } @@ -140,6 +144,7 @@ public async Task TransactionAggregateManager_RecordAdditionalRequestData_EmptyA await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.EmptyAdditionalTransactionMetaData, CancellationToken.None); } @@ -155,6 +160,7 @@ public async Task TransactionAggregateManager_RecordAdditionalResponseData_Addit await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData, CancellationToken.None); } @@ -170,6 +176,7 @@ public async Task TransactionAggregateManager_RecordAdditionalResponseData_NullA await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.NullAdditionalTransactionMetaData, CancellationToken.None); } @@ -185,6 +192,7 @@ public async Task TransactionAggregateManager_RecordAdditionalResponseData_Empty await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId, TestData.TransactionId, + TestData.OperatorIdentifier1, TestData.EmptyAdditionalTransactionMetaData, CancellationToken.None); } diff --git a/TransactionProcessor.BusinessLogic/Services/ITransactionAggregateManager.cs b/TransactionProcessor.BusinessLogic/Services/ITransactionAggregateManager.cs index aa9240b6..efc7b946 100644 --- a/TransactionProcessor.BusinessLogic/Services/ITransactionAggregateManager.cs +++ b/TransactionProcessor.BusinessLogic/Services/ITransactionAggregateManager.cs @@ -20,6 +20,7 @@ public interface ITransactionAggregateManager /// /// The estate identifier. /// The transaction identifier. + /// The operator identifier. /// The operator response. /// The transaction response code. /// The response message. @@ -27,6 +28,7 @@ public interface ITransactionAggregateManager /// Task AuthoriseTransaction(Guid estateId, Guid transactionId, + String operatorIdentifier, OperatorResponse operatorResponse, TransactionResponseCode transactionResponseCode, String responseMessage, @@ -63,6 +65,7 @@ Task CompleteTransaction(Guid estateId, /// /// The estate identifier. /// The transaction identifier. + /// The operator identifier. /// The operator response. /// The transaction response code. /// The response message. @@ -70,6 +73,7 @@ Task CompleteTransaction(Guid estateId, /// Task DeclineTransaction(Guid estateId, Guid transactionId, + String operatorIdentifier, OperatorResponse operatorResponse, TransactionResponseCode transactionResponseCode, String responseMessage, @@ -104,11 +108,13 @@ Task GetAggregate(Guid estateId, /// /// The estate identifier. /// The transaction identifier. + /// The operator identifier. /// The additional transaction request metadata. /// The cancellation token. /// Task RecordAdditionalRequestData(Guid estateId, Guid transactionId, + String operatorIdentifier, Dictionary additionalTransactionRequestMetadata, CancellationToken cancellationToken); @@ -117,11 +123,13 @@ Task RecordAdditionalRequestData(Guid estateId, /// /// The estate identifier. /// The transaction identifier. + /// The operator identifier. /// The additional transaction response metadata. /// The cancellation token. /// Task RecordAdditionalResponseData(Guid estateId, Guid transactionId, + String operatorIdentifier, Dictionary additionalTransactionResponseMetadata, CancellationToken cancellationToken); diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs b/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs index da6cc1a1..1056961a 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs @@ -46,12 +46,15 @@ public TransactionAggregateManager(IAggregateRepositoryManager aggregateReposito /// /// The estate identifier. /// The transaction identifier. + /// The operator identifier. /// The operator response. /// The transaction response code. /// The response message. /// The cancellation token. + /// public async Task AuthoriseTransaction(Guid estateId, Guid transactionId, + String operatorIdentifier, OperatorResponse operatorResponse, TransactionResponseCode transactionResponseCode, String responseMessage, @@ -62,7 +65,8 @@ public async Task AuthoriseTransaction(Guid estateId, TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); - transactionAggregate.AuthoriseTransaction(operatorResponse.AuthorisationCode, + transactionAggregate.AuthoriseTransaction(operatorIdentifier, + operatorResponse.AuthorisationCode, operatorResponse.ResponseCode, operatorResponse.ResponseMessage, operatorResponse.TransactionId, @@ -129,6 +133,7 @@ public async Task CompleteTransaction(Guid estateId, /// The cancellation token. public async Task DeclineTransaction(Guid estateId, Guid transactionId, + String operatorIdentifier, OperatorResponse operatorResponse, TransactionResponseCode transactionResponseCode, String responseMessage, @@ -139,7 +144,8 @@ public async Task DeclineTransaction(Guid estateId, TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); - transactionAggregate.DeclineTransaction(operatorResponse.ResponseCode, + transactionAggregate.DeclineTransaction(operatorIdentifier, + operatorResponse.ResponseCode, operatorResponse.ResponseMessage, ((Int32)transactionResponseCode).ToString().PadLeft(4, '0'), responseMessage); @@ -192,10 +198,12 @@ public async Task GetAggregate(Guid estateId, /// /// The estate identifier. /// The transaction identifier. + /// The operator identifier. /// The additional transaction request metadata. /// The cancellation token. public async Task RecordAdditionalRequestData(Guid estateId, Guid transactionId, + String operatorIdentifier, Dictionary additionalTransactionRequestMetadata, CancellationToken cancellationToken) { @@ -206,7 +214,7 @@ public async Task RecordAdditionalRequestData(Guid estateId, TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); - transactionAggregate.RecordAdditionalRequestData(additionalTransactionRequestMetadata); + transactionAggregate.RecordAdditionalRequestData(operatorIdentifier, additionalTransactionRequestMetadata); await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } @@ -221,6 +229,7 @@ public async Task RecordAdditionalRequestData(Guid estateId, /// The cancellation token. public async Task RecordAdditionalResponseData(Guid estateId, Guid transactionId, + String operatorIdentifier, Dictionary additionalTransactionResponseMetadata, CancellationToken cancellationToken) { @@ -231,7 +240,7 @@ public async Task RecordAdditionalResponseData(Guid estateId, TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); - transactionAggregate.RecordAdditionalResponseData(additionalTransactionResponseMetadata); + transactionAggregate.RecordAdditionalResponseData(operatorIdentifier, additionalTransactionResponseMetadata); await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs index 124bffb1..1ae5b478 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs @@ -188,7 +188,7 @@ await this.TransactionAggregateManager.StartTransaction(transactionId, if (validationResult.responseCode == TransactionResponseCode.Success) { // Record any additional request metadata - await this.TransactionAggregateManager.RecordAdditionalRequestData(estateId, transactionId, additionalTransactionMetadata, cancellationToken); + await this.TransactionAggregateManager.RecordAdditionalRequestData(estateId, transactionId, operatorIdentifier, additionalTransactionMetadata, cancellationToken); // Do the online processing with the operator here MerchantResponse merchant = await this.GetMerchant(estateId, merchantId, cancellationToken); @@ -202,6 +202,7 @@ await this.TransactionAggregateManager.StartTransaction(transactionId, await this.TransactionAggregateManager.AuthoriseTransaction(estateId, transactionId, + operatorIdentifier, operatorResponse, transactionResponseCode, responseMessage, @@ -214,6 +215,7 @@ await this.TransactionAggregateManager.AuthoriseTransaction(estateId, await this.TransactionAggregateManager.DeclineTransaction(estateId, transactionId, + operatorIdentifier, operatorResponse, transactionResponseCode, responseMessage, @@ -221,7 +223,7 @@ await this.TransactionAggregateManager.DeclineTransaction(estateId, } // Record any additional operator response metadata - await this.TransactionAggregateManager.RecordAdditionalResponseData(estateId, transactionId, operatorResponse.AdditionalTransactionResponseMetadata, cancellationToken); + await this.TransactionAggregateManager.RecordAdditionalResponseData(estateId, transactionId, operatorIdentifier, operatorResponse.AdditionalTransactionResponseMetadata, cancellationToken); } else diff --git a/TransactionProcessor.Testing/TestData.cs b/TransactionProcessor.Testing/TestData.cs index a7a1b12d..3959afe2 100644 --- a/TransactionProcessor.Testing/TestData.cs +++ b/TransactionProcessor.Testing/TestData.cs @@ -444,10 +444,11 @@ public static TransactionAggregate GetDeclinedTransactionAggregate(TransactionRe TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, + TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.GetResponseCodeAsString(transactionResponseCode), - TestData.GetResponseCodeMessage(transactionResponseCode)); + TestData.GetResponseCodeMessage(transactionResponseCode)); return transactionAggregate; } diff --git a/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs index 2783a08f..7cb990cc 100644 --- a/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs +++ b/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs @@ -14,22 +14,25 @@ public class AdditionalRequestDataRecordedEvent : DomainEvent #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The aggregate identifier. /// The event identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The additional transaction request metadata. public AdditionalRequestDataRecordedEvent(Guid aggregateId, Guid eventId, Guid estateId, Guid merchantId, + String operatorIdentifier, Dictionary additionalTransactionRequestMetadata) : base(aggregateId, eventId) { this.TransactionId = aggregateId; this.EstateId = estateId; this.MerchantId = merchantId; + this.OperatorIdentifier = operatorIdentifier; this.AdditionalTransactionRequestMetadata = additionalTransactionRequestMetadata; } @@ -64,6 +67,15 @@ public AdditionalRequestDataRecordedEvent(Guid aggregateId, [JsonProperty] public Guid MerchantId { get; private set; } + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty] + public String OperatorIdentifier { get; private set; } + /// /// Gets the transaction identifier. /// @@ -83,14 +95,16 @@ public AdditionalRequestDataRecordedEvent(Guid aggregateId, /// The aggregate identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The additional transaction request metadata. /// public static AdditionalRequestDataRecordedEvent Create(Guid aggregateId, Guid estateId, Guid merchantId, + String operatorIdentifier, Dictionary additionalTransactionRequestMetadata) { - return new AdditionalRequestDataRecordedEvent(aggregateId, Guid.NewGuid(), estateId, merchantId, additionalTransactionRequestMetadata); + return new AdditionalRequestDataRecordedEvent(aggregateId, Guid.NewGuid(), estateId, merchantId, operatorIdentifier, additionalTransactionRequestMetadata); } #endregion diff --git a/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs index 00233bc6..f516782a 100644 --- a/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs +++ b/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs @@ -14,22 +14,25 @@ public class AdditionalResponseDataRecordedEvent : DomainEvent #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The aggregate identifier. /// The event identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The additional transaction response metadata. public AdditionalResponseDataRecordedEvent(Guid aggregateId, Guid eventId, Guid estateId, Guid merchantId, + String operatorIdentifier, Dictionary additionalTransactionResponseMetadata) : base(aggregateId, eventId) { this.TransactionId = aggregateId; this.EstateId = estateId; this.MerchantId = merchantId; + this.OperatorIdentifier = operatorIdentifier; this.AdditionalTransactionResponseMetadata = additionalTransactionResponseMetadata; } @@ -64,6 +67,15 @@ public AdditionalResponseDataRecordedEvent(Guid aggregateId, [JsonProperty] public Guid MerchantId { get; private set; } + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty] + public String OperatorIdentifier { get; private set; } + /// /// Gets the transaction identifier. /// @@ -83,14 +95,16 @@ public AdditionalResponseDataRecordedEvent(Guid aggregateId, /// The aggregate identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The additional transaction response metadata. /// public static AdditionalResponseDataRecordedEvent Create(Guid aggregateId, Guid estateId, Guid merchantId, + String operatorIdentifier, Dictionary additionalTransactionResponseMetadata) { - return new AdditionalResponseDataRecordedEvent(aggregateId, Guid.NewGuid(), estateId, merchantId, additionalTransactionResponseMetadata); + return new AdditionalResponseDataRecordedEvent(aggregateId, Guid.NewGuid(), estateId, merchantId, operatorIdentifier, additionalTransactionResponseMetadata); } #endregion diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs index 4c8ebc8f..2cf9988e 100644 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs +++ b/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs @@ -22,6 +22,7 @@ public TransactionAuthorisedByOperatorEvent() /// The event identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The authorisation code. /// The operator response code. /// The operator response message. @@ -32,6 +33,7 @@ public TransactionAuthorisedByOperatorEvent(Guid aggregateId, Guid eventId, Guid estateId, Guid merchantId, + String operatorIdentifier, String authorisationCode, String operatorResponseCode, String operatorResponseMessage, @@ -42,6 +44,7 @@ public TransactionAuthorisedByOperatorEvent(Guid aggregateId, this.TransactionId = aggregateId; this.EstateId = estateId; this.MerchantId = merchantId; + this.OperatorIdentifier = operatorIdentifier; this.AuthorisationCode = authorisationCode; this.OperatorResponseCode = operatorResponseCode; this.OperatorResponseMessage = operatorResponseMessage; @@ -81,6 +84,15 @@ public TransactionAuthorisedByOperatorEvent(Guid aggregateId, [JsonProperty] public Guid MerchantId { get; private set; } + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty] + public String OperatorIdentifier { get; private set; } + /// /// Gets the operator response code. /// @@ -145,6 +157,7 @@ public TransactionAuthorisedByOperatorEvent(Guid aggregateId, /// The aggregate identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The authorisation code. /// The operator response code. /// The operator response message. @@ -155,6 +168,7 @@ public TransactionAuthorisedByOperatorEvent(Guid aggregateId, public static TransactionAuthorisedByOperatorEvent Create(Guid aggregateId, Guid estateId, Guid merchantId, + String operatorIdentifier, String authorisationCode, String operatorResponseCode, String operatorResponseMessage, @@ -166,6 +180,7 @@ public static TransactionAuthorisedByOperatorEvent Create(Guid aggregateId, Guid.NewGuid(), estateId, merchantId, + operatorIdentifier, authorisationCode, operatorResponseCode, operatorResponseMessage, diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs index 02add901..690f9d88 100644 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs +++ b/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs @@ -22,12 +22,16 @@ public TransactionDeclinedByOperatorEvent() /// The event identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The operator response code. /// The operator response message. + /// The response code. + /// The response message. public TransactionDeclinedByOperatorEvent(Guid aggregateId, Guid eventId, Guid estateId, Guid merchantId, + String operatorIdentifier, String operatorResponseCode, String operatorResponseMessage, String responseCode, @@ -36,6 +40,7 @@ public TransactionDeclinedByOperatorEvent(Guid aggregateId, this.TransactionId = aggregateId; this.EstateId = estateId; this.MerchantId = merchantId; + this.OperatorIdentifier = operatorIdentifier; this.OperatorResponseCode = operatorResponseCode; this.OperatorResponseMessage = operatorResponseMessage; this.ResponseCode = responseCode; @@ -64,6 +69,15 @@ public TransactionDeclinedByOperatorEvent(Guid aggregateId, [JsonProperty] public Guid MerchantId { get; private set; } + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty] + public String OperatorIdentifier { get; private set; } + /// /// Gets the operator response code. /// @@ -119,6 +133,7 @@ public TransactionDeclinedByOperatorEvent(Guid aggregateId, /// The aggregate identifier. /// The estate identifier. /// The merchant identifier. + /// The operator identifier. /// The operator response code. /// The operator response message. /// The response code. @@ -127,6 +142,7 @@ public TransactionDeclinedByOperatorEvent(Guid aggregateId, public static TransactionDeclinedByOperatorEvent Create(Guid aggregateId, Guid estateId, Guid merchantId, + String operatorIdentifier, String operatorResponseCode, String operatorResponseMessage, String responseCode, @@ -136,6 +152,7 @@ public static TransactionDeclinedByOperatorEvent Create(Guid aggregateId, Guid.NewGuid(), estateId, merchantId, + operatorIdentifier, operatorResponseCode, operatorResponseMessage, responseCode, diff --git a/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs b/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs index 32159455..f5753ffc 100644 --- a/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs +++ b/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs @@ -111,6 +111,7 @@ public void TransactionAuthorisedByOperatorEvent_CanBeCreated_IsCreated() TransactionAuthorisedByOperatorEvent transactionAuthorisedByOperatorEvent = TransactionAuthorisedByOperatorEvent.Create(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, + TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, @@ -131,6 +132,7 @@ public void TransactionAuthorisedByOperatorEvent_CanBeCreated_IsCreated() transactionAuthorisedByOperatorEvent.OperatorTransactionId.ShouldBe(TestData.OperatorTransactionId); transactionAuthorisedByOperatorEvent.ResponseCode.ShouldBe(TestData.ResponseCode); transactionAuthorisedByOperatorEvent.ResponseMessage.ShouldBe(TestData.ResponseMessage); + transactionAuthorisedByOperatorEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); } [Fact] @@ -139,6 +141,7 @@ public void TransactionDeclinedByOperatorEvent_CanBeCreated_IsCreated() TransactionDeclinedByOperatorEvent transactionDeclinedByOperatorEvent = TransactionDeclinedByOperatorEvent.Create(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, + TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, @@ -155,6 +158,7 @@ public void TransactionDeclinedByOperatorEvent_CanBeCreated_IsCreated() transactionDeclinedByOperatorEvent.OperatorResponseMessage.ShouldBe(TestData.DeclinedOperatorResponseMessage); transactionDeclinedByOperatorEvent.ResponseCode.ShouldBe(TestData.DeclinedResponseCode); transactionDeclinedByOperatorEvent.ResponseMessage.ShouldBe(TestData.DeclinedResponseMessage); + transactionDeclinedByOperatorEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); } [Fact] @@ -163,6 +167,7 @@ public void AdditionalResponseDataRecordedEvent_CanBeCreated_IsCreated() AdditionalResponseDataRecordedEvent additionalResponseDataRecordedEvent = AdditionalResponseDataRecordedEvent.Create(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, + TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); additionalResponseDataRecordedEvent.ShouldNotBeNull(); @@ -172,6 +177,7 @@ public void AdditionalResponseDataRecordedEvent_CanBeCreated_IsCreated() additionalResponseDataRecordedEvent.TransactionId.ShouldBe(TestData.TransactionId); additionalResponseDataRecordedEvent.EstateId.ShouldBe(TestData.EstateId); additionalResponseDataRecordedEvent.MerchantId.ShouldBe(TestData.MerchantId); + additionalResponseDataRecordedEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); additionalResponseDataRecordedEvent.AdditionalTransactionResponseMetadata.ShouldNotBeNull(); foreach (KeyValuePair keyValuePair in TestData.AdditionalTransactionMetaData) @@ -186,6 +192,7 @@ public void AdditionalRequestDataRecordedEvent_CanBeCreated_IsCreated() AdditionalRequestDataRecordedEvent additionalRequestDataRecordedEvent = AdditionalRequestDataRecordedEvent.Create(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, + TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); additionalRequestDataRecordedEvent.ShouldNotBeNull(); @@ -195,6 +202,7 @@ public void AdditionalRequestDataRecordedEvent_CanBeCreated_IsCreated() additionalRequestDataRecordedEvent.TransactionId.ShouldBe(TestData.TransactionId); additionalRequestDataRecordedEvent.EstateId.ShouldBe(TestData.EstateId); additionalRequestDataRecordedEvent.MerchantId.ShouldBe(TestData.MerchantId); + additionalRequestDataRecordedEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); additionalRequestDataRecordedEvent.AdditionalTransactionRequestMetadata.ShouldNotBeNull(); foreach (KeyValuePair keyValuePair in TestData.AdditionalTransactionMetaData) diff --git a/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs b/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs index 3743bf54..c8cd14a2 100644 --- a/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs +++ b/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs @@ -70,7 +70,8 @@ public void TransactionAggregate_StartTransaction_TransactionAlreadyCompleted_Er } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, + TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, @@ -187,7 +188,7 @@ public void TransactionAggregate_AuthoriseTransactionLocally_TransactionAlreadyA { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); Should.Throw(() => { @@ -221,7 +222,7 @@ public void TransactionAggregate_AuthoriseTransaction_TransactionIsAuthorised(Tr TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); transactionAggregate.IsLocallyAuthorised.ShouldBeFalse(); transactionAggregate.IsAuthorised.ShouldBeTrue(); @@ -238,7 +239,7 @@ public void TransactionAggregate_AuthoriseTransaction_TransactionNotStarted_Erro Should.Throw(() => { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); }); } @@ -249,11 +250,11 @@ public void TransactionAggregate_AuthoriseTransaction_TransactionAlreadyAuthoris { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); Should.Throw(() => { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); }); } @@ -308,7 +309,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyAut { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); Should.Throw(() => { @@ -338,7 +339,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyDec { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.DeclineTransaction(TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); Should.Throw(() => { @@ -354,7 +355,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionIsDeclined(Transa TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); transactionAggregate.IsAuthorised.ShouldBeFalse(); transactionAggregate.IsLocallyAuthorised.ShouldBeFalse(); @@ -372,7 +373,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionNotStarted_ErrorT Should.Throw(() => { - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); }); } @@ -398,11 +399,11 @@ public void TransactionAggregate_DeclineTransaction_TransactionAlreadyAuthorised { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); Should.Throw(() => { - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); }); } @@ -417,7 +418,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionAlreadyDeclinedLo Should.Throw(() => { - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); }); } @@ -428,11 +429,11 @@ public void TransactionAggregate_DeclineTransaction_TransactionAlreadyDeclined_E { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); Should.Throw(() => { - transactionAggregate.DeclineTransaction(TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); }); } @@ -450,7 +451,7 @@ public void TransactionAggregate_CompleteTransaction_TransactionIsCompleted(Tran } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } transactionAggregate.CompleteTransaction(); @@ -498,7 +499,7 @@ public void TransactionAggregate_CompleteTransaction_TransactionAlreadyCompleted } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } transactionAggregate.CompleteTransaction(); @@ -519,7 +520,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_RequestDataRecorded Should.NotThrow(() => { - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -533,7 +534,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_TransactionNotStart Should.Throw(() => { - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -544,11 +545,11 @@ public void TransactionAggregate_RecordAdditionalRequestData_AdditionalRequestDa { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); Should.Throw(() => { - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -559,7 +560,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyAuthorised_E { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); if (transactionType == TransactionType.Logon) { @@ -567,12 +568,12 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyAuthorised_E } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } Should.Throw(() => { - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -583,7 +584,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyDeclined_Err { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); if (transactionType == TransactionType.Logon) { @@ -591,12 +592,12 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyDeclined_Err } else { - transactionAggregate.DeclineTransaction(TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.DeclineTransaction(TestData.OperatorIdentifier1, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.ResponseCode, TestData.ResponseMessage); } Should.Throw(() => { - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -607,20 +608,20 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyCompleted_Er { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); if (transactionType == TransactionType.Logon) { transactionAggregate.AuthoriseTransactionLocally(TestData.AuthorisationCode, TestData.ResponseCode, TestData.ResponseMessage); } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } transactionAggregate.CompleteTransaction(); Should.Throw(() => { - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -640,12 +641,12 @@ public void TransactionAggregate_RecordAdditionalResponseData_ResponseDataRecord } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } Should.NotThrow(() => { - transactionAggregate.RecordAdditionalResponseData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalResponseData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -659,7 +660,7 @@ public void TransactionAggregate_RecordAdditionalResponseData_TransactionNotStar Should.Throw(() => { - transactionAggregate.RecordAdditionalResponseData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalResponseData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -670,20 +671,20 @@ public void TransactionAggregate_RecordAdditionalResponseData_AdditionalResponse { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); if (transactionType == TransactionType.Logon) { transactionAggregate.AuthoriseTransactionLocally(TestData.AuthorisationCode, TestData.ResponseCode, TestData.ResponseMessage); } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } - transactionAggregate.RecordAdditionalResponseData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalResponseData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); Should.Throw(() => { - transactionAggregate.RecordAdditionalResponseData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalResponseData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } @@ -694,21 +695,21 @@ public void TransactionAggregate_RecordAdditionalResponseData_AlreadyCompleted_E { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, TestData.TransactionReference, TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier); - transactionAggregate.RecordAdditionalRequestData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalRequestData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); if (transactionType == TransactionType.Logon) { transactionAggregate.AuthoriseTransactionLocally(TestData.AuthorisationCode, TestData.ResponseCode, TestData.ResponseMessage); } else { - transactionAggregate.AuthoriseTransaction(TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); + transactionAggregate.AuthoriseTransaction(TestData.OperatorIdentifier1, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); } - transactionAggregate.RecordAdditionalResponseData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalResponseData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); transactionAggregate.CompleteTransaction(); Should.Throw(() => { - transactionAggregate.RecordAdditionalResponseData(TestData.AdditionalTransactionMetaData); + transactionAggregate.RecordAdditionalResponseData(TestData.OperatorIdentifier1, TestData.AdditionalTransactionMetaData); }); } diff --git a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs b/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs index 36689fd8..2820d207 100644 --- a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs +++ b/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs @@ -215,13 +215,15 @@ private TransactionAggregate(Guid aggregateId) /// /// Authorises the transaction. /// + /// The operator identifier. /// The authorisation code. /// The operator response code. /// The operator response message. /// The operator transaction identifier. /// The response code. /// The response message. - public void AuthoriseTransaction(String authorisationCode, + public void AuthoriseTransaction(String operatorIdentifier, + String authorisationCode, String operatorResponseCode, String operatorResponseMessage, String operatorTransactionId, @@ -234,6 +236,7 @@ public void AuthoriseTransaction(String authorisationCode, TransactionAuthorisedByOperatorEvent transactionAuthorisedByOperatorEvent = TransactionAuthorisedByOperatorEvent.Create(this.AggregateId, this.EstateId, this.MerchantId, + operatorIdentifier, authorisationCode, operatorResponseCode, operatorResponseMessage, @@ -295,11 +298,13 @@ public static TransactionAggregate Create(Guid aggregateId) /// /// Declines the transaction. /// + /// The operator identifier. /// The operator response code. /// The operator response message. /// The response code. /// The response message. - public void DeclineTransaction(String operatorResponseCode, + public void DeclineTransaction(String operatorIdentifier, + String operatorResponseCode, String operatorResponseMessage, String responseCode, String responseMessage) @@ -312,6 +317,7 @@ public void DeclineTransaction(String operatorResponseCode, TransactionDeclinedByOperatorEvent.Create(this.AggregateId, this.EstateId, this.MerchantId, + operatorIdentifier, operatorResponseCode, operatorResponseMessage, responseCode, @@ -339,8 +345,9 @@ public void DeclineTransactionLocally(String responseCode, /// /// Records the additional request data. /// + /// The operator identifier. /// The additional transaction request metadata. - public void RecordAdditionalRequestData(Dictionary additionalTransactionRequestMetadata) + public void RecordAdditionalRequestData(String operatorIdentifier, Dictionary additionalTransactionRequestMetadata) { this.CheckTransactionNotAlreadyCompleted(); this.CheckTransactionHasBeenStarted(); @@ -349,7 +356,7 @@ public void RecordAdditionalRequestData(Dictionary additionalTra this.CheckAdditionalRequestDataNotAlreadyRecorded(); AdditionalRequestDataRecordedEvent additionalRequestDataRecordedEvent = - AdditionalRequestDataRecordedEvent.Create(this.AggregateId, this.EstateId, this.MerchantId, additionalTransactionRequestMetadata); + AdditionalRequestDataRecordedEvent.Create(this.AggregateId, this.EstateId, this.MerchantId, operatorIdentifier, additionalTransactionRequestMetadata); this.ApplyAndPend(additionalRequestDataRecordedEvent); } @@ -357,14 +364,15 @@ public void RecordAdditionalRequestData(Dictionary additionalTra /// /// Records the additional response data. /// + /// The operator identifier. /// The additional transaction response metadata. - public void RecordAdditionalResponseData(Dictionary additionalTransactionResponseMetadata) + public void RecordAdditionalResponseData(String operatorIdentifier, Dictionary additionalTransactionResponseMetadata) { this.CheckTransactionHasBeenStarted(); this.CheckAdditionalResponseDataNotAlreadyRecorded(); AdditionalResponseDataRecordedEvent additionalResponseDataRecordedEvent = - AdditionalResponseDataRecordedEvent.Create(this.AggregateId, this.EstateId, this.MerchantId, additionalTransactionResponseMetadata); + AdditionalResponseDataRecordedEvent.Create(this.AggregateId, this.EstateId, this.MerchantId, operatorIdentifier, additionalTransactionResponseMetadata); this.ApplyAndPend(additionalResponseDataRecordedEvent); }