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.
- Verify offlinethe token and your exact cart
- Accept onlinethe reservation becomes spend
- Shipor 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 /.
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 / 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
| Code | What to do |
|---|---|
network_ | The token is older than 10 minutes and its reservation was released. Ask the agent to authorize again. |
network_ | The person revoked or paused the grant. Don't ship. |
network_ | Already accepted by another store, cancelled or released. Don't ship. |
trial_ | A Free account used its trial API calls, or the trial ended. |