View as Markdown

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 /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.

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 }'
FieldWhat it does
object_idOne checkout assessment (cas_…) or cart approval (coap_…) of your account. Another kind of ID is 400 embed_object_kind_mismatch; another account's is 404.
ttlSeconds, 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 /v1/authorize/checkout_assessments/{id}, GET /v1/authorize/checkout_approvals/{id} and GET /v1/identify/decisions/{id}:

RowExampleFrom
Status lineApproved · by passkey, Order 1042 and its totalThe approval's status, else the assessment's outcome; order_id; the approval's cart
TimelineAgent seen, Assessed, Link sent, Shopper approved, Code checked, NowThe verdict's created_at; the assessment's created_at, outcome and reason; the approval's deliveries, decided_at, person_decision and passkey.step_up
IdentifyClass, Agent, Bot score, Signals, Action (in the visit words)The verdict the assessment stored (traffic_assessment_id): class, agent, bot_score, signals, decision
AssessmentOutcome, Reason, Rule, Covered by, Billingoutcome (as Approved, Challenged or Rejected), reason, policy.rule (the rule's name), covered, signals.billing
ApprovalStatus, Approved by, Identity, Methodstatus, person_decision and decided_at, approver.identity, approver.method
ApprovalPasskey: New · made on this page, New · 3 min old, Existing · 212 daysapprover.passkey, passkey.created_during_approval and passkey.age
ApprovalContact code: Checked by emailpasskey.step_up (a new passkey's code step-up, when it ran)
ApprovalApproved from: OR, USlocation.network (country and region only)
ApprovalDevice, Time zone, Networkapprover.platform, approver.timezone, approver.network (every plan)
ApprovalAuthenticator, Account age, Ships tosignals.authenticator, signals.account, signals.ships_to, where recorded
Location matchTime zone in billing countryComputed 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.

StatusWhenNow
ApprovedNo prompt was needed, the shopper approved, or your review approvedReady to fulfill
ChallengedThe shopper hasn't answered yetWaiting on the shopper
In reviewThe shopper approved and your after-approval rule holds the orderWaiting for your review
RejectedYour rules, the shopper or your review said no
ExpiredNobody 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

EventWhenDetail
pv:readyThe session openedwidget, object_id, mode
pv:resultFirst read, and whenever the checkout changeskind: "checkout", status, outcome
pv:token_refresh_failedgetToken() couldn't renew the sessionwidget
pv:errorThe element couldn't startcode, message

Embed, console or your own

This embedThe consoleYour own UI on the API
WhereYour admin toolAuthorize › Checkout, the order drawerAnywhere you like
PlanPro, or the Free trialEvery planEvery plan
WorkMint a session, drop the tagNoneRead 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

SymptomCauseFix
400 embed_object_kind_mismatchThe ID isn't an assessment or a cart approvalPass the cas_… or coap_… ID.
403 insufficient_scopeThe key has no authorize scopeMint with an Authorize key.
401 embed_token_invalidThe session expired or is for another widgetMint a new one, or give the element getToken().
503 embed_result_unavailableThe checkout couldn't be readRetry shortly.

See also