mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 23:51:13 +01:00
2d841e9bc0
* Update render function to receive user always as a param (cherry picked from commit fb53632298b08ab40bb82b8c8724a0bf254b2632) * Add user to the kwargs
33 lines
763 B
Python
33 lines
763 B
Python
import arrow
|
|
|
|
from app.db import Session
|
|
from app.email_utils import send_email, render
|
|
from app.log import LOG
|
|
from app.models import Subscription
|
|
from app import paddle_utils
|
|
|
|
|
|
def failed_payment(sub: Subscription, subscription_id: str):
|
|
LOG.w(
|
|
"Subscription failed payment %s for %s (sub %s)",
|
|
subscription_id,
|
|
sub.user,
|
|
sub.id,
|
|
)
|
|
|
|
sub.cancelled = True
|
|
Session.commit()
|
|
|
|
user = sub.user
|
|
|
|
paddle_utils.cancel_subscription(subscription_id)
|
|
|
|
send_email(
|
|
user.email,
|
|
"SimpleLogin - your subscription has failed to be renewed",
|
|
render(
|
|
"transactional/subscription-cancel.txt",
|
|
user=user,
|
|
end_date=arrow.arrow.datetime.utcnow(),
|
|
),
|
|
)
|