mirror of
https://github.com/bitwarden/server.git
synced 2025-05-20 11:04:31 -05:00
UsingInAppPurchase prop on sub models
This commit is contained in:
parent
ad95dd6bb2
commit
8340b22c2a
@ -19,6 +19,7 @@ namespace Bit.Core.Models.Api
|
|||||||
MaxStorageGb = user.MaxStorageGb;
|
MaxStorageGb = user.MaxStorageGb;
|
||||||
License = license;
|
License = license;
|
||||||
Expiration = License.Expires;
|
Expiration = License.Expires;
|
||||||
|
UsingInAppPurchase = subscription.UsingInAppPurchase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubscriptionResponseModel(User user, UserLicense license = null)
|
public SubscriptionResponseModel(User user, UserLicense license = null)
|
||||||
@ -42,6 +43,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public BillingSubscription Subscription { get; set; }
|
public BillingSubscription Subscription { get; set; }
|
||||||
public UserLicense License { get; set; }
|
public UserLicense License { get; set; }
|
||||||
public DateTime? Expiration { get; set; }
|
public DateTime? Expiration { get; set; }
|
||||||
|
public bool UsingInAppPurchase { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BillingSubscription
|
public class BillingSubscription
|
||||||
|
@ -9,6 +9,7 @@ namespace Bit.Core.Models.Business
|
|||||||
{
|
{
|
||||||
public BillingSubscription Subscription { get; set; }
|
public BillingSubscription Subscription { get; set; }
|
||||||
public BillingUpcomingInvoice UpcomingInvoice { get; set; }
|
public BillingUpcomingInvoice UpcomingInvoice { get; set; }
|
||||||
|
public bool UsingInAppPurchase { get; set; }
|
||||||
|
|
||||||
public class BillingSubscription
|
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<BillingSubscriptionItem>();
|
|
||||||
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? TrialStartDate { get; set; }
|
||||||
public DateTime? TrialEndDate { get; set; }
|
public DateTime? TrialEndDate { get; set; }
|
||||||
public DateTime? PeriodStartDate { get; set; }
|
public DateTime? PeriodStartDate { get; set; }
|
||||||
@ -93,22 +54,6 @@ namespace Bit.Core.Models.Business
|
|||||||
Quantity = (int)item.Quantity;
|
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 string Name { get; set; }
|
||||||
public decimal Amount { get; set; }
|
public decimal Amount { get; set; }
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user