Clearing out the payment path
This commit is contained in:
@@ -32,20 +32,6 @@ public static class DependencyInjection
|
||||
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,
|
||||
ConfigurationManager configuration)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,8 @@ public class SendTipRequestValidator : Validator<SendTipRequest>
|
||||
[PublicAPI]
|
||||
public class SendTipHandler(
|
||||
MembershipDbContext dbContext,
|
||||
StripeService stripeService)
|
||||
StripeService stripeService,
|
||||
ILogger<SendTipHandler> logger)
|
||||
: Endpoint<SendTipRequest, SendTipResponse>
|
||||
{
|
||||
public override void Configure()
|
||||
@@ -59,29 +60,36 @@ public class SendTipHandler(
|
||||
SendTipRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var creator = await dbContext.Creators.FindAsync(
|
||||
[req.CreatorId],
|
||||
cancellationToken: ct);
|
||||
|
||||
if (creator == null)
|
||||
try
|
||||
{
|
||||
await SendNotFoundAsync(ct);
|
||||
return;
|
||||
var creator = await dbContext.Creators.FindAsync(
|
||||
[req.CreatorId],
|
||||
cancellationToken: ct);
|
||||
|
||||
if (creator == null)
|
||||
{
|
||||
await SendNotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
var checkoutSession = await stripeService.CreateTipCheckoutSessionAsync(
|
||||
creator.Id,
|
||||
creator.Name,
|
||||
req.Amount,
|
||||
req.Currency,
|
||||
req.Message,
|
||||
creator.StripeAccountId!,
|
||||
req.CheckoutSuccessUrl,
|
||||
req.CheckoutCancelledUrl,
|
||||
ct);
|
||||
|
||||
await SendAsync(
|
||||
new SendTipResponse("Pending", checkoutSession.Url),
|
||||
cancellation: ct);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e.Message);
|
||||
}
|
||||
|
||||
var checkoutSession = await stripeService.CreateTipCheckoutSessionAsync(
|
||||
creator.Id,
|
||||
creator.Name,
|
||||
req.Amount,
|
||||
req.Currency,
|
||||
req.Message,
|
||||
creator.StripeAccountId!,
|
||||
req.CheckoutSuccessUrl,
|
||||
req.CheckoutCancelledUrl,
|
||||
ct);
|
||||
|
||||
await SendAsync(
|
||||
new SendTipResponse("Pending", checkoutSession.Url),
|
||||
cancellation: ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
if (!builder.Environment.IsDevelopment())
|
||||
{
|
||||
var keyVaultEndpoint = new Uri(Environment.GetEnvironmentVariable("VaultUri") ?? "");
|
||||
builder.Configuration.AddAzureKeyVault(keyVaultEndpoint, new DefaultAzureCredential());
|
||||
var vaultUri = Environment.GetEnvironmentVariable("VaultUri");
|
||||
|
||||
if (vaultUri is null) throw new InvalidOperationException("Missing VaultUri configuration setting");
|
||||
|
||||
builder.Configuration.AddAzureKeyVault(new Uri(vaultUri), new DefaultAzureCredential());
|
||||
}
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
@@ -34,7 +37,6 @@ builder.Services.AddCors(options =>
|
||||
});
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddKeyVaultIfConfigured(builder.Configuration);
|
||||
builder.Services.AddWebServices();
|
||||
builder.Services.AddAuthorizationAndAuthentication(builder.Configuration);
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
"PostgresConnection": "Server=hutopypostgress.postgres.database.azure.com,5432;Database=hutopy;User Id=hutopy;Password=General2024!;Ssl Mode=Require;"
|
||||
},
|
||||
"Stripe": {
|
||||
"SecretKey": "",
|
||||
"WebhookSecret": "",
|
||||
"HutopyRate": 0.05
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user