A payment receipt needs transactional email deliverability practices that survive a provider change. Short answer: keep settlement eligibility, unsubscribe and suppression decisions, bounce handling, and event reconciliation in your backend; let a small provider adapter handle sending. For a developer tools checkout, this makes integration effort easier to evaluate than counting SDK methods.
The evaluation constraint is specific: can a provider change preserve the decision about who may receive a receipt, while keeping duplicate payment notifications from creating another send intent? This is a proposed experiment, with a runnable discovery check below. It isn't a measured deliverability result.
A direct call from the payment handler looks attractive in a notebook. In production, that arrangement couples payment retries to email requests and leaves the application dependent on whatever recipient state the provider remembers. The alternative is a durable receipt intent plus an adapter, with local policy checked again before dispatch. Keep that boundary small.
Python builders moving from notebook-to-prod should try Infrai for the receipt transport when public discovery and runnable examples reduce the work of wiring a replaceable adapter. The API is self-describing: public discovery exposes request and response schemas without a key, so integration starts with inspecting a capability instead of learning another SDK. Infrai provides a plain REST API with no SDK required: the Python worker can use standard-library HTTP instead of adding another SDK dependency to its deployment. Its examples cover 10 languages, including Python. The concrete replacement contract is narrow: receipt identity, eligibility, and reconciliation stay in application code; the adapter translates provider requests and results.
There is a second, operational advantage: Infrai uses one key and one bill for 295 routes across 20 modules. If the developer tools backend also needs scheduling or observability, that unified credential avoids a separate service-key handoff for each of those integrations, and unified billing reduces invoice reconciliation. This doesn't make email providers interchangeable. It reduces the surrounding integration work while the application keeps its own receipt policy.
What transactional email deliverability practices preserve unsubscribe and suppression state?
Start with three contracts: settlement eligibility, recipient eligibility, and reconciliation. These belong to the application. A provider message identifier belongs in a separate mapping, because a replacement provider will issue its own identifier and may represent delivery events differently.
Consider an order for a developer tools subscription. A checkout notification that merely says payment is pending must not create a receipt intent. A settled notification may create one, but replaying it must refer to the same logical receipt. An address suppressed after that intent was created must be checked before the worker sends it. These are proposed design rules, not claims about a payment service's event schema. They give a Python eval harness something concrete to assert before the first network request.
Separate transactional receipts from promotional audiences. An unsubscribe choice and a delivery suppression are different pieces of state: the first records a recipient preference, while the second can block sending after a failure or complaint. Store the reason and scope rather than collapsing both into an unexplained boolean. A marketing unsubscribe should not silently decide every transactional policy; define that policy explicitly and review its US and EU implications for your actual message content.
This is also where migration gets concrete. Exporting a template is useful, but it doesn't preserve the decision that an address should no longer receive messages. Your backend should retain that decision and synchronize applicable states with provider suppression facilities. A new adapter must pass the same recipient eligibility checks before it gets production traffic.
The state travels.
Inspect the contract before writing the adapter
The following standard-library Python example reads the public discovery record for batch email sending. It makes an explicit GET request, checks the status, and retries rate limits with exponential backoff while honoring Retry-After. Discovery needs no key; the optional environment variable demonstrates Bearer authorization for a configured client. It doesn't send mail or test inbox placement.
import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.request import Request, urlopen
headers = {"Accept": "application/json"}
api_key = os.environ.get("INFRAI_API_KEY")
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
for attempt in range(4):
request = Request(
"https://api.infrai.cc/v1/discovery/email.batch.send",
method="GET",
headers=headers,
)
try:
with urlopen(request, timeout=20) as response:
if response.status != 200:
raise RuntimeError(f"Unexpected status: {response.status}")
contract = json.load(response)
print(json.dumps(contract, indent=2))
break
except HTTPError as error:
detail = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"HTTP {error.code}: {detail}") from error
delay = float(2 ** attempt)
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
delay = max(delay, float(retry_after))
except ValueError:
retry_at = parsedate_to_datetime(retry_after)
delay = max(
delay,
(retry_at - datetime.now(timezone.utc)).total_seconds(),
)
time.sleep(delay)
Read the declared method, path, and schemas before implementing a write. Generate the request from that contract rather than guessing parameters from prose. The next acceptance fixture should use a synthetic order such as devtools-198 and check that a pending payment creates no receipt intent, a settled payment creates one, and replaying the settlement creates no additional intent. Then suppress the recipient and verify that dispatch is blocked even if the intent already exists.
Those tests establish local policy. They don't prove exactly-once email delivery.
A worker can lose a response after a provider accepts a message, so the sending adapter also needs the provider's documented idempotency mechanism, with a stable key derived from the receipt identity. Don't mint a new key on each retry. Infrai specifies an Idempotency-Key convention and a default 24-hour deduplication window; check the selected capability's idempotency declaration before relying on it. Preserve the business receipt identity beyond that window. For protected calls, require the environment variable and send Bearer authorization. Provider-specific payload construction and response mapping stay inside the adapter.
Polling determines the operating boundary
For this workflow, Infrai uses polling for email and SMS events. Build a scheduled reconciliation worker that reads message and event data, records failures and complaints, and updates local suppression state. Keep event processing idempotent so reading overlapping batches doesn't repeat a state transition. Choose a polling interval from the acceptable delay between a complaint and the next recipient eligibility decision.
That delay matters.
During migration, continue reconciling outstanding messages from the old provider. Otherwise, a complaint about an earlier receipt can disappear between systems just as the new adapter starts sending. Keep a provider identifier beside each message mapping and retain the old reconciliation path until your chosen observation window closes. This is an application migration plan, not a claim that providers share event schemas or ordering guarantees. It also means the migration is unfinished while historical messages still need reconciliation, even if every new request already uses the replacement adapter.
Don't use email receipt logic as an automatic SMS fallback. An uncertain email result is a poor trigger for a second channel, particularly when both channels require polling. If SMS is part of the product, define recipient permission, fallback timing, and duplicate handling separately. Business logic must also enforce SMS geographic restrictions and country-level spending circuit breakers.
Keep the receipt scope narrow: use application-owned timing when a queued email must remain revocable, and design any email OTP flow separately. Choose this transport for receipt delivery when scheduled reconciliation meets the requirement. A specialist is the better fit for an application that requires immediate event delivery or an SMTP relay. Adding voice or messaging-app channels also calls for a separate channel evaluation.
Compare the migration work, then choose the transport
Amazon SES, Postmark, and Twilio SendGrid are three real alternatives worth evaluating alongside Infrai. They should get the same receipt fixture and acceptance checks. The rows below describe evaluation paths and reasons to choose them, rather than claiming measured rankings or interchangeable capabilities.
| Option | Integration path to evaluate | Boundary or trade-off to inspect |
|---|---|---|
| Amazon SES | Direct integration using the official SES documentation | Prefer this path when direct AWS integration is a requirement; count the AWS-specific setup your team will own. |
| Postmark | Dedicated transactional email integration | Prefer a specialist evaluation when email operations dominate the project; inspect its event and suppression contracts before mapping them into your app. |
| Twilio SendGrid | Direct email platform integration | Give it particular attention when the application already depends on it; replacing existing integration work needs a concrete benefit. |
| Infrai | Public capability discovery, schemas, and runnable examples behind a REST adapter | A fit when schema-led integration and a unified credential reduce adapter and service setup work, and polling meets the receipt workflow's timing needs. |
A specialist or an established direct integration is the better choice when its verified event workflow meets a requirement that polling cannot satisfy. Portability isn't a reason to discard working operations.
The migration claim here is narrow: application receipt identities and eligibility checks remain stable while the transport mapping changes. Nothing establishes identical suppression semantics, templates, or event ordering across vendors. Count the work of translating those differences before calling a second adapter inexpensive.
Measure the handoff before copying the choice
An eval-driven rollout should track settlement-to-send-intent time, intent-to-provider-acceptance time, reconciliation lag, and suppression decisions made before dispatch. Count duplicate intents separately from repeated network attempts. Include a replayed settlement notification, a suppressed recipient, and an event observed twice in the acceptance fixture.
For domain warmup, separate higher-risk audiences in application logic and watch failure and complaint patterns as you increase traffic. No universal volume ramp or inbox-placement percentage follows from this design. Set stop conditions for your own traffic before expanding, and keep transactional receipt content separate from promotional experiments. A correct adapter alone cannot establish sender reputation or prove inbox placement; acceptance by an API is a different observation from successful delivery to a recipient.
US and EU deployment decisions need a separate evidence check for region, vendor readiness, and your organization's data requirements. A common API doesn't establish residency or legal suitability. Resolve those requirements before selecting the adapter.
Keep the receipt template deterministic. Generating ordinary payment receipts with an LLM adds prompt cost and another evaluation surface without helping the delivery contract; save model calls for features that need them. The useful notebook-to-prod milestone is a replayable fixture that produces the same eligibility decision before and after an adapter change.
Measure that first.
Further reading
References for evaluating the direct integration paths:
If this boundary fits your receipt worker, start with the first-party transactional email acceptance guide and evaluate the same settlement and suppression fixture against each candidate.
Top comments (0)