1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Added customer ID to admin view

This commit is contained in:
Uncled1023 2022-08-14 19:43:45 -07:00
parent 270615be90
commit 4e5dd269bd
7 changed files with 44 additions and 1 deletions

View File

@ -11,6 +11,9 @@ namespace Teknik.BillingCore
{
public static BillingService GetBillingService(BillingConfig config)
{
if (config == null)
return null;
switch (config.Type)
{
case BillingType.Stripe:

View File

@ -20,6 +20,7 @@ namespace Teknik.BillingCore
public abstract List<Customer> GetCustomers();
public abstract Customer GetCustomer(string id);
public abstract string GetCustomerProfileUrl(string id);
public abstract string CreateCustomer(string username, string email);
public abstract List<Product> GetProductList();

View File

@ -47,6 +47,19 @@ namespace Teknik.BillingCore
return null;
}
public override string GetCustomerProfileUrl(string email)
{
if (!string.IsNullOrEmpty(email))
{
var service = new CustomerService();
var foundCustomer = service.Get(email);
if (foundCustomer != null)
return $"https://dashboard.stripe.com/customers/{foundCustomer.Id}";
}
return null;
}
public override string CreateCustomer(string username, string email)
{
if (string.IsNullOrEmpty(username))

View File

@ -19,6 +19,8 @@ using Teknik.Logging;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Teknik.MailService;
using Teknik.Areas.Billing;
using Teknik.BillingCore;
namespace Teknik.Areas.Admin.Controllers
{
@ -61,6 +63,19 @@ namespace Teknik.Areas.Admin.Controllers
if (info.AccountStatus.HasValue)
model.AccountStatus = info.AccountStatus.Value;
// Get Biling Service
var billingService = BillingFactory.GetBillingService(_config.BillingConfig);
if (billingService != null &&
user.BillingCustomer != null)
{
var customer = billingService.GetCustomer(user.BillingCustomer?.CustomerId);
if (customer != null)
{
model.CustomerId = customer.CustomerId;
model.CustomerProfileUrl = billingService.GetCustomerProfileUrl(customer.CustomerId);
}
}
var email = UserHelper.GetUserEmailAddress(_config, username);
if (UserHelper.UserEmailExists(mailService, _config, email))
model.Email = email;

View File

@ -12,6 +12,8 @@ namespace Teknik.Areas.Admin.ViewModels
public string Username { get; set; }
public AccountType AccountType { get; set; }
public AccountStatus AccountStatus { get; set; }
public string CustomerId { get; set; }
public string CustomerProfileUrl { get; set; }
public string Email { get; set; }
public bool EmailEnabled { get; set; }
public long MaxEmailStorage { get; set; }

View File

@ -53,6 +53,15 @@
</div>
</div>
<br />
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Customer ID:
</div>
<div class="col-sm-8">
<a href="@Model.CustomerProfileUrl">@Model.CustomerId</a>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Email:

View File

@ -1,4 +1,4 @@
/* globals editAccountType, editAccountStatus, createInviteCode, deleteUserURL, homeUrl, username */
/* globals editAccountType, editAccountStatus, editEmailActive, createInviteCode, deleteUserURL, homeUrl, username */
$(function () {
$('.userAccountType').on('change', function () {