TheWavlyDocs
DocsGuides

Accept agent orders

For stores. AI agents are starting to buy for people. Before you charge an agent's order, TheWavly tells you whether the agent is who it says it is and whether its user approved this payment. Each approval pays once, for no more than the user approved. Orders from people are never touched.

What an agent sends

An agent that checks out at your store sends two HTTP headers with the order:

HeaderValue
Wavly-AgentThe agent's handle or id in the public registry
Wavly-Payment-TokenThe single-use token TheWavly issued when it checked the purchase

Publish /.well-known/wavly-merchant.json so agents know to send them. The WooCommerce plugin and wavly.discovery() produce it.

Verify before you charge

One call, no account needed:

Shell
curl https://thewavly.com/v1/registry/verify -H "Content-Type: application/json" \
  -d '{ "agent": "tripbot", "payment_token": "eyJhbGciOi…" }'
JSON
{ "object": "order_verification", "accept": true,
  "agent": { "handle": "tripbot", "verified": true, "publisher": "Trip Co", … },
  "payment": { "valid": true, "max_amount_paise": 370000, "payee": "seaview@okhdfc", "livemode": true, … },
  "reasons": [] }

Then check what only you know: the order total is no more than max_amount_paise, the payee is yours, and a test token is not being used on a live store. The merchant library does all of this in one call.

Redeem once, just before charging

Shell
curl https://thewavly.com/v1/payment_tokens/redeem -H "Content-Type: application/json" \
  -d '{ "token": "eyJhbGciOi…", "amount_paise": 370000, "payee": "seaview@okhdfc", "payment_reference": "ORD-1001" }'

The answer includes:

  • receipt and verify_url: proof of the user's approval to keep with the order;
  • release_key: kept to give the approval back if the charge fails.

Repeating with the same payment_reference is safe. Any other reuse is refused.

If the charge fails

Shell
curl https://thewavly.com/v1/payment_tokens/release -H "Content-Type: application/json" \
  -d '{ "token": "eyJhbGciOi…", "release_key": "rlk_…", "reason": "Bank declined" }'

The user's budget is restored, and the agent must check again to retry. Only whoever redeemed holds the release key, so an agent cannot undo a payment you took.

Report what happened to the order

Once the order ships, report it. Each report becomes a signed record in the agent company's evidence pack, so a "never arrived" or "wrong item" complaint can be settled from your own word, not from a screenshot. Only whoever redeemed the token can report this way, proven with the same release key.

Shell
curl https://thewavly.com/v1/payment_tokens/fulfilment -H "Content-Type: application/json" \
  -d '{ "token": "eyJhbGciOi…", "release_key": "rlk_…", "status": "delivered",
        "items": [{ "description": "Silk saree, maroon", "quantity": 1 }],
        "carrier": "Delhivery", "tracking_reference": "AWB123456" }'
  • status: delivered, partially_delivered, not_delivered, returned, refunded (with amount_paise, at most what was paid) or cancelled.
  • The chain: you can send several reports for one order, up to 20. Each one commits to the one before it, so the history cannot be reordered later.
  • Disputes: your report updates the suggested finding of any open dispute on the order. For example, a full refund suggests the dispute is settled.
  • Personal data: the note and the tracking reference are erased if the user asks; the signed record keeps only their hashes.

WooCommerce

Download the plugin and upload it under Plugins → Add New → Upload Plugin.

  • Settings: WooCommerce → Settings → TheWavly. List your payee identifiers there.
  • Checkouts covered: classic checkout, block checkout and the Store API.
  • Modes: start in Record only, which never refuses and notes TheWavly's answer on each agent order, then switch to Require.

Razorpay, Cashfree and any Node store

The merchant library in the SDK bundle (sdk/merchant) verifies, redeems, releases and reports fulfilment (fulfil(order, "delivered", { items })). On Razorpay or Cashfree, agentCheckout also creates the gateway order with the TheWavly check in its notes, and gives the approval back if the gateway refuses.

JavaScript
import { wavlyMerchant } from "@thewavly/merchant";
import { razorpayGateway, agentCheckout, releaseFailed } from "@thewavly/merchant/gateways";

const wavly = wavlyMerchant({ payees: ["shop@okhdfc"] });
const r = await agentCheckout({ wavly, gateway: razorpayGateway({ keyId, keySecret, webhookSecret }),
                                headers: req.headers, amount_paise: 56100, order_id: "ord_1001" });
if (r.refused) return res.status(403).json({ reasons: r.reasons });
await db.save(r.order_id, r.wavly);     // check, receipt, release_key