- Sad to see you go 😢. Your subscription ends on
- {{ sub.next_bill_date.year }}-{{ sub.next_bill_date.month}}-{{ sub.next_bill_date.day }}
+ You are on the {{ sub.plan_name() }} plan.
+ You have canceled your subscription and it will end on {{current_user.next_bill_date()}}
({{ sub.next_bill_date | dt }}).
+ If you change your mind you can subscribe again to SimpleLogin but please note that this will be a completely
+ new subscription and
+ your payment method will be charged immediately.
+
+
+ We are going to send you an email by the end of the subscription so maybe you can upgrade at that time.
+
+ Re-subscribe
+
Click here to update billing information on Paddle, our payment partner:
Update billing information
diff --git a/app/models.py b/app/models.py
index 6b884102..8765fdb0 100644
--- a/app/models.py
+++ b/app/models.py
@@ -195,7 +195,34 @@ class User(db.Model, ModelMixin, UserMixin):
return False
def should_upgrade(self):
- return not self.lifetime_or_active_subscription()
+ if self.lifetime_or_active_subscription():
+ # user who has canceled can also re-subscribe
+ sub: Subscription = self.get_subscription()
+ if sub and sub.cancelled:
+ return True
+
+ return False
+
+ return True
+
+ def next_bill_date(self) -> str:
+ sub: Subscription = self.get_subscription()
+ if sub:
+ return sub.next_bill_date.strftime("%Y-%m-%d")
+
+ LOG.error(
+ f"next_bill_date() should be called only on user with active subscription. User {self}"
+ )
+ return ""
+
+ def is_cancel(self) -> bool:
+ """User has canceled their subscription but the subscription is still active,
+ i.e. next_bill_date > now"""
+ sub: Subscription = self.get_subscription()
+ if sub and sub.cancelled:
+ return True
+
+ return False
def is_premium(self) -> bool:
"""
@@ -273,7 +300,8 @@ class User(db.Model, ModelMixin, UserMixin):
# sub is active until the next billing_date + 1
if sub.next_bill_date >= arrow.now().shift(days=-1).date():
return sub
- else: # past subscription, user is considered not having a subscription
+ # past subscription, user is considered not having a subscription = free plan
+ else:
return None
else:
return sub
diff --git a/server.py b/server.py
index 0dedcd7b..f57adeb5 100644
--- a/server.py
+++ b/server.py
@@ -349,7 +349,7 @@ def setup_paddle_callback(app: Flask):
sub = Subscription.get_by(user_id=user.id)
if not sub:
- LOG.d("create a new sub")
+ LOG.d(f"create a new Subscription for user {user}")
Subscription.create(
user_id=user.id,
cancel_url=request.form.get("cancel_url"),
@@ -362,7 +362,7 @@ def setup_paddle_callback(app: Flask):
plan=plan,
)
else:
- LOG.d("update existing sub %s", sub)
+ LOG.d(f"Update an existing Subscription for user {user}")
sub.cancel_url = request.form.get("cancel_url")
sub.update_url = request.form.get("update_url")
sub.subscription_id = request.form.get("subscription_id")
diff --git a/templates/header.html b/templates/header.html
index ced588ad..2ca9e8b6 100644
--- a/templates/header.html
+++ b/templates/header.html
@@ -28,7 +28,11 @@
{% if current_user.in_trial() %}
Trial ends {{ current_user.trial_end|dt }}
{% elif current_user.lifetime_or_active_subscription() %}
-
Premium
+
Premium
+ {% if current_user.is_cancel() %}
+ until {{ current_user.next_bill_date() }}
+ {% endif %}
+
{% endif %}