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

# Prices, Fees and Totals

> Which call to use at each step of checkout, so customers always see the right number.

## Intro

Khaime has a few read-only calls that answer "what will the customer pay?" at different points in checkout. Used together, they let your UI show the right price, fee and total at every step — and the charge always matches what the customer saw.

## The calls, in checkout order

| Step in your checkout                      | Call                                                                    | What you show                                                                                  |
| ------------------------------------------ | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| Currency selector                          | [Get Currencies](/api-reference/products/get-currencies)                | The currencies customers can pay in. Default to their local one.                               |
| Product page and cart                      | [Get Product](/api-reference/commerce/get-product) with `?currency=`    | Each price in the customer's currency.                                                         |
| Before the customer's details are complete | [Get Fee Breakdown](/api-reference/products/get-fee-breakdown)          | An estimated transaction fee and total for the cart amount.                                    |
| Review, just before the pay button         | [Preview Payment](/api-reference/commerce/cart-payment-preview)         | The exact final payment: subtotal, discount, shipping, tax, fee and total. Nothing is created. |
| Pay                                        | [Create Product Payment Intent](/api-reference/commerce/payment-intent) | The checkout. Its `amount` matches the preview.                                                |
| After payment                              | [Webhooks](/webhooks/overview)                                          | Confirmation that the payment succeeded.                                                       |

```mermaid theme={null}
flowchart LR
  A[Get Currencies] --> B[Get Product ?currency]
  B --> C[Get Fee Breakdown<br/>estimate]
  C --> D[Preview Payment<br/>exact total]
  D --> E[Create Product<br/>Payment Intent]
  E --> F[Webhook]
```

You don't need every call. A single-page checkout with all details on one form can go straight from Get Product to Preview Payment.

## Hows

### Keep four things the same

1. **One currency everywhere.** Send the customer's chosen code to Get Product, Get Fee Breakdown, Preview Payment and the intent.
2. **Same body for preview and intent.** Preview Payment takes exactly the body you'll send to Create Product Payment Intent, so build it once and send it twice.
3. **Show the fee when the customer pays it.** When `customer_pays_fees` is `true`, show the transaction fee as its own line. See [Fees](/payments/overview#show-the-fee-when-the-customer-pays-it).
4. **The intent is the charge.** The breakdown and preview are for display. What the customer pays is the intent's `amount`.

### Example: review step, then pay

```javascript theme={null}
// Built once from the customer's cart and details.
const body = {
  product_type: "digital",
  cart: [{ product_id: 3046, quantity: 1, price: 5000, product_image: imageUrl }],
  email: "jane@example.com",
  first_name: "Jane",
  last_name: "Doe",
  currency: "GBP",
};

// Review step: exact numbers, nothing created.
const { data: preview } = await khaime.post("/cart-payment/preview", body);
showSummary({
  subtotal: preview.cart_total_before_fees,
  fee: preview.customer_pays_fees ? preview.total_fees_amount : null,
  total: preview.customer_pays_total,
});

// Customer presses Pay: same body.
const { data: intent } = await khaime.post("/product-payment/intent", body);
```

## Why nots

* **Don't compute fees or totals yourself.** Fees depend on currency, gateway, country and the merchant's settings, and they change. Read them from Khaime.
* **Preview Payment needs the full cart.** It validates everything the intent does, including required [custom fields](/api-reference/commerce/product-custom-fields), so call it once those are filled in. Use Get Fee Breakdown before that.
* **A preview isn't a reservation.** Rates can move between preview and payment. If the customer waits a long time, preview again.
