Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Shared.Results;
using Shared.Exceptions;
using Shared.Results;
using SimpleResults;
using TransactionProcessor.DataTransferObjects.Responses.Contract;

Expand Down Expand Up @@ -101,62 +102,31 @@ public async Task<Result<ProcessLogonTransactionResponse>> ProcessLogonTransacti

ProcessLogonTransactionResponse response = null;

try
{
Result<SerialisedMessage> transactionResult =
await this.TransactionProcessorClient.PerformTransaction(accessToken.AccessToken, requestSerialisedMessage, cancellationToken);
try {
Result<SerialisedMessage> transactionResult = await this.TransactionProcessorClient.PerformTransaction(accessToken.AccessToken, requestSerialisedMessage, cancellationToken);

if (transactionResult.IsFailed)
return ResultHelpers.CreateFailure(transactionResult);
SerialisedMessage responseSerialisedMessage = transactionResult.Data;

LogonTransactionResponse logonTransactionResponse = JsonConvert.DeserializeObject<LogonTransactionResponse>(responseSerialisedMessage.SerialisedData);

response = new ProcessLogonTransactionResponse
{
ResponseCode = logonTransactionResponse.ResponseCode,
ResponseMessage = logonTransactionResponse.ResponseMessage,
EstateId = estateId,
MerchantId = merchantId,
TransactionId = logonTransactionResponse.TransactionId,
response = new ProcessLogonTransactionResponse {
ResponseCode = logonTransactionResponse.ResponseCode,
ResponseMessage = logonTransactionResponse.ResponseMessage,
EstateId = estateId,
MerchantId = merchantId,
TransactionId = logonTransactionResponse.TransactionId,
};
}
catch(Exception ex)
{
if (ex.InnerException is InvalidOperationException)
{
// This means there is an error in the request
response = new ProcessLogonTransactionResponse
{
ResponseCode = "0001", // Request Message error
ResponseMessage = ex.InnerException.Message,
EstateId = estateId,
MerchantId = merchantId
};
}
else if (ex.InnerException is HttpRequestException)
{
Logger.LogError(ex.InnerException);

// Request Send Exception
response = new ProcessLogonTransactionResponse
{
ResponseCode = "0002", // Request Message error
ResponseMessage = $"Error Sending Request Message [{ex.InnerException.Message}]",
EstateId = estateId,
MerchantId = merchantId
};
}
else
{
response = new ProcessLogonTransactionResponse
{
ResponseCode = "0003", // General error
ResponseMessage = "General Error",
EstateId = estateId,
MerchantId = merchantId
};
}
catch (Exception ex) {
response = new ProcessLogonTransactionResponse {
ResponseCode = "0001", // Request Message error
ResponseMessage = "Process Logon Failed",
EstateId = estateId,
MerchantId = merchantId,
ErrorMessages = ex.GetExceptionMessages()
};
}

return Result.Success(response);
Expand Down Expand Up @@ -249,38 +219,14 @@ public async Task<Result<ProcessSaleTransactionResponse>> ProcessSaleTransaction
}
catch (Exception ex)
{
if (ex.InnerException is InvalidOperationException)
{
// This means there is an error in the request
response = new ProcessSaleTransactionResponse
{
ResponseCode = "0001", // Request Message error
ResponseMessage = ex.InnerException.Message,
EstateId = estateId,
MerchantId = merchantId
};
}
else if (ex.InnerException is HttpRequestException)
{
// Request Send Exception
response = new ProcessSaleTransactionResponse
{
ResponseCode = "0002", // Request Message error
ResponseMessage = "Error Sending Request Message",
EstateId = estateId,
MerchantId = merchantId
};
}
else
response = new ProcessSaleTransactionResponse
{
response = new ProcessSaleTransactionResponse
{
ResponseCode = "0003", // General error
ResponseMessage = "General Error",
EstateId = estateId,
MerchantId = merchantId
};
}
ResponseCode = "0001", // Request Message error
ResponseMessage = "Process Sale Failed",
EstateId = estateId,
MerchantId = merchantId,
ErrorMessages = ex.GetExceptionMessages()
};
}

return Result.Success(response);
Expand Down Expand Up @@ -339,32 +285,14 @@ public async Task<Result<ProcessReconciliationResponse>> ProcessReconciliation(G
}
catch (Exception ex)
{
if (ex.InnerException is InvalidOperationException)
{
// This means there is an error in the request
response = new ProcessReconciliationResponse
{
ResponseCode = "0001", // Request Message error
ResponseMessage = ex.InnerException.Message
};
}
else if (ex.InnerException is HttpRequestException)
{
// Request Send Exception
response = new ProcessReconciliationResponse
{
ResponseCode = "0002", // Request Message error
ResponseMessage = "Error Sending Request Message"
};
}
else
response = new ProcessReconciliationResponse
{
response = new ProcessReconciliationResponse
{
ResponseCode = "0003", // General error
ResponseMessage = "General Error"
};
}
ResponseCode = "0001", // Request Message error
ResponseMessage = "Process Reconciliation Failed",
EstateId = estateId,
MerchantId = merchantId,
ErrorMessages = ex.GetExceptionMessages()
};
}

return Result.Success(response);
Expand Down Expand Up @@ -416,32 +344,13 @@ public async Task<GetVoucherResponse> GetVoucher(Guid estateId,
}
catch (Exception ex)
{
if (ex.InnerException is InvalidOperationException)
{
// This means there is an error in the request
response = new GetVoucherResponse
{
ResponseCode = "0001", // Request Message error
ResponseMessage = ex.InnerException.Message,
};
}
else if (ex.InnerException is HttpRequestException)
{
// Request Send Exception
response = new GetVoucherResponse
{
ResponseCode = "0002", // Request Message error
ResponseMessage = "Error Sending Request Message",
};
}
else
// This means there is an error in the request
response = new GetVoucherResponse
{
response = new GetVoucherResponse
{
ResponseCode = "0003", // General error
ResponseMessage = "General Error",
};
}
ResponseCode = "0001", // Request Message error
ResponseMessage = "Get Voucher Failed",
ErrorMessages = ex.GetExceptionMessages()
};
}

return response;
Expand Down Expand Up @@ -499,34 +408,15 @@ public async Task<RedeemVoucherResponse> RedeemVoucher(Guid estateId,
}
catch (Exception ex)
{
if (ex.InnerException is InvalidOperationException)
{
// This means there is an error in the request
response = new RedeemVoucherResponse
{
ResponseCode = "0001", // Request Message error
ResponseMessage = ex.InnerException.Message,
};
}
else if (ex.InnerException is HttpRequestException)
{
// Request Send Exception
response = new RedeemVoucherResponse
{
ResponseCode = "0002", // Request Message error
ResponseMessage = "Error Sending Request Message",
};
}
else
// This means there is an error in the request
response = new RedeemVoucherResponse
{
response = new RedeemVoucherResponse
{
ResponseCode = "0003", // General error
ResponseMessage = "General Error",
};
}
ResponseCode = "0001", // Request Message error
ResponseMessage = "Redeem Voucher Failed",
ErrorMessages = ex.GetExceptionMessages()
};
}

return response;
}

Expand All @@ -540,7 +430,7 @@ public async Task<RedeemVoucherResponse> RedeemVoucher(Guid estateId,

Result<TokenResponse> accessTokenResult = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken);
if (accessTokenResult.IsFailed) {
ResultHelpers.CreateFailure(accessTokenResult);
return ResultHelpers.CreateFailure(accessTokenResult);
}
TokenResponse accessToken = accessTokenResult.Data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<DebugType>None</DebugType>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net5.0|AnyCPU'">
Expand Down
4 changes: 4 additions & 0 deletions TransactionProcessorACL.Models/GetVoucherResponse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace TransactionProcessorACL.Models;

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

[ExcludeFromCodeCoverage]
Expand All @@ -26,5 +27,8 @@ public class GetVoucherResponse

public Guid VoucherId { get; set; }


public List<String> ErrorMessages { get; set; }

#endregion
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace TransactionProcessorACL.Models
{
Expand Down Expand Up @@ -40,5 +41,7 @@ public class ProcessLogonTransactionResponse
public Guid MerchantId { get; set; }

public Guid TransactionId { get; set; }

public List<String> ErrorMessages { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace TransactionProcessorACL.Models
{
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

[ExcludeFromCodeCoverage]
Expand Down Expand Up @@ -40,5 +41,7 @@ public class ProcessReconciliationResponse
public Guid MerchantId { get; set; }

public Guid TransactionId { get; set; }

public List<String> ErrorMessages { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ public class ProcessSaleTransactionResponse
public Dictionary<String, String> AdditionalTransactionMetadata { get; set; }

public Guid TransactionId { get; set; }

public List<String> ErrorMessages { get; set; }

}
}
4 changes: 4 additions & 0 deletions TransactionProcessorACL.Models/RedeemVoucherResponse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace TransactionProcessorACL.Models;

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

[ExcludeFromCodeCoverage]
Expand All @@ -22,5 +23,8 @@ public class RedeemVoucherResponse

public String VoucherCode { get; set; }


public List<String> ErrorMessages { get; set; }

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<DebugType>None</DebugType>
</PropertyGroup>

</Project>
Loading
Loading