Case review: a credit arriving is not the same as being withdrawable
A real operations review exposed a common confusion between payment, account credit, and permission to use funds. Separate order matching, one-time crediting, and risk holds to prevent both duplicate credits and excessive privileges.
Symptom
In a prepaid API service, after a user makes an on-chain transfer, the system must decide whether to add API usage credits. A common puzzle is that a blockchain explorer shows a successful transaction and a payment platform shows an asset credited, yet the order remains pending. The opposite failure also occurs: an endpoint returns a status that appears to mean “received,” and the system immediately adds balance without matching the currency, order amount, or whether the transfer was already processed.
This is not merely a status-mapping bug. API credits represent permission to use a service. They are not the same as on-chain assets held in an account, and they do not imply permission to trade, transfer, or withdraw. If “crediting a top-up” is confused with “funds are freely available,” automation may grant excessive privileges. If the system demands unnecessary proof of withdrawal availability, a genuinely credited payment may be blocked indefinitely.
Investigation
The investigation separated three state chains: whether an order exists and belongs to the current user; whether a payment record has reached the designated asset account; and whether that record has already been used for another order or credited before. Checking these independently helps distinguish a normal pending state from a data mismatch or an idempotency safeguard when a transaction succeeds but the balance does not change.
Next, the upstream public status definitions and account types were reviewed to determine whether each state means on-chain confirmation, internal ledger posting, or availability for a particular operation. Similar field names do not guarantee equivalent semantics. Terms such as DONE, confirmed, credited, or settled must be interpreted using the documentation for the relevant endpoint. “Deposit credited” must also be distinguished from “withdrawable”: some platforms post an asset to an account while temporarily restricting transfers because of risk controls or source-of-funds checks.
Finally, the order's expected amount, credited quantity, currency, and precision were compared. Decimal precision, network type, order-expiry windows, late-discovered payments, and repeated callbacks can all cause mismatches. Security logs and the order timeline should be used for records that cannot be classified automatically, without putting secrets, full addresses, or personal identifiers in public incident notes.
Root cause
The underlying issue was a business process reduced to one “success/failure” flag, without separate models for order matching, account credit, and permission boundaries. If status semantics are not verified, the system can fail in two directions: it may treat assets that are credited but temporarily restricted as not received, or it may treat an unmatched transfer as a successful top-up.
A second risk is weak idempotency. The same on-chain transaction may be discovered repeatedly by polling, replayed in callbacks, or incorrectly associated with two orders. If deduplication exists only at the request layer and the database does not enforce transaction uniqueness and order-state constraints, duplicate credits remain possible.
A third risk is privilege creep. The confirmation outcome should grant only the agreed API usage credits. If the success branch also enables withdrawal, trading, or other asset operations, one payment confirmation has expanded into account capabilities that were never authorized.
Fix
The corrected flow uses a strict sequence. First, confirm that the order exists and that its amount and currency match. Then confirm that the payment record belongs to the specified network and asset account and has reached a credited state. Finally, in one database transaction, lock the order, register the unique payment record, and update credits. Add API credits only if every condition holds and the payment record has not been used before.
Keep records explicitly marked as restricted or pending review in a separate state and do not credit them automatically. During manual review, record the reason and audit details. If a payment is confirmed as credited but cannot be shown to be withdrawable, apply the service's rules by granting API consumption credits only, without enabling trading or withdrawal. For a payment made within the order's validity period but discovered later, match it within a defined look-back window. Route expired, mismatched, or restricted cases to review instead of guessing.
Database-level uniqueness constraints and transaction tests also protect against repeated notifications and concurrent polling. Lock the order and check payment uniqueness before committing the balance change. If any database operation fails, roll back the whole transaction. Thus, even if several workers discover the same payment at once, only one can credit it.
Checklist
- Verify order owner, currency, network, expected amount, and precision.
- Derive payment-state meaning from the relevant official API definition, not the field name.
- Treat “credited” and “withdrawable” separately; grant only the agreed API credits.
- Give every payment record a unique identifier and prevent duplicate associations at the database layer.
- Keep order locking, payment registration, and balance updates in one transaction.
- Define a look-back window for late payments; route expired, mismatched, or restricted cases to review.
- Test duplicate callbacks, repeated polling, and two orders competing for the same payment.
- Keep secrets, full addresses, and unnecessary personal information out of audit logs.
- Explain the purpose and limits of credits in the user interface; do not describe API credits as withdrawable balance.
Conclusion
A top-up system should not “see success and add balance.” A robust rule matches an order to a credited payment, ensures each payment is recorded only once, sends exceptional states to review, and strictly limits the permissions granted after success. This prevents duplicate crediting without wrongly rejecting a payment that has arrived but is temporarily not withdrawable.
Sources & attribution
This article references the public materials listed below. Analysis and wording are SalpX's own; quoted material remains the property of its original authors and publishers.
- SalpX API Reference — SalpX · accessed 2026-11-27Note:The SalpX API Reference provides public API context; case details are anonymized from an internal operations log dated November 26, 2026.
One key for Claude, GPT and 50+ models
The SalpX gateway is OpenAI-SDK compatible. Point base_url at https://www.salpx.com/v1 and you are done.