View as Markdown

Authorize · Guide

Accept network orders

Use this when an agent pays at your checkout under a person's network grant. Its Provenance-Intent token binds your exact cart, and you accept it online before you ship, so the person's budget stays correct across every store.

Before you begin: verify agent checkouts with verifyAgentCheckout. Accepting needs an account API key with the intent scope.

  1. Verify offline
    the token and your exact cart
  2. Accept online
    the reservation becomes spend
  3. Ship
    or cancel to refund the budget

1. Recognize a network order

A network token carries network: true and the grant in mandate_id. verifyAgentCheckout checks the signature and your cart as usual, and then returns accepted: false with reason: "requires_online_accept". Never ship on that result alone.

2. Accept it

acceptNetworkOrder does both steps: it verifies offline, then calls POST /v1/authorize/network_orders/confirm.

import { acceptNetworkOrder, loadJwks } from "@provenanceauth/rails/checkout";

const jwks = loadJwks(process.env.PROVENANCE_API!);
const result = await acceptNetworkOrder(req.headers["provenance-intent"], {
  jwks: await jwks.get(),
  expected: myOrderRecord, // your own record of this cart
  apiBaseUrl: process.env.PROVENANCE_API!,
  apiKey: process.env.PROVENANCE_KEY!,
});
if (!result.accepted) return reject(result.reason);
// result.acceptance: { object: "network_acceptance", status: "accepted", amount, currency, order_id, … }

A repeat for the same token returns the first acceptance with replayed: true, so a retry is safe. Another store can't accept a token that was accepted already.

3. Cancel or refund

When the order is cancelled or refunded, POST /v1/authorize/network_orders/cancel with the same token gives its amount back to the person's budget. Only the store that accepted it can cancel it.

Pricing: each accepted order counts as one decision on your account (plans and usage). Verifying, cancelling and failed accepts are free.

Errors you might see

CodeWhat to do
network_token_expiredThe token is older than 10 minutes and its reservation was released. Ask the agent to authorize again.
network_grant_inactiveThe person revoked or paused the grant. Don't ship.
network_order_closedAlready accepted by another store, cancelled or released. Don't ship.
trial_endedA Free account used its trial API calls, or the trial ended.

See also