diff --git a/src/Core/Models/Api/Response/SubscriptionResponseModel.cs b/src/Core/Models/Api/Response/SubscriptionResponseModel.cs index 951527f215..a67a22b497 100644 --- a/src/Core/Models/Api/Response/SubscriptionResponseModel.cs +++ b/src/Core/Models/Api/Response/SubscriptionResponseModel.cs @@ -19,6 +19,7 @@ namespace Bit.Core.Models.Api MaxStorageGb = user.MaxStorageGb; License = license; Expiration = License.Expires; + UsingInAppPurchase = subscription.UsingInAppPurchase; } public SubscriptionResponseModel(User user, UserLicense license = null) @@ -42,6 +43,7 @@ namespace Bit.Core.Models.Api public BillingSubscription Subscription { get; set; } public UserLicense License { get; set; } public DateTime? Expiration { get; set; } + public bool UsingInAppPurchase { get; set; } } public class BillingSubscription diff --git a/src/Core/Models/Business/SubscriptionInfo.cs b/src/Core/Models/Business/SubscriptionInfo.cs index 0ea199d6fc..7927d19426 100644 --- a/src/Core/Models/Business/SubscriptionInfo.cs +++ b/src/Core/Models/Business/SubscriptionInfo.cs @@ -9,6 +9,7 @@ namespace Bit.Core.Models.Business { public BillingSubscription Subscription { get; set; } public BillingUpcomingInvoice UpcomingInvoice { get; set; } + public bool UsingInAppPurchase { get; set; } public class BillingSubscription { @@ -28,46 +29,6 @@ namespace Bit.Core.Models.Business } } - public BillingSubscription(Braintree.Subscription sub, Braintree.Plan plan) - { - Status = sub.Status.ToString(); - - if(sub.HasTrialPeriod.GetValueOrDefault() && sub.CreatedAt.HasValue && sub.TrialDuration.HasValue) - { - TrialStartDate = sub.CreatedAt.Value; - if(sub.TrialDurationUnit == Braintree.SubscriptionDurationUnit.DAY) - { - TrialEndDate = TrialStartDate.Value.AddDays(sub.TrialDuration.Value); - } - else - { - TrialEndDate = TrialStartDate.Value.AddMonths(sub.TrialDuration.Value); - } - } - - PeriodStartDate = sub.BillingPeriodStartDate; - PeriodEndDate = sub.BillingPeriodEndDate; - - CancelAtEndDate = !sub.NeverExpires.GetValueOrDefault(); - Cancelled = sub.Status == Braintree.SubscriptionStatus.CANCELED; - if(Cancelled) - { - CancelledDate = sub.UpdatedAt.Value; - } - - var items = new List(); - items.Add(new BillingSubscriptionItem(plan)); - if(sub.AddOns != null) - { - items.AddRange(sub.AddOns.Select(a => new BillingSubscriptionItem(plan, a))); - } - - if(items.Count > 0) - { - Items = items; - } - } - public DateTime? TrialStartDate { get; set; } public DateTime? TrialEndDate { get; set; } public DateTime? PeriodStartDate { get; set; } @@ -93,22 +54,6 @@ namespace Bit.Core.Models.Business Quantity = (int)item.Quantity; } - public BillingSubscriptionItem(Braintree.Plan plan) - { - Name = plan.Name; - Amount = plan.Price.GetValueOrDefault(); - Interval = plan.BillingFrequency.GetValueOrDefault() == 12 ? "year" : "month"; - Quantity = 1; - } - - public BillingSubscriptionItem(Braintree.Plan plan, Braintree.AddOn addon) - { - Name = addon.Name; - Amount = addon.Amount.GetValueOrDefault(); - Interval = plan.BillingFrequency.GetValueOrDefault() == 12 ? "year" : "month"; - Quantity = addon.Quantity.GetValueOrDefault(); - } - public string Name { get; set; } public decimal Amount { get; set; } public int Quantity { get; set; }