paygate 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +61 -45
  2. package/package.json +8 -7
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # paygate
2
2
 
3
- Gate your API with USDC micropayments in one line of code. AI agents pay per-request using the [x402 protocol](https://x402.org) **no accounts, no API keys, no subscriptions needed.**
3
+ Accept agent payments on an existing API with HTTP 402 and USDC settlement. PayGate handles the x402 challenge, calls the ArisPay facilitator, and lets your handler run only after payment settles.
4
4
 
5
- Works with Express and Fastify. Settlement and gas sponsorship handled by ArisPay.
5
+ Use the hosted proxy for zero-code acceptance, or install this package when you want the 402 flow on your own domain.
6
6
 
7
7
  ## Install
8
8
 
@@ -17,16 +17,19 @@ import express from 'express';
17
17
  import { paygate } from 'paygate/express';
18
18
 
19
19
  const app = express();
20
- const pw = paygate({ wallet: '0xYourUSDCWallet' });
20
+
21
+ const pw = paygate({
22
+ merchantId: process.env.PAYGATE_MERCHANT_ID,
23
+ });
21
24
 
22
25
  // $0.10 per request
23
- app.get('/api/data', pw({ price: 0.10 }), (req, res) => {
26
+ app.get('/api/data', pw({ priceCents: 10 }), (req, res) => {
24
27
  res.json({ data: 'premium content' });
25
28
  });
26
29
 
27
30
  // Dynamic pricing
28
31
  app.post('/api/analyze', pw({
29
- price: (req) => req.body.depth === 'deep' ? 0.50 : 0.10,
32
+ priceCents: (req) => req.body.depth === 'deep' ? 50 : 10,
30
33
  description: 'AI analysis',
31
34
  }), (req, res) => {
32
35
  res.json({ result: '...' });
@@ -43,18 +46,23 @@ import paygate from 'paygate/fastify';
43
46
 
44
47
  const app = Fastify();
45
48
 
46
- await app.register(paygate, { wallet: '0xYourUSDCWallet' });
49
+ await app.register(paygate, {
50
+ merchantId: process.env.PAYGATE_MERCHANT_ID,
51
+ });
47
52
 
48
- // Auto-paywall via route config
53
+ // Route-config-driven paywall
49
54
  app.get('/api/data', {
50
- config: { x402: { price: 0.10 } }
55
+ config: { paygate: { priceCents: 10 } },
51
56
  }, async (req, reply) => {
52
57
  reply.send({ data: 'premium content' });
53
58
  });
54
59
 
55
60
  // Or imperative API
56
61
  app.get('/api/research', async (req, reply) => {
57
- const { paid } = await req.x402Pay({ price: 0.05, description: 'Research query' });
62
+ const { paid } = await req.paygatePay({
63
+ priceCents: 5,
64
+ description: 'Research query',
65
+ });
58
66
  if (!paid) return; // 402 challenge already sent
59
67
  reply.send({ results: '...' });
60
68
  });
@@ -62,65 +70,73 @@ app.get('/api/research', async (req, reply) => {
62
70
  await app.listen({ port: 3000 });
63
71
  ```
64
72
 
73
+ ## Hosted proxy
74
+
75
+ For a no-code merchant integration:
76
+
77
+ 1. Register at `https://paygate.arispay.app/merchant-register`.
78
+ 2. Add a primary USDC payout wallet in the PayGate dashboard.
79
+ 3. Add a product with `method`, `path`, `targetUrl`, and `priceCents`.
80
+ 4. Agents call `https://paygate.arispay.app/{slug}{path}`.
81
+
82
+ Example agent test:
83
+
84
+ ```bash
85
+ npx payagent pay https://paygate.arispay.app/acme/forecast?city=London
86
+ ```
87
+
88
+ API equivalent for product creation:
89
+
90
+ ```bash
91
+ curl -X POST https://api.arispay.app/v1/merchants/me/products \
92
+ -H 'authorization: Bearer mp_live_…' \
93
+ -H 'content-type: application/json' \
94
+ -d '{
95
+ "method": "GET",
96
+ "path": "/forecast",
97
+ "targetUrl": "https://api.acme.com/v1/forecast",
98
+ "priceCents": 2,
99
+ "description": "Weather forecast"
100
+ }'
101
+ ```
102
+
65
103
  ## How it works
66
104
 
67
105
  ```
68
- Agent Your API ArisPay Facilitator
106
+ Agent Your API / Proxy ArisPay Facilitator
69
107
  │ │ │
70
108
  ├─── GET /api/data ──────►│ │
71
- │ │ (no X-Payment header)
109
+ │ │ no X-Payment header
72
110
  │◄── 402 + requirements ──┤ │
73
111
  │ │ │
74
- (agent signs EIP-3009 USDC transfer)
112
+ │ agent signs USDC transfer authorization
75
113
  │ │ │
76
114
  ├─── GET /api/data ──────►│ │
77
115
  │ + X-Payment header ├── POST /settle ────────►│
78
116
  │ │ │ verify + settle
79
- │ │◄── { success, txHash } ─┤ sponsor gas
117
+ │ │◄── { success, txHash } ─┤
80
118
  │◄── 200 + data ──────────┤ │
81
119
  ```
82
120
 
83
- The agent SDKs ([payagent](https://npmjs.com/package/payagent)) handle the signing automatically agents don't need to understand the protocol.
121
+ The agent-side [`payagent`](https://www.npmjs.com/package/payagent) CLI and SDK handle the 402 loop automatically.
84
122
 
85
123
  ## Config
86
124
 
87
125
  | Option | Required | Default | Description |
88
126
  |---|---|---|---|
89
- | `wallet` | Yes | — | Your USDC wallet address |
90
- | `network` | No | `eip155:84532` | CAIP-2 network ID (Base Sepolia testnet) |
91
- | `asset` | No | Auto | USDC contract address |
92
- | `facilitatorUrl` | No | ArisPay production | Override the settlement facilitator |
93
- | `timeout` | No | `30000` | Facilitator call timeout (ms) |
94
-
95
- ## Networks
96
-
97
- | Network | ID | Status |
98
- |---|---|---|
99
- | Base Sepolia | `eip155:84532` | **Default (testnet)** |
100
- | Base Mainnet | `eip155:8453` | Production |
101
- | Ethereum | `eip155:1` | Production |
102
- | Polygon | `eip155:137` | Production |
103
-
104
- ## Agent-side
105
-
106
- Agents use [payagent](https://npmjs.com/package/payagent) — a drop-in fetch wrapper that handles 402 payments automatically:
127
+ | `merchantId` | Yes | — | PayGate merchant ID from the dashboard. The SDK fetches payout rail, wallet, asset, facilitator, and trust policy from ArisPay. |
128
+ | `apiUrl` | No | `https://api.arispay.app` | Override ArisPay API URL for staging/self-hosting. |
129
+ | `facilitatorUrl` | No | Manifest value | Compatibility override. In v3, merchant capabilities are authoritative. |
130
+ | `timeout` | No | `30000` | ArisPay/facilitator call timeout in ms. |
131
+ | `cacheTtlMs` | No | `300000` | Merchant capability cache TTL. |
107
132
 
108
- ```bash
109
- npm install payagent
110
- ```
133
+ ### Compatibility mode
111
134
 
112
- ```js
113
- import { createPayagentFetch } from 'payagent';
135
+ 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.
114
136
 
115
- const fetch = createPayagentFetch({
116
- apiKey: 'ap_live_...', // ArisPay API key
117
- agentId: 'agent-123', // Your agent ID
118
- });
137
+ ## Networks
119
138
 
120
- // This call will automatically handle any 402 challenges
121
- const res = await fetch('https://your-api.com/api/data');
122
- const data = await res.json();
123
- ```
139
+ PayGate currently settles USDC on EVM networks advertised by your merchant capability manifest. Base mainnet (`eip155:8453`) is the recommended production network.
124
140
 
125
141
  ## License
126
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paygate",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Accept payment from AI agents in two lines of code. Gate any Express or Fastify route with an x402 paywall backed by ArisPay — merchants don't hold keys, agents pay per-request, USDC settles in seconds on Base mainnet.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,6 +19,12 @@
19
19
  "types": "./dist/fastify.d.ts"
20
20
  }
21
21
  },
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "dev": "tsc --watch",
25
+ "type-check": "tsc --noEmit",
26
+ "prepublishOnly": "pnpm build"
27
+ },
22
28
  "dependencies": {},
23
29
  "peerDependencies": {
24
30
  "express": ">=4.0.0",
@@ -67,10 +73,5 @@
67
73
  "repository": {
68
74
  "type": "git",
69
75
  "url": "https://github.com/arispay-inc/ArisPay"
70
- },
71
- "scripts": {
72
- "build": "tsc",
73
- "dev": "tsc --watch",
74
- "type-check": "tsc --noEmit"
75
76
  }
76
- }
77
+ }