diff --git a/MidrandBooksApi/MidrandBooksApi.csproj b/MidrandBooksApi/MidrandBooksApi.csproj
index 70895cf..d075a31 100644
--- a/MidrandBooksApi/MidrandBooksApi.csproj
+++ b/MidrandBooksApi/MidrandBooksApi.csproj
@@ -14,8 +14,8 @@
-
-
+
+
@@ -39,8 +39,8 @@
-
-
+
+
@@ -54,13 +54,13 @@
-
+
-
+
@@ -89,6 +89,8 @@
+
+
diff --git a/MidrandBooksApi/Payments/Endpoints/IdentityEndpoint.cs b/MidrandBooksApi/Payments/Endpoints/IdentityEndpoint.cs
deleted file mode 100644
index 8276498..0000000
--- a/MidrandBooksApi/Payments/Endpoints/IdentityEndpoint.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using LiteCharms.Features.Abstractions;
-using LiteCharms.Features.Api;
-using LiteCharms.Features.Extensions;
-
-namespace MidrandBooksApi.Payments.Endpoints;
-
-[ApiVersionTarget(1)]
-public class IdentityEndpoint : IEndpoint
-{
- public void Map(IEndpointRouteBuilder builder)
- {
- builder.MapGet("security/test", () =>
- {
- return Results.Ok();
- })
- .RequireAuthorization()
- .WithDescription("Security test endpoint")
- .WithName(typeof(IdentityEndpoint).ToEndpointName())
- .Produces(StatusCodes.Status200OK)
- .WithTags("Security")
- .MapToApiVersion(1);
- }
-}
diff --git a/MidrandBooksApi/Payments/Payfast/PayfastCheckoutEndpoint.cs b/MidrandBooksApi/Payments/Payfast/PayfastCheckoutEndpoint.cs
new file mode 100644
index 0000000..eb76c82
--- /dev/null
+++ b/MidrandBooksApi/Payments/Payfast/PayfastCheckoutEndpoint.cs
@@ -0,0 +1,45 @@
+using LiteCharms.Features.Abstractions;
+using LiteCharms.Features.Api;
+using LiteCharms.Features.Extensions;
+using LiteCharms.Features.MidrandBooks.Customers;
+using LiteCharms.Features.MidrandBooks.Payments;
+using LiteCharms.Features.MidrandBooks.Payments.Models;
+using LiteCharms.Features.MidrandBooks.Products;
+using static LiteCharms.Features.Extensions.Api;
+
+namespace MidrandBooksApi.Payments.Payfast;
+
+[ApiVersionTarget(1)]
+public sealed class PayfastCheckoutEndpoint : IEndpoint
+{
+ private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
+
+ public void Map(IEndpointRouteBuilder builder)
+ {
+ builder.MapPost("payments/payfast/checkout", ([FromBody, Required] Cart shoppingCart, ProductService productService,
+ PaymentService paymentService, PayfastService payfastService, CustomerService customerService, IJobOrchestrator jobOrchestrator,
+ CancellationToken cancellationToken = default) =>
+ {
+ using Activity? activity = PaymentActivitySource.StartActivity("GeneratePayfastCheckoutUrl", ActivityKind.Server);
+
+ activity?.SetTag("messaging.system", "midrandbooks-api");
+ activity?.SetTag("messaging.destination.name", "payments/payfast/checkout");
+
+ // do work
+
+ var checkoutUrl = string.Empty;
+
+ activity?.SetStatus(ActivityStatusCode.Ok);
+
+ return Results.Ok(checkoutUrl);
+ })
+ .RequireAuthorization()
+ .WithDescription("Payfact checkout processor back-channel.")
+ .WithName(typeof(PayfastCheckoutEndpoint).ToEndpointName())
+ .MapToApiVersion(new ApiVersion(1))
+ .Produces(StatusCodes.Status200OK)
+ .Produces(StatusCodes.Status400BadRequest)
+ .Produces(StatusCodes.Status401Unauthorized)
+ .WithTags(Api.Payments); ;
+ }
+}
diff --git a/MidrandBooksApi/Payments/Endpoints/ConfirmationEndpoint.cs b/MidrandBooksApi/Payments/Payfast/PayfastConfirmationEndpoint.cs
similarity index 94%
rename from MidrandBooksApi/Payments/Endpoints/ConfirmationEndpoint.cs
rename to MidrandBooksApi/Payments/Payfast/PayfastConfirmationEndpoint.cs
index 379a3aa..570fbfc 100644
--- a/MidrandBooksApi/Payments/Endpoints/ConfirmationEndpoint.cs
+++ b/MidrandBooksApi/Payments/Payfast/PayfastConfirmationEndpoint.cs
@@ -6,10 +6,10 @@ using LiteCharms.Features.MidrandBooks.Payments.Events;
using LiteCharms.Features.MidrandBooks.Payments.Models;
using static LiteCharms.Features.Extensions.Api;
-namespace MidrandBooksApi.Payments.Endpoints;
+namespace MidrandBooksApi.Payments.Payfast;
[ApiVersionTarget(1)]
-public sealed class ConfirmationEndpoint : IEndpoint
+public sealed class PayfastConfirmationEndpoint : IEndpoint
{
private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
@@ -21,7 +21,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
using Activity? activity = PaymentActivitySource.StartActivity("ReceivePayfastWebhook", ActivityKind.Server);
activity?.SetTag("messaging.system", "payfast");
- activity?.SetTag("messaging.destination.name", "payments/confirm");
+ activity?.SetTag("messaging.destination.name", "payments/payfast/confirm");
string? remoteIp = request.HttpContext.Connection.RemoteIpAddress?.ToString();
@@ -57,7 +57,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
return Results.Unauthorized();
var notification = PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MerchantPaymentId!,
- allowLoopback: !hostEnvironment.IsProduction(), performBackgroundChecks: false); // Set to false because comprehensive checks are completed inline above
+ allowLoopback: !hostEnvironment.IsProduction(), performBackgroundChecks: false);
await jobOrchestrator.SendAsync(notification, cancellationToken);
@@ -66,7 +66,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
return Results.Ok();
})
.WithDescription("Securely confirm and process an incoming Payfast merchant payment callback.")
- .WithName(typeof(ConfirmationEndpoint).ToEndpointName())
+ .WithName(typeof(PayfastConfirmationEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces(StatusCodes.Status200OK)
.Produces(StatusCodes.Status400BadRequest)