# Show a checkout result

Show one agent checkout to your staff inside your own admin tool with <provenance-checkout-result>, keep its session alive with getToken(), and put your own next step beside it.

`<provenance-checkout-result>` shows one agent checkout to your staff, inside your own admin tool: what Identify saw, how the [assessment](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md) decided, the cart approval the shopper answered and how they answered it. Every row is one line, with a dot and a word. Beside it, a slot holds your own next step, such as **Approve purchase**; Provenance shows the facts and never picks the action.

**Before you begin:** a publishable key (see [embeds](https://provenanceauth.com/docs/embeds.md#1-create-a-publishable-key)) and a secret key with the `authorize` scope. The embed needs Pro or the Free trial; the same rows show in the console's checkout drawer on every plan.

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
```

## 1. Mint a session on your server

Your server mints a short session for one checkout with [`POST /v1/embed/tokens`](https://provenanceauth.com/docs/api/embeds.md#post-v1-embed-tokens), `widget: "checkout_result"` and the assessment's ID (or the cart approval's, when you opened one without an assessment). Put it behind a route your admin page calls, after your own sign-in check:

In the SDK tabs, `prov` (Node, Python) and `embed` (Go) are your server-side clients, set up as in [admin results and requests](https://provenanceauth.com/docs/embeds/admin-tools.md#3-mint-a-session-for-an-embed).

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/embed/tokens \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "widget": "checkout_result", "object_id": "cas_01M7K4ZXJB9M12Z6SB49X9YQNY", "ttl": 900 }'
```

**Node**

```ts
// GET /admin/provenance/session?order=1042 (your route, behind your staff sign-in)
const session = await prov.embed.createToken({ widget: "checkout_result", objectId: assessmentId, ttl: 900 });
res.json({ token: session.embedToken });
```

**Python**

```python
token = prov.embed.create_token(widget="checkout_result", object_id=assessment_id, ttl=900)["embed_token"]
```

**Go**

```go
session, err := embed.CreateToken(ctx, pv.EmbedTokenParams{Widget: pv.WidgetCheckoutResult, ObjectID: assessmentID, TTL: 900})
```

| Field | What it does |
| --- | --- |
| `object_id` | One checkout assessment (`cas_…`) or cart approval (`coap_…`) of your account. Another kind of ID is `400` [`embed_object_kind_mismatch`](https://provenanceauth.com/docs/platform/errors.md#embed_object_kind_mismatch); another account's is `404`. |
| `ttl` | Seconds, up to 900 (15 minutes). |

A key without the `authorize` scope gets `403` [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope). A copied session opens only this checkout, and only until it expires.

## 2. Drop the element in your page

```bash
npm install @provenance/embed
```

```html
<script type="module" src="https://unpkg.com/@provenance/embed"></script>

<provenance-checkout-result base-url="https://sandbox-api.provenanceauth.com" publishable-key="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se" theme="inherit">
  <div slot="actions"><button id="approve-purchase" hidden>Approve purchase</button></div>
</provenance-checkout-result>

<script>
  const el = document.querySelector("provenance-checkout-result");
  el.getToken = async () => (await (await fetch("/admin/provenance/session?order=1042")).json()).token;
</script>
```

The element calls `getToken()` on load and one minute before each session ends, and swaps the new session in place. If your server can't answer, it says **Session ended** with **Reload** and fires `pv:token_refresh_failed`. See [capture result in your admin](https://provenanceauth.com/docs/embeds/capture-result.md#3-keep-the-session-alive-with-gettoken) for the details; they're the same here.

If your server adds a tag of its own to the end of the order reference, name it in `hide-suffix` and the element shows the order reference without it.

In React:

```tsx
import { ProvenanceCheckoutResult } from "@provenance/embed/react";

<ProvenanceCheckoutResult
  baseUrl={process.env.NEXT_PUBLIC_PROVENANCE_API!}
  publishableKey="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se"
  getToken={async () => (await (await fetch(`/admin/provenance/session?order=${orderId}`)).json()).token}
  onResult={(r) => setResult(r)}
>
  <ApprovePurchase result={result} />
</ProvenanceCheckoutResult>;
```

## 3. Put your own next step in the slot

The `actions` slot is yours. Decide what to show from `pv:result`, which carries enums only:

```js
el.addEventListener("pv:result", (e) => {
  const { status, outcome } = e.detail;
  // Your rule, in your code: the shopper approved the cart, or no prompt was needed.
  document.querySelector("#approve-purchase").hidden = !(status === "approved" || outcome === "frictionless");
});
```

`status` is the cart approval's status, or the assessment's outcome when no one was asked. The slot can't cover or restyle the status line, the outcome words or the "Powered by Provenance" foot.

## What it shows

Each row, and where it comes from in the API, so you can find the same fact in [`GET /v1/authorize/checkout_assessments/{id}`](https://provenanceauth.com/docs/api/assessments.md#get-v1-authorize-checkout-assessments-id), [`GET /v1/authorize/checkout_approvals/{id}`](https://provenanceauth.com/docs/api/checkout-approvals.md#get-v1-authorize-checkout-approvals-id) and [`GET /v1/identify/decisions/{id}`](https://provenanceauth.com/docs/api/traffic-decisions.md#get-v1-identify-decisions-id):

| Row | Example | From |
| --- | --- | --- |
| Status line | Approved · by passkey, Order 1042 and its total | The approval's `status`, else the assessment's `outcome`; `order_id`; the approval's `cart` |
| Timeline | Agent seen, Assessed, Link sent, Shopper approved, Code checked, Now | The verdict's `created_at`; the assessment's `created_at`, `outcome` and `reason`; the approval's `deliveries`, `decided_at`, `person_decision` and `passkey.step_up` |
| Identify | Class, Agent, Bot score, Signals, Action (in the [visit words](https://provenanceauth.com/docs/embeds/traffic-list.md#visit-words)) | The verdict the assessment stored (`traffic_assessment_id`): `class`, `agent`, `bot_score`, `signals`, `decision` |
| Assessment | Outcome, Reason, Rule, Covered by, Billing | `outcome` (as Approved, Challenged or Rejected), `reason`, `policy.rule` (the rule's name), `covered`, `signals.billing` |
| Approval | Status, Approved by, Identity, Method | `status`, `person_decision` and `decided_at`, `approver.identity`, `approver.method` |
| Approval | Passkey: New · made on this page, New · 3 min old, Existing · 212 days | `approver.passkey`, `passkey.created_during_approval` and `passkey.age` |
| Approval | Contact code: Checked by email | `passkey.step_up` (a new passkey's code step-up, when it ran) |
| Approval | Approved from: OR, US | `location.network` (country and region only) |
| Approval | Device, Time zone, Network | `approver.platform`, `approver.timezone`, `approver.network` (every plan) |
| Approval | Authenticator, Account age, Ships to | `signals.authenticator`, `signals.account`, `signals.ships_to`, where recorded |
| Location match | Time zone in billing country | Computed for this view only: the approving browser's time zone against the billing country |

The approval rows show once the shopper answers, also while your review holds the order. Billing and the approving network show as region and country (OR, US): never the street, the city or the postal code. The location line is a display aid; no API read returns it, and a [rule](https://provenanceauth.com/docs/mandate/guides/policy-builder.md) compares locations itself.

The element never receives a token: reading an approved cart approval with your key returns `intent_token` and `ap2`, and the embed's answer leaves both out, always. It never receives the approver's IP or its nonce, even when you share the IP on your own reads. To see what it gets, call `GET /v1/embed/checkout_result` with the session.

While the shopper hasn't answered, the element reads the checkout again every 15 seconds. A checkout that can't be read shows that it's unavailable, never a made-up result. Confirm a decision on your server from the [webhook](https://provenanceauth.com/docs/integrate/webhooks.md), never from the event alone.

## Order status

One order reads one status everywhere: the list, the status line, the timeline's **Now** row and the console's Checkout page all take it from the same field map. Once a shopper was asked, the cart approval's status decides it; before that, the assessment's outcome.

| Status | When | Now |
| --- | --- | --- |
| Approved | No prompt was needed, the shopper approved, or your review approved | Ready to fulfill |
| Challenged | The shopper hasn't answered yet | Waiting on the shopper |
| In review | The shopper approved and your after-approval rule holds the order | Waiting for your review |
| Rejected | Your rules, the shopper or your review said no |  |
| Expired | Nobody answered in time |  |

The shopper's own answer reads **Shopper approved** or **Shopper declined**, so it never reads as your review. The Identify block says what Identify did to the request in the [visit words](https://provenanceauth.com/docs/embeds/traffic-list.md#visit-words).

## Events

| Event | When | Detail |
| --- | --- | --- |
| `pv:ready` | The session opened | `widget`, `object_id`, `mode` |
| `pv:result` | First read, and whenever the checkout changes | `kind: "checkout"`, `status`, `outcome` |
| `pv:token_refresh_failed` | `getToken()` couldn't renew the session | `widget` |
| `pv:error` | The element couldn't start | `code`, `message` |

## Embed, console or your own

|  | This embed | The console | Your own UI on the API |
| --- | --- | --- | --- |
| Where | Your admin tool | **Authorize › Checkout**, the order drawer | Anywhere you like |
| Plan | Pro, or the Free trial | Every plan | Every plan |
| Work | Mint a session, drop the tag | None | Read three objects, map the fields, leave out the token |

To build your own, read the assessment, its cart approval and its traffic assessment from your server; the table above names the field behind each row.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `400` [`embed_object_kind_mismatch`](https://provenanceauth.com/docs/platform/errors.md#embed_object_kind_mismatch) | The ID isn't an assessment or a cart approval | Pass the `cas_…` or `coap_…` ID. |
| `403` [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope) | The key has no `authorize` scope | Mint with an Authorize key. |
| `401` [`embed_token_invalid`](https://provenanceauth.com/docs/platform/errors.md#embed_token_invalid) | The session expired or is for another widget | Mint a new one, or give the element `getToken()`. |
| `503` [`embed_result_unavailable`](https://provenanceauth.com/docs/platform/errors.md#embed_result_unavailable) | The checkout couldn't be read | Retry shortly. |

## See also

- [Embeds](https://provenanceauth.com/docs/embeds.md)
- [Admin results and requests](https://provenanceauth.com/docs/embeds/admin-tools.md)
- [Capture result in your admin](https://provenanceauth.com/docs/embeds/capture-result.md)
- [3-D Secure for agentic commerce](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md)
