Skip to content

Commit e8ffbcd

Browse files
Merge pull request #607 from TransactionProcessing/task/#592_check_operator_is_enabled
reject sales when operator is disabled at either estate or merchant
2 parents 2354ea2 + 9a0e567 commit e8ffbcd

16 files changed

Lines changed: 285 additions & 108 deletions

File tree

TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using Testing;
2424
using TransactionAggregate;
2525
using Xunit;
26-
using MerchantResponse = EstateManagement.DataTransferObjects.Responses.MerchantResponse;
2726

2827
public class TransactionDomainServiceTests{
2928
#region Fields

TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs

Lines changed: 115 additions & 66 deletions
Large diffs are not rendered by default.

TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<DebugType>Full</DebugType>
5+
<DebugType>None</DebugType>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

TransactionProcessor.BusinessLogic/OperatorInterfaces/IOperatorProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55
using System.Threading;
66
using System.Threading.Tasks;
7-
using EstateManagement.DataTransferObjects.Responses;
7+
using EstateManagement.DataTransferObjects.Responses.Merchant;
88

99
/// <summary>
1010
///
@@ -18,7 +18,7 @@ Task<OperatorResponse> ProcessLogonMessage(String accessToken,
1818
Task<OperatorResponse> ProcessSaleMessage(String accessToken,
1919
Guid transactionId,
2020
Guid operatorId,
21-
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant,
21+
MerchantResponse merchant,
2222
DateTime transactionDateTime,
2323
String transactionReference,
2424
Dictionary<String, String> additionalTransactionMetadata,

TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPostPay/PataPawaPostPayProxy.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using Common;
8-
using EstateManagement.DataTransferObjects.Responses;
98
using global::PataPawaPostPay;
109
using Microsoft.Extensions.Caching.Memory;
1110
using Shared.Logger;

TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPrePay/PataPawaPrePayProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Threading;
77
using System.Threading.Tasks;
88
using Common;
9-
using EstateManagement.DataTransferObjects.Responses;
9+
using EstateManagement.DataTransferObjects.Responses.Merchant;
1010
using Microsoft.Extensions.Caching.Memory;
1111
using Newtonsoft.Json;
1212
using Shared.Logger;
@@ -56,7 +56,7 @@ public async Task<OperatorResponse> ProcessLogonMessage(String accessToken, Canc
5656
}
5757

5858
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken, Guid transactionId, Guid operatorId,
59-
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant, DateTime transactionDateTime, String transactionReference, Dictionary<String, String> additionalTransactionMetadata, CancellationToken cancellationToken){
59+
MerchantResponse merchant, DateTime transactionDateTime, String transactionReference, Dictionary<String, String> additionalTransactionMetadata, CancellationToken cancellationToken){
6060
// Get the logon response for the operator
6161
OperatorResponse logonResponse = this.MemoryCache.Get<OperatorResponse>("PataPawaPrePayLogon");
6262
if (logonResponse == null)

TransactionProcessor.BusinessLogic/OperatorInterfaces/SafaricomPinless/SafaricomPinlessProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Xml;
1212
using System.Xml.Serialization;
1313
using Common;
14-
using EstateManagement.DataTransferObjects.Responses;
14+
using EstateManagement.DataTransferObjects.Responses.Merchant;
1515
using Shared.Logger;
1616

1717
/// <summary>
@@ -74,7 +74,7 @@ public async Task<OperatorResponse> ProcessLogonMessage(String accessToken,
7474
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken,
7575
Guid transactionId,
7676
Guid operatorId,
77-
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant,
77+
MerchantResponse merchant,
7878
DateTime transactionDateTime,
7979
String transactionReference,
8080
Dictionary<String, String> additionalTransactionMetadata,

TransactionProcessor.BusinessLogic/OperatorInterfaces/VoucherManagement/VoucherManagementProxy.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ namespace TransactionProcessor.BusinessLogic.OperatorInterfaces.VoucherManagemen
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Common;
11-
using EstateManagement.DataTransferObjects.Responses;
11+
using EstateManagement.DataTransferObjects.Responses.Merchant;
1212
using IdentityModel.Client;
1313
using MediatR;
14-
//using global::VoucherManagement.Client;
15-
//using global::VoucherManagement.DataTransferObjects;
1614
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
1715
using Microsoft.Identity.Client;
1816
using Models;
@@ -56,7 +54,7 @@ public async Task<OperatorResponse> ProcessLogonMessage(String accessToken,
5654
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken,
5755
Guid transactionId,
5856
Guid operatorId,
59-
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant,
57+
MerchantResponse merchant,
6058
DateTime transactionDateTime,
6159
String transactionReference,
6260
Dictionary<String, String> additionalTransactionMetadata,

TransactionProcessor.BusinessLogic/Services/TransactionResponseCode.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public enum TransactionResponseCode
2222
MerchantHasNoContractsConfigured = 1014,
2323
ContractNotValidForMerchant = 1015,
2424
ProductNotValidForMerchant = 1016,
25+
OperatorNotEnabledForEstate = 1017,
26+
OperatorNotEnabledForMerchant = 1018,
2527

2628
// A Catch All generic Error where reason has not been identified
2729
UnknownFailure = 9999

TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public TransactionValidationService(IEstateClient estateClient,
141141
TransactionResponseCode.OperatorNotValidForEstate);
142142
}
143143

144+
// Check the operator is enabled and not deleted
145+
if (estateOperatorRecord.IsDeleted){
146+
throw new TransactionValidationException($"Operator {operatorId} not enabled for Estate [{estate.EstateName}]",
147+
TransactionResponseCode.OperatorNotEnabledForEstate);
148+
}
149+
144150
// Device Validation
145151
if (merchant.Devices == null || merchant.Devices.Any() == false){
146152
throw new TransactionValidationException($"Merchant {merchant.MerchantName} has no valid Devices for this transaction.",
@@ -168,8 +174,15 @@ public TransactionValidationService(IEstateClient estateClient,
168174
throw new TransactionValidationException($"Operator {operatorId} not configured for Merchant [{merchant.MerchantName}]",
169175
TransactionResponseCode.OperatorNotValidForMerchant);
170176
}
171-
}
172177

178+
// Check the operator is enabled and not deleted
179+
if (merchantOperatorRecord.IsDeleted)
180+
{
181+
throw new TransactionValidationException($"Operator {operatorId} not enabled for Merchant [{merchant.MerchantName}]",
182+
TransactionResponseCode.OperatorNotEnabledForMerchant);
183+
}
184+
}
185+
173186
// Contract and Product Validation
174187
if (contractId == Guid.Empty){
175188
throw new TransactionValidationException($"Contract Id [{contractId}] must be set for a sale transaction",

0 commit comments

Comments
 (0)