Make payments dependency injected based on the .env settings
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user