Fix - Couldn't detect gift card subscriptions
This commit is contained in:
parent
3d74fa7667
commit
1669561203
|
@ -113,12 +113,18 @@ public class CrAuth{
|
|||
if (responseSubs.IsOk){
|
||||
var subsc = Helpers.Deserialize<Subscription>(responseSubs.ResponseContent, crunInstance.SettingsJsonSerializerSettings);
|
||||
crunInstance.Profile.Subscription = subsc;
|
||||
if ( subsc.SubscriptionProducts is{ Count: 0 } && subsc.ThirdPartySubscriptionProducts is{ Count: > 0 }){
|
||||
if ( subsc is{ SubscriptionProducts:{ Count: 0 }, ThirdPartySubscriptionProducts.Count: > 0 }){
|
||||
var thirdPartySub = subsc.ThirdPartySubscriptionProducts.First();
|
||||
var remaining = thirdPartySub.ExpirationDate - DateTime.UtcNow;
|
||||
crunInstance.Profile.HasPremium = remaining > TimeSpan.Zero;
|
||||
crunInstance.Profile.Subscription.IsActive = remaining > TimeSpan.Zero;
|
||||
crunInstance.Profile.Subscription.NextRenewalDate = thirdPartySub.ExpirationDate;
|
||||
} else if(subsc is{ SubscriptionProducts:{ Count: 0 }, NonrecurringSubscriptionProducts.Count: > 0 }){
|
||||
var nonRecurringSub = subsc.NonrecurringSubscriptionProducts.First();
|
||||
var remaining = nonRecurringSub.EndDate - DateTime.UtcNow;
|
||||
crunInstance.Profile.HasPremium = remaining > TimeSpan.Zero;
|
||||
crunInstance.Profile.Subscription.IsActive = remaining > TimeSpan.Zero;
|
||||
crunInstance.Profile.Subscription.NextRenewalDate = nonRecurringSub.EndDate;
|
||||
} else{
|
||||
crunInstance.Profile.HasPremium = subsc.IsActive;
|
||||
}
|
||||
|
|
|
@ -45,9 +45,19 @@ public class Subscription{
|
|||
public List<ThirdPartySubscriptionProduct>? ThirdPartySubscriptionProducts{ get; set; }
|
||||
|
||||
[JsonProperty("nonrecurring_subscription_products")]
|
||||
public List<SubscriptionProduct>? NonrecurringSubscriptionProducts{ get; set; }
|
||||
public List<NonRecurringSubscriptionProduct>? NonrecurringSubscriptionProducts{ get; set; }
|
||||
}
|
||||
|
||||
public class NonRecurringSubscriptionProduct{
|
||||
[JsonProperty("start_date")]
|
||||
public DateTime StartDate{ get; set; }
|
||||
[JsonProperty("end_date")]
|
||||
public DateTime EndDate{ get; set; }
|
||||
public string? Sku{ get; set; }
|
||||
public string? Tier{ get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SubscriptionProduct{
|
||||
[JsonProperty("currency_code")]
|
||||
public string? CurrencyCode{ get; set; }
|
||||
|
|
|
@ -61,6 +61,8 @@ public partial class AccountPageViewModel : ViewModelBase{
|
|||
if (sub != null){
|
||||
IsCancelled = !sub.AutoRenew;
|
||||
}
|
||||
}else if(Crunchyroll.Instance.Profile.Subscription?.NonrecurringSubscriptionProducts.Count >= 1){
|
||||
IsCancelled = true;
|
||||
}
|
||||
|
||||
if (Crunchyroll.Instance.Profile.Subscription?.NextRenewalDate != null){
|
||||
|
|
Loading…
Reference in New Issue