feat: add transactional emails for order confirmation and shipping

Plain text emails via Swoosh OrderNotifier module. Order confirmation
triggered from Stripe webhook after payment, shipping notification
from Printify shipment webhook with polling fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-08 10:17:19 +00:00
parent 3e19887499
commit 0af8997623
6 changed files with 328 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ defmodule SimpleshopThemeWeb.StripeWebhookController do
use SimpleshopThemeWeb, :controller
alias SimpleshopTheme.Orders
alias SimpleshopTheme.Orders.OrderSubmissionWorker
alias SimpleshopTheme.Orders.{OrderNotifier, OrderSubmissionWorker}
require Logger
@@ -56,6 +56,9 @@ defmodule SimpleshopThemeWeb.StripeWebhookController do
order
end
# Reload items for the email (update_order doesn't preload)
order = Orders.get_order(order.id)
# Broadcast to success page via PubSub
Phoenix.PubSub.broadcast(
SimpleshopTheme.PubSub,
@@ -63,6 +66,8 @@ defmodule SimpleshopThemeWeb.StripeWebhookController do
{:order_paid, order}
)
OrderNotifier.deliver_order_confirmation(order)
# Submit to fulfilment provider
if order.shipping_address && order.shipping_address != %{} do
OrderSubmissionWorker.enqueue(order.id)