Sign In

paygate

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paygate

Accept payment from AI agents in two lines of code. Gate any Express or Fastify route with an x402 paywall — USD (USDC) or EUR (EURC) pricing, settled on Base mainnet via ArisPay's facilitator.

Source
npmnpm
Version
5.3.1
Version published
Weekly downloads
449
498.67%
Maintainers
1
Weekly downloads
 
Created
Source

paygate

Create agent-payable offers with HTTP 402 and USDC settlement. PayGate handles the x402 challenge, calls the ArisPay facilitator, and lets your handler run only after payment settles.

API endpoint offers are live today. Use the hosted proxy for zero-code acceptance, or install this package when you want the 402 flow on your own domain.

Install

npm install paygate

Express

import express from 'express';
import { paygate } from 'paygate/express';

const app = express();

const pw = paygate({
  merchantId: process.env.PAYGATE_MERCHANT_ID,
});

// $0.10 per request
app.get('/api/data', pw({ priceCents: 10 }), (req, res) => {
  res.json({ data: 'premium content' });
});

// Dynamic pricing
app.post('/api/analyze', pw({
  priceCents: (req) => req.body.depth === 'deep' ? 50 : 10,
  description: 'AI analysis',
}), (req, res) => {
  res.json({ result: '...' });
});

app.listen(3000);

Fastify

import Fastify from 'fastify';
import paygate from 'paygate/fastify';

const app = Fastify();

await app.register(paygate, {
  merchantId: process.env.PAYGATE_MERCHANT_ID,
});

// Route-config-driven paywall
app.get('/api/data', {
  config: { paygate: { priceCents: 10 } },
}, async (req, reply) => {
  reply.send({ data: 'premium content' });
});

// Or imperative API
app.get('/api/research', async (req, reply) => {
  const { paid } = await req.paygatePay({
    priceCents: 5,
    description: 'Research query',
  });
  if (!paid) return; // 402 challenge already sent
  reply.send({ results: '...' });
});

await app.listen({ port: 3000 });

Hosted proxy

For a no-code merchant integration:

  • Register at https://paygate.arispay.app/merchant-register.
  • Add a primary USDC payout wallet in the PayGate dashboard.
  • Create an API endpoint offer with method, path, targetUrl, and priceCents.
  • Agents call https://paygate.arispay.app/{slug}{path}.

Example agent test:

npx payagent pay https://paygate.arispay.app/acme/forecast?city=London

API equivalent for offer creation:

curl -X POST https://api.arispay.app/v1/merchants/me/products \
  -H 'authorization: Bearer mp_live_…' \
  -H 'content-type: application/json' \
  -d '{
    "method": "GET",
    "path": "/forecast",
    "targetUrl": "https://api.acme.com/v1/forecast",
    "priceCents": 2,
    "description": "Weather forecast"
  }'

How it works

Agent                    Your API / Proxy       ArisPay Facilitator
  │                         │                        │
  ├─── GET /api/data ──────►│                        │
  │                         │  no X-Payment header   │
  │◄── 402 + requirements ──┤                        │
  │                         │                        │
  │   agent signs USDC transfer authorization        │
  │                         │                        │
  ├─── GET /api/data ──────►│                        │
  │    + X-Payment header   ├── POST /settle ────────►│
  │                         │                        │ verify + settle
  │                         │◄── { success, txHash } ─┤
  │◄── 200 + data ──────────┤                        │

The agent-side payagent CLI and SDK handle the 402 loop automatically.

Config

OptionRequiredDefaultDescription
merchantIdYesPayGate merchant ID from the dashboard. The SDK fetches payout rail, wallet, asset, facilitator, and trust policy from ArisPay.
apiUrlNohttps://api.arispay.appOverride ArisPay API URL for staging/self-hosting.
facilitatorUrlNoManifest valueCompatibility override. In v3, merchant capabilities are authoritative.
timeoutNo30000ArisPay/facilitator call timeout in ms.
cacheTtlMsNo300000Merchant capability cache TTL.
selfSettleNo{ privateKey, rpcUrl? }. Submit settlements from your own funded key: verification runs against the facilitator (free), then the SDK submits the EIP-3009 transferWithAuthorization itself. You pay chain gas (~$0.001/settle on Base) and nobody else — no facilitator fee, no subsidy that ends. The key is any funded EOA; it pays gas only and never receives or holds customer funds. Replay protection is on-chain (the EIP-3009 nonce). Defaults to public Base RPCs; set rpcUrl for other networks or your own provider.

Self-settle

const pw = paygate({
  merchantId: "m_123",
  selfSettle: { privateKey: process.env.SETTLE_KEY! }, // funded with a few $ of Base ETH
});

Requires the optional peer dependency ethers (v6): npm install ethers. The facilitator path never loads it.

Verified end-to-end against Circle's real USDC on Base Sepolia (2026-07-19): a signed EIP-3009 authorization settled on-chain via submitSelfSettle — 0.01 USDC transferred, gas paid by the self-settle key — tx 0xe151fe05…dda4cb0 (AuthorizationUsed + Transfer events). This confirms Circle USDC accepts the 9-arg split-signature transferWithAuthorization form the SDK submits.

Compatibility mode

Older code that passes wallet and network still works through a v2 shim, but new integrations should use merchantId and configure payout wallets in the dashboard. The shim will be removed in a future major version.

Networks

PayGate currently settles USDC on EVM networks advertised by your merchant capability manifest. Base mainnet (eip155:8453) is the recommended production network.

Facilitator

PayGate settles through facilitator.arispay.app by default — an open x402 facilitator, live on Base mainnet, settling USDC and EURC. No facilitator fee and no gas subsidy: the seller pays chain gas and nobody else (self-settle with your own key, or the default relayer path). The live policy is machine-readable at /supported; the discovery document is at /facilitator. Point facilitatorUrl elsewhere if you run your own.

License

MIT

Keywords

x402

FAQs

Package last updated on 19 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts