-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Stripe serivices for retrieveing all subscriptions, last 10 sub…
…scriptions, subscribed/canceled ratio and last 30 day profits. Added 3 view models for CustomerData, IncomeStatistics and SubscriptionStatistics. Added StripeController endpoints to connect with those services and display the necessary data.
- Loading branch information
1 parent
d3c72bc
commit ff8bf96
Showing
6 changed files
with
204 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
using CookingApp.ViewModels.Stripe; | ||
using CookingApp.ViewModels.Stripe.Customer; | ||
using CookingApp.ViewModels.Stripe.Statistics; | ||
using CookingApp.ViewModels.Stripe.Subscription; | ||
using Stripe; | ||
|
||
namespace CookingApp.Services.Stripe | ||
{ | ||
public interface IStripeService | ||
{ | ||
Task<IEnumerable<Product>> GetProductsAsync(); | ||
Task<IEnumerable<ViewModels.Stripe.Product>> GetProductsAsync(); | ||
Task<SubscriptionCreationResponse> CreateSubscriptionAsync(SubscriptionCreation model); | ||
Task<SubscriptionCancellationResponse> CancelSubscriptionAsync(SubscriptionCancellation model); | ||
Task<List<CustomerData>> GetAllSubs(); | ||
Task<SubscriptionStatistics> GetSubsStats(); | ||
Task<IncomeStatistics> GetIncome30DaysBack(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/server/CookingApp/ViewModels/Stripe/Customer/CustomerData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace CookingApp.ViewModels.Stripe.Customer | ||
{ | ||
using CookingApp.Infrastructure.Mapping; | ||
using System.Collections.Generic; | ||
using global::Stripe; | ||
|
||
public class CustomerData : IMapFrom<Customer> | ||
{ | ||
public string Id { get; set; } | ||
public DateTime Created { get; set; } | ||
public string? Description { get; set; } | ||
public string? Email { get; set; } | ||
public Dictionary<string, string> Metadata { get; set; } | ||
public string? Name { get; set; } | ||
public string? Phone { get; set; } | ||
public List<SubscriptionState> Subscriptions { get; set; } | ||
} | ||
|
||
public class SubscriptionState | ||
{ | ||
public string Id { get; set; } | ||
public string PriceId { get; set; } | ||
public string State { get; set; } | ||
public DateTime CancelAt { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/server/CookingApp/ViewModels/Stripe/Statistics/IncomeStatistics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace CookingApp.ViewModels.Stripe.Statistics | ||
{ | ||
using CookingApp.Infrastructure.Mapping; | ||
using global::Stripe; | ||
|
||
public class IncomeStatistics : IMapFrom<Balance> | ||
{ | ||
public long Total { get; set; } | ||
public double AmountAfterTax { get; set; } | ||
public int TotalTransactions { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/server/CookingApp/ViewModels/Stripe/Statistics/SubscriptionStatistics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace CookingApp.ViewModels.Stripe.Statistics | ||
{ | ||
public class SubscriptionStatistics | ||
{ | ||
public double ActiveSubscriptions { get; set; } | ||
public double CanceledSubscriptions { get; set; } | ||
} | ||
} |