Compare commits

..

7 Commits

Author SHA1 Message Date
khwezi 851ca72b46 Merge pull request 'payments' (#4) from payments into master
Reviewed-on: #4
2026-06-02 00:33:11 +02:00
Khwezi Mngoma 27418322f4 Stable run
continuous-integration/drone/pr Build is passing
2026-06-02 00:31:36 +02:00
Khwezi Mngoma 99a307527a Fixed return bug
Added quartz job
Added otel exports
2026-06-01 23:11:25 +02:00
khwezi b731ebdcea Merge pull request 'Applied api reference redirect on root path' (#3) from payments into master
Reviewed-on: #3
2026-06-01 18:25:22 +02:00
Khwezi Mngoma 3deffab351 Applied api reference redirect on root path
continuous-integration/drone/pr Build is passing
2026-06-01 18:24:48 +02:00
khwezi f3e71aa604 Merge pull request 'Refactored pipeline to use correct template file' (#2) from payments into master
Reviewed-on: #2
2026-06-01 17:53:13 +02:00
Khwezi Mngoma 44632d2f54 Refactored pipeline to use correct template file
continuous-integration/drone/pr Build is passing
2026-06-01 17:52:46 +02:00
4 changed files with 32 additions and 11 deletions
+3 -3
View File
@@ -82,9 +82,9 @@ steps:
commands: commands:
- mkdir -p $HOME/.kube - mkdir -p $HOME/.kube
- echo "$KUBE_CONFIG" > $HOME/.kube/config - echo "$KUBE_CONFIG" > $HOME/.kube/config
- kubectl apply -f midrandbooks-uat.yml - kubectl apply -f midrandbooksapi-uat.yml
- sleep 10 - sleep 10
- kubectl rollout restart deployment/midrandbooks -n midrandbooks-uat - kubectl rollout restart deployment/midrandbooks-api -n midrandbooksapi-uat
depends_on: depends_on:
- package - package
@@ -105,7 +105,7 @@ steps:
commands: commands:
- mkdir -p $HOME/.kube - mkdir -p $HOME/.kube
- echo "$KUBE_CONFIG" > $HOME/.kube/config - echo "$KUBE_CONFIG" > $HOME/.kube/config
- kubectl apply -f midrandbooks.yml - kubectl apply -f midrandbooks-api.yml
depends_on: depends_on:
- uat - uat
+3 -2
View File
@@ -53,13 +53,13 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="LiteCharms.Features" Version="1.61.0" /> <PackageReference Include="LiteCharms.Features" Version="1.64.0" />
</ItemGroup> </ItemGroup>
<!-- UI --> <!-- UI -->
<ItemGroup> <ItemGroup>
<PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" /> <PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" />
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.61.0" /> <PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.64.0" />
<!-- Global Usings --> <!-- Global Usings -->
<Using Include="Blazored.Toast.Services" /> <Using Include="Blazored.Toast.Services" />
@@ -85,6 +85,7 @@
<!-- Shared Global Usings --> <!-- Shared Global Usings -->
<ItemGroup> <ItemGroup>
<Using Include="System.Diagnostics" />
<Using Include="System.Reflection" /> <Using Include="System.Reflection" />
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" /> <Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
</ItemGroup> </ItemGroup>
@@ -1,17 +1,24 @@
using LiteCharms.Features.Extensions; using LiteCharms.Features.Hasher;
using LiteCharms.Features.Hasher; using LiteCharms.Features.MidrandBooks.Payments.Events;
using LiteCharms.Features.Models; using LiteCharms.Features.Models;
using LiteCharms.Features.Quartz.Abstractions;
namespace MidrandBooksApi.Payments.Endpoints; namespace MidrandBooksApi.Payments.Endpoints;
[ApiVersionTarget(1)] [ApiVersionTarget(1)]
public sealed class ConfirmationEndpoint : IEndpoint public sealed class ConfirmationEndpoint : IEndpoint
{ {
private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
public void Map(IEndpointRouteBuilder builder) public void Map(IEndpointRouteBuilder builder)
{ {
builder.MapPost("payments/confirm", async (HttpRequest request, HashService hashService, builder.MapPost("payments/confirm", async (HttpRequest request, HashService hashService,
CancellationToken cancellationToken) => IJobOrchestrator jobOrchestrator, CancellationToken cancellationToken) =>
{ {
using Activity? activity = PaymentActivitySource.StartActivity("ReceivePayfastWebhook", ActivityKind.Server);
activity?.SetTag("messaging.system", "payfast");
activity?.SetTag("messaging.destination.name", "payments/confirm");
var formCollection = await request.ReadFormAsync(cancellationToken); var formCollection = await request.ReadFormAsync(cancellationToken);
if (!formCollection.TryGetValue("signature", out var signatureValues) || string.IsNullOrWhiteSpace(signatureValues.ToString())) if (!formCollection.TryGetValue("signature", out var signatureValues) || string.IsNullOrWhiteSpace(signatureValues.ToString()))
@@ -28,9 +35,13 @@ public sealed class ConfirmationEndpoint : IEndpoint
var validationResult = hashService.VerifyPayfastWebhookSignature(payload, incomingSignature); var validationResult = hashService.VerifyPayfastWebhookSignature(payload, incomingSignature);
return validationResult.IsFailed || !validationResult.Value if (validationResult.IsFailed || !validationResult.Value) return Results.Unauthorized();
? Results.Unauthorized()
: Results.Ok(); await jobOrchestrator.SendAsync(PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MPaymentId!), cancellationToken);
activity?.SetStatus(ActivityStatusCode.Ok);
return Results.Ok();
}) })
.WithDescription("Securely confirm and process an incoming Payfast merchant payment callback.") .WithDescription("Securely confirm and process an incoming Payfast merchant payment callback.")
.WithName(typeof(ConfirmationEndpoint).ToEndpointName()) .WithName(typeof(ConfirmationEndpoint).ToEndpointName())
+9
View File
@@ -1,4 +1,5 @@
using Asp.Versioning.Builder; using Asp.Versioning.Builder;
using k8s.Models;
using LiteCharms.Features.Extensions; using LiteCharms.Features.Extensions;
using LiteCharms.Features.Mediator; using LiteCharms.Features.Mediator;
using LiteCharms.Features.MidrandBooks.Extensions; using LiteCharms.Features.MidrandBooks.Extensions;
@@ -74,6 +75,10 @@ app.UseHealthChecks("/ready");
app.MapOpenApi(); app.MapOpenApi();
var apiVersions = app.DescribeApiVersions()
.OrderByDescending(o => o.ApiVersion.MajorVersion)
.ToList();
foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.ApiVersion.MajorVersion)) foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.ApiVersion.MajorVersion))
app.MapScalarApiReference($"/openapi/{description.GroupName}", (options, context) => app.MapScalarApiReference($"/openapi/{description.GroupName}", (options, context) =>
{ {
@@ -84,6 +89,10 @@ foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.A
options.Authentication = new ScalarAuthenticationOptions { PreferredSecuritySchemes = ["Bearer"] }; options.Authentication = new ScalarAuthenticationOptions { PreferredSecuritySchemes = ["Bearer"] };
}); });
var latestVersionGroup = apiVersions.FirstOrDefault()?.GroupName ?? "v1";
app.MapGet("/", () => Results.Redirect($"/openapi/{latestVersionGroup}"))
.ExcludeFromDescription();
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
app.UseExceptionHandler("/Error", createScopeForErrors: true); app.UseExceptionHandler("/Error", createScopeForErrors: true);