Simple Checkout Flow
This guide demonstrates how to integrate with the Sell Anything API by walking through the complete lifecycle of a checkout, from creation to final status.
Step 1: Create a Checkout Intent
To initiate a new checkout, send a POST
request to:
All processing is asynchronous. Always poll the
GET
endpoint after each major step.Once in a terminal state (
completed
orfailed
), the intent is complete.Use
failureReason
to display helpful error messages to users.
Step 2: Poll for awaiting_confirmation
After creating the intent, poll the following endpoint to wait for it to reach the awaiting_confirmation
state:
Repeat the request every few seconds until you receive:
This reflects completion of background processing (offers, shipping, costs).
Step 3: Confirm Final Pricing
Before proceeding to payment confirmation, inspect the latest checkout intent response to confirm:
- Shipping options and pricing
- Taxes
- Total cost
- Selected offer availability
Ensure your UI reflects the full final cost to the user and allows for selection or changes if applicable.
You can extract this information from the GET /api/v1/checkout_intent/{id}
response payload.
Step 4: Request and Tokenize Payment
Retrieve a payment token for the credit card you want to use. Follow the steps here.
Step 5: Confirm with Payment
Once the user has reviewed the final cost and approved, confirm the intent with their payment card information:
Step 6: Poll for Final State
After confirmation, poll the GET endpoint again until you reach one of the terminal states:
completed
: Order was placed successfully.failed
: Something went wrong (e.g., out of stock, expired).
Example polling logic:
or
This flow enables you to build a robust checkout experience around asynchronous processing and confirmation.