Guide · 7 min read
Your agent can pay without ever seeing the card: payment connectors and HSM wallets
An agent that can pay needs a payment credential, and a credential in the agent's context is a credential anyone who can steer the agent can use. A payment connector keeps the key and the card in the vault: the agent asks for a payment, the gateway adds the credential, and your spend policy decides before anything reaches the processor.
What a connector is
A connector is an HTTPS upstream the Entity Gateway calls for an agent, at /v1/connectors/<id>/<path>. The credential (a bearer token, an API-key header or basic auth) comes from your vault, goes into the outbound request and is scrubbed from the answer. The agent holds only a short-lived gateway token with the scope gateway:invoke:connectors. A connector that moves money has a commerce block, and that is where your policy lives.
{
"connectors": [{
"id": "stripe",
"base_url": "https://api.stripe.com",
"auth": {"type": "basic", "secret": "psp/stripe-key"},
"paths": ["/v1/*"],
"commerce": {
"currency": "USD",
"merchant_did": "did:web:shop.example",
"spend_paths": ["/v1/payment_intents"],
"per_tx_cap": 5000, "daily_cap": 20000,
"auto_approve_below": 1000,
"forbid_fields": ["transfer_data", "on_behalf_of"]
}
}],
"grants": [{"id": "pay", "src": ["did:key:z6Mk..."], "connectors": ["stripe"]}]
}What the agent does
Over HTTP the agent sends the payment as the processor expects it. Over MCP it calls the tool connector_pay with the connector, the path, the merchant DID and the fields. Amounts are in minor units.
curl https://gateway.agentsecretstore.com/v1/connectors/stripe/v1/payment_intents \
-H "Authorization: Bearer $GATEWAY_TOKEN" \
-H "X-OE-Merchant-DID: did:web:shop.example" \
-d "amount=1000¤cy=usd&payment_method=pm_card_visa&confirm=true"There are three outcomes, and the agent can handle each without a human in the prompt.
- It goes through. The payment was under the auto-approve amount and the agent is one the Open Entity registry vouches for, or an owner mandate covers it.
- It is refused, with a reason. Over a cap, a merchant that is not on the list, a field you forbade, or a purchase that cannot be written as a cart. Nothing is sent to the processor.
- It waits for a person. The gateway answers 409 and the
connector_paytool returnspending_approval. The approval your human sees carries a cart summary of what is being bought and what it costs. The agent polls the approval and repeats the same call once.
Why the policy can be trusted
- It reads the bytes sent. The amount and currency come from the request that would reach the processor, never from a field the agent filled in to describe it.
- The payee is pinned. A connector with a merchant list or a mandate requirement fixes the merchant DID in its config, one connector per merchant. A merchant DID in a request is the agent's own claim and does not choose who gets paid.
- A mandate never lifts a cap. An owner mandate signed in the OpenEntity app can authorise what the policy would send to a person, within its own limits and your caps. A bad or foreign mandate is refused, not ignored.
- Every secret is scrubbed. The gateway removes every secret the connector declares from every response, so a value planted in a processor field cannot be read back.
- A failed payment does not count. A payment the processor declined, or that never reached it, is not charged against the caps.
A card the agent can use but not read
For a network-tokenised card, declare the secret on the connector and let the agent write a placeholder: {{secret.card}} in a JSON or form body is filled from the vault inside the gateway. The agent never sees the value, and a placeholder the connector does not declare is refused. It works in JSON and form bodies only.
Wallets with the key in hardware
For payments on chain, an agent wallet is a secp256k1 key that lives only in Cloud KMS at HSM protection level. It cannot be exported: the vault sees the public key and signatures. Each wallet has a policy you set: a cap per transaction and per day, an allowlist of contracts and functions, and an amount under which a plain transfer by a vouched-for agent signs without asking. Everything else, including every message signature, goes to a person. A wallet inside an organisation takes its limits from the organisation's budget.
Proof that an agent is governed
Agents that use the gateway get a custom:agentsecretstore:gateway_governed attestation in the Open Entity registry, renewed weekly. When every provider and tool key the agent used stayed in the vault, it also says so. A merchant that runs Agent Commerce Check can read it.
What is not covered yet
OAuth2 and dynamic client registration upstreams are not supported: a connector injects a bearer token, an API-key header or basic auth. Connectors are checked end to end against Stripe in test mode.
For agents
Never ask for a key or a card number: ask for a connector. Pay with connector_pay, name the merchant by DID, send an idempotency key and reuse it on a retry. On pending_approval tell your owner what is being bought, poll get_approval_status and repeat the identical call once. If a refusal gives a reason, report it and stop; do not change the amount or the payee to get around it.