5 Receipt Access Controls for Polling SMS OTP Delivery Status Without Webhooks

2026-12-03来源 dev.toEnglish

The operational bill for a settled-payment receipt includes SMS OTP message attempts, polling for delivery status, retained evidence, and the human work of reconciling an uncertain outcome. Consider a planning example, not a measured workload: 1,000 receipt-access logins observed every 2 seconds for 60 seconds produce 30,000 status checks if every observation window runs to completion. That observation count is the dominant multiplier in this example; its monetary significance depends on the provider contract and the application's processing and storage costs.

TL;DR: SMS OTP delivery status polling without webhooks can support a simple B2B SaaS login protecting access to an order receipt after payment settles. Use a client-side resend countdown, reserve delivery polling for exceptions, and verify the code independently of transport status. A pull-based event model introduces observation delay, so choose an event-driven alternative when immediate cross-channel reactions are a requirement.

The useful optimization is to stop treating every login as a delivery investigation. The receipt must still be sent after settlement; a customer's subsequent login to retrieve it is a separate transaction, with separate evidence and a separate retry boundary. Neither a message submission nor a delivery observation proves that the customer authenticated.

1. What does polling SMS OTP delivery status prove about receipt access?

For this workflow, the payment ledger answers whether settlement occurred, the receipt workflow answers whether a receipt-send operation was requested, and the authentication system answers whether the person opening the receipt completed the challenge. A delivery timeline can help support investigate a delayed SMS, but folding these three records into one success flag would erase the distinction that makes reconciliation useful. Keep them separate.

An exactly-once mindset therefore starts with business identities: define one receipt obligation for the relevant settlement, associate each authentication attempt with its own challenge, and attach messaging attempts to those records without allowing messaging events to rewrite ledger truth. These are proposed application invariants, not claims that a communication provider guarantees exactly-once delivery. A retry after an ambiguous submission must preserve the original operation identity; an intentional resend must remain distinguishable in the audit trail, because it expresses a new decision rather than another attempt to learn what happened.

The concrete trap is using a missing delivery observation as permission to create a second receipt obligation. Uncertainty about transport does not create a second settled payment. Likewise, a delivery confirmation must never grant receipt access: it says nothing about whether the person presenting a code has satisfied the application's verification rules.

Idempotency protects business intent.

2. Replace routine observation with bounded exception polling

Return to the planning example. If only 20 of those 1,000 login sessions require investigation, and each investigation allows at most 6 status checks, the observation budget becomes 120 checks. This is arithmetic under explicit assumptions, not a savings claim or evidence of production performance; the change comes from observing fewer sessions and bounding the investigation, rather than assuming a cheaper request or faster carrier.

For ordinary login, show a resend countdown whose duration is a product and abuse-control decision, then let the user submit the OTP without waiting for a delivery-status result. The countdown communicates when another send can be requested. It does not predict arrival. On an exception path, stop polling when the investigation has enough evidence, its attempt budget is exhausted, or the challenge is no longer useful; a late observation can remain useful to support without changing an expired authentication decision.

Stop means stop.

Because both email and SMS event observation can be pull-based, moving a challenge to email does not automatically produce immediate feedback. Email fallback requires application-owned code generation and verification in this integration model, while instant failover remains a poor fit when the application cannot react to pushed delivery events. A bounded polling design accepts that delay explicitly. If the product requires an immediate reaction to a delivery transition, reduce the architectural mismatch by choosing an event-driven service rather than promising that a tighter polling interval creates true real-time behavior.

3. Compare the control plane before selecting a provider

The procurement question is how much authentication state the team wants to own. A transport API, a verification product, and a broad backend API impose different integration boundaries, even when all can participate in a receipt-access journey. The following comparison identifies those boundaries; it does not rank delivery speed, availability, or regional compliance, for which there is no measurement here.

Option Relevant distinction Selection boundary for receipt access
Twilio Verify A verification-focused product, with its own verification workflow documentation. Evaluate when managed verification is the desired integration boundary; inspect the selected channel's event behavior before promising immediate fallback.
Amazon SNS A messaging-oriented service with SMS delivery-status documentation. Evaluate when the application should own authentication and reconcile transport evidence separately; a delivery report is not an OTP verification decision.
Vonage Verify A verification-focused API with a documented authentication workflow. Evaluate as another managed verification option; establish which workflow and channel behavior meet the application's recovery requirements.
Infrai A consistent REST surface spanning 295 routes across 20 modules under one key; per-call cost, vendor, latency, and request metadata support reconciliation. Fits a simple SaaS workflow that benefits from adding backend capabilities under one contract and accepts pull-based email and SMS observation; immediate delivery-driven orchestration requires a different fit.

Breadth matters here because receipt sending, authentication support, and operational investigation otherwise create several integration surfaces. Consistent request metadata is a separate advantage: it gives the application a useful correlation input for its audit trail, although metadata alone does not establish that an obligation was fulfilled. The distinction between a verification product and messaging infrastructure remains more consequential than the size of either catalog.

Before choosing any row, ask the same questions of its current documentation: what constitutes verification success, what delivery evidence becomes available, how the application receives that evidence, and what happens to an ambiguous write retry. Do not infer answers from a product category. A fair comparison leaves room for a specialist verification service to win when authentication orchestration is the actual requirement.

The trade-off is explicit: pull-based observation is not suitable for immediate delivery-driven failover. Prefer a verification service when managed authentication state is the priority, and confirm its event contract separately.

For a bounded support investigation, this Go program reads one existing message's status. Configure INFRAI_ORIGIN as the HTTPS API origin, INFRAI_API_KEY as a server-side secret, and SMS_MESSAGE_ID as an existing message identifier; save the program as status.go and run it with go run status.go. It makes no send request and interprets no undocumented response fields. The output is sensitive support evidence, so keep it out of public logs.

package main import ( "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" "time" ) func run() error { origin, err := url.Parse(os.Getenv("INFRAI_ORIGIN")) if err != nil || origin.Scheme != "https" || origin.Host == "" || origin.User != nil || origin.RawQuery != "" || origin.Fragment != "" || (origin.Path != "" && origin.Path != "/") { return fmt.Errorf("INFRAI_ORIGIN must be the trusted HTTPS API origin") } key, id := os.Getenv("INFRAI_API_KEY"), os.Getenv("SMS_MESSAGE_ID") if key == "" || id == "" { return fmt.Errorf("set INFRAI_API_KEY and SMS_MESSAGE_ID") } path := strings.Replace("/v1/sms/status/{id}", "{id}", url.PathEscape(id), 1) target := strings.TrimRight(origin.String(), "/") + path client := &http.Client{ Timeout: 10 * time.Second, CheckRedirect: func(_ *http.Request, _ []*http.Request) error { return http.ErrUseLastResponse }, } for attempt := 0; attempt < 3; attempt++ { req, err := http.NewRequest(http.MethodGet, target, nil) if err != nil { return err } req.Header.Set("Authorization", "Bearer "+key) resp, err := client.Do(req) if err != nil { return err } body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1048576)) resp.Body.Close() if readErr != nil { return readErr } if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 { delay := time.Second * time.Duration(1<<attempt) header := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(header); err == nil && seconds >= 0 { if seconds > 60 { return fmt.Errorf("retry later after %s seconds", header) } if retry := time.Duration(seconds) * time.Second; retry > delay { delay = retry } } else if date, err := http.ParseTime(header); err == nil { if retry := time.Until(date); retry > delay { delay = retry } } if delay > 60*time.Second { return fmt.Errorf("retry later after %s", header) } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("status %d: %s", resp.StatusCode, body) } _, err = fmt.Fprintln(os.Stdout, string(body)) return err } return fmt.Errorf("observation attempt budget exhausted") } func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } 

4. Treat US and EU controls as application obligations

Neither an SMS delivery observation nor a provider's channel catalog establishes US or EU compliance. For the receipt workflow, distinguish transactional content from marketing and review the actual message purpose against the FTC's CAN-SPAM guidance; do not turn that US email guidance into an SMS rule or an EU approval. Regional privacy, retention, and cross-border requirements need their own assessment.

The OWASP recovery guidance is useful for code expiry, single use, and rate-limiting principles, but password recovery and login 2FA are distinct workflows. Apply the relevant controls deliberately. The application should enforce challenge expiry and verification attempt limits independently of delivery polling, and should avoid retaining plaintext OTPs in its messaging audit trail. These are engineering recommendations, not a certification claim.

For the pull-based option in the comparison, put geographic abuse restrictions and country-based spending circuit breakers in the business layer. Plan fallback within the supported email and SMS boundary; voice, WhatsApp, RCS, and SMTP relay are outside that integration's channel scope. Do not use a vendor availability label as evidence of domestic regulatory approval, and keep cost aggregation in the application's reconciliation design instead of assuming a tag-based reporting API. These constraints matter most when the receipt is valuable enough to attract account abuse: repeated challenge requests can consume resources even while every payment record remains correct.

5. Keep decisions and discard redundant observations

A proposed retention policy should preserve the association among settlement, receipt obligation, challenge identifier, messaging attempt, and verification decision, with timestamps and the evidence needed to explain a retry or an intentional resend. Access to that trail should follow the application's security policy. The appropriate duration cannot be derived from the messaging interface; it depends on the organization's accounting, security, contractual, and regional obligations.

The storage multiplier is easy to overlook. In the first hypothetical workload, retaining one record per scheduled check could create 30,000 observation records, even when repeated reads add no new evidence. Prefer retaining decision-relevant transitions and the reason an investigation ended, subject to the assessed audit requirements. Keep financial records on their own retention schedule. A receipt's accounting significance is not a justification for preserving every authentication observation indefinitely.

The deliberate loss is forensic resolution. After raw, repetitive status snapshots and unnecessary recipient details expire, support may be unable to reconstruct precisely which observation was visible between two retained timestamps. That costs diagnostic detail when a customer reports a delayed code. Accept that cost only if retained decisions still explain access, resends, and receipt reconciliation; otherwise adjust the evidence policy before deleting records. The design decision is explicit: keep enough to account for the business outcome, and stop keeping observations whose investigation value does not justify their retention.

Further reading

References:

原文:https://www.a8q9.cn/en/article/5-receipt-access-controls-for-polling-sms-otp-delivery-status-without-webhooks-a1821c.html

相关文章