Clearing out the payment path

This commit is contained in:
2025-04-17 00:18:17 -04:00
parent 910c5572a1
commit 9d2a00a928
4 changed files with 37 additions and 43 deletions

View File

@@ -32,20 +32,6 @@ public static class DependencyInjection
return services; return services;
} }
public static IServiceCollection AddKeyVaultIfConfigured(this IServiceCollection services,
ConfigurationManager configuration)
{
var keyVaultUri = configuration["KeyVaultUri"];
if (!string.IsNullOrWhiteSpace(keyVaultUri))
{
configuration.AddAzureKeyVault(
new Uri(keyVaultUri),
new DefaultAzureCredential());
}
return services;
}
public static IServiceCollection AddAuthorizationAndAuthentication(this IServiceCollection services, public static IServiceCollection AddAuthorizationAndAuthentication(this IServiceCollection services,
ConfigurationManager configuration) ConfigurationManager configuration)
{ {

View File

@@ -44,7 +44,8 @@ public class SendTipRequestValidator : Validator<SendTipRequest>
[PublicAPI] [PublicAPI]
public class SendTipHandler( public class SendTipHandler(
MembershipDbContext dbContext, MembershipDbContext dbContext,
StripeService stripeService) StripeService stripeService,
ILogger<SendTipHandler> logger)
: Endpoint<SendTipRequest, SendTipResponse> : Endpoint<SendTipRequest, SendTipResponse>
{ {
public override void Configure() public override void Configure()
@@ -58,6 +59,8 @@ public class SendTipHandler(
public override async Task HandleAsync( public override async Task HandleAsync(
SendTipRequest req, SendTipRequest req,
CancellationToken ct) CancellationToken ct)
{
try
{ {
var creator = await dbContext.Creators.FindAsync( var creator = await dbContext.Creators.FindAsync(
[req.CreatorId], [req.CreatorId],
@@ -84,4 +87,9 @@ public class SendTipHandler(
new SendTipResponse("Pending", checkoutSession.Url), new SendTipResponse("Pending", checkoutSession.Url),
cancellation: ct); cancellation: ct);
} }
catch (Exception e)
{
logger.LogError(e.Message);
}
}
} }

View File

@@ -17,8 +17,11 @@ var builder = WebApplication.CreateBuilder(args);
if (!builder.Environment.IsDevelopment()) if (!builder.Environment.IsDevelopment())
{ {
var keyVaultEndpoint = new Uri(Environment.GetEnvironmentVariable("VaultUri") ?? ""); var vaultUri = Environment.GetEnvironmentVariable("VaultUri");
builder.Configuration.AddAzureKeyVault(keyVaultEndpoint, new DefaultAzureCredential());
if (vaultUri is null) throw new InvalidOperationException("Missing VaultUri configuration setting");
builder.Configuration.AddAzureKeyVault(new Uri(vaultUri), new DefaultAzureCredential());
} }
builder.Services.AddCors(options => builder.Services.AddCors(options =>
@@ -34,7 +37,6 @@ builder.Services.AddCors(options =>
}); });
// Add services to the container. // Add services to the container.
builder.Services.AddKeyVaultIfConfigured(builder.Configuration);
builder.Services.AddWebServices(); builder.Services.AddWebServices();
builder.Services.AddAuthorizationAndAuthentication(builder.Configuration); builder.Services.AddAuthorizationAndAuthentication(builder.Configuration);

View File

@@ -3,8 +3,6 @@
"PostgresConnection": "Server=hutopypostgress.postgres.database.azure.com,5432;Database=hutopy;User Id=hutopy;Password=General2024!;Ssl Mode=Require;" "PostgresConnection": "Server=hutopypostgress.postgres.database.azure.com,5432;Database=hutopy;User Id=hutopy;Password=General2024!;Ssl Mode=Require;"
}, },
"Stripe": { "Stripe": {
"SecretKey": "",
"WebhookSecret": "",
"HutopyRate": 0.05 "HutopyRate": 0.05
} }
} }