Alipay query says pending after a success callback: handling out-of-order results
An Alipay order has been credited from a verified success callback, but a query later returns pending. Do not reset the local order to unpaid. Arrival time is not necessarily observation time. This guide covers merchant-side merging; actual status meanings and query consistency depend on the 稳付pay integration agreement.
Continue by topic
Reconstruct request, observation and commit times
For each query keep its request reference, send and return times, merchant/order mapping and a safe status summary. For callbacks retain verification, amount checks, commit result and local transaction version. Exclude keys, authentication strings and customer details from diagnostic screenshots.
Verify that both results concern the same merchant and order. A query sent at 09:00 that returns pending at 09:02 may reflect an earlier observation than a success committed at 09:01. A later response alone cannot overturn an established payment.
Use one server-side merge path
Queries, callbacks and manual reconciliation should enter one handler. Validate source, signature where applicable, ownership, amount and status eligibility, then read the current order version within a transaction. After verified success, an ordinary pending response, timeout or query failure adds an observation without reversing payment or repeating delivery.
Do not rank every status by a single numeric order. Refund, fulfillment and merchant settlement are separate dimensions. Record a verified refund without erasing the original payment. Conflicting terminal facts require preserved evidence and technical reconciliation, not a guess that one endpoint is always authoritative.
Example: stop a delayed update with a version condition
The local order is pending at version 7 when a query starts. A success callback then commits the payment fact, unique credit and version 8 together. A worker trying to update version 7 must fail its conditional update, reread version 8 and merge, rather than retry an unconditional overwrite.
Two concurrent successes must still create only one credit. Use a persistent uniqueness scope covering merchant, original payment and business action; commit the credit record with its balance effect. Versions 7 and 8 are local examples, not gateway fields. Isolation settings alone do not supply the state rules or constraints.
Prove that old responses only add observations
Test pending first, success first, concurrent successes, query timeout after success, a verified later refund and identical order numbers under different merchants. Inspect credit entries, delivery count, versions and observation records, not just the final success screen.
If stale responses already overwrote states, reconstruct discrepancies from trusted payment and ledger evidence and isolate affected fulfillment. Reconcile original actions instead of bulk-crediting again. Keep the repair batch, approvals, before/after versions and idempotent outcomes. Show customers the real payment and delivery stages to discourage another payment.
Frequently asked questions
Why is a later query response not necessarily newer?
Later arrival does not prove later observation or completed data propagation. Keep a request/commit timeline and prevent ordinary pending observations from overwriting verified success.
Is making success immutable sufficient?
No. Preserve the payment fact while separately tracking refunds, fulfillment and disputes. Handle genuine conflicts and atomic, idempotent commits rather than ignoring later evidence.