Compare commits
1
Commits
fc2f457add
..
1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e07cd0e0fd |
+3
-3
@@ -82,9 +82,9 @@ steps:
|
||||
commands:
|
||||
- mkdir -p $HOME/.kube
|
||||
- echo "$KUBE_CONFIG" > $HOME/.kube/config
|
||||
- kubectl apply -f midrandbooksapi-uat.yml
|
||||
- kubectl apply -f midrandbooks-uat.yml
|
||||
- sleep 10
|
||||
- kubectl rollout restart deployment/midrandbooks-api -n midrandbooksapi-uat
|
||||
- kubectl rollout restart deployment/midrandbooks -n midrandbooks-uat
|
||||
|
||||
depends_on:
|
||||
- package
|
||||
@@ -105,7 +105,7 @@ steps:
|
||||
commands:
|
||||
- mkdir -p $HOME/.kube
|
||||
- echo "$KUBE_CONFIG" > $HOME/.kube/config
|
||||
- kubectl apply -f midrandbooks-api.yml
|
||||
- kubectl apply -f midrandbooks.yml
|
||||
|
||||
depends_on:
|
||||
- uat
|
||||
|
||||
+1
-2
@@ -360,5 +360,4 @@ MigrationBackup/
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
/MidrandBooksApi/http/http-client.env.json
|
||||
FodyWeavers.xsd
|
||||
@@ -53,13 +53,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LiteCharms.Features" Version="1.64.0" />
|
||||
<PackageReference Include="LiteCharms.Features" Version="1.61.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- UI -->
|
||||
<ItemGroup>
|
||||
<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 -->
|
||||
<Using Include="Blazored.Toast.Services" />
|
||||
@@ -85,7 +85,6 @@
|
||||
|
||||
<!-- Shared Global Usings -->
|
||||
<ItemGroup>
|
||||
<Using Include="System.Diagnostics" />
|
||||
<Using Include="System.Reflection" />
|
||||
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
using LiteCharms.Features.Hasher;
|
||||
using LiteCharms.Features.MidrandBooks.Payments.Events;
|
||||
using LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Hasher;
|
||||
using LiteCharms.Features.Models;
|
||||
using LiteCharms.Features.Quartz.Abstractions;
|
||||
|
||||
namespace MidrandBooksApi.Payments.Endpoints;
|
||||
|
||||
[ApiVersionTarget(1)]
|
||||
public sealed class ConfirmationEndpoint : IEndpoint
|
||||
{
|
||||
private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
|
||||
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapPost("payments/payfast/confirm", async (HttpRequest request, HashService hashService,
|
||||
IJobOrchestrator jobOrchestrator, CancellationToken cancellationToken) =>
|
||||
builder.MapPost("payments/confirm", async (HttpRequest request, HashService hashService,
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
if (validationResult.IsFailed || !validationResult.Value) return Results.Unauthorized();
|
||||
|
||||
await jobOrchestrator.SendAsync(PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MPaymentId!), cancellationToken);
|
||||
|
||||
activity?.SetStatus(ActivityStatusCode.Ok);
|
||||
|
||||
return Results.Ok();
|
||||
return validationResult.IsFailed || !validationResult.Value
|
||||
? Results.Unauthorized()
|
||||
: Results.Ok();
|
||||
})
|
||||
.WithDescription("Securely confirm and process an incoming Payfast merchant payment callback.")
|
||||
.WithName(typeof(ConfirmationEndpoint).ToEndpointName())
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Asp.Versioning.Builder;
|
||||
using k8s.Models;
|
||||
using LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Mediator;
|
||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||
@@ -75,10 +74,6 @@ app.UseHealthChecks("/ready");
|
||||
|
||||
app.MapOpenApi();
|
||||
|
||||
var apiVersions = app.DescribeApiVersions()
|
||||
.OrderByDescending(o => o.ApiVersion.MajorVersion)
|
||||
.ToList();
|
||||
|
||||
foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.ApiVersion.MajorVersion))
|
||||
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"] };
|
||||
});
|
||||
|
||||
var latestVersionGroup = apiVersions.FirstOrDefault()?.GroupName ?? "v1";
|
||||
|
||||
app.MapGet("/", () => Results.Redirect($"/openapi/{latestVersionGroup}"))
|
||||
.ExcludeFromDescription();
|
||||
|
||||
if (!app.Environment.IsDevelopment())
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7196;http://localhost:5159",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
## Payfast Payment Confirmation
|
||||
# This endpoint is used by Payfast to confirm the payment status of a transaction.
|
||||
# It receives a POST request with the payment details and updates the order status accordingly.
|
||||
|
||||
POST {{baseUrl}}/v1/payments/payfast/confirm
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
amount={{amount}}&item_name={{item_name}}&m_payment_id={{paymentId}}&signature={{signature}}
|
||||
Reference in New Issue
Block a user