notify admin when user cancels
This commit is contained in:
parent
c74857c7e7
commit
8a11e42da9
|
@ -1207,6 +1207,8 @@ class EmailLog(db.Model, ModelMixin):
|
|||
|
||||
|
||||
class Subscription(db.Model, ModelMixin):
|
||||
"""Paddle subscription"""
|
||||
|
||||
# Come from Paddle
|
||||
cancel_url = db.Column(db.String(1024), nullable=False)
|
||||
update_url = db.Column(db.String(1024), nullable=False)
|
||||
|
@ -1230,6 +1232,9 @@ class Subscription(db.Model, ModelMixin):
|
|||
else:
|
||||
return "Yearly ($29.99/year)"
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Subscription {self.plan} {self.next_bill_date}>"
|
||||
|
||||
|
||||
class ManualSubscription(db.Model, ModelMixin):
|
||||
"""
|
||||
|
|
|
@ -41,10 +41,12 @@ from app.config import (
|
|||
SENTRY_FRONT_END_DSN,
|
||||
FIRST_ALIAS_DOMAIN,
|
||||
SESSION_COOKIE_NAME,
|
||||
ADMIN_EMAIL,
|
||||
)
|
||||
from app.dashboard.base import dashboard_bp
|
||||
from app.developer.base import developer_bp
|
||||
from app.discover.base import discover_bp
|
||||
from app.email_utils import send_email
|
||||
from app.extensions import db, login_manager, migrate, limiter
|
||||
from app.jose_utils import get_jwk_key
|
||||
from app.log import LOG
|
||||
|
@ -545,6 +547,12 @@ def setup_paddle_callback(app: Flask):
|
|||
|
||||
sub.cancelled = True
|
||||
db.session.commit()
|
||||
|
||||
send_email(
|
||||
ADMIN_EMAIL,
|
||||
subject=f"{sub.user} cancels",
|
||||
plaintext=f"{sub} {request.form.get('cancellation_effective_date')}",
|
||||
)
|
||||
else:
|
||||
return "No such subscription", 400
|
||||
elif request.form.get("alert_name") == "subscription_updated":
|
||||
|
|
Loading…
Reference in New Issue