> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Check a Price Without Buying

> Get the exact total of an order, with shipping and tax, and stop before the payment

A product page often does not show the final price. Shipping, tax, and discounts appear only at the checkout. To get the exact total, run a checkout to the payment step, read the amount, and cancel the checkout. Nothing is bought.

<video className="w-full rounded-xl" autoPlay muted loop playsInline src="https://mintcdn.com/crossmint/eLFFFOlQTcnBWJ-s/images/agents/checkouts/price-check.mp4?fit=max&auto=format&n=eLFFFOlQTcnBWJ-s&q=85&s=78e053d7faf643950adbca0e9cee78d6" data-path="images/agents/checkouts/price-check.mp4" />

## Prerequisites

* **Agent Checkouts integration** — complete the [quickstart](/agents/agent-checkouts-quickstart).
* **Server key** — a production key with `agent-checkouts.create`, `agent-checkouts.read`, `agent-checkouts.update`, and `agent-checkouts.cancel`.

## Get the Total

<Steps>
  <Step title="Start the checkout">
    Give the product and its options in the task. Set `maxCost` above the price that you expect, so that the checkout can reach the payment step. A [buyer profile](/agents/checkouts/configure) gives the shipping address that the total depends on.

    ```typescript theme={null}
    const BASE_URL = "https://www.crossmint.com/api/unstable/agent-checkouts";
    const headers = {
        "Content-Type": "application/json",
        "X-API-KEY": process.env.CROSSMINT_SERVER_API_KEY!,
        "x-crossmint-user-id": "YOUR_USER_ID",
    };

    const response = await fetch(BASE_URL, {
        method: "POST",
        headers,
        body: JSON.stringify({
            request: {
                startUrl: "https://shop.example.com/products/wireless-headphones",
                task: "Go to the checkout for one pair of the wireless headphones in black, with standard shipping.",
            },
            buyerProfileId: "YOUR_BUYER_PROFILE_ID",
            constraints: { maxCost: { amount: "500.00", currency: "USD" } },
        }),
    });
    if (!response.ok) {
        throw new Error(`Could not start checkout: ${response.status}`);
    }
    const { runId } = await response.json();
    ```
  </Step>

  <Step title="Read the total from the payment request">
    [Follow the checkout](/agents/checkouts/follow-run) and answer its questions. When it reaches the payment step, the status is `awaiting_input` and the question is a payment request. When `interaction.amount.kind` is `"exact"`, `interaction.amount.value` is the total:

    ```json theme={null}
    {
        "kind": "payment",
        "purpose": "checkout_payment",
        "method": "card",
        "amount": { "kind": "exact", "value": "348.00", "currency": "USD" },
        "merchant": { "name": "Example Shop", "url": "https://shop.example.com", "countryCode": "US" }
    }
    ```

    When `amount.kind` is `"maximum"`, `amount.value` is your spending cap, not the total: the merchant did not show a final total before the payment. Do not show it as the price.
  </Step>

  <Step title="Cancel the checkout">
    Do not answer the payment request. Cancel the checkout:

    ```typescript theme={null}
    // Uses BASE_URL, headers, and runId from the first step.
    const cancelResponse = await fetch(`${BASE_URL}/${runId}/cancel`, { method: "POST", headers });
    if (!cancelResponse.ok) {
        throw new Error(`Could not cancel checkout: ${cancelResponse.status}`);
    }
    ```

    The cancel request returns `202 Accepted`. Keep reading the checkout until its status is `cancelled`.
  </Step>

  <Step title="Show the total">
    Show the total to the user. To buy later, start a new checkout and pay with an order intent. See [Pay for a Checkout](/agents/checkouts/payments).
  </Step>
</Steps>

## Common Gotchas

<AccordionGroup>
  <Accordion title="The total changes before the purchase">
    Prices, shipping, and stock can change. The total of a later purchase can be different. Set `maxCost` on the purchase to the highest total that the user accepts.
  </Accordion>

  <Accordion title="Each check costs a checkout">
    Crossmint bills each checkout that starts, also when you cancel it.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={3}>
  <Card title="Buy When the Price Drops" icon="arrow-trend-down" href="/agents/checkouts/use-cases/buy-when-the-price-drops">
    Buy automatically under a limit
  </Card>

  <Card title="Pay for a Checkout" icon="credit-card" href="/agents/checkouts/payments">
    Answer a payment request with an order intent
  </Card>

  <Card title="Create a Checkout" icon="brackets-curly" href="/api-reference/agent-checkouts/create-agent-checkout">
    Review the complete create request schema
  </Card>
</CardGroup>
