Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1132ba0401 | |||
| 5e119818bb | |||
| 181056d70d | |||
| c01a02ee97 | |||
| dfb5ce8a4b | |||
| 36b2f365d9 | |||
| 9bff28cec2 | |||
| c76438b881 | |||
| 857173af25 | |||
| e29c1ef6fc | |||
| c8a4a4cb17 | |||
| 56e002875e | |||
| d485e78498 | |||
| ba3f8f6f9b | |||
| 815470ab07 | |||
| 16a2516816 | |||
| 8842d92b9b | |||
| fc25d7ea40 | |||
| 8d8c1436f6 | |||
| 0c14872602 | |||
| d0ec655085 | |||
| 3e23217eb4 | |||
| 17d2ac409b | |||
| 2d5614c504 | |||
| 5bb7c4a959 |
@@ -14,8 +14,8 @@
|
|||||||
<PackageReference Include="IdentityModel.AspNetCore.OAuth2introspection" Version="6.2.0" />
|
<PackageReference Include="IdentityModel.AspNetCore.OAuth2introspection" Version="6.2.0" />
|
||||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
||||||
<PackageReference Include="IdentityModel" Version="6.2.0" />
|
<PackageReference Include="IdentityModel" Version="6.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="10.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="10.0.9" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Health Checks -->
|
<!-- Health Checks -->
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
<!-- API Documentation -->
|
<!-- API Documentation -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9" />
|
||||||
<PackageReference Include="Scalar.AspNetCore" Version="2.14.14" />
|
<PackageReference Include="Scalar.AspNetCore" Version="2.16.3" />
|
||||||
|
|
||||||
<Using Include="Scalar.AspNetCore" />
|
<Using Include="Scalar.AspNetCore" />
|
||||||
<Using Include="Microsoft.OpenApi" />
|
<Using Include="Microsoft.OpenApi" />
|
||||||
@@ -54,13 +54,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteCharms.Features" Version="1.68.0" />
|
<PackageReference Include="LiteCharms.Features" Version="1.102.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.68.0" />
|
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.102.0" />
|
||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<Using Include="Blazored.Toast.Services" />
|
<Using Include="Blazored.Toast.Services" />
|
||||||
@@ -89,6 +89,8 @@
|
|||||||
<Using Include="System.Web" />
|
<Using Include="System.Web" />
|
||||||
<Using Include="System.Diagnostics" />
|
<Using Include="System.Diagnostics" />
|
||||||
<Using Include="System.Reflection" />
|
<Using Include="System.Reflection" />
|
||||||
|
<Using Include="Microsoft.AspNetCore.Mvc" />
|
||||||
|
<Using Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
|
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -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<string>(StatusCodes.Status200OK)
|
||||||
|
.Produces(StatusCodes.Status400BadRequest)
|
||||||
|
.Produces(StatusCodes.Status401Unauthorized)
|
||||||
|
.WithTags(Api.Payments); ;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-6
@@ -4,13 +4,12 @@ using LiteCharms.Features.Extensions;
|
|||||||
using LiteCharms.Features.MidrandBooks.Payments;
|
using LiteCharms.Features.MidrandBooks.Payments;
|
||||||
using LiteCharms.Features.MidrandBooks.Payments.Events;
|
using LiteCharms.Features.MidrandBooks.Payments.Events;
|
||||||
using LiteCharms.Features.MidrandBooks.Payments.Models;
|
using LiteCharms.Features.MidrandBooks.Payments.Models;
|
||||||
using LiteCharms.Features.Quartz.Abstractions;
|
|
||||||
using static LiteCharms.Features.Extensions.Api;
|
using static LiteCharms.Features.Extensions.Api;
|
||||||
|
|
||||||
namespace MidrandBooksApi.Payments.Endpoints;
|
namespace MidrandBooksApi.Payments.Payfast;
|
||||||
|
|
||||||
[ApiVersionTarget(1)]
|
[ApiVersionTarget(1)]
|
||||||
public sealed class ConfirmationEndpoint : IEndpoint
|
public sealed class PayfastConfirmationEndpoint : IEndpoint
|
||||||
{
|
{
|
||||||
private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
|
private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
|
|||||||
using Activity? activity = PaymentActivitySource.StartActivity("ReceivePayfastWebhook", ActivityKind.Server);
|
using Activity? activity = PaymentActivitySource.StartActivity("ReceivePayfastWebhook", ActivityKind.Server);
|
||||||
|
|
||||||
activity?.SetTag("messaging.system", "payfast");
|
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();
|
string? remoteIp = request.HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||||
|
|
||||||
@@ -58,7 +57,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
|
|||||||
return Results.Unauthorized();
|
return Results.Unauthorized();
|
||||||
|
|
||||||
var notification = PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MerchantPaymentId!,
|
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);
|
await jobOrchestrator.SendAsync(notification, cancellationToken);
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ public sealed class ConfirmationEndpoint : IEndpoint
|
|||||||
return Results.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(PayfastConfirmationEndpoint).ToEndpointName())
|
||||||
.MapToApiVersion(new ApiVersion(1))
|
.MapToApiVersion(new ApiVersion(1))
|
||||||
.Produces(StatusCodes.Status200OK)
|
.Produces(StatusCodes.Status200OK)
|
||||||
.Produces(StatusCodes.Status400BadRequest)
|
.Produces(StatusCodes.Status400BadRequest)
|
||||||
@@ -11,10 +11,8 @@ builder.Services.AddEndpointsApiExplorer();
|
|||||||
builder.Services.AddEndpoints(Assembly.GetExecutingAssembly());
|
builder.Services.AddEndpoints(Assembly.GetExecutingAssembly());
|
||||||
builder.Services.AddApiServices(builder.Configuration);
|
builder.Services.AddApiServices(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddAuthorization();
|
|
||||||
builder.Services.AddAuthentication();
|
|
||||||
|
|
||||||
builder.Services.AddMediator();
|
builder.Services.AddMediator();
|
||||||
|
builder.Services.AddLiteCharmsApiSecurity(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
|
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
|
||||||
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
|
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"LiteCharmsSettings": {
|
||||||
|
"Authority": "https://sts.security.khongisa.co.za",
|
||||||
|
"Audience": "midrandbooks-api"
|
||||||
|
},
|
||||||
"ValidPayfastHosts": [
|
"ValidPayfastHosts": [
|
||||||
"www.payfast.co.za",
|
"www.payfast.co.za",
|
||||||
"sandbox.payfast.co.za",
|
"sandbox.payfast.co.za",
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ data:
|
|||||||
ValidPayfastHosts__4: "ips.payfast.co.za"
|
ValidPayfastHosts__4: "ips.payfast.co.za"
|
||||||
ValidPayfastHosts__5: "api.payfast.co.za"
|
ValidPayfastHosts__5: "api.payfast.co.za"
|
||||||
ValidPayfastHosts__6: "payment.payfast.io"
|
ValidPayfastHosts__6: "payment.payfast.io"
|
||||||
|
LiteCharmsSettings__Authority: "https://sts.security.khongisa.co.za"
|
||||||
|
LiteCharmsSettings__Audience: "midrandbooks-api"
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
@@ -41,6 +43,8 @@ data:
|
|||||||
hasher-payfastpassphrase: OUdBSVIwdFdwaFgwcU8=
|
hasher-payfastpassphrase: OUdBSVIwdFdwaFgwcU8=
|
||||||
bookshop-s3-accesskey: R0s1MTRkMmNlOGRjNjkyMzdhMDVjMDFlZWY=
|
bookshop-s3-accesskey: R0s1MTRkMmNlOGRjNjkyMzdhMDVjMDFlZWY=
|
||||||
bookshop-s3-secretkey: ZWFhZmVkYTFhZWQ0MDllY2ZlNjA3MTRlY2RhNTQ5YjgyYmRmNWEzZGFmOWYxOGRkNjFmNjZiNDk3M2E2NDgyZQ==
|
bookshop-s3-secretkey: ZWFhZmVkYTFhZWQ0MDllY2ZlNjA3MTRlY2RhNTQ5YjgyYmRmNWEzZGFmOWYxOGRkNjFmNjZiNDk3M2E2NDgyZQ==
|
||||||
|
litecharms-clientid: bWlkcmFuZGJvb2tzLWFwaQ==
|
||||||
|
litecharms-clientsecret: c2VjcmV0X2YzZjA0YWNhYTMzNmVlOTEzZDRjNjdlYmQwOTE1ZWFlYzQ0NzdmYTkwOTdlYTJhYzkyZGE4ZDc0NjgzZTAyNTU=
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
@@ -93,6 +97,16 @@ spec:
|
|||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: midrandbooksapi-config
|
name: midrandbooksapi-config
|
||||||
env:
|
env:
|
||||||
|
- name: LiteCharmsSettings__ClientId
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: midrandbooksapi-secrets
|
||||||
|
key: litecharms-clientid
|
||||||
|
- name: LiteCharmsSettings__ClientSecret
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: midrandbooksapi-secrets
|
||||||
|
key: litecharms-clientsecret
|
||||||
- name: BookshopS3Settings__AccessKey
|
- name: BookshopS3Settings__AccessKey
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
Reference in New Issue
Block a user