Skip to content

Commit

Permalink
server: Send customer email on subscription.revoked
Browse files Browse the repository at this point in the history
  • Loading branch information
birkjernstrom committed Dec 11, 2024
1 parent 2b1ea58 commit 3e0174e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
31 changes: 31 additions & 0 deletions server/polar/subscription/email_templates/revoked.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends "base.html" %}

{% block body %}
<h1>Your subscription has now ended</h1>
<p>Thank you being a subscriber of <strong>{{ product.name }}</strong>.</p>
<p>We hope to see you again in the future - you're always welcome back.</p>

<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0" role="presentation">
<tr>
<td align="center">
<a href="{{ url | safe }}" class="f-fallback button">View subscription</a>
</td>
</tr>
</table>
</td>
</tr>
</table>

<!-- Sub copy -->
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">If you're having trouble with the button above, copy and paste the URL below into your web browser:</p>
<p class="f-fallback sub"><a href="{{ url | safe }}">{{ url | safe }}</a></p>
</td>
</tr>
</table>
{% endblock %}
9 changes: 9 additions & 0 deletions server/polar/subscription/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ async def _after_subscription_revoked(
await self._send_webhook(
session, subscription, WebhookEventType.subscription_revoked
)
await self.send_revoked_email(session, subscription)
await eventstream.publish_subscription_revoked_event(subscription)

async def _send_new_subscription_notification(
Expand Down Expand Up @@ -814,6 +815,14 @@ async def send_cancellation_email(
template_path="subscription/cancellation.html",
)

async def send_revoked_email(
self, session: AsyncSession, subscription: Subscription
) -> None:
return await self._send_customer_email(
session,
subscription,
subject_template="Your {{ product.name }} subscription has ended",
template_path="subscription/revoked.html",
)

async def _send_customer_email(
Expand Down

0 comments on commit 3e0174e

Please sign in to comment.