Browse Source

Added checks for billing enabled.

feature/billing
Teknikode 7 months ago
parent
commit
7954b7f269
  1. 9
      Teknik/Areas/API/V1/Controllers/BillingAPIv1Controller.cs
  2. 9
      Teknik/Areas/Billing/Controllers/BillingController.cs
  3. 4
      Teknik/Areas/Billing/Views/Billing/ViewSubscription.cshtml

9
Teknik/Areas/API/V1/Controllers/BillingAPIv1Controller.cs

@ -23,6 +23,9 @@ namespace Teknik.Areas.API.V1.Controllers @@ -23,6 +23,9 @@ namespace Teknik.Areas.API.V1.Controllers
public async Task<IActionResult> HandleCheckoutCompleteEvent()
{
if (!_config.BillingConfig.Enabled)
return Forbid();
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
var billingEvent = await billingService.ParseEvent(Request, _config.BillingConfig.StripeCheckoutWebhookSecret);
@ -43,6 +46,9 @@ namespace Teknik.Areas.API.V1.Controllers @@ -43,6 +46,9 @@ namespace Teknik.Areas.API.V1.Controllers
public async Task<IActionResult> HandleSubscriptionChange()
{
if (!_config.BillingConfig.Enabled)
return Forbid();
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
var billingEvent = await billingService.ParseEvent(Request, _config.BillingConfig.StripeSubscriptionWebhookSecret);
@ -61,6 +67,9 @@ namespace Teknik.Areas.API.V1.Controllers @@ -61,6 +67,9 @@ namespace Teknik.Areas.API.V1.Controllers
public async Task<IActionResult> HandleCustomerDeletion()
{
if (!_config.BillingConfig.Enabled)
return Forbid();
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
var billingEvent = await billingService.ParseEvent(Request, _config.BillingConfig.StripeCustomerWebhookSecret);

9
Teknik/Areas/Billing/Controllers/BillingController.cs

@ -172,6 +172,9 @@ namespace Teknik.Areas.Billing.Controllers @@ -172,6 +172,9 @@ namespace Teknik.Areas.Billing.Controllers
public IActionResult Checkout(string priceId)
{
if (!_config.BillingConfig.Enabled)
throw new UnauthorizedAccessException();
// Get Subscription Info
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
@ -192,6 +195,9 @@ namespace Teknik.Areas.Billing.Controllers @@ -192,6 +195,9 @@ namespace Teknik.Areas.Billing.Controllers
public IActionResult CheckoutComplete(string productId, string session_id)
{
if (!_config.BillingConfig.Enabled)
throw new UnauthorizedAccessException();
// Get Checkout Info
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
var checkoutSession = billingService.GetCheckoutSession(session_id);
@ -224,6 +230,9 @@ namespace Teknik.Areas.Billing.Controllers @@ -224,6 +230,9 @@ namespace Teknik.Areas.Billing.Controllers
public IActionResult EditSubscription(string priceId)
{
if (!_config.BillingConfig.Enabled)
throw new UnauthorizedAccessException();
// Get Subscription Info
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);

4
Teknik/Areas/Billing/Views/Billing/ViewSubscription.cshtml

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
}
var btnClass = "";
if (Model.CurrentSubMonthly)
if (Model.CurrentSubMonthly || !Config.BillingConfig.Enabled)
{
btnClass = "disabled";
}
@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
@if (Model.BasePriceYearly != null)
{
var yearBtnClass = "";
if (Model.CurrentSubYearly)
if (Model.CurrentSubYearly || !Config.BillingConfig.Enabled)
{
yearBtnClass = "disabled";
}

Loading…
Cancel
Save