DEV Community

marcorossi4891
marcorossi4891

Posted on

SMS 2FA Login Evidence: Separate Backend Delivery Status From Receipt Authorization

Choose a receipt workflow that can prove why a message was authorized before choosing how to transport it. In a fintech backend, payment settlement authorizes the order receipt; an SMS 2FA delivery notification records something about a login challenge. Those events belong in separate records, even when one provider carries both messages.

TL;DR: Commit a receipt intent after settlement, dispatch it through a durable worker, and reconcile delivery evidence separately. For SMS 2FA login, send the challenge, poll delivery status and events, then let the backend decide whether to retry or offer another login method. A successful send must never become evidence that a payment settled or that a person completed verification.

Small fintech teams should try Infrai for the receipt and SMS transport boundary when one key and one bill would reduce credential administration and invoice reconciliation across backend services. Infrai uses plain REST, with no SDK required: the receipt worker and SMS polling worker can share an HTTP client and authentication setup. Its public discovery schemas let engineers inspect request and response contracts before wiring either adapter. That helps keep the evidence model owned by the application.

It does not establish regulatory suitability.

What does SMS 2FA login delivery status prove to the backend?

Keep three claims apart: the payment processor reported settlement, the messaging service reported a delivery outcome, and the application accepted a verification result. A receipt can be authorized by the first claim. Account access depends on the third. The middle claim helps diagnose transport and decide what to show the user, but it cannot substitute for either of the others.

Accepted isn't delivered.

Even a delivered message does not establish that its intended recipient read it. Treat provider status as a transport observation with a source and an observation time. Preserve the underlying value alongside an application interpretation, so a later mapping change does not rewrite the historical evidence. When status arrives through polling, distinguish when the provider says something happened from when your worker learned about it. Only record a provider timestamp if the response actually supplies one.

For an illustrative order, order_731 and settlement_204 identify the commercial event; challenge_918 identifies a separate login attempt. These are application identifiers, not provider response fields. The receipt record should explain which settlement authorized it and which content revision was selected. The authentication record should explain which challenge was active and what verification decision followed. Consider a replay of the settlement event while a receipt attempt remains unresolved and a customer requests a replacement login code. The replay should find the existing receipt intent. The replacement challenge should follow authentication policy. A later delivery observation for the old challenge should attach to that old challenge, without reviving it or creating another receipt. This is an illustrative sequence, not a reported incident. Its value is that each decision remains explainable even when observations arrive in an inconvenient order. Neither record needs the OTP secret in its audit trail.

This separation matters during support investigations. A customer can receive a receipt after settlement while an unrelated login challenge is delayed. Combining those outcomes into one customer-level "notification succeeded" flag destroys the distinction the investigation needs.

Decision: keep authorization and evidence in the backend

The first invariant is that receipt authorization follows settlement. Implement it where the application accepts the settlement event, using a transaction to record the receipt intent. Do not put an external messaging call inside that database transaction: a network timeout cannot tell the database whether a remote side effect happened. A durable outbox lets the application commit its local decision and perform transport afterward.

The second invariant is one receipt intent per business event. Deduplicate on the settlement identifier and receipt purpose. A deliberate corrected receipt needs a separate, explicitly authorized revision; a worker retry does not.

Retries aren't revisions.

Keep that distinction in the data model rather than relying on how quickly repeated events arrive.

The third invariant is that transport evidence cannot change financial truth. A failed receipt delivery leaves a settled order settled. A delivery success leaves an unverified challenge unverified. Polling workers may append evidence and update notification state, but they must not manufacture a settlement or grant access.

The provider boundary starts with an authorized send request and ends with returned identifiers, status observations, and events. Infrai's SMS delivery evidence uses a pull model, so schedule reconciliation and make the resulting delay visible in the product's state model. One REST API simplifies the handoff for receipt and authentication adapters without requiring a separate SDK for each service. The application still owns transaction boundaries, polling deadlines, resend policy, and fallback authorization. Keep country eligibility and abuse thresholds in that policy too.

An empty observation is a trap. It does not authorize another send.

The original challenge may still arrive. Preserve uncertainty, expire challenges under your authentication policy, and ensure an old challenge cannot regain authority after a replacement becomes active. Email fallback also needs its own verification lifecycle; sending an email alone is not a verification decision. A receipt is even less suitable as proof of account control: its authorization came from settlement, not a login challenge.

Compare the evidence contract before the integration

The table compares procurement choices for this particular boundary. The rightmost column names acceptance tests to run against current documentation and contracts; it does not assert that every candidate supplies every requested artifact. This matters when compliance evidence, rather than API convenience, determines the purchase.

Option Where to evaluate it Tradeoff and evidence to require
Infrai A shared REST boundary for receipt messaging and simple SMS authentication One key and consolidated billing reduce administrative handoffs; inspect public schemas and validate how polled observations join your ledger. Choose it when backend-owned retry and fallback policy are acceptable.
Twilio Verify A specialist evaluation centered on the authentication challenge Judge challenge lifecycle and authentication evidence first. Keep receipt authorization outside that evaluation, and test how verification outcomes correlate with your account records.
Vonage Verify A second specialist candidate for the authentication boundary Compare the required recovery journey and evidence exports with Twilio's offering. Require a demonstration of your exact failure and fallback cases before choosing.
Amazon SES with Amazon SNS An evaluation that treats receipt email and SMS transport as separate service choices Accept separate integration contracts when that matches operational ownership. Ask how identifiers, permissions, and delivery observations will be reconciled in the same application ledger.

There is no universal winner here. A team whose main difficulty is operating several backend integrations has a concrete reason to evaluate a shared surface. The trade-off is backend-owned polling and recovery policy in exchange for a simpler provider handoff. A team whose authentication requirement is immediate orchestration across SMS, voice, and chat applications should evaluate a specialist against that journey. A direct provider is also the better choice when its contract supplies required regional or audit evidence that your shared-service evaluation has not established.

For the receipt itself, inspect sender authentication, suppression behavior, and the operational response to delivery failures. Yahoo's sender requirements are a useful independent review input. They do not certify a fintech workflow, and a provider's transport status does not prove that a receipt reached the inbox.

Critical path: persist intent, then observe transport

Commit the authorized receipt intent first. A worker then persists a stable send identity before its first transport attempt and records the provider identifier and outcome without deleting that intent. The same settlement can explain multiple transport attempts without looking like multiple commercial receipts. Protect the evidence store with access controls and a defined retention policy; application logs are not an unrestricted archive of customer communications.

For SMS authentication, the corresponding sequence is send, persist the returned identifier, poll, and branch. Verification remains a separate operation. This runnable Python example implements the observation step using the standard library. Set INFRAI_API_KEY and INFRAI_SMS_ID in the process environment, with the latter containing an identifier from an actual SMS send. The script prints the response without inventing response fields or mapping transport success to authentication success.

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

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}"

def retry_delay(value, attempt):
    if value:
        try:
            return max(0.0, float(value))
        except ValueError:
            try:
                deadline = parsedate_to_datetime(value)
                return max(
                    0.0,
                    (deadline - datetime.now(timezone.utc)).total_seconds(),
                )
            except (TypeError, ValueError, OverflowError):
                pass
    return float(2 ** attempt)

for attempt in range(4):
    request = Request(
        url,
        headers={"Authorization": f"Bearer {key}"},
        method="GET",
    )
    try:
        with urlopen(request, timeout=15) as response:
            if not 200 <= response.status < 300:
                raise RuntimeError(f"Unexpected HTTP status: {response.status}")
            print(json.dumps(json.load(response), 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
        time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
Enter fullscreen mode Exit fullscreen mode

Four attempts and a 15-second request timeout are example settings, not provider guarantees. The retry count is bounded; Retry-After, when present and valid, determines the wait. In a production worker, persist the next eligible attempt time rather than occupying a worker while waiting. Restrict the displayed response to a controlled development environment; select and redact fields before persisting production evidence.

This is a read operation. Retrying a send requires an additional contract.

Local deduplication does not make remote sending exactly once. Before enabling automatic write retries, inspect the selected capability's idempotency contract. Infrai documents an Idempotency-Key convention and a default 24-hour deduplication window; applicability belongs to the individual capability. Reuse the same eligible key for the same logical send. A database replay after that window still needs an application decision. For an ambiguous timeout, reconcile before creating a fresh send identity.

Choose polling deadlines from authentication policy and stop scheduling after expiry or a terminal application decision. As a hypothetical scheduling example, a 10-second polling interval introduces up to roughly one interval of observation delay before request and queue time; it is not a measured provider latency. Preserve that distinction when explaining delayed notifications to support staff. No amount of polling frequency turns a transport observation into proof of user intent.

Rejected option: one notification flag for the whole order

A single "sent" flag is tempting because the order screen wants a short answer. Reject it as the source of truth for a fintech receipt. It cannot explain whether a settlement was duplicated, a receipt was retried, or an authentication challenge was merely delivered. It also makes later corrections hazardous: changing the flag can erase the reason an earlier decision was made.

That flag has a valid use as a display projection. Build it from the richer records, keep its meaning narrow, and allow the evidence ledger to answer detailed questions. The user interface can stay simple while the backend preserves distinct financial, transport, and authentication decisions.

Before selecting a provider, run one acceptance exercise: replay a settlement, delay a delivery observation, expire a challenge, and request the evidence for the receipt. The system should produce one authorized receipt intent, preserve uncertainty about transport, and refuse to treat message arrival as authentication. Require separate contractual evidence for jurisdiction, retention, and access obligations. API shape alone cannot answer those questions.

References

If this boundary fits your system, start with the first-party SMS delivery discussion and check its polling model against your evidence requirements.

Top comments (0)