# Pay with Preznt — `xyz.preznt.pay`

**Status:** preview (Solana devnet only — test USDC, no real money moves)
**UCP version:** 2026-08-25
**Handler name:** `xyz.preznt.pay` · **Schema host:** `pay.preznt.xyz`

Pay with Preznt lets a buyer's agent pay a UCP merchant in USDC from a
KYB-verified Preznt business account. The buyer approves every payment in
Preznt and signs the USDC transfer with their own wallet; the merchant receives
a single-use token it redeems with Preznt to capture the payment.

## Participants

| Participant | Role |
| --- | --- |
| **Buyer** | A Preznt business. Its owner approves and signs each payment. |
| **Platform** | The buyer's agent (the Preznt agent, or any UCP platform the buyer signs in to Preznt with). It discovers the merchant, builds the checkout and asks Preznt for an instrument. |
| **Merchant** | A UCP business that lists `xyz.preznt.pay` in its profile and holds a Preznt merchant API key. |
| **Preznt** | The handler: checks both sides, records the buyer's approval, issues and redeems tokens. |

## Prerequisites

- **Merchant:** a Preznt business that has passed KYB, with a Solana wallet to
  receive USDC, a `merchant_id` and a merchant API key (issued once, stored
  hashed). During the preview, access is by request.
- **Buyer:** a Preznt business that has passed KYB, with USDC in its Preznt
  wallet. Only the business owner can approve a payment.
- Both wallets are screened before any payment.

## Handler declaration

A merchant declares the handler in `/.well-known/ucp` under
`ucp.payment_handlers`:

```json
"xyz.preznt.pay": [{
  "id": "preznt_usdc_devnet",
  "version": "2026-08-25",
  "spec": "https://pay.preznt.xyz/specs/v1/handler.md",
  "schema": "https://pay.preznt.xyz/schemas/v1/handler.json",
  "available_instruments": [{ "type": "preznt_pay" }],
  "config": { "environment": "devnet", "merchant_id": "<your merchant id>" }
}]
```

- **business config** (`schemas/v1/business_config.json`): `environment`
  (`"devnet"`) and `merchant_id`, both required.
- **platform config** (`schemas/v1/platform_config.json`): `environment`.
- **response config** (`schemas/v1/response_config.json`): `environment`,
  `merchant_id`, and optionally `fee_bps`.

The schema is served from `pay.preznt.xyz`, whose reversed host is the handler
name, and is never served behind a redirect.

## INSTRUMENT_ACQUISITION

1. The platform reads the merchant's profile and checks that the
   `xyz.preznt.pay` entry names the merchant's Preznt `merchant_id` and that
   its `schema` URL satisfies the namespace rule.
2. The platform creates the checkout with the merchant as usual.
3. The platform calls **`POST https://<preznt api>/ucp/v1/tokenize`** as the
   signed-in buyer:

   ```json
   { "binding": { "type": "dev.ucp.shopping.checkout", "id": "<checkout id>" },
     "amount": 3500, "currency": "USD", "merchant_id": "<merchant id>" }
   ```

   `amount` is the checkout total in minor units (cents). Preznt checks buyer
   KYB, merchant KYB, sanctions and the buyer's balance (amount plus fee), then
   answers `202` with `{ "status": "pending_approval", "authorization_id",
   "checkout_status": "requires_escalation", "expires_at" }`.
4. Until the buyer approves, the platform treats the checkout as
   **`requires_escalation`**. Preznt shows the buyer an approval card with the
   merchant, items, amount and fee.
5. The owner approves and signs **one** USDC transfer with their own wallet: the
   merchant's full amount to the merchant's wallet, plus Preznt's fee **on top**
   to Preznt. Preznt verifies the signed transaction is exactly that transfer,
   pays the network fee and sends it.
6. Once the transfer confirms, the platform fetches the credential with
   **`GET /ucp/v1/tokenize/<authorization_id>`**:

   ```json
   { "type": "preznt_pay_token", "token": "pzt_…", "expiry": "2026-11-26T18:15:00.000Z" }
   ```

   - at least 128 bits of entropy (256 in practice), stored by Preznt only as a hash
   - single use, valid for at most 15 minutes
   - issued to exactly one merchant and bound to exactly one checkout
   - fetching it again replaces an unused token
7. The platform completes the checkout with the instrument (see
   `schemas/v1/instrument.json`):

   ```json
   { "id": "pzt_instr_…", "handler_id": "preznt_usdc_devnet", "type": "preznt_pay",
     "display": { "description": "Pay with Preznt (USDC, devnet)" },
     "credential": { "type": "preznt_pay_token", "token": "pzt_…", "expiry": "…" } }
   ```

## PROCESSING

On `complete`, the merchant redeems the token:

```http
POST https://<preznt api>/ucp/v1/charges
Authorization: Bearer <merchant API key>
Idempotency-Key: <unique per charge, e.g. checkout:<id>>
Content-Type: application/json

{ "token": "pzt_…", "binding": { "type": "dev.ucp.shopping.checkout", "id": "<checkout id>" }, "amount": 3500 }
```

Preznt checks that the token was issued to this merchant, the binding matches
exactly, `amount` is no more than the buyer approved, and the token is unused
and unexpired. Success:

```json
{ "status": "succeeded", "charge_id": "pzc_…", "amount": 3500, "currency": "USD",
  "solana_tx": "<signature>", "explorer_url": "https://explorer.solana.com/tx/…?cluster=devnet",
  "environment": "devnet" }
```

**Idempotency.** The same `Idempotency-Key` with the same body replays the
first response, success or failure. The same key with a different body is
`409 idempotency_conflict`.

**Errors** use UCP messages (`{ "status": "failed", "messages": [{ "type": "error", "code", "content", "severity" }] }`):

| Situation | HTTP | code | severity |
| --- | --- | --- | --- |
| Token unknown, used, expired or issued to another merchant | 402 | `payment_failed` | `unrecoverable` |
| Binding mismatch, or amount above what the buyer approved | 402 | `payment_failed` | `requires_buyer_review` |
| Same Idempotency-Key, different body | 409 | `idempotency_conflict` | `unrecoverable` |
| Missing or bad merchant API key | 401 | `unauthorized` | `unrecoverable` |
| Malformed request | 400 | `invalid_request` | `unrecoverable` |

A merchant maps any non-success to UCP `payment_failed` on its `complete`.

**Settlement.** In the preview, funds move when the buyer signs (step 5), before
the charge; the charge captures and records it. There is no hold or escrow yet,
so a charge for less than the approved amount does not return the difference.

## Security

- **No money moves without KYB on both sides.** Buyer and merchant businesses
  must have passed verification; wallets are screened.
- **The buyer signs every transfer.** Preznt never holds a buyer key and never
  signs for the buyer. The relayer only adds its fee-payer signature to a
  transaction it has checked is the approved transfer.
- **Agents can't approve.** A platform can request a payment, never approve
  one; approval is the owner's, in Preznt.
- **Tokens** are random, single use, short-lived, bound to one merchant and one
  checkout, stored hashed, and never shown to the model driving the agent.
- **Merchant API keys** are stored hashed and shown once.
- **Devnet only.** The preview has no mainnet code path.

## Next

Not in the preview; planned before mainnet:

- OAuth 2.0 for platforms other than the Preznt agent (today: a Preznt session)
- RFC 9421 HTTP message signatures on tokenize and charge requests, verified against `keys[]`
- Signed webhooks for charge and settlement events
- Refunds and partial captures
- An on-chain escrow program, so funds are held from approval until the charge
- Standing buyer mandates (limits per merchant and period) in place of per-payment approval
- AP2 mandate support (`dev.ucp.common.payment.ap2_mandate`)
