Payment Methods

Batch Payment#

This page is for HTTP Sellers. Batch payment is currently only supported for HTTP Sellers.

For definitions and the underlying protocol, see Core Concepts · Batch payment. This page focuses on integration.


When it fits#

Your businessSuitable
Per-call amount is very low (cents to fractions of a cent)
Very high call frequency (tens to hundreds per minute)
Response speed is more important than instant on-chain settlement
Resources are non-revocable, must wait for on-chain confirmation before delivery❌ Use One-time payment with syncSettle: true
Low call volume / low frequency❌ Use One-time payment
Per-call consumption is unpredictable (per-token / per-byte billing)❌ Use Pay-as-you-go

Prerequisites#

Batch payment requires the Buyer to use Agentic Wallet. Ordinary EVM wallets cannot use this mode.

Why: Batch payment depends on two key pieces of infrastructure:

  • Session Key: a temporary signing key generated by Agentic Wallet, allowing the Agent to sign autonomously within the authorized scope without invoking the main private key on every call
  • TEE: a hardware-isolated secure environment where OKX runs batch settlement, ensuring signature data cannot be tampered with or stolen

Business flow#

Key timing difference (vs. One-time payment): the Buyer gets the resource immediately, and the Seller also confirms receipt immediately (verified signature = received payment); on-chain settlement happens asynchronously.


Seller integration#

SDK Status

✅ Node.js / Rust / Go / Java SDKs are all available

Each tab below is a single-language complete implementation (aggr_deferred scheme). The architecture is composed of four pieces: Facilitator client (with OKX API Key) → Resource Server (register schemes) → Routes config (accepts array) → middleware mount.

typescript
import express from "express";
import {
  paymentMiddleware,
  x402ResourceServer,
} from "@okxweb3/x402-express";
import { AggrDeferredEvmScheme } from "@okxweb3/x402-evm/aggr-deferred/server";
import { OKXFacilitatorClient } from "@okxweb3/x402-core";

const app = express();
const NETWORK = "eip155:196";
const PAY_TO = process.env.PAY_TO_ADDRESS || "0xYourSellerWallet";

const facilitatorClient = new OKXFacilitatorClient({
  apiKey: "OKX_API_KEY",
  secretKey: "OKX_SECRET_KEY",
  passphrase: "OKX_PASSPHRASE",
});

const resourceServer = new x402ResourceServer(facilitatorClient);
resourceServer.register(NETWORK, new AggrDeferredEvmScheme());

app.use(
  paymentMiddleware(
    {
      "GET /api/realtime": {
        accepts: [
          {
            scheme: "aggr_deferred",
            network: NETWORK,
            payTo: PAY_TO,
            price: "$0.001",
          },
        ],
        description: "Realtime data",
        mimeType: "application/json",
      },
    },
    resourceServer,
  ),
);

app.get("/api/realtime", (_req, res) => {
  res.json({ data: "realtime data" });
});

app.listen(4000);

Buyer integration#

The Buyer must use Agentic Wallet and pre-authorize a Session Key.

  1. 1
    Install Agentic Wallet

    Create Agentic Wallet through Onchain OS Skill (email login, no seed phrase needed); the private key is generated and held inside a TEE. See Agentic Wallet installation.

  2. 2
    Authorize a Session Key

    Set the Agent's signing scope:

    • Cap: start with a small amount (e.g. 10 USD₮0)
    • Validity: start with a short period (e.g. 24 hours)
    • Scope: bind to a specific Seller domain / endpoint
  3. 3
    High-frequency calls

    The Agent signs autonomously within the authorized scope; each signature is millisecond-fast, and the call flow does not need the Buyer's main private key.


Limits and trade-offs#

When not to use Batch payment
  • Large per-call amount, must wait for on-chain confirmation before delivery: Aggregated on-chain has latency; resources may be delivered before on-chain confirmation (you've already counted it as received, but on-chain hasn't completed) → use One-time payment with syncSettle: true
  • Buyer doesn't want to install Agentic Wallet: Batch payment requires Agentic Wallet → fall back to One-time payment (any EIP-3009 wallet works)
  • Per-call consumption is unpredictable: use Pay-as-you-go
  • Need revenue splits: Batch payment doesn't yet support splits; for small-amount scenarios needing splits, use One-time payment with charge

Advanced#

Coexisting with exact#

Make the same route serve both buyer types — declare both exact and aggr_deferred in the accepts array and let the buyer wallet auto-select by capability.

Buyer typeScheme usedOn-chain timing
Plain EIP-3009 walletexactInstant
Agentic Wallet, high-frequency callsaggr_deferredAsync aggregation

charge (with splits) is coming soon; once available, you can append it to the accepts array for split-required scenarios.


Next#