Browse Source

Added portal to main billing settings page

feature/billing
Teknikode 7 months ago
parent
commit
485f0eb3bc
  1. 5
      Teknik/Areas/User/Controllers/UserController.cs
  2. 2
      Teknik/Areas/User/ViewModels/BillingSettingsViewModel.cs
  3. 2
      Teknik/Areas/User/ViewModels/SubscriptionViewModel.cs
  4. 24
      Teknik/Areas/User/Views/User/Settings/BillingSettings.cshtml

5
Teknik/Areas/User/Controllers/UserController.cs

@ -366,13 +366,15 @@ namespace Teknik.Areas.Users.Controllers @@ -366,13 +366,15 @@ namespace Teknik.Areas.Users.Controllers
if (user.BillingCustomer != null)
{
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
var portalSession = billingService.CreatePortalSession(user.BillingCustomer.CustomerId, Url.SubRouteUrl("account", "User.BillingSettings"));
model.PortalUrl = portalSession.Url;
var subs = billingService.GetSubscriptionList(user.BillingCustomer.CustomerId);
foreach (var sub in subs)
{
foreach (var price in sub.Prices)
{
var product = billingService.GetProduct(price.ProductId);
var portalSession = billingService.CreatePortalSession(user.BillingCustomer.CustomerId, Url.SubRouteUrl("account", "User.BillingSettings"));
var subView = new SubscriptionViewModel()
{
SubscriptionId = sub.Id,
@ -381,7 +383,6 @@ namespace Teknik.Areas.Users.Controllers @@ -381,7 +383,6 @@ namespace Teknik.Areas.Users.Controllers
Storage = price.Storage,
Price = price.Amount,
Interval = price.Interval.ToString(),
PortalUrl = portalSession?.Url
};
model.Subscriptions.Add(subView);
}

2
Teknik/Areas/User/ViewModels/BillingSettingsViewModel.cs

@ -8,6 +8,8 @@ namespace Teknik.Areas.Users.ViewModels @@ -8,6 +8,8 @@ namespace Teknik.Areas.Users.ViewModels
{
public class BillingSettingsViewModel : SettingsViewModel
{
public string PortalUrl { get; set; }
public List<SubscriptionViewModel> Subscriptions { get; set; }
public BillingSettingsViewModel()

2
Teknik/Areas/User/ViewModels/SubscriptionViewModel.cs

@ -19,7 +19,5 @@ namespace Teknik.Areas.Users.ViewModels @@ -19,7 +19,5 @@ namespace Teknik.Areas.Users.ViewModels
public string Interval { get; set; }
public long Storage { get; set; }
public string PortalUrl { get; set; }
}
}

24
Teknik/Areas/User/Views/User/Settings/BillingSettings.cshtml

@ -7,9 +7,25 @@ @@ -7,9 +7,25 @@
}
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<br />
<label for="activeSubscriptions"><h4>Active Subscriptions</h4></label>
<div class="col-sm-12">
<h2>Billing Information</h2>
<hr />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<a href="@Model.PortalUrl">Click here</a> to view/modify your billing information and invoices.</>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h2>Active Subscriptions</h2>
<hr />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="activeSubscriptions" style="overflow-y: auto; max-height: 400px;">
<ul class="list-group" id="activeSubscriptionList">
@if (Model.Subscriptions.Any())
@ -18,7 +34,7 @@ @@ -18,7 +34,7 @@
{
<li class="list-group-item">
<h4 class="list-group-item-heading">@subscription.ProductName: <strong>@(StringHelper.GetBytesReadable(subscription.Storage))</strong> for <strong>@($"${subscription.Price:0.00} / {subscription.Interval}")</strong></h4>
<p><a href="@subscription.PortalUrl">Subscription Details</a> | <a href="@(Url.SubRouteUrl("billing", "Billing.CancelSubscription", new { subscriptionId = subscription.SubscriptionId, productId = subscription.ProductId }))">Cancel Subscription</a></p>
<p><a href="@(Url.SubRouteUrl("billing", "Billing.CancelSubscription", new { subscriptionId = subscription.SubscriptionId, productId = subscription.ProductId }))">Cancel Subscription</a></p>
</li>
}
}

Loading…
Cancel
Save