Embeds · Guide
Show a checkout result
<provenance-checkout-result> shows one agent checkout to your staff, inside your own admin tool: what Identify saw, how the assessment 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) 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.
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 /, 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.
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 }'
// 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 });
token = prov.embed.create_token(widget="checkout_result", object_id=assessment_id, ttl=900)["embed_token"]
session, err := embed.CreateToken(ctx, pv.EmbedTokenParams{Widget: pv.WidgetCheckoutResult, ObjectID: assessmentID, TTL: 900})
| Field | What it does |
|---|---|
object_ | One checkout assessment (cas_) or cart approval (coap_) of your account. Another kind of ID is 400 embed_; another account's is 404. |
ttl | Seconds, up to 900 (15 minutes). |
A key without the authorize scope gets 403 insufficient_scope. A copied session opens only this checkout, and only until it expires.
2. Drop the element in your page
npm install @provenance/embed
<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 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:
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:
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 /, GET / and GET /:
| Row | Example | From |
|---|---|---|
| Status line | Approved · by passkey, Order 1042 and its total | The approval's status, else the assessment's outcome; order_; the approval's cart |
| Timeline | Agent seen, Assessed, Link sent, Shopper approved, Code checked, Now | The verdict's created_; the assessment's created_, outcome and reason; the approval's deliveries, decided_, person_ and passkey. |
| Identify | Class, Agent, Bot score, Signals, Action (in the visit words) | The verdict the assessment stored (traffic_): class, agent, bot_, signals, decision |
| Assessment | Outcome, Reason, Rule, Covered by, Billing | outcome (as Approved, Challenged or Rejected), reason, policy. (the rule's name), covered, signals. |
| Approval | Status, Approved by, Identity, Method | status, person_ and decided_, approver., approver. |
| Approval | Passkey: New · made on this page, New · 3 min old, Existing · 212 days | approver., passkey. and passkey. |
| Approval | Contact code: Checked by email | passkey. (a new passkey's code step-up, when it ran) |
| Approval | Approved from: OR, US | location. (country and region only) |
| Approval | Device, Time zone, Network | approver., approver., approver. (every plan) |
| Approval | Authenticator, Account age, Ships to | signals., signals., signals., 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 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, 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.
Events
| Event | When | Detail |
|---|---|---|
pv:ready | The session opened | widget, object_, mode |
pv:result | First read, and whenever the checkout changes | kind: "checkout", status, outcome |
pv:token_ | 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_ | The ID isn't an assessment or a cart approval | Pass the cas_ or coap_ ID. |
403 insufficient_ | The key has no authorize scope | Mint with an Authorize key. |
401 embed_ | The session expired or is for another widget | Mint a new one, or give the element getToken(). |
503 embed_ | The checkout couldn't be read | Retry shortly. |