supporters: Add sustainer confirmation email

This commit is contained in:
Ben Sturmfels 2024-10-24 17:51:49 +11:00
parent 48048f349a
commit a51a7e2099
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
3 changed files with 38 additions and 1 deletions

View file

@ -0,0 +1,17 @@
from django.core.mail import EmailMessage
from django.template.loader import render_to_string
def make_stripe_email(order) -> EmailMessage:
subject = 'Thanks for your sustainer payment!'
email_body = render_to_string(
'supporters/mail/sustainer_thanks.txt',
{'order': order},
).strip()
message = EmailMessage(
subject,
email_body,
'Software Freedom Conservancy <sustainers@sfconservancy.org>',
[order.email],
)
return message

View file

@ -0,0 +1,18 @@
Hi {{ order.name }},
Thanks so much for being a sustainer! Your support is what makes our work possible.
Order: #{{ order.id }}
Payment: ${{ order.amount }}{% if order.recurring %} {{ order.get_recurring_display }}{% endif %}
Acknowledge me on the list of sustainers: {{ order.acknowledge_publicly|yesno }}
Add me to the announcements email list: {{ order.add_to_mailing_list|yesno }}
T-shirt: {{ order.get_tshirt_size_display }}{% if order.tshirt_size %}
Postal address:
{{ order.street }}
{{ order.city }} {{ order.state }} {{ order.zip_code }}
{{ order.country }}{% endif %}
{% if order.recurring == 'month' and order.tshirt_size %}
Please note that you may not receive the T-shirt until you've paid at least $60.{% endif %}
Kind regards,
Software Freedom Conservancy

View file

@ -8,7 +8,7 @@ from django.utils import timezone
import stripe
from .. import ParameterValidator
from . import forms
from . import forms, mail
from .models import Supporter, SustainerOrder
logger = logging.getLogger(__name__)
@ -138,6 +138,8 @@ def fulfill_checkout(session_id):
order.payment_id = checkout_session['invoice']['payment_intent']
order.save()
logger.info(f'Marked sustainer order {order.id} (order.email) as paid')
email = mail.make_stripe_email(order)
email.send()
except SustainerOrder.DoesNotExist:
logger.info('No action')