Handling asynchronous checkout responses before custom logic runs
Key Takeaway
Checkout work runs in the background, so a successful response doesn't mean it has finished. Wait for 200 OK before you run custom logic, start payment, or call the next Checkout API.
In B2B Commerce, Checkout APIs start background calculators for pricing, promotions, inventory, shipping and tax. They can return a response before those calculators finish. Custom UI components and custom Apex must wait until checkout reports that processing is complete. If they run early, they read incomplete data or collide with checkout's own updates to the cart.
Why a response isn't the end
Checkout APIs invoke calculators that run asynchronously, so a successful API response doesn't mean processing is complete or the data is ready. Read the HTTP status code instead of only checking that there was no error.
| Status code | What it means | What you do |
|---|---|---|
| 200 OK | Processing is complete and the data is ready. | Move to the next step. |
| 202 Accepted | Background calculators are still running, and the cart is locked for updates. | Poll checkout status until it returns 200 OK. |
| 409 Conflict | The request arrived while a previous operation was still in progress. | Wait for that operation to complete, then retry. |