Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Allow verified subscription product changes

Neeraj Gupta7bda849ea394
diff --git a/server/pkg/controller/billing.go b/server/pkg/controller/billing.go
index 4dba916b65..a0d4e709b5 100644
--- a/server/pkg/controller/billing.go
+++ b/server/pkg/controller/billing.go
@@ -290,6 +290,7 @@ func shouldSkipVerifiedSubscriptionReplacement(currentSubscription ente.Subscrip
(currentSubscription.ProductID != ente.FreePlanProductID &&
currentSubscription.PaymentProvider == verifiedSubscription.PaymentProvider &&
currentSubscription.OriginalTransactionID == verifiedSubscription.OriginalTransactionID &&
+ currentSubscription.ProductID == verifiedSubscription.ProductID &&
verifiedSubscription.ExpiryTime < currentSubscription.ExpiryTime)
}
diff --git a/server/pkg/controller/billing_test.go b/server/pkg/controller/billing_test.go
index 73d65ffa51..e11716329f 100644
--- a/server/pkg/controller/billing_test.go
+++ b/server/pkg/controller/billing_test.go
@@ -52,6 +52,15 @@ func TestShouldSkipVerifiedSubscriptionReplacement(t *testing.T) {
verified: paid(ente.AppStore, "apple", now+30),
want: true,
},
+ {
+ name: "accepts App Store product change with earlier expiry",
+ current: ente.Subscription{
+ ProductID: "old", PaymentProvider: ente.AppStore, OriginalTransactionID: "apple", ExpiryTime: now + 45,
+ },
+ verified: ente.Subscription{
+ ProductID: "new", PaymentProvider: ente.AppStore, OriginalTransactionID: "apple", ExpiryTime: now + 30,
+ },
+ },
}
for _, test := range tests {