From c539af542adda4fe82d0f5688b8598131f82716d Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:00:35 +0530 Subject: [PATCH] make subject logic for payment failure notification email simpler --- payments/tasks.py | 7 ++----- payments/webhooks.py | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/payments/tasks.py b/payments/tasks.py index 7627acfef..f0ee87fce 100644 --- a/payments/tasks.py +++ b/payments/tasks.py @@ -1,6 +1,3 @@ -from typing import Literal - -import stripe from django.utils import timezone from loguru import logger @@ -47,7 +44,7 @@ def send_payment_failed_email_with_invoice( uid: str, invoice_url: str, dollar_amt: float, - kind: Literal["subscription", "auto recharge"], + subject: str, ): from routers.account import account_route @@ -59,7 +56,7 @@ def send_payment_failed_email_with_invoice( send_email_via_postmark( from_address=settings.PAYMENT_EMAIL, to_address=user.email, - subject=f"Payment failure on your Gooey.AI {kind}", + subject=subject, html_body=templates.get_template( "off_session_payment_failed_email.html" ).render( diff --git a/payments/webhooks.py b/payments/webhooks.py index 79c788f19..2c1820065 100644 --- a/payments/webhooks.py +++ b/payments/webhooks.py @@ -207,7 +207,7 @@ def handle_invoice_failed(cls, uid: str, data: dict): uid=uid, invoice_url=data["hosted_invoice_url"], dollar_amt=data["amount_due"] / 100, - kind="auto recharge", + subject="Payment failure on your Gooey.AI auto-recharge", ) elif data.get("subscription_details", {}): print("subscription failed") @@ -215,7 +215,7 @@ def handle_invoice_failed(cls, uid: str, data: dict): uid=uid, invoice_url=data["hosted_invoice_url"], dollar_amt=data["amount_due"] / 100, - kind="subscription", + subject="Payment failure on your Gooey.AI subscription", ) else: print("not auto recharge or subscription")