Email API for Ecommerce: Keep Orders, Payments and Shipments Distinct
Design ecommerce email around durable business events so retries, partial shipments and refunds do not create duplicate or misleading messages.
TL;DR
- Design notifications so payment confirmations, receipts, shipments and refunds are distinct events rather than one “order email,” preventing deduplication collisions and supporting clear customer-service evidence.
- Make commerce events authoritative: map systems for payment, fulfillment and refunds, record business changes with notification intent, and render messages from immutable, versioned event snapshots.
- Verify design with commerce-specific acceptance tests and a small live canary that distinguishes order logic from delivery state, ensuring provider integration preserves evidence through retries and failures.
One order can justify several different emails
An ecommerce order is not a single email event. A customer may receive a payment confirmation, order receipt, shipment update, partial refund notice and final cancellation message at different times. Treating all of them as “the order email” creates collisions in deduplication and confusion in customer support.
Start with an event map. Identify which system is authoritative for payment, fulfillment and refunds. Then define the notification associated with each event. A repeated payment callback should not create another receipt, while a second legitimate shipment may require another shipment notification.
This distinction matters when evaluating an email API. The provider must fit the sending and evidence requirements, but your application must decide what happened in the business. No email service can infer the correct order state from a loosely assembled HTML payload.
Related reading: Scheduled Email Delivery: Store the Time, Content and Cancellation State.
Make the commerce event authoritative
Suppose an illustrative store receives the same payment-success callback three times. The application should recognize one payment event and one corresponding confirmation intent. It should not create three email jobs and hope that the provider guesses they are duplicates.
Record the business change and notification intent together where your database architecture allows it. An outbox pattern is one documented way to avoid the gap between committing data and requesting an external action. It still requires idempotent consumers and a recovery policy. Transactional outbox pattern.
Do not send a final payment confirmation merely because a checkout page loaded. Browser navigation is not authoritative payment evidence. Similarly, a label being created does not necessarily mean a package has left the warehouse. Match the message wording to the event your system can actually establish.
Design identities for partial fulfillment
Use a notification identity that describes the intended event, not just the order number. An order confirmation might be unique per completed order, while a shipment message is unique per shipment event. A refund notice should refer to a particular refund record.
Store that identity before sending and preserve it during recovery. If the provider supports idempotent submission for the relevant operation, use the same key for retries of that operation. A new random key on every worker execution defeats the purpose.
SendDart's documented SDK supports operation keys on specified send endpoints and exposes message retrieval for reconciliation. Review the current recovery contract before adding retries. Do not assume that a failed network response means the message was never accepted. SendDart SDK documentation.
Render from an immutable snapshot
An order can change after checkout. Product names may be edited, addresses corrected and taxes adjusted. Decide what the email should represent, then render from a versioned event snapshot rather than a collection of mutable current records.
For a receipt, preserve the amounts and currency associated with the confirmed transaction. For a shipment notice, preserve the shipment items and tracking reference. If an address correction triggers a new message, record that as a deliberate event rather than silently changing content during a retry.
Test unusual data: multiple currencies in different orders, long product names, discounts, zero-cost items, partial quantities and missing optional address lines. Use fictional customer details. The email should remain understandable without relying on an image to convey essential totals or instructions.
Separate delivery state from order state
An email bounce does not cancel an order. A successful email submission does not prove payment completion. Keep notification status in its own record and expose it to support alongside, rather than inside, the authoritative commerce state.
Support should be able to see that the order was confirmed, the receipt was accepted by the provider and a later delivery failure occurred. That gives them a basis for correcting an address or guiding the customer without accidentally changing fulfillment.
Avoid automatically emailing a different address because one bounced. Address changes should follow your account or order verification policy. A convenient recovery shortcut can reveal private purchase details to the wrong recipient if identity checks are bypassed.
Choose links and attachments deliberately
Receipts and invoices may be delivered as attachments or through authenticated download links, depending on product and access requirements. Evaluate size, versioning, access control and retention. A public permanent file URL is not equivalent to a private account download.
If the worker fetches an attachment at send time, ensure that the URL remains valid long enough and points to the intended immutable document. A short-lived URL can expire while a queued message waits. A mutable URL can return a different invoice on retry.
For customer-facing links, use the canonical application origin and a supported route. Do not build links from untrusted request headers or arbitrary user-provided hosts. Test them in the final rendered message, including the plain-text alternative.
Run a commerce-specific acceptance test
Test a repeated payment callback, two partial shipments, a refund after shipment and a worker interruption after submission. Verify the number and purpose of notifications created. Then test delivery-event replay and confirm that it updates evidence without generating another business email.
Keep a small live canary separate from simulated transport tests. The canary validates domain configuration and real provider correlation; local tests validate order logic and recovery. Neither should send duplicate notifications to customers merely for experimentation.
Choose an email API that lets your team maintain this evidence trail and operate within its limits. The dependable ecommerce design is the combination of clear business events, immutable rendering and controlled sending. A provider integration succeeds when it preserves that design through retries, changes and ordinary operational failures.
Related reading: Best Email API: Choose With a Production Acceptance Test.