If the payment processor is unavailable, do not add a top-up to the spendable wallet balance until the processor authoritatively confirms payment. Existing model traffic may continue only while confirmed funds or an explicit, risk-limited grace policy allow. Keep metering usage, preserve transaction state, and reconcile every ambiguous payment before issuing credit.
The immediate answer: pause wallet crediting, not necessarily model traffic
A payment outage creates two separate operational questions:
- Can the system safely recognize new funds? Not without authoritative payment confirmation.
- Can existing model requests continue? Potentially, if the account still has confirmed funds or qualifies for a predefined grace policy.
Keeping those decisions separate protects ledger integrity without making the payment processor a direct availability dependency for otherwise healthy inference infrastructure. “Fail closed” should apply narrowly to monetary state: unverified funds remain unavailable. It does not have to mean immediately stopping every model request.
A practical decision model looks like this:
| Account and payment condition | Top-up treatment | Model-traffic treatment |
|---|---|---|
| Confirmed balance remains available | Do not credit unconfirmed funds | Continue while the confirmed balance and usage policy allow |
| Confirmed balance reaches its configured threshold | Keep the top-up unavailable or pending | Throttle or reject new usage according to the account policy |
| Preapproved grace mode is enabled | Do not represent grace as a successful top-up | Permit limited usage within defined exposure and duration limits |
| Payment outcome is unknown after submission | Record an ambiguous or pending state | Use only confirmed balance or an explicitly authorized grace allowance |
Do not increase spendable balance without authoritative payment confirmation
Submitting a payment request and receiving a successful payment result are not the same event. A wallet should recognize new spendable funds only after it can verify the processor’s authoritative status for that payment.
If the processor is unreachable before submission, the safest response is to leave the wallet unchanged and tell the customer that top-ups are temporarily unavailable. If the failure occurs after submission, the outcome may be unknown. The system should preserve the attempt and check its status rather than assuming that it failed and sending another charge.
This avoids two common failure modes:
- Optimistic crediting: The wallet balance increases even though the payment was never authorized or captured.
- Duplicate completion: A retry creates a second charge, a second wallet credit, or both.
Payment confirmation and ledger crediting should also be separate, traceable events. A processor can confirm a payment while the internal credit transaction is still waiting to complete. Conversely, an internal record that says “submitted” does not prove the processor accepted the payment.
Let existing balances and a predefined usage policy govern active traffic
Model serving should consult the account’s confirmed spendable balance and usage policy—not the health of the payment processor alone. If sufficient confirmed funds remain, traffic can continue while the top-up path is degraded.
When the balance reaches a configured threshold, the service needs an explicit response. Depending on the commercial and operational policy, that response might be:
- Allow in-flight requests to finish but reject new requests.
- Reduce concurrency or apply a lower request-rate limit.
- Restrict access to approved models or workload classes.
- Enter a preapproved grace mode for eligible accounts.
- Stop billable traffic when no authorized funding remains.
The choice should reflect how the workload behaves. Interrupting an interactive request, a batch job, and a long-running agent workflow can have different customer and cost implications. The policy should define whether controls apply before a request starts, during an active operation, or at the next metering checkpoint.
Treat grace usage as controlled exposure, not invisible wallet credit
Temporary credit or a negative-balance allowance is optional, not a universal default. If offered, it should be authorized in advance and represented separately from settled wallet funds.
A controlled grace policy can account for:
- Maximum financial exposure per account.
- Maximum outage duration or usage period.
- Account eligibility and risk classification.
- Permitted models, request types, or concurrency levels.
- Escalation thresholds and manual override authority.
- Customer notices and repayment treatment after recovery.
The ledger and audit trail should make it clear that usage occurred under a grace decision. Silently increasing the displayed wallet balance can mislead users and make later reconciliation harder.
Preserve usage metering throughout the outage
Payment availability and usage measurement should be independent. Even if top-ups cannot be confirmed, the serving path should continue recording accepted requests, billable units, timestamps, account identifiers, and the policy under which traffic was allowed.
Durable metering supports three important decisions after recovery:
- Whether usage remained within the confirmed balance.
- Whether a grace allowance was used and stayed within its limits.
- Whether the account balance and usage records need adjustment.
If metering becomes unreliable, continuing unrestricted traffic creates financial uncertainty. The degraded-mode policy should therefore define what happens when both payment processing and usage measurement are impaired.
Represent every top-up with an explicit payment and ledger state
A top-up should move through a visible state model rather than a single success flag. This is especially important when network failures make the processor outcome ambiguous.
A useful state model separates these stages:
| State | Meaning | Spendable balance effect |
|---|---|---|
initiated | A top-up request has been created locally | None |
unavailable | The processor could not accept a submission | None |
submitted or pending | The processor may have received the request, but the result is not final | None |
confirmed | The processor authoritatively reports a successful payment | Eligible for one ledger credit |
failed | The processor authoritatively reports failure or cancellation | None |
credited | The corresponding ledger transaction has increased the wallet balance | Increase applied once |
State transitions should be durable and traceable. Where possible, retain a stable top-up identifier, the processor’s transaction reference, timestamps, the amount and currency, and the internal ledger transaction identifier. Sensitive payment information should not be copied into systems that do not need it.
Distinguish unavailable, pending, failed, confirmed, and credited states
These labels answer different customer and operational questions:
- Payment unavailable means the system could not begin or complete normal processor communication.
- Top-up pending means an attempt exists, but its final outcome has not yet been verified.
- Top-up failed means the authoritative payment result is unsuccessful.
- Payment confirmed means the processor reports success, but internal crediting may still be completing.
- Wallet credited means the ledger has applied the corresponding funds.
Collapsing these conditions into “success” and “failure” encourages unsafe retries. It can also cause support teams to tell customers that they were not charged when the actual result is still unknown.
Treat a timeout after submission as an ambiguous outcome
A timeout only proves that the caller did not receive a timely response. It does not prove that the processor rejected the payment. The processor may have completed the operation just before the connection failed.
For an ambiguous result, the application should:
- Preserve the top-up as pending or unknown.
- Avoid issuing spendable credit.
- Query the processor using the original transaction reference or idempotency key.
- Retry submission only when the processor’s status and retry semantics make that safe.
- Notify the customer when the payment reaches a final state.
Sending a new payment request immediately after every timeout can create duplicate authorizations. Marking every timeout as successful can create unfunded balances. An authoritative lookup is the safer bridge between those outcomes.
Record pending state durably without presenting it as settled funds
A pending record is operationally useful only if it survives process restarts and can be reconciled later. It should remain distinct from the spendable balance and from any optional grace allowance.
Customer interfaces can display the pending amount for transparency, but labels should avoid suggesting that the funds are ready to use. For example:
Top-up pending: We have not yet received a final payment status. Your spendable balance has not changed. Please do not submit the same payment again while verification is in progress.
If model usage continues from an existing balance, say so separately:
Model usage remains available from your confirmed balance. New wallet funds will not be available until the payment is confirmed.
Use idempotency and ledger deduplication at different boundaries
An idempotency key allows repeated delivery of the same logical top-up request without intentionally creating a new payment each time. The key should be stable across retries of the same attempt and different for a genuinely new top-up.
Ledger crediting needs its own deduplication control. A common pattern is to make the confirmed processor transaction reference unique within the credit ledger. If a webhook, status poll, and incident-recovery job all report the same successful payment, they should converge on one wallet credit rather than create three.
A simplified flow could be:
- Create
top_up_idandidempotency_key. - Save the initiated top-up before calling the processor.
- Submit the payment with the same
idempotency_keyon safe retries. - If the result is unknown, save pending state and query authoritative status.
- After confirmed success, create one ledger transaction linked to
top_up_id. - Enforce uniqueness for the processor payment reference and ledger credit.
- Mark the top-up credited only after the ledger transaction commits.
This design reduces duplicate-processing risk, but it should not be described as a guarantee of exactly-once payment processing. External systems, delayed events, and operational intervention still require reconciliation.
Recover through verification and reconciliation
A payment incident should not be closed merely because the processor endpoint responds again. Recovery should verify what happened during the outage and align processor, top-up, ledger, and usage records.
A practical incident runbook should include these steps:
- Stabilize the top-up path. Stop unsafe retries and retain every initiated or ambiguous attempt.
- Confirm processor recovery. Verify that status lookups and normal transaction operations are functioning.
- Resolve ambiguous attempts. Check each pending payment against the processor’s authoritative record.
- Retry only eligible operations. Reuse the original idempotency key when retrying the same logical payment.
- Apply confirmed credits once. Create or verify the ledger entry associated with each successful payment.
- Reconcile records. Compare processor transactions, top-up states, wallet ledger entries, and usage metering.
- Review grace exposure. Identify accounts that continued under temporary limits and apply the defined commercial treatment.
- Investigate discrepancies. Isolate duplicate charges, missing credits, unmatched references, and unexpected negative balances.
- Notify affected customers. Communicate final payment and balance outcomes without overstating certainty.
- Close with operational review. Record the incident timeline, policy decisions, manual actions, and follow-up work.
Make degraded status clear to customers and operators
Customer messaging should distinguish payment health from model-serving health. Useful messages include:
- Payment unavailable: “Wallet top-ups are temporarily unavailable. No new funds have been added.”
- Outcome unknown: “Your top-up was submitted, but its final status is still being verified. Please do not retry it.”
- Top-up failed: “The payment was not completed, and your wallet balance was not increased.”
- Usage continuing: “Model usage remains available from your confirmed balance, subject to your account limits.”
- Balance exhausted: “Your confirmed balance has reached its usage threshold. New requests are limited until funding is available or another authorized policy applies.”
Operational monitoring should cover more than processor uptime. Teams should watch pending-payment age and volume, retry activity, unmatched processor transactions, ledger-credit failures, balance thresholds, grace exposure, metering continuity, and the number of accounts being throttled or rejected.
Alerts should map to a documented owner and response. A growing pending queue, for example, requires a different action from a processor outage with no submitted transactions.
Connect billing decisions to inference control without coupling the systems
The billing service should produce a clear authorization outcome for the serving layer, such as normal access, restricted access, grace access, or blocked access. The inference control plane can then enforce the corresponding traffic policy without implementing payment logic itself.
This separation becomes particularly important as workloads move from early API validation into predictable, privately deployed inference. Token Forge Cloud Managed Model APIs provide an API-first path for teams seeking model access and usage data before committing to private serving capacity. Token Forge Cloud Private LLM Inference supports private deployment and serving-layer control for enterprise AI workloads.
Within the inference layer, caching, model routing, batching, quantization, and GPU scheduling can support workload-specific serving decisions. Billing authorization and wallet reconciliation should remain separate concerns: payment systems determine whether spending is authorized, while the serving layer governs how permitted traffic is executed.
For architecture planning, teams should define the contract between these layers explicitly. That contract should cover balance-state freshness, request admission, in-flight work, metering delivery, policy changes, and behavior when the billing decision service itself cannot be reached.