Make payments dependency injected based on the .env settings

This commit is contained in:
2025-06-20 18:31:18 -07:00
parent c4ad0f2c10
commit fb2a2c6ae9
8 changed files with 111 additions and 83 deletions
+10 -2
View File
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authentication.Cookies;
using MistoxWebsite.Server.Controllers;
using MistoxWebsite.Server.Controllers.Payment;
using MistoxWebsite.Server.Services;
using MistoxWebsite.Server.Services.DatabaseService;
using Stripe;
@@ -37,8 +38,15 @@ EmailService Emailservice = new EmailService( EmailServer, EmailPort, EmailAddre
builder.Services.Add( new ServiceDescriptor( typeof( EmailService ), Emailservice ));
// Payment Service
string? StripeKey = Environment.GetEnvironmentVariable("StripeKey");
StripeConfiguration.ApiKey = StripeKey;
string? PaymentService = Environment.GetEnvironmentVariable("PaymentService");
IPayment._PaymentType = (PaymentType)Enum.Parse(typeof(PaymentType), PaymentService, true);
if (IPayment._PaymentType == PaymentType.StripeIntent) {
string? StripeKey = Environment.GetEnvironmentVariable("StripeKey");
StripeConfiguration.ApiKey = StripeKey;
string? StripeEndpointKey = Environment.GetEnvironmentVariable("StripeEndpointSecret");
IPayment._EndpointSecret = string.IsNullOrEmpty(StripeEndpointKey) ? "" : StripeEndpointKey ;
}
// Authentication Service
builder.Services.AddAuthentication( options => {