Skip to content

Commit

Permalink
make subject logic for payment failure notification email simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Aug 28, 2024
1 parent bd6e730 commit c539af5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions payments/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from typing import Literal

import stripe
from django.utils import timezone
from loguru import logger

Expand Down Expand Up @@ -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

Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions payments/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ 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")
send_payment_failed_email_with_invoice.delay(
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")
Expand Down

0 comments on commit c539af5

Please sign in to comment.