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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user