Used shared components
continuous-integration/drone/pr Build is passing

Built loopbackip check override based on environment
This commit is contained in:
Khwezi Mngoma
2026-06-03 00:47:54 +02:00
parent 8eedf16a49
commit 8be8eb52bc
9 changed files with 11 additions and 143 deletions
@@ -1,7 +1,11 @@
using LiteCharms.Features.MidrandBooks.Payments;
using LiteCharms.Features.Abstractions;
using LiteCharms.Features.Api;
using LiteCharms.Features.Extensions;
using LiteCharms.Features.MidrandBooks.Payments;
using LiteCharms.Features.MidrandBooks.Payments.Events;
using LiteCharms.Features.MidrandBooks.Payments.Models;
using LiteCharms.Features.Quartz.Abstractions;
using static LiteCharms.Features.Extensions.Api;
namespace MidrandBooksApi.Payments.Endpoints;
@@ -22,7 +26,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
string? remoteIp = request.HttpContext.Connection.RemoteIpAddress?.ToString();
var ipValidation = await payfastService.ValidateReferrerIpAsync(remoteIp!, cancellationToken);
var ipValidation = await payfastService.ValidateReferrerIpAsync(remoteIp!, !hostEnvironment.IsProduction(), cancellationToken);
if (ipValidation.IsFailed || !ipValidation.Value) return Results.Unauthorized();
@@ -54,7 +58,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
return Results.Unauthorized();
var notification = PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MerchantPaymentId!,
performBackgroundChecks: false); // Set to false because comprehensive checks are completed inline above
allowLoopback: !hostEnvironment.IsProduction(), performBackgroundChecks: false); // Set to false because comprehensive checks are completed inline above
await jobOrchestrator.SendAsync(notification, cancellationToken);
@@ -68,7 +72,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
.Produces(StatusCodes.Status200OK)
.Produces(StatusCodes.Status400BadRequest)
.Produces(StatusCodes.Status401Unauthorized)
.WithTags(EndpointTags.Payments);
.WithTags(Api.Payments);
}
private static PayfastWebhookPayload ParseForm(IFormCollection formCollection, string incomingSignature) => new()