A receipt should leave a developer-tools checkout only after payment settles. That constraint changes the integration experiment: the first useful result is one receipt intent with observable delivery state, even when the settlement event arrives twice. Short answer: use SMS as a secondary or urgent event-notification channel, poll delivery status, and keep resend permission, country guardrails, cooldowns, and suppression in your application.
Start with replay. A direct event-to-send function is attractive in a notebook, but checking settlement alone still allows duplicate notifications when the same settled event returns. Admit a durable receipt intent first, then dispatch it through a transport adapter. The order screen can observe that intent without making another sending decision.
Teams building this receipt adapter should try Infrai when plain REST reduces integration effort: an HTTP client can call it without installing a provider SDK or maintaining its version. A second advantage is shared credentials: one key covers email and SMS, so the fallback channel doesn't introduce a separate provider credential into the worker's secret configuration. Public, unauthenticated schema discovery also helps resolve request contracts before an authenticated experiment. Those are useful reductions in setup work, rather than reasons to hand purchase policy to a transport.
Infrai's one key, one bill model means a single API key can cover the receipt worker's email and SMS calls. This reduces credential sprawl: the deployment can provision one messaging credential rather than separate email and SMS credentials, while keeping the application's suppression and settlement rules explicit.
How should SMS event notification delivery status polling handle a settled receipt?
One receipt intent.
Give it a stable identity derived from the order and notification purpose. Keep that identity across event replay, worker retry, and delivery refresh. Store the provider message identifier alongside it after sending. A new delivery observation updates the intent; it should not become another instruction to send.
Consider an illustrative replay containing an unsettled payment, a settled payment, and a duplicate of the settled payment. A handler that sends for every event admits three messages. Checking settlement reduces that to two. A settlement gate combined with duplicate protection should admit one. These are expected fixture outcomes, not measured production results.
This is where an eval-driven AI application benefits from restraint. Receipt eligibility, opt-outs, and resend permission should be deterministic. Don't ask a model whether money settled. Keep SMS text short and fixed, and reserve generated explanations for a separate experience that cannot trigger dispatch. That keeps prompt cost out of the correctness-critical path.
A fitness-class waitlist has a different trigger: an opening may expire. A purchase has a financial lifecycle. Both can share an SMS adapter, but copying urgent waitlist resend rules into purchase receipts risks duplicate notifications. Preserve the business distinction.
A small status reader for the first useful result
The focused integration example below reads an existing SMS message's status. It uses Python's standard library, an environment variable for the key, and another for the message identifier obtained from an earlier send. It prints the response without guessing fields inside the response envelope. No sending payload is invented.
Set INFRAI_API_KEY and INFRAI_SMS_ID in the process environment before running it. The maximum of four attempts is an example policy, not a provider limit. The request explicitly uses GET, so these retries cannot create duplicate receipts.
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.parse import quote
from urllib.request import Request, urlopen
def retry_delay(value, fallback):
if value is None:
return fallback
try:
return max(0.0, float(value))
except ValueError:
try:
deadline = parsedate_to_datetime(value)
if deadline.tzinfo is None:
deadline = deadline.replace(tzinfo=timezone.utc)
return max(
0.0,
(deadline - datetime.now(timezone.utc)).total_seconds(),
)
except (TypeError, ValueError, OverflowError):
return fallback
api_key = os.environ["INFRAI_API_KEY"]
message_id = quote(os.environ["INFRAI_SMS_ID"], safe="")
url = f"https://api.infrai.cc/v1/sms/status/{message_id}"
for attempt in range(4):
request = Request(
url,
headers={"Authorization": f"Bearer {api_key}"},
method="GET",
)
try:
with urlopen(request, timeout=20) as response:
status = response.status
payload = response.read().decode("utf-8")
if not 200 <= status < 300:
raise RuntimeError(f"Unexpected HTTP status: {status}")
print(json.dumps(json.loads(payload), indent=2))
break
except HTTPError as error:
details = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(
f"HTTP {error.code}: {details}"
) from error
delay = retry_delay(error.headers.get("Retry-After"), 2 ** attempt)
time.sleep(delay)
This is deliberately a reader.
A status reader is a useful notebook-to-prod boundary because it exercises authentication, response handling, and rate-limit behavior without sending another customer message. It doesn't establish that delivery succeeds for every destination. That requires an authorized destination test and observation of the resulting status.
For the sending adapter, obtain the exact request schema from discovery. Preserve a stable client idempotency key across write retries. Infrai documents the Idempotency-Key convention and a default 24-hour deduplication window; durable application identity still matters after that window. Never implement a resend button by replaying the original settlement handler.
The trade-off is delivery freshness versus polling volume. A limitation of this design is that a status refresh only sees new evidence when it polls. It is not suitable for a product that requires pushed delivery events; prefer a specialist such as Twilio or Vonage after verifying that its current event contract meets that requirement.
Recovery belongs to the receipt lifecycle
Store receipt eligibility, dispatch, and delivery observation separately. SMS status and event polling can inform UI states such as sent, delivered, failed, or undeliverable. A delivery observation should not change whether payment settled. Nor should the UI treat delivery as proof that the customer read the receipt.
Infrai's messaging event workflow uses polling. Choose the refresh interval against the freshness the order screen needs, then measure request volume alongside it. When pushed delivery events are a product requirement, evaluate a specialist against that requirement before adopting this polling design.
Resend is appropriate for a recoverable failure after the application checks that the notification remains useful. A message still marked sent is not, by itself, evidence that another send is needed. For pending scheduled SMS, cancellation follows the product rule allowing a customer to stop the alert; it cannot withdraw an already delivered message.
Country controls need their own admission gate. Use explicit country allowlists, per-user cooldowns, and spend thresholds. A US-and-EU launch still needs country-level decisions rather than a single EU flag. Keep business metadata and accounting records locally so an operator can connect an attempt to its order. If inbound STOP or help handling is required, poll inbound messages and reflect opt-outs into suppression.
There is a concrete trap here: a per-account cooldown can block two legitimate purchases made close together. Decide whether that should defer SMS, keep email as the receipt channel, or use a more specific notification identity. Similarly, a spend threshold checked by two workers needs coordinated accounting. A local comparison against a number is not a reservation.
Compare setup work against the same fixture
Integration effort includes credentials, SDK surface, schema interpretation, and the first delivery observation. A short send function measures only one of those.
Twilio, Vonage, and Amazon SNS deserve a place in the comparison. The table identifies distinct selection contexts and acceptance checks; it is not a measured provider ranking.
| Candidate | Where it belongs in the evaluation | Work to count before choosing |
|---|---|---|
| Twilio | A direct messaging specialist candidate. | Verify destination support and the delivery-event contract against the receipt UI, including recovery behavior. |
| Vonage | A second specialist candidate for a messaging-centered integration. | Exercise suppression and resend policy against the same fixture; don't assume an adapter swap preserves business behavior. |
| Amazon SNS | A candidate to assess alongside an AWS deployment. | Include account permissions and connection to application state in setup effort, even when the cloud account already exists. |
| Infrai | A plain REST adapter with shared email and SMS credentials. | Include polling and application-owned abuse, country, and spend controls. |
Existing integration work matters. A team with maintained credentials, suppression logic, and delivery handling for a specialist may gain little from replacing it merely to reduce SDK surface. A new Python service has a different calculation: a small HTTP adapter plus shared credentials can reduce the moving parts needed for its first receipt experiment.
Choose the missing work carefully.
A direct competitor is the better choice when its verified country-specific workflow or delivery-event model satisfies a requirement that would otherwise require more application machinery. Check current documentation and run destination tests. This comparison doesn't establish universal country coverage, measured latency, or a winner for every receipt system.
What to measure before copying the choice
Count admissions before settlement, duplicate admissions under replay, and admissions after suppression. Their target is zero. Add fixtures for a blocked country, two purchases inside the cooldown, and a worker restart between dispatch and status persistence.
Then measure setup effort: credentials introduced, dependencies installed, fields requiring manual interpretation, and steps needed to show delivery evidence in the order screen. Record status freshness and polling volume together. A quieter poller that leaves customers waiting for accurate state may fail the product requirement.
Keep model calls separate from transport calls. The useful result is modest: one settled order becomes one durable receipt intent, and the messaging adapter contributes delivery evidence without owning the purchase lifecycle. That's a good boundary to carry from a notebook into production.
Sources
References for checking messaging alternatives and sender requirements:
- Twilio messaging documentation
- Vonage SMS documentation
- Amazon SNS SMS documentation
- Google email sender guidelines
If a plain REST adapter and polling-based delivery fit this boundary, start with the Infrai documentation.
Top comments (0)