The gateway approved it. Your store failed to save it.
A failed order save does not undo a payment approval. Separate the store’s database result from the gateway operation before retrying, repairing or returning money.
In this article
A customer submits an order. The gateway approves the authorization, but the store encounters an error while saving the result. The application rolls back its unfinished database changes and displays a payment failure.
In this hypothetical checkout, the database has done its job. The message to the customer has not. An approval can still exist outside the store, even though the order screen has no record of it.
Asking the customer to try again would make a missing record their problem. It can also create another payment attempt before the first one has been understood.
The rollback has a boundary
A database transaction groups changes that should succeed or fail together. PostgreSQL’s documentation explains that a rollback discards updates within that transaction. The guarantee concerns those database changes. Calling a remote gateway during the same piece of application code does not bring the gateway’s financial operation inside that local guarantee.
For the merchant, there are now two questions: what did the payment service do, and what did the store retain? A local error answers only the second. It does not establish a decline, cancellation or refund.
Keep the payment stage precise. An approved authorization is not itself a completed capture or a bank deposit. A store configured to submit an authorization and capture together has different records to inspect from one that captures later. Recovery starts with the operation actually sent, rather than a generic Paid or Failed label.
The distinction affects customer communication. Someone checking a card account may see an authorization while support sees an unpaid order. Neither view, by itself, explains the whole purchase. Tell the customer that the original payment is being checked, with a responsible contact and a follow-up, instead of asking for another card as a diagnostic step.
Repair the record before collecting again
Find the original operation in the correct account and environment. Cybersource’s recovery guidance uses the request identifier when available and the merchant reference when necessary. Search results can take time to appear; an immediate empty result is not conclusive evidence that nothing happened.
If the original operation is verified, reconnect it to the intended order and repair the missing local state through the application’s supported recovery process. Check the expected amount, currency and purchase. Do not simply set an order to Paid because someone found a similar amount in the gateway.
That correction must not repeat the business actions attached to payment. The warehouse may already have received an instruction, or a customer message may have gone out before the failed save. OWASP’s payment integration guidance calls for verified results and protection against repeated fulfillment. The repair should restore an understandable history, not trigger the sale a second time.
If the purchase can no longer proceed, select the supported remedy for the verified payment state and confirm its result. An authorization reversal, void and refund serve different stages. Another lost response during that remedy creates another operation to investigate; it does not justify issuing the remedy repeatedly.
The attempted purchase needs to survive the failed save
Ask the web team what durable evidence exists before the financial request leaves the store. Staff need to recover the order, account, amount, currency and original attempt even when the later result cannot be saved. If the only useful reference lives inside the database update that rolls back, the team has made investigation unnecessarily difficult.
There is no universal database design to copy into every store. For systems that coordinate saved records with outgoing work, patterns such as a transactional outbox can reduce the gap between committing a local change and delivering its message. AWS also warns that delivery can repeat, so the receiver still needs duplicate protection. An outbox does not make a remote payment reversible by rolling back the store’s database.
Keep recovery evidence separate from payment credentials. The original attempt should be traceable without retaining card security codes, secret keys or temporary payment tokens in ordinary logs. Preserve only permitted information with appropriate access controls.
Ask to see this failure before launch
Have the team demonstrate a controlled save failure after a provider result in a supported test environment. Then restart the worker, revisit the order and deliver the same result again. The useful evidence is whether staff can locate the original attempt and recover the correct purchase without another collection or fulfillment.
For a Trolleys custom checkout, use the testing guidance and agree who owns unresolved cases. Your web team repairs the store’s records; the merchant and gateway records establish the payment activity. A support handoff should retain the safe references needed to investigate.
A reliable checkout can explain a purchase even when part of its own software fails. That explanation is what lets the merchant help the customer without making them pay for the store’s uncertainty.