Compare commits
1
Commits
27418322f4
..
1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e07cd0e0fd |
+3
-3
@@ -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 midrandbooksapi-uat.yml
|
- kubectl apply -f midrandbooks-uat.yml
|
||||||
- sleep 10
|
- sleep 10
|
||||||
- kubectl rollout restart deployment/midrandbooks-api -n midrandbooksapi-uat
|
- kubectl rollout restart deployment/midrandbooks -n midrandbooks-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-api.yml
|
- kubectl apply -f midrandbooks.yml
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- uat
|
- uat
|
||||||
|
|||||||
@@ -53,13 +53,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteCharms.Features" Version="1.64.0" />
|
<PackageReference Include="LiteCharms.Features" Version="1.61.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.64.0" />
|
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.61.0" />
|
||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<Using Include="Blazored.Toast.Services" />
|
<Using Include="Blazored.Toast.Services" />
|
||||||
@@ -85,7 +85,6 @@
|
|||||||
|
|
||||||
<!-- 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,24 +1,17 @@
|
|||||||
using LiteCharms.Features.Hasher;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.MidrandBooks.Payments.Events;
|
using LiteCharms.Features.Hasher;
|
||||||
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,
|
||||||
IJobOrchestrator jobOrchestrator, CancellationToken cancellationToken) =>
|
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()))
|
||||||
@@ -35,13 +28,9 @@ public sealed class ConfirmationEndpoint : IEndpoint
|
|||||||
|
|
||||||
var validationResult = hashService.VerifyPayfastWebhookSignature(payload, incomingSignature);
|
var validationResult = hashService.VerifyPayfastWebhookSignature(payload, incomingSignature);
|
||||||
|
|
||||||
if (validationResult.IsFailed || !validationResult.Value) return Results.Unauthorized();
|
return validationResult.IsFailed || !validationResult.Value
|
||||||
|
? Results.Unauthorized()
|
||||||
await jobOrchestrator.SendAsync(PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MPaymentId!), cancellationToken);
|
: Results.Ok();
|
||||||
|
|
||||||
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())
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
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;
|
||||||
@@ -75,10 +74,6 @@ 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) =>
|
||||||
{
|
{
|
||||||
@@ -89,10 +84,6 @@ 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user